[Spice-devel,2/6] usbclerk: move wdi driver extraction path to system32

Submitted by Arnon Gilboa on July 23, 2012, 9:23 a.m.

Details

Message ID 1343035388-15090-2-git-send-email-agilboa@redhat.com
State New
Headers show

Not browsing as part of any series.

Commit Message

Arnon Gilboa July 23, 2012, 9:23 a.m.
prevents user from replacing the drivers
---
 usbclerk.cpp |   12 +++++++-----
 1 files changed, 7 insertions(+), 5 deletions(-)

Patch hide | download patch | download mbox

diff --git a/usbclerk.cpp b/usbclerk.cpp
index 441f4a1..9100811 100644
--- a/usbclerk.cpp
+++ b/usbclerk.cpp
@@ -17,7 +17,7 @@ 
 #define USB_CLERK_LOG_PATH          TEXT("%susbclerk.log")
 #define USB_CLERK_PIPE_TIMEOUT      10000
 #define USB_CLERK_PIPE_BUF_SIZE     1024
-#define USB_DRIVER_PATH             "%Swdi_usb_driver"
+#define USB_DRIVER_PATH             "%S\\wdi_usb_driver"
 #define USB_DRIVER_INFNAME_LEN      64
 #define USB_DRIVER_INSTALL_RETRIES  10
 #define USB_DRIVER_INSTALL_INTERVAL 2000
@@ -206,13 +206,15 @@  VOID WINAPI USBClerk::main(DWORD argc, TCHAR* argv[])
 
     SERVICE_STATUS* status;
     TCHAR log_path[MAX_PATH];
-    TCHAR temp_path[MAX_PATH];
+    TCHAR path[MAX_PATH];
 
-    if (GetTempPath(MAX_PATH, temp_path)) {
-        sprintf_s(s->_wdi_path, MAX_PATH, USB_DRIVER_PATH, temp_path);
-        swprintf_s(log_path, MAX_PATH, USB_CLERK_LOG_PATH, temp_path);
+    if (GetTempPath(MAX_PATH, path)) {
+        swprintf_s(log_path, MAX_PATH, USB_CLERK_LOG_PATH, path);
         s->_log = VDLog::get(log_path);
     }
+    if (GetSystemDirectory(path, MAX_PATH)) {
+        sprintf_s(s->_wdi_path, MAX_PATH, USB_DRIVER_PATH, path);
+    }
     vd_printf("***Service started***");
     SetPriorityClass(GetCurrentProcess(), ABOVE_NORMAL_PRIORITY_CLASS);
     status = &s->_status;