Popular Post Beege Posted April 25, 2020 Popular Post Share Posted April 25, 2020 (edited) Here is a idispatch object with all the base code written in assembly and is setup in a way so that it can be easily modified to integrate your own custom methods with minimal overhead code. Credits to @genius257 (and @trancexx for helping him) for his AutoitObject udf. I learned a tremendous amount from his code and a lot of the assembly is based of his work so many many thanks! Credits also to @LarsJ for his Accessing Autoit Variables thread showing us that we can expose the autoit variables via objects and how to work with the autoit variants/safearrays within assembly code. As mentioned above this is setup for you to modify so there's not a lot of functions you'll be calling directly and a good amount of code you should not have to touch but I'm going to explain the parts that your expected modify and how that code links to the functions you should not have to mess with. There's really only two spots. The first part is your function table. At the top of the IDispatchASM() function you will find a variable like code below called $sFunctions and will get used in two functions; _CreateFuncTable() and _AsmFuncTable(). You don't call these functions but that's where it gets used. One function gathers all the addresses of the functions and the other generates the assembly code allowing you to easily call these functions within your assembly code. The format is one dll per line with a comma separated list of functions for that dll. There is also one line included for autoit functions and will handle registering and releasing the callbacks so its all nicely in one spot. Local $sFunctions = 'kernel32.dll:HeapAlloc,GlobalAlloc,GlobalFree,GlobalLock,GlobalHandle,RtlMoveMemory' & @LF & _ 'oleaut32.dll:VariantInit,VariantCopy,VariantClear,' & @LF & _ 'au3:' & _RegisterAu3Callbacks('_CreateArray,ptr,dword|_GetKeys,ptr,ptr') To call any of function in the list, you just need to first load up a register with the current memory position and call that register with the function name added to it. Here's some small snips from the code showing what I mean: _('getmempos ebx'); load ebx with memory pos ..code... _('stdcall [ebx+_CreateArray], [esi+tObj.count]'); call autoit function to create an array for us to fill ..code... _('stdcall [ebx+VariantClear], [pVarResult]') _('stdcall [ebx+VariantCopy], [pVarResult],[edx+tProp.Variant]'); copy array to result _('stdcall [ebx+_CreateArray],0'); release object The second area that you will modify is the _invoke function and you would do this to add your own methods. All the methods that are currently included are completely optional and can be replaced/removed if you choose. Whats there right now is more or less practice. All you have to do to add your own method is create a new .elseif statement with the ID your assigning and name of method. Just follow the pattern like below. The _DefineDispID() function works hand in hand with the _AsmDispIDChecks() to automatically generate the lookup code needed to lookup the ID's. The only important part to remember when creating your own methods is that they MUST begin with characters "__" and you must use a negative ID starting at -2. I've written the lookup code to only check if this is one of our methods being called when the first 2 characters begin with "__" - this saves a lot of extra checking going on when its not a method being called. ;===================================== _(' .elseif dword[dispIdMember] = ' & _DefineDispID(-5,'__keys')); .. _(' getmempos ebx') ...code... _(' stdcall [ebx+_CreateArray],0'); release object ;===================================== _(' .elseif dword[dispIdMember] = ' & _DefineDispID(-6,'__fill')); _(' mov esi, [pDispParams]') ...code... _(' xor eax,eax'); set return S_OK ;===================================== _(' .elseif dword[dispIdMember] = ' & _DefineDispID(-7,'__reverse')) ; _(' mov esi, [pDispParams]') ...code... _(' xor eax,eax'); set return S_OK ;===================================== Let me know if you have issues, questions or comments. Thanks for looking Update 05/24/2020: I got x64 support working for this now. I didn't get all the methods converted but all the base code is there it looks to be stable (fingers crossed). It should be able to run this portion of the example either 32bit or 64bit. Example: Local $aArray = [111, 222, 333] $oIDispatch = IDispatchASM() $oIDispatch.string = "string test" $oIDispatch.__string = "__string test2" $oIDispatch.float = 12.345145 $oIDispatch.array = $aArray $oIDispatch.binary = Binary(12345678) $oIDispatch.bool = True $oIDispatch.dllStruct = DllStructCreate("BYTE t") $oIDispatch.dllStruct.t = 99 ConsoleWrite('-Direct get test:' & @CRLF & _ '$oIDispatch.string = ' & $oIDispatch.string & @CRLF & _ '$oIDispatch.__string = ' & $oIDispatch.__string & @CRLF & _ '$oIDispatch.float = ' & $oIDispatch.float & @CRLF & _ '$oIDispatch.array[1] = ' & $oIDispatch.array[1] & @CRLF) ConsoleWrite('-method __keysau3 test:' & @CRLF) Local $aKeyAU3s = $oIDispatch.__keysau3() ConsoleWrite('$aKeyAU3s = ' & _ArrayToString($aKeyAU3s) & @CRLF) ConsoleWrite('-method __get test:' & @CRLF) For $k In $oIDispatch.__keysau3() $val = $oIDispatch.__get($k) ConsoleWrite('$oIDispatch.' & $k & ' = ' & (IsArray($val) ? _ArrayToString($val) : (IsDllStruct($val) ? DllStructGetData($val, 1) : $val)) & @CRLF) Next ConsoleWrite('-method __set test:' & @CRLF) Local $i = 0 For $k In $oIDispatch.__keysau3() $oIDispatch.__set($k) = $i ConsoleWrite('$oIDispatch.' & $k & ' = ' & $oIDispatch.__get($k) & @CRLF) $i += 1 Next Output: -Direct get test: $oIDispatch.string = string test $oIDispatch.__string = __string test2 $oIDispatch.float = 12.345145 $oIDispatch.array[1] = 222 -method __keysau3 test: $aKeyAU3s = string|__string|float|array|binary|bool|dllStruct -method __get test: $oIDispatch.string = string test $oIDispatch.__string = __string test2 $oIDispatch.float = 12.345145 $oIDispatch.array = 111|222|333 $oIDispatch.binary = 0x4E61BC00 $oIDispatch.bool = True $oIDispatch.dllStruct = 99 -method __set test: $oIDispatch.string = 0 $oIDispatch.__string = 1 $oIDispatch.float = 2 $oIDispatch.array = 3 $oIDispatch.binary = 4 $oIDispatch.bool = 5 $oIDispatch.dllStruct = 6 I also added 2 more methods to the 32bit part. __PrintAllParms shows how to check the number of parms that were passed and then prints each one to the console. The second is __search and is generic (1D) array search method demonstrating the use of VarCmp function. That would be a key function in creating a arraysort as well. Let me know if you have any issues. Thanks! Edit: Fixed issue with beta versions of autoit not working IDispatchASM 5-24-2020.zip Previous versions: Spoiler IDispatchASM.zip IDispatchASM 5-24-2020.zip Edited May 24, 2020 by Beege Danyfirex, UEZ, genius257 and 4 others 7 Assembly Code: fasmg . fasm . BmpSearch . Au3 Syntax Highlighter . Bounce Multithreading Example . IDispatchASMUDFs: Explorer Frame . ITaskBarList . Scrolling Line Graph . Tray Icon Bar Graph . Explorer Listview . Wiimote . WinSnap . Flicker Free Labels . iTunesPrograms: Ftp Explorer . Snipster . Network Meter . Resistance Calculator Link to comment Share on other sites More sharing options...
UEZ Posted April 25, 2020 Share Posted April 25, 2020 Great work @Beege 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...
Beege Posted April 25, 2020 Author Share Posted April 25, 2020 Thanks UEZ! Im working on a x64 version next 😉 Assembly Code: fasmg . fasm . BmpSearch . Au3 Syntax Highlighter . Bounce Multithreading Example . IDispatchASMUDFs: Explorer Frame . ITaskBarList . Scrolling Line Graph . Tray Icon Bar Graph . Explorer Listview . Wiimote . WinSnap . Flicker Free Labels . iTunesPrograms: Ftp Explorer . Snipster . Network Meter . Resistance Calculator Link to comment Share on other sites More sharing options...
argumentum Posted April 26, 2020 Share Posted April 26, 2020 7 hours ago, Beege said: Let me know if you have issues, questions or comments. There are no issues or comments. But I have a ton of questions, like "What is a dispatch object ?", just to start. So, where can I read up on dispatch, at a kindergarten level seadoggie01 1 Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting. Link to comment Share on other sites More sharing options...
Beege Posted April 26, 2020 Author Share Posted April 26, 2020 1 hour ago, argumentum said: There are no issues or comments. But I have a ton of questions, like "What is a dispatch object ?", just to start. So, where can I read up on dispatch, at a kindergarten level Im gonna change that to iDispatch, but even with that change I dont know if "idispatch object" is an actual thing, its just what I started calling it in my head. IDispatch is the interface we are using to create the object. It all really started with Hooking into the IDispatch interface. Then came AutoitObject and sometime later we got the native function ObjCreateInterface. iDispatch is what your looking to read up on. argumentum 1 Assembly Code: fasmg . fasm . BmpSearch . Au3 Syntax Highlighter . Bounce Multithreading Example . IDispatchASMUDFs: Explorer Frame . ITaskBarList . Scrolling Line Graph . Tray Icon Bar Graph . Explorer Listview . Wiimote . WinSnap . Flicker Free Labels . iTunesPrograms: Ftp Explorer . Snipster . Network Meter . Resistance Calculator Link to comment Share on other sites More sharing options...
Beege Posted April 27, 2020 Author Share Posted April 27, 2020 (edited) Here is another version of the reverse method only this one does not make a copy to a second array, it modifies the original array. It works like the autoit one doing half the loops by swapping the first and last elements each loop. Let me know if any questions _(' .elseif [dispIdMember] = ' & _DefineDispID(-8,'__reverse2')) ; _(' mov esi, [pDispParams]') _(' mov esi, [esi+tDISPPARAMS.rgvargs]'); variant passed _(' mov esi, [esi+tVARIANT.data]'); this is the safearray _(' inc [esi+tSAFEARRAY.cLocks]'); set lock _( _fasmg_Debug('struct:esi:' & $tagSAFEARRAY)) _(' mov eax, [esi+tSAFEARRAY.cElements]') ; number of elements (Ubound) _(' dec eax'); subtract 1 as in Ubound($a)-1 _(' mod eax, 2'); divide by 2 - result in eax (mod result in edx) _(' mov ecx, eax'); set loop count _(' mov eax, [esi+tSAFEARRAY.cElements]'); set ecx to number of elements (Ubound) _(' dec eax') _(' mov edx, [esi+tSAFEARRAY.cbElements]'); this is size of element _(' mul edx'); this is multiplying eax*edx -> result in eax. eax now equals distance to last element _(' add eax, [esi+tSAFEARRAY.pvData]'); eax = address of last element _(' mov edx, [esi+tSAFEARRAY.pvData]'); edx = address of first element _(' reversea2:') _(' push [eax+tVARIANT.vt]'); push last element type _(' push [edx+tVARIANT.vt]'); push first element type _(' pop [eax+tVARIANT.vt]'); pop first element to last _(' pop [edx+tVARIANT.vt]'); pop last to first _(' push [eax+tVARIANT.data]'); repeat for data _(' push [edx+tVARIANT.data]') _(' pop [eax+tVARIANT.data]') _(' pop [edx+tVARIANT.data]') _(' add edx, [esi+tSAFEARRAY.cbElements]') ;Add size of variant structure to edx to move on to next element _(' sub eax, [esi+tSAFEARRAY.cbElements]'); subtrack size _(' loop reversea2') _(' dec [esi+tSAFEARRAY.cLocks]'); remove lock _(' xor eax,eax') ;===================================== Edited April 27, 2020 by Beege Assembly Code: fasmg . fasm . BmpSearch . Au3 Syntax Highlighter . Bounce Multithreading Example . IDispatchASMUDFs: Explorer Frame . ITaskBarList . Scrolling Line Graph . Tray Icon Bar Graph . Explorer Listview . Wiimote . WinSnap . Flicker Free Labels . iTunesPrograms: Ftp Explorer . Snipster . Network Meter . Resistance Calculator Link to comment Share on other sites More sharing options...
idontknow Posted April 28, 2020 Share Posted April 28, 2020 Very Nice ! May i ask how i can run __defineGetter and __defineSetter like AutoItObject Thanks Link to comment Share on other sites More sharing options...
Beege Posted April 28, 2020 Author Share Posted April 28, 2020 20 hours ago, idontknow said: Very Nice ! May i ask how i can run __defineGetter and __defineSetter like AutoItObject Thanks Thank you. Those methods do not exist in the current code so they would have to be written. This isnt a replacement for AutoItobject. All the base code does handle the main stuff for the properties like creation, put, get, name lookup, release. All the methods I have in place right now are optional and could be replaced with whatever kind of method you want to write. The benifits here are more for assembly writting and being able to directly pass autoit variables right into your code. Its also much much easier to just tack on more functions (methods) with ease and not having to do all the leg work you normally would with creating a whole new assembly function and new Dllcalladdress to go along with it and whatever variables you are passing.. it can start being a pain in the ass. Now we can just paste in new methods like the __reverse2 I have above and it magically becomes available right in the autoit code. Assembly Code: fasmg . fasm . BmpSearch . Au3 Syntax Highlighter . Bounce Multithreading Example . IDispatchASMUDFs: Explorer Frame . ITaskBarList . Scrolling Line Graph . Tray Icon Bar Graph . Explorer Listview . Wiimote . WinSnap . Flicker Free Labels . iTunesPrograms: Ftp Explorer . Snipster . Network Meter . Resistance Calculator Link to comment Share on other sites More sharing options...
Bilgus Posted May 4, 2020 Share Posted May 4, 2020 I like the way you compile the ASM on the fly unfortunately it crashes if I run the example or is is that even compiled as x86 it doesn't work on x64 pcs? I wasn't thinking that were the case..? You have the upperhand here with running code in a separate process But I'd like to see the difference in speed on the calls versus doing it in Autoit like: Link to comment Share on other sites More sharing options...
Bilgus Posted May 4, 2020 Share Posted May 4, 2020 Little Proof Of Concept Spoiler expandcollapse popup#Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_UseX64=y #AutoIt3Wrapper_AU3Check_Parameters=-d -w 1 -w 2 -w 3 -w- 4 -w 5 -w 6 #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** ;Au3CallByName, Bilgus Global $Au3_CallByName = 0 Local $hKernel32 = DllOpen("Kernel32.dll") OnAutoItExitRegister(__CallByNameCleanup) Global $oDictionary Func __CallByNameCleanup() Au3_CallByName_Init(False) ;Unload DllClose($hKernel32) EndFunc ;==>__CallByNameCleanup ; Takes a pointer to the v-table in a class and replaces specified member Id in it to a new one. Func __HookVTableEntry($pVtable, $iVtableOffset, $pHook, ByRef $pOldRet) ;;https://www.autoitscript.com/forum/topic/107678-hooking-into-the-idispatch-interface/ Local Const $PAGE_READWRITE = 0x04 Local $tpVtable = DllStructCreate("ptr", $pVtable) Local $szPtr = DllStructGetSize($tpVtable) Local $pFirstEntry, $pEntry, $tEntry, $aCall, $flOldProtect, $bStatus ; Dereference the vtable pointer $pFirstEntry = DllStructGetData($tpVtable, 1) $pEntry = $pFirstEntry + ($iVtableOffset * $szPtr) ;vtable is a big array of pointers ; Make the memory free for all. Yay! $aCall = DllCall($hKernel32, "int", "VirtualProtect", "ptr", $pEntry, "long", $szPtr, "dword", $PAGE_READWRITE, "dword*", 0) If @error Or Not $aCall[0] Then ConsoleWriteError("Error: Failed To hook vTable" & @CRLF) Return False EndIf $flOldProtect = $aCall[4] $tEntry = DllStructCreate("ptr", $pEntry) $pOldRet = DllStructGetData($tEntry, 1) If $pOldRet <> $pHook Then DllStructSetData($tEntry, 1, $pHook) $bStatus = True Else ;Already Hooked ConsoleWriteError("Error: vTable is already hooked" & @CRLF) $bStatus = False EndIf ;put the memory protect back how we found it DllCall($hKernel32, "int", "VirtualProtect", "ptr", $pEntry, "long", $szPtr, "dword", $flOldProtect, "dword*", 0) Return $bStatus EndFunc ;==>__HookVTableEntry ; Everytime autoit wants to call a method, get or set a property in a object it needs to go to ; IDispatch::GetIDsFromNames. This is our version of that function, note that by defining this ourselves ; we can fool autoit to believe that the object supports a lot of different properties/methods. Func __IDispatch_GetIDsFromNames($pSelf, $riid, $rgszNames, $cNames, $lcid, $rgDispId) Local Const $DISP_E_UNKNOWNNAME = 0x80020006, $DISPID_UNKNOWN = -1 Local Static $pGIFN = __Pointer_GetIDsFromNames() Local $hRes ;Call the original GetIDsFromNames $hRes = DllCallAddress("LRESULT", $pGIFN, "ptr", $pSelf, "ptr", $riid, _ "struct*", $rgszNames, "dword", $cNames, "dword", $lcid, "ptr", $rgDispId) If @error Then ConsoleWriteError("Error: GetIDsFromNames: " & @error & @CRLF) Return $DISP_E_UNKNOWNNAME EndIf ; Autoit didnt find the name now its our turn If $DISPID_UNKNOWN = DllStructGetData(DllStructCreate("long[" & $cNames & "]", $rgDispId), 1, 1) Then ;$rgszNames is a pointer to an array[$cNames] of names -- Autoit only asks for one member $cNames = 1 Local $tName = DllStructCreate("wchar[64]", DllStructGetData(DllStructCreate("ptr[" & $cNames & "]", $rgszNames), 1, 1)) Local $sName = DllStructGetData($tName, 1) ;We just prepend CBN_CB_ to the function name and try to call it $hRes = Call("CBN_CB_" & $sName, $sName, $pGIFN, $pSelf, $riid, $rgszNames, $cNames, $lcid, $rgDispId) If $hRes <> Default Then Return $hRes ; User handled the function ;Call the original GetIDsFromNames $hRes = DllCallAddress("LRESULT", $pGIFN, "ptr", $pSelf, "ptr", $riid, _ "struct*", $rgszNames, "dword", $cNames, "dword", $lcid, "ptr", $rgDispId) If @error Then ConsoleWrite("Error: GetIDsFromNames: " & @error & @CRLF) Return $DISP_E_UNKNOWNNAME EndIf EndIf Return $hRes[0] EndFunc ;==>__IDispatch_GetIDsFromNames Func __Pointer_GetIDsFromNames($ptr = 0) ;Stores pointer to the original 'GetIDsFromNames' Local Static $pOldGIFN = $ptr If $ptr <> 0 Then $pOldGIFN = $ptr Return $pOldGIFN EndFunc ;==>__Pointer_GetIDsFromNames Func Au3_CallByName_Init($bHook = True, $classname = "shell.application") Local Const $iOffset_GetIDsFromNames = 5 ;vtable index Local Static $IDispatch_GetIDsFromNames_Callback = 0 Local $oObject, $pObject, $pHook, $pOldGIFN If $bHook Then If $IDispatch_GetIDsFromNames_Callback = 0 Then $IDispatch_GetIDsFromNames_Callback = DllCallbackRegister("__IDispatch_GetIDsFromNames", _ "LRESULT", "ptr;ptr;ptr;dword;dword;ptr") EndIf $pHook = DllCallbackGetPtr($IDispatch_GetIDsFromNames_Callback) Else $pHook = __Pointer_GetIDsFromNames() If $pHook <= 0 Then Return ;Already Unloaded EndIf $oObject = ObjCreate($classname) $pObject = DllStructSetData(DllStructCreate("ptr"), 1, $oObject) If __HookVTableEntry($pObject, $iOffset_GetIDsFromNames, $pHook, $pOldGIFN) Then __Pointer_GetIDsFromNames($pOldGIFN) ;Save the original pointer to GetIDsFromNames If Not $bHook Then DllCallbackFree($IDispatch_GetIDsFromNames_Callback) $IDispatch_GetIDsFromNames_Callback = 0 EndIf Else ;Error EndIf $oObject = 0 EndFunc ;==>Au3_CallByName_Init ;|||||||||===========||||||||| ;||||||||| CallBacks ||||||||| Global $hFunc = DllCallbackRegister("FSU_Func", "LRESULT", "ptr;int") ;DllCallbackFree($hFunc) Global $pOldFunc Func FSU_Func($pSelf, $i) #ForceRef $pSelf ConsoleWrite("!Test CB " & $i & @crlf) Return 0x0 EndFunc Func CBN_CB_Au3_CallByName($sName, $pGIFN, $pSelf, $riid, $rgszNames, $cNames, $lcid, $rgDispId) Local Const $DISP_E_UNKNOWNNAME = 0x80020006 ConsoleWrite(">Call By Name: " & $sName & @crlf) Local Static $tpMember = DllStructCreate("ptr") If $Au3_CallByName Then Local $hRes, $tMember ;ConsoleWrite("CallByName: " & $Au3_CallByName & @CRLF) $tMember = DllStructCreate("wchar[" & StringLen($Au3_CallByName) + 1 & "]") DllStructSetData($tMember, 1, $Au3_CallByName) DllStructSetData($tpMember, 1, DllStructGetPtr($tMember)) $rgszNames = $tpMember $Au3_CallByName = 0 ;Call the original GetIDsFromNames $hRes = DllCallAddress("LRESULT", $pGIFN, "ptr", $pSelf, "ptr", $riid, _ "struct*", $rgszNames, "dword", $cNames, "dword", $lcid, "ptr", $rgDispId) If @error Then ConsoleWrite("Error: Call By Name: " & @error & @CRLF) Return $DISP_E_UNKNOWNNAME EndIf Return $hRes[0] EndIf Return Default ;Default handler EndFunc Func CBN_CB_MyNewFunction($sName, $pGIFN, $pSelf, $riid, $rgszNames, $cNames, $lcid, $rgDispId) #ForceRef $pGIFN, $pSelf, $riid, $rgszNames, $cNames, $lcid, $rgDispId ConsoleWrite(">MyNewFunction: " & $sName & @crlf) ;Screwed up stuff just POC patch the second entry to out own function Local $oObj = $oDictionary Local $pObj = DllStructSetData(DllStructCreate("ptr"), 1, $oObj) __HookVTableEntry($pObj, 4, DllCallbackGetPtr($hFunc), $pOldFunc) ;Monkey patch! DllStructSetData(DllStructCreate("long[" & $cNames & "]", $rgDispId), 1, 4, 1) ; Point at vtable entry 4 (RemoveAll) Return 0x0 ;Success! EndFunc ;||||||||| CallBacks ||||||||| ;|||||||||===========||||||||| ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;TESTS; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; $oDictionary = ObjCreate("Scripting.Dictionary") Au3_CallByName_Init() Sleep(1000) For $i = 1 To 3 $Au3_CallByName = "Add" $oDictionary.Au3_CallByName("test1:" & $i, "Dictionary Item: " & $i) Next $Au3_CallByName = "keys" For $sKey In $oDictionary.Au3_CallByName() For $j = 0 To 1 $Au3_CallByName = ($j = 0) ? "Item" : "Exists" ConsoleWrite($sKey & " -> " & $oDictionary.Au3_CallByName($sKey) & @CRLF) Next Next $oDictionary.RemoveAll $oDictionary.MyNewFunction() $oDictionary.RemoveAll() Au3_CallByName_Init(False) ;Unload (Not Strictly Needed, Done on Script Close) So this is the above Au3_CallbyName code but using a callback mechanism when we call MyNewFunction it monkey patches the vtable entry of oDictionary.RemoveAll and runs our function FSU_Func (And If you are wondering YES probably a bad idea) you'll notice the next call to RemoveAll calls our function too Next step would be to expand the vtable so we can patch in or own functions and parameters to them which I think @monoceres mentioned in one of his examples.. Link to comment Share on other sites More sharing options...
Beege Posted May 10, 2020 Author Share Posted May 10, 2020 On 5/4/2020 at 1:41 AM, Bilgus said: Little Proof Of Concept Thanks for the posts @Bilgus, that's a pretty cool example. I've actually been trying to see if I can work with a scripting.dictionary object within some assembly code if I passed it as a parameter and this might get me a little closer. As for x64 that's still on the to-do list. This is all x86 only right now. x64 was supposed to be next but I've been distracted with just getting a feel for working with the autoit variables. When it comes to speed of just calling the functions I don't think there is going to be that much of a difference. This is not a separate process. The performance potential you get with mixing autoit and assembly are the spots where autoit has to do a lot of loops during the processing. Assembly Code: fasmg . fasm . BmpSearch . Au3 Syntax Highlighter . Bounce Multithreading Example . IDispatchASMUDFs: Explorer Frame . ITaskBarList . Scrolling Line Graph . Tray Icon Bar Graph . Explorer Listview . Wiimote . WinSnap . Flicker Free Labels . iTunesPrograms: Ftp Explorer . Snipster . Network Meter . Resistance Calculator Link to comment Share on other sites More sharing options...
Beege Posted May 24, 2020 Author Share Posted May 24, 2020 I got the x64 portion of this working now. Danyfirex 1 Assembly Code: fasmg . fasm . BmpSearch . Au3 Syntax Highlighter . Bounce Multithreading Example . IDispatchASMUDFs: Explorer Frame . ITaskBarList . Scrolling Line Graph . Tray Icon Bar Graph . Explorer Listview . Wiimote . WinSnap . Flicker Free Labels . iTunesPrograms: Ftp Explorer . Snipster . Network Meter . Resistance Calculator Link to comment Share on other sites More sharing options...
argumentum Posted May 24, 2020 Share Posted May 24, 2020 On 4/25/2020 at 3:06 PM, Beege said: Update 05/24/2020: I got x64 support working for this now. x64 in 3.3.14.5 wont run but in the beta 3.3.15.3 runs just fine. Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting. Link to comment Share on other sites More sharing options...
Beege Posted May 24, 2020 Author Share Posted May 24, 2020 (edited) 2 hours ago, argumentum said: x64 in 3.3.14.5 wont run but in the beta 3.3.15.3 runs just fine. Did you get the same result for the compiled example? I justed tested on a second pc and everything seems ok. I'm definitely running 3.3.14.5. If the compiled example works then this may have something to do with the path of your 32bit version of autoit.exe, but the script should have given you a message saying it couldnt find the exe. Edit: I'm actually seeing the opposite. The only beta I can get x64 compiled example to work is 3.3.15.0. I get a crash when using beta version's 3.3.15.1, 3.3.15.2, and 3.3.15.3 >"C:\Program Files (x86)\AutoIt3\SciTE\..\AutoIt3.exe" "C:\Program Files (x86)\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.au3" /run /prod /ErrorStdOut /in "C:\Users\bj\Downloads\IDispatchASM 5-24-2020\IdispatchASM.au3" /UserParams +>11:46:30 Starting AutoIt3Wrapper v.19.102.1901.0 SciTE v.4.1.2.0 Keyboard:00000409 OS:WIN_10/ CPU:X64 OS:X64 Environment(Language:0409) CodePage:0 utf8.auto.check:4 +> SciTEDir => C:\Program Files (x86)\AutoIt3\SciTE UserDir => C:\Users\bj\AppData\Local\AutoIt v3\SciTE\AutoIt3Wrapper SCITE_USERHOME => C:\Users\bj\AppData\Local\AutoIt v3\SciTE >Running AU3Check (3.3.14.5) from:C:\Program Files (x86)\AutoIt3 input:C:\Users\bj\Downloads\IDispatchASM 5-24-2020\IdispatchASM.au3 +>11:46:30 AU3Check ended.rc:0 >Running:(3.3.14.5):C:\Program Files (x86)\AutoIt3\autoit3_x64.exe "C:\Users\bj\Downloads\IDispatchASM 5-24-2020\IdispatchASM.au3" +>Setting Hotkeys...--> Press Ctrl+Alt+Break to Restart or Ctrl+Break to Stop -Direct get test: $oIDispatch.string = string test $oIDispatch.__string = __string test2 $oIDispatch.float = 12.345145 $oIDispatch.array[1] = 222 -method __keysau3 test: $aKeyAU3s = string|__string|float|array|binary|bool|dllStruct -method __get test: $oIDispatch.string = string test $oIDispatch.__string = __string test2 $oIDispatch.float = 12.345145 $oIDispatch.array = 111|222|333 $oIDispatch.binary = 0x4E61BC00 $oIDispatch.bool = True $oIDispatch.dllStruct = 99 -method __set test: $oIDispatch.string = 0 $oIDispatch.__string = 1 $oIDispatch.float = 2 $oIDispatch.array = 3 $oIDispatch.binary = 4 $oIDispatch.bool = 5 $oIDispatch.dllStruct = 6 +>11:46:32 AutoIt3.exe ended.rc:0 +>11:46:32 AutoIt3Wrapper Finished. >Exit code: 0 Time: 2.767 Edited May 24, 2020 by Beege Assembly Code: fasmg . fasm . BmpSearch . Au3 Syntax Highlighter . Bounce Multithreading Example . IDispatchASMUDFs: Explorer Frame . ITaskBarList . Scrolling Line Graph . Tray Icon Bar Graph . Explorer Listview . Wiimote . WinSnap . Flicker Free Labels . iTunesPrograms: Ftp Explorer . Snipster . Network Meter . Resistance Calculator Link to comment Share on other sites More sharing options...
argumentum Posted May 24, 2020 Share Posted May 24, 2020 (edited) What a pickle !. In Win10 1909 ( run "winver" ), it behaves as in yours but on Win10 1607, is the other way around. My main PC is with 1607 but I have other PCs, mainly to test if my coding works abroad. Since Jon is looking at workarounds due to the, masterful updates in Win10, this may help him in debugging too, if he find it relevant to AutoIt. ..and as a side note: Is thanks to ppl like you is that I can have working code. Thanks. This is the 1607 console Spoiler expandcollapse popup>"C:\ProgFilesSelf\AutoIt3\SciTE\..\AutoIt3.exe" "C:\ProgFilesSelf\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.au3" /run /prod /ErrorStdOut /in "C:\Users\Tester\Downloads\au3.IDispatchASM 5-24-2020\IdispatchASM_compiled_example.au3" /UserParams +>14:02:45 Starting AutoIt3Wrapper (19.1127.1402.2} from:SciTE.exe (4.1.2.0) Keyboard:00000409 OS:WIN_10/ CPU:X64 OS:X64 Environment(Language:0409) CodePage:0 utf8.auto.check:4 +> SciTEDir => C:\ProgFilesSelf\AutoIt3\SciTE UserDir => C:\Users\Tester\AppData\Local\AutoIt v3\SciTE\AutoIt3Wrapper SCITE_USERHOME => C:\Users\Tester\AppData\Local\AutoIt v3\SciTE >Running AU3Check (3.3.14.5) from:C:\ProgFilesSelf\AutoIt3 input:C:\Users\Tester\Downloads\au3.IDispatchASM 5-24-2020\IdispatchASM_compiled_example.au3 +>14:02:45 AU3Check ended.rc:0 >Running:(3.3.14.5):C:\ProgFilesSelf\AutoIt3\autoit3_x64.exe "C:\Users\Tester\Downloads\au3.IDispatchASM 5-24-2020\IdispatchASM_compiled_example.au3" +>Setting Hotkeys...--> Press Ctrl+Alt+Break to Restart or Ctrl+BREAK to Stop. !>14:02:46 AutoIt3.exe ended.rc:-1073741819 +>14:02:46 AutoIt3Wrapper Finished. >Exit code: 3221225477 Time: 1.551 >"C:\ProgFilesSelf\AutoIt3\SciTE\..\AutoIt3.exe" "C:\ProgFilesSelf\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.au3" /run /beta /ErrorStdOut /in "C:\Users\Tester\Downloads\au3.IDispatchASM 5-24-2020\IdispatchASM_compiled_example.au3" /UserParams +>14:03:36 Starting AutoIt3Wrapper (19.1127.1402.2} from:SciTE.exe (4.1.2.0) Keyboard:00000409 OS:WIN_10/ CPU:X64 OS:X64 Environment(Language:0409) CodePage:0 utf8.auto.check:4 +> SciTEDir => C:\ProgFilesSelf\AutoIt3\SciTE UserDir => C:\Users\Tester\AppData\Local\AutoIt v3\SciTE\AutoIt3Wrapper SCITE_USERHOME => C:\Users\Tester\AppData\Local\AutoIt v3\SciTE >Running AU3Check (3.3.15.3) from:C:\ProgFilesSelf\AutoIt3\Beta input:C:\Users\Tester\Downloads\au3.IDispatchASM 5-24-2020\IdispatchASM_compiled_example.au3 +>14:03:37 AU3Check ended.rc:0 >Running:(3.3.15.3):C:\ProgFilesSelf\AutoIt3\Beta\autoit3_x64.exe "C:\Users\Tester\Downloads\au3.IDispatchASM 5-24-2020\IdispatchASM_compiled_example.au3" +>Setting Hotkeys...--> Press Ctrl+Alt+Break to Restart or Ctrl+BREAK to Stop. -Direct get test: $oIDispatch.string = string test $oIDispatch.__string = __string test2 $oIDispatch.float = 12.345145 $oIDispatch.array[1] = 222 -method __keysau3 test: $aKeyAU3s = string|__string|float|array|binary|bool|dllStruct -method __get test: $oIDispatch.string = string test $oIDispatch.__string = __string test2 $oIDispatch.float = 12.345145 $oIDispatch.array = 111|222|333|444 $oIDispatch.binary = 0x4E61BC00 $oIDispatch.bool = True $oIDispatch.dllStruct = 99 -method __set test: $oIDispatch.string = 0 $oIDispatch.__string = 1 $oIDispatch.float = 2 $oIDispatch.array = 3 $oIDispatch.binary = 4 $oIDispatch.bool = 5 $oIDispatch.dllStruct = 6 +>14:03:37 AutoIt3.exe ended.rc:0 +>14:03:37 AutoIt3Wrapper Finished. >Exit code: 0 Time: 0.8606 This is the 1909 console Spoiler expandcollapse popup>"C:\Utilities\AutoIt3\SciTE\..\AutoIt3.exe" "C:\Utilities\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.au3" /run /prod /ErrorStdOut /in "C:\Users\Tester\Downloads\IDispatchASM 5-24-2020\IdispatchASM_compiled_example.au3" /UserParams +>14:32:49 Starting AutoIt3Wrapper (19.1127.1402.0} from:SciTE.exe (4.2.0.0) Keyboard:00000409 OS:WIN_10/ CPU:X64 OS:X64 Environment(Language:0409) CodePage:0 utf8.auto.check:4 +> SciTEDir => C:\Utilities\AutoIt3\SciTE UserDir => C:\Users\Public\AutoIt v3\SciTE\AutoIt3Wrapper SCITE_USERHOME => C:\Users\Public\AutoIt v3\SciTE >Running AU3Check (3.3.14.5) from:C:\Utilities\AutoIt3 input:C:\Users\Tester\Downloads\IDispatchASM 5-24-2020\IdispatchASM_compiled_example.au3 +>14:32:49 AU3Check ended.rc:0 >Running:(3.3.14.5):C:\Utilities\AutoIt3\autoit3_x64.exe "C:\Users\Tester\Downloads\IDispatchASM 5-24-2020\IdispatchASM_compiled_example.au3" +>Setting Hotkeys...--> Press Ctrl+Alt+Break to Restart or Ctrl+BREAK to Stop. -Direct get test: $oIDispatch.string = string test $oIDispatch.__string = __string test2 $oIDispatch.float = 12.345145 $oIDispatch.array[1] = 222 -method __keysau3 test: $aKeyAU3s = string|__string|float|array|binary|bool|dllStruct -method __get test: $oIDispatch.string = string test $oIDispatch.__string = __string test2 $oIDispatch.float = 12.345145 $oIDispatch.array = 111|222|333 $oIDispatch.binary = 0x4E61BC00 $oIDispatch.bool = True $oIDispatch.dllStruct = 99 -method __set test: $oIDispatch.string = 0 $oIDispatch.__string = 1 $oIDispatch.float = 2 $oIDispatch.array = 3 $oIDispatch.binary = 4 $oIDispatch.bool = 5 $oIDispatch.dllStruct = 6 +>14:32:50 AutoIt3.exe ended.rc:0 +>14:32:50 AutoIt3Wrapper Finished. >Exit code: 0 Time: 1.835 >"C:\Utilities\AutoIt3\SciTE\..\AutoIt3.exe" "C:\Utilities\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.au3" /run /beta /ErrorStdOut /in "C:\Users\Tester\Downloads\IDispatchASM 5-24-2020\IdispatchASM_compiled_example.au3" /UserParams +>14:09:44 Starting AutoIt3Wrapper (19.1127.1402.0} from:SciTE.exe (4.2.0.0) Keyboard:00000409 OS:WIN_10/ CPU:X64 OS:X64 Environment(Language:0409) CodePage:0 utf8.auto.check:4 +> SciTEDir => C:\Utilities\AutoIt3\SciTE UserDir => C:\Users\Public\AutoIt v3\SciTE\AutoIt3Wrapper SCITE_USERHOME => C:\Users\Public\AutoIt v3\SciTE >Running AU3Check (3.3.15.3) from:C:\Utilities\AutoIt3\Beta input:C:\Users\Tester\Downloads\IDispatchASM 5-24-2020\IdispatchASM_compiled_example.au3 +>14:09:44 AU3Check ended.rc:0 >Running:(3.3.15.3):C:\Utilities\AutoIt3\Beta\autoit3_x64.exe "C:\Users\Tester\Downloads\IDispatchASM 5-24-2020\IdispatchASM_compiled_example.au3" +>Setting Hotkeys...--> Press Ctrl+Alt+Break to Restart or Ctrl+BREAK to Stop. !>14:09:46 AutoIt3.exe ended.rc:-1073741819 +>14:09:46 AutoIt3Wrapper Finished. >Exit code: 3221225477 Time: 3.221 ...add to your code ConsoleWrite('+ ReleaseId: ' & RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion", "ReleaseId") & @CRLF) ,to report what Win10 "class" is the user running. I think it may help on the console log. Edited May 24, 2020 by argumentum added console log Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting. Link to comment Share on other sites More sharing options...
Beege Posted May 24, 2020 Author Share Posted May 24, 2020 1 hour ago, argumentum said: This is the 1607 console Thank you for that. This is indeed a pickle. I got the beta portion narrowed down to it not liking the any of the direct get code and setting the dllstruct name directly by name. Commenting that portion out gets the rest of it working and gives me something to look at but I'm stumped for what would be going on between windows versions. Local $aArray = [111, 222, 333] $oIDispatch = IDispatchASM() $oIDispatch.string = "string test" $oIDispatch.__string = "__string test2" $oIDispatch.float = 12.345145 $oIDispatch.array = $aArray $oIDispatch.binary = Binary(12345678) $oIDispatch.bool = True $oIDispatch.dllStruct = DllStructCreate("BYTE t") ;~ $oIDispatch.dllStruct.t = 99 ;~ ConsoleWrite('-Direct get test:' & @CRLF & _ ;~ '$oIDispatch.string = ' & $oIDispatch.string & @CRLF & _ ;~ '$oIDispatch.__string = ' & $oIDispatch.__string & @CRLF & _ ;~ '$oIDispatch.float = ' & $oIDispatch.float & @CRLF & _ ;~ '$oIDispatch.array[1] = ' & $oIDispatch.array[1] & @CRLF) ConsoleWrite('-method __keysau3 test:' & @CRLF) Local $aKeyAU3s = $oIDispatch.__keysau3() ConsoleWrite('$aKeyAU3s = ' & _ArrayToString($aKeyAU3s) & @CRLF) ConsoleWrite('-method __get test:' & @CRLF) For $k In $oIDispatch.__keysau3() $val = $oIDispatch.__get($k) ConsoleWrite('$oIDispatch.' & $k & ' = ' & (IsArray($val) ? _ArrayToString($val) : (IsDllStruct($val) ? DllStructGetData($val, 1) : $val)) & @CRLF) Next ConsoleWrite('-method __set test:' & @CRLF) Local $i = 0 For $k In $oIDispatch.__keysau3() $oIDispatch.__set($k) = $i ConsoleWrite('$oIDispatch.' & $k & ' = ' & $oIDispatch.__get($k) & @CRLF) $i += 1 Next >"C:\Program Files (x86)\AutoIt3\SciTE\..\AutoIt3.exe" "C:\Program Files (x86)\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.au3" /run /beta /ErrorStdOut /in "F:\AutoIt Scripts\FLAT Assembler\fasmg dll\IDispatchASM\IdispatchASM_compiled_example.au3" /UserParams +>14:51:22 Starting AutoIt3Wrapper v.19.102.1901.0 SciTE v.4.1.2.0 Keyboard:00000409 OS:WIN_10/ CPU:X64 OS:X64 Environment(Language:0409) CodePage:0 utf8.auto.check:4 +> SciTEDir => C:\Program Files (x86)\AutoIt3\SciTE UserDir => C:\Users\BJ\AppData\Local\AutoIt v3\SciTE\AutoIt3Wrapper SCITE_USERHOME => C:\Users\BJ\AppData\Local\AutoIt v3\SciTE >Running AU3Check (3.3.15.2) from:C:\Program Files (x86)\AutoIt3\Beta input:F:\AutoIt Scripts\FLAT Assembler\fasmg dll\IDispatchASM\IdispatchASM_compiled_example.au3 +>14:51:22 AU3Check ended.rc:0 >Running:(3.3.15.2):C:\Program Files (x86)\AutoIt3\Beta\autoit3_x64.exe "F:\AutoIt Scripts\FLAT Assembler\fasmg dll\IDispatchASM\IdispatchASM_compiled_example.au3" +>Setting Hotkeys...--> Press Ctrl+Alt+Break to Restart or Ctrl+Break to Stop -method __keysau3 test: $aKeyAU3s = string|__string|float|array|binary|bool|dllStruct -method __get test: $oIDispatch.string = string test $oIDispatch.__string = __string test2 $oIDispatch.float = 12.345145 $oIDispatch.array = 111|222|333 $oIDispatch.binary = 0x4E61BC00 $oIDispatch.bool = True $oIDispatch.dllStruct = 0 -method __set test: $oIDispatch.string = 0 $oIDispatch.__string = 1 $oIDispatch.float = 2 $oIDispatch.array = 3 $oIDispatch.binary = 4 $oIDispatch.bool = 5 $oIDispatch.dllStruct = 6 +>14:51:22 AutoIt3.exe ended.rc:0 +>14:51:22 AutoIt3Wrapper Finished. >Exit code: 0 Time: 0.8726 Assembly Code: fasmg . fasm . BmpSearch . Au3 Syntax Highlighter . Bounce Multithreading Example . IDispatchASMUDFs: Explorer Frame . ITaskBarList . Scrolling Line Graph . Tray Icon Bar Graph . Explorer Listview . Wiimote . WinSnap . Flicker Free Labels . iTunesPrograms: Ftp Explorer . Snipster . Network Meter . Resistance Calculator Link to comment Share on other sites More sharing options...
argumentum Posted May 24, 2020 Share Posted May 24, 2020 4 minutes ago, Beege said: Commenting that portion out gets the rest of it working Yes, did that and worked on both PCs Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting. Link to comment Share on other sites More sharing options...
argumentum Posted May 24, 2020 Share Posted May 24, 2020 ...now, would you code an example of how to "DllCall" a script to ...use it as 2 scripts ?. I'm really clueless and can't figure how to split it into 2 scripts, the IDispatch holder and the calling script. Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting. Link to comment Share on other sites More sharing options...
Beege Posted May 24, 2020 Author Share Posted May 24, 2020 2 hours ago, argumentum said: how to "DllCall" a script to ...use it as 2 scripts ? The way you quoted "Dllcall" here has got me a bit confused. Are you talking about splitting the example into a separate file with "include Idispatchasm.au3" so they are 2 scripts? I found the issue going on with the betas and have reuploaded with the fix. The fix is updating the flags check to force a word value instead of default within the invoke method and should be done for 32bit as well even though its doesnt seem to be a problem. _(' .if word[wFlags] = DISPATCH_PROPERTYGET');.. line 207 Assembly Code: fasmg . fasm . BmpSearch . Au3 Syntax Highlighter . Bounce Multithreading Example . IDispatchASMUDFs: Explorer Frame . ITaskBarList . Scrolling Line Graph . Tray Icon Bar Graph . Explorer Listview . Wiimote . WinSnap . Flicker Free Labels . iTunesPrograms: Ftp Explorer . Snipster . Network Meter . Resistance Calculator Link to comment Share on other sites More sharing options...
argumentum Posted May 25, 2020 Share Posted May 25, 2020 (edited) 18 minutes ago, Beege said: The way you quoted "Dllcall" here has got me a bit confused well, the way I had it in my head is that 1 script would have functions that can be called from another script. And thought it would be ala dll due to the iDispach. Am I too far off ? Edit: run in both PCs, a-OK Edited May 25, 2020 by argumentum Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting. 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