summaryrefslogtreecommitdiff
path: root/general/ioctl
diff options
context:
space:
mode:
authorJ M Rossy <[email protected]>2015-07-29 15:40:09 -0700
committerJ M Rossy <[email protected]>2015-07-29 16:34:40 -0700
commit5d61a4a79a1e96dc5d9af1e5e712c84507307544 (patch)
tree49ed270893578cd18758b74ffcca16dc7ab948d6 /general/ioctl
parent5d41613e26e147d2300c786bb2b34cb4b4067a25 (diff)
Samples update for public Windows 10 release
Fix #2 Enabling WPP Recorder in Sensors Samples causes errors Fix #4 Add back fixed KMDOD sample Add new BarcodeScanner sample in pos folder Add new MagneticStripeReader sample in pos folder Add new SynpaticsTouch sample in input folder Add new Power Engine Plugin sample in pofx folder Add new DeviceMft sample in avstream folder Add new AvsCamera sample in root Add new SimBatt sample in root Add other pre-existing samples not yet released for Win10
Diffstat (limited to 'general/ioctl')
-rw-r--r--general/ioctl/kmdf/ReadMe.md67
-rw-r--r--general/ioctl/kmdf/exe/install.c812
-rw-r--r--general/ioctl/kmdf/exe/nonpnp.inf8
-rw-r--r--general/ioctl/kmdf/exe/nonpnpapp.vcxproj197
-rw-r--r--general/ioctl/kmdf/exe/nonpnpapp.vcxproj.Filters25
-rw-r--r--general/ioctl/kmdf/exe/testapp.c642
-rw-r--r--general/ioctl/kmdf/ioctl.sln46
-rw-r--r--general/ioctl/kmdf/sys/localwpp.ini17
-rw-r--r--general/ioctl/kmdf/sys/nonpnp.c1309
-rw-r--r--general/ioctl/kmdf/sys/nonpnp.h90
-rw-r--r--general/ioctl/kmdf/sys/nonpnp.rc10
-rw-r--r--general/ioctl/kmdf/sys/nonpnp.vcxproj196
-rw-r--r--general/ioctl/kmdf/sys/nonpnp.vcxproj.Filters31
-rw-r--r--general/ioctl/kmdf/sys/public.h53
-rw-r--r--general/ioctl/kmdf/sys/trace.h68
-rw-r--r--general/ioctl/wdm/exe/ioctlapp.vcxproj5
-rw-r--r--general/ioctl/wdm/exe/ioctlapp.vcxproj.Filters6
-rw-r--r--general/ioctl/wdm/ioctl.sln44
-rw-r--r--general/ioctl/wdm/sys/sioctl.vcxproj5
-rw-r--r--general/ioctl/wdm/sys/sioctl.vcxproj.Filters8
20 files changed, 3604 insertions, 35 deletions
diff --git a/general/ioctl/kmdf/ReadMe.md b/general/ioctl/kmdf/ReadMe.md
new file mode 100644
index 00000000..4cdee4d4
--- /dev/null
+++ b/general/ioctl/kmdf/ReadMe.md
@@ -0,0 +1,67 @@
+Non-PnP Driver Sample
+====================
+
+This sample is primarily meant to demonstrate how to write a NON-PNP driver using the Kernel Mode Driver Framework.
+
+It also illustrates several other important framework interfaces. Following table gives a typical usage scenario and summarizes all the features used in this sample.
+
+This sample would be useful for writing a driver that does not interact with any hardware. Typically, such drivers are written to provide some kernel-level services to a user application. These drivers are dynamically loaded by the application when it is run and unloaded when it exits.
+
+(Examples: FileMon, Regmon, DeviceTree are examples of tools that use this type of driver.)
+
+- How to Write a NON PNP driver
+
+- How to register EvtPreProcessCallback to handle requests in the context of the calling thread
+
+- Show how to probe and lock buffers in the preprocess callback for METHOD\_NEITHER IOCTL requests
+
+- Also show how to handle other 3 types of IOCTLs (METHOD\_BUFFERED, METHOD\_IN\_DIRECT & METHOD\_OUT\_DIRECT)
+
+- How to open a file in Kernel-mode and Read & Write to it
+
+- Finally show event tracing and dumping variable length data in the tracelog using HEXDUMP format.
+
+The sample is accompanied by a simple multithreaded Win32 console application to test the driver.
+
+This sample is adapted from the original IOCTL sample present in WDK (src\\general\\ioctl).
+
+*Disclaimer*: This is a minimal driver meant to demonstrate an OS feature. Neither it nor its sample programs are intended for use in a production environment. Rather, they are intended for educational purposes and as a skeleton driver.
+
+
+Build the sample
+----------------
+
+For information on how to build a driver solution using Microsoft Visual Studio, see [Building a Driver](http://msdn.microsoft.com/en-us/library/windows/hardware/ff554644).
+
+If the build succeeds, you will find the driver, nonpnp.sys, and the test application, nonpnpapp.exe, in the binary output directory specified for the build environment.
+
+To test this driver, copy the nonpnp.inf into the same folder as the nonpnpapp.exe and the wdfcoinstaller\<version\>.dll .
+
+**Note**  
+
+You can obtain redistributable framework updates by downloading the *wdfcoinstaller.msi* package from [WDK 8 Redistributable Components](http://go.microsoft.com/fwlink/p/?LinkID=226396). This package performs a silent install into the directory of your Windows Driver Kit (WDK) installation. You will see no confirmation that the installation has completed. You can verify that the redistributables have been installed on top of the WDK by ensuring there is a redist\\wdf directory under the root directory of the WDK, %ProgramFiles(x86)%\\Windows Kits\\8.0.
+
+Next, run nonpnpapp.exe, a simple Win32 multithreaded console mode application. The driver will be automatically loaded and started. When you exit the app, the driver will be stopped and removed.
+
+Usage: nonpnpapp.exe (-l) (-v version)
+
+**Note**: This application first tries to open the device (\\Device\\FileIo). If the device doesn't exist, it takes that as a hint that the driver is not loaded and tries to load the driver using service control manager API. If the service is loaded successfully, it tries to open the device again. If successful, it makes all four different types of DeviceControl calls to the driver. After that it makes a WriteFile call with an arbitrary size buffer. The driver, in response, writes that buffer to a file opened in the Create request. The name of the file was provided by the application as part of the device name and the directory path is hardcoded to %WINDIR%\\temp. When the WriteFile returns, the application makes a ReadFile call to read the file through the driver, and then compares the data returned by the driver with the one it originally wrote. If you specify -l option in command line, the application does this Write and Read operation in an infinite loop. The -v command line option is used to specify the version of the KMDF coinstaller (wdfcoinstaller\<version\>.dll) to load. If none is specified then it loads the coinstaller for v1.0 (wdfcoinstaller01000.dll)
+
+### WDF SECTION
+
+Nonpnp drivers typically don't need an INF file to install. Since we are using framework interfaces, we have to use the Kmdf coinstaller to install the framework binaries on the target machine. The Kmdf coinstaller needs a WDF specific section in the INF to get the driver service name and the version of the Kmdf library the driver is bound to. The syntax and description of the section is given below. Any non inf based driver using Kmdf library will need to have a dummy inf file with the wdf section in it. The format of the Wdf section is given below:
+
+[Version]
+
+Signature="\$WINDOWS NT\$"
+
+[\<driver name\>.NT.Wdf]
+
+KmdfService = \<your driver service name here\>, \<driver service install subsection\>
+
+[\<driver service install subsection\>]
+
+KmdfLibraryVersion = \<version bound to here, in Major.minor format\>
+
+For example, for V1.0 KmdfLibraryVersion is "1.0"
+
diff --git a/general/ioctl/kmdf/exe/install.c b/general/ioctl/kmdf/exe/install.c
new file mode 100644
index 00000000..7060243a
--- /dev/null
+++ b/general/ioctl/kmdf/exe/install.c
@@ -0,0 +1,812 @@
+/*++
+Copyright (c) Microsoft Corporation. All rights reserved.
+
+ THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
+ KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
+ PURPOSE.
+
+Module Name:
+
+ install.c
+
+Abstract:
+
+ Win32 routines to dynamically load and unload a Windows NT kernel-mode
+ driver using the Service Control Manager APIs.
+
+Environment:
+
+ User mode only
+
+--*/
+
+
+#include <DriverSpecs.h>
+_Analysis_mode_(_Analysis_code_type_user_code_)
+
+#include <windows.h>
+#include <strsafe.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "public.h"
+
+#include <wdfinstaller.h>
+
+#define ARRAY_SIZE(x) (sizeof(x) /sizeof(x[0]))
+
+extern
+PCHAR
+GetCoinstallerVersion(
+ VOID
+ ) ;
+
+BOOLEAN
+InstallDriver(
+ IN SC_HANDLE SchSCManager,
+ IN LPCTSTR DriverName,
+ IN LPCTSTR ServiceExe
+ );
+
+
+BOOLEAN
+RemoveDriver(
+ IN SC_HANDLE SchSCManager,
+ IN LPCTSTR DriverName
+ );
+
+BOOLEAN
+StartDriver(
+ IN SC_HANDLE SchSCManager,
+ IN LPCTSTR DriverName
+ );
+
+BOOLEAN
+StopDriver(
+ IN SC_HANDLE SchSCManager,
+ IN LPCTSTR DriverName
+ );
+
+#define SYSTEM32_DRIVERS "\\System32\\Drivers\\"
+#define NONPNP_INF_FILENAME L"\\nonpnp.inf"
+#define WDF_SECTION_NAME L"nonpnp.NT.Wdf"
+
+//----------------------------------------------------------------------------
+//
+//----------------------------------------------------------------------------
+PFN_WDFPREDEVICEINSTALLEX pfnWdfPreDeviceInstallEx;
+PFN_WDFPOSTDEVICEINSTALL pfnWdfPostDeviceInstall;
+PFN_WDFPREDEVICEREMOVE pfnWdfPreDeviceRemove;
+PFN_WDFPOSTDEVICEREMOVE pfnWdfPostDeviceRemove;
+
+//-----------------------------------------------------------------------------
+// 4127 -- Conditional Expression is Constant warning
+//-----------------------------------------------------------------------------
+#define WHILE(a) \
+__pragma(warning(suppress:4127)) while(a)
+
+LONG
+GetPathToInf(
+ _Out_writes_(InfFilePathSize) PWCHAR InfFilePath,
+ IN ULONG InfFilePathSize
+ )
+{
+ LONG error = ERROR_SUCCESS;
+
+ if (GetCurrentDirectoryW(InfFilePathSize, InfFilePath) == 0) {
+ error = GetLastError();
+ printf("InstallDriver failed! Error = %d \n", error);
+ return error;
+ }
+ if (FAILED( StringCchCatW(InfFilePath,
+ InfFilePathSize,
+ NONPNP_INF_FILENAME) )) {
+ error = ERROR_BUFFER_OVERFLOW;
+ return error;
+ }
+ return error;
+
+}
+
+//----------------------------------------------------------------------------
+//
+//----------------------------------------------------------------------------
+BOOLEAN
+InstallDriver(
+ IN SC_HANDLE SchSCManager,
+ IN LPCTSTR DriverName,
+ IN LPCTSTR ServiceExe
+ )
+/*++
+
+Routine Description:
+
+Arguments:
+
+Return Value:
+
+--*/
+{
+ SC_HANDLE schService;
+ DWORD err;
+ WCHAR infPath[MAX_PATH];
+ WDF_COINSTALLER_INSTALL_OPTIONS clientOptions;
+
+ WDF_COINSTALLER_INSTALL_OPTIONS_INIT(&clientOptions);
+
+ //
+ // NOTE: This creates an entry for a standalone driver. If this
+ // is modified for use with a driver that requires a Tag,
+ // Group, and/or Dependencies, it may be necessary to
+ // query the registry for existing driver information
+ // (in order to determine a unique Tag, etc.).
+ //
+ //
+ // PRE-INSTALL for WDF support
+ //
+ err = GetPathToInf(infPath, ARRAY_SIZE(infPath) );
+ if (err != ERROR_SUCCESS) {
+ return FALSE;
+ }
+ err = pfnWdfPreDeviceInstallEx(infPath, WDF_SECTION_NAME, &clientOptions);
+
+ if (err != ERROR_SUCCESS) {
+ if (err == ERROR_SUCCESS_REBOOT_REQUIRED) {
+ printf("System needs to be rebooted, before the driver installation can proceed.\n");
+ }
+
+ return FALSE;
+ }
+
+ //
+ // Create a new a service object.
+ //
+
+ schService = CreateService(SchSCManager, // handle of service control manager database
+ DriverName, // address of name of service to start
+ DriverName, // address of display name
+ SERVICE_ALL_ACCESS, // type of access to service
+ SERVICE_KERNEL_DRIVER, // type of service
+ SERVICE_DEMAND_START, // when to start service
+ SERVICE_ERROR_NORMAL, // severity if service fails to start
+ ServiceExe, // address of name of binary file
+ NULL, // service does not belong to a group
+ NULL, // no tag requested
+ NULL, // no dependency names
+ NULL, // use LocalSystem account
+ NULL // no password for service account
+ );
+
+ if (schService == NULL) {
+
+ err = GetLastError();
+
+ if (err == ERROR_SERVICE_EXISTS) {
+
+ //
+ // Ignore this error.
+ //
+
+ return TRUE;
+
+ } else {
+
+ printf("CreateService failed! Error = %d \n", err );
+
+ //
+ // Indicate an error.
+ //
+
+ return FALSE;
+ }
+ }
+
+ //
+ // Close the service object.
+ //
+ CloseServiceHandle(schService);
+
+ //
+ // POST-INSTALL for WDF support
+ //
+ err = pfnWdfPostDeviceInstall( infPath, WDF_SECTION_NAME );
+
+ if (err != ERROR_SUCCESS) {
+ return FALSE;
+ }
+
+ //
+ // Indicate success.
+ //
+
+ return TRUE;
+
+} // InstallDriver
+
+BOOLEAN
+ManageDriver(
+ IN LPCTSTR DriverName,
+ IN LPCTSTR ServiceName,
+ IN USHORT Function
+ )
+{
+
+ SC_HANDLE schSCManager;
+
+ BOOLEAN rCode = TRUE;
+
+ //
+ // Insure (somewhat) that the driver and service names are valid.
+ //
+
+ if (!DriverName || !ServiceName) {
+
+ printf("Invalid Driver or Service provided to ManageDriver() \n");
+
+ return FALSE;
+ }
+
+ //
+ // Connect to the Service Control Manager and open the Services database.
+ //
+
+ schSCManager = OpenSCManager(NULL, // local machine
+ NULL, // local database
+ SC_MANAGER_ALL_ACCESS // access required
+ );
+
+ if (!schSCManager) {
+
+ printf("Open SC Manager failed! Error = %d \n", GetLastError());
+
+ return FALSE;
+ }
+
+ //
+ // Do the requested function.
+ //
+
+ switch( Function ) {
+
+ case DRIVER_FUNC_INSTALL:
+
+ //
+ // Install the driver service.
+ //
+
+ if (InstallDriver(schSCManager,
+ DriverName,
+ ServiceName
+ )) {
+
+ //
+ // Start the driver service (i.e. start the driver).
+ //
+
+ rCode = StartDriver(schSCManager,
+ DriverName
+ );
+
+ } else {
+
+ //
+ // Indicate an error.
+ //
+
+ rCode = FALSE;
+ }
+
+ break;
+
+ case DRIVER_FUNC_REMOVE:
+
+ //
+ // Stop the driver.
+ //
+
+ StopDriver(schSCManager,
+ DriverName
+ );
+
+ //
+ // Remove the driver service.
+ //
+
+ RemoveDriver(schSCManager,
+ DriverName
+ );
+
+ //
+ // Ignore all errors.
+ //
+
+ rCode = TRUE;
+
+ break;
+
+ default:
+
+ printf("Unknown ManageDriver() function. \n");
+
+ rCode = FALSE;
+
+ break;
+ }
+
+ //
+ // Close handle to service control manager.
+ //
+ CloseServiceHandle(schSCManager);
+
+ return rCode;
+
+} // ManageDriver
+
+
+BOOLEAN
+RemoveDriver(
+ IN SC_HANDLE SchSCManager,
+ IN LPCTSTR DriverName
+ )
+{
+ SC_HANDLE schService;
+ BOOLEAN rCode;
+ DWORD err;
+ WCHAR infPath[MAX_PATH];
+
+ err = GetPathToInf(infPath, ARRAY_SIZE(infPath) );
+ if (err != ERROR_SUCCESS) {
+ return FALSE;
+ }
+
+ //
+ // PRE-REMOVE of WDF support
+ //
+ err = pfnWdfPreDeviceRemove( infPath, WDF_SECTION_NAME );
+
+ if (err != ERROR_SUCCESS) {
+ return FALSE;
+ }
+
+ //
+ // Open the handle to the existing service.
+ //
+
+ schService = OpenService(SchSCManager,
+ DriverName,
+ SERVICE_ALL_ACCESS
+ );
+
+ if (schService == NULL) {
+
+ printf("OpenService failed! Error = %d \n", GetLastError());
+
+ //
+ // Indicate error.
+ //
+
+ return FALSE;
+ }
+
+ //
+ // Mark the service for deletion from the service control manager database.
+ //
+
+ if (DeleteService(schService)) {
+
+ //
+ // Indicate success.
+ //
+
+ rCode = TRUE;
+
+ } else {
+
+ printf("DeleteService failed! Error = %d \n", GetLastError());
+
+ //
+ // Indicate failure. Fall through to properly close the service handle.
+ //
+
+ rCode = FALSE;
+ }
+
+ //
+ // Close the service object.
+ //
+ CloseServiceHandle(schService);
+
+ //
+ // POST-REMOVE of WDF support
+ //
+ err = pfnWdfPostDeviceRemove(infPath, WDF_SECTION_NAME );
+
+ if (err != ERROR_SUCCESS) {
+ rCode = FALSE;
+ }
+
+ return rCode;
+
+} // RemoveDriver
+
+
+
+BOOLEAN
+StartDriver(
+ IN SC_HANDLE SchSCManager,
+ IN LPCTSTR DriverName
+ )
+{
+ SC_HANDLE schService;
+ DWORD err;
+ BOOL ok;
+
+ //
+ // Open the handle to the existing service.
+ //
+ schService = OpenService(SchSCManager,
+ DriverName,
+ SERVICE_ALL_ACCESS
+ );
+
+ if (schService == NULL) {
+ //
+ // Indicate failure.
+ //
+ printf("OpenService failed! Error = %d\n", GetLastError());
+ return FALSE;
+ }
+
+ //
+ // Start the execution of the service (i.e. start the driver).
+ //
+ ok = StartService( schService, 0, NULL );
+
+ if (!ok) {
+
+ err = GetLastError();
+
+ if (err == ERROR_SERVICE_ALREADY_RUNNING) {
+ //
+ // Ignore this error.
+ //
+ return TRUE;
+
+ } else {
+ //
+ // Indicate failure.
+ // Fall through to properly close the service handle.
+ //
+ printf("StartService failure! Error = %d\n", err );
+ return FALSE;
+ }
+ }
+
+ //
+ // Close the service object.
+ //
+ CloseServiceHandle(schService);
+
+ return TRUE;
+
+} // StartDriver
+
+
+
+BOOLEAN
+StopDriver(
+ IN SC_HANDLE SchSCManager,
+ IN LPCTSTR DriverName
+ )
+{
+ BOOLEAN rCode = TRUE;
+ SC_HANDLE schService;
+ SERVICE_STATUS serviceStatus;
+
+ //
+ // Open the handle to the existing service.
+ //
+
+ schService = OpenService(SchSCManager,
+ DriverName,
+ SERVICE_ALL_ACCESS
+ );
+
+ if (schService == NULL) {
+
+ printf("OpenService failed! Error = %d \n", GetLastError());
+
+ return FALSE;
+ }
+
+ //
+ // Request that the service stop.
+ //
+
+ if (ControlService(schService,
+ SERVICE_CONTROL_STOP,
+ &serviceStatus
+ )) {
+
+ //
+ // Indicate success.
+ //
+
+ rCode = TRUE;
+
+ } else {
+
+ printf("ControlService failed! Error = %d \n", GetLastError() );
+
+ //
+ // Indicate failure. Fall through to properly close the service handle.
+ //
+
+ rCode = FALSE;
+ }
+
+ //
+ // Close the service object.
+ //
+ CloseServiceHandle (schService);
+
+ return rCode;
+
+} // StopDriver
+
+
+//
+// Caller must free returned pathname string.
+//
+PCHAR
+BuildDriversDirPath(
+ _In_ PSTR DriverName
+ )
+{
+ size_t remain;
+ size_t len;
+ PCHAR dir;
+
+ if (!DriverName || strlen(DriverName) == 0) {
+ return NULL;
+ }
+
+ remain = MAX_PATH;
+
+ //
+ // Allocate string space
+ //
+ dir = (PCHAR) malloc( remain + 1 );
+
+ if (!dir) {
+ return NULL;
+ }
+
+ //
+ // Get the base windows directory path.
+ //
+ len = GetWindowsDirectory( dir, (UINT) remain );
+
+ if (len == 0 ||
+ (remain - len) < sizeof(SYSTEM32_DRIVERS)) {
+ free(dir);
+ return NULL;
+ }
+ remain -= len;
+
+ //
+ // Build dir to have "%windir%\System32\Drivers\<DriverName>".
+ //
+ if (FAILED( StringCchCat(dir, remain, SYSTEM32_DRIVERS) )) {
+ free(dir);
+ return NULL;
+ }
+
+ remain -= sizeof(SYSTEM32_DRIVERS);
+ len += sizeof(SYSTEM32_DRIVERS);
+ len += strlen(DriverName);
+
+ if (remain < len) {
+ free(dir);
+ return NULL;
+ }
+
+ if (FAILED( StringCchCat(dir, remain, DriverName) )) {
+ free(dir);
+ return NULL;
+ }
+
+ dir[len] = '\0'; // keeps prefast happy
+
+ return dir;
+}
+
+
+BOOLEAN
+SetupDriverName(
+ _Inout_updates_all_(BufferLength) PCHAR DriverLocation,
+ _In_ ULONG BufferLength
+ )
+{
+ HANDLE fileHandle;
+ DWORD driverLocLen = 0;
+ BOOL ok;
+ PCHAR driversDir;
+
+ //
+ // Setup path name to driver file.
+ //
+ driverLocLen =
+ GetCurrentDirectory(BufferLength, DriverLocation);
+
+ if (!driverLocLen) {
+
+ printf("GetCurrentDirectory failed! Error = %d \n",
+ GetLastError());
+
+ return FALSE;
+ }
+
+ if (FAILED( StringCchCat(DriverLocation, BufferLength, "\\" DRIVER_NAME ".sys") )) {
+ return FALSE;
+ }
+
+ //
+ // Insure driver file is in the specified directory.
+ //
+ fileHandle = CreateFile( DriverLocation,
+ GENERIC_READ,
+ FILE_SHARE_READ,
+ NULL,
+ OPEN_EXISTING,
+ FILE_ATTRIBUTE_NORMAL,
+ NULL );
+
+ if (fileHandle == INVALID_HANDLE_VALUE) {
+ //
+ // Indicate failure.
+ //
+ printf("Driver: %s.SYS is not in the %s directory. \n",
+ DRIVER_NAME, DriverLocation );
+ return FALSE;
+ }
+
+ //
+ // Build %windir%\System32\Drivers\<DRIVER_NAME> path.
+ // Copy the driver to %windir%\system32\drivers
+ //
+ driversDir = BuildDriversDirPath( DRIVER_NAME ".sys" );
+
+ if (!driversDir) {
+ printf("BuildDriversDirPath failed!\n");
+ return FALSE;
+ }
+
+ ok = CopyFile( DriverLocation, driversDir, FALSE );
+
+ if(!ok) {
+ printf("CopyFile failed: error(%d) - \"%s\"\n",
+ GetLastError(), driversDir );
+ free(driversDir);
+ return FALSE;
+ }
+
+ if (FAILED( StringCchCopy(DriverLocation, BufferLength, driversDir) )) {
+ free(driversDir);
+ return FALSE;
+ }
+
+ free(driversDir);
+
+ //
+ // Close open file handle.
+ //
+ if (fileHandle) {
+ CloseHandle(fileHandle);
+ }
+
+ //
+ // Indicate success.
+ //
+ return TRUE;
+
+} // SetupDriverName
+
+
+HMODULE
+LoadWdfCoInstaller(
+ VOID
+ )
+{
+ HMODULE library = NULL;
+ DWORD error = ERROR_SUCCESS;
+ CHAR szCurDir[MAX_PATH];
+ CHAR tempCoinstallerName[MAX_PATH];
+ PCHAR coinstallerVersion;
+
+ do {
+
+ if (GetCurrentDirectory(MAX_PATH, szCurDir) == 0) {
+
+ printf("GetCurrentDirectory failed! Error = %d \n", GetLastError());
+ break;
+ }
+ coinstallerVersion = GetCoinstallerVersion();
+ if (FAILED( StringCchPrintf(tempCoinstallerName,
+ MAX_PATH,
+ "\\WdfCoInstaller%s.dll",
+ coinstallerVersion) )) {
+ break;
+ }
+ if (FAILED( StringCchCat(szCurDir, MAX_PATH, tempCoinstallerName) )) {
+ break;
+ }
+
+ library = LoadLibrary(szCurDir);
+
+ if (library == NULL) {
+ error = GetLastError();
+ printf("LoadLibrary(%s) failed: %d\n", szCurDir, error);
+ break;
+ }
+
+ pfnWdfPreDeviceInstallEx =
+ (PFN_WDFPREDEVICEINSTALLEX) GetProcAddress( library, "WdfPreDeviceInstallEx" );
+
+ if (pfnWdfPreDeviceInstallEx == NULL) {
+ error = GetLastError();
+ printf("GetProcAddress(\"WdfPreDeviceInstallEx\") failed: %d\n", error);
+ return NULL;
+ }
+
+ pfnWdfPostDeviceInstall =
+ (PFN_WDFPOSTDEVICEINSTALL) GetProcAddress( library, "WdfPostDeviceInstall" );
+
+ if (pfnWdfPostDeviceInstall == NULL) {
+ error = GetLastError();
+ printf("GetProcAddress(\"WdfPostDeviceInstall\") failed: %d\n", error);
+ return NULL;
+ }
+
+ pfnWdfPreDeviceRemove =
+ (PFN_WDFPREDEVICEREMOVE) GetProcAddress( library, "WdfPreDeviceRemove" );
+
+ if (pfnWdfPreDeviceRemove == NULL) {
+ error = GetLastError();
+ printf("GetProcAddress(\"WdfPreDeviceRemove\") failed: %d\n", error);
+ return NULL;
+ }
+
+ pfnWdfPostDeviceRemove =
+ (PFN_WDFPREDEVICEREMOVE) GetProcAddress( library, "WdfPostDeviceRemove" );
+
+ if (pfnWdfPostDeviceRemove == NULL) {
+ error = GetLastError();
+ printf("GetProcAddress(\"WdfPostDeviceRemove\") failed: %d\n", error);
+ return NULL;
+ }
+
+ } WHILE (0);
+
+ if (error != ERROR_SUCCESS) {
+ if (library) {
+ FreeLibrary( library );
+ }
+ library = NULL;
+ }
+
+ return library;
+}
+
+
+VOID
+UnloadWdfCoInstaller(
+ HMODULE Library
+ )
+{
+ if (Library) {
+ FreeLibrary( Library );
+ }
+}
+
diff --git a/general/ioctl/kmdf/exe/nonpnp.inf b/general/ioctl/kmdf/exe/nonpnp.inf
new file mode 100644
index 00000000..b20a58b4
--- /dev/null
+++ b/general/ioctl/kmdf/exe/nonpnp.inf
@@ -0,0 +1,8 @@
+[Version]
+Signature="$WINDOWS NT$"
+
+[nonpnp.NT.Wdf]
+KmdfService = nonpnp, nonpnp_Service_kmdfInst
+
+[nonpnp_Service_kmdfInst]
+KmdfLibraryVersion = 1.11
diff --git a/general/ioctl/kmdf/exe/nonpnpapp.vcxproj b/general/ioctl/kmdf/exe/nonpnpapp.vcxproj
new file mode 100644
index 00000000..2c94c413
--- /dev/null
+++ b/general/ioctl/kmdf/exe/nonpnpapp.vcxproj
@@ -0,0 +1,197 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup Label="ProjectConfigurations">
+ <ProjectConfiguration Include="Debug|Win32">
+ <Configuration>Debug</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|Win32">
+ <Configuration>Release</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Debug|x64">
+ <Configuration>Debug</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|x64">
+ <Configuration>Release</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ </ItemGroup>
+ <PropertyGroup Label="Globals">
+ <ProjectGuid>{0EF21B20-E757-4FD0-8A1C-4ABF6FD7E466}</ProjectGuid>
+ <RootNamespace>$(MSBuildProjectName)</RootNamespace>
+ <KMDF_VERSION_MAJOR>1</KMDF_VERSION_MAJOR>
+ <KMDF_VERSION_MINOR>11</KMDF_VERSION_MINOR>
+ <Configuration Condition="'$(Configuration)' == ''">Debug</Configuration>
+ <Platform Condition="'$(Platform)' == ''">Win32</Platform>
+ <SampleGuid>{FF8A5123-63A1-4527-A466-ED494318076D}</SampleGuid>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+ <PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <TargetVersion>Windows10</TargetVersion>
+ <UseDebugLibraries>False</UseDebugLibraries>
+ <DriverTargetPlatform>Desktop</DriverTargetPlatform>
+ <DriverType />
+ <PlatformToolset>WindowsApplicationForDrivers10.0</PlatformToolset>
+ <ConfigurationType>Application</ConfigurationType>
+ </PropertyGroup>
+ <PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <TargetVersion>Windows10</TargetVersion>
+ <UseDebugLibraries>True</UseDebugLibraries>
+ <DriverTargetPlatform>Desktop</DriverTargetPlatform>
+ <DriverType />
+ <PlatformToolset>WindowsApplicationForDrivers10.0</PlatformToolset>
+ <ConfigurationType>Application</ConfigurationType>
+ </PropertyGroup>
+ <PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <TargetVersion>Windows10</TargetVersion>
+ <UseDebugLibraries>False</UseDebugLibraries>
+ <DriverTargetPlatform>Desktop</DriverTargetPlatform>
+ <DriverType />
+ <PlatformToolset>WindowsApplicationForDrivers10.0</PlatformToolset>
+ <ConfigurationType>Application</ConfigurationType>
+ </PropertyGroup>
+ <PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <TargetVersion>Windows10</TargetVersion>
+ <UseDebugLibraries>True</UseDebugLibraries>
+ <DriverTargetPlatform>Desktop</DriverTargetPlatform>
+ <DriverType />
+ <PlatformToolset>WindowsApplicationForDrivers10.0</PlatformToolset>
+ <ConfigurationType>Application</ConfigurationType>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+ <PropertyGroup>
+ <OutDir>$(IntDir)</OutDir>
+ </PropertyGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" />
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" />
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" />
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" />
+ </ImportGroup>
+ <ItemGroup Label="WrappedTaskItems">
+ <ClCompile Include="testapp.c; install.c">
+ <WppEnabled>true</WppEnabled>
+ </ClCompile>
+ </ItemGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <TargetName>nonpnpapp</TargetName>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <TargetName>nonpnpapp</TargetName>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <TargetName>nonpnpapp</TargetName>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <TargetName>nonpnpapp</TargetName>
+ </PropertyGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <Link>
+ <AdditionalDependencies>%(AdditionalDependencies);setupapi.lib;user32.lib</AdditionalDependencies>
+ </Link>
+ <ResourceCompile>
+ <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);..\sys</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>%(PreprocessorDefinitions);KMDF_VERSION_MAJOR=1;KMDF_VERSION_MINOR=11</PreprocessorDefinitions>
+ <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);$(WDKContentRoot)\Include\wdf\kmdf\1.11</AdditionalIncludeDirectories>
+ </ResourceCompile>
+ <ClCompile>
+ <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);..\sys</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>%(PreprocessorDefinitions);KMDF_VERSION_MAJOR=1;KMDF_VERSION_MINOR=11</PreprocessorDefinitions>
+ <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);$(WDKContentRoot)\Include\wdf\kmdf\1.11</AdditionalIncludeDirectories>
+ <ExceptionHandling>
+ </ExceptionHandling>
+ </ClCompile>
+ <Midl>
+ <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);..\sys</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>%(PreprocessorDefinitions);KMDF_VERSION_MAJOR=1;KMDF_VERSION_MINOR=11</PreprocessorDefinitions>
+ <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);$(WDKContentRoot)\Include\wdf\kmdf\1.11</AdditionalIncludeDirectories>
+ </Midl>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <Link>
+ <AdditionalDependencies>%(AdditionalDependencies);setupapi.lib;user32.lib</AdditionalDependencies>
+ </Link>
+ <ResourceCompile>
+ <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);..\sys</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>%(PreprocessorDefinitions);KMDF_VERSION_MAJOR=1;KMDF_VERSION_MINOR=11</PreprocessorDefinitions>
+ <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);$(WDKContentRoot)\Include\wdf\kmdf\1.11</AdditionalIncludeDirectories>
+ </ResourceCompile>
+ <ClCompile>
+ <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);..\sys</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>%(PreprocessorDefinitions);KMDF_VERSION_MAJOR=1;KMDF_VERSION_MINOR=11</PreprocessorDefinitions>
+ <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);$(WDKContentRoot)\Include\wdf\kmdf\1.11</AdditionalIncludeDirectories>
+ <ExceptionHandling>
+ </ExceptionHandling>
+ </ClCompile>
+ <Midl>
+ <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);..\sys</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>%(PreprocessorDefinitions);KMDF_VERSION_MAJOR=1;KMDF_VERSION_MINOR=11</PreprocessorDefinitions>
+ <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);$(WDKContentRoot)\Include\wdf\kmdf\1.11</AdditionalIncludeDirectories>
+ </Midl>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <Link>
+ <AdditionalDependencies>%(AdditionalDependencies);setupapi.lib;user32.lib</AdditionalDependencies>
+ </Link>
+ <ResourceCompile>
+ <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);..\sys</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>%(PreprocessorDefinitions);KMDF_VERSION_MAJOR=1;KMDF_VERSION_MINOR=11</PreprocessorDefinitions>
+ <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);$(WDKContentRoot)\Include\wdf\kmdf\1.11</AdditionalIncludeDirectories>
+ </ResourceCompile>
+ <ClCompile>
+ <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);..\sys</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>%(PreprocessorDefinitions);KMDF_VERSION_MAJOR=1;KMDF_VERSION_MINOR=11</PreprocessorDefinitions>
+ <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);$(WDKContentRoot)\Include\wdf\kmdf\1.11</AdditionalIncludeDirectories>
+ <ExceptionHandling>
+ </ExceptionHandling>
+ </ClCompile>
+ <Midl>
+ <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);..\sys</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>%(PreprocessorDefinitions);KMDF_VERSION_MAJOR=1;KMDF_VERSION_MINOR=11</PreprocessorDefinitions>
+ <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);$(WDKContentRoot)\Include\wdf\kmdf\1.11</AdditionalIncludeDirectories>
+ </Midl>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <Link>
+ <AdditionalDependencies>%(AdditionalDependencies);setupapi.lib;user32.lib</AdditionalDependencies>
+ </Link>
+ <ResourceCompile>
+ <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);..\sys</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>%(PreprocessorDefinitions);KMDF_VERSION_MAJOR=1;KMDF_VERSION_MINOR=11</PreprocessorDefinitions>
+ <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);$(WDKContentRoot)\Include\wdf\kmdf\1.11</AdditionalIncludeDirectories>
+ </ResourceCompile>
+ <ClCompile>
+ <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);..\sys</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>%(PreprocessorDefinitions);KMDF_VERSION_MAJOR=1;KMDF_VERSION_MINOR=11</PreprocessorDefinitions>
+ <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);$(WDKContentRoot)\Include\wdf\kmdf\1.11</AdditionalIncludeDirectories>
+ <ExceptionHandling>
+ </ExceptionHandling>
+ </ClCompile>
+ <Midl>
+ <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);..\sys</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>%(PreprocessorDefinitions);KMDF_VERSION_MAJOR=1;KMDF_VERSION_MINOR=11</PreprocessorDefinitions>
+ <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);$(WDKContentRoot)\Include\wdf\kmdf\1.11</AdditionalIncludeDirectories>
+ </Midl>
+ </ItemDefinitionGroup>
+ <ItemGroup>
+ <Inf Exclude="@(Inf)" Include="*.inf" />
+ <FilesToPackage Include="$(TargetPath)" Condition="'$(ConfigurationType)'=='Driver' or '$(ConfigurationType)'=='DynamicLibrary'" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Exclude="@(None)" Include="*.txt;*.htm;*.html" />
+ <None Exclude="@(None)" Include="*.ico;*.cur;*.bmp;*.dlg;*.rct;*.gif;*.jpg;*.jpeg;*.wav;*.jpe;*.tiff;*.tif;*.png;*.rc2" />
+ <None Exclude="@(None)" Include="*.def;*.bat;*.hpj;*.asmx" />
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Exclude="@(ClInclude)" Include="*.h;*.hpp;*.hxx;*.hm;*.inl;*.xsd" />
+ </ItemGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+</Project> \ No newline at end of file
diff --git a/general/ioctl/kmdf/exe/nonpnpapp.vcxproj.Filters b/general/ioctl/kmdf/exe/nonpnpapp.vcxproj.Filters
new file mode 100644
index 00000000..221896d4
--- /dev/null
+++ b/general/ioctl/kmdf/exe/nonpnpapp.vcxproj.Filters
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup>
+ <Filter Include="Source Files">
+ <Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx;*</Extensions>
+ <UniqueIdentifier>{438A7A19-8784-4ADC-BB59-D3D149EA5459}</UniqueIdentifier>
+ </Filter>
+ <Filter Include="Header Files">
+ <Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
+ <UniqueIdentifier>{A4461789-7186-462B-9A53-73365178FC6A}</UniqueIdentifier>
+ </Filter>
+ <Filter Include="Resource Files">
+ <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms;man;xml</Extensions>
+ <UniqueIdentifier>{323846A7-7FFC-4D78-8D57-B470FE54DE4B}</UniqueIdentifier>
+ </Filter>
+ </ItemGroup>
+ <ItemGroup>
+ <ClCompile Include="install.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="testapp.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ </ItemGroup>
+</Project> \ No newline at end of file
diff --git a/general/ioctl/kmdf/exe/testapp.c b/general/ioctl/kmdf/exe/testapp.c
new file mode 100644
index 00000000..a6cd07c1
--- /dev/null
+++ b/general/ioctl/kmdf/exe/testapp.c
@@ -0,0 +1,642 @@
+/*++
+
+Copyright (c) Microsoft Corporation. All rights reserved.
+
+ THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
+ KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
+ PURPOSE.
+
+
+Module Name:
+
+ testapp.c
+
+Abstract:
+
+ Purpose of this app to test the NONPNP sample driver. The app
+ makes four different ioctl calls to test all the buffer types, write
+ some random buffer content to a file created by the driver in \SystemRoot\Temp
+ directory, and reads the same file and matches the content.
+ If -l option is specified, it does the write and read operation in a loop
+ until the app is terminated by pressing ^C.
+
+ Make sure you have the \SystemRoot\Temp directory exists before you run the test.
+
+Environment:
+
+ Win32 console application.
+
+--*/
+
+
+#include <DriverSpecs.h>
+_Analysis_mode_(_Analysis_code_type_user_code_)
+
+#include <windows.h>
+
+#pragma warning(disable:4201) // nameless struct/union
+#include <winioctl.h>
+#pragma warning(default:4201)
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <time.h>
+#include <limits.h>
+#include <strsafe.h>
+#include "public.h"
+
+
+BOOLEAN
+ManageDriver(
+ IN LPCTSTR DriverName,
+ IN LPCTSTR ServiceName,
+ IN USHORT Function
+ );
+
+HMODULE
+LoadWdfCoInstaller(
+ VOID
+ );
+
+VOID
+UnloadWdfCoInstaller(
+ HMODULE Library
+ );
+
+BOOLEAN
+SetupDriverName(
+ _Inout_updates_all_(BufferLength) PCHAR DriverLocation,
+ _In_ ULONG BufferLength
+ );
+
+BOOLEAN
+DoFileReadWrite(
+ HANDLE HDevice
+ );
+
+VOID
+DoIoctls(
+ HANDLE hDevice
+ );
+
+// for example, WDF 1.9 is "01009". the size 6 includes the ending NULL marker
+//
+#define MAX_VERSION_SIZE 6
+
+CHAR G_coInstallerVersion[MAX_VERSION_SIZE] = {0};
+BOOLEAN G_fLoop = FALSE;
+BOOL G_versionSpecified = FALSE;
+
+
+
+//-----------------------------------------------------------------------------
+// 4127 -- Conditional Expression is Constant warning
+//-----------------------------------------------------------------------------
+#define WHILE(constant) \
+__pragma(warning(disable: 4127)) while(constant); __pragma(warning(default: 4127))
+
+
+#define USAGE \
+"Usage: nonpnpapp <-V version> <-l> \n" \
+ " -V version {if no version is specified the version specified in the build environment will be used.}\n" \
+ " The version is the version of the KMDF coinstaller to use \n" \
+ " The format of version is MMmmm where MM -- major #, mmm - serial# \n" \
+ " -l { option to continuously read & write to the file} \n"
+
+BOOL
+ValidateCoinstallerVersion(
+ _In_ PSTR Version
+ )
+{ BOOL ok = FALSE;
+ INT i;
+
+ for(i= 0; i<MAX_VERSION_SIZE ;i++){
+ if( ! IsCharAlphaNumericA(Version[i])) {
+ break;
+ }
+ }
+ if (i == (MAX_VERSION_SIZE -sizeof(CHAR))) {
+ ok = TRUE;
+ }
+ return ok;
+}
+
+LONG
+Parse(
+ _In_ int argc,
+ _In_reads_(argc) char *argv[]
+ )
+/*++
+Routine Description:
+
+ Called by main() to parse command line parms
+
+Arguments:
+
+ argc and argv that was passed to main()
+
+Return Value:
+
+ Sets global flags as per user function request
+
+--*/
+{
+ int i;
+ BOOL ok;
+ LONG error = ERROR_SUCCESS;
+
+ for (i=0; i<argc; i++) {
+ if (argv[i][0] == '-' ||
+ argv[i][0] == '/') {
+ switch(argv[i][1]) {
+ case 'V':
+ case 'v':
+ if (( (i+1 < argc ) &&
+ ( argv[i+1][0] != '-' && argv[i+1][0] != '/'))) {
+ //
+ // use version in commandline
+ //
+ i++;
+ ok = ValidateCoinstallerVersion(argv[i]);
+ if (!ok) {
+ printf("Not a valid format for coinstaller version\n"
+ "It should be characters between A-Z, a-z , 0-9\n"
+ "The version format is MMmmm where MM -- major #, mmm - serial#");
+ error = ERROR_INVALID_PARAMETER;
+ break;
+ }
+ if (FAILED( StringCchCopy(G_coInstallerVersion,
+ MAX_VERSION_SIZE,
+ argv[i]) )) {
+ break;
+ }
+ G_versionSpecified = TRUE;
+
+ }
+ else{
+ printf(USAGE);
+ error = ERROR_INVALID_PARAMETER;
+ }
+ break;
+ case 'l':
+ case 'L':
+ G_fLoop = TRUE;
+ break;
+ default:
+ printf(USAGE);
+ error = ERROR_INVALID_PARAMETER;
+
+ }
+ }
+ }
+ return error;
+}
+
+PCHAR
+GetCoinstallerVersion(
+ VOID
+ )
+{
+ if (FAILED( StringCchPrintf(G_coInstallerVersion,
+ MAX_VERSION_SIZE,
+ "%02d%03d", // for example, "01009"
+ KMDF_VERSION_MAJOR,
+ KMDF_VERSION_MINOR)))
+ {
+ printf("StringCchCopy failed with error \n");
+ }
+
+ return (PCHAR)&G_coInstallerVersion;
+}
+
+VOID __cdecl
+main(
+ _In_ ULONG argc,
+ _In_reads_(argc) PCHAR argv[]
+ )
+{
+ HANDLE hDevice;
+ DWORD errNum = 0;
+ CHAR driverLocation [MAX_PATH];
+ BOOL ok;
+ HMODULE library = NULL;
+ LONG error;
+ PCHAR coinstallerVersion;
+
+ //
+ // Parse command line args
+ // -l -- loop option
+ //
+ if ( argc > 1 ) {// give usage if invoked with no parms
+ error = Parse(argc, argv);
+ if (error != ERROR_SUCCESS) {
+ return;
+ }
+ }
+
+ if (!G_versionSpecified ) {
+ coinstallerVersion = GetCoinstallerVersion();
+
+ //
+ // if no version is specified or an invalid one is specified use default version
+ //
+ printf("No version specified. Using default version:%s\n",
+ coinstallerVersion);
+
+ } else {
+ coinstallerVersion = (PCHAR)&G_coInstallerVersion;
+ }
+
+ //
+ // open the device
+ //
+ hDevice = CreateFile(DEVICE_NAME,
+ GENERIC_READ | GENERIC_WRITE,
+ 0,
+ NULL,
+ CREATE_ALWAYS,
+ FILE_ATTRIBUTE_NORMAL,
+ NULL);
+
+ if(hDevice == INVALID_HANDLE_VALUE) {
+
+ errNum = GetLastError();
+
+ if (!(errNum == ERROR_FILE_NOT_FOUND ||
+ errNum == ERROR_PATH_NOT_FOUND)) {
+
+ printf("CreateFile failed! ERROR_FILE_NOT_FOUND = %d\n",
+ errNum);
+ return ;
+ }
+
+ //
+ // Load WdfCoInstaller.dll.
+ //
+ library = LoadWdfCoInstaller();
+
+ if (library == NULL) {
+ printf("The WdfCoInstaller%s.dll library needs to be "
+ "in same directory as nonpnpapp.exe\n", coinstallerVersion);
+ return;
+ }
+
+ //
+ // The driver is not started yet so let us the install the driver.
+ // First setup full path to driver name.
+ //
+ ok = SetupDriverName( driverLocation, MAX_PATH );
+
+ if (!ok) {
+ return ;
+ }
+
+ ok = ManageDriver( DRIVER_NAME,
+ driverLocation,
+ DRIVER_FUNC_INSTALL );
+
+ if (!ok) {
+
+ printf("Unable to install driver. \n");
+
+ //
+ // Error - remove driver.
+ //
+ ManageDriver( DRIVER_NAME,
+ driverLocation,
+ DRIVER_FUNC_REMOVE );
+ return;
+ }
+
+ hDevice = CreateFile( DEVICE_NAME,
+ GENERIC_READ | GENERIC_WRITE,
+ 0,
+ NULL,
+ CREATE_ALWAYS,
+ FILE_ATTRIBUTE_NORMAL,
+ NULL );
+
+ if (hDevice == INVALID_HANDLE_VALUE) {
+ printf ( "Error: CreatFile Failed : %d\n", GetLastError());
+ return;
+ }
+ }
+
+ DoIoctls(hDevice);
+
+ do {
+
+ if(!DoFileReadWrite(hDevice)) {
+ break;
+ }
+
+ if(!G_fLoop) {
+ break;
+ }
+ Sleep(1000); // sleep for 1 sec.
+
+ } WHILE (TRUE);
+
+ //
+ // Close the handle to the device before unloading the driver.
+ //
+ CloseHandle ( hDevice );
+
+ //
+ // Unload the driver. Ignore any errors.
+ //
+ ManageDriver( DRIVER_NAME,
+ driverLocation,
+ DRIVER_FUNC_REMOVE );
+
+ //
+ // Unload WdfCoInstaller.dll
+ //
+ if ( library ) {
+ UnloadWdfCoInstaller( library );
+ }
+ return;
+}
+
+
+VOID
+DoIoctls(
+ HANDLE hDevice
+ )
+{
+ char OutputBuffer[100];
+ char InputBuffer[200];
+ BOOL bRc;
+ ULONG bytesReturned;
+
+ //
+ // Printing Input & Output buffer pointers and size
+ //
+
+ printf("InputBuffer Pointer = %p, BufLength = %d\n", InputBuffer,
+ sizeof(InputBuffer));
+ printf("OutputBuffer Pointer = %p BufLength = %d\n", OutputBuffer,
+ sizeof(OutputBuffer));
+ //
+ // Performing METHOD_BUFFERED
+ //
+
+ if(FAILED(StringCchCopy(InputBuffer, sizeof(InputBuffer),
+ "this String is from User Application; using METHOD_BUFFERED"))){
+ return;
+ }
+
+ printf("\nCalling DeviceIoControl METHOD_BUFFERED:\n");
+
+ memset(OutputBuffer, 0, sizeof(OutputBuffer));
+
+ bRc = DeviceIoControl ( hDevice,
+ (DWORD) IOCTL_NONPNP_METHOD_BUFFERED,
+ InputBuffer,
+ (DWORD) strlen( InputBuffer )+1,
+ OutputBuffer,
+ sizeof( OutputBuffer),
+ &bytesReturned,
+ NULL
+ );
+
+ if ( !bRc )
+ {
+ printf ( "Error in DeviceIoControl : %d", GetLastError());
+ return;
+
+ }
+ printf(" OutBuffer (%d): %s\n", bytesReturned, OutputBuffer);
+
+
+ //
+ // Performing METHOD_NIETHER
+ //
+
+ printf("\nCalling DeviceIoControl METHOD_NEITHER\n");
+
+ if(FAILED(StringCchCopy(InputBuffer, sizeof(InputBuffer),
+ "this String is from User Application; using METHOD_NEITHER"))) {
+ return;
+ }
+
+ memset(OutputBuffer, 0, sizeof(OutputBuffer));
+
+ bRc = DeviceIoControl ( hDevice,
+ (DWORD) IOCTL_NONPNP_METHOD_NEITHER,
+ InputBuffer,
+ (DWORD) strlen( InputBuffer )+1,
+ OutputBuffer,
+ sizeof( OutputBuffer),
+ &bytesReturned,
+ NULL
+ );
+
+ if ( !bRc )
+ {
+ printf ( "Error in DeviceIoControl : %d\n", GetLastError());
+ return;
+
+ }
+
+ printf(" OutBuffer (%d): %s\n", bytesReturned, OutputBuffer);
+
+ //
+ // Performing METHOD_IN_DIRECT
+ //
+
+ printf("\nCalling DeviceIoControl METHOD_IN_DIRECT\n");
+
+ if(FAILED(StringCchCopy(InputBuffer, sizeof(InputBuffer),
+ "this String is from User Application; using METHOD_IN_DIRECT"))) {
+ return;
+ }
+
+ if(FAILED(StringCchCopy(OutputBuffer, sizeof(OutputBuffer),
+ "This String is from User Application in OutBuffer; using METHOD_IN_DIRECT"))) {
+ return;
+ }
+
+ bRc = DeviceIoControl ( hDevice,
+ (DWORD) IOCTL_NONPNP_METHOD_IN_DIRECT,
+ InputBuffer,
+ (DWORD) strlen( InputBuffer )+1,
+ OutputBuffer,
+ sizeof( OutputBuffer),
+ &bytesReturned,
+ NULL
+ );
+
+ if ( !bRc )
+ {
+ printf ( "Error in DeviceIoControl : : %d", GetLastError());
+ return;
+ }
+
+ printf(" Number of bytes transfered from OutBuffer: %d\n",
+ bytesReturned);
+
+ //
+ // Performing METHOD_OUT_DIRECT
+ //
+
+ printf("\nCalling DeviceIoControl METHOD_OUT_DIRECT\n");
+ if(FAILED(StringCchCopy(InputBuffer, sizeof(InputBuffer),
+ "this String is from User Application; using METHOD_OUT_DIRECT"))){
+ return;
+ }
+
+ memset(OutputBuffer, 0, sizeof(OutputBuffer));
+
+ bRc = DeviceIoControl ( hDevice,
+ (DWORD) IOCTL_NONPNP_METHOD_OUT_DIRECT,
+ InputBuffer,
+ (DWORD) strlen( InputBuffer )+1,
+ OutputBuffer,
+ sizeof( OutputBuffer),
+ &bytesReturned,
+ NULL
+ );
+
+ if ( !bRc )
+ {
+ printf ( "Error in DeviceIoControl : : %d", GetLastError());
+ return;
+ }
+
+ printf(" OutBuffer (%d): %s\n", bytesReturned, OutputBuffer);
+
+ return;
+
+}
+
+
+BOOLEAN
+DoFileReadWrite(
+ HANDLE HDevice
+ )
+{
+ ULONG bufLength, index;
+ PUCHAR readBuf = NULL;
+ PUCHAR writeBuf = NULL;
+ BOOLEAN ret;
+ ULONG bytesWritten, bytesRead;
+
+ //
+ // Seed the random-number generator with current time so that
+ // the numbers will be different every time we run.
+ //
+ srand( (unsigned)time( NULL ) );
+
+ //
+ // rand function returns a pseudorandom integer in the range 0 to RAND_MAX
+ // (0x7fff)
+ //
+ bufLength = rand();
+ //
+ // Try until the bufLength is not zero.
+ //
+ while(bufLength == 0) {
+ bufLength = rand();
+ }
+
+ //
+ // Allocate a buffer of that size to use for write operation.
+ //
+ writeBuf = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, bufLength);
+ if(!writeBuf) {
+ ret = FALSE;
+ goto End;
+ }
+ //
+ // Fill the buffer with randon number less than UCHAR_MAX.
+ //
+ index = bufLength;
+ while(index){
+ writeBuf[index-1] = (UCHAR) rand() % UCHAR_MAX;
+ index--;
+ }
+
+ printf("Write %d bytes to file\n", bufLength);
+
+ //
+ // Tell the driver to write the buffer content to the file from the
+ // begining of the file.
+ //
+
+ if (!WriteFile(HDevice,
+ writeBuf,
+ bufLength,
+ &bytesWritten,
+ NULL)) {
+
+ printf("ReadFile failed with error 0x%x\n", GetLastError());
+
+ ret = FALSE;
+ goto End;
+
+ }
+
+ //
+ // Allocate another buffer of same size.
+ //
+ readBuf = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, bufLength);
+ if(!readBuf) {
+
+ ret = FALSE;
+ goto End;
+ }
+
+ printf("Read %d bytes from the same file\n", bufLength);
+
+ //
+ // Tell the driver to read the file from the begining.
+ //
+ if (!ReadFile(HDevice,
+ readBuf,
+ bufLength,
+ &bytesRead,
+ NULL)) {
+
+ printf("Error: ReadFile failed with error 0x%x\n", GetLastError());
+
+ ret = FALSE;
+ goto End;
+
+ }
+
+ //
+ // Now compare the readBuf and writeBuf content. They should be the same.
+ //
+
+ if(bytesRead != bytesWritten) {
+ printf("bytesRead(%d) != bytesWritten(%d)\n", bytesRead, bytesWritten);
+ ret = FALSE;
+ goto End;
+ }
+
+ if(memcmp(readBuf, writeBuf, bufLength) != 0){
+ printf("Error: ReadBuf and WriteBuf contents are not the same\n");
+ ret = FALSE;
+ goto End;
+ }
+
+ ret = TRUE;
+
+End:
+
+ if(readBuf){
+ HeapFree (GetProcessHeap(), 0, readBuf);
+ }
+
+ if(writeBuf){
+ HeapFree (GetProcessHeap(), 0, writeBuf);
+ }
+
+ return ret;
+
+
+}
+
+
diff --git a/general/ioctl/kmdf/ioctl.sln b/general/ioctl/kmdf/ioctl.sln
new file mode 100644
index 00000000..aab61213
--- /dev/null
+++ b/general/ioctl/kmdf/ioctl.sln
@@ -0,0 +1,46 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio 2013
+VisualStudioVersion = 12.0
+MinimumVisualStudioVersion = 12.0
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Exe", "Exe", "{B028EBDA-6423-4F60-AA5E-FA6D82D7724A}"
+EndProject
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Sys", "Sys", "{4DA95BFC-3253-4E4A-92C3-7C8BAE993A05}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "nonpnpapp", "exe\nonpnpapp.vcxproj", "{75AE3580-0818-45CF-B6F0-FBA6FA7BE8EB}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "nonpnp", "sys\nonpnp.vcxproj", "{B622D542-4942-46A1-B976-F530446DD6A5}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Win32 = Debug|Win32
+ Release|Win32 = Release|Win32
+ Debug|x64 = Debug|x64
+ Release|x64 = Release|x64
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {75AE3580-0818-45CF-B6F0-FBA6FA7BE8EB}.Debug|Win32.ActiveCfg = Debug|Win32
+ {75AE3580-0818-45CF-B6F0-FBA6FA7BE8EB}.Debug|Win32.Build.0 = Debug|Win32
+ {75AE3580-0818-45CF-B6F0-FBA6FA7BE8EB}.Release|Win32.ActiveCfg = Release|Win32
+ {75AE3580-0818-45CF-B6F0-FBA6FA7BE8EB}.Release|Win32.Build.0 = Release|Win32
+ {75AE3580-0818-45CF-B6F0-FBA6FA7BE8EB}.Debug|x64.ActiveCfg = Debug|x64
+ {75AE3580-0818-45CF-B6F0-FBA6FA7BE8EB}.Debug|x64.Build.0 = Debug|x64
+ {75AE3580-0818-45CF-B6F0-FBA6FA7BE8EB}.Release|x64.ActiveCfg = Release|x64
+ {75AE3580-0818-45CF-B6F0-FBA6FA7BE8EB}.Release|x64.Build.0 = Release|x64
+ {B622D542-4942-46A1-B976-F530446DD6A5}.Debug|Win32.ActiveCfg = Debug|Win32
+ {B622D542-4942-46A1-B976-F530446DD6A5}.Debug|Win32.Build.0 = Debug|Win32
+ {B622D542-4942-46A1-B976-F530446DD6A5}.Release|Win32.ActiveCfg = Release|Win32
+ {B622D542-4942-46A1-B976-F530446DD6A5}.Release|Win32.Build.0 = Release|Win32
+ {B622D542-4942-46A1-B976-F530446DD6A5}.Debug|x64.ActiveCfg = Debug|x64
+ {B622D542-4942-46A1-B976-F530446DD6A5}.Debug|x64.Build.0 = Debug|x64
+ {B622D542-4942-46A1-B976-F530446DD6A5}.Release|x64.ActiveCfg = Release|x64
+ {B622D542-4942-46A1-B976-F530446DD6A5}.Release|x64.Build.0 = Release|x64
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+ GlobalSection(NestedProjects) = preSolution
+ {75AE3580-0818-45CF-B6F0-FBA6FA7BE8EB} = {B028EBDA-6423-4F60-AA5E-FA6D82D7724A}
+ {B622D542-4942-46A1-B976-F530446DD6A5} = {4DA95BFC-3253-4E4A-92C3-7C8BAE993A05}
+ EndGlobalSection
+EndGlobal
diff --git a/general/ioctl/kmdf/sys/localwpp.ini b/general/ioctl/kmdf/sys/localwpp.ini
new file mode 100644
index 00000000..c290070a
--- /dev/null
+++ b/general/ioctl/kmdf/sys/localwpp.ini
@@ -0,0 +1,17 @@
+//
+// This defines how to log a len/buffer pair.
+// This function should be in trace.h
+//
+
+DEFINE_CPLX_TYPE(HEXDUMP, WPP_LOGHEXDUMP, xstr_t, ItemHEXDump,"s", _HEX_, 0,2);
+
+// DEFINE_CPLX_TYPE(
+// name, // i.e. HEXDUMP // %!HEXDUMP!
+// macro, // i.e. WPP_LOGHEXDUMP // Marshalling macro, defined in trace.h
+// structure, // i.e. xstr_t // Argument type (structure to be created by above macro)
+// item type, // i.e. ItemHEXDump // MOF type that TracePrt can understand
+// format specifier, // i.e. "s" // a format specifier that TracePrt can understand
+// ???? // i.e. _HEX_ // Type signature (becomes a part of function name)
+// ???? // i.e. 0 // Weight (0 is variable data length)
+// ???? // i.e. 2 // Slots used by this entry (optional, 1 default)
+// )
diff --git a/general/ioctl/kmdf/sys/nonpnp.c b/general/ioctl/kmdf/sys/nonpnp.c
new file mode 100644
index 00000000..519ae838
--- /dev/null
+++ b/general/ioctl/kmdf/sys/nonpnp.c
@@ -0,0 +1,1309 @@
+/*++
+
+Copyright (c) Microsoft Corporation. All rights reserved.
+
+ THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
+ KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
+ PURPOSE.
+
+Module Name:
+
+ nonpnp.c
+
+Abstract:
+
+ Purpose of this driver is to demonstrate how to write a legacy (NON WDM)
+ driver using framework, show how to handle 4 different ioctls -
+ METHOD_NEITHER - in particular and also show how to read & write to file
+ from KernelMode using Zw functions.
+
+ For a non-framework version of sample on how to handle IOCTLs in driver,
+ study src\general\IOCTL in the DDK.
+
+Environment:
+
+ Kernel mode only.
+
+--*/
+
+#include "nonpnp.h"
+
+//
+// The trace message header file must be included in a source file
+// before any WPP macro calls and after defining a WPP_CONTROL_GUIDS
+// macro. During the compilation, WPP scans the source files for
+// TraceEvents() calls and builds a .tmh file which stores a unique
+// data GUID for each message, the text resource string for each message,
+// and the data types of the variables passed in for each message.
+// This file is automatically generated and used during post-processing.
+//
+#include "nonpnp.tmh"
+
+
+#ifdef ALLOC_PRAGMA
+#pragma alloc_text( INIT, DriverEntry )
+#pragma alloc_text( PAGE, NonPnpDeviceAdd)
+#pragma alloc_text( PAGE, NonPnpEvtDriverContextCleanup)
+#pragma alloc_text( PAGE, NonPnpEvtDriverUnload)
+#pragma alloc_text( PAGE, NonPnpEvtDeviceIoInCallerContext)
+#pragma alloc_text( PAGE, NonPnpEvtDeviceFileCreate)
+#pragma alloc_text( PAGE, NonPnpEvtFileClose)
+#pragma alloc_text( PAGE, FileEvtIoRead)
+#pragma alloc_text( PAGE, FileEvtIoWrite)
+#pragma alloc_text( PAGE, FileEvtIoDeviceControl)
+#endif // ALLOC_PRAGMA
+
+
+NTSTATUS
+DriverEntry(
+ IN OUT PDRIVER_OBJECT DriverObject,
+ IN PUNICODE_STRING RegistryPath
+ )
+/*++
+
+Routine Description:
+ This routine is called by the Operating System to initialize the driver.
+
+ It creates the device object, fills in the dispatch entry points and
+ completes the initialization.
+
+Arguments:
+ DriverObject - a pointer to the object that represents this device
+ driver.
+
+ RegistryPath - a pointer to our Services key in the registry.
+
+Return Value:
+ STATUS_SUCCESS if initialized; an error otherwise.
+
+--*/
+{
+ NTSTATUS status;
+ WDF_DRIVER_CONFIG config;
+ WDFDRIVER hDriver;
+ PWDFDEVICE_INIT pInit = NULL;
+ WDF_OBJECT_ATTRIBUTES attributes;
+
+ KdPrint(("Driver Frameworks NONPNP Legacy Driver Example\n"));
+
+
+ WDF_DRIVER_CONFIG_INIT(
+ &config,
+ WDF_NO_EVENT_CALLBACK // This is a non-pnp driver.
+ );
+
+ //
+ // Tell the framework that this is non-pnp driver so that it doesn't
+ // set the default AddDevice routine.
+ //
+ config.DriverInitFlags |= WdfDriverInitNonPnpDriver;
+
+ //
+ // NonPnp driver must explicitly register an unload routine for
+ // the driver to be unloaded.
+ //
+ config.EvtDriverUnload = NonPnpEvtDriverUnload;
+
+ //
+ // Register a cleanup callback so that we can call WPP_CLEANUP when
+ // the framework driver object is deleted during driver unload.
+ //
+ WDF_OBJECT_ATTRIBUTES_INIT(&attributes);
+ attributes.EvtCleanupCallback = NonPnpEvtDriverContextCleanup;
+
+ //
+ // Create a framework driver object to represent our driver.
+ //
+ status = WdfDriverCreate(DriverObject,
+ RegistryPath,
+ &attributes,
+ &config,
+ &hDriver);
+ if (!NT_SUCCESS(status)) {
+ KdPrint (("NonPnp: WdfDriverCreate failed with status 0x%x\n", status));
+ return status;
+ }
+
+ //
+ // Since we are calling WPP_CLEANUP in the DriverContextCleanup
+ // callback we should initialize WPP Tracing after WDFDRIVER
+ // object is created to ensure that we cleanup WPP properly
+ // if we return failure status from DriverEntry. This
+ // eliminates the need to call WPP_CLEANUP in every path
+ // of DriverEntry.
+ //
+ WPP_INIT_TRACING( DriverObject, RegistryPath );
+
+ //
+ // On Win2K system, you will experience some delay in getting trace events
+ // due to the way the ETW is activated to accept trace messages.
+ //
+ KdPrint(("NonPnp: DriverEntry: tracing enabled\n"));
+
+ TraceEvents(TRACE_LEVEL_VERBOSE, DBG_INIT,
+ "Driver Frameworks NONPNP Legacy Driver Example");
+
+ //
+ //
+ // In order to create a control device, we first need to allocate a
+ // WDFDEVICE_INIT structure and set all properties.
+ //
+ pInit = WdfControlDeviceInitAllocate(
+ hDriver,
+ &SDDL_DEVOBJ_SYS_ALL_ADM_RWX_WORLD_RW_RES_R
+ );
+
+ if (pInit == NULL) {
+ status = STATUS_INSUFFICIENT_RESOURCES;
+ return status;
+ }
+
+ //
+ // Call NonPnpDeviceAdd to create a deviceobject to represent our
+ // software device.
+ //
+ status = NonPnpDeviceAdd(hDriver, pInit);
+
+ return status;
+}
+
+NTSTATUS
+NonPnpDeviceAdd(
+ IN WDFDRIVER Driver,
+ IN PWDFDEVICE_INIT DeviceInit
+ )
+/*++
+
+Routine Description:
+
+ Called by the DriverEntry to create a control-device. This call is
+ responsible for freeing the memory for DeviceInit.
+
+Arguments:
+
+ DriverObject - a pointer to the object that represents this device
+ driver.
+
+ DeviceInit - Pointer to a driver-allocated WDFDEVICE_INIT structure.
+
+Return Value:
+
+ STATUS_SUCCESS if initialized; an error otherwise.
+
+--*/
+{
+ NTSTATUS status;
+ WDF_OBJECT_ATTRIBUTES attributes;
+ WDF_IO_QUEUE_CONFIG ioQueueConfig;
+ WDF_FILEOBJECT_CONFIG fileConfig;
+ WDFQUEUE queue;
+ WDFDEVICE controlDevice;
+ DECLARE_CONST_UNICODE_STRING(ntDeviceName, NTDEVICE_NAME_STRING) ;
+ DECLARE_CONST_UNICODE_STRING(symbolicLinkName, SYMBOLIC_NAME_STRING) ;
+
+ UNREFERENCED_PARAMETER( Driver );
+
+ PAGED_CODE();
+
+ TraceEvents(TRACE_LEVEL_VERBOSE, DBG_INIT,
+ "NonPnpDeviceAdd DeviceInit %p\n", DeviceInit);
+ //
+ // Set exclusive to TRUE so that no more than one app can talk to the
+ // control device at any time.
+ //
+ WdfDeviceInitSetExclusive(DeviceInit, TRUE);
+
+ WdfDeviceInitSetIoType(DeviceInit, WdfDeviceIoBuffered);
+
+
+ status = WdfDeviceInitAssignName(DeviceInit, &ntDeviceName);
+
+ if (!NT_SUCCESS(status)) {
+ TraceEvents(TRACE_LEVEL_ERROR, DBG_INIT, "WdfDeviceInitAssignName failed %!STATUS!", status);
+ goto End;
+ }
+
+ WdfControlDeviceInitSetShutdownNotification(DeviceInit,
+ NonPnpShutdown,
+ WdfDeviceShutdown);
+
+ //
+ // Initialize WDF_FILEOBJECT_CONFIG_INIT struct to tell the
+ // framework whether you are interested in handling Create, Close and
+ // Cleanup requests that gets generated when an application or another
+ // kernel component opens an handle to the device. If you don't register
+ // the framework default behaviour would be to complete these requests
+ // with STATUS_SUCCESS. A driver might be interested in registering these
+ // events if it wants to do security validation and also wants to maintain
+ // per handle (fileobject) context.
+ //
+
+ WDF_FILEOBJECT_CONFIG_INIT(
+ &fileConfig,
+ NonPnpEvtDeviceFileCreate,
+ NonPnpEvtFileClose,
+ WDF_NO_EVENT_CALLBACK // not interested in Cleanup
+ );
+
+ WdfDeviceInitSetFileObjectConfig(DeviceInit,
+ &fileConfig,
+ WDF_NO_OBJECT_ATTRIBUTES);
+
+ //
+ // In order to support METHOD_NEITHER Device controls, or
+ // NEITHER device I/O type, we need to register for the
+ // EvtDeviceIoInProcessContext callback so that we can handle the request
+ // in the calling threads context.
+ //
+ WdfDeviceInitSetIoInCallerContextCallback(DeviceInit,
+ NonPnpEvtDeviceIoInCallerContext);
+
+ //
+ // Specify the size of device context
+ //
+ WDF_OBJECT_ATTRIBUTES_INIT_CONTEXT_TYPE(&attributes,
+ CONTROL_DEVICE_EXTENSION);
+
+ status = WdfDeviceCreate(&DeviceInit,
+ &attributes,
+ &controlDevice);
+ if (!NT_SUCCESS(status)) {
+ TraceEvents(TRACE_LEVEL_ERROR, DBG_INIT, "WdfDeviceCreate failed %!STATUS!", status);
+ goto End;
+ }
+
+ //
+ // Create a symbolic link for the control object so that usermode can open
+ // the device.
+ //
+
+
+ status = WdfDeviceCreateSymbolicLink(controlDevice,
+ &symbolicLinkName);
+
+ if (!NT_SUCCESS(status)) {
+ //
+ // Control device will be deleted automatically by the framework.
+ //
+ TraceEvents(TRACE_LEVEL_ERROR, DBG_INIT, "WdfDeviceCreateSymbolicLink failed %!STATUS!", status);
+ goto End;
+ }
+
+ //
+ // Configure a default queue so that requests that are not
+ // configure-fowarded using WdfDeviceConfigureRequestDispatching to goto
+ // other queues get dispatched here.
+ //
+ WDF_IO_QUEUE_CONFIG_INIT_DEFAULT_QUEUE(&ioQueueConfig,
+ WdfIoQueueDispatchSequential);
+
+ ioQueueConfig.EvtIoRead = FileEvtIoRead;
+ ioQueueConfig.EvtIoWrite = FileEvtIoWrite;
+ ioQueueConfig.EvtIoDeviceControl = FileEvtIoDeviceControl;
+
+ WDF_OBJECT_ATTRIBUTES_INIT(&attributes);
+ //
+ // Since we are using Zw function set execution level to passive so that
+ // framework ensures that our Io callbacks called at only passive-level
+ // even if the request came in at DISPATCH_LEVEL from another driver.
+ //
+ //attributes.ExecutionLevel = WdfExecutionLevelPassive;
+
+ //
+ // By default, Static Driver Verifier (SDV) displays a warning if it
+ // doesn't find the EvtIoStop callback on a power-managed queue.
+ // The 'assume' below causes SDV to suppress this warning. If the driver
+ // has not explicitly set PowerManaged to WdfFalse, the framework creates
+ // power-managed queues when the device is not a filter driver. Normally
+ // the EvtIoStop is required for power-managed queues, but for this driver
+ // it is not needed b/c the driver doesn't hold on to the requests or
+ // forward them to other drivers. This driver completes the requests
+ // directly in the queue's handlers. If the EvtIoStop callback is not
+ // implemented, the framework waits for all driver-owned requests to be
+ // done before moving in the Dx/sleep states or before removing the
+ // device, which is the correct behavior for this type of driver.
+ // If the requests were taking an indeterminate amount of time to complete,
+ // or if the driver forwarded the requests to a lower driver/another stack,
+ // the queue should have an EvtIoStop/EvtIoResume.
+ //
+ __analysis_assume(ioQueueConfig.EvtIoStop != 0);
+ status = WdfIoQueueCreate(controlDevice,
+ &ioQueueConfig,
+ &attributes,
+ &queue // pointer to default queue
+ );
+ __analysis_assume(ioQueueConfig.EvtIoStop == 0);
+ if (!NT_SUCCESS(status)) {
+ TraceEvents(TRACE_LEVEL_ERROR, DBG_INIT, "WdfIoQueueCreate failed %!STATUS!", status);
+ goto End;
+ }
+
+ //
+ // Control devices must notify WDF when they are done initializing. I/O is
+ // rejected until this call is made.
+ //
+ WdfControlFinishInitializing(controlDevice);
+
+End:
+ //
+ // If the device is created successfully, framework would clear the
+ // DeviceInit value. Otherwise device create must have failed so we
+ // should free the memory ourself.
+ //
+ if (DeviceInit != NULL) {
+ WdfDeviceInitFree(DeviceInit);
+ }
+
+ return status;
+
+}
+
+VOID
+NonPnpEvtDriverContextCleanup(
+ IN WDFOBJECT Driver
+ )
+/*++
+Routine Description:
+
+ Called when the driver object is deleted during driver unload.
+ You can free all the resources created in DriverEntry that are
+ not automatically freed by the framework.
+
+Arguments:
+
+ Driver - Handle to a framework driver object created in DriverEntry
+
+Return Value:
+
+ NTSTATUS
+
+--*/
+{
+ TraceEvents(TRACE_LEVEL_VERBOSE, DBG_INIT,
+ "Entered NonPnpEvtDriverContextCleanup\n");
+
+ PAGED_CODE();
+
+ //
+ // No need to free the controldevice object explicitly because it will
+ // be deleted when the Driver object is deleted due to the default parent
+ // child relationship between Driver and ControlDevice.
+ //
+ WPP_CLEANUP( WdfDriverWdmGetDriverObject( (WDFDRIVER)Driver ) );
+
+}
+
+
+
+VOID
+NonPnpEvtDeviceFileCreate (
+ IN WDFDEVICE Device,
+ IN WDFREQUEST Request,
+ IN WDFFILEOBJECT FileObject
+ )
+/*++
+
+Routine Description:
+
+ The framework calls a driver's EvtDeviceFileCreate callback
+ when it receives an IRP_MJ_CREATE request.
+ The system sends this request when a user application opens the
+ device to perform an I/O operation, such as reading or writing a file.
+ This callback is called synchronously, in the context of the thread
+ that created the IRP_MJ_CREATE request.
+
+Arguments:
+
+ Device - Handle to a framework device object.
+ FileObject - Pointer to fileobject that represents the open handle.
+ CreateParams - Parameters of IO_STACK_LOCATION for create
+
+Return Value:
+
+ NT status code
+
+--*/
+{
+ PUNICODE_STRING fileName;
+ UNICODE_STRING absFileName, directory;
+ OBJECT_ATTRIBUTES fileAttributes;
+ IO_STATUS_BLOCK ioStatus;
+ PCONTROL_DEVICE_EXTENSION devExt;
+ NTSTATUS status;
+ USHORT length = 0;
+
+
+ UNREFERENCED_PARAMETER( FileObject );
+
+ PAGED_CODE ();
+
+ devExt = ControlGetData(Device);
+
+ //
+ // Assume the directory is a temp directory under %windir%
+ //
+ RtlInitUnicodeString(&directory, L"\\SystemRoot\\temp");
+
+ //
+ // Parsed filename has "\" in the begining. The object manager strips
+ // of all "\", except one, after the device name.
+ //
+ fileName = WdfFileObjectGetFileName(FileObject);
+
+ TraceEvents(TRACE_LEVEL_VERBOSE, DBG_INIT, "NonPnpEvtDeviceFileCreate %wZ%wZ",
+ &directory, fileName);
+
+ //
+ // Find the total length of the directory + filename
+ //
+ length = directory.Length + fileName->Length;
+
+ absFileName.Buffer = ExAllocatePoolWithTag(PagedPool, length, POOL_TAG);
+ if(absFileName.Buffer == NULL) {
+ status = STATUS_INSUFFICIENT_RESOURCES;
+ TraceEvents(TRACE_LEVEL_ERROR, DBG_INIT, "ExAllocatePoolWithTag failed");
+ goto End;
+ }
+ absFileName.Length = 0;
+ absFileName.MaximumLength = length;
+
+ status = RtlAppendUnicodeStringToString(&absFileName, &directory);
+ if (!NT_SUCCESS(status)) {
+ TraceEvents(TRACE_LEVEL_ERROR, DBG_INIT,
+ "RtlAppendUnicodeStringToString failed with status %!STATUS!",
+ status);
+ goto End;
+ }
+
+ status = RtlAppendUnicodeStringToString(&absFileName, fileName);
+ if (!NT_SUCCESS(status)) {
+ TraceEvents(TRACE_LEVEL_ERROR, DBG_INIT,
+ "RtlAppendUnicodeStringToString failed with status %!STATUS!",
+ status);
+ goto End;
+ }
+
+ TraceEvents(TRACE_LEVEL_VERBOSE, DBG_INIT, "Absolute Filename %wZ", &absFileName);
+
+ InitializeObjectAttributes( &fileAttributes,
+ &absFileName,
+ OBJ_CASE_INSENSITIVE | OBJ_KERNEL_HANDLE,
+ NULL, // RootDirectory
+ NULL // SecurityDescriptor
+ );
+
+ status = ZwCreateFile (
+ &devExt->FileHandle,
+ SYNCHRONIZE | GENERIC_WRITE | GENERIC_READ,
+ &fileAttributes,
+ &ioStatus,
+ NULL,// alloc size = none
+ FILE_ATTRIBUTE_NORMAL,
+ FILE_SHARE_READ,
+ FILE_OPEN_IF,
+ FILE_SYNCHRONOUS_IO_NONALERT |FILE_NON_DIRECTORY_FILE,
+ NULL,// eabuffer
+ 0// ealength
+ );
+
+ if (!NT_SUCCESS(status)) {
+
+ TraceEvents(TRACE_LEVEL_ERROR, DBG_INIT,
+ "ZwCreateFile failed with status %!STATUS!", status);
+ devExt->FileHandle = NULL;
+ }
+
+End:
+ if(absFileName.Buffer != NULL) {
+ ExFreePool(absFileName.Buffer);
+ }
+
+ WdfRequestComplete(Request, status);
+
+ return;
+}
+
+
+VOID
+NonPnpEvtFileClose (
+ IN WDFFILEOBJECT FileObject
+ )
+
+/*++
+
+Routine Description:
+
+ EvtFileClose is called when all the handles represented by the FileObject
+ is closed and all the references to FileObject is removed. This callback
+ may get called in an arbitrary thread context instead of the thread that
+ called CloseHandle. If you want to delete any per FileObject context that
+ must be done in the context of the user thread that made the Create call,
+ you should do that in the EvtDeviceCleanp callback.
+
+Arguments:
+
+ FileObject - Pointer to fileobject that represents the open handle.
+
+Return Value:
+
+ VOID
+
+--*/
+{
+ PCONTROL_DEVICE_EXTENSION devExt;
+
+ PAGED_CODE ();
+
+
+ TraceEvents(TRACE_LEVEL_VERBOSE, DBG_INIT, "NonPnpEvtFileClose\n");
+
+ devExt = ControlGetData(WdfFileObjectGetDevice(FileObject));
+
+ if(devExt->FileHandle) {
+ TraceEvents(TRACE_LEVEL_VERBOSE, DBG_INIT,
+ "Closing File Handle %p", devExt->FileHandle);
+ ZwClose(devExt->FileHandle);
+ }
+
+ return;
+}
+
+
+VOID
+FileEvtIoRead(
+ IN WDFQUEUE Queue,
+ IN WDFREQUEST Request,
+ IN size_t Length
+ )
+/*++
+
+Routine Description:
+
+ This event is called when the framework receives IRP_MJ_READ requests.
+ We will just read the file.
+
+Arguments:
+
+ Queue - Handle to the framework queue object that is associated with the
+ I/O request.
+ Request - Handle to a framework request object.
+
+ Length - number of bytes to be read.
+ Queue is by default configured to fail zero length read & write requests.
+
+Return Value:
+
+ None.
+
+--*/
+{
+ NTSTATUS status = STATUS_SUCCESS;
+ PVOID outBuf;
+ IO_STATUS_BLOCK ioStatus;
+ PCONTROL_DEVICE_EXTENSION devExt;
+ FILE_POSITION_INFORMATION position;
+ ULONG_PTR bytesRead = 0;
+ size_t bufLength;
+
+ TraceEvents(TRACE_LEVEL_VERBOSE, DBG_RW, "FileEvtIoRead: Request: 0x%p, Queue: 0x%p\n",
+ Request, Queue);
+
+ PAGED_CODE ();
+
+ //
+ // Get the request buffer. Since the device is set to do buffered
+ // I/O, this function will retrieve Irp->AssociatedIrp.SystemBuffer.
+ //
+ status = WdfRequestRetrieveOutputBuffer(Request, 0, &outBuf, &bufLength);
+ if(!NT_SUCCESS(status)) {
+ WdfRequestComplete(Request, status);
+ return;
+
+ }
+
+ devExt = ControlGetData(WdfIoQueueGetDevice(Queue));
+
+ if(devExt->FileHandle) {
+
+ //
+ // Set the file position to the beginning of the file.
+ //
+ position.CurrentByteOffset.QuadPart = 0;
+ status = ZwSetInformationFile(devExt->FileHandle,
+ &ioStatus,
+ &position,
+ sizeof(FILE_POSITION_INFORMATION),
+ FilePositionInformation);
+ if (NT_SUCCESS(status)) {
+
+ status = ZwReadFile (devExt->FileHandle,
+ NULL,// Event,
+ NULL,// PIO_APC_ROUTINE ApcRoutine
+ NULL,// PVOID ApcContext
+ &ioStatus,
+ outBuf,
+ (ULONG)Length,
+ 0, // ByteOffset
+ NULL // Key
+ );
+
+ if (!NT_SUCCESS(status)) {
+
+ TraceEvents(TRACE_LEVEL_ERROR, DBG_RW,
+ "ZwReadFile failed with status 0x%x",
+ status);
+ }
+
+ status = ioStatus.Status;
+ bytesRead = ioStatus.Information;
+ }
+ }
+
+ WdfRequestCompleteWithInformation(Request, status, bytesRead);
+
+}
+
+
+
+VOID
+FileEvtIoWrite(
+ IN WDFQUEUE Queue,
+ IN WDFREQUEST Request,
+ IN size_t Length
+ )
+/*++
+
+Routine Description:
+
+ This event is called when the framework receives IRP_MJ_WRITE requests.
+
+Arguments:
+
+ Queue - Handle to the framework queue object that is associated with the
+ I/O request.
+ Request - Handle to a framework request object.
+
+ Length - number of bytes to be written.
+ Queue is by default configured to fail zero length read & write requests.
+
+
+Return Value:
+
+ None
+--*/
+{
+ NTSTATUS status = STATUS_SUCCESS;
+ PVOID inBuf;
+ IO_STATUS_BLOCK ioStatus;
+ PCONTROL_DEVICE_EXTENSION devExt;
+ FILE_POSITION_INFORMATION position;
+ ULONG_PTR bytesWritten = 0;
+ size_t bufLength;
+
+
+ TraceEvents(TRACE_LEVEL_VERBOSE, DBG_RW, "FileEvtIoWrite: Request: 0x%p, Queue: 0x%p\n",
+ Request, Queue);
+ PAGED_CODE ();
+
+ //
+ // Get the request buffer. Since the device is set to do buffered
+ // I/O, this function will retrieve Irp->AssociatedIrp.SystemBuffer.
+ //
+ status = WdfRequestRetrieveInputBuffer(Request, 0, &inBuf, &bufLength);
+ if(!NT_SUCCESS(status)) {
+ WdfRequestComplete(Request, status);
+ return;
+
+ }
+
+ devExt = ControlGetData(WdfIoQueueGetDevice(Queue));
+
+ if(devExt->FileHandle) {
+
+ //
+ // Set the file position to the beginning of the file.
+ //
+ position.CurrentByteOffset.QuadPart = 0;
+
+ status = ZwSetInformationFile(devExt->FileHandle,
+ &ioStatus,
+ &position,
+ sizeof(FILE_POSITION_INFORMATION),
+ FilePositionInformation);
+ if (NT_SUCCESS(status))
+ {
+
+ status = ZwWriteFile(devExt->FileHandle,
+ NULL,// Event,
+ NULL,// PIO_APC_ROUTINE ApcRoutine
+ NULL,// PVOID ApcContext
+ &ioStatus,
+ inBuf,
+ (ULONG)Length,
+ 0, // ByteOffset
+ NULL // Key
+ );
+ if (!NT_SUCCESS(status))
+ {
+ TraceEvents(TRACE_LEVEL_ERROR, DBG_RW,
+ "ZwWriteFile failed with status 0x%x",
+ status);
+ }
+
+ status = ioStatus.Status;
+ bytesWritten = ioStatus.Information;
+ }
+ }
+
+ WdfRequestCompleteWithInformation(Request, status, bytesWritten);
+
+}
+
+VOID
+FileEvtIoDeviceControl(
+ IN WDFQUEUE Queue,
+ IN WDFREQUEST Request,
+ IN size_t OutputBufferLength,
+ IN size_t InputBufferLength,
+ IN ULONG IoControlCode
+ )
+/*++
+Routine Description:
+
+ This event is called when the framework receives IRP_MJ_DEVICE_CONTROL
+ requests from the system.
+
+Arguments:
+
+ Queue - Handle to the framework queue object that is associated
+ with the I/O request.
+ Request - Handle to a framework request object.
+
+ OutputBufferLength - length of the request's output buffer,
+ if an output buffer is available.
+ InputBufferLength - length of the request's input buffer,
+ if an input buffer is available.
+
+ IoControlCode - the driver-defined or system-defined I/O control code
+ (IOCTL) that is associated with the request.
+
+Return Value:
+
+ VOID
+
+--*/
+{
+ NTSTATUS status = STATUS_SUCCESS;// Assume success
+ PCHAR inBuf = NULL, outBuf = NULL; // pointer to Input and output buffer
+ PCHAR data = "this String is from Device Driver !!!";
+ ULONG datalen = (ULONG) strlen(data)+1;//Length of data including null
+ PCHAR buffer = NULL;
+ PREQUEST_CONTEXT reqContext = NULL;
+ size_t bufSize;
+
+ UNREFERENCED_PARAMETER( Queue );
+
+ PAGED_CODE();
+
+ if(!OutputBufferLength || !InputBufferLength)
+ {
+ WdfRequestComplete(Request, STATUS_INVALID_PARAMETER);
+ return;
+ }
+
+ //
+ // Determine which I/O control code was specified.
+ //
+
+ switch (IoControlCode)
+ {
+ case IOCTL_NONPNP_METHOD_BUFFERED:
+
+
+ TraceEvents(TRACE_LEVEL_VERBOSE, DBG_IOCTL, "Called IOCTL_NONPNP_METHOD_BUFFERED\n");
+
+ //
+ // For bufffered ioctls WdfRequestRetrieveInputBuffer &
+ // WdfRequestRetrieveOutputBuffer return the same buffer
+ // pointer (Irp->AssociatedIrp.SystemBuffer), so read the
+ // content of the buffer before writing to it.
+ //
+ status = WdfRequestRetrieveInputBuffer(Request, 0, &inBuf, &bufSize);
+ if(!NT_SUCCESS(status)) {
+ status = STATUS_INSUFFICIENT_RESOURCES;
+ break;
+ }
+
+ ASSERT(bufSize == InputBufferLength);
+
+ //
+ // Read the input buffer content.
+ // We are using the following function to print characters instead
+ // TraceEvents with %s format because the string we get may or
+ // may not be null terminated. The buffer may contain non-printable
+ // characters also.
+ //
+ Hexdump((TRACE_LEVEL_VERBOSE, DBG_IOCTL, "Data from User : %!HEXDUMP!\n",
+ log_xstr(inBuf, (USHORT)InputBufferLength)));
+ PrintChars(inBuf, InputBufferLength );
+
+
+ status = WdfRequestRetrieveOutputBuffer(Request, 0, &outBuf, &bufSize);
+ if(!NT_SUCCESS(status)) {
+ status = STATUS_INSUFFICIENT_RESOURCES;
+ break;
+ }
+
+ ASSERT(bufSize == OutputBufferLength);
+
+ //
+ // Writing to the buffer over-writes the input buffer content
+ //
+
+ RtlCopyMemory(outBuf, data, OutputBufferLength);
+
+ Hexdump((TRACE_LEVEL_VERBOSE, DBG_IOCTL, "Data to User : %!HEXDUMP!\n",
+ log_xstr(outBuf, (USHORT)datalen)));
+ PrintChars(outBuf, datalen );
+
+ //
+ // Assign the length of the data copied to IoStatus.Information
+ // of the request and complete the request.
+ //
+ WdfRequestSetInformation(Request,
+ OutputBufferLength < datalen? OutputBufferLength:datalen);
+
+ //
+ // When the request is completed the content of the SystemBuffer
+ // is copied to the User output buffer and the SystemBuffer is
+ // is freed.
+ //
+
+ break;
+
+
+ case IOCTL_NONPNP_METHOD_IN_DIRECT:
+
+
+ TraceEvents(TRACE_LEVEL_VERBOSE, DBG_IOCTL, "Called IOCTL_NONPNP_METHOD_IN_DIRECT\n");
+
+ //
+ // Get the Input buffer. WdfRequestRetrieveInputBuffer returns
+ // Irp->AssociatedIrp.SystemBuffer.
+ //
+ status = WdfRequestRetrieveInputBuffer(Request, 0, &inBuf, &bufSize);
+ if(!NT_SUCCESS(status)) {
+ status = STATUS_INSUFFICIENT_RESOURCES;
+ break;
+ }
+
+ ASSERT(bufSize == InputBufferLength);
+
+ Hexdump((TRACE_LEVEL_VERBOSE, DBG_IOCTL, "Data from User : %!HEXDUMP!\n",
+ log_xstr(inBuf, (USHORT)InputBufferLength)));
+ PrintChars(inBuf, InputBufferLength);
+
+ //
+ // Get the output buffer. Framework calls MmGetSystemAddressForMdlSafe
+ // on the Irp->MdlAddress and returns the system address.
+ // Oddity: For this method, this buffer is intended for transfering data
+ // from the application to the driver.
+ //
+
+ status = WdfRequestRetrieveOutputBuffer(Request, 0, &buffer, &bufSize);
+ if(!NT_SUCCESS(status)) {
+ break;
+ }
+
+ ASSERT(bufSize == OutputBufferLength);
+
+ Hexdump((TRACE_LEVEL_VERBOSE, DBG_IOCTL, "Data from User in OutputBuffer: %!HEXDUMP!\n",
+ log_xstr(buffer, (USHORT)OutputBufferLength)));
+ PrintChars(buffer, OutputBufferLength);
+
+ //
+ // Return total bytes read from the output buffer.
+ // Note OutputBufferLength = MmGetMdlByteCount(Irp->MdlAddress)
+ //
+
+ WdfRequestSetInformation(Request, OutputBufferLength);
+
+ //
+ // NOTE: Changes made to the SystemBuffer are not copied
+ // to the user input buffer by the I/O manager
+ //
+
+ break;
+
+ case IOCTL_NONPNP_METHOD_OUT_DIRECT:
+
+
+ TraceEvents(TRACE_LEVEL_VERBOSE, DBG_IOCTL, "Called IOCTL_NONPNP_METHOD_OUT_DIRECT\n");
+
+ //
+ // Get the Input buffer. WdfRequestRetrieveInputBuffer returns
+ // Irp->AssociatedIrp.SystemBuffer.
+ //
+ status = WdfRequestRetrieveInputBuffer(Request, 0, &inBuf, &bufSize);
+ if(!NT_SUCCESS(status)) {
+ status = STATUS_INSUFFICIENT_RESOURCES;
+ break;
+ }
+
+ ASSERT(bufSize == InputBufferLength);
+
+ Hexdump((TRACE_LEVEL_VERBOSE, DBG_IOCTL, "Data from User : %!HEXDUMP!\n",
+ log_xstr(inBuf, (USHORT)InputBufferLength)));
+ PrintChars(inBuf, InputBufferLength);
+
+ //
+ // Get the output buffer. Framework calls MmGetSystemAddressForMdlSafe
+ // on the Irp->MdlAddress and returns the system address.
+ // For this method, this buffer is intended for transfering data from the
+ // driver to the application.
+ //
+ status = WdfRequestRetrieveOutputBuffer(Request, 0, &buffer, &bufSize);
+ if(!NT_SUCCESS(status)) {
+ break;
+ }
+
+ ASSERT(bufSize == OutputBufferLength);
+
+ //
+ // Write data to be sent to the user in this buffer
+ //
+ RtlCopyMemory(buffer, data, OutputBufferLength);
+
+ Hexdump((TRACE_LEVEL_VERBOSE, DBG_IOCTL, "Data to User : %!HEXDUMP!\n",
+ log_xstr(buffer, (USHORT)datalen)));
+ PrintChars(buffer, datalen);
+
+ WdfRequestSetInformation(Request,
+ OutputBufferLength < datalen? OutputBufferLength: datalen);
+
+ //
+ // NOTE: Changes made to the SystemBuffer are not copied
+ // to the user input buffer by the I/O manager
+ //
+
+ break;
+
+ case IOCTL_NONPNP_METHOD_NEITHER:
+ {
+ size_t inBufLength, outBufLength;
+
+ //
+ // The NonPnpEvtDeviceIoInCallerContext has already probe and locked the
+ // pages and mapped the user buffer into system address space and
+ // stored memory buffer pointers in the request context. We can get the
+ // buffer pointer by calling WdfMemoryGetBuffer.
+ //
+ TraceEvents(TRACE_LEVEL_VERBOSE, DBG_IOCTL, "Called IOCTL_NONPNP_METHOD_NEITHER\n");
+
+ reqContext = GetRequestContext(Request);
+
+ inBuf = WdfMemoryGetBuffer(reqContext->InputMemoryBuffer, &inBufLength);
+ outBuf = WdfMemoryGetBuffer(reqContext->OutputMemoryBuffer, &outBufLength);
+
+ if(inBuf == NULL || outBuf == NULL) {
+ status = STATUS_INVALID_PARAMETER;
+ }
+
+ ASSERT(inBufLength == InputBufferLength);
+ ASSERT(outBufLength == OutputBufferLength);
+
+ //
+ // Now you can safely read the data from the buffer in any arbitrary
+ // context.
+ //
+ Hexdump((TRACE_LEVEL_VERBOSE, DBG_IOCTL, "Data from User : %!HEXDUMP!\n",
+ log_xstr(inBuf, (USHORT)inBufLength)));
+ PrintChars(inBuf, inBufLength);
+
+ //
+ // Write to the buffer in any arbitrary context.
+ //
+ RtlCopyMemory(outBuf, data, outBufLength);
+
+ Hexdump((TRACE_LEVEL_VERBOSE, DBG_IOCTL, "Data to User : %!HEXDUMP!\n",
+ log_xstr(outBuf, (USHORT)datalen)));
+ PrintChars(outBuf, datalen);
+
+ //
+ // Assign the length of the data copied to IoStatus.Information
+ // of the Irp and complete the Irp.
+ //
+ WdfRequestSetInformation(Request,
+ outBufLength < datalen? outBufLength:datalen);
+
+ break;
+ }
+ default:
+
+ //
+ // The specified I/O control code is unrecognized by this driver.
+ //
+ status = STATUS_INVALID_DEVICE_REQUEST;
+ TraceEvents(TRACE_LEVEL_ERROR, DBG_IOCTL, "ERROR: unrecognized IOCTL %x\n", IoControlCode);
+ break;
+ }
+
+ TraceEvents(TRACE_LEVEL_VERBOSE, DBG_IOCTL, "Completing Request %p with status %X",
+ Request, status );
+
+ WdfRequestComplete( Request, status);
+
+}
+
+VOID
+NonPnpEvtDeviceIoInCallerContext(
+ IN WDFDEVICE Device,
+ IN WDFREQUEST Request
+ )
+/*++
+Routine Description:
+
+ This I/O in-process callback is called in the calling threads context/address
+ space before the request is subjected to any framework locking or queueing
+ scheme based on the device pnp/power or locking attributes set by the
+ driver. The process context of the calling app is guaranteed as long as
+ this driver is a top-level driver and no other filter driver is attached
+ to it.
+
+ This callback is only required if you are handling method-neither IOCTLs,
+ or want to process requests in the context of the calling process.
+
+ Driver developers should avoid defining neither IOCTLs and access user
+ buffers, and use much safer I/O tranfer methods such as buffered I/O
+ or direct I/O.
+
+Arguments:
+
+ Device - Handle to a framework device object.
+
+ Request - Handle to a framework request object. Framework calls
+ PreProcess callback only for Read/Write/ioctls and internal
+ ioctl requests.
+
+Return Value:
+
+ VOID
+
+--*/
+{
+ NTSTATUS status = STATUS_SUCCESS;
+ PREQUEST_CONTEXT reqContext = NULL;
+ WDF_OBJECT_ATTRIBUTES attributes;
+ WDF_REQUEST_PARAMETERS params;
+ size_t inBufLen, outBufLen;
+ PVOID inBuf, outBuf;
+
+ PAGED_CODE();
+
+ WDF_REQUEST_PARAMETERS_INIT(&params);
+
+ WdfRequestGetParameters(Request, &params );
+
+ TraceEvents(TRACE_LEVEL_VERBOSE, DBG_IOCTL, "Entered NonPnpEvtDeviceIoInCallerContext %p \n",
+ Request);
+
+ //
+ // Check to see whether we have recevied a METHOD_NEITHER IOCTL. if not
+ // just send the request back to framework because we aren't doing
+ // any pre-processing in the context of the calling thread process.
+ //
+ if(!(params.Type == WdfRequestTypeDeviceControl &&
+ params.Parameters.DeviceIoControl.IoControlCode ==
+ IOCTL_NONPNP_METHOD_NEITHER)) {
+ //
+ // Forward it for processing by the I/O package
+ //
+ status = WdfDeviceEnqueueRequest(Device, Request);
+ if( !NT_SUCCESS(status) ) {
+ TraceEvents(TRACE_LEVEL_ERROR, DBG_IOCTL,
+ "Error forwarding Request 0x%x", status);
+ goto End;
+ }
+
+ return;
+ }
+
+ TraceEvents(TRACE_LEVEL_VERBOSE, DBG_IOCTL, "EvtIoPreProcess: received METHOD_NEITHER ioctl \n");
+
+ //
+ // In this type of transfer, the I/O manager assigns the user input
+ // to Type3InputBuffer and the output buffer to UserBuffer of the Irp.
+ // The I/O manager doesn't copy or map the buffers to the kernel
+ // buffers.
+ //
+ status = WdfRequestRetrieveUnsafeUserInputBuffer(Request, 0, &inBuf, &inBufLen);
+ if(!NT_SUCCESS(status)) {
+ TraceEvents(TRACE_LEVEL_ERROR, DBG_IOCTL,
+ "Error WdfRequestRetrieveUnsafeUserInputBuffer failed 0x%x", status);
+ goto End;
+ }
+
+ status = WdfRequestRetrieveUnsafeUserOutputBuffer(Request, 0, &outBuf, &outBufLen);
+ if(!NT_SUCCESS(status)) {
+ TraceEvents(TRACE_LEVEL_ERROR, DBG_IOCTL,
+ "Error WdfRequestRetrieveUnsafeUserOutputBuffer failed 0x%x", status);
+ goto End;
+ }
+
+ //
+ // Allocate a context for this request so that we can store the memory
+ // objects created for input and output buffer.
+ //
+ WDF_OBJECT_ATTRIBUTES_INIT_CONTEXT_TYPE(&attributes, REQUEST_CONTEXT);
+
+ status = WdfObjectAllocateContext(Request, &attributes, &reqContext);
+ if(!NT_SUCCESS(status)) {
+ TraceEvents(TRACE_LEVEL_ERROR, DBG_IOCTL,
+ "Error WdfObjectAllocateContext failed 0x%x", status);
+ goto End;
+ }
+
+ //
+ // WdfRequestProbleAndLockForRead/Write function checks to see
+ // whether the caller in the right thread context, creates an MDL,
+ // probe and locks the pages, and map the MDL to system address
+ // space and finally creates a WDFMEMORY object representing this
+ // system buffer address. This memory object is associated with the
+ // request. So it will be freed when the request is completed. If we
+ // are accessing this memory buffer else where, we should store these
+ // pointers in the request context.
+ //
+
+ #pragma prefast(suppress:6387, "If inBuf==NULL at this point, then inBufLen==0")
+ status = WdfRequestProbeAndLockUserBufferForRead(Request,
+ inBuf,
+ inBufLen,
+ &reqContext->InputMemoryBuffer);
+
+ if(!NT_SUCCESS(status)) {
+ TraceEvents(TRACE_LEVEL_ERROR, DBG_IOCTL,
+ "Error WdfRequestProbeAndLockUserBufferForRead failed 0x%x", status);
+ goto End;
+ }
+
+ #pragma prefast(suppress:6387, "If outBuf==NULL at this point, then outBufLen==0")
+ status = WdfRequestProbeAndLockUserBufferForWrite(Request,
+ outBuf,
+ outBufLen,
+ &reqContext->OutputMemoryBuffer);
+ if(!NT_SUCCESS(status)) {
+ TraceEvents(TRACE_LEVEL_ERROR, DBG_IOCTL,
+ "Error WdfRequestProbeAndLockUserBufferForWrite failed 0x%x", status);
+ goto End;
+ }
+
+ //
+ // Finally forward it for processing by the I/O package
+ //
+ status = WdfDeviceEnqueueRequest(Device, Request);
+ if(!NT_SUCCESS(status)) {
+ TraceEvents(TRACE_LEVEL_ERROR, DBG_IOCTL,
+ "Error WdfDeviceEnqueueRequest failed 0x%x", status);
+ goto End;
+ }
+
+ return;
+
+End:
+
+ TraceEvents(TRACE_LEVEL_VERBOSE, DBG_IOCTL, "EvtIoPreProcess failed %x \n", status);
+ WdfRequestComplete(Request, status);
+ return;
+}
+
+VOID
+NonPnpShutdown(
+ WDFDEVICE Device
+ )
+/*++
+
+Routine Description:
+ Callback invoked when the machine is shutting down. If you register for
+ a last chance shutdown notification you cannot do the following:
+ o Call any pageable routines
+ o Access pageable memory
+ o Perform any file I/O operations
+
+ If you register for a normal shutdown notification, all of these are
+ available to you.
+
+ This function implementation does nothing, but if you had any outstanding
+ file handles open, this is where you would close them.
+
+Arguments:
+ Device - The device which registered the notification during init
+
+Return Value:
+ None
+
+ --*/
+
+{
+ UNREFERENCED_PARAMETER(Device);
+ return;
+}
+
+
+VOID
+NonPnpEvtDriverUnload(
+ IN WDFDRIVER Driver
+ )
+/*++
+Routine Description:
+
+ Called by the I/O subsystem just before unloading the driver.
+ You can free the resources created in the DriverEntry either
+ in this routine or in the EvtDriverContextCleanup callback.
+
+Arguments:
+
+ Driver - Handle to a framework driver object created in DriverEntry
+
+Return Value:
+
+ NTSTATUS
+
+--*/
+{
+ UNREFERENCED_PARAMETER(Driver);
+
+ PAGED_CODE();
+
+ TraceEvents(TRACE_LEVEL_VERBOSE, DBG_INIT, "Entered NonPnpDriverUnload\n");
+
+ return;
+}
+
+VOID
+PrintChars(
+ _In_reads_(CountChars) PCHAR BufferAddress,
+ _In_ size_t CountChars
+ )
+{
+ if (CountChars) {
+
+ while (CountChars--) {
+
+ if (*BufferAddress > 31
+ && *BufferAddress != 127) {
+
+ KdPrint (( "%c", *BufferAddress) );
+
+ } else {
+
+ KdPrint(( ".") );
+
+ }
+ BufferAddress++;
+ }
+ KdPrint (("\n"));
+ }
+ return;
+}
+
diff --git a/general/ioctl/kmdf/sys/nonpnp.h b/general/ioctl/kmdf/sys/nonpnp.h
new file mode 100644
index 00000000..28176038
--- /dev/null
+++ b/general/ioctl/kmdf/sys/nonpnp.h
@@ -0,0 +1,90 @@
+/*++
+
+Copyright (c) 1997 Microsoft Corporation
+
+Module Name:
+
+ nonpnp.h
+
+Abstract:
+
+ Contains function prototypes and includes other neccessary header files.
+
+Environment:
+
+ Kernel mode only.
+
+--*/
+
+#include <ntddk.h>
+#include <wdf.h>
+
+#define NTSTRSAFE_LIB
+#include <ntstrsafe.h>
+#include <wdmsec.h> // for SDDLs
+#include "public.h" // contains IOCTL definitions
+#include "Trace.h" // contains macros for WPP tracing
+
+#define NTDEVICE_NAME_STRING L"\\Device\\NONPNP"
+#define SYMBOLIC_NAME_STRING L"\\DosDevices\\NONPNP"
+#define POOL_TAG 'ELIF'
+
+typedef struct _CONTROL_DEVICE_EXTENSION {
+
+ HANDLE FileHandle; // Store your control data here
+
+} CONTROL_DEVICE_EXTENSION, *PCONTROL_DEVICE_EXTENSION;
+
+WDF_DECLARE_CONTEXT_TYPE_WITH_NAME(CONTROL_DEVICE_EXTENSION,
+ ControlGetData)
+
+//
+// Following request context is used only for the method-neither ioctl case.
+//
+typedef struct _REQUEST_CONTEXT {
+
+ WDFMEMORY InputMemoryBuffer;
+ WDFMEMORY OutputMemoryBuffer;
+
+} REQUEST_CONTEXT, *PREQUEST_CONTEXT;
+
+WDF_DECLARE_CONTEXT_TYPE_WITH_NAME(REQUEST_CONTEXT, GetRequestContext)
+
+//
+// Device driver routine declarations.
+//
+
+DRIVER_INITIALIZE DriverEntry;
+
+//
+// Don't use EVT_WDF_DRIVER_DEVICE_ADD for NonPnpDeviceAdd even though
+// the signature is same because this is not an event called by the
+// framework.
+//
+NTSTATUS
+NonPnpDeviceAdd(
+ IN WDFDRIVER Driver,
+ IN PWDFDEVICE_INIT DeviceInit
+ );
+
+EVT_WDF_DRIVER_UNLOAD NonPnpEvtDriverUnload;
+
+EVT_WDF_DEVICE_CONTEXT_CLEANUP NonPnpEvtDriverContextCleanup;
+EVT_WDF_DEVICE_SHUTDOWN_NOTIFICATION NonPnpShutdown;
+
+EVT_WDF_IO_QUEUE_IO_DEVICE_CONTROL FileEvtIoDeviceControl;
+EVT_WDF_IO_QUEUE_IO_READ FileEvtIoRead;
+EVT_WDF_IO_QUEUE_IO_WRITE FileEvtIoWrite;
+
+EVT_WDF_IO_IN_CALLER_CONTEXT NonPnpEvtDeviceIoInCallerContext;
+EVT_WDF_DEVICE_FILE_CREATE NonPnpEvtDeviceFileCreate;
+EVT_WDF_FILE_CLOSE NonPnpEvtFileClose;
+
+VOID
+PrintChars(
+ _In_reads_(CountChars) PCHAR BufferAddress,
+ _In_ size_t CountChars
+ );
+
+#pragma warning(disable:4127)
+
diff --git a/general/ioctl/kmdf/sys/nonpnp.rc b/general/ioctl/kmdf/sys/nonpnp.rc
new file mode 100644
index 00000000..28e9a0e3
--- /dev/null
+++ b/general/ioctl/kmdf/sys/nonpnp.rc
@@ -0,0 +1,10 @@
+#include <windows.h>
+
+#include <ntverp.h>
+
+#define VER_FILETYPE VFT_DRV
+#define VER_FILESUBTYPE VFT2_DRV_SYSTEM
+#define VER_FILEDESCRIPTION_STR "Sample Non-PNP Driver using WDF"
+#define VER_INTERNALNAME_STR "NONPNP.sys"
+
+#include "common.ver"
diff --git a/general/ioctl/kmdf/sys/nonpnp.vcxproj b/general/ioctl/kmdf/sys/nonpnp.vcxproj
new file mode 100644
index 00000000..615ccb8e
--- /dev/null
+++ b/general/ioctl/kmdf/sys/nonpnp.vcxproj
@@ -0,0 +1,196 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup Label="ProjectConfigurations">
+ <ProjectConfiguration Include="Debug|Win32">
+ <Configuration>Debug</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|Win32">
+ <Configuration>Release</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Debug|x64">
+ <Configuration>Debug</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|x64">
+ <Configuration>Release</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ </ItemGroup>
+ <PropertyGroup Label="Globals">
+ <ProjectGuid>{B622D542-4942-46A1-B976-F530446DD6A5}</ProjectGuid>
+ <RootNamespace>$(MSBuildProjectName)</RootNamespace>
+ <KMDF_VERSION_MAJOR>1</KMDF_VERSION_MAJOR>
+ <Configuration Condition="'$(Configuration)' == ''">Debug</Configuration>
+ <Platform Condition="'$(Platform)' == ''">Win32</Platform>
+ <SampleGuid>{AC100EE8-8981-47E5-ABCA-B8DCCFFA5682}</SampleGuid>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+ <PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <TargetVersion>Windows10</TargetVersion>
+ <UseDebugLibraries>False</UseDebugLibraries>
+ <DriverTargetPlatform>Desktop</DriverTargetPlatform>
+ <DriverType>KMDF</DriverType>
+ <PlatformToolset>WindowsKernelModeDriver10.0</PlatformToolset>
+ <ConfigurationType>Driver</ConfigurationType>
+ </PropertyGroup>
+ <PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <TargetVersion>Windows10</TargetVersion>
+ <UseDebugLibraries>True</UseDebugLibraries>
+ <DriverTargetPlatform>Desktop</DriverTargetPlatform>
+ <DriverType>KMDF</DriverType>
+ <PlatformToolset>WindowsKernelModeDriver10.0</PlatformToolset>
+ <ConfigurationType>Driver</ConfigurationType>
+ </PropertyGroup>
+ <PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <TargetVersion>Windows10</TargetVersion>
+ <UseDebugLibraries>False</UseDebugLibraries>
+ <DriverTargetPlatform>Desktop</DriverTargetPlatform>
+ <DriverType>KMDF</DriverType>
+ <PlatformToolset>WindowsKernelModeDriver10.0</PlatformToolset>
+ <ConfigurationType>Driver</ConfigurationType>
+ </PropertyGroup>
+ <PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <TargetVersion>Windows10</TargetVersion>
+ <UseDebugLibraries>True</UseDebugLibraries>
+ <DriverTargetPlatform>Desktop</DriverTargetPlatform>
+ <DriverType>KMDF</DriverType>
+ <PlatformToolset>WindowsKernelModeDriver10.0</PlatformToolset>
+ <ConfigurationType>Driver</ConfigurationType>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+ <PropertyGroup>
+ <OutDir>$(IntDir)</OutDir>
+ </PropertyGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" />
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" />
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" />
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" />
+ </ImportGroup>
+ <ItemGroup Label="WrappedTaskItems">
+ <ClCompile Include="nonpnp.c">
+ <WppEnabled>true</WppEnabled>
+ <WppKernelMode>true</WppKernelMode>
+ <WppTraceFunction>TraceEvents(LEVEL,FLAGS,MSG,...);Hexdump((LEVEL,FLAGS,MSG,...))</WppTraceFunction>
+ <WppGenerateUsingTemplateFile>{km-WdfDefault.tpl}*.tmh</WppGenerateUsingTemplateFile>
+ </ClCompile>
+ <OtherWpp Include="nonpnp.rc">
+ <WppEnabled>true</WppEnabled>
+ <WppKernelMode>true</WppKernelMode>
+ <WppTraceFunction>TraceEvents(LEVEL,FLAGS,MSG,...);Hexdump((LEVEL,FLAGS,MSG,...))</WppTraceFunction>
+ <WppGenerateUsingTemplateFile>{km-WdfDefault.tpl}*.tmh</WppGenerateUsingTemplateFile>
+ </OtherWpp>
+ </ItemGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <TargetName>nonpnp</TargetName>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <TargetName>nonpnp</TargetName>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <TargetName>nonpnp</TargetName>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <TargetName>nonpnp</TargetName>
+ </PropertyGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <Link>
+ <AdditionalDependencies>%(AdditionalDependencies);$(DDK_LIB_PATH)\ntstrsafe.lib;$(DDK_LIB_PATH)\wdmsec.lib</AdditionalDependencies>
+ </Link>
+ <ClCompile>
+ <PreprocessorDefinitions>%(PreprocessorDefinitions);_WIN2K_COMPAT_SLIST_USAGE</PreprocessorDefinitions>
+ <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);..</AdditionalIncludeDirectories>
+ <ExceptionHandling>
+ </ExceptionHandling>
+ </ClCompile>
+ <Midl>
+ <PreprocessorDefinitions>%(PreprocessorDefinitions);_WIN2K_COMPAT_SLIST_USAGE</PreprocessorDefinitions>
+ <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);..</AdditionalIncludeDirectories>
+ </Midl>
+ <ResourceCompile>
+ <PreprocessorDefinitions>%(PreprocessorDefinitions);_WIN2K_COMPAT_SLIST_USAGE</PreprocessorDefinitions>
+ <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);..</AdditionalIncludeDirectories>
+ </ResourceCompile>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <Link>
+ <AdditionalDependencies>%(AdditionalDependencies);$(DDK_LIB_PATH)\ntstrsafe.lib;$(DDK_LIB_PATH)\wdmsec.lib</AdditionalDependencies>
+ </Link>
+ <ClCompile>
+ <PreprocessorDefinitions>%(PreprocessorDefinitions);_WIN2K_COMPAT_SLIST_USAGE</PreprocessorDefinitions>
+ <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);..</AdditionalIncludeDirectories>
+ <ExceptionHandling>
+ </ExceptionHandling>
+ </ClCompile>
+ <Midl>
+ <PreprocessorDefinitions>%(PreprocessorDefinitions);_WIN2K_COMPAT_SLIST_USAGE</PreprocessorDefinitions>
+ <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);..</AdditionalIncludeDirectories>
+ </Midl>
+ <ResourceCompile>
+ <PreprocessorDefinitions>%(PreprocessorDefinitions);_WIN2K_COMPAT_SLIST_USAGE</PreprocessorDefinitions>
+ <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);..</AdditionalIncludeDirectories>
+ </ResourceCompile>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <Link>
+ <AdditionalDependencies>%(AdditionalDependencies);$(DDK_LIB_PATH)\ntstrsafe.lib;$(DDK_LIB_PATH)\wdmsec.lib</AdditionalDependencies>
+ </Link>
+ <ClCompile>
+ <PreprocessorDefinitions>%(PreprocessorDefinitions);_WIN2K_COMPAT_SLIST_USAGE</PreprocessorDefinitions>
+ <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);..</AdditionalIncludeDirectories>
+ <ExceptionHandling>
+ </ExceptionHandling>
+ </ClCompile>
+ <Midl>
+ <PreprocessorDefinitions>%(PreprocessorDefinitions);_WIN2K_COMPAT_SLIST_USAGE</PreprocessorDefinitions>
+ <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);..</AdditionalIncludeDirectories>
+ </Midl>
+ <ResourceCompile>
+ <PreprocessorDefinitions>%(PreprocessorDefinitions);_WIN2K_COMPAT_SLIST_USAGE</PreprocessorDefinitions>
+ <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);..</AdditionalIncludeDirectories>
+ </ResourceCompile>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <Link>
+ <AdditionalDependencies>%(AdditionalDependencies);$(DDK_LIB_PATH)\ntstrsafe.lib;$(DDK_LIB_PATH)\wdmsec.lib</AdditionalDependencies>
+ </Link>
+ <ClCompile>
+ <PreprocessorDefinitions>%(PreprocessorDefinitions);_WIN2K_COMPAT_SLIST_USAGE</PreprocessorDefinitions>
+ <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);..</AdditionalIncludeDirectories>
+ <ExceptionHandling>
+ </ExceptionHandling>
+ </ClCompile>
+ <Midl>
+ <PreprocessorDefinitions>%(PreprocessorDefinitions);_WIN2K_COMPAT_SLIST_USAGE</PreprocessorDefinitions>
+ <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);..</AdditionalIncludeDirectories>
+ </Midl>
+ <ResourceCompile>
+ <PreprocessorDefinitions>%(PreprocessorDefinitions);_WIN2K_COMPAT_SLIST_USAGE</PreprocessorDefinitions>
+ <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);..</AdditionalIncludeDirectories>
+ </ResourceCompile>
+ </ItemDefinitionGroup>
+ <ItemGroup>
+ <ResourceCompile Include="nonpnp.rc" />
+ </ItemGroup>
+ <ItemGroup>
+ <Inf Exclude="@(Inf)" Include="*.inf" />
+ <FilesToPackage Include="$(TargetPath)" Condition="'$(ConfigurationType)'=='Driver' or '$(ConfigurationType)'=='DynamicLibrary'" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Exclude="@(None)" Include="*.txt;*.htm;*.html" />
+ <None Exclude="@(None)" Include="*.ico;*.cur;*.bmp;*.dlg;*.rct;*.gif;*.jpg;*.jpeg;*.wav;*.jpe;*.tiff;*.tif;*.png;*.rc2" />
+ <None Exclude="@(None)" Include="*.def;*.bat;*.hpj;*.asmx" />
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Exclude="@(ClInclude)" Include="*.h;*.hpp;*.hxx;*.hm;*.inl;*.xsd" />
+ </ItemGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+</Project> \ No newline at end of file
diff --git a/general/ioctl/kmdf/sys/nonpnp.vcxproj.Filters b/general/ioctl/kmdf/sys/nonpnp.vcxproj.Filters
new file mode 100644
index 00000000..eb46c5bb
--- /dev/null
+++ b/general/ioctl/kmdf/sys/nonpnp.vcxproj.Filters
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup>
+ <Filter Include="Source Files">
+ <Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx;*</Extensions>
+ <UniqueIdentifier>{D4EF066B-A145-401A-8669-BAAC70BA8F50}</UniqueIdentifier>
+ </Filter>
+ <Filter Include="Header Files">
+ <Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
+ <UniqueIdentifier>{C68D949D-F770-4FF0-883D-729F5284E601}</UniqueIdentifier>
+ </Filter>
+ <Filter Include="Resource Files">
+ <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms;man;xml</Extensions>
+ <UniqueIdentifier>{724D8E55-13DB-47B2-AB8D-3A86DF521511}</UniqueIdentifier>
+ </Filter>
+ <Filter Include="Driver Files">
+ <Extensions>inf;inv;inx;mof;mc;</Extensions>
+ <UniqueIdentifier>{A4CB0903-2F69-4A15-8F3D-AF05EFE1323F}</UniqueIdentifier>
+ </Filter>
+ </ItemGroup>
+ <ItemGroup>
+ <ClCompile Include="nonpnp.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ </ItemGroup>
+ <ItemGroup>
+ <ResourceCompile Include="nonpnp.rc">
+ <Filter>Resource Files</Filter>
+ </ResourceCompile>
+ </ItemGroup>
+</Project> \ No newline at end of file
diff --git a/general/ioctl/kmdf/sys/public.h b/general/ioctl/kmdf/sys/public.h
new file mode 100644
index 00000000..4d53666e
--- /dev/null
+++ b/general/ioctl/kmdf/sys/public.h
@@ -0,0 +1,53 @@
+/*++
+
+Copyright (c) Microsoft Corporation. All rights reserved.
+
+ THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
+ KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
+ PURPOSE.
+
+
+Module Name:
+
+ PUBLIC.H
+
+Abstract:
+
+
+ Defines the IOCTL codes that will be used by this driver. The IOCTL code
+ contains a command identifier, plus other information about the device,
+ the type of access with which the file must have been opened,
+ and the type of buffering.
+
+Environment:
+
+ Kernel mode only.
+
+--*/
+
+//
+// Device type -- in the "User Defined" range."
+//
+#define FILEIO_TYPE 40001
+//
+// The IOCTL function codes from 0x800 to 0xFFF are for customer use.
+//
+#define IOCTL_NONPNP_METHOD_IN_DIRECT \
+ CTL_CODE( FILEIO_TYPE, 0x900, METHOD_IN_DIRECT, FILE_ANY_ACCESS )
+
+#define IOCTL_NONPNP_METHOD_OUT_DIRECT \
+ CTL_CODE( FILEIO_TYPE, 0x901, METHOD_OUT_DIRECT , FILE_ANY_ACCESS )
+
+#define IOCTL_NONPNP_METHOD_BUFFERED \
+ CTL_CODE( FILEIO_TYPE, 0x902, METHOD_BUFFERED, FILE_ANY_ACCESS )
+
+#define IOCTL_NONPNP_METHOD_NEITHER \
+ CTL_CODE( FILEIO_TYPE, 0x903, METHOD_NEITHER , FILE_ANY_ACCESS )
+
+
+#define DRIVER_FUNC_INSTALL 0x01
+#define DRIVER_FUNC_REMOVE 0x02
+
+#define DRIVER_NAME "NONPNP"
+#define DEVICE_NAME "\\\\.\\NONPNP\\nonpnpsamp.log"
diff --git a/general/ioctl/kmdf/sys/trace.h b/general/ioctl/kmdf/sys/trace.h
new file mode 100644
index 00000000..c9459ed2
--- /dev/null
+++ b/general/ioctl/kmdf/sys/trace.h
@@ -0,0 +1,68 @@
+/*++
+
+Copyright (c) Microsoft Corporation. All rights reserved.
+
+ THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
+ KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
+ PURPOSE.
+
+Module Name:
+
+ TRACE.h
+
+Abstract:
+
+ Header file for the debug tracing related function defintions and macros.
+
+Environment:
+
+ Kernel mode
+
+--*/
+
+//
+// If software tracing is defined in the sources file..
+// WPP_DEFINE_CONTROL_GUID specifies the GUID used for this driver.
+// *** REPLACE THE GUID WITH YOUR OWN UNIQUE ID ***
+// WPP_DEFINE_BIT allows setting debug bit masks to selectively print.
+// The names defined in the WPP_DEFINE_BIT call define the actual names
+// that are used to control the level of tracing for the control guid
+// specified.
+//
+// {71ae54db-0862-41bf-a24f-5330cec3c7f6}
+//
+#define WPP_CHECK_FOR_NULL_STRING //to prevent exceptions due to NULL strings
+
+#define WPP_CONTROL_GUIDS \
+ WPP_DEFINE_CONTROL_GUID( FileIoTraceGuid, \
+ (71ae54db,0862,41bf,a24f,5330cec3c7f6), \
+ WPP_DEFINE_BIT(DBG_INIT) \
+ WPP_DEFINE_BIT(DBG_RW) \
+ WPP_DEFINE_BIT(DBG_IOCTL) \
+ )
+
+#define WPP_LEVEL_FLAGS_LOGGER(lvl,flags) WPP_LEVEL_LOGGER(flags)
+#define WPP_LEVEL_FLAGS_ENABLED(lvl, flags) (WPP_LEVEL_ENABLED(flags) && WPP_CONTROL(WPP_BIT_ ## flags).Level >= lvl)
+
+#pragma warning(disable:4204) // C4204 nonstandard extension used : non-constant aggregate initializer
+
+//
+// Define the 'xstr' structure for logging buffer and length pairs
+// and the 'log_xstr' function which returns it to create one in-place.
+// this enables logging of complex data types.
+//
+typedef struct xstr { char * _buf; short _len; } xstr_t;
+__inline xstr_t log_xstr(void * p, short l) { xstr_t xs = {(char*)p,l}; return xs; }
+
+#pragma warning(default:4204)
+
+//
+// Define the macro required for a hexdump use as:
+//
+// Hexdump((FLAG,"%!HEXDUMP!\n", log_xstr(buffersize,(char *)buffer) ));
+//
+//
+#define WPP_LOGHEXDUMP(x) WPP_LOGPAIR(2, &((x)._len)) WPP_LOGPAIR((x)._len, (x)._buf)
+
+
diff --git a/general/ioctl/wdm/exe/ioctlapp.vcxproj b/general/ioctl/wdm/exe/ioctlapp.vcxproj
index a4fe1dc9..9157b73e 100644
--- a/general/ioctl/wdm/exe/ioctlapp.vcxproj
+++ b/general/ioctl/wdm/exe/ioctlapp.vcxproj
@@ -19,11 +19,11 @@
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
- <ProjectGuid>{0F1154FD-BDCC-4DCD-A452-C04E4AD94CEA}</ProjectGuid>
+ <ProjectGuid>{2B0BDC9E-ABF1-48DD-9814-7553B8D52725}</ProjectGuid>
<RootNamespace>$(MSBuildProjectName)</RootNamespace>
<Configuration Condition="'$(Configuration)' == ''">Debug</Configuration>
<Platform Condition="'$(Platform)' == ''">Win32</Platform>
- <SampleGuid>{A8666C84-4408-4F56-834E-989B3B03ED5A}</SampleGuid>
+ <SampleGuid>{CD28B759-C8BC-4F51-AB5E-AFF59331509B}</SampleGuid>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
@@ -182,7 +182,6 @@
<ItemGroup>
<Inf Exclude="@(Inf)" Include="*.inf" />
<FilesToPackage Include="$(TargetPath)" Condition="'$(ConfigurationType)'=='Driver' or '$(ConfigurationType)'=='DynamicLibrary'" />
- <FilesToPackage Include="@(Inf->'%(CopyOutput)')" Condition="'@(Inf)'!=''" />
</ItemGroup>
<ItemGroup>
<None Exclude="@(None)" Include="*.txt;*.htm;*.html" />
diff --git a/general/ioctl/wdm/exe/ioctlapp.vcxproj.Filters b/general/ioctl/wdm/exe/ioctlapp.vcxproj.Filters
index af420f3f..4129898e 100644
--- a/general/ioctl/wdm/exe/ioctlapp.vcxproj.Filters
+++ b/general/ioctl/wdm/exe/ioctlapp.vcxproj.Filters
@@ -3,15 +3,15 @@
<ItemGroup>
<Filter Include="Source Files">
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx;*</Extensions>
- <UniqueIdentifier>{96F80F7E-43A8-4FF2-833B-0F4E0B486149}</UniqueIdentifier>
+ <UniqueIdentifier>{73262017-91DD-45A8-8A68-9CCCAB2CA1C0}</UniqueIdentifier>
</Filter>
<Filter Include="Header Files">
<Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
- <UniqueIdentifier>{49685EE8-840B-4F1C-92CA-EF94838E1143}</UniqueIdentifier>
+ <UniqueIdentifier>{744376AF-8B58-45ED-828B-AA01CE10E194}</UniqueIdentifier>
</Filter>
<Filter Include="Resource Files">
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms;man;xml</Extensions>
- <UniqueIdentifier>{F87C331A-2013-470A-A6AC-100426820F7F}</UniqueIdentifier>
+ <UniqueIdentifier>{CB96AC92-B6DE-4B43-A7B4-EEB29C73C2BB}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
diff --git a/general/ioctl/wdm/ioctl.sln b/general/ioctl/wdm/ioctl.sln
index ff5233dc..d1d7b7fe 100644
--- a/general/ioctl/wdm/ioctl.sln
+++ b/general/ioctl/wdm/ioctl.sln
@@ -3,13 +3,13 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2013
VisualStudioVersion = 12.0
MinimumVisualStudioVersion = 12.0
-Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Exe", "Exe", "{784A1AB1-AE41-4D83-99A8-82848B129B48}"
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Exe", "Exe", "{05ABA65F-2F21-4F5E-A1D5-DD008F644663}"
EndProject
-Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Sys", "Sys", "{8D7246D9-D426-4517-9631-BCDC343A98A5}"
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Sys", "Sys", "{D5D0F833-0D75-4099-9A7F-B016159FC352}"
EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ioctlapp", "exe\ioctlapp.vcxproj", "{0F1154FD-BDCC-4DCD-A452-C04E4AD94CEA}"
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ioctlapp", "exe\ioctlapp.vcxproj", "{2B0BDC9E-ABF1-48DD-9814-7553B8D52725}"
EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "sioctl", "sys\sioctl.vcxproj", "{7B626BD2-8EA8-42C1-BCC4-BBBBF52E5E68}"
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "sioctl", "sys\sioctl.vcxproj", "{8A61FFBC-9D75-43B0-9715-B75E1BD3BFC0}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -19,28 +19,28 @@ Global
Release|x64 = Release|x64
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {0F1154FD-BDCC-4DCD-A452-C04E4AD94CEA}.Debug|Win32.ActiveCfg = Debug|Win32
- {0F1154FD-BDCC-4DCD-A452-C04E4AD94CEA}.Debug|Win32.Build.0 = Debug|Win32
- {0F1154FD-BDCC-4DCD-A452-C04E4AD94CEA}.Release|Win32.ActiveCfg = Release|Win32
- {0F1154FD-BDCC-4DCD-A452-C04E4AD94CEA}.Release|Win32.Build.0 = Release|Win32
- {0F1154FD-BDCC-4DCD-A452-C04E4AD94CEA}.Debug|x64.ActiveCfg = Debug|x64
- {0F1154FD-BDCC-4DCD-A452-C04E4AD94CEA}.Debug|x64.Build.0 = Debug|x64
- {0F1154FD-BDCC-4DCD-A452-C04E4AD94CEA}.Release|x64.ActiveCfg = Release|x64
- {0F1154FD-BDCC-4DCD-A452-C04E4AD94CEA}.Release|x64.Build.0 = Release|x64
- {7B626BD2-8EA8-42C1-BCC4-BBBBF52E5E68}.Debug|Win32.ActiveCfg = Debug|Win32
- {7B626BD2-8EA8-42C1-BCC4-BBBBF52E5E68}.Debug|Win32.Build.0 = Debug|Win32
- {7B626BD2-8EA8-42C1-BCC4-BBBBF52E5E68}.Release|Win32.ActiveCfg = Release|Win32
- {7B626BD2-8EA8-42C1-BCC4-BBBBF52E5E68}.Release|Win32.Build.0 = Release|Win32
- {7B626BD2-8EA8-42C1-BCC4-BBBBF52E5E68}.Debug|x64.ActiveCfg = Debug|x64
- {7B626BD2-8EA8-42C1-BCC4-BBBBF52E5E68}.Debug|x64.Build.0 = Debug|x64
- {7B626BD2-8EA8-42C1-BCC4-BBBBF52E5E68}.Release|x64.ActiveCfg = Release|x64
- {7B626BD2-8EA8-42C1-BCC4-BBBBF52E5E68}.Release|x64.Build.0 = Release|x64
+ {2B0BDC9E-ABF1-48DD-9814-7553B8D52725}.Debug|Win32.ActiveCfg = Debug|Win32
+ {2B0BDC9E-ABF1-48DD-9814-7553B8D52725}.Debug|Win32.Build.0 = Debug|Win32
+ {2B0BDC9E-ABF1-48DD-9814-7553B8D52725}.Release|Win32.ActiveCfg = Release|Win32
+ {2B0BDC9E-ABF1-48DD-9814-7553B8D52725}.Release|Win32.Build.0 = Release|Win32
+ {2B0BDC9E-ABF1-48DD-9814-7553B8D52725}.Debug|x64.ActiveCfg = Debug|x64
+ {2B0BDC9E-ABF1-48DD-9814-7553B8D52725}.Debug|x64.Build.0 = Debug|x64
+ {2B0BDC9E-ABF1-48DD-9814-7553B8D52725}.Release|x64.ActiveCfg = Release|x64
+ {2B0BDC9E-ABF1-48DD-9814-7553B8D52725}.Release|x64.Build.0 = Release|x64
+ {8A61FFBC-9D75-43B0-9715-B75E1BD3BFC0}.Debug|Win32.ActiveCfg = Debug|Win32
+ {8A61FFBC-9D75-43B0-9715-B75E1BD3BFC0}.Debug|Win32.Build.0 = Debug|Win32
+ {8A61FFBC-9D75-43B0-9715-B75E1BD3BFC0}.Release|Win32.ActiveCfg = Release|Win32
+ {8A61FFBC-9D75-43B0-9715-B75E1BD3BFC0}.Release|Win32.Build.0 = Release|Win32
+ {8A61FFBC-9D75-43B0-9715-B75E1BD3BFC0}.Debug|x64.ActiveCfg = Debug|x64
+ {8A61FFBC-9D75-43B0-9715-B75E1BD3BFC0}.Debug|x64.Build.0 = Debug|x64
+ {8A61FFBC-9D75-43B0-9715-B75E1BD3BFC0}.Release|x64.ActiveCfg = Release|x64
+ {8A61FFBC-9D75-43B0-9715-B75E1BD3BFC0}.Release|x64.Build.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
- {0F1154FD-BDCC-4DCD-A452-C04E4AD94CEA} = {784A1AB1-AE41-4D83-99A8-82848B129B48}
- {7B626BD2-8EA8-42C1-BCC4-BBBBF52E5E68} = {8D7246D9-D426-4517-9631-BCDC343A98A5}
+ {2B0BDC9E-ABF1-48DD-9814-7553B8D52725} = {05ABA65F-2F21-4F5E-A1D5-DD008F644663}
+ {8A61FFBC-9D75-43B0-9715-B75E1BD3BFC0} = {D5D0F833-0D75-4099-9A7F-B016159FC352}
EndGlobalSection
EndGlobal
diff --git a/general/ioctl/wdm/sys/sioctl.vcxproj b/general/ioctl/wdm/sys/sioctl.vcxproj
index 7941eb1d..8b12549a 100644
--- a/general/ioctl/wdm/sys/sioctl.vcxproj
+++ b/general/ioctl/wdm/sys/sioctl.vcxproj
@@ -19,11 +19,11 @@
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
- <ProjectGuid>{7B626BD2-8EA8-42C1-BCC4-BBBBF52E5E68}</ProjectGuid>
+ <ProjectGuid>{8A61FFBC-9D75-43B0-9715-B75E1BD3BFC0}</ProjectGuid>
<RootNamespace>$(MSBuildProjectName)</RootNamespace>
<Configuration Condition="'$(Configuration)' == ''">Debug</Configuration>
<Platform Condition="'$(Platform)' == ''">Win32</Platform>
- <SampleGuid>{FCA3A913-3152-480C-8F1A-78460EBE1F76}</SampleGuid>
+ <SampleGuid>{57EBFE5D-4194-4628-B3DB-243FA7D03AC9}</SampleGuid>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
@@ -126,7 +126,6 @@
<ItemGroup>
<Inf Exclude="@(Inf)" Include="*.inf" />
<FilesToPackage Include="$(TargetPath)" Condition="'$(ConfigurationType)'=='Driver' or '$(ConfigurationType)'=='DynamicLibrary'" />
- <FilesToPackage Include="@(Inf->'%(CopyOutput)')" Condition="'@(Inf)'!=''" />
</ItemGroup>
<ItemGroup>
<None Exclude="@(None)" Include="*.txt;*.htm;*.html" />
diff --git a/general/ioctl/wdm/sys/sioctl.vcxproj.Filters b/general/ioctl/wdm/sys/sioctl.vcxproj.Filters
index 2c4c9583..4f493adc 100644
--- a/general/ioctl/wdm/sys/sioctl.vcxproj.Filters
+++ b/general/ioctl/wdm/sys/sioctl.vcxproj.Filters
@@ -3,19 +3,19 @@
<ItemGroup>
<Filter Include="Source Files">
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx;*</Extensions>
- <UniqueIdentifier>{0293F632-CB51-45F8-8DF6-6CE8AB8DEB1D}</UniqueIdentifier>
+ <UniqueIdentifier>{E9EE9FFB-2EBC-4879-8005-029F0C26829C}</UniqueIdentifier>
</Filter>
<Filter Include="Header Files">
<Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
- <UniqueIdentifier>{8214575D-756B-4919-88AE-CDECEFA1921F}</UniqueIdentifier>
+ <UniqueIdentifier>{7C81EF4D-3554-45D3-A116-B443830349FD}</UniqueIdentifier>
</Filter>
<Filter Include="Resource Files">
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms;man;xml</Extensions>
- <UniqueIdentifier>{7306FA3C-F664-4252-9566-E061F0301808}</UniqueIdentifier>
+ <UniqueIdentifier>{4B6FECB8-7A2A-4AFD-95F2-94D7C452E97E}</UniqueIdentifier>
</Filter>
<Filter Include="Driver Files">
<Extensions>inf;inv;inx;mof;mc;</Extensions>
- <UniqueIdentifier>{8721C5CF-CC9A-4480-B324-73C98BFD444A}</UniqueIdentifier>
+ <UniqueIdentifier>{D4A26FDD-3685-4E62-BFD4-51FD89171C68}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>