flat assembler
Message board for the users of flat assembler.
Index
> High Level Languages > [DONE]High Level Programming Language |
Author |
|
BlastWave 20 Oct 2006, 22:53
I have added headers and bug fixed it so it work, but i still can't get it to work :S
Heres my snip Code: format PE console 4.0 include 'win32a.inc' ; Initiate. invoke GlobalAlloc,GMEM_FIXED,0 mov [mem],eax call AddArray invoke lstrcpy,esi,theName ; Im going use movsb instead of lstrcpy. Just want it to work first.. invoke lstrcpy,edi,theMsg mov eax,[mem] add eax,4 invoke MessageBox,0,[mem],eax,0 call AddArray invoke lstrcpy,esi,theName2 invoke lstrcpy,edi,theMsg2 mov eax,[mem] add eax,4 invoke MessageBox,0,[mem],eax,0 invoke ExitProcess,0 theName db 'hello()',0 theMsg db 'im a variable',0 theName2 db 'hmm()',0 theMsg2 db 'me tooooo',0 AddArray: add dword[var_size],1 mov eax,dword[var_size] imul eax,4 invoke GlobalReAlloc,[mem],eax,GMEM_MOVEABLE ; Now we Allocated the memory so we 8bytes more space aka 2 * dwords mov [mem],eax ; Remember it. mov eax,dword[var_size] ; Get the size to eax. imul eax,8 ; Multiply it for get the real size sub eax,8 ; The Variable name. add eax,dword[mem] ; Now its the accutly address. mov edi,eax ; Esi is the Variable name. add eax,4 ; The next dword (Variable value) mov esi,eax ; Edi is the variable value. invoke GlobalAlloc,GMEM_FIXED,30 ; Make Space for the variable name max 30. mov dword[esi],eax ; Save it invoke GlobalAlloc,GMEM_FIXED,100 ; Make Space for the variable value max 100. mov dword[edi],eax ; Save it ret var_size dd 0 ; The size of it. mem dd 0 ; The handler of all sub variables/values. section '' import data readable library user32,'user32.dll',\ kernel32,'kernel32.dll' import user32,\ MessageBox,'MessageBoxA' import kernel32,\ lstrcpy,'lstrcpy',\ GlobalAlloc,'GlobalAlloc',\ GlobalReAlloc,'GlobalReAlloc',\ ExitProcess,'ExitProcess' Im thinking about using stack instead, seen ppl use it when googleing, and also here. Should I? and what "good" and "bad" would there be with it. Thanks in advanges I have try with stack's and work perfeclty for my needs. I will post the code for learning. Code: format pe console 4.0 include 'win32a.inc' mov edi,ebp sub edi,8 invoke GlobalAlloc,GMEM_FIXED,1024 invoke lstrcpy,eax,one mov [edi],eax invoke GlobalAlloc,GMEM_FIXED,1024 invoke lstrcpy,eax,oneone mov [edi + 4],eax sub edi,8 invoke GlobalAlloc,GMEM_FIXED,1024 invoke lstrcpy,eax,two mov [edi],eax invoke GlobalAlloc,GMEM_FIXED,1024 invoke lstrcpy,eax,twotwo mov [edi + 4],eax cmp ebp,edi je arrayexit @@: invoke MessageBox,0,[edi],[edi + 4],0 add edi,8 cmp edi,ebp je arrayexit jmp @B arrayexit: invoke ExitProcess,0 one db 'the one',0 oneone db 'oneee oneee',0 two db 'der two',0 twotwo db 'twooo twoooo',0 section '' import data readable library kernel32,'kernel32.dll',\ user32,'user32.dll' import user32,\ MessageBox,'MessageBoxA' import kernel32,\ ExitProcess,'ExitProcess',\ GlobalAlloc,'GlobalAlloc',\ lstrcpy,'lstrcpy' Sorry for wastefull topic i didn't think i would have the solutions on my own hands :oops: GoodBye for now |
|||
20 Oct 2006, 22:53 |
|
vid 21 Oct 2006, 13:22
1. you are forgetting to check return value from Global(Re)Alloc / GlobalFree.
2. you are creating array of size 4*var_size, but accessing it as if it was 8*var_size. one of these two is wrong: Code: imul eax,4 imul eax,8 ; Multiply it for get the real size i believe it's the first one, you may want "imul eax,8" or "shl eax, 3" |
|||
21 Oct 2006, 13:22 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.