flat assembler
Message board for the users of flat assembler.
Index
> High Level Languages > Accessing reserved data without ORG in a flat binary proc |
Author |
|
Beege 02 Sep 2019, 18:55
Hi, Quick back story, I was introduced to assembly/fasm years ago via AutoIt scripting langauge for windows by a member who created a library for using fasm.dll. Autoit is great for a lot of things but it is an interpreting language so can get kinda slow in certain situations (mainly functions with tons of loops) and thats where fasm came in great. Using the dll, I generate flat binary procedures (correct term?), load the opcode output from dll into memory and then execute that memory location like any other function in the script.
Recently I added a package for fasmg (Link below) and would love to confirm if I am correct about accessing reserved data when generating code like this (single procedure only) and not using the ORG statement to specify the memory location the code is going to be executed at. I like using ORG for quickly writing and testing code but also like to write the code not using ORG so it can be saved as binary string in script and later execute without requiring the fasmg.dll and includes files. I know I can pass the function the current address as a parameter and then access the data that way, but mainly just want to be sure thats my only option if I dont use ORG. Below is a sample inline fasmg fuction I would put in my script. This first code below out fine when passing the current address as pCurrentMemAddr and I have told myself thats the only way I can do it, but I want to be sure. Code: ;"force" is just a macro that creates an annoynomous label to ensure _TestDataAccess is generated (since nothing calls this function within fasmg). force _TestDataAccess ; proc _TestDataAccess uses ebx, pCurrentMemAddr, iParm2 mov ebx, [pCurrentMemAddr] mov eax, [ebx+iTest] add eax, [iParm2] ret iTest dd 0xAABBCCDD endp Here pCurrentMemAddr is taken out of the function. Is there any other way reach that data? Possibly something with LOAD/STORE? Code: force _TestDataAccess ; proc _TestDataAccess, iParm2 ; Anything I can put here to reach iTest? ; add eax, [iParm2] ret iTest dd 0xAABBCCDD endp Any feedback is appreciated. Thanks https://www.autoitscript.com/forum/topic/199758-flat-assembler-g-udf https://www.autoitscript.com/forum/topic/197423-a-new-way-to-write-fasm-assembly-code-with-extended-headers |
|||
02 Sep 2019, 18:55 |
|
st 03 Sep 2019, 08:03
In 32 bit mode the current address (instruction pointer register) can be obtained with the following code snippet
Code: call delta
delta: pop ebx I think there should be some topics about Position Independent Code (PIC) here. For example https://board.flatassembler.net/topic.php?p=66010 |
|||
03 Sep 2019, 08:03 |
|
Beege 03 Sep 2019, 14:53
Wow that's an awesome trick! thank you!
|
|||
03 Sep 2019, 14:53 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.