PDA

View Full Version : asm: Add trailing backslash at the end of string


DeViaN
June 24th, 2007, 09:52
Hello everybody

I"m trying to figure out how to add Trailing backslash ("\" at the of string,I"m not too good in assembler

I looked into ascii table,and backslash is "92" as byte.

I tried to load that string into esi and then Add that byte,but it aways adds at beginning of that string.

ESI: "C:"
ADD BYTE PTR DS:[ESI],92

Can please somebody help me ?

EDIT: I need to detect length of that string in ESI ? if yes please how.

blabberer
June 24th, 2007, 10:14
assuming you know where the original string is and can transfer it to edi this should do it



01013D79 B8 5C000000 MOV EAX,5C
01013D7E BF 705D0101 MOV EDI,calc.01015D70 ; ASCII "c:"
01013D83 47 INC EDI
01013D84 47 INC EDI
01013D85 AA STOS BYTE PTR ES:[EDI]
01013D86 90 NOP




before
[CODE]
01015D70 63 3A 00 c:.

after
01015D70 63 3A 5C c:\

[CODE]

add doesnt add strings it is a mathematical operator
it can do your work provided the original byte there was 0x00 if it was anything else it will add 92 to original contents

stosb == store byte at position
inc is to get to the place

you should use lstrcat() function instead of this jugglery

DeViaN
June 24th, 2007, 10:41
Thank you ,but if that string is dynamically changed at runtime ? how I can obtain length of that string ?

Can you please example of lstrcat ? please.

or Like That:
push esi
push eax
CALL DWORD PTR DS:[73421088]

esther
June 24th, 2007, 10:45
Hi,
"lots" of examples below
http://www.asmcommunity.net/board/index.php?topic=330.0

DeViaN
June 24th, 2007, 10:47
Oh Thank you so much .. I appreciated that