supersonic Posted November 28, 2016 Share Posted November 28, 2016 (edited) Hi, I'm trying to fetch some data from out terminal server (connection time, login time, etc.). Therefore the DLL winsta.dll can be used. Although searching the web for any help on this, I'm still failing to return any useful data. That's what I have so far: #include <Array.au3> Local $sServerName = @ComputerName Local $iSessionId = 0 Local $aResult = DllCall("wtsapi32.dll", "HANDLE", "WTSOpenServerA", "STR", $sServerName) If (Not @error) Then Local Const $hServer = $aResult[0] Local Const $tagWINSTATIONINFORMATIONW = _ "BYTE Reserved1[72];" & _ "ULONG SessionId;" & _ "BYTE Reserved2[4];" & _ "CHAR ConnectTime;" & _ "CHAR DisconnectTime;" & _ "CHAR LastInputTime;" & _ "CHAR LoginTime;" & _ "BYTE Reserved3[1096];" & _ "CHAR CurrentTime;" Local $tTmp = DllStructCreate($tagWINSTATIONINFORMATIONW) $aResult = DllCall("winsta.dll", "BOOL", "WinStationQueryInformationW", "HANDLE", $hServer, "DWORD", $iSessionId, "DWORD", 8, "PTR", $tTmp, "DWORD", DllStructGetSize($tTmp), "PTR*", 0) If (Not @error) Then _ArrayDisplay($aResult) MsgBox(0, "", DllStructGetData($tagWINSTATIONINFORMATIONW, 5)) EndIf EndIf MSDN: https://msdn.microsoft.com/en-us/library/aa383827(v=VS.85).aspx . The call returns "some" results, but how to extract the data from the structure? S. Edited November 28, 2016 by supersonic Link to comment Share on other sites More sharing options...
JohnOne Posted November 28, 2016 Share Posted November 28, 2016 Do a quick sanity test. DllCall("winsta.dll", "BOOL", "WinStationQueryInformationW", "HANDLE", $hServer, "DWORD", $aData[2][1], "DWORD", 8, "PTR", DllStructgetPtr($tTmp), "DWORD", DllStructGetSize($tTmp), "PTR*", 0) arg 4should be void pointer? AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
Danyfirex Posted November 28, 2016 Share Posted November 28, 2016 Also check your structure. It should be something like this: typedef struct _WINSTATIONQUERYINFORMATION { char Reserved1[72]; unsigned int SessionId; char Reserved2[4]; FILETIME ConnectTime; FILETIME DisconnectTime; FILETIME LastInputTime; FILETIME LogonTime; char Reserved3[1096]; FILETIME CurrentTime; } WINSTATIONQUERYINFORMATION, *PWINSTATIONQUERYINFORMATION; 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...
supersonic Posted November 28, 2016 Author Share Posted November 28, 2016 JohnOne, thank you. I forgot to use DllStructGetPtr() in the 2nd DllCall and now a valid (?) ptr returns... But how to go on to get the desired data...? Link to comment Share on other sites More sharing options...
Danyfirex Posted November 28, 2016 Share Posted November 28, 2016 You should use the structure $tTmp instead $tagWINSTATIONINFORMATIONW. 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...
supersonic Posted November 28, 2016 Author Share Posted November 28, 2016 Danyfirex, I don't know to do better: How should $tagWINSTATIONINFORMATIONW look like? Link to comment Share on other sites More sharing options...
JohnOne Posted November 28, 2016 Share Posted November 28, 2016 DllStructGetData($tTmp, 5)) AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
jguinch Posted November 28, 2016 Share Posted November 28, 2016 if I understand, you should use $tTmp here : MsgBox(0, "", DllStructGetData($tTmp , 5)) Spoiler Network configuration UDF, _DirGetSizeByExtension, _UninstallList Firefox ConfigurationArray multi-dimensions, Printer Management UDF Link to comment Share on other sites More sharing options...
supersonic Posted November 28, 2016 Author Share Posted November 28, 2016 My fault - of course I have to use DllStructGetData($tTmp, ...) Still no data returns; is the structure correct? What is the equiv. for "FILETIME" in AutoIt? Link to comment Share on other sites More sharing options...
Danyfirex Posted November 28, 2016 Share Posted November 28, 2016 Structure should look like: Local Const $tagWINSTATIONINFORMATIONW = _ "char Reserved1[72];" & _ "uint SessionId;" & _ "char Reserved2[4];" & _ "dword;dword;" & _ "dword;dword;" & _ "dword;dword;" & _ "dword;dword;" & _ "char Reserved3[1096];" & _ "dword;dword;" dword;dword are FILETIME structure. Saludos jguinch 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...
jguinch Posted November 28, 2016 Share Posted November 28, 2016 Maybe this : #Include <StructureConstants.au3> Local $tFILETIME = DllStructCreate($tagFILETIME) @dany : can you confirm ? Danyfirex 1 Spoiler Network configuration UDF, _DirGetSizeByExtension, _UninstallList Firefox ConfigurationArray multi-dimensions, Printer Management UDF Link to comment Share on other sites More sharing options...
Danyfirex Posted November 28, 2016 Share Posted November 28, 2016 Confirmed. It is. 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...
jguinch Posted November 28, 2016 Share Posted November 28, 2016 @Danyfirex : I thought we should use something like this : Local Const $tagWINSTATIONINFORMATIONW = _ "char Reserved1[72];" & _ "uint SessionId;" & _ "char Reserved2[4];" & _ "struct,dword;dword;endstruct;" & _ "struct,dword;dword;endstruct;" & _ "struct,dword;dword;endstruct;" & _ "struct,dword;dword;endstruct;" & _ "char Reserved3[1096];" & _ "struct,dword;dword;endstruct;" is it the same thing ? Spoiler Network configuration UDF, _DirGetSizeByExtension, _UninstallList Firefox ConfigurationArray multi-dimensions, Printer Management UDF Link to comment Share on other sites More sharing options...
supersonic Posted November 28, 2016 Author Share Posted November 28, 2016 Perfect! Thank you all. I ended up with this: ; ... Local Const $tagWINSTATIONINFORMATIONW = _ "char Reserved1[72];" & _ "uint SessionId;" & _ "char Reserved2[4];" & _ "struct; dword; dword; endstruct;" & _ "struct; dword; dword; endstruct;" & _ "struct; dword; dword; endstruct;" & _ "struct; dword; dword; endstruct;" & _ "char Reserved3[1096];" & _ "struct; dword; dword; endstruct;" ; ... Local $tFILETIME = DllStructCreate($tagFILETIME) DllStructSetData($tFILETIME, 1, DllStructGetData($tTmp, 13)) DllStructSetData($tFILETIME, 2, DllStructGetData($tTmp, 14)) MsgBox(0, "", _Date_Time_FileTimeToStr($tFileTime)) Link to comment Share on other sites More sharing options...
Danyfirex Posted November 28, 2016 Share Posted November 28, 2016 @jguinch It will not work because you use "," after struct haha . Using ";" Its same as mine. 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...
jguinch Posted November 28, 2016 Share Posted November 28, 2016 well spotted ! Spoiler Network configuration UDF, _DirGetSizeByExtension, _UninstallList Firefox ConfigurationArray multi-dimensions, Printer Management UDF 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