flat assembler
Message board for the users of flat assembler.

Index > Windows > macros for various fasm assemblers for fasmw ide plus more

Author
Thread Post new topic Reply to topic
Kenneth



Joined: 16 Nov 2005
Posts: 38
Location: United States of America
Kenneth 16 Nov 2013, 08:04
First off, this may require windows with an nt kernel depending on how you use it. fasmwide compiler is only for version 1.71.16 of the ide. These macros require at least a version with the postpone directive, excluding fasm.asm.
Separate file, multiple compile macros build code to assemble your source when you compile+run (F9) via different fasm flavors. The source must be a different file, local/global file names should all work. Supports fasm.exe, fa.exe, fasm.dll located in the path INCLUDE,'..\' (located via INCLUDE environment variable in your ide's fasmw.ini file), and your current fasmw ide process via sendmessage fm_compile.
Also supports fasm.asm source code overloading as a compiler, compiles fasm.exe everytime. (single compile only, no ide.init either)
Code:
include 'compiler/compiler.inc'
define COMPILER fasmwide  ; fasm.asm, fasm.exe, fasm.dll, or fa.exe 

start:  ;required because of a different feature, omit for fasm.asm or error
compile 'source.asm', 'out.exe'
compilerun 'source.asm','out.exe'
    

compilerun is used to run the output. Output is ran if compile was successful, except fasm.exe and fa.exe who do not check and will always attempt to run.
Fasm.exe and fa.exe also accept commandline and only take one arg instead if only compiling, 2 if also running output.

Code:
compile.fasmcl 'source.asm test.exe'
compilerun.facl 'source.asm -o test.exe', 'test.exe'
    

Besides compiling there are macros to alter your ide. Specifically code to open up all your source files for you so all you have to is open up the build file and hit F9 to setup your environment. If you place the provided folder in your fasmw include folder, the example file will open up your ide's source and the compiler macro files ready for editing.
Code:
define COMPILER fasm.exe
include 'compiler.inc'

;code places here is processed if you only have 1 or 0 tabs open in your ide.
ide.assign  ;assigns tab 0 to ide compiler
ide.open '..\..\SOURCE\IDE\FASMW\FASMW.ASM'
;ide.open '..\..\SOURCE\IDE\FASMW\fasm.inc'
ide.open 'Compiler.inc'
ide.open 'cFasmwIDE.inc'
ide.open 'cFasmExe.inc'
;etc

start:  ;code here is always ran
compilerun '..\..\SOURCE\IDE\FASMW\fasmw.asm', 'name2.exe'
compile '..\..\SOURCE\IDE\FASMW\fasmw.asm', 'name3.exe'
;compile.fasmcl '..\..\SOURCE\IDE\FASMW\FASMW.ASM fasmw.exe'
;compilerun.facl '..\..\SOURCE\IDE\FASMW\FASMW.ASM -o fasmw.exe', 'fasmw.exe'       
    

some additional info:
Include variable is copied and automatically set for all compilers, found via file directive '..\fasmw.ini' where it is parsed from the include environment variable. Don't test the code i wrote it very quickly but it should work if fasmw.exe built the ini file. It does not seem to effect fasm.dll.
Symbols are always dumped for all compilers if possible (not fasm.dll).
Getting local files, '..\', and globals working for everything took a lot of checking and code altering but everything should work as long as you dont exceed the buffers. All compilers should output symbols and code uniformly to correct paths.
Local files are based off of current directory of the build.asm for compile and ide.init. So compile '..\file1.asm', 'file2.exe' will compile file1.asm in build.asm parent folder and output to the building file folder (current). The symbols file will be dumped to the src folder as 'file1.fas'


Description:
Download
Filename: Ex.zip
Filesize: 26.95 KB
Downloaded: 248 Time(s)



