About InstallWinIoDriver function of WinIo.dll
-
Dear all: I use winIo.dll with my project, when I call InstallWinIoDriver function, it always return false, but my application still work, What happened? There are source code below
bool _stdcall InstallWinIoDriver(PWSTR pszWinIoDriverPath, bool IsDemandLoaded)
{
SC_HANDLE hSCManager;
SC_HANDLE hService;
// Remove any previous instance of the driver
RemoveWinIoDriver();hSCManager = OpenSCManager(NULL, NULL, SC\_MANAGER\_ALL\_ACCESS); if(hSCManager) { // Install the driver hService = CreateService(hSCManager, L"WINIO", L"WINIO", SERVICE\_ALL\_ACCESS, SERVICE\_KERNEL\_DRIVER, (IsDemandLoaded == true) ? SERVICE\_DEMAND\_START : SERVICE\_SYSTEM\_START, SERVICE\_ERROR\_NORMAL, pszWinIoDriverPath, NULL, NULL, NULL, NULL, NULL); CloseServiceHandle(hSCManager); if(hService == NULL) return false; //strange } else return false; //strange CloseServiceHandle(hService); //strange return true; //strange
}
Thanks for your help, Victor
-
Dear all: I use winIo.dll with my project, when I call InstallWinIoDriver function, it always return false, but my application still work, What happened? There are source code below
bool _stdcall InstallWinIoDriver(PWSTR pszWinIoDriverPath, bool IsDemandLoaded)
{
SC_HANDLE hSCManager;
SC_HANDLE hService;
// Remove any previous instance of the driver
RemoveWinIoDriver();hSCManager = OpenSCManager(NULL, NULL, SC\_MANAGER\_ALL\_ACCESS); if(hSCManager) { // Install the driver hService = CreateService(hSCManager, L"WINIO", L"WINIO", SERVICE\_ALL\_ACCESS, SERVICE\_KERNEL\_DRIVER, (IsDemandLoaded == true) ? SERVICE\_DEMAND\_START : SERVICE\_SYSTEM\_START, SERVICE\_ERROR\_NORMAL, pszWinIoDriverPath, NULL, NULL, NULL, NULL, NULL); CloseServiceHandle(hSCManager); if(hService == NULL) return false; //strange } else return false; //strange CloseServiceHandle(hService); //strange return true; //strange
}
Thanks for your help, Victor
I have no idea really. But it's always useful to have some trace-code that prints the result of
GetLastError()
andFormatMessage()
. Something like:MY_TRACE (("CreateService() failed; %s\n", my_strerror(GetLastError())));
-- Gisle V.
-
Dear all: I use winIo.dll with my project, when I call InstallWinIoDriver function, it always return false, but my application still work, What happened? There are source code below
bool _stdcall InstallWinIoDriver(PWSTR pszWinIoDriverPath, bool IsDemandLoaded)
{
SC_HANDLE hSCManager;
SC_HANDLE hService;
// Remove any previous instance of the driver
RemoveWinIoDriver();hSCManager = OpenSCManager(NULL, NULL, SC\_MANAGER\_ALL\_ACCESS); if(hSCManager) { // Install the driver hService = CreateService(hSCManager, L"WINIO", L"WINIO", SERVICE\_ALL\_ACCESS, SERVICE\_KERNEL\_DRIVER, (IsDemandLoaded == true) ? SERVICE\_DEMAND\_START : SERVICE\_SYSTEM\_START, SERVICE\_ERROR\_NORMAL, pszWinIoDriverPath, NULL, NULL, NULL, NULL, NULL); CloseServiceHandle(hSCManager); if(hService == NULL) return false; //strange } else return false; //strange CloseServiceHandle(hService); //strange return true; //strange
}
Thanks for your help, Victor
Hmmm, Could be that the CreateService function[^] is returning either ERROR_DUPLICATE_SERVICE_NAME or maybe ERROR_SERVICE_EXISTS. As previously stated GetLastError[^] is your friend.
cedricvictor wrote:
but my application still work,
Keep in mind that if you do not have source code for winIo.dll ... it could also be installing the service. Best Wishes, -David Delaune
-
Hmmm, Could be that the CreateService function[^] is returning either ERROR_DUPLICATE_SERVICE_NAME or maybe ERROR_SERVICE_EXISTS. As previously stated GetLastError[^] is your friend.
cedricvictor wrote:
but my application still work,
Keep in mind that if you do not have source code for winIo.dll ... it could also be installing the service. Best Wishes, -David Delaune
Dear Randor: You are right. In other function, the service is exist. So the function always return false. Thank for your help, Victor