Need assistance activating with AutoIt

I've read the posts that included oregonjohn back in 2012 but I'm having trouble getting things working. I believe I've been able to interface with TurboActivate.dll using DllOpen and DllCall through cdecl since I now get handles back from TA_GetHandle. I can also pass that handle, my test key and "flags" (unit32_t 1) to TA_CheckAndSavePKey and it now returns 0 (previously I was getting 1B - Invalid Handle - which I fixed). But no matter what I try as options and types passed to TA_Activate (using the same handle I passed to TA_CheckAndSavePKey) the website won't show an activation even though I get a return code of 0 from TA_Activate. At this point I'm not sure my test script is even trying to reach the server. 🤔

Any assistance would be greatly appreciated! I'm happy to provide what I have so far along with return values and types.

Update: I believe I'm having an issue with the Struct I'm passing to TA_Activate. Maybe if I post my Struct code (DllStructs are special C/C++ style constructs in AutoIt specifically for passing to DllCall) it'll help weed out where the issue is...

Local $sExtraData = "testExtraData"Local $gsActOpts = "uint nLength;wchar sExtraData[" & StringLen($sExtraData) & "]"Local $gActOpts = DllStructCreate($gsActOpts)DllStructSetData($gActOpts, "sExtraData", $sExtraData)DllStructSetData($gActOpts, "nLength", _UINT(DllStructGetSize($gActOpts)))_WinAPI_DisplayStruct($gActOpts)

The _WinAPI_DisplayStruct shows me this: https://drive.google.com/open?id=1I6kYKfmhJAwB2TBXt_5PFomXnq8njkFe

Does that look like it's the correct format for what TA_Activate is expecting? If not, could you tell me what's wrong with the structure so I can fix it?

Thank you in advance to anyone who can assist and help me straighten out the variable issue!

Side note: I'm unable to edit my first post because I wasn't logged in when I created it. I created this one the same way to avoid confusion in who posted the follow-up. If I DM a mod can they help me change my account username and then put these posts under my account? 😳

Update: I can now successfully call TA_Activate - as long as the DllStruct I pass has no value entered for the sExtraData portion of ACTIVATE_OPTIONS. I believe it's because the sExtraData is defined as LPWSTR but AutoIt can only do wchar[] in its DllStructs.

Can anyone confirm my assumption is correct? If that's the case then hopefully I'll be able to get full functionality minus the ability to send extra data through TA_Activate. Thankfully I don't currently require this functionality so I'm excited to finally get this working!

With that said, I would still like to figure out for sure if it's possible to actually pass data using ACTIVATE_OPTIONS using AutoIt. Here is the struct that I pass by PTR to TA_Activate for a successful activation:

Local $gsActOpts = "uint nLength;wchar sExtraData"Local $gActOpts = DllStructCreate($gsActOpts)DllStructSetData($gActOpts, "sExtraData", "")DllStructSetData($gActOpts, "nLength", _UINT(DllStructGetSize($gActOpts)))_WinAPI_DisplayStruct($gActOpts)

_WinAPI_DisplayStruct shows: https://drive.google.com/file/d/16-8uECRdxbwXCds_ptwn97PnGwBT_KVi

If I pass a ptr to the $gActOpts struct using this (condensed) code TA_Activate is successful and returns a proper code:

Global $hgTA = DllOpen("TurboActivate.dll")Local $hTA = DllCall($hgTA, _MSDNtoAutoItTypes("UINT32_T") & ":" & $TA_CC, "TA_GetHandle", _MSDNtoAutoItTypes("STRCTYPE"), _WSTR($gsVersionGUID))Local $iActivate = DllCall($hgTA, _MSDNtoAutoItTypes("HRESULT") & ":" & $TA_CC, "TA_Activate", _MSDNtoAutoItTypes("UINT32_T"), $hTA[0], "PTR", DllStructGetPtr($gActOpts))

I've tried changing sExtraData to wchar, wchar[], char, and char[] and adding a single character but they all fail terribly (I'm not sure what gets sent back but AutoIt doesn't like it and fails with a hard error). If TA_Activate is expecting sExtraData to be LPWSTR I'm sure that's the reason but I'm not sure how to get around it. Or, if TA_Activate is expecting a different type I haven't been able to determine what type it's supposed to be, yet.

Any suggestions or personal experience that could help me either confirm my suspicions or provide information/direction on what I should look at or how I should change something would be greatly appreciated!

Thank you for your time and consideration!

LPWSTR is essentially a "wchar *" (LPWSTR = Long Pointer to Wide String). How AutoIt passes pointers to a wchar array is the question.

Sorry, none of us here has AutoIt experience. Also, you can avoid passing the struct pointer by passing a nil or null pointer instead (however AutoIt calls it).

Wyatt,

Whether you know AutoIt or not your answer was exactly what I needed! I was finally able to pass something in sExtraData and, even better, it was an entire string! I needed to create an additional DllStruct for the sExtraData, and then put a PTR to the new DllStruct in place of the data itself. Basically, here is my new method that works (in case any other random AutoIt users happen by here in the future):

Local $sExtraData = "testExtraData" ;~ Data to be passed as sExtraData in ACTIVATE_OPTIONSLocal $sExtraDataStructDecl = "wchar sExtraData[" & StringLen($sExtraData) & "]" ;~ String to declare DllStruct for sExtraDataStruct accounting for the length of the string being placed in the char arrayLocal $sExtraDataStruct = DllStructCreate($sExtraDataStructDecl) ;~ Actually creating the DllStructDllStructSetData($sExtraDataStruct, 1, _WSTR($sExtraData)) ;~ Assigning the value of $sExtraData to the $sExtraDataStructLocal $gsActOptsStructDecl = "STRUCT;uint nLength;ptr sExtraData;ENDSTRUCT" ;~ String to declare DllStruct for $gActOptsStructLocal $gActOptsStruct = DllStructCreate($gsActOpts) ;~ Actually creating the DllStructDllStructSetData($gActOptsStruct, "sExtraData", DllStructGetPtr($sExtraDataStruct)) ;~ Assigning sExtraData in $gActOptsStruct with a PTR to $sExtraDataStructDllStructSetData($gActOptsStruct, "nLength", _UINT(DllStructGetSize($gActOptsStruct))) ;~ Setting nLength in $gActOptsStruct with the total size in bytes of the DllStruct

Again, thank you for the assistance, Wyatt! Even the smallest comments can be the greatest help! Now I know how I can pass pretty much anything to TurboActivate. You rock!

No problem, I'm glad I could help a little bit (you did most of the work!)