i cant seem to solve this easy problem... perhaps im too tired from work :) Anyway, here is want i want to do:

(This is sorta like a converter)

editbox1 contains Win32
editbox2 is empty

1. Get "W" from string Win32, convert W to decimal, add 100, convert it to hex and add it to a buffer.

2 Get "i" from string Win32, convert i to decimal, add 100, convert it to hex and add it to a buffer. (The buffer now contains the hex from #1 and #2 and so on...)

3 like above

4. like above

5. like above

6 SetDlgItemText the buffer to the empty editbox...

Thanks in advance
Posted on 2003-10-29 06:11:04 by Ni?o
Something like


.data
buffer db 64 dup (?)
.code
...
mov esi, offset buffer
mov edi, esi
invoke GetDlgItemText, hdlg, ID1, esi, 64
@@:
lodsb
test al, al
jz _out
add al, 100
stosb
jmp @B
_out:
invoke SetDlgItemText, hdlg,ID2, offset buffer

?
PS:Untested.
Posted on 2003-10-29 06:51:06 by roticv
doesnt work in a way :( i need the result in the editbox in hex format
Posted on 2003-10-29 07:06:06 by Ni?o
hmmm i found it only problem is when i convert i get 00's... for example i get 00000048 when i only need is 48.... how do i do that?
Posted on 2003-10-29 07:30:06 by Ni?o
Try this routine for to convert to hex, wrote it sometime back to remove the 0's:


dwtoh:
push eax
push ecx
mov ecx, 32
@@:
sub ecx, 4
jz @F
mov eax, edx
shr eax, cl
or eax, eax
jz @B
@@:
mov eax, edx
shr eax, cl
and eax, 01111y
cmp al, 0Ah
sbb al,69h
das
stosb
sub ecx, 4
jns @B
mov byte ptr[edi], 0
pop ecx
pop eax
retn

Input in edx, or unless you want to change the code and edi for the string to be stored...
Posted on 2003-10-29 08:12:14 by roticv
Afternoon, Ni?o.

This sounds suspiciously like a Key Generator.

If you'd like to NOT have this thread closed/removed, then I think it'd be appropriate for you to mention *exactly* what you are wanting to code this for.

Cheers,
Scronty
Posted on 2003-10-29 17:31:33 by Scronty
it is somewhat like a key generator. FOR MY SHAREWARE PROGRAM. :) so i guess it wont be illegal coz its for my software, right? if still in doubt i will post a copy of my program here...

anyway i came up with this code,


Posted on 2003-10-30 22:55:07 by Ni?o
Perhaps


mov esi,offset buffer1
mov edi, offset buffer3
Invoke GetDlgItemText,hWin,IDC_EDT1,esi,5
mov ecx, 4
@@:
lodsb
movzx edx, al
call dwtoh
dec ecx
jnz @B
mov byte ptr[edi], 0
Invoke SetDlgItemText,hWin,IDC_EDT2,offset buffer3
...

dwtoh:
push eax
push ecx
mov ecx, 32
@@:
sub ecx, 4
jz @F
mov eax, edx
shr eax, cl
or eax, eax
jz @B
@@:
mov eax, edx
shr eax, cl
and eax, 01111y
cmp al, 0Ah
sbb al,69h
das
stosb
sub ecx, 4
jns @B
pop ecx
pop eax
retn

Not too sure though, Have yet to test it...
Posted on 2003-10-30 23:59:15 by roticv