AutoIt Forums: AutoIt Inline Assembly UDF - AutoIt Forums

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

AutoIt Inline Assembly UDF Yes, it is Assembly! Rate Topic: -----

#1 User is offline   Ward 

  • Member
  • Pip
  • Group: Full Members
  • Posts: 44
  • Joined: 25-February 06
  • Location:Taiwan

Posted 26 December 2008 - 06: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:
[ code='text' ]    ( ExpandCollapse - Popup )
#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)
Number of downloads: 542

#2 User is offline   Lazycat 

  • Coding cat
  • Icon
  • Group: AutoIt MVPs(MVP)
  • Posts: 1,125
  • Joined: 15-December 03
  • Gender:Male
  • Location:Location: COLD

Posted 26 December 2008 - 08: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!

#3 User is offline   Dampe 

  • Spammer!
  • PipPipPip
  • Group: Full Members
  • Posts: 222
  • Joined: 03-November 07

Posted 26 December 2008 - 08:43 AM

Very nice, Unfortunately:

[ code='text' ]    ( Popup )
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

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

Result: 0.00672067206720672ms

This post has been edited by Dampe: 26 December 2008 - 08:43 AM


#4 User is offline   Ward 

  • Member
  • Pip
  • Group: Full Members
  • Posts: 44
  • Joined: 25-February 06
  • Location:Taiwan

Posted 26 December 2008 - 09:09 AM

View PostDampe, on Dec 25 2008, 11:43 PM, said:

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.

This post has been edited by Ward: 26 December 2008 - 09:10 AM


#5 User is offline   Lazycat 

  • Coding cat
  • Icon
  • Group: AutoIt MVPs(MVP)
  • Posts: 1,125
  • Joined: 15-December 03
  • Gender:Male
  • Location:Location: COLD

Posted 26 December 2008 - 09:10 AM

Quote

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.

#6 User is offline   SmOke_N 

  • It's not what you know .... It's what you can prove!
  • Icon
  • Group: Moderators(Mod)
  • Posts: 15,014
  • Joined: 21-February 05
  • Location:UNITED STATES

Posted 26 December 2008 - 09:24 AM

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

#7 User is offline   Dampe 

  • Spammer!
  • PipPipPip
  • Group: Full Members
  • Posts: 222
  • Joined: 03-November 07

Posted 26 December 2008 - 09:25 AM

View PostWard, on Dec 26 2008, 01:09 AM, said:

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 :)

#8 User is offline   oMBRa 

  • Mass Spammer!
  • PipPipPipPipPip
  • Group: Full Members
  • Posts: 814
  • Joined: 10-August 08
  • Location:italy

Posted 26 December 2008 - 01: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 User is offline   JamesBrooks 

  • Do You Wanna Be A Human Controlling An Avatar?
  • Icon
  • Group: AutoIt MVPs(MVP)
  • Posts: 7,783
  • Joined: 24-November 06
  • Gender:Male
  • Location:Null

Posted 26 December 2008 - 01:20 PM

View PostSmOke_N, on Dec 26 2008, 08:24 AM, said:

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 User is offline   doudou 

  • Member
  • Pip
  • Group: Full Members
  • Posts: 78
  • Joined: 18-November 05

Posted 26 December 2008 - 01: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! ;)

#11 User is offline   doudou 

  • Member
  • Pip
  • Group: Full Members
  • Posts: 78
  • Joined: 18-November 05

Posted 26 December 2008 - 01:27 PM

View PostoMBra, on Dec 26 2008, 02:12 PM, said:

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 :D Assembler won't help You at all unless Your cheat prog is registered as a debugger.

#12 User is offline   oMBRa 

  • Mass Spammer!
  • PipPipPipPipPip
  • Group: Full Members
  • Posts: 814
  • Joined: 10-August 08
  • Location:italy

Posted 26 December 2008 - 01:41 PM

u mean SeDebugPrivileges?

#13 User is offline   doudou 

  • Member
  • Pip
  • Group: Full Members
  • Posts: 78
  • Joined: 18-November 05

Posted 26 December 2008 - 01:51 PM

View PostoMBra, on Dec 26 2008, 02:41 PM, said:

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.

#14 User is offline   oMBRa 

  • Mass Spammer!
  • PipPipPipPipPip
  • Group: Full Members
  • Posts: 814
  • Joined: 10-August 08
  • Location:italy

Posted 26 December 2008 - 01:55 PM

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

#15 User is offline   doudou 

  • Member
  • Pip
  • Group: Full Members
  • Posts: 78
  • Joined: 18-November 05

Posted 26 December 2008 - 02:09 PM

View PostoMBra, on Dec 26 2008, 02:55 PM, said:

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.

#16 User is offline   Pain 

  • Mass Spammer!
  • PipPipPipPip
  • Group: Full Members
  • Posts: 592
  • Joined: 15-December 07
  • Location:Sweden

Posted 26 December 2008 - 08:35 PM

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

#17 User is offline   StrategicX 

  • Member
  • Pip
  • Group: Full Members
  • Posts: 43
  • Joined: 13-February 09

Posted 28 March 2009 - 07: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 :) If someone has done this please PM me or post it thanks alotttt

#18 User is offline   Dalord 

  • Newbie
  • Group: Full Members
  • Posts: 8
  • Joined: 20-January 09

Posted 02 April 2009 - 03: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)

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users