foxygit / doom Log in
commit 77ea97c6277cc7261e332deec5d48fbddd88821a
Author:     Simon Howard <fraggle@gmail.com>
AuthorDate: Sat Feb 27 18:57:46 2010 +0000
Commit:     Simon Howard <fraggle@gmail.com>
CommitDate: Sat Feb 27 18:57:46 2010 +0000

    When loading driver, pass the full path to the ioperm.sys file.

    Subversion-branch: /branches/opl-branch
    Subversion-revision: 1874
---
 opl/ioperm_sys.c | 37 ++++++++++++++++++++++++-------------
 1 file changed, 24 insertions(+), 13 deletions(-)

diff --git a/opl/ioperm_sys.c b/opl/ioperm_sys.c
index 37512b63..4c06d97a 100644
--- a/opl/ioperm_sys.c
+++ b/opl/ioperm_sys.c
@@ -93,6 +93,7 @@ int IOperm_EnablePortRange(unsigned int from, unsigned int num, int turn_on)

 int IOperm_InstallDriver(void)
 {
+    wchar_t driver_path[MAX_PATH];
     int error;
     int result = 1;

@@ -106,19 +107,25 @@ int IOperm_InstallDriver(void)
         return 0;
     }

-    svc = CreateService(scm,
-                        TEXT("ioperm"),
-                        TEXT("I/O port access driver"),
-                        SERVICE_ALL_ACCESS,
-                        SERVICE_KERNEL_DRIVER,
-                        SERVICE_AUTO_START,
-                        SERVICE_ERROR_NORMAL,
-                        "ioperm.sys",
-                        NULL,
-                        NULL,
-                        NULL,
-                        NULL,
-                        NULL);
+    // Get the full path to the driver file.
+
+    GetFullPathNameW(L"ioperm.sys", MAX_PATH, driver_path, NULL);
+
+    // Create the service.
+
+    svc = CreateServiceW(scm,
+                         L"ioperm",
+                         L"ioperm support for Cygwin driver",
+                         SERVICE_ALL_ACCESS,
+                         SERVICE_KERNEL_DRIVER,
+                         SERVICE_AUTO_START,
+                         SERVICE_ERROR_NORMAL,
+                         driver_path,
+                         NULL,
+                         NULL,
+                         NULL,
+                         NULL,
+                         NULL);

     if (svc == NULL)
     {
@@ -229,6 +236,10 @@ int IOperm_UninstallDriver(void)

             result = 0;
         }
+        else
+        {
+            printf("IOperm_InstallDriver: ioperm driver uninstalled.\n");
+        }
     }

     // Close handles.