_SendtoNotepad proc _lpsz
local @hWinNotepad

pushad
invoke FindWindow,addr szDestClass,NULL
.if eax
mov ecx,eax
invoke ChildWindowFromPoint,ecx,20,20
.endif
.if eax
mov @hWinNotepad,eax
mov esi,_lpsz
@@:
lodsb
or al,al
jz @F
movzx eax,al
invoke PostMessage,@hWinNotepad,WM_CHAR,eax,1
jmp@B
@@:
.endif
popad
ret

_SendtoNotepad endp


this is a part of a exe,that send message to notpad,can you tell me what dose or al,al mean?i can not understand it in this part?thank youvery much!
Posted on 2003-08-21 06:29:13 by tomorrow
if the byte(char) is 0 (endstring I presume) it jumps forward, zero flag manipulation basically. since it doesn't seem to be from your own source and it's your first post here: make sure to read our rules, thx.
Posted on 2003-08-21 06:41:18 by Hiroshimator
yes,i am first post here,i know rule,ths
but why use or al,al,why not use or ax,ax,or use or eax ,eax
Posted on 2003-08-21 07:11:42 by tomorrow
Well lodsb changes the value of al. So if al = 0 (end of string), the jmp to the latter unnamed label is taken.
Posted on 2003-08-21 07:22:08 by roticv
but mov esi,_lpsz
lodsb make eds:esi to eax,why you tell me al.
why use lodsb buy not lodsd,think you tell me
Posted on 2003-08-21 07:26:23 by tomorrow
You are wrong about what lodsb does.

It does the same as the following


mov al, [esi]
inc esi

and does not affect edi. Why lodsw or lodsd is not used is because it is scanning *byte* by byte for the null-terminator, the signal of the end of a string.
Posted on 2003-08-21 07:34:03 by roticv
i don't understand "*byte* by byte for the null-terminator, the signal of the end of a string."mean,can you tell me?
why not use mov eax,,but use mov al,
what time use al,and what time use ax or eax,can you tell me ,DaGe
Posted on 2003-08-21 07:45:23 by tomorrow
Hi,

When I speak of string, I mean ascii strings. Ascii strings in windows are usually terminated with 0 (end of sting marked with 0h). Furthermore ascii strings are defined that one byte represent one character and the null-terminator take up 1 byte. So during the scanning for null-terminator, it is done byte by byte.

what time use al,and what time use ax or eax

Mostly for ascii strings, al is used, while for unicode strings ax is used. Sometimes lodsd is used for data manipulation. It depends on what it needed to be done. I can't exactly tell you the uses.

DaGe

I think I am younger than you. So maybe you should not call me DaGe.
:grin:
Posted on 2003-08-21 07:57:07 by roticv
tomorrow,

You write BYTE data in the .DATA section of a 32 bit file like this,


text db "This is a text",0

The data type is BYTE which is a sequence of BYTE values that you access by the name of the variable "text" in this example.

When you are reading or writing BYTE data you must work in the correct data size so when you write code like,


mov al, [esi]
inc esi

you are copying 1 byte from the ADDRESS in ESI to the BYTE size register AL.

When you use the old string instruction like LODSB, MOVSB etc ... you must know the correct registers to use with them. Normally these are ESI, EDI which are the source and destination indexes, and you use ECX as the counter and EAX/AX/AL as the data transfer register.

Just note that the old string instructions are slow and should be coded manually to get string operations up to speed.

Regards,
http://www.asmcommunity.net/board/cryptmail.php?tauntspiders=in.your.face@nomail.for.you&id=2f46ed9f24413347f14439b64bdc03fd
Posted on 2003-08-21 08:52:00 by hutch--
LODSB only changes 8 bits in the EAX register.
Unless the program clears the other 24 bits of the register before LODSB, you cannot guarantee that OR AX,AX or OR EAX,EAX will detect a zero byte (byte = 8-bit value).
Posted on 2003-08-21 22:35:21 by tenkey
i can not belive i can see you ,you a great man.
but my english is too bad,so i can not complet understand that you say
,but i belive i can see tomorrow.thankyou.
Posted on 2003-08-21 22:39:31 by tomorrow