The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: yaki on May 16, 2006, 05:24:18 PM

Title: beginner and strings
Post by: yaki on May 16, 2006, 05:24:18 PM
hi all
I am a beginner...and I think that works  with  strings is important.
I work with a sniffer and I have an output like 1DA0206548....and I would like to reformat this output to have %1D%A0%20%65%48

any help will be appreciate

Thanks in advance

yaki
Title: Re: beginner and strings
Post by: hutch-- on May 17, 2006, 03:10:16 AM
yaki,

I moved the topic to the Campus so you had a better chance of a reply. Just make sure that the question you are asking is not cracking or reverse engineering related as we cannot allow that under the forum rules.
Title: Re: beginner and strings
Post by: Ossa on May 17, 2006, 07:53:56 AM
Hi,

try this

ConvertString PROC pszOut:DWORD, pszIn:DWORD

push edi
push esi

mov edi, pszOut
mov esi, pszIn

@@:

mov ax, [esi]
or  al, al
jz  @F
or  ah, ah ; These lines aren't needed if the input
jz  @F ; string is certain to be even in length

shl eax, 8
mov al, '%'
mov [edi], eax

add edi, 3
add esi, 2
jmp @B

@@:

mov [edi], byte ptr 0

pop esi
pop edi

ret
ConvertString ENDP


It's not optimised or anything, but it works.

Hope that helps,
Ossa
Title: Re: beginner and strings
Post by: yaki on May 17, 2006, 06:35:18 PM
hi
it is not the cracking or hacking but a simple strings manipulation.
thanks Ossa