Old fashion design for PC-104
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

159 lines
3.2 KiB

4 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. //----------------------------------------------------------------------------
  2. // Laser Guard Ltd.
  3. // Copyright � 2000-2002. All Rights Reserved.
  4. // Version 1.0 01/01/2000
  5. // Last modification: 08/10/2003
  6. // PROJECT:
  7. // SUBSYSTEM:
  8. // FILE: InstDrv.cpp
  9. // AUTHOR: Sergey Chizhevskiy
  10. // OVERVIEW
  11. // ~~~~~~~~
  12. // http://www.internals.com //
  13. //----------------------------------------------------------------------------
  14. // ---------------------------------------------------- //
  15. // WinIo v2.0 //
  16. // Direct Hardware Access Under Windows 9x/NT/2000/XP //
  17. // Copyright 1998-2002 Yariv Kaplan //
  18. // http://www.internals.com //
  19. // ---------------------------------------------------- //
  20. #include <windows.h>
  21. #include "kernelio.h"
  22. bool _stdcall InstallWinIoDriver(PSTR pszWinIoDriverPath, bool IsDemandLoaded)
  23. {
  24. SC_HANDLE hSCManager;
  25. SC_HANDLE hService;
  26. // Remove any previous instance of the driver
  27. RemoveWinIoDriver();
  28. hSCManager = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS);
  29. if (hSCManager)
  30. {
  31. // Install the driver
  32. hService = CreateService(hSCManager,
  33. "WINIO",
  34. "WINIO",
  35. SERVICE_ALL_ACCESS,
  36. SERVICE_KERNEL_DRIVER,
  37. (IsDemandLoaded == true) ? SERVICE_DEMAND_START : SERVICE_SYSTEM_START,
  38. SERVICE_ERROR_NORMAL,
  39. pszWinIoDriverPath,
  40. NULL,
  41. NULL,
  42. NULL,
  43. NULL,
  44. NULL);
  45. CloseServiceHandle(hSCManager);
  46. if (hService == NULL)
  47. return false;
  48. }
  49. else
  50. return false;
  51. CloseServiceHandle(hService);
  52. return true;
  53. }
  54. bool _stdcall RemoveWinIoDriver()
  55. {
  56. SC_HANDLE hSCManager;
  57. SC_HANDLE hService;
  58. bool bResult;
  59. StopWinIoDriver();
  60. hSCManager = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS);
  61. if (hSCManager)
  62. {
  63. hService = OpenService(hSCManager, "WINIO", SERVICE_ALL_ACCESS);
  64. CloseServiceHandle(hSCManager);
  65. if (hService)
  66. {
  67. bResult = DeleteService(hService);
  68. CloseServiceHandle(hService);
  69. }
  70. else
  71. return false;
  72. }
  73. else
  74. return false;
  75. return bResult;
  76. }
  77. bool _stdcall StartWinIoDriver()
  78. {
  79. SC_HANDLE hSCManager;
  80. SC_HANDLE hService;
  81. bool bResult;
  82. hSCManager = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS);
  83. if (hSCManager)
  84. {
  85. hService = OpenService(hSCManager, "WINIO", SERVICE_ALL_ACCESS);
  86. CloseServiceHandle(hSCManager);
  87. if (hService)
  88. {
  89. bResult = StartService(hService, 0, NULL) || GetLastError() == ERROR_SERVICE_ALREADY_RUNNING;
  90. CloseServiceHandle(hService);
  91. }
  92. else
  93. return false;
  94. }
  95. else
  96. return false;
  97. return bResult;
  98. }
  99. bool _stdcall StopWinIoDriver()
  100. {
  101. SC_HANDLE hSCManager;
  102. SC_HANDLE hService;
  103. SERVICE_STATUS ServiceStatus;
  104. bool bResult;
  105. hSCManager = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS);
  106. if (hSCManager)
  107. {
  108. hService = OpenService(hSCManager, "WINIO", SERVICE_ALL_ACCESS);
  109. CloseServiceHandle(hSCManager);
  110. if (hService)
  111. {
  112. bResult = ControlService(hService, SERVICE_CONTROL_STOP, &ServiceStatus);
  113. CloseServiceHandle(hService);
  114. }
  115. else
  116. return false;
  117. }
  118. else
  119. return false;
  120. return bResult;
  121. }