trancexx Posted November 16, 2008 Share Posted November 16, 2008 (edited) Don't jump on me now for maybe somewhere bombastic title, that is intentional btw Anyway, this is nothing new. I mentioned earlier today in some post that Ward did it some time ago, but I'm not seeing him around lately I'm just translating it to plain human language. I know that there are some people that are actually very good with assembly (unlike me) and AutoIt (also unlike me) and I'm sure they can elevate this to the level of true AutoIt's virtue. This script is showing basic mathematical operations on two integers using inline (you might call it that way) assembly: expandcollapse popup#NoTrayIcon ConsoleWrite(_Add(56, 4) & @CRLF) ConsoleWrite(_Substract(75, 37) & @CRLF) ConsoleWrite(_Multiply(5, 7) & @CRLF) ConsoleWrite(_Divide(56, 8) & @CRLF) Func _Add($iNum1, $iNum2) #cs 55 push ebp 89E5 mov ebp, esp 8B4508 mov eax, dword[ebp+08] 03450C add eax, dword[ebp+0C] 5D pop ebp C3 ret #ce Local $Opcode = "0x5589E58B450803450C5DC3" ;ADD TWO INTEGERS Local $CodeBuffer = DllStructCreate("byte[" & BinaryLen($Opcode) & "]") DllStructSetData($CodeBuffer, 1, $Opcode) Local $Ret = DllCall("user32.dll", "int", "CallWindowProc", _ "ptr", DllStructGetPtr($CodeBuffer), _ "int", $iNum1, _ "int", $iNum2, _ "int", 0, _ "int", 0) Return $Ret[0] EndFunc Func _Substract($iNum1, $iNum2) #cs 55 push ebp 89E5 mov ebp, esp 8B4508 mov eax, dword[ebp+08] 2B450C sub eax, dword[ebp+0C] 5D pop ebp C3 ret #ce Local $Opcode = "0x5589E58B45082B450C5DC3" ;SUBSTRACT TWO INTEGERS Local $CodeBuffer = DllStructCreate("byte[" & BinaryLen($Opcode) & "]") DllStructSetData($CodeBuffer, 1, $Opcode) Local $Ret = DllCall("user32.dll", "int", "CallWindowProc", _ "ptr", DllStructGetPtr($CodeBuffer), _ "int", $iNum1, _ "int", $iNum2, _ "int", 0, _ "int", 0) Return $Ret[0] EndFunc Func _Multiply($iNum1, $iNum2) #cs 55 push ebp 89E5 mov ebp, esp 8B4508 mov eax, dword[ebp+08] F76D0C imul dword[ebp+0C] 5D pop ebp C3 ret #ce Local $Opcode = "0x5589E58B4508F76D0C5DC3" ;MULTIPLY TWO INTEGERS Local $CodeBuffer = DllStructCreate("byte[" & BinaryLen($Opcode) & "]") DllStructSetData($CodeBuffer, 1, $Opcode) Local $Ret = DllCall("user32.dll", "int", "CallWindowProc", _ "ptr", DllStructGetPtr($CodeBuffer), _ "int", $iNum1, _ "int", $iNum2, _ "int", 0, _ "int", 0) Return $Ret[0] EndFunc Func _Divide($iNum1, $iNum2) #cs 55 push ebp 89E5 mov ebp, esp 8B4508 mov eax, dword[ebp+08] 99 cdq F77D0C idiv dword[ebp+0C] 5D pop ebp C3 ret #ce Local $Opcode = "0x5589E58B450899F77D0C5DC3" ;DIVIDE TWO INTEGERS Local $CodeBuffer = DllStructCreate("byte[" & BinaryLen($Opcode) & "]") DllStructSetData($CodeBuffer, 1, $Opcode) Local $Ret = DllCall("user32.dll", "int", "CallWindowProc", _ "ptr", DllStructGetPtr($CodeBuffer), _ "int", $iNum1, _ "int", $iNum2, _ "int", 0, _ "int", 0) Return $Ret[0] EndFunc edit: typo, typo, eng, eng, typo Edited November 17, 2008 by trancexx ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
Zedna Posted November 16, 2008 Share Posted November 16, 2008 Looks nice and simple but it crashes on my WIN98SE Program made unsupported operation. Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
ahha Posted November 16, 2008 Share Posted November 16, 2008 Very nice. I'll keep it in mind when I really need speed. Link to comment Share on other sites More sharing options...
trancexx Posted November 17, 2008 Author Share Posted November 17, 2008 Looks nice and simple but it crashes on my WIN98SEProgram made unsupported operation.You know that MSLU thing?Do you have that instaled and in function? ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
Zedna Posted November 17, 2008 Share Posted November 17, 2008 You know that MSLU thing?Yes.Do you have that instaled and in function?Yes. Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
trancexx Posted November 17, 2008 Author Share Posted November 17, 2008 Yes.Try unicode version of CallWindowProc.MSDN link says that CallWindowProc is supported since Windows 95 and Windows NT 3.1 ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
trancexx Posted November 18, 2008 Author Share Posted November 18, 2008 Since you are quiet I would think that "W" is not a problem. It could be mutual* misunderstanding of your processor and $Opcode. What processor is there? Anyway, I wish Ward is here somewhere to help us with (assembly --> opcode) action. Unfortunately it appears that poor lady died. Yes, yes, that's right, Ward was this old lady (very old, like 110-120) and she died few weeks ago (so I was told by her mother) God rest her soul. One more word about this method. By implementing it you don't need to use external dlls. This is the same thing as that. If you look at any first post function you will actually be seeing a DllCall to some dll (function inside that dll) that is calculating for you. All that would come with that dll is everything arround its hart - the function. So, this is basically stripping redundancy. * - funny part ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
A. Percy Posted November 18, 2008 Share Posted November 18, 2008 Interesting! The only thing now is to make a asm interpreter to convert it to opcode Só o que posso lhe dizer, bom é quando faz mal!My work:Au3Irrlicht - Irrlicht for AutoItMsAgentLib - An UDF for MSAgentAu3GlPlugin T2 - A 3D plugin for AutoIt...OpenGl Plugin - The old version of Au3GlPlugin.MAC Address Changer - Changes the MAC AddressItCopter - A dragonfly R/C helicopter simulator VW Bug user Pinheiral (Pinewood) city: http://pt.wikipedia.org/wiki/Pinheiral Link to comment Share on other sites More sharing options...
jvanegmond Posted November 18, 2008 Share Posted November 18, 2008 (edited) Too bad. But I guess that was not the intent of showing this. For $i = 0 to UBound($addArray)-1 $addArray[$i] = Random(0,100,1) Next ;$tempvar because you can't just add and do nothing with it $normalAdd = TimerInit() For $i = 0 to UBound($addArray)-1 Step 2 $tempvar = $addArray[$i] + $addArray[$i+1] Next $timeNormal = TimerDiff($normalAdd) $assemblyAdd = TimerInit() For $i = 0 to UBound($addArray)-1 Step 2 $tempvar = _Add($addArray[$i],$addArray[$i+1]) Next $timeAssembly = TimerDiff($assemblyAdd) ConsoleWrite($timeNormal & @CRLF) ConsoleWrite($timeAssembly & @CRLF) Edited November 18, 2008 by Manadar github.com/jvanegmond Link to comment Share on other sites More sharing options...
trancexx Posted November 18, 2008 Author Share Posted November 18, 2008 (edited) Too bad. But I guess that was not the intent of showing this. For $i = 0 to UBound($addArray)-1 $addArray[$i] = Random(0,100,1) Next ;$tempvar because you can't just add and do nothing with it $normalAdd = TimerInit() For $i = 0 to UBound($addArray)-1 Step 2 $tempvar = $addArray[$i] + $addArray[$i+1] Next $timeNormal = TimerDiff($normalAdd) $assemblyAdd = TimerInit() For $i = 0 to UBound($addArray)-1 Step 2 $tempvar = _Add($addArray[$i],$addArray[$i+1]) Next $timeAssembly = TimerDiff($assemblyAdd) ConsoleWrite($timeNormal & @CRLF) ConsoleWrite($timeAssembly & @CRLF)I respect you and your coding abilities hence me take that as a joke. edit: words, playing with Edited November 18, 2008 by trancexx ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
Zedna Posted November 18, 2008 Share Posted November 18, 2008 (edited) Try unicode version of CallWindowProc.MSDN link says that CallWindowProc is supported since Windows 95 and Windows NT 3.11) on WIN98SE- with CallWindowProc it crashes- with CallWindowProcA it crashes too- with CallWindowProcW it returns 0 without error2) on WINXP- with CallWindowProc it works fine and returns good results Edited November 18, 2008 by Zedna Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
trancexx Posted November 19, 2008 Author Share Posted November 19, 2008 1) on WIN98SE - with CallWindowProc it crashes - with CallWindowProcA it crashes too - with CallWindowProcW it returns 0 without error 2) on WINXP - with CallWindowProc it works fine and returns good resultsProblem appears to be closely related with MSLU. ahhh, well... You know, I have one copy of Microsoft Windows v1.0 Header of programs says "This program requires Microsoft Windows" Try this. This should just print number 128: #NoTrayIcon ConsoleWrite(_Ret128() & @CRLF) Func _Ret128() #cs B8 mov eax, 00000080 C3 ret #ce Local $Opcode = "0xB880000000C3" Local $CodeBuffer = DllStructCreate("byte[" & BinaryLen($Opcode) & "]") DllStructSetData($CodeBuffer, 1, $Opcode) Local $Ret = DllCall("user32.dll", "int", "CallWindowProcW", _ "ptr", DllStructGetPtr($CodeBuffer), _ "int", 0, _ "int", 0, _ "int", 0, _ "int", 0) Return $Ret[0] EndFunc ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
rasim Posted November 19, 2008 Share Posted November 19, 2008 (edited) trancexxHey! Very nice example! Thanks for sharing. But where you found information about this? If this is not a secret, can you post the reference link? Edited November 19, 2008 by rasim Link to comment Share on other sites More sharing options...
jvanegmond Posted November 19, 2008 Share Posted November 19, 2008 I respect you and your coding abilities hence me take that as a joke.Hah, I guess I just needed to prove that to myself somehow.. I don't know what got into me either. github.com/jvanegmond Link to comment Share on other sites More sharing options...
trancexx Posted November 19, 2008 Author Share Posted November 19, 2008 trancexxHey! Very nice example! Thanks for sharing. But where you found information about this? If this is not a secret, can you post the reference link? No secrets (there was tis girly band named like that, I think ) here.I wouldn't know what to post you as a reference. This was implemented in some scripts posted by mentioned poor, to early passed away, little lady. I'm kidding here, that's obvious, right? I guess nothing can bring to life that non beating autoit heart.I guess the best reference would be reading Wards posts here on forum and posted codes.It hit me what is that about when source code of Base64Encode was posted. When I started thinking what would I do with that code if I was a compiler (khm, khm...) some cards were opened. (link to that).Loading dll from memory and related (link) is something that everyone should read too if interested in this. There can be seen how to implement call - very important instruction.And link to CallWindowProc function. ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
Zedna Posted November 19, 2008 Share Posted November 19, 2008 Problem appears to be closely related with MSLU. ahhh, well... You know, I have one copy of Microsoft Windows v1.0 Header of programs says "This program requires Microsoft Windows" Try this. This should just print number 128: #NoTrayIcon ConsoleWrite(_Ret128() & @CRLF) Func _Ret128() #cs B8 mov eax, 00000080 C3 ret #ce Local $Opcode = "0xB880000000C3" Local $CodeBuffer = DllStructCreate("byte[" & BinaryLen($Opcode) & "]") DllStructSetData($CodeBuffer, 1, $Opcode) Local $Ret = DllCall("user32.dll", "int", "CallWindowProcW", _ "ptr", DllStructGetPtr($CodeBuffer), _ "int", 0, _ "int", 0, _ "int", 0, _ "int", 0) Return $Ret[0] EndFunc Returns 0 on WIN98SE. Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
trancexx Posted November 20, 2008 Author Share Posted November 20, 2008 Returns 0 on WIN98SE.It would be lovely that it works but considering this (last sentence anyway) it's not really a problem. ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
Zedna Posted November 20, 2008 Share Posted November 20, 2008 It would be lovely that it works but considering this (last sentence anyway) it's not really a problem.I know about that. OK I will not be teasing you with Win9x anymore :-)Anyway good stuff in this your topic! Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
Ward Posted December 8, 2008 Share Posted December 8, 2008 Anyway, I wish Ward is here somewhere to help us with (assembly --> opcode) action. Unfortunately it appears that poor lady died. Yes, yes, that's right, Ward was this old lady (very old, like 110-120) and she died few weeks ago (so I was told by her mother) God rest her soul.Why I am a old lady Maybe my English is not good enough to understood what do you say 新版 _ArrayAdd 的白痴作者,不管是誰,去死一死好了。 Link to comment Share on other sites More sharing options...
trancexx Posted December 14, 2008 Author Share Posted December 14, 2008 Why I am a old lady Maybe my English is not good enough to understood what do you say You are alive!!! Someone's been lying How many ways there are to load assembly code from our scripts, that you know of?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. ♡♡♡ . eMyvnE 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