flat assembler
Message board for the users of flat assembler.

Index > Compiler Internals > Resolve fasm.dll symbols by myself?

Author
Thread Post new topic Reply to topic
Yuki



Joined: 07 May 2015
Posts: 3
Yuki 17 Jul 2021, 12:04
Hi everyone, before all, sorry for my english Embarassed Embarassed i am from Argentina (spanish speaker)

Well, i am trying to use fasm.dll like an extension of CheatEngine for memory edition, but i need to insert my owns symbol names within Fasm Assembly Code... so i thought to implement a callback that it will invoked when a symbol name be undefined. This method will be better than just add my own symbols as plain text.

I think that it could be very useful and powerful if i can implement it well, something like just replace the symbol with its correct address or insert some code in the middle of compilation

My problem is that i don't know anything about Fasm Source Code, so where i need start to get the "undefined symbol" error? Rolling Eyes
Post 17 Jul 2021, 12:04
View user's profile Send private message Reply with quote
bitRAKE



Joined: 21 Jul 2003
Posts: 4046
Location: vpcmpistri
bitRAKE 17 Jul 2021, 14:29
Because of the speed (and complexity) of fasm - it's actually better to append symbolic definitions as plain text, imho. If there is a concern of size - like a large number of constants - then maybe inject through fasm FILE support as binary.

fasm core goes to the system support routines to request the file. If you designed a specific syntax that would reference memory directly. This could be completely accomplished with the system support without touching fasm core, imho.

Within your pre-assembly code you'd access constants from the loaded 'file' in a VIRTUAL region with the LOAD directive.

Hola! Yo hablo poquito Espanol. Embarassed

_________________
¯\(°_o)/¯ “languages are not safe - uses can be” Bjarne Stroustrup
Post 17 Jul 2021, 14:29
View user's profile Send private message Visit poster's website Reply with quote
Yuki



Joined: 07 May 2015
Posts: 3
Yuki 18 Jul 2021, 16:50
That is a really smart idea, but when of FASM Macros it's about, i am a complety newie guy, i just used the standard fasm library macros and i don't know how those works.

i was awake tonight studying the source code of fasm, i found the section in wich i could invoke the callback with the name of undefined symbol.

I think i'm going to return the undefined symbol name in the FASM_STATE structure and just append the symbol with its value over the plain text... i.e. i will recall fasm_Assemble every time that i get a new undefined symbol

I tried to define a symbol by myself, but the fasm functions works under a very specific context that i can't replicate within a simple procedure.

Well, at least was funny Razz
Post 18 Jul 2021, 16:50
View user's profile Send private message Reply with quote
bitRAKE



Joined: 21 Jul 2003
Posts: 4046
Location: vpcmpistri
bitRAKE 18 Jul 2021, 18:49
Code:
virtual at 0
CheatEngine::
        file '$CheatEngine$'
; custom file handling would:
;       + intercept special '$CheatEngine$' name and return a psuedo-handle
;         (note: values with high-bit set should not collide with real file handles)
;       + intercept special psuedo-handle for read and copy data from memory
end virtual

struc CEConst offset {
        load . from CheatEngine:offset
}

const123 CEConst 123    
...was thinking something like above.
Really, not that complex.

I have created a more complex patch with a custom address space:
https://board.flatassembler.net/topic.php?p=215013#215013
...this shows the patch working...
https://github.com/bitRAKE/fasm_playground/blob/reloc/TESTS/__reloc/t0.asm

This would be another way to go - skipping the pseudo-file trickery.

_________________
¯\(°_o)/¯ “languages are not safe - uses can be” Bjarne Stroustrup
Post 18 Jul 2021, 18:49
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.