flat assembler
Message board for the users of flat assembler.
![]() |
Author |
|
Spool 28 Jan 2013, 03:41
[ Post removed by author. ]
Last edited by Spool on 17 Mar 2013, 04:43; edited 1 time in total |
|||
![]() |
|
TheRedPill 28 Jan 2013, 04:09
Spool wrote: You should load the compiled code in VirtualAlloc(...) and VirtualProtect(...) with PAGE_EXECUTE in case in if your using Windows. The executable code must be aligned by 16bytes padded with nops. VirtualAlloc, VirtualProtect, VirtualFree is clear so far and the way i am doing it already, but what do you mean with 16bytes padded with no operation instructions? |
|||
![]() |
|
Spool 28 Jan 2013, 04:17
[ Post removed by author. ]
Last edited by Spool on 17 Mar 2013, 04:43; edited 1 time in total |
|||
![]() |
|
TheRedPill 28 Jan 2013, 04:31
Spool wrote:
AFAIU this is the multiple of 16 and if yes, why the multiple of 16? I had 18 bytes on the original output and i nop'ed it to 32 bit, but it still looks like this: 0x00000000 67668B442408 MOV AX,WORD PTR [ESP+0x8] 0x00000006 67668B4C2404 MOV CX,WORD PTR [ESP+0x4] 0x0000000C 6601C8 ADD AX,CX 0x0000000F C20800 RET 0x8 0x00000012 90 NOP 0x00000013 90 NOP 0x00000014 90 NOP 0x00000015 90 NOP 0x00000016 90 NOP 0x00000017 90 NOP 0x00000018 90 NOP 0x00000019 90 NOP 0x0000001A 90 NOP 0x0000001B 90 NOP 0x0000001C 90 NOP 0x0000001D 90 NOP 0x0000001E 90 NOP 0x0000001F 90 NOP |
|||
![]() |
|
sinsi 28 Jan 2013, 04:35
use32
|
|||
![]() |
|
TheRedPill 28 Jan 2013, 04:44
I found it, its the use32 directive that must be placed in thea sources header section.
|
|||
![]() |
|
TheRedPill 28 Jan 2013, 04:46
sinsi wrote: use32 Yes, i found it, its documented here: http://flatassembler.net/docs.php?article=manual#2.4 Thanky you anyway. ![]() |
|||
![]() |
|
Spool 28 Jan 2013, 04:50
[ Post removed by author. ]
Last edited by Spool on 17 Mar 2013, 04:44; edited 2 times in total |
|||
![]() |
|
TheRedPill 28 Jan 2013, 05:22
Spool wrote: here its workable: Thank you for the example, but this could "possibly" not work in Windows and could possibly also not work in *nix systems and its also not eaxctly the answer to my OP. The OP question was how i could make the input assembly instructions go output into 32 bit assembly and not the 16 bit variant. Your example uses correct bytes to run, but you are using the wrong methods. As you pointed out by yourself, one should use the Virtual* functions, but malloc() uses internall malloc->HeapAlloc->RtlAllocateHeap accross three dynamic link libraries and the heap allocated memory could, must not be executable due to memory protection mechanisms. This could lead to a segmentation fault. In *nix you use mmap() and mprotect() for this. Even though the memory will be freed by the OS kernel on app termination, one should always use free() on *nix or VirtualFree() on Windows systems to release the memory previously allocated. |
|||
![]() |
|
Spool 28 Jan 2013, 05:29
[ Post removed by author. ]
Last edited by Spool on 17 Mar 2013, 04:44; edited 1 time in total |
|||
![]() |
|
TheRedPill 28 Jan 2013, 05:34
Spool wrote: The code above can be 16-bit or 32-bit but Windows application running without compatibility is 32-bit. I guess it "can" work on *nix systems, but if memory protection comes in, it will fail in some way. |
|||
![]() |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2023, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.