flat assembler
Message board for the users of flat assembler.
Index
> Macroinstructions > macro local |
Author |
|
cod3b453 01 Sep 2013, 16:45
The declaration is correct but foo will expand to the buffer you created and the code afterwards, so if you tried to execute foo, you're actually executing the local data as code. A possible correction would be:
Code: macro foo { local hello local skip jmp skip hello db 20 dup ('F') skip: mov eax, 'ABCD' mov byte [hello], al ; not error, but stuck here } |
|||
01 Sep 2013, 16:45 |
|
system error 01 Sep 2013, 18:19
Hello cod3b453, appreciate your reply but that code didn't work either. This is my updated code. Just a test code with no specific purpose.
Code: format PE console include 'win32ax.inc' entry main macro foo { local hello local skip jmp skip hello db 10 dup ('XyXyXyXyXy') skip: mov eax, 'ABCD' mov byte [hello], al ; not error, but stuck here cinvoke printf, "%c", dword [hello] } section '.code' code executable main: foo invoke system, "pause" invoke exit, 0 section '.data' data readable writable anything db ? section '.idata' import data readable library msvcrt, 'msvcrt.dll' import msvcrt,\ system, 'system',\ printf,'printf',\ exit, 'exit' I opened the VC++ debugger and it gave me: Unhandled exception in foo32exe: 0xC0000005:Access Violation. This is the problematic region I got from the debugger 00401001 pop eax 00401003 jns 0040105D 00401005 jns 0040105F 00401007 jns 00401061 ---cut--- 0040105F jns 004010B9 00401061 jns 004010BB 00401063 jns 004010BD 00401065 jns 0040101F 00401067 inc ecx 00401068 inc edx 00401069 inc ebx 0040106A inc esp 0040106B mov [00401002],al ;<<--- Debugger stops here. |
|||
01 Sep 2013, 18:19 |
|
bitRAKE 01 Sep 2013, 20:14
"Access Violation" means that permission to write is not allowed. So, we would look at the permissions of memory location. Code section is read only (default). Need to add WRITEABLE to the SECTION definition.
|
|||
01 Sep 2013, 20:14 |
|
system error 01 Sep 2013, 20:27
bitRAKE wrote: "Access Violation" means that permission to write is not allowed. So, we would look at the permissions of memory location. Code section is read only (default). Need to add WRITEABLE to the SECTION definition. Great! I got it working now. Thanks to you and cod3b45e. I didn't know FASM macro is that 'powerful'. |
|||
01 Sep 2013, 20:27 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.