|
|
//----------------------------------------------------------------------------// Laser Guard Ltd.// Copyright � 2000-2002. All Rights Reserved.// Version 1.0 01/01/2000// Last modification: 08/10/2003// PROJECT: // SUBSYSTEM: // FILE: InstDrv.cpp// AUTHOR: Sergey Chizhevskiy// OVERVIEW// ~~~~~~~~// http://www.internals.com ////----------------------------------------------------------------------------// ---------------------------------------------------- //// 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 "kernelio.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)==1; 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)==1; CloseServiceHandle(hService); } else return false; } else return false; return bResult;}
|