Ontosy Posted April 17, 2016 Share Posted April 17, 2016 when i use "__QueryServiceStatus" from _NTServices.au3 i obtain a "Error 6: ERROR_INVALID_HANDLE". I obtain same error also when use this dll. from what may depend? Link to comment Share on other sites More sharing options...
LarsJ Posted April 18, 2016 Share Posted April 18, 2016 If _NTServices.au3 is from this old example then there are a number of issues in the implementation of the functions. For example that handles are stored as integer data types in DllCalls. This means that the UDF will not work on 64 bit. And all the functions seems to be the ansi version (A-functions). Today you would use the unicode version (W-functions). If you go through the entire UDF and corrects all the mistakes, I'm pretty sure it'll work. Controls, File Explorer, ROT objects, UI Automation, Windows Message MonitorCompiled code: Accessing AutoIt variables, DotNet.au3 UDF, Using C# and VB codeShell menus: The Context menu, The Favorites menu. Shell related: Control Panel, System Image ListsGraphics related: Rubik's Cube, OpenGL without external libraries, Navigating in an image, Non-rectangular selectionsListView controls: Colors and fonts, Multi-line header, Multi-line items, Checkboxes and icons, Incremental searchListView controls: Virtual ListViews, Editing cells, Data display functions Link to comment Share on other sites More sharing options...
Ontosy Posted April 18, 2016 Author Share Posted April 18, 2016 Same script work in Win7 x64 and not in Win10 x64. I not know if it is a SO or SO setting. I not know how investigate it. Link to comment Share on other sites More sharing options...
LarsJ Posted April 18, 2016 Share Posted April 18, 2016 It takes a few months before I get access to a Windows 10 PC. Perhaps there is another who can look at it. I'm almost sure it'll work if the functions are implemented properly. Controls, File Explorer, ROT objects, UI Automation, Windows Message MonitorCompiled code: Accessing AutoIt variables, DotNet.au3 UDF, Using C# and VB codeShell menus: The Context menu, The Favorites menu. Shell related: Control Panel, System Image ListsGraphics related: Rubik's Cube, OpenGL without external libraries, Navigating in an image, Non-rectangular selectionsListView controls: Colors and fonts, Multi-line header, Multi-line items, Checkboxes and icons, Incremental searchListView controls: Virtual ListViews, Editing cells, Data display functions Link to comment Share on other sites More sharing options...
Danyfirex Posted April 18, 2016 Share Posted April 18, 2016 Hello. As LarsJ says funtions are not implemented properly. So I wrote this example with correct implementation. (tested in windows 10 x64. Compiled as x86 and x64) expandcollapse popupGlobal Const $sTagSERVICE_STATUS = "DWORD dwServiceType;" & _ "DWORD dwCurrentState;" & _ "DWORD dwControlsAccepted;" & _ "DWORD dwWin32ExitCode;" & _ "DWORD dwServiceSpecificExitCode;" & _ "DWORD dwCheckPoint;" & _ "DWORD dwWaitHint;" Global $STANDARD_RIGHTS_REQUIRED = 0x000F0000 Global $SC_MANAGER_CONNECT = 0x0001 Global $SC_MANAGER_CREATE_SERVICE = 0x0002 Global $SC_MANAGER_ENUMERATE_SERVICE = 0x0004 Global $SC_MANAGER_LOCK = 0x0008 Global $SC_MANAGER_QUERY_LOCK_STATUS = 0x0010 Global $SC_MANAGER_MODIFY_BOOT_CONFIG = 0x0020 Global $SC_MANAGER_ALL_ACCESS = BitOR($STANDARD_RIGHTS_REQUIRED, _ $SC_MANAGER_CONNECT, _ $SC_MANAGER_CREATE_SERVICE, _ $SC_MANAGER_ENUMERATE_SERVICE, _ $SC_MANAGER_LOCK, _ $SC_MANAGER_QUERY_LOCK_STATUS, _ $SC_MANAGER_MODIFY_BOOT_CONFIG) Global Const $hAdvapi32 = DllOpen("advapi32.dll") MsgBox(64, "Info", "Make sure youre running Admin") Local $aRet = 0 Local $sServiceName = "Spooler" $aRet = DllCall($hAdvapi32, "handle", "OpenSCManagerW", _ "wstr", Null, _ "wstr", Null, _ "dword", $SC_MANAGER_ALL_ACCESS) If $aRet[0] = 0 Then If $aRet[0] = 0 And Not @error Then ConsoleWrite("!Error in OpenSCManager" & @CRLF) Exit EndIf Local $hSCManager = $aRet[0] ;~ MsgBox(0, "", $hSCManager) ConsoleWrite(">$hSCManager: " & $hSCManager & @CRLF) $aRet = DllCall($hAdvapi32, "handle", "OpenServiceW", _ "handle",$hSCManager, _ "wstr", $sServiceName, _ "long", $SC_MANAGER_ALL_ACCESS) If $aRet[0] = 0 Then If $aRet[0] = 0 And Not @error Then ConsoleWrite("!Error in OpenServiceW" & @CRLF) Exit EndIf Local $hServ = $aRet[0] ;~ MsgBox(0, "", $hServ) ConsoleWrite(">$hSCManager: " & $hServ & @CRLF) Local $tStatus = DllStructCreate($sTagSERVICE_STATUS) $aRet = DllCall($hAdvapi32, "bool", "QueryServiceStatus", _ "handle", $hServ, _ "ptr", DllStructGetPtr($tStatus)) If $aRet[0] = 0 Then If $aRet[0] = 0 And Not @error Then ConsoleWrite("!Error in QueryServiceStatus" & @CRLF) Exit EndIf ConsoleWrite("+Spooler Status: " & $tStatus.dwCurrentState & @CRLF) MsgBox(0, "", "Spooler Status: " & $tStatus.dwCurrentState) DllCall($hAdvapi32, "bool", "CloseServiceHandle", "handle", $hServ) DllCall($hAdvapi32, "bool", "CloseServiceHandle", "handle", $hSCManager) DllClose($hAdvapi32) Saludos LarsJ and Ontosy 2 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...
Ontosy Posted April 18, 2016 Author Share Posted April 18, 2016 (edited) Ty, now it is works. Edited April 19, 2016 by Ontosy 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