📄 instdrv.cpp
字号:
// ---------------------------------------------------- //
// WinIo v2.0 //
// Direct Hardware Access Under Windows 9x/NT/2000/XP //
// Copyright 1998-2002 Yariv Kaplan //
// http://www.internals.com //
// ---------------------------------------------------- //
#include <windows.h>
#include "winio.h"
bool _stdcall InstallWinIoDriver(PSTR 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,
"WINIO",
"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;
}
else
return false;
CloseServiceHandle(hService);
return true;
}
bool _stdcall RemoveWinIoDriver()
{
SC_HANDLE hSCManager;
SC_HANDLE hService;
bool bResult;
StopWinIoDriver();
hSCManager = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS);
if (hSCManager)
{
hService = OpenService(hSCManager, "WINIO", SERVICE_ALL_ACCESS);
CloseServiceHandle(hSCManager);
if (hService)
{
bResult = DeleteService(hService);
CloseServiceHandle(hService);
}
else
return false;
}
else
return false;
return bResult;
}
bool _stdcall StartWinIoDriver()
{
SC_HANDLE hSCManager;
SC_HANDLE hService;
bool bResult;
hSCManager = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS);
if (hSCManager)
{
hService = OpenService(hSCManager, "WINIO", SERVICE_ALL_ACCESS);
CloseServiceHandle(hSCManager);
if (hService)
{
bResult = StartService(hService, 0, NULL) || GetLastError() == ERROR_SERVICE_ALREADY_RUNNING;
CloseServiceHandle(hService);
}
else
return false;
}
else
return false;
return bResult;
}
bool _stdcall StopWinIoDriver()
{
SC_HANDLE hSCManager;
SC_HANDLE hService;
SERVICE_STATUS ServiceStatus;
bool bResult;
hSCManager = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS);
if (hSCManager)
{
hService = OpenService(hSCManager, "WINIO", SERVICE_ALL_ACCESS);
CloseServiceHandle(hSCManager);
if (hService)
{
bResult = ControlService(hService, SERVICE_CONTROL_STOP, &ServiceStatus);
CloseServiceHandle(hService);
}
else
return false;
}
else
return false;
return bResult;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -