Welcome to Help4Web.co.uk - Web Design Help, Html Tutorial, Php, Asp , SQL help and CCNA, MCSE definitions!
Google
Webkpop-web.com

     Main Menu

· Home
· Free Downloads
· Computing FAQ
· Contact Us
· Free Software Downloads
· Tech Forum
· Technology News
· Web Design Help
· Web Links
· Your Online Account
· Your PM



     Web Browser


     Website Links
Supermediastore! #1 in Computer media & Accessory

White Papers IT
Learn Korean
Chinese Pop Music
Advertise Kpop
Korean Pop Site Map
Web Design
Pop Music
Chinese Girls
HK Pop Korean Music
Lee Hyori
Hyori
Boa Park Ji Yoon
Baby Vox YG Family
Jeon Ji Hyun
1 Tym Ha Ji Won
Shyne Rain Bi
Shin Mina SM Town
Fly to the Sky
Korean Girls and Models
Nicholas Tse
161 Clan
보아
Edison Chen
Sung Hi Lee
Shinhwa
Andy Lau Jay Chou
White Papers
Case Study SES
Kelly Chen
Liu Yi Fei Sammi Cheng
Jordan Chan Music
Computer Jobs IT

Computer Help Forum and Programming Advice :: View topic - I need help with assembly code
 Forum FAQForum FAQ   SearchSearch   UsergroupsUsergroups   ProfileProfile   Log inLog in 

I need help with assembly code

 
Post new topic   Reply to topic    Computer Help Forum and Programming Advice Forum Index -> General Programming
View previous topic :: View next topic  
Author Message
sensini
Web Design Newbie
Web Design Newbie


Joined: Oct 18, 2005
Posts: 10

PostPosted: Thu Mar 16, 2006 10:14 pm    Post subject: I need help with assembly code Reply with quote

i want to load an image from the dos command line: like LSB.exe image.bmp
here is the program source files (HERE THE LOADING OF THE IMAGE IS DONE BY OPEN WINDOW)
please help me i need to do command line execution of the program....
the LSB.asm saves the result image but i want it displayed in a window


please help i dont know any thing about assembly..

the code is the following
callW macro x
extrn x:PROC
call x
endm

.486
.model flat


;-------------- Data of the Program --------------

.data

;----------------- structures --------------------

openfilename_struct:
lStructSize dd openfilename_struct_size
hwndOwner dd 0
hInstance dd 0
lpstrFilter dd offset filter
lpstrCustomFilter dd 0
nMaxCustFilter dd 0
nFilterIndex dd 0
lpstrFile dd offset namebuffer
nMaxFile dd 255
lpstrFileTitle dd 0
nMaxFileTitle dd 32
lpstrInitialDir dd 0
lpstrTitle dd 0
Flags dd 1000h+4h+200000h
nFileOffset dw 0
nFileExtension dw 0
lpstrDefExt dd 0
lCustData dd 0
lpfnHook dd 0
lpTemplateName dd 0
openfilename_struct_size equ $-offset openfilename_struct

;------------- file/memory Essentials --------------------

filter db "Bmp files *.bmp",0,"*.bmp",0,0
namebuffer db 255 dup(0)
result_title db "BMP2LSB", 0
no_bmp db "This is not a Bitmap Image",0

file_handle2 dd ?
file_size dd ?
file_handle dd ?
file_mem_buffer dd ?
file_nb_bytes_read dd ?
pixels_data_start dd ?



;-------------- Code of the Program --------------
.code

program:

;-------- choose a file -------------

push offset openfilename_struct
callW GetOpenFileNameA
test eax, eax
jz end

;-------- open it --------------

push 0
push 80h
push 3
push 0
push 0
push 80000000h+40000000h
push dword ptr [lpstrFile]
callW CreateFileA
inc eax
jz end
dec eax
mov file_handle, eax

;---------- get its size ---------

push 0
push dword ptr file_handle
callW GetFileSize
inc eax
jz close_file
dec eax
mov file_size, eax

;--------- alloc memory for file --------

mov eax, file_size
add eax, 1024
push eax
push 40h
callW LocalAlloc
test eax, eax
jz close_file
mov file_mem_buffer, eax

;------- read entire file ------------

