Log in

View Full Version : converting string to offset


ud49
August 2nd, 2002, 00:22
hi there guys
those of you who code keygens are familiar with the thingy:

push eax
push offset format
push offset temp
Call _wsprintfA

in which the offset of eax is converted to string and stored at temp

ex: eax is F123AB42, using the above code memory at temp will hold F123AB42

my question is, how can I reverse that.
I mean how can I transform the string entered in a keygen to eax's offset?

ex: user entered C12345AE and i want eax to have address C12345AE

is there a special use of an api - a keypoint or do i have to write a function?

hope i could expressmyself
thx

Kayaker
August 2nd, 2002, 06:25
Hi

You may need to come up with your own routine for this. Retrieve it with GetDlgItemText and parse the string into dwords. Then convert ascii dwords to hex with a conversion routine. Take a look at the MASMv7 source for the 'htodw' conversion routine. Or use wsprintf again to convert to a hex dword. Then you can handle the extended string.

Or you could be tricky and put each dword back into the edit box control (SetDlgItemText), and retrieve it again with GetDlgItemInt. It will be converted for you

Kayaker

ZaiRoN
August 2nd, 2002, 10:18
hi!
hope this helps (is written with masm):
Code:

.386
.MODEL FLAT, STDCALL
option casemap :none

include \masm32\include\kernel32.inc
includelib \masm32\lib\kernel32.lib

; ZZZZZZZZZZ
.data
number db "C23F98A0",0 ; the string u want to convert

; ZZZZZZZZZZ
.code
main:
invoke GetModuleHandle, 0

xor eax, eax
xor ecx, ecx
lea esi, number
lodsb

@cycle:
cmp al, 3Ah
jb @number
sub al, 37h
jmp @do
@number:
sub al, 30h

@do:
xor ecx, eax

lodsb
test al, al
jz @end
rol ecx, 4

jmp @cycle

@end: ; here: eax = C23F98A0

end main ; game over!!!


ciao,
ZaiRoN

ud49
August 2nd, 2002, 23:58
oh thx a lot
i have come up with about the same thing on tasm before asking the question
but always came up eax bein 0C02030F etc
i guess xoring was the point