James Posted December 14, 2008 Share Posted December 14, 2008 You could technically write an ASM interpreter here. Add POP, PUSH and MOV and away you go Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ Link to comment Share on other sites More sharing options...
Ward Posted December 14, 2008 Share Posted December 14, 2008 How many ways there are to load assembly code from our scripts, that you know of?I only know how to load binary codes from scripts, however, this codes must be designed carefully to avoid static reference.If you really want to load assembly code, maybe you can try finding some assembler DLL, like this one olly_dll. I am too busy to test it now, may be later.But in fact, I don't think compiling assembly code and running them by script is really helpful. It is just for fun. A cleverer way is to compile the code into DLL and then load them by MemoryDLL. Is there any way for AutoIt script to be compiled to PE format? Why don't you try it? I can see thousands of problems, but I think that few smart heads could even make it happen.You mean Aut2exe? 新版 _ArrayAdd 的白痴作者,不管是誰,去死一死好了。 Link to comment Share on other sites More sharing options...
trancexx Posted December 14, 2008 Author Share Posted December 14, 2008 I only know how to load binary codes from scripts, however, this codes must be designed carefully to avoid static reference. If you really want to load assembly code, maybe you can try finding some assembler DLL, like this one olly_dll. I am too busy to test it now, may be later. But in fact, I don't think compiling assembly code and running them by script is really helpful. It is just for fun. A cleverer way is to compile the code into DLL and then load them by MemoryDLL. You mean Aut2exe?Fun is good. I don't mean Aut2exe. I mean something like this: Step 1 - make script Func _Add($iA, $iB) Return $iA + $iB EndFunc Step 2 - create assembly code out of that script push ebp mov ebp, esp mov eax, dword[ebp+08] add eax, dword[ebp+0C] pop ebp ret Step 3 - get opcode out of assembly code 0x5589E58B450803450C5DC3 step 4 - wrap it in exe or dll In other words - compile script to exe. Make a true compiler for AutoIt scripts. I'm aware of the size of possible job but nevertheless... ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
Ward Posted December 14, 2008 Share Posted December 14, 2008 You mean write a compiler? I will never say never, but it is really a very hard work you know... I think it may be not worth to try, even for fun. 新版 _ArrayAdd 的白痴作者,不管是誰,去死一死好了。 Link to comment Share on other sites More sharing options...
trancexx Posted December 14, 2008 Author Share Posted December 14, 2008 Yes, AutoIt is primarily scripting language and compiling option present at this moment is, I guess, just for popularizing it. But to be frank I'm in love with it's syntax and stuff. So when I think what could be done if it could be compiled. Well, you know... kids writing bitchen apps and maybe even Vulcans be coming. ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
monoceres Posted May 5, 2009 Share Posted May 5, 2009 (edited) Example of calling a function.expandcollapse popup#include <winapi.au3> ConsoleWrite("Entering sleep... ") AsmSleepCall(2500) ConsoleWrite("Done!"&@CRLF) Func AsmSleepCall($iMilliseconds) #cs Assembly code B8 00000000 move eax, 00000000 50 push eax E8 0x00000000 call 0x00000000 // This needs to be the offset from the instruction after the call C3 ret #ce ; Pointer to Sleep() Local $SleepAddress = DllCall("Kernel32.dll", "ptr", "GetProcAddress", "ptr", _WinAPI_GetModuleHandle("Kernel32.dll"), "str", "Sleep") $SleepAddress = $SleepAddress[0] Local $CodeBuffer = DllStructCreate("byte[12]") ; Calculate the offset from the address after the call Local $offset = $SleepAddress - (DllStructGetPtr($CodeBuffer) + 11) ; x86 is using little endian DllStructSetData($CodeBuffer, 1, "0xB8" & SwapEndian($iMilliseconds) & "50E8" & SwapEndian($offset) & "C3") Local $Ret = DllCall("user32.dll", "int", "CallWindowProc", _ "ptr", DllStructGetPtr($CodeBuffer), _ "int", 0, _ "int", 0, _ "int", 0, _ "int", 0) Return $Ret[0] EndFunc;==>AsmSleepCall Func SwapEndian($hex) Return Hex(BitOR(BitOR(BitOR(BitShift($hex, 24), _ BitAND(BitShift($hex, -8), 0x00FF0000)), _ BitAND(BitShift($hex, 8), 0x0000FF00)), _ BitShift($hex, -24)), 8) EndFunc;==>SwapEndianGuess I could squeeze more of the code into the binary, but meh, this was hard enough to get to work.For other people wantingto work with this, I used the following references for opcodes and opcode usage.http://developer.intel.com/design/PentiumI...uals/243191.htmhttp://www.swansontec.com/sintel.htmlhttp://www.sandpile.org/ia32/opc_1.htm Edited May 5, 2009 by monoceres Broken link? PM me and I'll send you the file! Link to comment Share on other sites More sharing options...
UEZ Posted May 5, 2009 Share Posted May 5, 2009 Example of calling a function. expandcollapse popupConsoleWrite("Entering sleep... ") AsmSleepCall(2500) ConsoleWrite("Done!"&@CRLF) Func AsmSleepCall($iMilliseconds) #cs Assembly code B8 00000000 move eax, 00000000 50 push eax E8 0x00000000 call 0x00000000 // This needs to be the offset from the instruction after the call C3 ret #ce ; Pointer to Sleep() Local $SleepAddress = DllCall("Kernel32.dll", "ptr", "GetProcAddress", "ptr", _WinAPI_GetModuleHandle("Kernel32.dll"), "str", "Sleep") $SleepAddress = $SleepAddress[0] Local $CodeBuffer = DllStructCreate("byte[12]") ; Calculate the offset from the address after the call Local $offset = $SleepAddress - (DllStructGetPtr($CodeBuffer) + 11) ; x86 is using little endian DllStructSetData($CodeBuffer, 1, "0xB8" & SwapEndian($iMilliseconds) & "50E8" & SwapEndian($offset) & "C3") Local $Ret = DllCall("user32.dll", "int", "CallWindowProc", _ "ptr", DllStructGetPtr($CodeBuffer), _ "int", 0, _ "int", 0, _ "int", 0, _ "int", 0) Return $Ret[0] EndFunc;==>AsmSleepCall Func SwapEndian($hex) Return Hex(BitOR(BitOR(BitOR(BitShift($hex, 24), _ BitAND(BitShift($hex, -8), 0x00FF0000)), _ BitAND(BitShift($hex, 8), 0x0000FF00)), _ BitShift($hex, -24)), 8) EndFunc;==>SwapEndian Guess I could squeeze more of the code into the binary, but meh, this was hard enough to get to work. For other people wantingto work with this, I used the following references for opcodes and opcode usage. http://developer.intel.com/design/PentiumI...uals/243191.htm http://www.swansontec.com/sintel.html http://www.sandpile.org/ia32/opc_1.htm Nice example but #include <WinAPI.au3> is missing UEZ Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
monoceres Posted May 5, 2009 Share Posted May 5, 2009 Nice example but #include <WinAPI.au3> is missing UEZOops, thanks. Broken link? PM me and I'll send you the file! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now