push 0
push offset file_nb_bytes_read
push file_size
push file_mem_buffer
push file_handle
callW ReadFile
test eax, eax
jz free_memory
mov eax, file_nb_bytes_read
cmp eax, file_size
jnz free_memory

;-------- find BMP signature in header ---------

mov esi, file_mem_buffer
lodsw
cmp ax, "MB"
jne trouble

;------- find number of bits per pixel ------

add esi, 8
lodsd
add eax, file_mem_buffer
mov pixels_data_start, eax
add esi, 14
lodsw
cmp ax, 24
je this_looks_like_a_bmp

;-------- not 24-bits BMP -----------

trouble:
push 0
push offset result_title
push offset no_bmp
push 0
callW MessageBoxA
jmp free_memory

;------ Enhance LSBs -----------

this_looks_like_a_bmp:

mov eax, pixels_data_start
sub eax, file_mem_buffer
mov ecx, file_size
sub ecx, eax

mov esi, pixels_data_start
mov edi, esi

change_all:
lodsb ;get byte
and al, 1 ;eliminate everything except LSB
jz no_fill ;if 0, do nothing
mov al, 0ffh ;if 1, replace by 255
no_fill:
stosb ;put the byte back
loop change_all

;------- add _LSB to the name ----------------

mov esi, offset namebuffer
mov ecx, 255

find_extension:
mov al, [esi+ecx]
cmp al, "."
je modify_name
loop find_extension

modify_name:
mov eax, "BSL_"
mov [esi+ecx], eax
mov eax, "pmb."
mov [esi+ecx+4], eax

;------- open a new file on the disk ----------------

push 0
push 80h
push 2
push 0
push 0
push 40000000h
push offset namebuffer
call CreateFileA
mov file_handle2, eax

;------- write buffer in it ----------------

push 0
push offset file_nb_bytes_read
push file_size
push file_mem_buffer
push file_handle2
callW WriteFile

;------- close it ----------------

push file_handle2
callW CloseHandle
jmp free_memory

;------- close memory ----------------

free_memory:
push file_mem_buffer
callW LocalFree

;-------- close file ----------

close_file:
push dword ptr file_handle
callW CloseHandle

;----------- exit ----------

end:
push -1
callW ExitProcess

end program
Back to top
View user's profile Send private message
ci5co
Web Design Newbie
Web Design Newbie


Joined: Aug 18, 2004
Posts: 89

PostPosted: Thu Mar 16, 2006 10:15 pm    Post subject: Reply with quote

WTF are you doing with all this code if you don't know bupkis about ASM? I suggest you pick up a book and learn the basics before you ask any questions. If this is really urgent, go look for whoever dumped you this job and tell the person you know 0% of ASM.
_________________
White Papers

Internet Marketing

Boku
Back to top
View user's profile Send private message Visit poster's website
sensini
Web Design Newbie
Web Design Newbie


Joined: Oct 18, 2005
Posts: 10

PostPosted: Thu Mar 16, 2006 10:16 pm    Post subject: Reply with quote

sorry but the coder email is not in use

this program is loading a 24-bit bitmap image and then extracts the LSB then it saves the result image in the same name of the loaded image with _LSB extention
the only thing i need is to load the image from the comand line like this LSB.exe image.bmp
and then displays the result image rather than saving it.

i need it badly because my project uses this command line feature...

sorry if i was annoying..
but if you can help me please do..
thanks
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Computer Help Forum and Programming Advice Forum Index -> General Programming All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum







Learn Chinese | Learn cantonese | Learn Mandarin | Grace Park | Party Organisers | Kaila yu | Phone Card | Twins | Chinese Society | Loans UK | BokuMaro | CV Help Book | Chinese Wife | Korean Singles | British Born Chinese | Bae Yong Jun | Speak Korean | Chinese Models | Music | Information Security Management | Maritime Greenwich Campus | Covering Letters Help | Chinese Music | Jang Nara | SES | YG Family | Learn Korean | Firewall Definition | Server Definition | Wireless Network Definition | E-Commerce Definition | Sales Leads | Application Firewall | CCNA definitions | Research Papers | Webcast | CV Help

Author KPop Music :- Jon Bock ( Chinese Pop Music Learn Korean )
Produced by Kpop-Web Design Associates, all rights not reserved.
Internet Marketing and Search Engine Optimisation Software Defined Radio