flat assembler
Message board for the users of flat assembler.
Index
> Windows > Easy way of adding new section to a pe file ?????? Goto page Previous 1, 2 |
Author |
|
Reverend 17 Oct 2005, 13:48
comrade wrote: A new section is required because the program makes relocations, so the code in attach.inc would run normally under another imagebase. Only with a new section it is possible to "fake" an arbitrary imagebase. EDIT: Code is MASM-specific.
|
|||||||||||
17 Oct 2005, 13:48 |
|
comrade 17 Oct 2005, 23:49
Yes, but it is a pain to write imagebase-independent code. With my solution of performing relocations during attachment, it is possible to inject almost any code with little changes (just the import table and a bit more during start-up).
|
|||
17 Oct 2005, 23:49 |
|
Reverend 18 Oct 2005, 12:16
comrade: It's not so hard. Just do at the beginning:
Code: call @F @@: pop ebp sub ebp, @B Code: ; mov eax, [memory_location1] mov eax, [ebp+memory_location1] ; inc [memory_location2] inc [ebp+memory_location2] |
|||
18 Oct 2005, 12:16 |
|
comrade 18 Oct 2005, 16:48
I know. I consider that painful. Do not kid yourself. This is not a style you want to program normally in, when you have to reference everything in memory relative to some location.
|
|||
18 Oct 2005, 16:48 |
|
comrade 18 Oct 2005, 16:51
Would you rather write this:
Code: code: mov eax,[ebp-data+var1] add eax,[ebp-data+var2] movzx ecx,byte [ebp-data+var3] xor eax,ecx data: var1 dd ? var2 dd ? var3 db ? or this: Code: code: mov eax,[var1] add eax,[var2] movzx ecx,[var3] xor eax,ecx data: var1 dd ? var2 dd ? var3 db ? In fact, I don't know if you could even write "-data" with FASM. |
|||
18 Oct 2005, 16:51 |
|
Reverend 18 Oct 2005, 17:38
There wasn't so much of the code to be place-independent. Only from 'attach' file. But ok, it's your decision. Peace
|
|||
18 Oct 2005, 17:38 |
|
comrade 19 Oct 2005, 00:15
The attach.inc file could be enormous. In one project, I had a full-blown GUI as an attachment. The relocation technique worked quite well, and I did not have to bother myself with writing address-independent code.
|
|||
19 Oct 2005, 00:15 |
|
Goto page Previous 1, 2 < Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.