Jump to content

Recommended Posts

Posted
  On 4/25/2020 at 7:06 PM, Beege said:

 Let me know if you have issues, questions or comments.

Expand  

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

Follow the link to my code contribution ( and other things too ).
FAQ - Please Read Before Posting.
autoit_scripter_blue_userbar.png

Posted
  On 4/26/2020 at 2:49 AM, 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 :baby:

Expand  

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. 

Posted (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 by Beege
Posted
  On 4/28/2020 at 2:46 AM, idontknow said:

Very Nice !

May i ask how i can run __defineGetter and __defineSetter like AutoItObject

Thanks

Expand  

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. 

Posted

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:

 

 

 

Posted

Little Proof Of Concept 

  Reveal hidden contents

 

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..

Posted
  On 5/4/2020 at 7:41 AM, Bilgus said:

Little Proof Of Concept 

Expand  

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. 

Posted (edited)
  On 5/24/2020 at 3:23 PM, argumentum said:

x64 in 3.3.14.5 wont run but in the beta 3.3.15.3 runs just fine.

Expand  

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

>"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 by Beege
Posted (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.:cheer:

This is the 1607 console

  Reveal hidden contents

This is the 1909 console

  Reveal hidden contents

...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 by argumentum
added console log

Follow the link to my code contribution ( and other things too ).
FAQ - Please Read Before Posting.
autoit_scripter_blue_userbar.png

Posted
  On 5/24/2020 at 6:29 PM, argumentum said:

This is the 1607 console

Expand  

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

 

Posted
  On 5/24/2020 at 8:58 PM, argumentum said:

how to "DllCall" a script to ...use it as 2 scripts ?

Expand  

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

 

Posted (edited)
  On 5/24/2020 at 11:57 PM, Beege said:

The way you quoted "Dllcall" here has got me a bit confused

Expand  

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 ?:baby: 

Edit: run in both PCs, a-OK :) 

Edited by argumentum

Follow the link to my code contribution ( and other things too ).
FAQ - Please Read Before Posting.
autoit_scripter_blue_userbar.png

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...