Jump to content



Photo

The Embedded Flat Assembler (FASM) UDF


  • Please log in to reply
9 replies to this topic

#1 Ward

Ward

    Adventurer

  • Active Members
  • PipPip
  • 140 posts

Posted 15 March 2010 - 11:25 AM

This UDF is similar to my previous Inline Assembly UDF, but only better. Because this one uses flat assembler, a open source and powerful assembler. See http://flatassembler.net/. Thanks to XDa from http://www.opensc.ws/ provide a "fasm.dll". So my job is just easy, warp it using my MemoryDll UDF.

The usage is also similar to previously, but a kind of different. FasmGetFuncPtr() will compile the source and return the address ready to be call. And FasmGetBasePtr() only return the base address without compiling and error handling. FasmGetBasePtr() is added for "org" directive.

Have fun. Maybe also take a look at AndyG's Fractals script.

FASM.zip (55.47K)
Number of downloads: 127

2010/03/19 Update Note:
# Embedded FASM version update to v1.68
# Add OOP version using AutoItObject, thanks to AutoItObject-Team
# New examples
# Better error handling, can handle errors in macro now
FASM.zip (141.76K)
Number of downloads: 601

2011/06/14 Update Note:
# Embedded FASM version update to v1.69
# AutoItObject UDF version update to v1.2.8.0
# MemoryDLL UDF update to X64 supported version
# New BinaryCall UDF to run a machine code in "Binary" format
# Add FASMServer and FASMServerDemo, demonstrate embedded assembly in AutoIt X64
# Add fast BinaryXOR function (Both X86/X64) as an example (in FASMServerDemo2)
Attached File  FASM.zip   119.63K   780 downloads

Edited by Ward, 03 June 2011 - 10:24 PM.






#2 AndyG

AndyG

    Prodigy

  • Active Members
  • PipPipPip
  • 187 posts

Posted 15 March 2010 - 11:15 PM

Hi.....

what can i say other than THANK YOU! :(

Andy

#3 Beege

Beege

    Universalist

  • MVPs
  • 843 posts

Posted 16 March 2010 - 05:10 AM

Thanks a lot for this sharing this ward. Great little examples too. Very helpful. 5*. :(

#4 Beege

Beege

    Universalist

  • MVPs
  • 843 posts

Posted 16 March 2010 - 05:51 PM

Do you know if there is a way I can pass parameters to the autoit functions?

#5 monoceres

monoceres

    asdf

  • MVPs
  • 3,718 posts

Posted 16 March 2010 - 06:45 PM

Do you know if there is a way I can pass parameters to the autoit functions?


Check out DllCallbackRegister.
Posted ImageIs the link in my post broken? I do not longer own my domain, all the files are moved to my new domain.Example: http://monoceres.se/test.au3 -> http://andhen.mine.nu/monoceres.se/test.au3

#6 Ward

Ward

    Adventurer

  • Active Members
  • PipPip
  • 140 posts

Posted 16 March 2010 - 07:02 PM

Do you know if there is a way I can pass parameters to the autoit functions?

It is easy:
Plain Text         
#include "FASM.au3" Dim $Fasm = FasmInit() Demo7() Func Demo7()     ; Demo 7: Call AutoIt Func From Assembly And Pass Parameters     $AutoItFunc = DllCallbackRegister("AutoItFunc2", "int", "str;uint;uint")     FasmReset($Fasm)     FasmAdd($Fasm, "use32")     FasmAdd($Fasm, "org " & FasmGetBasePtr($Fasm))     FasmAdd($Fasm, "rdtsc")     FasmAdd($Fasm, "push eax")     FasmAdd($Fasm, "push edx")     FasmAdd($Fasm, "push s1")     FasmAdd($Fasm, "call " & DllCallbackGetPtr($AutoItFunc))     FasmAdd($Fasm, "ret")     FasmAdd($Fasm, "s1: db 'RDTSC = %08X%08X', 0")     ConsoleWrite(String(FasmGetBinary($Fasm)) & @CRLF)     $Ret = MemoryFuncCall("int", FasmGetFuncPtr($Fasm))     DllCallbackFree($AutoItFunc) EndFunc Func AutoItFunc2($String, $Edx, $Eax)     MsgBox(0, "AutoItFunc", StringFormat($String, $Edx, $Eax)) EndFunc


#7 Beege

Beege

    Universalist

  • MVPs
  • 843 posts

Posted 16 March 2010 - 07:46 PM

Thanks ward. That helped a lot. :(
But now I'm confused on why the data in s1 gets set after the 'ret'. I figured it would be the other way around.
FasmAdd($Fasm, "s1: db 'RDTSC = %08X%08X', 0") FasmAdd($Fasm, "ret")

Anyway, just another item on the list of "things to read and learn about." Thanks again.

Edited by Beege, 17 March 2010 - 06:00 PM.


#8 trancexx

trancexx

    Hm, I really shouldn't.

  • Active Members
  • PipPipPipPipPipPip
  • 5,186 posts

Posted 22 March 2010 - 06:32 PM

Object version is refreshing.

Thanks Ward.

eMyvnE


#9 Ascend4nt

Ascend4nt

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 1,072 posts

Posted 22 March 2010 - 07:10 PM

Excellent job again Ward.

Out of curiosity, since FASM supports x64 code ('use64'), what would you say the chances are of someday compiling & integrating a 64-bit DLL. I'm getting well versed in x64 code so I'd be able to provide 64-bit versions of the Examples for ya.

Thanks again for all your work
Ascend4nt

#10 Ward

Ward

    Adventurer

  • Active Members
  • PipPip
  • 140 posts

Posted 03 June 2011 - 10:28 PM

This UDF is updated to support AutoIt X86/X64.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users