win-pvdrivers

diff shutdownmon/shutdownmon.c @ 716:5bdb7251370c

Use WinDDK 7600.16385.0
Update userspace binaries to build for XP not 2K (2K not supported in new DDK)
Fix lots of PREfast errors
Make build and installer less dependant on DDK version
Fix IRQL crash in DpgPrint hooking
author James Harper <james.harper@bendigoit.com.au>
date Tue Dec 22 22:44:07 2009 +1100 (2009-12-22)
parents b79b67b46d0c
children 8f483a2b2991
line diff
     1.1 --- a/shutdownmon/shutdownmon.c	Tue Dec 22 22:13:29 2009 +1100
     1.2 +++ b/shutdownmon/shutdownmon.c	Tue Dec 22 22:44:07 2009 +1100
     1.3 @@ -10,6 +10,7 @@
     1.4  #include <setupapi.h>
     1.5  #include <ctype.h>
     1.6  #include <powrprof.h>
     1.7 +#include <strsafe.h>
     1.8  
     1.9  #define SERVICE_ID "ShutdownMon"
    1.10  #define SERVICE_NAME "Xen Shutdown Monitor"
    1.11 @@ -68,7 +69,7 @@ install_service()
    1.12      return;
    1.13    }
    1.14  
    1.15 -  sprintf(command_line, "\"%s\" -s", path);
    1.16 +  StringCbPrintf(command_line, MAX_PATH + 10, "\"%s\" -s", path);
    1.17    manager_handle = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS);
    1.18   
    1.19    if (!manager_handle)
    1.20 @@ -282,7 +283,7 @@ get_xen_interface_path()
    1.21    }
    1.22    
    1.23    path = malloc(strlen(sdidd->DevicePath) + 1);
    1.24 -  strcpy(path, sdidd->DevicePath);
    1.25 +  StringCbCopyA(path, strlen(sdidd->DevicePath) + 1, sdidd->DevicePath);
    1.26    free(sdidd);
    1.27    
    1.28    return path;
    1.29 @@ -302,8 +303,8 @@ xb_add_watch(HANDLE handle, char *path)
    1.30    msg->req_id = 0;
    1.31    msg->tx_id = 0;
    1.32    msg->len = (ULONG)(strlen(path) + 1 + strlen(token) + 1);
    1.33 -  strcpy(buf + sizeof(*msg), path);
    1.34 -  strcpy(buf + sizeof(*msg) + strlen(path) + 1, token);
    1.35 +  StringCbCopyA(buf + sizeof(*msg), 1024 - sizeof(*msg), path);
    1.36 +  StringCbCopyA(buf + sizeof(*msg) + strlen(path) + 1, 1024 - sizeof(*msg) - strlen(path) - 1, token);
    1.37  
    1.38    if (!WriteFile(handle, buf, sizeof(*msg) + msg->len, &bytes_written, NULL))
    1.39    {
    1.40 @@ -359,7 +360,7 @@ printf("read start\n");
    1.41    msg->req_id = 0;
    1.42    msg->tx_id = 0;
    1.43    msg->len = (ULONG)(strlen(path) + 1);
    1.44 -  strcpy(buf + sizeof(*msg), path);
    1.45 +  StringCbCopyA(buf + sizeof(*msg), 1024 - sizeof(*msg), path);
    1.46  
    1.47    if (!WriteFile(handle, buf, sizeof(*msg) + msg->len, &bytes_written, NULL))
    1.48    {
    1.49 @@ -377,7 +378,7 @@ printf("read start\n");
    1.50    buf[sizeof(*msg) + msg->len] = 0;
    1.51    printf("msg text = %s\n", buf + sizeof(*msg));
    1.52    ret = malloc(strlen(buf + sizeof(*msg)) + 1);
    1.53 -  strcpy(ret, buf + sizeof(*msg));
    1.54 +  StringCbCopyA(ret, 1024 - sizeof(*msg), buf + sizeof(*msg));
    1.55    return ret;
    1.56  }
    1.57