win-pvdrivers

changeset 716:5bdb7251370c 0.11.0.162

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 04dd3ddfefa1
children b30bcfed15d7
files coinst/sources common/include/xen_windows.h copyconfig/copyconfig.c installer.wxs makedist.bat shutdownmon/shutdownmon.c sign.bat wix.bat xennet/xennet.c xennet/xennet.h xennet/xennet_rx.c xennet/xennet_tx.c xenpci/evtchn.c xenpci/xenbus.c xenpci/xenbus_device_interface.c xenpci/xenpci.c xenpci/xenpci.h xenpci/xenpci_dbgprint.c xenpci/xenpci_dma.c xenpci/xenpci_fdo.c xenpci/xenpci_highsync.c xenpci/xenpci_pdo.c xenscsi/xenscsi.c xenusb/xenusb.c xenusb/xenusb.h xenusb/xenusb_fdo.c xenusb/xenusb_hub.c xenvbd/xenvbd.c xenvbd/xenvbd.h
line diff
     1.1 --- a/coinst/sources	Tue Dec 22 22:13:29 2009 +1100
     1.2 +++ b/coinst/sources	Tue Dec 22 22:44:07 2009 +1100
     1.3 @@ -2,7 +2,7 @@ TARGETNAME=coinst
     1.4  TARGETTYPE=DYNLINK
     1.5  USE_MSVCRT=1
     1.6  
     1.7 -_NT_TARGET_VERSION=$(_NT_TARGET_VERSION_WIN2K)
     1.8 +_NT_TARGET_VERSION=$(_NT_TARGET_VERSION_WINXP)
     1.9  
    1.10  SOURCES=coinst.c \
    1.11          coinst.rc
     2.1 --- a/common/include/xen_windows.h	Tue Dec 22 22:13:29 2009 +1100
     2.2 +++ b/common/include/xen_windows.h	Tue Dec 22 22:44:07 2009 +1100
     2.3 @@ -91,7 +91,7 @@ SplitString(char *String, char Split, in
     2.4      for (last = first; *last != '\0' && *last != Split; last++);
     2.5      RetVal[*Count] = (char *)ExAllocatePoolWithTag(NonPagedPool, last - first + 1, SPLITSTRING_POOL_TAG);
     2.6      //KdPrint((__DRIVER_NAME "     c - count = %d\n", *Count));
     2.7 -    strncpy(RetVal[*Count], first, last - first);
     2.8 +    RtlStringCbCopyNA(RetVal[*Count], last - first + 1, first, last - first);
     2.9      RetVal[*Count][last - first] = 0;
    2.10      //KdPrint((__DRIVER_NAME "     d - count = %d\n", *Count));
    2.11      (*Count)++;
     3.1 --- a/copyconfig/copyconfig.c	Tue Dec 22 22:13:29 2009 +1100
     3.2 +++ b/copyconfig/copyconfig.c	Tue Dec 22 22:44:07 2009 +1100
     3.3 @@ -7,10 +7,13 @@
     3.4  #include <string.h>
     3.5  #include <winioctl.h>
     3.6  #include <ntddndis.h>
     3.7 +#include <strsafe.h>
     3.8  
     3.9  #define ADAPTER_TYPE_XEN
    3.10  #define ADAPTER_TYPE_OTHER
    3.11  
    3.12 +#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
    3.13 +
    3.14  typedef struct adapter_details
    3.15  {
    3.16    struct adapter_details *next;
    3.17 @@ -65,7 +68,7 @@ main(
    3.18      if (buf_len != 38)
    3.19        continue;
    3.20      /* check that the name looks like a guid */
    3.21 -    sprintf(filename, "\\\\.\\%s", adapter_key_name);
    3.22 +    StringCbPrintfA(filename, ARRAY_SIZE(filename), "\\\\.\\%s", adapter_key_name);
    3.23      handle = CreateFile(filename, FILE_GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
    3.24      if (!handle)
    3.25        continue;
    3.26 @@ -155,14 +158,14 @@ main(
    3.27      if (adapter->xen_IpConfig_key_name[0] && adapter->other_IpConfig_key_name[0])
    3.28      {
    3.29        // open HKLM\SYSTEM\Services\%s
    3.30 -      sprintf((char *)buf, "SYSTEM\\CurrentControlSet\\Services\\%s", adapter->xen_IpConfig_key_name);
    3.31 +      StringCbPrintfA((char *)buf, ARRAY_SIZE(buf), "SYSTEM\\CurrentControlSet\\Services\\%s", adapter->xen_IpConfig_key_name);
    3.32        status = RegOpenKey(HKEY_LOCAL_MACHINE, (LPCSTR)buf, &dst_key_handle);
    3.33        if (status != ERROR_SUCCESS)
    3.34        {
    3.35          printf(" Cannot open Xen adapter config key. Skipping.\n");
    3.36          continue;
    3.37        }
    3.38 -      sprintf((char *)buf, "SYSTEM\\CurrentControlSet\\Services\\%s", adapter->other_IpConfig_key_name);
    3.39 +      StringCbPrintfA((char *)buf, ARRAY_SIZE(buf), "SYSTEM\\CurrentControlSet\\Services\\%s", adapter->other_IpConfig_key_name);
    3.40        status = RegOpenKey(HKEY_LOCAL_MACHINE, (LPCSTR)buf, &src_key_handle);
    3.41        if (status != ERROR_SUCCESS)
    3.42        {
     4.1 --- a/installer.wxs	Tue Dec 22 22:13:29 2009 +1100
     4.2 +++ b/installer.wxs	Tue Dec 22 22:44:07 2009 +1100
     4.3 @@ -47,7 +47,7 @@
     4.4                  <File Id='xenpci.cat' Name='xenpci.cat' DiskId='1' Source='xenpci\obj$(env.BUILD_ALT_DIR)\$(var.ARCHDIR)\xenpci.cat' />
     4.5                  <File Id='xenpci.inf' Name='xenpci.inf' DiskId='1' Source='xenpci\obj$(env.BUILD_ALT_DIR)\$(var.ARCHDIR)\xenpci.inf' />
     4.6                  <File Id='xenpci.sys' Name='xenpci.sys' DiskId='1' Source='xenpci\obj$(env.BUILD_ALT_DIR)\$(var.ARCHDIR)\xenpci.sys' />
     4.7 -                <File Id='WdfCoInstaller01007.dll' Name='WdfCoInstaller01007.dll' DiskId='1' Source='xenpci\obj$(env.BUILD_ALT_DIR)\$(var.ARCHDIR)\WdfCoInstaller01007.dll' />
     4.8 +                <File Id='$(env.WDFFILENAME)' Name='$(env.WDFFILENAME)' DiskId='1' Source='xenpci\obj$(env.BUILD_ALT_DIR)\$(var.ARCHDIR)\$(env.WDFFILENAME)' />
     4.9                  <difx:Driver Sequence='99' Legacy='yes' PlugAndPlayPrompt='no' ForceInstall='yes' />
    4.10                </Component>
    4.11              </Directory>
    4.12 @@ -82,7 +82,7 @@
    4.13                  <File Id='xenusb.inf' Name='xenusb.inf' DiskId='1' Source='xenusb\obj$(env.BUILD_ALT_DIR)\$(var.ARCHDIR)\xenusb.inf' />
    4.14                  <File Id='xenusb.sys' Name='xenusb.sys' DiskId='1' Source='xenusb\obj$(env.BUILD_ALT_DIR)\$(var.ARCHDIR)\xenusb.sys' />
    4.15                  <!-- we deliberately use the file from xenpci so that wix can deduplicate it -->
    4.16 -                <File Id='WdfCoInstaller01007.dll_usb' Name='WdfCoInstaller01007.dll' DiskId='1' Source='xenpci\obj$(env.BUILD_ALT_DIR)\$(var.ARCHDIR)\WdfCoInstaller01007.dll' />
    4.17 +                <File Id='$(env.WDFFILENAME)_usb' Name='$(env.WDFFILENAME)' DiskId='1' Source='xenpci\obj$(env.BUILD_ALT_DIR)\$(var.ARCHDIR)\$(env.WDFFILENAME)' />
    4.18                  <difx:Driver Sequence='3' Legacy='yes' PlugAndPlayPrompt='no' ForceInstall='yes' />
    4.19                </Component>
    4.20              </Directory>
     5.1 --- a/makedist.bat	Tue Dec 22 22:13:29 2009 +1100
     5.2 +++ b/makedist.bat	Tue Dec 22 22:44:07 2009 +1100
     5.3 @@ -1,7 +1,7 @@
     5.4  @echo off
     5.5 -IF NOT EXIST set_ddk_path.bat ECHO >set_ddk_path.bat SET DDK_PATH=C:\WinDDK\6001.18002
     5.6 +IF NOT EXIST set_ddk_path.bat ECHO >set_ddk_path.bat SET DDK_PATH=C:\WinDDK\7600.16385.0
     5.7  
     5.8 -SET VERSION=0.10.0
     5.9 +SET VERSION=0.11.0
    5.10  SET BUILD_NUMBER=0
    5.11  IF EXIST build_number.bat CALL build_number.bat
    5.12  
     6.1 --- a/shutdownmon/shutdownmon.c	Tue Dec 22 22:13:29 2009 +1100
     6.2 +++ b/shutdownmon/shutdownmon.c	Tue Dec 22 22:44:07 2009 +1100
     6.3 @@ -10,6 +10,7 @@
     6.4  #include <setupapi.h>
     6.5  #include <ctype.h>
     6.6  #include <powrprof.h>
     6.7 +#include <strsafe.h>
     6.8  
     6.9  #define SERVICE_ID "ShutdownMon"
    6.10  #define SERVICE_NAME "Xen Shutdown Monitor"
    6.11 @@ -68,7 +69,7 @@ install_service()
    6.12      return;
    6.13    }
    6.14  
    6.15 -  sprintf(command_line, "\"%s\" -s", path);
    6.16 +  StringCbPrintf(command_line, MAX_PATH + 10, "\"%s\" -s", path);
    6.17    manager_handle = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS);
    6.18   
    6.19    if (!manager_handle)
    6.20 @@ -282,7 +283,7 @@ get_xen_interface_path()
    6.21    }
    6.22    
    6.23    path = malloc(strlen(sdidd->DevicePath) + 1);
    6.24 -  strcpy(path, sdidd->DevicePath);
    6.25 +  StringCbCopyA(path, strlen(sdidd->DevicePath) + 1, sdidd->DevicePath);
    6.26    free(sdidd);
    6.27    
    6.28    return path;
    6.29 @@ -302,8 +303,8 @@ xb_add_watch(HANDLE handle, char *path)
    6.30    msg->req_id = 0;
    6.31    msg->tx_id = 0;
    6.32    msg->len = (ULONG)(strlen(path) + 1 + strlen(token) + 1);
    6.33 -  strcpy(buf + sizeof(*msg), path);
    6.34 -  strcpy(buf + sizeof(*msg) + strlen(path) + 1, token);
    6.35 +  StringCbCopyA(buf + sizeof(*msg), 1024 - sizeof(*msg), path);
    6.36 +  StringCbCopyA(buf + sizeof(*msg) + strlen(path) + 1, 1024 - sizeof(*msg) - strlen(path) - 1, token);
    6.37  
    6.38    if (!WriteFile(handle, buf, sizeof(*msg) + msg->len, &bytes_written, NULL))
    6.39    {
    6.40 @@ -359,7 +360,7 @@ printf("read start\n");
    6.41    msg->req_id = 0;
    6.42    msg->tx_id = 0;
    6.43    msg->len = (ULONG)(strlen(path) + 1);
    6.44 -  strcpy(buf + sizeof(*msg), path);
    6.45 +  StringCbCopyA(buf + sizeof(*msg), 1024 - sizeof(*msg), path);
    6.46  
    6.47    if (!WriteFile(handle, buf, sizeof(*msg) + msg->len, &bytes_written, NULL))
    6.48    {
    6.49 @@ -377,7 +378,7 @@ printf("read start\n");
    6.50    buf[sizeof(*msg) + msg->len] = 0;
    6.51    printf("msg text = %s\n", buf + sizeof(*msg));
    6.52    ret = malloc(strlen(buf + sizeof(*msg)) + 1);
    6.53 -  strcpy(ret, buf + sizeof(*msg));
    6.54 +  StringCbCopyA(ret, 1024 - sizeof(*msg), buf + sizeof(*msg));
    6.55    return ret;
    6.56  }
    6.57  
     7.1 --- a/sign.bat	Tue Dec 22 22:13:29 2009 +1100
     7.2 +++ b/sign.bat	Tue Dec 22 22:44:07 2009 +1100
     7.3 @@ -13,34 +13,37 @@ ECHO SIGN_OS=%SIGN_OS%
     7.4  
     7.5  xcopy /D coinst\%BUILDDIR%\coinst.dll xenvbd\%BUILDDIR%
     7.6  move xenvbd\%BUILDDIR%\coinst.dll xenvbd\%BUILDDIR%\xencoinst.dll
     7.7 -xcopy /D %BASEDIR%\redist\wdf\%_BUILDARCH%\WdfCoInstaller01007.dll xenpci\%BUILDDIR%
     7.8 -xcopy /D %BASEDIR%\redist\wdf\%_BUILDARCH%\WdfCoInstaller01007.dll xenusb\%BUILDDIR%
     7.9 +
    7.10 +for /F %%x in ('DIR /B %BASEDIR%\redist\wdf\%_BUILDARCH%\WdfCoInstaller?????.dll') do set WDFFILENAME=%%x
    7.11 +xcopy /D %BASEDIR%\redist\wdf\%_BUILDARCH%\%WDFFILENAME% xenpci\%BUILDDIR%
    7.12 +xcopy /D %BASEDIR%\redist\wdf\%_BUILDARCH%\%WDFFILENAME% xenusb\%BUILDDIR%
    7.13  
    7.14  REM IF NOT EXIST SIGN_CONFIG.BAT GOTO DONT_SIGN
    7.15  REM CALL SIGN_CONFIG.BAT
    7.16  
    7.17  SET CERT_NAME=GPLPV_Test_Cert
    7.18  
    7.19 -REM %DDK_PATH%\bin\selfsign\signtool sign /v /s PrivateCertStore /n %CERT_NAME% /t http://timestamp.verisign.com/scripts/timestamp.dll xenpci\%BUILDDIR%\xenpci.sys xenpci\%BUILDDIR%\WdfCoInstaller01007.dll
    7.20 -%DDK_PATH%\bin\selfsign\signtool sign /v /s PrivateCertStore /n %CERT_NAME% /t http://timestamp.verisign.com/scripts/timestamp.dll xenpci\%BUILDDIR%\xenpci.sys
    7.21 -%DDK_PATH%\bin\selfsign\inf2cat /driver:xenpci\%BUILDDIR% /os:%SIGN_OS%
    7.22 -%DDK_PATH%\bin\selfsign\signtool sign /v /s PrivateCertStore /n %CERT_NAME% /t http://timestamp.verisign.com/scripts/timestamp.dll xenpci\%BUILDDIR%\xenpci.cat
    7.23 -
    7.24 -%DDK_PATH%\bin\selfsign\signtool sign /v /s PrivateCertStore /n %CERT_NAME% /t http://timestamp.verisign.com/scripts/timestamp.dll xennet\%BUILDDIR%\xennet.sys
    7.25 -%DDK_PATH%\bin\selfsign\inf2cat /driver:xennet\%BUILDDIR% /os:%SIGN_OS%
    7.26 -%DDK_PATH%\bin\selfsign\signtool sign /v /s PrivateCertStore /n %CERT_NAME% /t http://timestamp.verisign.com/scripts/timestamp.dll xennet\%BUILDDIR%\xennet.cat
    7.27 +SET SIGNTOOL=%DDK_PATH%\bin\x86\signtool.exe
    7.28 +IF NOT EXIST %SIGNTOOL% SET SIGNTOOL=%DDK_PATH%\bin\selfsign\signtool.exe
    7.29  
    7.30 -%DDK_PATH%\bin\selfsign\signtool sign /v /s PrivateCertStore /n %CERT_NAME% /t http://timestamp.verisign.com/scripts/timestamp.dll xenvbd\%BUILDDIR%\xenvbd.sys xenvbd\%BUILDDIR%\xencoinst.dll
    7.31 +%SIGNTOOL% sign /v /s PrivateCertStore /n %CERT_NAME% /t http://timestamp.verisign.com/scripts/timestamp.dll xenpci\%BUILDDIR%\xenpci.sys
    7.32 +%DDK_PATH%\bin\selfsign\inf2cat /driver:xenpci\%BUILDDIR% /os:%SIGN_OS%
    7.33 +%SIGNTOOL% sign /v /s PrivateCertStore /n %CERT_NAME% /t http://timestamp.verisign.com/scripts/timestamp.dll xenpci\%BUILDDIR%\xenpci.cat
    7.34 +
    7.35 +%SIGNTOOL% sign /v /s PrivateCertStore /n %CERT_NAME% /t http://timestamp.verisign.com/scripts/timestamp.dll xennet\%BUILDDIR%\xennet.sys
    7.36 +%DDK_PATH%\bin\selfsign\inf2cat /driver:xennet\%BUILDDIR% /os:%SIGN_OS%
    7.37 +%SIGNTOOL% sign /v /s PrivateCertStore /n %CERT_NAME% /t http://timestamp.verisign.com/scripts/timestamp.dll xennet\%BUILDDIR%\xennet.cat
    7.38 +
    7.39 +%SIGNTOOL% sign /v /s PrivateCertStore /n %CERT_NAME% /t http://timestamp.verisign.com/scripts/timestamp.dll xenvbd\%BUILDDIR%\xenvbd.sys xenvbd\%BUILDDIR%\xencoinst.dll
    7.40  %DDK_PATH%\bin\selfsign\inf2cat /driver:xenvbd\%BUILDDIR% /os:%SIGN_OS%
    7.41 -%DDK_PATH%\bin\selfsign\signtool sign /v /s PrivateCertStore /n %CERT_NAME% /t http://timestamp.verisign.com/scripts/timestamp.dll xenvbd\%BUILDDIR%\xenvbd.cat
    7.42 +%SIGNTOOL% sign /v /s PrivateCertStore /n %CERT_NAME% /t http://timestamp.verisign.com/scripts/timestamp.dll xenvbd\%BUILDDIR%\xenvbd.cat
    7.43  
    7.44 -%DDK_PATH%\bin\selfsign\signtool sign /v /s PrivateCertStore /n %CERT_NAME% /t http://timestamp.verisign.com/scripts/timestamp.dll xenscsi\%BUILDDIR%\xenscsi.sys
    7.45 +%SIGNTOOL% sign /v /s PrivateCertStore /n %CERT_NAME% /t http://timestamp.verisign.com/scripts/timestamp.dll xenscsi\%BUILDDIR%\xenscsi.sys
    7.46  %DDK_PATH%\bin\selfsign\inf2cat /driver:xenscsi\%BUILDDIR% /os:%SIGN_OS%
    7.47 -%DDK_PATH%\bin\selfsign\signtool sign /v /s PrivateCertStore /n %CERT_NAME% /t http://timestamp.verisign.com/scripts/timestamp.dll xenscsi\%BUILDDIR%\xenscsi.cat
    7.48 +%SIGNTOOL% sign /v /s PrivateCertStore /n %CERT_NAME% /t http://timestamp.verisign.com/scripts/timestamp.dll xenscsi\%BUILDDIR%\xenscsi.cat
    7.49  
    7.50 -REM %DDK_PATH%\bin\selfsign\signtool sign /v /s PrivateCertStore /n %CERT_NAME% /t http://timestamp.verisign.com/scripts/timestamp.dll xenusb\%BUILDDIR%\xenusb.sys xenusb\%BUILDDIR%\WdfCoInstaller01007.dll
    7.51 -%DDK_PATH%\bin\selfsign\signtool sign /v /s PrivateCertStore /n %CERT_NAME% /t http://timestamp.verisign.com/scripts/timestamp.dll xenusb\%BUILDDIR%\xenusb.sys
    7.52 +%SIGNTOOL% sign /v /s PrivateCertStore /n %CERT_NAME% /t http://timestamp.verisign.com/scripts/timestamp.dll xenusb\%BUILDDIR%\xenusb.sys
    7.53  %DDK_PATH%\bin\selfsign\inf2cat /driver:xenusb\%BUILDDIR% /os:%SIGN_OS%
    7.54 -%DDK_PATH%\bin\selfsign\signtool sign /v /s PrivateCertStore /n %CERT_NAME% /t http://timestamp.verisign.com/scripts/timestamp.dll xenusb\%BUILDDIR%\xenusb.cat
    7.55 +%SIGNTOOL% sign /v /s PrivateCertStore /n %CERT_NAME% /t http://timestamp.verisign.com/scripts/timestamp.dll xenusb\%BUILDDIR%\xenusb.cat
    7.56  
    7.57  :DONT_SIGN
     8.1 --- a/wix.bat	Tue Dec 22 22:13:29 2009 +1100
     8.2 +++ b/wix.bat	Tue Dec 22 22:44:07 2009 +1100
     8.3 @@ -14,5 +14,7 @@ IF "%DDK_TARGET_OS%"=="WinLH" (SET MSIOS
     8.4  
     8.5  SET MSINAME=gplpv_%MSIOS%%MSIARCH%_%GPLPV_VERSION%%MSIBUILD%.msi
     8.6  
     8.7 +for /F %%x in ('DIR /B %BASEDIR%\redist\wdf\%_BUILDARCH%\WdfCoInstaller?????.dll') do set WDFFILENAME=%%x
     8.8 +
     8.9  "%WIX%\bin\candle" installer.wxs -ext "%WIX%\bin\WixUIExtension.dll" -ext "%WIX%\bin\WixDifxAppExtension.dll" -ext "%WIX%\bin\WixIIsExtension.dll"
    8.10  "%WIX%\bin\light.exe" -o %MSINAME% installer.wixobj "%DIFXLIB%" -ext "%WIX%\bin\WixUIExtension.dll" -ext "%WIX%\bin\WixDifxAppExtension.dll" -ext "%WIX%\bin\WixIIsExtension.dll"
     9.1 --- a/xennet/xennet.c	Tue Dec 22 22:13:29 2009 +1100
     9.2 +++ b/xennet/xennet.c	Tue Dec 22 22:44:07 2009 +1100
     9.3 @@ -22,6 +22,11 @@ Foundation, Inc., 51 Franklin Street, Fi
     9.4  #include <io/xenbus.h>
     9.5  #include "xennet.h"
     9.6  
     9.7 +/* Not really necessary but keeps PREfast happy */
     9.8 +DRIVER_INITIALIZE DriverEntry;
     9.9 +static IO_WORKITEM_ROUTINE XenNet_Resume;
    9.10 +static KDEFERRED_ROUTINE XenNet_SuspendResume;
    9.11 +
    9.12  /* ----- BEGIN Other people's code --------- */
    9.13  /* from linux/include/linux/ctype.h, used under GPLv2 */
    9.14  #define _U      0x01    /* upper */
    10.1 --- a/xennet/xennet.h	Tue Dec 22 22:13:29 2009 +1100
    10.2 +++ b/xennet/xennet.h	Tue Dec 22 22:44:07 2009 +1100
    10.3 @@ -21,12 +21,6 @@ Foundation, Inc., 51 Franklin Street, Fi
    10.4  #pragma warning(disable: 4201)
    10.5  #pragma warning(disable: 4214)
    10.6  
    10.7 -#ifdef __MINGW32__
    10.8 -#include <ntddk.h>
    10.9 -#define NDIS50_MINIPORT 1
   10.10 -#include <ndis.h>
   10.11 -#include "../mingw/mingw_extras.h"
   10.12 -#else
   10.13  #define DDKAPI
   10.14  #include <ntddk.h>
   10.15  #include <wdm.h>
   10.16 @@ -39,7 +33,6 @@ Foundation, Inc., 51 Franklin Street, Fi
   10.17  #include <ndis.h>
   10.18  #define NTSTRSAFE_LIB
   10.19  #include <ntstrsafe.h>
   10.20 -#endif
   10.21  
   10.22  #define VENDOR_DRIVER_VERSION_MAJOR 0
   10.23  #define VENDOR_DRIVER_VERSION_MINOR 10
   10.24 @@ -353,9 +346,6 @@ VOID
   10.25  XenNet_RxResumeEnd(xennet_info_t *xi);
   10.26  
   10.27  VOID
   10.28 -XenNet_TxBufferGC(PKDPC dpc, PVOID context, PVOID arg1, PVOID arg2);
   10.29 -
   10.30 -VOID
   10.31  XenNet_TxResumeStart(xennet_info_t *xi);
   10.32  
   10.33  VOID
    11.1 --- a/xennet/xennet_rx.c	Tue Dec 22 22:13:29 2009 +1100
    11.2 +++ b/xennet/xennet_rx.c	Tue Dec 22 22:44:07 2009 +1100
    11.3 @@ -20,6 +20,9 @@ Foundation, Inc., 51 Franklin Street, Fi
    11.4  
    11.5  #include "xennet.h"
    11.6  
    11.7 +/* Not really necessary but keeps PREfast happy */
    11.8 +static KDEFERRED_ROUTINE XenNet_RxBufferCheck;
    11.9 +
   11.10  static __inline shared_buffer_t *
   11.11  get_pb_from_freelist(struct xennet_info *xi)
   11.12  {
    12.1 --- a/xennet/xennet_tx.c	Tue Dec 22 22:13:29 2009 +1100
    12.2 +++ b/xennet/xennet_tx.c	Tue Dec 22 22:44:07 2009 +1100
    12.3 @@ -20,6 +20,9 @@ Foundation, Inc., 51 Franklin Street, Fi
    12.4  
    12.5  #include "xennet.h"
    12.6  
    12.7 +/* Not really necessary but keeps PREfast happy */
    12.8 +static KDEFERRED_ROUTINE XenNet_TxBufferGC;
    12.9 +
   12.10  static USHORT
   12.11  get_id_from_freelist(struct xennet_info *xi)
   12.12  {
   12.13 @@ -398,7 +401,7 @@ XenNet_SendQueuedPackets(struct xennet_i
   12.14  
   12.15  //ULONG packets_outstanding = 0;
   12.16  // Called at DISPATCH_LEVEL
   12.17 -VOID
   12.18 +static VOID
   12.19  XenNet_TxBufferGC(PKDPC dpc, PVOID context, PVOID arg1, PVOID arg2)
   12.20  {
   12.21    struct xennet_info *xi = context;
    13.1 --- a/xenpci/evtchn.c	Tue Dec 22 22:13:29 2009 +1100
    13.2 +++ b/xenpci/evtchn.c	Tue Dec 22 22:44:07 2009 +1100
    13.3 @@ -19,10 +19,10 @@ Foundation, Inc., 51 Franklin Street, Fi
    13.4  
    13.5  #include "xenpci.h"
    13.6  
    13.7 -#if defined(__MINGW32__)
    13.8 -  #define xchg(p1, p2) InterlockedExchange((xen_long_t * volatile)p1, p2)
    13.9 -  /* rest implemented in mingw_extras.c */
   13.10 -#elif defined(_X86_)
   13.11 +/* Not really necessary but keeps PREfast happy */
   13.12 +static KDEFERRED_ROUTINE EvtChn_DpcBounce;
   13.13 +
   13.14 +#if defined(_X86_)
   13.15    #define xchg(p1, p2) InterlockedExchange(p1, p2)
   13.16    #define synch_clear_bit(p1, p2) InterlockedBitTestAndReset(p2, p1)
   13.17    #define synch_set_bit(p1, p2) InterlockedBitTestAndSet(p2, p1)
   13.18 @@ -293,7 +293,7 @@ EvtChn_BindIrq(PVOID Context, evtchn_por
   13.19    xpdd->ev_actions[Port].xpdd = xpdd;
   13.20    KeMemoryBarrier();
   13.21    xpdd->ev_actions[Port].type = EVT_ACTION_TYPE_IRQ;
   13.22 -  strncpy(xpdd->ev_actions[Port].description, description, 128);
   13.23 +  RtlStringCbCopyA(xpdd->ev_actions[Port].description, 128, description);
   13.24  
   13.25    EvtChn_Unmask(Context, Port);
   13.26  
    14.1 --- a/xenpci/xenbus.c	Tue Dec 22 22:13:29 2009 +1100
    14.2 +++ b/xenpci/xenbus.c	Tue Dec 22 22:44:07 2009 +1100
    14.3 @@ -23,6 +23,9 @@ Foundation, Inc., 51 Franklin Street, Fi
    14.4  #pragma warning( disable : 4204 ) 
    14.5  #pragma warning( disable : 4221 ) 
    14.6  
    14.7 +/* Not really necessary but keeps PREfast happy */
    14.8 +static EVT_WDF_WORKITEM XenBus_WatchWorkItemProc;
    14.9 +
   14.10  WDF_DECLARE_CONTEXT_TYPE(xsd_sockmsg_t)
   14.11  
   14.12  struct write_req {
   14.13 @@ -237,6 +240,12 @@ XenBus_WatchWorkItemProc(WDFWORKITEM wor
   14.14    msg = WdfObjectGetTypedContext(workitem, xsd_sockmsg_t);
   14.15    path = (PCHAR)msg + sizeof(xsd_sockmsg_t);
   14.16    index = atoi(path + strlen(path) + 1);
   14.17 +  if (index < 0 || index >= MAX_WATCH_ENTRIES)
   14.18 +  {
   14.19 +    KdPrint((__DRIVER_NAME "     Watch index %d out of range\n", index));
   14.20 +    WdfObjectDelete(workitem);
   14.21 +    return;
   14.22 +  }
   14.23    ExAcquireFastMutex(&xpdd->xb_watch_mutex);
   14.24    entry = &xpdd->XenBus_WatchEntries[index];
   14.25    if (!entry->Active || !entry->ServiceRoutine)
   14.26 @@ -602,7 +611,7 @@ XenBus_AddWatch(
   14.27    /* must init watchentry before starting watch */
   14.28    
   14.29    w_entry = &xpdd->XenBus_WatchEntries[i];
   14.30 -  strncpy(w_entry->Path, Path, ARRAY_SIZE(w_entry->Path));
   14.31 +  RtlStringCbCopyA(w_entry->Path, ARRAY_SIZE(w_entry->Path), Path);
   14.32    w_entry->ServiceRoutine = ServiceRoutine;
   14.33    w_entry->ServiceContext = ServiceContext;
   14.34    w_entry->Count = 0;
    15.1 --- a/xenpci/xenbus_device_interface.c	Tue Dec 22 22:13:29 2009 +1100
    15.2 +++ b/xenpci/xenbus_device_interface.c	Tue Dec 22 22:44:07 2009 +1100
    15.3 @@ -19,6 +19,12 @@ Foundation, Inc., 51 Franklin Street, Fi
    15.4  
    15.5  #include "xenpci.h"
    15.6  
    15.7 +/* Not really necessary but keeps PREfast happy */
    15.8 +static EVT_WDF_FILE_CLEANUP XenBus_EvtFileCleanup;
    15.9 +static EVT_WDF_FILE_CLOSE XenBus_EvtFileClose;
   15.10 +static EVT_WDF_IO_QUEUE_IO_READ XenBus_EvtIoRead;
   15.11 +static EVT_WDF_IO_QUEUE_IO_WRITE XenBus_EvtIoWrite;
   15.12 +
   15.13  typedef struct {
   15.14    LIST_ENTRY entry;
   15.15    PVOID data;
    16.1 --- a/xenpci/xenpci.c	Tue Dec 22 22:13:29 2009 +1100
    16.2 +++ b/xenpci/xenpci.c	Tue Dec 22 22:44:07 2009 +1100
    16.3 @@ -28,6 +28,12 @@ Foundation, Inc., 51 Franklin Street, Fi
    16.4  
    16.5  #pragma warning(disable : 4200) // zero-sized array
    16.6  
    16.7 +/* Not really necessary but keeps PREfast happy */
    16.8 +DRIVER_INITIALIZE DriverEntry;
    16.9 +static EVT_WDF_DRIVER_DEVICE_ADD XenPci_EvtDeviceAdd;
   16.10 +static EVT_WDF_DEVICE_USAGE_NOTIFICATION XenPci_EvtDeviceUsageNotification;
   16.11 +static EVT_WDF_DEVICE_PREPARE_HARDWARE XenHide_EvtDevicePrepareHardware;
   16.12 +
   16.13  static VOID
   16.14  XenPci_EvtDeviceUsageNotification(WDFDEVICE device, WDF_SPECIAL_FILE_TYPE notification_type, BOOLEAN is_in_notification_path)
   16.15  {
   16.16 @@ -592,8 +598,10 @@ DriverEntry(PDRIVER_OBJECT DriverObject,
   16.17    }
   16.18    
   16.19    XenPci_HookDbgPrint();
   16.20 -  
   16.21 +
   16.22 +#if 0 
   16.23    XenPci_FixLoadOrder();
   16.24 +#endif
   16.25  
   16.26    RtlInitUnicodeString(&RegKeyName, L"\\Registry\\Machine\\System\\CurrentControlSet\\Control");
   16.27    InitializeObjectAttributes(&RegObjectAttributes, &RegKeyName, OBJ_CASE_INSENSITIVE, NULL, NULL);
    17.1 --- a/xenpci/xenpci.h	Tue Dec 22 22:13:29 2009 +1100
    17.2 +++ b/xenpci/xenpci.h	Tue Dec 22 22:44:07 2009 +1100
    17.3 @@ -24,7 +24,7 @@ Foundation, Inc., 51 Franklin Street, Fi
    17.4  #define EISCONN 127
    17.5  
    17.6  #include <ntifs.h>
    17.7 -#include <ntddk.h>
    17.8 +//#include <ntddk.h>
    17.9  
   17.10  #define DDKAPI
   17.11  //#include <wdm.h>
   17.12 @@ -385,11 +385,8 @@ EVT_WDF_DEVICE_D0_ENTRY_POST_INTERRUPTS_
   17.13  EVT_WDF_DEVICE_D0_EXIT XenPci_EvtDeviceD0Exit;
   17.14  EVT_WDF_DEVICE_D0_EXIT_PRE_INTERRUPTS_DISABLED XenPci_EvtDeviceD0ExitPreInterruptsDisabled;
   17.15  EVT_WDF_DEVICE_QUERY_REMOVE XenPci_EvtDeviceQueryRemove;
   17.16 -
   17.17 -NTSTATUS
   17.18 -XenPci_EvtChildListCreateDevice(WDFCHILDLIST child_list, PWDF_CHILD_IDENTIFICATION_DESCRIPTION_HEADER description_header, PWDFDEVICE_INIT child_init);
   17.19 -VOID
   17.20 -XenPci_EvtChildListScanForChildren(WDFCHILDLIST child_list);
   17.21 +EVT_WDF_CHILD_LIST_CREATE_DEVICE XenPci_EvtChildListCreateDevice;
   17.22 +EVT_WDF_CHILD_LIST_SCAN_FOR_CHILDREN XenPci_EvtChildListScanForChildren;
   17.23  
   17.24  VOID
   17.25  XenPci_HideQemuDevices();
   17.26 @@ -547,13 +544,9 @@ GntTbl_PutRef(PVOID Context, grant_ref_t
   17.27  grant_ref_t
   17.28  GntTbl_GetRef(PVOID Context);
   17.29  
   17.30 -BOOLEAN
   17.31 -XenPci_BIS_TranslateBusAddress(PVOID context, PHYSICAL_ADDRESS bus_address, ULONG length, PULONG address_space, PPHYSICAL_ADDRESS translated_address);
   17.32 -PDMA_ADAPTER
   17.33 -XenPci_BIS_GetDmaAdapter(PVOID context, PDEVICE_DESCRIPTION device_description, PULONG number_of_map_registers);
   17.34 -ULONG
   17.35 -XenPci_BIS_SetBusData(PVOID context, ULONG data_type, PVOID buffer, ULONG offset, ULONG length);
   17.36 -ULONG
   17.37 -XenPci_BIS_GetBusData(PVOID context, ULONG data_type, PVOID buffer, ULONG offset, ULONG length);
   17.38 +TRANSLATE_BUS_ADDRESS XenPci_BIS_TranslateBusAddress;
   17.39 +GET_DMA_ADAPTER XenPci_BIS_GetDmaAdapter;
   17.40 +GET_SET_DEVICE_DATA XenPci_BIS_SetBusData;
   17.41 +GET_SET_DEVICE_DATA XenPci_BIS_GetBusData;
   17.42  
   17.43  #endif
    18.1 --- a/xenpci/xenpci_dbgprint.c	Tue Dec 22 22:13:29 2009 +1100
    18.2 +++ b/xenpci/xenpci_dbgprint.c	Tue Dec 22 22:44:07 2009 +1100
    18.3 @@ -53,8 +53,8 @@ typedef struct _IDT
    18.4  } IDT, *PIDT;
    18.5  #pragma pack()
    18.6  
    18.7 -//typedef void (*PDBGPRINT_CALLBACK_FUNCTION)(IN PANSI_STRING String, IN ULONG ComponentId, IN ULONG Level);
    18.8 -//typedef NTSTATUS (*PDBG_SET_DEBUGPRINT_CALLBACK)(PDBGPRINT_CALLBACK_FUNCTION Function, IN BOOLEAN Mode);
    18.9 +/* Not really necessary but keeps PREfast happy */
   18.10 +static KBUGCHECK_CALLBACK_ROUTINE XenPci_BugcheckCallback;
   18.11  
   18.12  KBUGCHECK_CALLBACK_RECORD callback_record;
   18.13  
   18.14 @@ -83,15 +83,16 @@ XenPci_BugcheckCallback(PVOID buffer, UL
   18.15  
   18.16  static BOOLEAN debug_port_enabled = FALSE;
   18.17  
   18.18 +/* This appears to be called with interrupts disabled already, so no need to go to HIGH_LEVEL or anything like that */
   18.19  static void XenDbgPrint(PCHAR string, ULONG length)
   18.20  {
   18.21    ULONG i;
   18.22 -  KIRQL old_irql = 0;
   18.23 +  //KIRQL old_irql = 0;
   18.24  
   18.25 -  KeRaiseIrql(HIGH_LEVEL, &old_irql);
   18.26 +  //KeRaiseIrql(HIGH_LEVEL, &old_irql);
   18.27    for (i = 0; i < length; i++)
   18.28      WRITE_PORT_UCHAR(XEN_IOPORT_LOG, string[i]);
   18.29 -  KeLowerIrql(old_irql);
   18.30 +  //KeLowerIrql(old_irql);
   18.31  }
   18.32  
   18.33  VOID
    19.1 --- a/xenpci/xenpci_dma.c	Tue Dec 22 22:13:29 2009 +1100
    19.2 +++ b/xenpci/xenpci_dma.c	Tue Dec 22 22:44:07 2009 +1100
    19.3 @@ -947,7 +947,10 @@ XenPci_DOP_GetScatterGatherList(
    19.4    status = XenPci_DOP_BuildScatterGatherListButDontExecute(DmaAdapter, DeviceObject, Mdl, CurrentVa, Length, WriteToDevice, sg_list, list_size, TRUE);
    19.5    
    19.6    if (NT_SUCCESS(status))
    19.7 +  {
    19.8 +    /* sg_list is free'd via PutScatterGatherList later */
    19.9      ExecutionRoutine(DeviceObject, DeviceObject->CurrentIrp, sg_list, Context);
   19.10 +  }
   19.11    else
   19.12      ExFreePoolWithTag(sg_list, XENPCI_POOL_TAG);
   19.13    
    20.1 --- a/xenpci/xenpci_fdo.c	Tue Dec 22 22:13:29 2009 +1100
    20.2 +++ b/xenpci/xenpci_fdo.c	Tue Dec 22 22:44:07 2009 +1100
    20.3 @@ -25,6 +25,11 @@ Foundation, Inc., 51 Franklin Street, Fi
    20.4  #define SHUTDOWN_PATH "control/shutdown"
    20.5  #define BALLOON_PATH "memory/target"
    20.6  
    20.7 +/* Not really necessary but keeps PREfast happy */
    20.8 +static EVT_WDF_WORKITEM XenPci_SuspendResume;
    20.9 +static KSTART_ROUTINE XenPci_BalloonThreadProc;
   20.10 +
   20.11 +
   20.12  static VOID
   20.13  XenPci_MapHalThenPatchKernel(PXENPCI_DEVICE_DATA xpdd)
   20.14  {
    21.1 --- a/xenpci/xenpci_highsync.c	Tue Dec 22 22:13:29 2009 +1100
    21.2 +++ b/xenpci/xenpci_highsync.c	Tue Dec 22 22:44:07 2009 +1100
    21.3 @@ -19,6 +19,10 @@ Foundation, Inc., 51 Franklin Street, Fi
    21.4  
    21.5  #include "xenpci.h"
    21.6  
    21.7 +/* Not really necessary but keeps PREfast happy */
    21.8 +static KDEFERRED_ROUTINE XenPci_HighSyncCallFunction0;
    21.9 +static KDEFERRED_ROUTINE XenPci_HighSyncCallFunctionN;
   21.10 +
   21.11  /*
   21.12  we need these intrinsics as even going to HIGH_LEVEL doesn't ensure that interrupts are completely disabled
   21.13  */
    22.1 --- a/xenpci/xenpci_pdo.c	Tue Dec 22 22:13:29 2009 +1100
    22.2 +++ b/xenpci/xenpci_pdo.c	Tue Dec 22 22:44:07 2009 +1100
    22.3 @@ -24,6 +24,16 @@ Foundation, Inc., 51 Franklin Street, Fi
    22.4  #pragma warning(disable : 4200) // zero-sized array
    22.5  #pragma warning(disable: 4127) // conditional expression is constant
    22.6  
    22.7 +/* Not really necessary but keeps PREfast happy */
    22.8 +static EVT_WDF_INTERRUPT_SYNCHRONIZE XenPci_EvtChn_Sync_Routine;
    22.9 +static EVT_WDF_DEVICE_D0_ENTRY XenPciPdo_EvtDeviceD0Entry;
   22.10 +static EVT_WDF_DEVICE_D0_EXIT XenPciPdo_EvtDeviceD0Exit;
   22.11 +static EVT_WDF_DEVICE_PREPARE_HARDWARE XenPciPdo_EvtDevicePrepareHardware;
   22.12 +static EVT_WDF_DEVICE_RELEASE_HARDWARE XenPciPdo_EvtDeviceReleaseHardware;
   22.13 +static EVT_WDF_DEVICE_USAGE_NOTIFICATION XenPciPdo_EvtDeviceUsageNotification;
   22.14 +static EVT_WDFDEVICE_WDM_IRP_PREPROCESS XenPciPdo_EvtDeviceWdmIrpPreprocess_START_DEVICE;
   22.15 +static EVT_WDF_DEVICE_RESOURCE_REQUIREMENTS_QUERY XenPciPdo_EvtDeviceResourceRequirementsQuery;
   22.16 +
   22.17  /*
   22.18  Called at PASSIVE_LEVEL(?)
   22.19  Called during restore
   22.20 @@ -620,8 +630,8 @@ XenPci_XenConfigDeviceSpecifyBuffers(WDF
   22.21    vectors.GntTbl_EndAccess = XenPci_GntTbl_EndAccess;
   22.22    vectors.XenPci_XenConfigDevice = XenPci_XenConfigDevice;
   22.23    vectors.XenPci_XenShutdownDevice = XenPci_XenShutdownDevice;
   22.24 -  strncpy(vectors.path, xppdd->path, 128);
   22.25 -  strncpy(vectors.backend_path, xppdd->backend_path, 128);
   22.26 +  RtlStringCbCopyA(vectors.path, 128, xppdd->path);
   22.27 +  RtlStringCbCopyA(vectors.backend_path, 128, xppdd->backend_path);
   22.28    //vectors.pdo_event_channel = xpdd->pdo_event_channel;
   22.29    vectors.XenBus_Read = XenPci_XenBus_Read;
   22.30    vectors.XenBus_Write = XenPci_XenBus_Write;
    23.1 --- a/xenscsi/xenscsi.c	Tue Dec 22 22:13:29 2009 +1100
    23.2 +++ b/xenscsi/xenscsi.c	Tue Dec 22 22:44:07 2009 +1100
    23.3 @@ -19,6 +19,7 @@ Foundation, Inc., 51 Franklin Street, Fi
    23.4  
    23.5  #include "xenscsi.h"
    23.6  
    23.7 +/* Not really necessary but keeps PREfast happy */
    23.8  DRIVER_INITIALIZE DriverEntry;
    23.9  
   23.10  #ifdef ALLOC_PRAGMA
   23.11 @@ -271,8 +272,8 @@ XenScsi_DevWatch(PCHAR path, PVOID Devic
   23.12    XenScsi_WaitPause(DeviceExtension);
   23.13    
   23.14    KdPrint((__DRIVER_NAME "     Watch triggered on %s\n", path));
   23.15 -  strncpy(tmp_path, xsdd->vectors.backend_path, 128);
   23.16 -  strncat(tmp_path, "/vscsi-devs", 128);
   23.17 +  RtlStringCbCopyA(tmp_path, ARRAY_SIZE(tmp_path), xsdd->vectors.backend_path);
   23.18 +  RtlStringCbCatA(tmp_path, ARRAY_SIZE(tmp_path), "/vscsi-devs");
   23.19    msg = xsdd->vectors.XenBus_List(xsdd->vectors.context, XBT_NIL, tmp_path, &devices);
   23.20    if (msg)
   23.21    {
   23.22 @@ -295,10 +296,10 @@ XenScsi_DevWatch(PCHAR path, PVOID Devic
   23.23        break; /* not a dev so we are not interested */
   23.24      }
   23.25      dev_no = atoi(devices[i] + 4);
   23.26 -    strncpy(tmp_path, xsdd->vectors.backend_path, 128);
   23.27 -    strncat(tmp_path, "/vscsi-devs/", 128);
   23.28 -    strncat(tmp_path, devices[i], 128);
   23.29 -    strncat(tmp_path, "/state", 128);
   23.30 +    RtlStringCbCopyA(tmp_path, ARRAY_SIZE(tmp_path), xsdd->vectors.backend_path);
   23.31 +    RtlStringCbCatA(tmp_path, ARRAY_SIZE(tmp_path), "/vscsi-devs/");
   23.32 +    RtlStringCbCatA(tmp_path, ARRAY_SIZE(tmp_path), devices[i]);
   23.33 +    RtlStringCbCatA(tmp_path, ARRAY_SIZE(tmp_path), "/state");
   23.34      msg = xsdd->vectors.XenBus_Read(xsdd->vectors.context, XBT_NIL, tmp_path, &value);
   23.35      if (msg)
   23.36      {
   23.37 @@ -321,10 +322,10 @@ XenScsi_DevWatch(PCHAR path, PVOID Devic
   23.38        dev->dev_no = dev_no;
   23.39        dev->state = state;
   23.40        dev->validated = TRUE;
   23.41 -      strncpy(tmp_path, xsdd->vectors.backend_path, 128);
   23.42 -      strncat(tmp_path, "/vscsi-devs/", 128);
   23.43 -      strncat(tmp_path, devices[i], 128);
   23.44 -      strncat(tmp_path, "/v-dev", 128);
   23.45 +      RtlStringCbCopyA(tmp_path, ARRAY_SIZE(tmp_path), xsdd->vectors.backend_path);
   23.46 +      RtlStringCbCatA(tmp_path, ARRAY_SIZE(tmp_path), "/vscsi-devs/");
   23.47 +      RtlStringCbCatA(tmp_path, ARRAY_SIZE(tmp_path), devices[i]);
   23.48 +      RtlStringCbCatA(tmp_path, ARRAY_SIZE(tmp_path), "/v-dev");
   23.49        msg = xsdd->vectors.XenBus_Read(xsdd->vectors.context, XBT_NIL, tmp_path, &value);
   23.50        if (msg)
   23.51        {
   23.52 @@ -336,10 +337,10 @@ XenScsi_DevWatch(PCHAR path, PVOID Devic
   23.53          XenScsi_ParseBackendDevice(dev, value);
   23.54          // should verify that the controller = this
   23.55        }
   23.56 -      strncpy(tmp_path, xsdd->vectors.path, 128);
   23.57 -      strncat(tmp_path, "/vscsi-devs/", 128);
   23.58 -      strncat(tmp_path, devices[i], 128);
   23.59 -      strncat(tmp_path, "/state", 128);      
   23.60 +      RtlStringCbCopyA(tmp_path, ARRAY_SIZE(tmp_path), xsdd->vectors.path);
   23.61 +      RtlStringCbCatA(tmp_path, ARRAY_SIZE(tmp_path), "/vscsi-devs/");
   23.62 +      RtlStringCbCatA(tmp_path, ARRAY_SIZE(tmp_path), devices[i]);
   23.63 +      RtlStringCbCatA(tmp_path, ARRAY_SIZE(tmp_path), "/state");
   23.64        msg = xsdd->vectors.XenBus_Write(xsdd->vectors.context, XBT_NIL, tmp_path, "4");
   23.65        if (msg)
   23.66        {
   23.67 @@ -529,8 +530,8 @@ XenScsi_HwScsiFindAdapter(PVOID DeviceEx
   23.68    {
   23.69      InitializeListHead(&xsdd->dev_list_head);
   23.70      /* should do something if we haven't enumerated in a certain time */
   23.71 -    strncpy(path, xsdd->vectors.backend_path, 128);
   23.72 -    strncat(path, "/vscsi-devs", 128);
   23.73 +    RtlStringCbCopyA(path, ARRAY_SIZE(path), xsdd->vectors.backend_path);
   23.74 +    RtlStringCbCatA(path, ARRAY_SIZE(path), "/vscsi-devs");
   23.75      xsdd->vectors.XenBus_AddWatch(xsdd->vectors.context, XBT_NIL, path,
   23.76        XenScsi_DevWatch, xsdd);
   23.77    }
    24.1 --- a/xenusb/xenusb.c	Tue Dec 22 22:13:29 2009 +1100
    24.2 +++ b/xenusb/xenusb.c	Tue Dec 22 22:44:07 2009 +1100
    24.3 @@ -21,6 +21,9 @@ Foundation, Inc., 51 Franklin Street, Fi
    24.4  #include "xenusb.h"
    24.5  #include <stdlib.h>
    24.6  
    24.7 +/* Not really necessary but keeps PREfast happy */
    24.8 +DRIVER_INITIALIZE DriverEntry;
    24.9 +
   24.10  NTSTATUS
   24.11  DriverEntry(PDRIVER_OBJECT DriverObject, PUNICODE_STRING RegistryPath)
   24.12  {
    25.1 --- a/xenusb/xenusb.h	Tue Dec 22 22:13:29 2009 +1100
    25.2 +++ b/xenusb/xenusb.h	Tue Dec 22 22:44:07 2009 +1100
    25.3 @@ -311,33 +311,16 @@ EVT_WDF_DEVICE_D0_EXIT_PRE_INTERRUPTS_DI
    25.4  EVT_WDF_DEVICE_QUERY_REMOVE XenUsb_EvtDeviceQueryRemove;
    25.5  */
    25.6  
    25.7 -//PFN_WDF_DRIVER_DEVICE_ADD XenUsb_EvtDriverDeviceAdd;
    25.8 -NTSTATUS
    25.9 -XenUsb_EvtDriverDeviceAdd(WDFDRIVER driver, PWDFDEVICE_INIT device_init);
   25.10 +EVT_WDF_DRIVER_DEVICE_ADD XenUsb_EvtDriverDeviceAdd;
   25.11  
   25.12 -NTSTATUS
   25.13 -XenUsb_EvtChildListCreateDevice(WDFCHILDLIST child_list, PWDF_CHILD_IDENTIFICATION_DESCRIPTION_HEADER description_header, PWDFDEVICE_INIT child_init);
   25.14 -VOID
   25.15 -XenUsb_EvtChildListScanForChildren(WDFCHILDLIST child_list);
   25.16 +EVT_WDF_CHILD_LIST_CREATE_DEVICE XenUsb_EvtChildListCreateDevice;
   25.17 +EVT_WDF_CHILD_LIST_SCAN_FOR_CHILDREN XenUsb_EvtChildListScanForChildren;
   25.18  
   25.19  VOID
   25.20  XenUsb_EnumeratePorts(WDFDEVICE device);
   25.21  
   25.22 -VOID
   25.23 -XenUsb_EvtIoInternalDeviceControl_ROOTHUB_SUBMIT_URB(
   25.24 -  WDFQUEUE queue,
   25.25 -  WDFREQUEST request,
   25.26 -  size_t output_buffer_length,
   25.27 -  size_t input_buffer_length,
   25.28 -  ULONG io_control_code);
   25.29 -
   25.30 -VOID
   25.31 -XenUsb_EvtIoInternalDeviceControl_DEVICE_SUBMIT_URB(
   25.32 -  WDFQUEUE queue,
   25.33 -  WDFREQUEST request,
   25.34 -  size_t output_buffer_length,
   25.35 -  size_t input_buffer_length,
   25.36 -  ULONG io_control_code);
   25.37 +EVT_WDF_IO_QUEUE_IO_INTERNAL_DEVICE_CONTROL XenUsb_EvtIoInternalDeviceControl_DEVICE_SUBMIT_URB;
   25.38 +EVT_WDF_IO_QUEUE_IO_INTERNAL_DEVICE_CONTROL XenUsb_EvtIoInternalDeviceControl_ROOTHUB_SUBMIT_URB;
   25.39  
   25.40  NTSTATUS
   25.41  XenUsb_ExecuteRequest(
    26.1 --- a/xenusb/xenusb_fdo.c	Tue Dec 22 22:13:29 2009 +1100
    26.2 +++ b/xenusb/xenusb_fdo.c	Tue Dec 22 22:44:07 2009 +1100
    26.3 @@ -19,6 +19,20 @@ Foundation, Inc., 51 Franklin Street, Fi
    26.4  
    26.5  #include "xenusb.h"
    26.6  
    26.7 +/* Not really necessary but keeps PREfast happy */
    26.8 +static EVT_WDF_DEVICE_D0_ENTRY XenUsb_EvtDeviceD0Entry;
    26.9 +static EVT_WDF_DEVICE_D0_ENTRY_POST_INTERRUPTS_ENABLED XenUsb_EvtDeviceD0EntryPostInterruptsEnabled;
   26.10 +static EVT_WDF_DEVICE_D0_EXIT XenUsb_EvtDeviceD0Exit;
   26.11 +static EVT_WDF_DEVICE_D0_EXIT_PRE_INTERRUPTS_DISABLED XenUsb_EvtDeviceD0ExitPreInterruptsDisabled;
   26.12 +static EVT_WDF_DEVICE_PREPARE_HARDWARE XenUsb_EvtDevicePrepareHardware;
   26.13 +static EVT_WDF_DEVICE_RELEASE_HARDWARE XenUsb_EvtDeviceReleaseHardware;
   26.14 +static EVT_WDF_DEVICE_QUERY_REMOVE XenUsb_EvtDeviceQueryRemove;
   26.15 +static EVT_WDFDEVICE_WDM_IRP_PREPROCESS XenUsb_EvtDeviceWdmIrpPreprocessQUERY_INTERFACE;
   26.16 +static EVT_WDF_IO_QUEUE_IO_DEVICE_CONTROL XenUsb_EvtIoDeviceControl;
   26.17 +static EVT_WDF_IO_QUEUE_IO_INTERNAL_DEVICE_CONTROL XenUsb_EvtIoInternalDeviceControl;
   26.18 +static EVT_WDF_IO_QUEUE_IO_DEFAULT XenUsb_EvtIoDefault;
   26.19 +static EVT_WDF_PROGRAM_DMA XenUsb_ExecuteRequestCallback;
   26.20 +
   26.21  static BOOLEAN
   26.22  XenUsb_ExecuteRequestCallback(
   26.23    WDFDMATRANSACTION dma_transaction,
    27.1 --- a/xenusb/xenusb_hub.c	Tue Dec 22 22:13:29 2009 +1100
    27.2 +++ b/xenusb/xenusb_hub.c	Tue Dec 22 22:44:07 2009 +1100
    27.3 @@ -22,6 +22,32 @@ Foundation, Inc., 51 Franklin Street, Fi
    27.4  
    27.5  #pragma warning(disable: 4127) // conditional expression is constant
    27.6  
    27.7 +static EVT_WDF_DEVICE_D0_ENTRY XenUsbHub_EvtDeviceD0Entry;
    27.8 +static EVT_WDF_DEVICE_D0_EXIT XenUsbHub_EvtDeviceD0Exit;
    27.9 +static EVT_WDF_DEVICE_PREPARE_HARDWARE XenUsbHub_EvtDevicePrepareHardware;
   27.10 +static EVT_WDF_DEVICE_RELEASE_HARDWARE XenUsbHub_EvtDeviceReleaseHardware;
   27.11 +static EVT_WDF_DEVICE_USAGE_NOTIFICATION XenUsbHub_EvtDeviceUsageNotification;
   27.12 +static EVT_WDF_TIMER XenUsbHub_HubInterruptTimer;
   27.13 +static EVT_WDF_IO_QUEUE_IO_INTERNAL_DEVICE_CONTROL XenUsbHub_EvtIoInternalDeviceControl;
   27.14 +static EVT_WDF_IO_QUEUE_IO_DEVICE_CONTROL XenUsbHub_EvtIoDeviceControl;
   27.15 +static EVT_WDF_IO_QUEUE_IO_DEFAULT XenUsbHub_EvtIoDefault;
   27.16 +static USB_BUSIFFN_CREATE_USB_DEVICE XenUsbHub_UBIH_CreateUsbDevice;
   27.17 +static USB_BUSIFFN_INITIALIZE_USB_DEVICE XenUsbHub_UBIH_InitializeUsbDevice;
   27.18 +static USB_BUSIFFN_GET_USB_DESCRIPTORS XenUsbHub_UBIH_GetUsbDescriptors;
   27.19 +static USB_BUSIFFN_REMOVE_USB_DEVICE XenUsbHub_UBIH_RemoveUsbDevice;
   27.20 +static USB_BUSIFFN_RESTORE_DEVICE XenUsbHub_UBIH_RestoreUsbDevice;
   27.21 +static USB_BUSIFFN_GET_POTRTHACK_FLAGS XenUsbHub_UBIH_GetPortHackFlags;
   27.22 +static USB_BUSIFFN_GET_DEVICE_INFORMATION XenUsbHub_UBIH_QueryDeviceInformation;
   27.23 +static USB_BUSIFFN_GET_CONTROLLER_INFORMATION XenUsbHub_UBIH_GetControllerInformation;
   27.24 +static USB_BUSIFFN_CONTROLLER_SELECTIVE_SUSPEND XenUsbHub_UBIH_ControllerSelectiveSuspend;
   27.25 +static USB_BUSIFFN_GET_EXTENDED_HUB_INFO XenUsbHub_UBIH_GetExtendedHubInformation;
   27.26 +static USB_BUSIFFN_GET_ROOTHUB_SYM_NAME XenUsbHub_UBIH_GetRootHubSymbolicName;
   27.27 +static USB_BUSIFFN_GET_DEVICE_BUSCONTEXT XenUsbHub_UBIH_GetDeviceBusContext;
   27.28 +static USB_BUSIFFN_INITIALIZE_20HUB XenUsbHub_UBIH_Initialize20Hub;
   27.29 +static USB_BUSIFFN_ROOTHUB_INIT_NOTIFY XenUsbHub_UBIH_RootHubInitNotification;
   27.30 +static USB_BUSIFFN_FLUSH_TRANSFERS XenUsbHub_UBIH_FlushTransfers;
   27.31 +static USB_BUSIFFN_SET_DEVHANDLE_DATA XenUsbHub_UBIH_SetDeviceHandleData;
   27.32 +
   27.33  static VOID
   27.34  XenUsbHub_EvtIoDefault(
   27.35    WDFQUEUE queue,
   27.36 @@ -257,7 +283,7 @@ XenUsbHub_EvtIoInternalDeviceControl(
   27.37    //FUNCTION_EXIT();
   27.38  }
   27.39  
   27.40 -NTSTATUS
   27.41 +static NTSTATUS
   27.42  XenUsbHub_EvtDeviceD0Entry(WDFDEVICE device, WDF_POWER_DEVICE_STATE previous_state)
   27.43  {
   27.44    NTSTATUS status = STATUS_SUCCESS;
   27.45 @@ -296,7 +322,7 @@ XenUsbHub_EvtDeviceD0Entry(WDFDEVICE dev
   27.46    return status;
   27.47  }
   27.48  
   27.49 -NTSTATUS
   27.50 +static NTSTATUS
   27.51  XenUsbHub_EvtDeviceD0Exit(WDFDEVICE device, WDF_POWER_DEVICE_STATE target_state)
   27.52  {
   27.53    NTSTATUS status = STATUS_SUCCESS;
   27.54 @@ -337,7 +363,7 @@ XenUsbHub_EvtDeviceD0Exit(WDFDEVICE devi
   27.55    return status;
   27.56  }
   27.57  
   27.58 -NTSTATUS
   27.59 +static NTSTATUS
   27.60  XenUsbHub_EvtDevicePrepareHardware(WDFDEVICE device, WDFCMRESLIST resources_raw, WDFCMRESLIST resources_translated)
   27.61  {
   27.62    NTSTATUS status = STATUS_SUCCESS;
   27.63 @@ -352,7 +378,7 @@ XenUsbHub_EvtDevicePrepareHardware(WDFDE
   27.64    return status;
   27.65  }
   27.66  
   27.67 -NTSTATUS
   27.68 +static NTSTATUS
   27.69  XenUsbHub_EvtDeviceReleaseHardware(WDFDEVICE device, WDFCMRESLIST resources_translated)
   27.70  {
   27.71    NTSTATUS status = STATUS_SUCCESS;
   27.72 @@ -1019,20 +1045,18 @@ XenUsbHub_UBIH_RootHubInitNotification(
   27.73    return status;
   27.74  }
   27.75  
   27.76 -static NTSTATUS
   27.77 +/* This definition is incorrect in the docs */
   27.78 +static VOID
   27.79  XenUsbHub_UBIH_FlushTransfers(
   27.80    PVOID BusContext,
   27.81 -  PUSB_DEVICE_HANDLE DeviceHandle)
   27.82 +  PVOID DeviceHandle)
   27.83  {
   27.84 -  NTSTATUS status = STATUS_SUCCESS;
   27.85 -
   27.86    UNREFERENCED_PARAMETER(BusContext);
   27.87    UNREFERENCED_PARAMETER(DeviceHandle);
   27.88    
   27.89    FUNCTION_ENTER();
   27.90  
   27.91    FUNCTION_EXIT();
   27.92 -  return status;
   27.93  }
   27.94  
   27.95  static VOID
    28.1 --- a/xenvbd/xenvbd.c	Tue Dec 22 22:13:29 2009 +1100
    28.2 +++ b/xenvbd/xenvbd.c	Tue Dec 22 22:44:07 2009 +1100
    28.3 @@ -36,6 +36,9 @@ Foundation, Inc., 51 Franklin Street, Fi
    28.4    #define LongLongToPtr(x) UlongToPtr(x)
    28.5  #endif
    28.6  
    28.7 +/* Not really necessary but keeps PREfast happy */
    28.8 +DRIVER_INITIALIZE DriverEntry;
    28.9 +
   28.10  static BOOLEAN dump_mode = FALSE;
   28.11  
   28.12  CHAR scsi_device_manufacturer[8];
   28.13 @@ -1471,7 +1474,7 @@ DriverEntry(PDRIVER_OBJECT DriverObject,
   28.14          if(NT_SUCCESS(status))
   28.15            wcstombs(scsi_device_manufacturer, (PWCHAR)kpv->Data, min(kpv->DataLength, 8));
   28.16          else
   28.17 -          strncpy(scsi_device_manufacturer, "XEN     ", 8);
   28.18 +          RtlStringCbCopyA(scsi_device_manufacturer, 8, "XEN     ");
   28.19  
   28.20          RtlInitUnicodeString(&value_name, L"Disk_Model");
   28.21          buf_len = 256;
   28.22 @@ -1479,7 +1482,7 @@ DriverEntry(PDRIVER_OBJECT DriverObject,
   28.23          if(NT_SUCCESS(status))
   28.24            wcstombs(scsi_disk_model, (PWCHAR)kpv->Data, min(kpv->DataLength, 16));
   28.25          else
   28.26 -          strncpy(scsi_disk_model, "PV DISK          ", 16);
   28.27 +          RtlStringCbCopyA(scsi_disk_model, 16, "PV DISK          ");
   28.28  
   28.29          RtlInitUnicodeString(&value_name, L"CDROM_Model");
   28.30          buf_len = 256;
   28.31 @@ -1487,7 +1490,7 @@ DriverEntry(PDRIVER_OBJECT DriverObject,
   28.32          if(NT_SUCCESS(status))
   28.33            wcstombs(scsi_cdrom_model, (PWCHAR)kpv->Data, min(kpv->DataLength, 16));
   28.34          else
   28.35 -          strncpy(scsi_cdrom_model, "PV CDROM        ", 16);
   28.36 +          RtlStringCbCopyA(scsi_cdrom_model, 16, "PV CDROM        ");
   28.37        }
   28.38        ZwClose(service_handle);
   28.39      }
    29.1 --- a/xenvbd/xenvbd.h	Tue Dec 22 22:13:29 2009 +1100
    29.2 +++ b/xenvbd/xenvbd.h	Tue Dec 22 22:44:07 2009 +1100
    29.3 @@ -20,20 +20,14 @@ Foundation, Inc., 51 Franklin Street, Fi
    29.4  #if !defined(_XENVBD_H_)
    29.5  #define _XENVBD_H_
    29.6  
    29.7 -#ifdef __MINGW32__
    29.8 -#include <ntddk.h>
    29.9 -#include "../mingw/mingw_extras.h"
   29.10 -
   29.11 -#else
   29.12  #define DDKAPI
   29.13  
   29.14 -#include <ntifs.h>
   29.15 +//#include <ntifs.h>
   29.16  #include <ntddk.h>
   29.17  #include <wdm.h>
   29.18  #include <initguid.h>
   29.19  #define NTSTRSAFE_LIB
   29.20  #include <ntstrsafe.h>
   29.21 -#endif
   29.22  
   29.23  #include <ntdddisk.h>
   29.24  #include <srb.h>