flat assembler
Message board for the users of flat assembler.
Index
> Compiler Internals > Post-Processor file size operator? |
Author |
|
revolution 11 Jun 2015, 02:40
Do you mean fasm's source code? Or within the your own source code? It is not clear what you are doing. Can you post your code example please?
|
|||
11 Jun 2015, 02:40 |
|
Foxxy 11 Jun 2015, 04:05
I think expressing myself through an image would best help me explain what I'm looking for:
|
|||
11 Jun 2015, 04:05 |
|
revolution 11 Jun 2015, 04:41
Getting the on-disk size of a PE file without the normal disk functions is not a trivial thing. The in-memory address ranges and the on-disk sizes are different. You would have to scan the section headers to determine the on-disk size of each individual section.
Since you don't want to use GetFileSize then you make your task a lot more involved. Do you want to modify fasm source code to pass into the program the on-disk size? Is that why you posted this in the "Compiler Internals" forum? Last edited by revolution on 11 Jun 2015, 13:59; edited 1 time in total |
|||
11 Jun 2015, 04:41 |
|
Foxxy 11 Jun 2015, 13:49
Yes! That's exactly what I am looking for. I thought there was already a way to do this, I must have been mistaken.
I have done a very poor job of explaining myself. What I was looking for was if there was already a way for FASM to insert to the finished product's file size into the finished product wherever specified. I should not have mentioned GetFileSize since that only made things more confusing. I had no original intention to modify FASM, I was looking for a built in functionality. |
|||
11 Jun 2015, 13:49 |
|
revolution 11 Jun 2015, 13:58
If you look at PARSER.INC and find the label 'get_predefined_id' you could add another value similar to the existing %t.
|
|||
11 Jun 2015, 13:58 |
|
Foxxy 11 Jun 2015, 17:11
Is parser.inc used in the final stages of compilation, at the time where the final size would be or could be known?
|
|||
11 Jun 2015, 17:11 |
|
revolution 12 Jun 2015, 01:38
You need to start with parser.inc to add the symbol (something like %s, or whatever). Then you add processing for that similar to %t to generate the value you want. The size value would come from the PE formatter code. And being a forward referenced value you would need a minimum of two passes to get the correct value.
|
|||
12 Jun 2015, 01:38 |
|
Foxxy 12 Jun 2015, 05:34
Okay, time to delve into FASM's source, thanks!
|
|||
12 Jun 2015, 05:34 |
|
cod3b453 12 Jun 2015, 19:40
For stuff like this I use multi stage assembly with an initial "null" pass that fills in the binary with placeholders then a second assembly that fills this in with proper values:
Code: format PE console 4.0 entry start include '%fasminc%/win32ax.inc' section '.data' data readable writable if 0 ; First assemble with 0; then assemble with 1 (this will have the size) virtual at 0 file 'test.exe' ; assuming source is test.asm _mysize = $ ; actual end virtual else _mysize = 0 ; null end if mysize dd _mysize section '.code' code readable executable start: cinvoke printf,"Size: %d",[mysize] ret section '.idata' import data readable writable library msvcrt,'MSVCRT.DLL' import msvcrt,printf,'printf' |
|||
12 Jun 2015, 19:40 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.