hi i am quite new to asm for windows so sorry for any stupidness you see...

i am writing a small prog to take a name then calculate key from this.

below i attach source for generation routine. window, edit boxes, button are all working ok; the routie called from clicking BUTTON.

really i need to know how to take values from box such as length and compare to values in registers. i try assign names in .data? section then use the equates against register (ie. cmp eax,VARIABLE) but get error in MASM assembly :(

i played with this for few hours before decide ask your HELP :) :)

here is source, only "snapshot" in time- modifyed and probably modified still before your read.


[color=red][i]errors in red[/i][/color]

xor ebx,ebx ;ebx==0
xor ecx,ecx ;ecx==0
xor edx,edx ;edx==0
[color=red]mov ecx, 0x0A ;ecx==0x0a[/color]

invoke GetDlgItemTextA, EditClass1Name, Edit1ID,Buffer,NULL ;get name

;--------------test for name in box will go here

[color=red]mov NameLen,eax[/color]
idiv ecx
xor edx,ebx
add edx, 00000002

[color=red]cmp dl,0x0a[/color]
jl goooo
[color=red]sub dl,0x0a[/color]
mov [edi+ebx], dl
inc ebx
[color=red]cmp ebx,NameLen[/color]
jne calcs

[color=red]mov ReturnBuff,edi[/color]

SetDlgItemTextA,EditClass2Name, Edit2ID,[color=red] ReturnBuff


actually after check the message here i see big errors in calc but same questions as above are still here :(
Posted on 2003-07-19 12:08:53 by wilson
rea crackme 1 huh?

hex value should end with h like for example 0x0A should be 0Ah.
Posted on 2003-07-19 12:34:03 by roticv
maybe.... lolz, i saw another old topic about crackme's get shut down for forum rules :)
anycase the job was done, this is just to help me in ASM- try to learn from both ends...

ok thanks, half my errors are gone :)

but how can i make a variable/equate available to arithmatic such as cmp/add etc?

i took name in as "Buffer" (assigned in .data?), now need to manipulate the data in "Buffer".
now i want to do things like
cmp eax,Buffer

MASM tells me "invalid instruction operands"...
Posted on 2003-07-19 13:04:26 by wilson
How are Buffer and NameLen defined?
Posted on 2003-07-20 06:19:42 by Eóin
i have defined them in .data? eg Buffer db 20 dup (?)
Posted on 2003-07-22 07:10:21 by wilson
ok i been playing more, thanks roticv for "pointer" in email ;)
now i got an assembled program but it crashes when run... :(
i ran debug and found the error line (in red) but dont know why that happens/how to stop this?
i use masm, both inbuffer and outbuffer assigned in .data?

invoke GetWindowText, hwndINbox,ADDR inbuffer,512
mov esi, OFFSET inbuffer
lea edi, OFFSET outbuffer
mov ecx, LENGTHOF inbuffer
add ecx,esi
mov eax, [esi]
inc esi
;---here is algo
inc al ;simple for testing :)
;---end algo
[color=red]mov [edi],al[/color]
inc edi
cmp edi,ecx
jne gooo
invoke SetWindowText, hwndOUTbox, ADDR outbuffer
Posted on 2003-07-23 15:39:46 by wilson
Shouldn't it be

invoke GetWindowText, hwndINbox,ADDR inbuffer,512
mov esi, OFFSET inbuffer
;lea edi, OFFSET outbuffer
mov edi, offset outbuffer
;mov ecx, LENGTHOF inbuffer
;add ecx,esi
mov eax, [esi]
inc esi
;---here is algo
inc al ;simple for testing
;---end algo
mov [edi],al
inc edi
cmp edi,SIZEOF inbuffer
jne gooo
invoke SetWindowText, hwndOUTbox, ADDR outbuffer

or something like that...
Posted on 2003-07-24 02:38:45 by roticv
just tryed that but same problem (prog crashes when push button, unhandeled exception/acces violation..)
both out source is pretty much the same, i added length of inbuffer to offset of the buffer and stored that in ecx then compared ecx to offset in outbuffer; inc each time round. (your code is less dense though :))

the problem comes when moving the "calculated" value from al into the output buffer, i really dont why see this problem should happen:confused:
Posted on 2003-07-24 04:41:07 by wilson
I am getting rusty

It should be something liek

mov esi, offset input
mov edi, offset output
mov ecx, SIZEOF input
mov al, [esi]
inc esi
;do something
mov [edi], al
inc edi
dec ecx
jnz @B

I think i spotted the mistake. It should be mov al, instead of mov eax,
Posted on 2003-07-24 07:06:01 by roticv
hey i spotted it first hehe (less than few minutes by the look of it :))
also i moved the buffers to initialised data section

now i get correct output, but an extra character displayed after it. any idea?
usually it is ""
Posted on 2003-07-24 07:37:50 by wilson
Cause if al = 0 (or null terminator), you increase it, you get 1h, which looks weird...
Posted on 2003-07-24 08:14:04 by roticv
got round it by
cmp al,0
je (end of the routine)

not the best way, no spaces allowed in name :(
also 9+1=: lolz
least i got some prog running

10000x thanks roticv mate:alright:
Posted on 2003-07-24 09:07:28 by wilson