Jump to content



Photo

AutoIt Inline Assembly UDF


  • Please log in to reply
19 replies to this topic

#1 Ward

Ward

    Adventurer

  • Active Members
  • PipPip
  • 140 posts

Posted 26 December 2008 - 05:37 AM

Thanks to disasm source code by Oleh Yuschuk from http://www.ollydbg.de/.
I compiled them into a DLL and use it in this UDF.

Loot at the example script first:
Plain Text         
#include <ASM.au3> ; Initial an asm object Global $Asm = AsmInit() Demo1() Func Demo1() ; Demo 1: Using Parameters     AsmReset($Asm)     AsmAdd($Asm, "push ebp")     AsmAdd($Asm, "mov ebp, esp")     AsmAdd($Asm, "mov eax, [ebp + 08]")     AsmAdd($Asm, "add eax, [ebp + 0c]")     AsmAdd($Asm, "pop ebp")     AsmAdd($Asm, "retn 8")     ConsoleWrite(String(AsmGetBinary($Asm)) & @CRLF)     $Ret = MemoryFuncCall("int", AsmGetPtr($Asm), "int", 1, "int", 2)     MsgBox(0, "Demo 1: Using Parameters", "1 + 2 = " & $Ret[0]) EndFunc ; Release the asm object AsmExit($Asm) Exit

There are more examples including read Time-Stamp counter, using label,
call AutoIt function from assembly, and a assembly crc32 routine in the archive.

Have fun!
Attached File  asm.zip   36.4K   1836 downloads





#2 Lazycat

Lazycat

    Coding cat

  • MVPs
  • 1,174 posts

Posted 26 December 2008 - 07:34 AM

I have no words... It's time to start learning assembler?
It's still need to compare performance (is this faster then calling regular function from dll?), but anyway this a lot more flexible way then preparing machine code!
Koda homepage (http://www.autoitscript.com/fileman/users/lookfar/formdesign.html) (Bug Tracker)My Autoit script page (http://www.autoitscript.com/fileman/users/Lazycat/)

#3 Dampe

Dampe

    Polymath

  • Active Members
  • PipPipPipPip
  • 231 posts

Posted 26 December 2008 - 07:43 AM

Very nice, Unfortunately:

Func Demo1() ; Demo 1: Using Parameters     $timer = TimerInit()     AsmReset($Asm)     AsmAdd($Asm, "push ebp")     AsmAdd($Asm, "mov ebp, esp")     AsmAdd($Asm, "mov eax, [ebp + 08]")     AsmAdd($Asm, "add eax, [ebp + 0c]")     AsmAdd($Asm, "pop ebp")     AsmAdd($Asm, "retn 8")     ConsoleWrite(String(AsmGetBinary($Asm)) & @CRLF)     $Ret = MemoryFuncCall("int", AsmGetPtr($Asm), "int", 1, "int", 2)     ConsoleWrite (TimerDiff ($timer) & "ms" & @CRLF)     $timer = ""     MsgBox(0, "Demo 1: Using Parameters", "1 + 2 = " & $Ret[0]) EndFunc


Result: 5.0036303630363ms

Func Demotwo()     $timer = TimerInit()     $t = 1 + 2     ConsoleWrite (TimerDiff ($timer) & "ms" & @CRLF)     $timer = ""     MsgBox (32, "test", $t) EndFunc

Result: 0.00672067206720672ms

Edited by Dampe, 26 December 2008 - 07:43 AM.

Posted Image

#4 Ward

Ward

    Adventurer

  • Active Members
  • PipPip
  • 140 posts

Posted 26 December 2008 - 08:09 AM

Very nice, Unfortunately:

I don't think it is unfortunately.

This UDF assemble the code to binary machine code, and then run it. So other machine code UDF must be faster than these.

So, it is not for speed, it for powerful, and for fun. Want to get cpu's Time-Stamp Counter ? You will find assembly is the easiest way.

If you need speed, see my other post about machine code UDF or MemoryDll UDF.

Edited by Ward, 26 December 2008 - 08:10 AM.


#5 Lazycat

Lazycat

    Coding cat

  • MVPs
  • 1,174 posts

Posted 26 December 2008 - 08:10 AM

Unfortunately:

This is bad example for compare speed, since Ward's UDF require some time for initializing. It's need time-intensive tasks, like checksums for big files, for which using those techiques are reasonable.
Koda homepage (http://www.autoitscript.com/fileman/users/lookfar/formdesign.html) (Bug Tracker)My Autoit script page (http://www.autoitscript.com/fileman/users/Lazycat/)

#6 SmOke_N

SmOke_N

    It's not what you know ... It's what you can prove!

  • Moderators
  • 15,729 posts

Posted 26 December 2008 - 08:24 AM

Wow... No time this evening to play/test... but this could be huge. Thanks Ward.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.


#7 Dampe

Dampe

    Polymath

  • Active Members
  • PipPipPipPip
  • 231 posts

Posted 26 December 2008 - 08:25 AM

I don't think it is unfortunately.

This UDF assemble the code to binary machine code, and then run it. So other machine code UDF must be faster than these.

So, it is not for speed, it for powerful, and for fun. Want to get cpu's Time-Stamp Counter ? You will find assembly is the easiest way.

If you need speed, see my other post about machine code UDF or MemoryDll UDF.


Yeah, I agree completely on the fact of it's power, I just don't think it would be efficient to use it for basic addition and subtraction / whatever else.

Nice UDF none the less :)
Posted Image

#8 oMBRa

oMBRa

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 836 posts

Posted 26 December 2008 - 12:12 PM

Newbie question: I have found with cheat engine and address ( for example 0x6F000000) and the opcode is ''mov eax, [ebp + 08]'' and ebp + 08 is the address Im searching to read a value... is possible to determine it with this UDF?

#9 James

James

    jbrooksuk

  • MVPs
  • 9,468 posts

Posted 26 December 2008 - 12:20 PM

Wow... No time this evening to play/test... but this could be huge. Thanks Ward.

Well you got be stunned. And Smoke too? Wow, this is really good!

#10 doudou

doudou

    reverse engineer, the evil twin of the obverse decomposer

  • Active Members
  • PipPipPipPipPipPip
  • 335 posts

Posted 26 December 2008 - 12:22 PM

LOL
Nice toy! I can't imagine any practical use for it in a scripting language but hey, who says programmers are not allowed to play around?
Next challenge: write a hardware driver entirely in AutoIt script! :)
UDFS:Apps:Coder's last words before final release: WE APOLOGIZE FOR INCONVENIENCE