Last edited by Kenneth on 15 Feb 2014, 05:12; edited 7 times in total
Post 16 Nov 2013, 08:04
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger ICQ Number Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20289
Location: In your JS exploiting you and your system
revolution 16 Nov 2013, 08:12
Kenneth wrote:
For fasmwide I tried to get fasw ide's process id by using ntprocesssomething or the other which worked fine throwing no errors at all but it was returning 0's to the buffer when using readprocessmemory so I guess the handle is trash for such purposes.
There is a good chance this is a security setting that is blocking the reads. Your app will need debug privileges to be able to read another processes memory.
Post 16 Nov 2013, 08:12
View user's profile Send private message Visit poster's website Reply with quote
Kenneth



Joined: 16 Nov 2005
Posts: 38
Location: United States of America
Kenneth 16 Nov 2013, 08:23
I used NtQueryInformationProcess which returns structure containing the unique process id and calling openprocess on that which did not fail. Following calls to ReadProcessMemory using the openprocess handle also returned successful but did not work only acted as if it read 0's. I think its because the id is not made for openprocess/rpm/wpm but its an undocumented function anyway.
I need to try the official way and see if that id works. process32first etc. or see if I can get the window handles using the unique processid.
Post 16 Nov 2013, 08:23
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger ICQ Number Reply with quote
Kenneth



Joined: 16 Nov 2005
Posts: 38
Location: United States of America
Kenneth 30 Nov 2013, 05:37
Run compiled processes in debug mode and open olly (tested with v1.10 and 2.01) only if and when a breakpoint occurs. Debugger is then detached and olly is automatically started via command line to attach to the debugee process and take over.
Eip is changed back to the int 3 instruction that caused the breakpoint and the thread is resumed when olly is hopefully ready to process and focus on the code for you.

Define debug and olly path to enable debugging:
Code:
define COMPILER fasmwide
define DEBUG
define OLLY    'C:\P\odbg110\OLLYDBG.EXE'
include 'compiler.inc'     
;compile/run your source file.    

[edit] Updated generic fix for olly v1 or 2 (Only tested with 110 and 201)
and utilizes checkremotebdeuggerpresent instead of a blind sleep and hope olly attached. Still required but almost no sleep necessary for v2, half a sec for v1 since olly still might not be ready to process the breakpoint.
Also fixed a couple bugs.[/edit]
Post 30 Nov 2013, 05:37
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger ICQ Number Reply with quote
Kenneth



Joined: 16 Nov 2005
Posts: 38
Location: United States of America
Kenneth 15 Feb 2014, 04:36
New version, should work with more versions of fasmw.exe. Symbols are dumped for fasmw.exe and necessary symbols are found so it should work with versions that work similar and use the same symbol names. The info is saved for future reference so it doesn't have to be extracted again.
Also tools can automatically be used on assembled sources' symbols dump. Tools are automatically assembled if they are not already (using fasm.exe).
Code:
define COMPILER fasmwide
;define DUMP     ALL  ;automatically uses all 3 tools on all source files
define DUMPPATH 'Ex'  ;based off of source file. do not use leading or trailing slash
include 'Ex\Ex.inc'  ;header changed
;ideinit
ide.assign
ide.open 'sourcefile.asm'
stop

;assemble code
start:
compilerun 'sourcefile.asm', 'output.exe'
dump  ;uses all 3 tools on last source file  (following a compile or compilerun, not implemented for compile.fa(sm)cl commands)
                 

Define DUMP as ALL to automatically dump all info you can for every source file, or else follow a compile command with dump to dump last source. Prepsrc, listing, and symbols tool dumps will be put in same folder as source file. Define DUMPPATH and they will be saved in the source file folder/DUMPPATH/ directory instead.
All tools work fine for me with fasmwide/fasm.exe as the assembling backends. Fa.exe doesn't work with listing tool...probably just needs a setcurrentdirectory fix.
Extracting the necessary symbols from fasmw.fas for fasmwide and ide hooks tested with 1.71.16, .17, and .19 and everything seems to work fine. You should just be able to throw the folder in your fasm include folder and everything should work.
Post 15 Feb 2014, 04:36
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger ICQ Number 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.