TwoBeAss Posted September 14, 2019 Share Posted September 14, 2019 (edited) Hey there, i think i am doing something wrong... I want to call some Functions in a DLL API File: #include <MsgBoxConstants.au3> Global $hDll, $aResult, $aResult2 Local $tGetAPIVersion=DllStructCreate("char apiVersion[200]") ;this one is working Local $tSearchDevice=DllStructCreate("int numDevicesFound;int* deviceIDS;char** deviceSerial;char** deviceType");this is not working $hDll = DllOpen("RSA_API.dll") If $hDll <> -1 Then $aResult = DllCall($hDll, "none:cdecl", "DEVICE_GetAPIVersion", "ptr", DllStructGetPtr($tGetAPIVersion)) $aResult2 = DllCall($hDll, "none:cdecl", "DEVICE_Search", "ptr", DllStructGetPtr($tSearchDevice)) If Not @error Then MsgBox(0,"ApiVersion:",DllStructGetData($tGetAPIVersion,"apiVersion")) MsgBox(0,"numDevicesFound:",DllStructGetData($tSearchDevice,"numDevicesFound")) MsgBox(0,"deviceIDS:",DllStructGetData($tSearchDevice,"deviceIDS")) MsgBox(0,"deviceSerial:",DllStructGetData($tSearchDevice,"deviceSerial")) MsgBox(0,"deviceType:",DllStructGetData($tSearchDevice,"deviceType")) EndIf Else Msgbox(0, "DllOpen", "DllOpen failed") EndIf DllClose($hDll) The API Documentation says under DEVICE_Search: DEVICE_Search Searches for connectable devices (user buffers) Declaration: ReturnStatus DEVICE_Search(int* numDevicesFound, int deviceIDs[], char deviceSerial[][DEVSRCH_SERIAL_MAX_STRLEN], char deviceType[][DEVSRCH_TYPE_MAX_STRLEN]); Maybe someone can point me in the right direction ? I think my problem is to understand the DllStructCreate Part... I found a cpp example project, where the variables were declared like this. I think i just dont know how to translate that for my DllStruct... int numFound = 0; int* deviceIDs; const char** deviceSerial; const char** deviceType; char apiVersion[200]; Thanks for helping me! Edited September 14, 2019 by TwoBeAss additional info Link to comment Share on other sites More sharing options...
dmob Posted September 15, 2019 Share Posted September 15, 2019 19 hours ago, TwoBeAss said: int numFound = 0; int* deviceIDs; const char** deviceSerial; const char** deviceType; char apiVersion[200]; Your example specifies numFound yet your code has numDevicesFound... could that be your problem? Link to comment Share on other sites More sharing options...
Danyfirex Posted September 15, 2019 Share Posted September 15, 2019 Hello. Seems to be you don't need structures. Could you share the C++/C Example. Saludos Danysys.com AutoIt... UDFs: VirusTotal API 2.0 UDF - libZPlay UDF - Apps: Guitar Tab Tester - VirusTotal Hash Checker Examples: Text-to-Speech ISpVoice Interface - Get installed applications - Enable/Disable Network connection PrintHookProc - WINTRUST - Mute Microphone Level - Get Connected NetWorks - Create NetWork Connection ShortCut Link to comment Share on other sites More sharing options...
TwoBeAss Posted September 15, 2019 Author Share Posted September 15, 2019 (edited) @dmob, nope, you can use any varname you want afaik... @Danyfirex im trying to implement the RSA API from Tectronix.. Here you find an example in c++ https://github.com/tektronix/RSA_API/blob/master/C%2B%2B/rsa_api_cpp/consumers.cpp there are also other examples in c#, python and vb.net... i just want to use autoit for my little tool... Would be great if sb can point me in the right direction ! You find the RSA_API.h attached Thanks RSA_API.h Edited September 15, 2019 by TwoBeAss Link to comment Share on other sites More sharing options...
Danyfirex Posted September 16, 2019 Share Posted September 16, 2019 Hello Maybe something like this would work. #include <MsgBoxConstants.au3> Global $hDll = DllOpen("RSA_API.dll") If $hDll <> -1 Then Local $aCall = DllCall($hDll, "int:cdecl", "DEVICE_GetAPIVersion", "str*", Null) Local $sAPIVersion = $aCall[1] ConsoleWrite("APIVersion: " & $sAPIVersion & @CRLF) $aCall = DllCall($hDll, "int:cdecl", "DEVICE_SearchInt", "int*", 0, "ptr*", 0, "ptr*", 0, "ptr*", 0) Local $iNumberOfDevices = $aCall[1] ConsoleWrite("NumberOfDevices: " & $iNumberOfDevices & @CRLF) ;here you will need to cast the information from the pointers ;$aCall[2] ;here is maybe DllStructCreate("int[10]",$aCall[2]) ;$aCall[3] ;here is maybe DllStructCreate("ptr[NumberofDevices]",$aCall[3]) ;$aCall[4] ;here is maybe DllStructCreate("ptr[NumberofDevices]",$aCall[4]) ;then get data(string) from each pointer. Else MsgBox(0, "DllOpen", "DllOpen failed") EndIf DllClose($hDll) Saludos TwoBeAss 1 Danysys.com AutoIt... UDFs: VirusTotal API 2.0 UDF - libZPlay UDF - Apps: Guitar Tab Tester - VirusTotal Hash Checker Examples: Text-to-Speech ISpVoice Interface - Get installed applications - Enable/Disable Network connection PrintHookProc - WINTRUST - Mute Microphone Level - Get Connected NetWorks - Create NetWork Connection ShortCut Link to comment Share on other sites More sharing options...
TwoBeAss Posted September 17, 2019 Author Share Posted September 17, 2019 Seems some kind of working! Thanks a lot Danyfirex... $aCall[2] for example, points to a Adress.. Now i just need to figure out, how to reveal the Array behind it... Link to comment Share on other sites More sharing options...
TwoBeAss Posted September 22, 2019 Author Share Posted September 22, 2019 Im still stucked in the middle of this... Im just getting back the Memory Adresses and i dont know how to get to the real data i need... Maybe someone has another hint for me... Local $iNumberOfDevices = $aCall[1] ConsoleWrite("NumberOfDevices: " & $iNumberOfDevices & @CRLF) $tempstruct = DllStructCreate("int[10]",$aCall[2]) $result = DllStructGetData($tempstruct,1) ConsoleWrite("DeviceIDs: " & $result & @CRLF) $tempstruct2 = DllStructCreate("ptr[1]",$aCall[3]) $result2 = DllStructGetData($tempstruct2,1) ConsoleWrite("DeviceSerials: " & $result2 & @CRLF) This returns just: NumberOfDevices: 1 DeviceIDs: 0 DeviceSerials: 0x7B266AC0 Link to comment Share on other sites More sharing options...
Danyfirex Posted September 26, 2019 Share Posted September 26, 2019 Hello. then you need to get the string from pointer. Local $tString=DllStructCreate("char[100]",0x7B266AC0) ConsoleWrite(DllStructGetData($tString,1) & @CRLF) Saludos Danysys.com AutoIt... UDFs: VirusTotal API 2.0 UDF - libZPlay UDF - Apps: Guitar Tab Tester - VirusTotal Hash Checker Examples: Text-to-Speech ISpVoice Interface - Get installed applications - Enable/Disable Network connection PrintHookProc - WINTRUST - Mute Microphone Level - Get Connected NetWorks - Create NetWork Connection ShortCut 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