#11 doudou

doudou

    reverse engineer, the evil twin of the obverse decomposer

  • Active Members
  • PipPipPipPipPipPip
  • 335 posts

Posted 26 December 2008 - 12:27 PM

Newbie question: I have found with cheat engine and address ( for example 0x6F000000) and the opcode is ''mov eax, [ebp + 08]'' and ebp + 08 is the address Im searching to read a value... is possible to determine it with this UDF?

If You are talking about reading some other process' memory - bad luck, in protected mode it is ahm... protected :) Assembler won't help You at all unless Your cheat prog is registered as a debugger.
UDFS:Apps:Coder's last words before final release: WE APOLOGIZE FOR INCONVENIENCE

#12 oMBRa

oMBRa

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 836 posts

Posted 26 December 2008 - 12:41 PM

u mean SeDebugPrivileges?

#13 doudou

doudou

    reverse engineer, the evil twin of the obverse decomposer

  • Active Members
  • PipPipPipPipPipPip
  • 335 posts

Posted 26 December 2008 - 12:51 PM

u mean SeDebugPrivileges?

I mean You need to start the cheatee or attach to it with debugging rights and Your user has to be granted the privilege to debug software in first place. From my perspective it's easier just to fire up Visual Studio (or similar) and do the dirty work from there.
UDFS:Apps:Coder's last words before final release: WE APOLOGIZE FOR INCONVENIENCE

#14 oMBRa

oMBRa

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 836 posts

Posted 26 December 2008 - 12:55 PM

I just have to do ''ebp + 08'', but how to determine ebp? (let's say I have debugging rights etc...)

#15 doudou

doudou

    reverse engineer, the evil twin of the obverse decomposer

  • Active Members
  • PipPipPipPipPipPip
  • 335 posts

Posted 26 December 2008 - 01:09 PM

I just have to do ''ebp + 08'', but how to determine ebp? (let's say I have debugging rights etc...)

I may have misunderstood his UDF but I think all register content is in $Ret array after MemoryFuncCall. We'll have to figure out which one is which or wait for a reply from the author.
UDFS:Apps:Coder's last words before final release: WE APOLOGIZE FOR INCONVENIENCE

#16 Pain

Pain

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 627 posts

Posted 26 December 2008 - 07:35 PM

I'm speechless, this is awesome. Thee is so many new opportunities with asm support.

#17 StrategicX

StrategicX

    Seeker

  • Active Members
  • 43 posts

Posted 28 March 2009 - 06:43 PM

Can this be used to inject ASM into a live process I.E online game like wow, And as for debugging writes all you need is the new NomadMemory.au3 and use the function SETPRIVILEGE("SeDebugPrivilege", 1) and your au3 app has all the rights a debugger has... hackinggggggg :D If someone has done this please PM me or post it thanks alotttt
*WoW Dev Projects: AFK Tele Bot development journalSimple Player Pointer Scanner + Z-Teleport*My Projects: coming soon.Check out my WoW Dev wiki for patch 3.0.9!http://www.wowdev.wikidot.com

#18 Dalord

Dalord

    Seeker

  • Active Members
  • 10 posts

Posted 02 April 2009 - 02:42 PM

I too am interested in inject ASM into a live process (Hi StrategicX, nice to see we are both researching the same line)

#19 TheOnlyOne

TheOnlyOne

    Prodigy

  • Active Members
  • PipPipPip
  • 169 posts

Posted 04 August 2010 - 04:41 PM

Hmm how can u use the jmp or je in here ? to a self made asm function ?

#20 AndyG

AndyG

    Prodigy

  • Active Members
  • PipPipPip
  • 187 posts

Posted 04 August 2010 - 08:30 PM

with Ward´s FASM-Assembly-UDF it is possible to call AutoIt-functions from Assemblercode. Look at the nice examples. With FASM the forward-jumps are also now possible. 




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users