{"owner":"microsoft","repo":"Windows-driver-samples","hasSkills":true,"totalSkillsCount":7,"totalTokensCount":5201,"categories":["plugin-manifest"],"hasMcp":false,"mcpConfig":null,"found":["tools/sdv/samples/SDV-FailDriver-NDIS/README.md","storage/tools/spti/README.md","tools/sdv/samples/SDV-FailDriver-WDM/README.md","tools/dv/samples/DV-FailDriver-WDM/README.md","tools/kasan/samples/KasanDemo-WDM/README.md","tools/sdv/samples/SDV-FailDriver-KMDF/README.md","tools/sdv/samples/SDV-FailDriver-STORPORT/README.md"],"skills":{"tools/sdv/samples/SDV-FailDriver-NDIS/README.md":"---\npage_type: sample\ndescription: \"Demonstrates how Static Driver Verifier (SDV) can find errors in a NDIS driver.\"\nlanguages:\n- cpp\nproducts:\n- windows\n- windows-wdk\n---\n\n# SDV-FailDriver-NDIS\n\nThe SDV-FailDriver-NDIS sample driver contains intentional code errors that are designed to show the capabilities and features of [Static Driver Verifier](https://docs.microsoft.com/windows-hardware/drivers/devtest/static-driver-verifier) (SDV). SDV is a static verification tool that systematically analyzes the source code of Windows kernel-mode drivers. SDV is included in the Windows Driver Kit (WDK) and can be run from Microsoft Visual Studio. The sample demonstrates how SDV can find errors in an NDIS driver.\n\n> [!CAUTION]\n> These sample drivers contain intentional code errors that are designed to show the capabilities and features of SDV. These sample drivers are not functional and are not intended as examples for real driver development projects.\n\n## Run the sample\n\n1. In the **Solutions Explorer** window, select the driver project (sdvmp.vcxProj).\n\n    From the **Driver** menu, click **Launch Static Driver Verifier...**.\n\n    This opens the Static Driver Verifier application, where you can control, configure, and schedule when Static Driver Verifier performs an analysis.\n\n1. Click the **Rules** tab to select which driver DDI usage rules to verify when you start the analysis.\n\n    Static Driver Verifier detects the type of driver you are analyzing (WDF, WDM, NDIS, or Storport) and selects the default set of rules for your driver type. If this is the first time you are running SDV on your driver, you should run the default rule set. To shorten the amount of time it takes to analyze the sample driver, you can select the **Custom rule selection**.\n\n    Use the default rule set, or select **Custom rule selection**, click **Clear All**, and then select the following rules for the NDIS sdvmp sample:\n\n    - [NdisAllocateMemoryWithTagPriority](https://docs.microsoft.com/windows-hardware/drivers/devtest/ndis-ndisallocatememorywithtagpriority)\n\n    - [Init\\_RegisterSG](https://docs.microsoft.com/windows-hardware/drivers/devtest/ndis-init-registersg)\n\n    - [NdisStallExecution\\_Delay](https://docs.microsoft.com/windows-hardware/drivers/devtest/ndis-ndisstallexecution-delay)\n\n    - [Flags\\_Irql](https://docs.microsoft.com/windows-hardware/drivers/devtest/ndis-flags-irql)\n\n    - [Irql\\_Synch\\_Function](https://docs.microsoft.com/windows-hardware/drivers/devtest/ndis-irql-synch-function)\n\n    For information about the rules, see [DDI Compliance Rules](https://docs.microsoft.com/windows-hardware/drivers/devtest/static-driver-verifier-rules).\n\n1. Start the static analysis. Click the **Main** tab, and click **Start**. When you click **Start**, a message is displayed to let you know that static analysis is scheduled and that the analysis can take a long time to run. Click **OK** to continue.\n\n## View and analyze the results\n\nAs the static analysis proceeds, SDV reports the status of the analysis. When the analysis is complete, SDV reports the results and statistics. If the driver fails to satisfy a DDI usage rule, the result is reported as a defect. SDV finds 5 defects in this sample.\n\nOn the **Main** tab, under **Results**, click the **Rules** tab. This tab displays the name of each rule that was verified in the last run and the results of the analysis. To view the reported defects, click the **Defect** link in the **Results** column. This opens the [Static Driver Verifier Report Page](https://docs.microsoft.com/windows-hardware/drivers/devtest/static-driver-verifier-report) and the [Trace Viewer](https://docs.microsoft.com/windows-hardware/drivers/devtest/defect-viewer), which displays a trace of the code path to the rule violation. For more information, see [Interpreting Static Driver Verifier Results](https://docs.microsoft.com/windows-hardware/drivers/devtest/interpreting-static-driver-verifier-results).\n","storage/tools/spti/README.md":"---\npage_type: sample\ndescription: \"Demonstrates how to communicate with a SCSI device using pass-through IOCTLs in an application using DeviceIoControl API.\"\nlanguages:\n- cpp\nproducts:\n- windows\n- windows-wdk\n---\n\n# SCSI Pass-Through Interface Tool\n\nThe SCSI Pass Through Interface sample demonstrates how to communicate with a SCSI device from Microsoft Win32 applications by using the **DeviceIoControl** API.\n\n## Installation and Operation\n\nThe storage port drivers provide an interface for Win32 applications to send SCSI CBDs (Command Descriptor Block) to SCSI devices. The interfaces are [**IOCTL\\_SCSI\\_PASS\\_THROUGH**](https://docs.microsoft.com/windows-hardware/drivers/ddi/content/ntddscsi/ni-ntddscsi-ioctl_scsi_pass_through) and [**IOCTL\\_SCSI\\_PASS\\_THROUGH\\_DIRECT**](https://docs.microsoft.com/windows-hardware/drivers/ddi/content/ntddscsi/ni-ntddscsi-ioctl_scsi_pass_through_direct). Applications can build a pass-through request and send it to the device by using this IOCTL.\n\nTwo command line parameters can be used with *SPTI.EXE*. The first parameter is mandatory. It is the name of the device to be opened. Typical values for this are drive letters such as \"C:\", or device names as defined by a class driver such as Scanner0, or the SCSI port driver name, ScsiN:, where N = 0, 1, 2, etc. The second parameter is optional and is used to set the share mode (note that access mode and share mode are different things) and sector size. The default share mode is (FILE\\_SHARE\\_READ | FILE\\_SHARE\\_WRITE) and the default sector size is 512. A parameter of \"r\" changes the share mode to only FILE\\_SHARE\\_READ. A parameter of \"w\" changes the share mode to only FILE\\_SHARE\\_WRITE. A parameter of \"c\" changes the share mode to only FILE\\_SHARE\\_READ and also changes the sector size to 2048. Typically, a CD-ROM device would use the \"c\" parameter.\n","tools/sdv/samples/SDV-FailDriver-WDM/README.md":"---\npage_type: sample\ndescription: \"Demonstrates how Static Driver Verifier (SDV) can find errors in a WDM driver.\"\nlanguages:\n- cpp\nproducts:\n- windows\n- windows-wdk\n---\n\n# SDV-FailDriver-WDM\n\nThe SDV-FailDriver-WDM sample driver contains intentional code errors that are designed to show the capabilities and features of [Static Driver Verifier](https://docs.microsoft.com/windows-hardware/drivers/devtest/static-driver-verifier) (SDV). SDV is a static verification tool that systematically analyzes the source code of Windows kernel-mode drivers. SDV is included in the Windows Driver Kit (WDK) and can be run from Microsoft Visual Studio. The sample demonstrates how SDV can find errors in a WDM driver.\n\n> [!CAUTION]\n> These sample drivers contain intentional code errors that are designed to show the capabilities and features of SDV. These sample drivers are not functional and are not intended as examples for real driver development projects.\n\n## Run the sample\n\n1. In the **Solutions Explorer** window, select the driver project (fail\\_driver1).\n\n    From the **Driver** menu, click **Launch Static Driver Verifier...**.\n\n    This opens the Static Driver Verifier application, where you can control, configure, and schedule when Static Driver Verifier performs an analysis.\n\n1. Click the **Rules** tab to select which driver DDI usage rules to verify when you start the analysis.\n\n    Static Driver Verifier detects the type of driver you are analyzing (WDF, WDM, NDIS, or Storport) and selects the default set of rules for your driver type. If this is the first time you are running SDV on your driver, you should run the default rule set. To shorten the amount of time it takes to analyze the fail\\_driver1 driver sample, you can select the **Custom rule selection**.\n\n    Use the default rule set, or select **Custom rule selection**, click **Clear All**, and then select the following rules for the WDM fail\\_driver1 sample:\n\n    - [CancelSpinLock](https://docs.microsoft.com/windows-hardware/drivers/devtest/wdm-cancelspinlock)\n\n    - [IrqlIoApcLte](https://docs.microsoft.com/windows-hardware/drivers/devtest/wdm-irqlioapclte)\n\n    - [IrqlKeSetEvent](https://docs.microsoft.com/windows-hardware/drivers/devtest/wdm-irqlkesetevent)\n\n    - [LowerDriverReturn](https://docs.microsoft.com/windows-hardware/drivers/devtest/wdm-lowerdriverreturn)\n\n    - [SpinLock (WDM)](https://docs.microsoft.com/windows-hardware/drivers/devtest/wdm-spinlock)\n\n    For information about the rules, see [DDI Compliance Rules](https://docs.microsoft.com/windows-hardware/drivers/devtest/static-driver-verifier-rules).\n\n1. Start the static analysis. Click the **Main** tab, and click **Start**. When you click **Start**, a message is displayed to let you know that static analysis is scheduled and that the analysis can take a long time to run. Click **OK** to continue.\n\n## View and analyze the results\n\nAs the static analysis proceeds, SDV reports the status of the analysis. When the analysis is complete, SDV reports the results and statistics. If the driver fails to satisfy a DDI usage rule, the result is reported as a defect. SDV finds 5 defects in this sample.\n\nOn the **Main** tab, under **Results**, click the **Rules** tab. This tab displays the name of each rule that was verified in the last run and the results of the analysis. To view the reported defects, click the **Defect** link in the **Results** column. This opens the [Static Driver Verifier Report Page](https://docs.microsoft.com/windows-hardware/drivers/devtest/static-driver-verifier-report) and the [Trace Viewer](https://docs.microsoft.com/windows-hardware/drivers/devtest/defect-viewer), which displays a trace of the code path to the rule violation. For more information, see [Interpreting Static Driver Verifier Results](https://docs.microsoft.com/windows-hardware/drivers/devtest/interpreting-static-driver-verifier-results).\n","tools/dv/samples/DV-FailDriver-WDM/README.md":"---\npage_type: sample\ndescription: \"Demonstrates how Driver Verifier (DV) can find errors in a WDM driver.\"\nlanguages:\n- cpp\nproducts:\n- windows\n- windows-wdk\n---\n\n# DV-FailDriver-WDM\n\nThe DV-FailDriver-WDM sample driver contains intentional code errors that are designed to show the capabilities and features of [Driver Verifier](https://docs.microsoft.com/windows-hardware/drivers/devtest/driver-verifier) (DV) and the [Device Fundamentals tests](https://docs.microsoft.com/windows-hardware/drivers/devtest/device-fundamentals-tests).  Driver Verifier is a component of the Windows kernel designed to detect drivers that are behaving poorly and stop their execution via a bugcheck; the Device Fundamentals tests are a series of tests provided in the Windows Driver Kit (WDK) designed to provide a good basic set of tests against a driver.\n\n> [!CAUTION]\n> This sample driver contains intentional code errors that are designed to show the capabilities and features of DV and SDV. This sample driver is not intended as an example for real driver development projects.\n\n## Build the sample for desktop\n\n1. In the **Solutions Explorer** window, select the driver solution (DV-FailDriver-WDM).\n\n1. From the **Build** menu, select **Build Solution**.\n\n## Deploy the sample\n\nSee [Deploying a Driver to a Test Computer](https://docs.microsoft.com/windows-hardware/drivers/develop/deploying-a-driver-to-a-test-computer) for details on how to deploy the sample.\n\n#### New\n\nIt is highly encouraged when testing a driver to use [DevGen](https://learn.microsoft.com/windows-hardware/drivers/devtest/devgen) to create a [SwDevice](https://learn.microsoft.com/windows/win32/api/_swdevice/).\n\n__DevGen Usage Example__\n\n1. From a terminal (running as admin) on test computer go to the WDK tools path and run `.\\devgen /add /bus SWD /hardwareid root\\defect_toastmon`. ***If WDK is not available on test computer, simply copy over `devgen.exe`***\n\n2. There is now a `Generic software device` available in the system. ***Use Device Manager as a simple means to inspect or from a terminal run `pnputil /enum-devices /deviceid \"root\\defect_toastmon\"`.***\n\n3. Now that there is a device with the appropriate hardware ID, deploy/install driver sample accordingly.\n\n> Note: Use `.\\devgen /remove \"<Device instance path>\"` to remove SW device (the path can be copied from output of `.\\devgen /add` or from Device Manager).\n>\n> Device instance path example `\"SWD\\DEVGEN\\{D0299946-2EC2-C146-B00B-E01144166F8B}\"`\n\n## Test the sample\n\nSee [How to test a driver at runtime](https://docs.microsoft.com/windows-hardware/drivers/develop/how-to-test-a-driver-at-runtime-from-a-command-prompt) for details on how to run tests on the Toastmon driver.\n\nTo observe the injected defect being caught by DV, you should enable DV on the Toastmon driver, and then run the \"DF - PNP Surprise Remove (Development and Integration)\" test on the Toastmon sample driver and device.\n","tools/kasan/samples/KasanDemo-WDM/README.md":"---\npage_type: sample\ndescription: \"Demonstrates KASAN.\"\nlanguages:\n- cpp\nproducts:\n- windows\n- windows-wdk\n---\n\n# KasanDemo\n\nThis sample demonstrates how KASAN detects illegal memory accesses.\n\nThe sample consists of a legacy device driver that contains intentionally incorrect code that performs illegal memory accesses, and a Win32 console agent that interacts with the driver to trigger different types of illegal memory accesses that KASAN successfully detects.\n\n> [!CAUTION]\n> This driver contains INTENTIONALLY INCORRECT code. Neither this driver nor its sample programs are intended for use in a production environment. Instead, they are intended for educational purposes.\n\n> [!CAUTION]\n> This driver will cause KASAN to bugcheck your system.\n\n## Run the sample\n\nTo run this sample, enable KASAN in your system, load the `kasantrigger.sys` driver, and then run the `kasanagent.exe` application.\n","tools/sdv/samples/SDV-FailDriver-KMDF/README.md":"---\npage_type: sample\ndescription: \"Demonstrates how Static Driver Verifier (SDV) can find errors in a KMDF driver.\"\nlanguages:\n- cpp\nproducts:\n- windows\n- windows-wdk\n---\n\n# SDV-FailDriver-KMDF\n\nThe SDV-FailDriver-KMDF sample driver contains intentional code errors that are designed to show the capabilities and features of [Static Driver Verifier](https://docs.microsoft.com/windows-hardware/drivers/devtest/static-driver-verifier) (SDV). SDV is a static verification tool that systematically analyzes the source code of Windows kernel-mode drivers. SDV is included in the Windows Driver Kit (WDK) and can be run from Microsoft Visual Studio. The sample demonstrates how SDV can find errors in a KMDF driver.\n\n> [!CAUTION]\n> These sample drivers contain intentional code errors that are designed to show the capabilities and features of SDV. These sample drivers are not functional and are not intended as examples for real driver development projects.\n\n## Run the sample\n\n1. In the **Solutions Explorer** window, select the driver project (fail\\_driver1).\n\n    From the **Driver** menu, click **Launch Static Driver Verifier...**.\n\n    This opens the Static Driver Verifier application, where you can control, configure, and schedule when Static Driver Verifier performs an analysis.\n\n1. The fail\\_driver1 sample driver includes a library. To add the library, click the **Libraries** tab and click **Add Library**.\n\n    Browse to the sample library directory and select the library project file (fail\\_library1.vcxProj). The library must be added before SDV analyzes the driver. For more information, see [Library Processing in Static Driver Verifier](https://docs.microsoft.com/windows-hardware/drivers/devtest/library-processing-in-static-driver-verifier).\n\n1. Click the **Rules** tab to select which driver DDI usage rules to verify when you start the analysis.\n\n    Static Driver Verifier detects the type of driver you are analyzing (WDF, WDM, NDIS, or Storport) and selects the default set of rules for your driver type. If this is the first time you are running SDV on your driver, you should run the default rule set. To shorten the amount of time it takes to analyze the fail\\_driver1 driver sample, you can select the **Custom rule selection**.\n\n    Use the default rule set, or select **Custom rule selection**, click **Clear All**, and then select the following rules for the KMDF fail\\_driver1 sample:\n\n    - [DriverCreate](https://docs.microsoft.com/windows-hardware/drivers/devtest/kmdf-drivercreate)\n\n    - [DeviceInitAPI](https://docs.microsoft.com/windows-hardware/drivers/devtest/kmdf-deviceinitapi)\n\n    - [CtlDeviceFinishInitDeviceAdd](https://docs.microsoft.com/windows-hardware/drivers/devtest/kmdf-ctldevicefinishinitdeviceadd)\n\n    - [MdlAfterReqCompletedIoctl](https://docs.microsoft.com/windows-hardware/drivers/devtest/kmdf-mdlafterreqcompletedioctl)\n\n    - [MemAfterReqCompletedIntIoctlA](https://docs.microsoft.com/windows-hardware/drivers/devtest/kmdf-memafterreqcompletedintioctla)\n\n    - [MdlAfterReqCompletedIntIoctlA](https://docs.microsoft.com/windows-hardware/drivers/devtest/kmdf-mdlafterreqcompletedintioctla)\n\n    - [MarkCancOnCancReqLocal](https://docs.microsoft.com/windows-hardware/drivers/devtest/kmdf-markcanconcancreqlocal)\n\n    - [StopAckWithinEvtIoStop](https://docs.microsoft.com/windows-hardware/drivers/devtest/kmdf-stopackwithinevtiostop)\n\n    For information about the rules, see [DDI Compliance Rules](https://docs.microsoft.com/windows-hardware/drivers/devtest/static-driver-verifier-rules).\n\n1. Start the static analysis. Click the **Main** tab, and then click **Start**. When you click **Start**, a message is displayed to let you know that static analysis is scheduled and that the analysis can take a long time to run. Click **OK** to continue.\n\n## View and analyze the results\n\nAs the static analysis proceeds, SDV reports the status of the analysis. When the analysis is complete, SDV reports the results and statistics. If the driver fails to satisfy a DDI usage rule, the result is reported as a defect. SDV finds 8 defects in this sample.\n\nOn the **Main** tab, under **Results**, click the **Rules** tab. This tab displays the name of each rule that was verified in the last run and the results of the analysis. To view the reported defects, click the **Defect** link in the **Results** column. This opens the [Static Driver Verifier Report Page](https://docs.microsoft.com/windows-hardware/drivers/devtest/static-driver-verifier-report) and the [Trace Viewer](https://docs.microsoft.com/windows-hardware/drivers/devtest/defect-viewer), which displays a trace of the code path to the rule violation. For more information, see [Interpreting Static Driver Verifier Results](https://docs.microsoft.com/windows-hardware/drivers/devtest/interpreting-static-driver-verifier-results).\n","tools/sdv/samples/SDV-FailDriver-STORPORT/README.md":"---\npage_type: sample\ndescription: \"Demonstrates how Static Driver Verifier (SDV) can find errors in a Storport driver.\"\nlanguages:\n- cpp\nproducts:\n- windows\n- windows-wdk\n---\n\n# SDV-FailDriver-STORPORT\n\nThe SDV-FailDriver-Storport sample driver contains intentional code errors that are designed to show the capabilities and features of [Static Driver Verifier](https://docs.microsoft.com/windows-hardware/drivers/devtest/static-driver-verifier) (SDV). SDV is a static verification tool that systematically analyzes the source code of Windows kernel-mode drivers. SDV is included in the Windows Driver Kit (WDK) and can be run from Microsoft Visual Studio. The sample demonstrates how SDV can find errors in a Storport driver.\n\n> [!CAUTION]\n> These sample drivers contain intentional code errors that are designed to show the capabilities and features of SDV. These sample drivers are not functional and are not intended as examples for real driver development projects.\n\n## Run the sample\n\n1. In the **Solutions Explorer** window, select the driver project (lsi\\_u3.vcxProj).\n\n    From the **Driver** menu, click **Launch Static Driver Verifier...**.\n\n    This opens the Static Driver Verifier application, where you can control, configure, and schedule when Static Driver Verifier performs an analysis.\n\n1. Click the **Rules** tab to select which driver DDI usage rules to verify when you start the analysis.\n\n    Static Driver Verifier detects the type of driver you are analyzing (WDF, WDM, NDIS, or Storport) and selects the default set of rules for your driver type. If this is the first time you are running SDV on your driver, you should run the default rule set. To shorten the amount of time it takes to analyze the sample driver, you can select the **Custom rule selection**.\n\n    Use the default rule set, or select **Custom rule selection**, click **Clear All**, and then select the following rules for the Storport sample:\n\n    - [StorPortAllocatePool2 Rule (Storport)](https://docs.microsoft.com/windows-hardware/drivers/devtest/storport-storportallocatepool2)\n\n    - [StorPortDeprecated Rule (Storport)](https://docs.microsoft.com/windows-hardware/drivers/devtest/storport-storportdeprecated)\n\n    - [StorPortEnablePassive Rule (Storport)](https://docs.microsoft.com/windows-hardware/drivers/devtest/storport-storportenablepassive)\n\n    - [StorPortNotification2 Rule (Storport)](https://docs.microsoft.com/windows-hardware/drivers/devtest/storport-storportnotification2)\n\n    - [StorPortSpinLock Rule (Storport)](https://docs.microsoft.com/windows-hardware/drivers/devtest/storport-storportspinlock)\n\n    - [StorPortStartIo Rule (Storport)](https://docs.microsoft.com/windows-hardware/drivers/devtest/storport-storportstartio)\n\n    - [StorPortStatusPending Rule (Storport)](https://docs.microsoft.com/windows-hardware/drivers/devtest/storport-storportstatuspending)\n\n    For information about the rules, see [DDI Compliance Rules](https://docs.microsoft.com/windows-hardware/drivers/devtest/static-driver-verifier-rules).\n\n1. Start the static analysis. Click the **Main** tab, and click **Start**. When you click **Start**, a message is displayed to let you know that static analysis is scheduled and that the analysis can take a long time to run. Click **OK** to continue.\n\n## View and analyze the results\n\nAs the static analysis proceeds, SDV reports the status of the analysis. When the analysis is complete, SDV reports the results and statistics. If the driver fails to satisfy a DDI usage rule, the result is reported as a defect. SDV finds 7 defects in this sample.\n\nOn the **Main** tab, under **Results**, click the **Rules** tab. This tab displays the name of each rule that was verified in the last run and the results of the analysis. To view the reported defects, click the **Defect** link in the **Results** column. This opens the [Static Driver Verifier Report Page](https://docs.microsoft.com/windows-hardware/drivers/devtest/static-driver-verifier-report) and the [Trace Viewer](https://docs.microsoft.com/windows-hardware/drivers/devtest/defect-viewer), which displays a trace of the code path to the rule violation. For more information, see [Interpreting Static Driver Verifier Results](https://docs.microsoft.com/windows-hardware/drivers/devtest/interpreting-static-driver-verifier-results).\n"},"files":{"tools/sdv/samples/SDV-FailDriver-NDIS/README.md":"---\npage_type: sample\ndescription: \"Demonstrates how Static Driver Verifier (SDV) can find errors in a NDIS driver.\"\nlanguages:\n- cpp\nproducts:\n- windows\n- windows-wdk\n---\n\n# SDV-FailDriver-NDIS\n\nThe SDV-FailDriver-NDIS sample driver contains intentional code errors that are designed to show the capabilities and features of [Static Driver Verifier](https://docs.microsoft.com/windows-hardware/drivers/devtest/static-driver-verifier) (SDV). SDV is a static verification tool that systematically analyzes the source code of Windows kernel-mode drivers. SDV is included in the Windows Driver Kit (WDK) and can be run from Microsoft Visual Studio. The sample demonstrates how SDV can find errors in an NDIS driver.\n\n> [!CAUTION]\n> These sample drivers contain intentional code errors that are designed to show the capabilities and features of SDV. These sample drivers are not functional and are not intended as examples for real driver development projects.\n\n## Run the sample\n\n1. In the **Solutions Explorer** window, select the driver project (sdvmp.vcxProj).\n\n    From the **Driver** menu, click **Launch Static Driver Verifier...**.\n\n    This opens the Static Driver Verifier application, where you can control, configure, and schedule when Static Driver Verifier performs an analysis.\n\n1. Click the **Rules** tab to select which driver DDI usage rules to verify when you start the analysis.\n\n    Static Driver Verifier detects the type of driver you are analyzing (WDF, WDM, NDIS, or Storport) and selects the default set of rules for your driver type. If this is the first time you are running SDV on your driver, you should run the default rule set. To shorten the amount of time it takes to analyze the sample driver, you can select the **Custom rule selection**.\n\n    Use the default rule set, or select **Custom rule selection**, click **Clear All**, and then select the following rules for the NDIS sdvmp sample:\n\n    - [NdisAllocateMemoryWithTagPriority](https://docs.microsoft.com/windows-hardware/drivers/devtest/ndis-ndisallocatememorywithtagpriority)\n\n    - [Init\\_RegisterSG](https://docs.microsoft.com/windows-hardware/drivers/devtest/ndis-init-registersg)\n\n    - [NdisStallExecution\\_Delay](https://docs.microsoft.com/windows-hardware/drivers/devtest/ndis-ndisstallexecution-delay)\n\n    - [Flags\\_Irql](https://docs.microsoft.com/windows-hardware/drivers/devtest/ndis-flags-irql)\n\n    - [Irql\\_Synch\\_Function](https://docs.microsoft.com/windows-hardware/drivers/devtest/ndis-irql-synch-function)\n\n    For information about the rules, see [DDI Compliance Rules](https://docs.microsoft.com/windows-hardware/drivers/devtest/static-driver-verifier-rules).\n\n1. Start the static analysis. Click the **Main** tab, and click **Start**. When you click **Start**, a message is displayed to let you know that static analysis is scheduled and that the analysis can take a long time to run. Click **OK** to continue.\n\n## View and analyze the results\n\nAs the static analysis proceeds, SDV reports the status of the analysis. When the analysis is complete, SDV reports the results and statistics. If the driver fails to satisfy a DDI usage rule, the result is reported as a defect. SDV finds 5 defects in this sample.\n\nOn the **Main** tab, under **Results**, click the **Rules** tab. This tab displays the name of each rule that was verified in the last run and the results of the analysis. To view the reported defects, click the **Defect** link in the **Results** column. This opens the [Static Driver Verifier Report Page](https://docs.microsoft.com/windows-hardware/drivers/devtest/static-driver-verifier-report) and the [Trace Viewer](https://docs.microsoft.com/windows-hardware/drivers/devtest/defect-viewer), which displays a trace of the code path to the rule violation. For more information, see [Interpreting Static Driver Verifier Results](https://docs.microsoft.com/windows-hardware/drivers/devtest/interpreting-static-driver-verifier-results).\n","storage/tools/spti/README.md":"---\npage_type: sample\ndescription: \"Demonstrates how to communicate with a SCSI device using pass-through IOCTLs in an application using DeviceIoControl API.\"\nlanguages:\n- cpp\nproducts:\n- windows\n- windows-wdk\n---\n\n# SCSI Pass-Through Interface Tool\n\nThe SCSI Pass Through Interface sample demonstrates how to communicate with a SCSI device from Microsoft Win32 applications by using the **DeviceIoControl** API.\n\n## Installation and Operation\n\nThe storage port drivers provide an interface for Win32 applications to send SCSI CBDs (Command Descriptor Block) to SCSI devices. The interfaces are [**IOCTL\\_SCSI\\_PASS\\_THROUGH**](https://docs.microsoft.com/windows-hardware/drivers/ddi/content/ntddscsi/ni-ntddscsi-ioctl_scsi_pass_through) and [**IOCTL\\_SCSI\\_PASS\\_THROUGH\\_DIRECT**](https://docs.microsoft.com/windows-hardware/drivers/ddi/content/ntddscsi/ni-ntddscsi-ioctl_scsi_pass_through_direct). Applications can build a pass-through request and send it to the device by using this IOCTL.\n\nTwo command line parameters can be used with *SPTI.EXE*. The first parameter is mandatory. It is the name of the device to be opened. Typical values for this are drive letters such as \"C:\", or device names as defined by a class driver such as Scanner0, or the SCSI port driver name, ScsiN:, where N = 0, 1, 2, etc. The second parameter is optional and is used to set the share mode (note that access mode and share mode are different things) and sector size. The default share mode is (FILE\\_SHARE\\_READ | FILE\\_SHARE\\_WRITE) and the default sector size is 512. A parameter of \"r\" changes the share mode to only FILE\\_SHARE\\_READ. A parameter of \"w\" changes the share mode to only FILE\\_SHARE\\_WRITE. A parameter of \"c\" changes the share mode to only FILE\\_SHARE\\_READ and also changes the sector size to 2048. Typically, a CD-ROM device would use the \"c\" parameter.\n","tools/sdv/samples/SDV-FailDriver-WDM/README.md":"---\npage_type: sample\ndescription: \"Demonstrates how Static Driver Verifier (SDV) can find errors in a WDM driver.\"\nlanguages:\n- cpp\nproducts:\n- windows\n- windows-wdk\n---\n\n# SDV-FailDriver-WDM\n\nThe SDV-FailDriver-WDM sample driver contains intentional code errors that are designed to show the capabilities and features of [Static Driver Verifier](https://docs.microsoft.com/windows-hardware/drivers/devtest/static-driver-verifier) (SDV). SDV is a static verification tool that systematically analyzes the source code of Windows kernel-mode drivers. SDV is included in the Windows Driver Kit (WDK) and can be run from Microsoft Visual Studio. The sample demonstrates how SDV can find errors in a WDM driver.\n\n> [!CAUTION]\n> These sample drivers contain intentional code errors that are designed to show the capabilities and features of SDV. These sample drivers are not functional and are not intended as examples for real driver development projects.\n\n## Run the sample\n\n1. In the **Solutions Explorer** window, select the driver project (fail\\_driver1).\n\n    From the **Driver** menu, click **Launch Static Driver Verifier...**.\n\n    This opens the Static Driver Verifier application, where you can control, configure, and schedule when Static Driver Verifier performs an analysis.\n\n1. Click the **Rules** tab to select which driver DDI usage rules to verify when you start the analysis.\n\n    Static Driver Verifier detects the type of driver you are analyzing (WDF, WDM, NDIS, or Storport) and selects the default set of rules for your driver type. If this is the first time you are running SDV on your driver, you should run the default rule set. To shorten the amount of time it takes to analyze the fail\\_driver1 driver sample, you can select the **Custom rule selection**.\n\n    Use the default rule set, or select **Custom rule selection**, click **Clear All**, and then select the following rules for the WDM fail\\_driver1 sample:\n\n    - [CancelSpinLock](https://docs.microsoft.com/windows-hardware/drivers/devtest/wdm-cancelspinlock)\n\n    - [IrqlIoApcLte](https://docs.microsoft.com/windows-hardware/drivers/devtest/wdm-irqlioapclte)\n\n    - [IrqlKeSetEvent](https://docs.microsoft.com/windows-hardware/drivers/devtest/wdm-irqlkesetevent)\n\n    - [LowerDriverReturn](https://docs.microsoft.com/windows-hardware/drivers/devtest/wdm-lowerdriverreturn)\n\n    - [SpinLock (WDM)](https://docs.microsoft.com/windows-hardware/drivers/devtest/wdm-spinlock)\n\n    For information about the rules, see [DDI Compliance Rules](https://docs.microsoft.com/windows-hardware/drivers/devtest/static-driver-verifier-rules).\n\n1. Start the static analysis. Click the **Main** tab, and click **Start**. When you click **Start**, a message is displayed to let you know that static analysis is scheduled and that the analysis can take a long time to run. Click **OK** to continue.\n\n## View and analyze the results\n\nAs the static analysis proceeds, SDV reports the status of the analysis. When the analysis is complete, SDV reports the results and statistics. If the driver fails to satisfy a DDI usage rule, the result is reported as a defect. SDV finds 5 defects in this sample.\n\nOn the **Main** tab, under **Results**, click the **Rules** tab. This tab displays the name of each rule that was verified in the last run and the results of the analysis. To view the reported defects, click the **Defect** link in the **Results** column. This opens the [Static Driver Verifier Report Page](https://docs.microsoft.com/windows-hardware/drivers/devtest/static-driver-verifier-report) and the [Trace Viewer](https://docs.microsoft.com/windows-hardware/drivers/devtest/defect-viewer), which displays a trace of the code path to the rule violation. For more information, see [Interpreting Static Driver Verifier Results](https://docs.microsoft.com/windows-hardware/drivers/devtest/interpreting-static-driver-verifier-results).\n","tools/dv/samples/DV-FailDriver-WDM/README.md":"---\npage_type: sample\ndescription: \"Demonstrates how Driver Verifier (DV) can find errors in a WDM driver.\"\nlanguages:\n- cpp\nproducts:\n- windows\n- windows-wdk\n---\n\n# DV-FailDriver-WDM\n\nThe DV-FailDriver-WDM sample driver contains intentional code errors that are designed to show the capabilities and features of [Driver Verifier](https://docs.microsoft.com/windows-hardware/drivers/devtest/driver-verifier) (DV) and the [Device Fundamentals tests](https://docs.microsoft.com/windows-hardware/drivers/devtest/device-fundamentals-tests).  Driver Verifier is a component of the Windows kernel designed to detect drivers that are behaving poorly and stop their execution via a bugcheck; the Device Fundamentals tests are a series of tests provided in the Windows Driver Kit (WDK) designed to provide a good basic set of tests against a driver.\n\n> [!CAUTION]\n> This sample driver contains intentional code errors that are designed to show the capabilities and features of DV and SDV. This sample driver is not intended as an example for real driver development projects.\n\n## Build the sample for desktop\n\n1. In the **Solutions Explorer** window, select the driver solution (DV-FailDriver-WDM).\n\n1. From the **Build** menu, select **Build Solution**.\n\n## Deploy the sample\n\nSee [Deploying a Driver to a Test Computer](https://docs.microsoft.com/windows-hardware/drivers/develop/deploying-a-driver-to-a-test-computer) for details on how to deploy the sample.\n\n#### New\n\nIt is highly encouraged when testing a driver to use [DevGen](https://learn.microsoft.com/windows-hardware/drivers/devtest/devgen) to create a [SwDevice](https://learn.microsoft.com/windows/win32/api/_swdevice/).\n\n__DevGen Usage Example__\n\n1. From a terminal (running as admin) on test computer go to the WDK tools path and run `.\\devgen /add /bus SWD /hardwareid root\\defect_toastmon`. ***If WDK is not available on test computer, simply copy over `devgen.exe`***\n\n2. There is now a `Generic software device` available in the system. ***Use Device Manager as a simple means to inspect or from a terminal run `pnputil /enum-devices /deviceid \"root\\defect_toastmon\"`.***\n\n3. Now that there is a device with the appropriate hardware ID, deploy/install driver sample accordingly.\n\n> Note: Use `.\\devgen /remove \"<Device instance path>\"` to remove SW device (the path can be copied from output of `.\\devgen /add` or from Device Manager).\n>\n> Device instance path example `\"SWD\\DEVGEN\\{D0299946-2EC2-C146-B00B-E01144166F8B}\"`\n\n## Test the sample\n\nSee [How to test a driver at runtime](https://docs.microsoft.com/windows-hardware/drivers/develop/how-to-test-a-driver-at-runtime-from-a-command-prompt) for details on how to run tests on the Toastmon driver.\n\nTo observe the injected defect being caught by DV, you should enable DV on the Toastmon driver, and then run the \"DF - PNP Surprise Remove (Development and Integration)\" test on the Toastmon sample driver and device.\n","tools/kasan/samples/KasanDemo-WDM/README.md":"---\npage_type: sample\ndescription: \"Demonstrates KASAN.\"\nlanguages:\n- cpp\nproducts:\n- windows\n- windows-wdk\n---\n\n# KasanDemo\n\nThis sample demonstrates how KASAN detects illegal memory accesses.\n\nThe sample consists of a legacy device driver that contains intentionally incorrect code that performs illegal memory accesses, and a Win32 console agent that interacts with the driver to trigger different types of illegal memory accesses that KASAN successfully detects.\n\n> [!CAUTION]\n> This driver contains INTENTIONALLY INCORRECT code. Neither this driver nor its sample programs are intended for use in a production environment. Instead, they are intended for educational purposes.\n\n> [!CAUTION]\n> This driver will cause KASAN to bugcheck your system.\n\n## Run the sample\n\nTo run this sample, enable KASAN in your system, load the `kasantrigger.sys` driver, and then run the `kasanagent.exe` application.\n","tools/sdv/samples/SDV-FailDriver-KMDF/README.md":"---\npage_type: sample\ndescription: \"Demonstrates how Static Driver Verifier (SDV) can find errors in a KMDF driver.\"\nlanguages:\n- cpp\nproducts:\n- windows\n- windows-wdk\n---\n\n# SDV-FailDriver-KMDF\n\nThe SDV-FailDriver-KMDF sample driver contains intentional code errors that are designed to show the capabilities and features of [Static Driver Verifier](https://docs.microsoft.com/windows-hardware/drivers/devtest/static-driver-verifier) (SDV). SDV is a static verification tool that systematically analyzes the source code of Windows kernel-mode drivers. SDV is included in the Windows Driver Kit (WDK) and can be run from Microsoft Visual Studio. The sample demonstrates how SDV can find errors in a KMDF driver.\n\n> [!CAUTION]\n> These sample drivers contain intentional code errors that are designed to show the capabilities and features of SDV. These sample drivers are not functional and are not intended as examples for real driver development projects.\n\n## Run the sample\n\n1. In the **Solutions Explorer** window, select the driver project (fail\\_driver1).\n\n    From the **Driver** menu, click **Launch Static Driver Verifier...**.\n\n    This opens the Static Driver Verifier application, where you can control, configure, and schedule when Static Driver Verifier performs an analysis.\n\n1. The fail\\_driver1 sample driver includes a library. To add the library, click the **Libraries** tab and click **Add Library**.\n\n    Browse to the sample library directory and select the library project file (fail\\_library1.vcxProj). The library must be added before SDV analyzes the driver. For more information, see [Library Processing in Static Driver Verifier](https://docs.microsoft.com/windows-hardware/drivers/devtest/library-processing-in-static-driver-verifier).\n\n1. Click the **Rules** tab to select which driver DDI usage rules to verify when you start the analysis.\n\n    Static Driver Verifier detects the type of driver you are analyzing (WDF, WDM, NDIS, or Storport) and selects the default set of rules for your driver type. If this is the first time you are running SDV on your driver, you should run the default rule set. To shorten the amount of time it takes to analyze the fail\\_driver1 driver sample, you can select the **Custom rule selection**.\n\n    Use the default rule set, or select **Custom rule selection**, click **Clear All**, and then select the following rules for the KMDF fail\\_driver1 sample:\n\n    - [DriverCreate](https://docs.microsoft.com/windows-hardware/drivers/devtest/kmdf-drivercreate)\n\n    - [DeviceInitAPI](https://docs.microsoft.com/windows-hardware/drivers/devtest/kmdf-deviceinitapi)\n\n    - [CtlDeviceFinishInitDeviceAdd](https://docs.microsoft.com/windows-hardware/drivers/devtest/kmdf-ctldevicefinishinitdeviceadd)\n\n    - [MdlAfterReqCompletedIoctl](https://docs.microsoft.com/windows-hardware/drivers/devtest/kmdf-mdlafterreqcompletedioctl)\n\n    - [MemAfterReqCompletedIntIoctlA](https://docs.microsoft.com/windows-hardware/drivers/devtest/kmdf-memafterreqcompletedintioctla)\n\n    - [MdlAfterReqCompletedIntIoctlA](https://docs.microsoft.com/windows-hardware/drivers/devtest/kmdf-mdlafterreqcompletedintioctla)\n\n    - [MarkCancOnCancReqLocal](https://docs.microsoft.com/windows-hardware/drivers/devtest/kmdf-markcanconcancreqlocal)\n\n    - [StopAckWithinEvtIoStop](https://docs.microsoft.com/windows-hardware/drivers/devtest/kmdf-stopackwithinevtiostop)\n\n    For information about the rules, see [DDI Compliance Rules](https://docs.microsoft.com/windows-hardware/drivers/devtest/static-driver-verifier-rules).\n\n1. Start the static analysis. Click the **Main** tab, and then click **Start**. When you click **Start**, a message is displayed to let you know that static analysis is scheduled and that the analysis can take a long time to run. Click **OK** to continue.\n\n## View and analyze the results\n\nAs the static analysis proceeds, SDV reports the status of the analysis. When the analysis is complete, SDV reports the results and statistics. If the driver fails to satisfy a DDI usage rule, the result is reported as a defect. SDV finds 8 defects in this sample.\n\nOn the **Main** tab, under **Results**, click the **Rules** tab. This tab displays the name of each rule that was verified in the last run and the results of the analysis. To view the reported defects, click the **Defect** link in the **Results** column. This opens the [Static Driver Verifier Report Page](https://docs.microsoft.com/windows-hardware/drivers/devtest/static-driver-verifier-report) and the [Trace Viewer](https://docs.microsoft.com/windows-hardware/drivers/devtest/defect-viewer), which displays a trace of the code path to the rule violation. For more information, see [Interpreting Static Driver Verifier Results](https://docs.microsoft.com/windows-hardware/drivers/devtest/interpreting-static-driver-verifier-results).\n","tools/sdv/samples/SDV-FailDriver-STORPORT/README.md":"---\npage_type: sample\ndescription: \"Demonstrates how Static Driver Verifier (SDV) can find errors in a Storport driver.\"\nlanguages:\n- cpp\nproducts:\n- windows\n- windows-wdk\n---\n\n# SDV-FailDriver-STORPORT\n\nThe SDV-FailDriver-Storport sample driver contains intentional code errors that are designed to show the capabilities and features of [Static Driver Verifier](https://docs.microsoft.com/windows-hardware/drivers/devtest/static-driver-verifier) (SDV). SDV is a static verification tool that systematically analyzes the source code of Windows kernel-mode drivers. SDV is included in the Windows Driver Kit (WDK) and can be run from Microsoft Visual Studio. The sample demonstrates how SDV can find errors in a Storport driver.\n\n> [!CAUTION]\n> These sample drivers contain intentional code errors that are designed to show the capabilities and features of SDV. These sample drivers are not functional and are not intended as examples for real driver development projects.\n\n## Run the sample\n\n1. In the **Solutions Explorer** window, select the driver project (lsi\\_u3.vcxProj).\n\n    From the **Driver** menu, click **Launch Static Driver Verifier...**.\n\n    This opens the Static Driver Verifier application, where you can control, configure, and schedule when Static Driver Verifier performs an analysis.\n\n1. Click the **Rules** tab to select which driver DDI usage rules to verify when you start the analysis.\n\n    Static Driver Verifier detects the type of driver you are analyzing (WDF, WDM, NDIS, or Storport) and selects the default set of rules for your driver type. If this is the first time you are running SDV on your driver, you should run the default rule set. To shorten the amount of time it takes to analyze the sample driver, you can select the **Custom rule selection**.\n\n    Use the default rule set, or select **Custom rule selection**, click **Clear All**, and then select the following rules for the Storport sample:\n\n    - [StorPortAllocatePool2 Rule (Storport)](https://docs.microsoft.com/windows-hardware/drivers/devtest/storport-storportallocatepool2)\n\n    - [StorPortDeprecated Rule (Storport)](https://docs.microsoft.com/windows-hardware/drivers/devtest/storport-storportdeprecated)\n\n    - [StorPortEnablePassive Rule (Storport)](https://docs.microsoft.com/windows-hardware/drivers/devtest/storport-storportenablepassive)\n\n    - [StorPortNotification2 Rule (Storport)](https://docs.microsoft.com/windows-hardware/drivers/devtest/storport-storportnotification2)\n\n    - [StorPortSpinLock Rule (Storport)](https://docs.microsoft.com/windows-hardware/drivers/devtest/storport-storportspinlock)\n\n    - [StorPortStartIo Rule (Storport)](https://docs.microsoft.com/windows-hardware/drivers/devtest/storport-storportstartio)\n\n    - [StorPortStatusPending Rule (Storport)](https://docs.microsoft.com/windows-hardware/drivers/devtest/storport-storportstatuspending)\n\n    For information about the rules, see [DDI Compliance Rules](https://docs.microsoft.com/windows-hardware/drivers/devtest/static-driver-verifier-rules).\n\n1. Start the static analysis. Click the **Main** tab, and click **Start**. When you click **Start**, a message is displayed to let you know that static analysis is scheduled and that the analysis can take a long time to run. Click **OK** to continue.\n\n## View and analyze the results\n\nAs the static analysis proceeds, SDV reports the status of the analysis. When the analysis is complete, SDV reports the results and statistics. If the driver fails to satisfy a DDI usage rule, the result is reported as a defect. SDV finds 7 defects in this sample.\n\nOn the **Main** tab, under **Results**, click the **Rules** tab. This tab displays the name of each rule that was verified in the last run and the results of the analysis. To view the reported defects, click the **Defect** link in the **Results** column. This opens the [Static Driver Verifier Report Page](https://docs.microsoft.com/windows-hardware/drivers/devtest/static-driver-verifier-report) and the [Trace Viewer](https://docs.microsoft.com/windows-hardware/drivers/devtest/defect-viewer), which displays a trace of the code path to the rule violation. For more information, see [Interpreting Static Driver Verifier Results](https://docs.microsoft.com/windows-hardware/drivers/devtest/interpreting-static-driver-verifier-results).\n"},"items":[{"name":"README.md","path":"storage/tools/spti/README.md","rawUrl":"https://raw.githubusercontent.com/microsoft/Windows-driver-samples/HEAD/storage/tools/spti/README.md","title":"spti Documentation","category":"plugin-manifest","format":"markdown","content":"---\npage_type: sample\ndescription: \"Demonstrates how to communicate with a SCSI device using pass-through IOCTLs in an application using DeviceIoControl API.\"\nlanguages:\n- cpp\nproducts:\n- windows\n- windows-wdk\n---\n\n# SCSI Pass-Through Interface Tool\n\nThe SCSI Pass Through Interface sample demonstrates how to communicate with a SCSI device from Microsoft Win32 applications by using the **DeviceIoControl** API.\n\n## Installation and Operation\n\nThe storage port drivers provide an interface for Win32 applications to send SCSI CBDs (Command Descriptor Block) to SCSI devices. The interfaces are [**IOCTL\\_SCSI\\_PASS\\_THROUGH**](https://docs.microsoft.com/windows-hardware/drivers/ddi/content/ntddscsi/ni-ntddscsi-ioctl_scsi_pass_through) and [**IOCTL\\_SCSI\\_PASS\\_THROUGH\\_DIRECT**](https://docs.microsoft.com/windows-hardware/drivers/ddi/content/ntddscsi/ni-ntddscsi-ioctl_scsi_pass_through_direct). Applications can build a pass-through request and send it to the device by using this IOCTL.\n\nTwo command line parameters can be used with *SPTI.EXE*. The first parameter is mandatory. It is the name of the device to be opened. Typical values for this are drive letters such as \"C:\", or device names as defined by a class driver such as Scanner0, or the SCSI port driver name, ScsiN:, where N = 0, 1, 2, etc. The second parameter is optional and is used to set the share mode (note that access mode and share mode are different things) and sector size. The default share mode is (FILE\\_SHARE\\_READ | FILE\\_SHARE\\_WRITE) and the default sector size is 512. A parameter of \"r\" changes the share mode to only FILE\\_SHARE\\_READ. A parameter of \"w\" changes the share mode to only FILE\\_SHARE\\_WRITE. A parameter of \"c\" changes the share mode to only FILE\\_SHARE\\_READ and also changes the sector size to 2048. Typically, a CD-ROM device would use the \"c\" parameter.\n","frontmatter":{"page_type":"sample","description":"Demonstrates how to communicate with a SCSI device using pass-through IOCTLs in an application using DeviceIoControl API.","languages":["cpp"],"products":["windows","windows-wdk"]},"isInternal":false,"tokens":448,"sizeBytes":1862},{"name":"README.md","path":"tools/dv/samples/DV-FailDriver-WDM/README.md","rawUrl":"https://raw.githubusercontent.com/microsoft/Windows-driver-samples/HEAD/tools/dv/samples/DV-FailDriver-WDM/README.md","title":"DV-FailDriver-WDM Documentation","category":"plugin-manifest","format":"markdown","content":"---\npage_type: sample\ndescription: \"Demonstrates how Driver Verifier (DV) can find errors in a WDM driver.\"\nlanguages:\n- cpp\nproducts:\n- windows\n- windows-wdk\n---\n\n# DV-FailDriver-WDM\n\nThe DV-FailDriver-WDM sample driver contains intentional code errors that are designed to show the capabilities and features of [Driver Verifier](https://docs.microsoft.com/windows-hardware/drivers/devtest/driver-verifier) (DV) and the [Device Fundamentals tests](https://docs.microsoft.com/windows-hardware/drivers/devtest/device-fundamentals-tests).  Driver Verifier is a component of the Windows kernel designed to detect drivers that are behaving poorly and stop their execution via a bugcheck; the Device Fundamentals tests are a series of tests provided in the Windows Driver Kit (WDK) designed to provide a good basic set of tests against a driver.\n\n> [!CAUTION]\n> This sample driver contains intentional code errors that are designed to show the capabilities and features of DV and SDV. This sample driver is not intended as an example for real driver development projects.\n\n## Build the sample for desktop\n\n1. In the **Solutions Explorer** window, select the driver solution (DV-FailDriver-WDM).\n\n1. From the **Build** menu, select **Build Solution**.\n\n## Deploy the sample\n\nSee [Deploying a Driver to a Test Computer](https://docs.microsoft.com/windows-hardware/drivers/develop/deploying-a-driver-to-a-test-computer) for details on how to deploy the sample.\n\n#### New\n\nIt is highly encouraged when testing a driver to use [DevGen](https://learn.microsoft.com/windows-hardware/drivers/devtest/devgen) to create a [SwDevice](https://learn.microsoft.com/windows/win32/api/_swdevice/).\n\n__DevGen Usage Example__\n\n1. From a terminal (running as admin) on test computer go to the WDK tools path and run `.\\devgen /add /bus SWD /hardwareid root\\defect_toastmon`. ***If WDK is not available on test computer, simply copy over `devgen.exe`***\n\n2. There is now a `Generic software device` available in the system. ***Use Device Manager as a simple means to inspect or from a terminal run `pnputil /enum-devices /deviceid \"root\\defect_toastmon\"`.***\n\n3. Now that there is a device with the appropriate hardware ID, deploy/install driver sample accordingly.\n\n> Note: Use `.\\devgen /remove \"<Device instance path>\"` to remove SW device (the path can be copied from output of `.\\devgen /add` or from Device Manager).\n>\n> Device instance path example `\"SWD\\DEVGEN\\{D0299946-2EC2-C146-B00B-E01144166F8B}\"`\n\n## Test the sample\n\nSee [How to test a driver at runtime](https://docs.microsoft.com/windows-hardware/drivers/develop/how-to-test-a-driver-at-runtime-from-a-command-prompt) for details on how to run tests on the Toastmon driver.\n\nTo observe the injected defect being caught by DV, you should enable DV on the Toastmon driver, and then run the \"DF - PNP Surprise Remove (Development and Integration)\" test on the Toastmon sample driver and device.\n","frontmatter":{"page_type":"sample","description":"Demonstrates how Driver Verifier (DV) can find errors in a WDM driver.","languages":["cpp"],"products":["windows","windows-wdk"]},"isInternal":false,"tokens":690,"sizeBytes":2933},{"name":"README.md","path":"tools/kasan/samples/KasanDemo-WDM/README.md","rawUrl":"https://raw.githubusercontent.com/microsoft/Windows-driver-samples/HEAD/tools/kasan/samples/KasanDemo-WDM/README.md","title":"KasanDemo-WDM Documentation","category":"plugin-manifest","format":"markdown","content":"---\npage_type: sample\ndescription: \"Demonstrates KASAN.\"\nlanguages:\n- cpp\nproducts:\n- windows\n- windows-wdk\n---\n\n# KasanDemo\n\nThis sample demonstrates how KASAN detects illegal memory accesses.\n\nThe sample consists of a legacy device driver that contains intentionally incorrect code that performs illegal memory accesses, and a Win32 console agent that interacts with the driver to trigger different types of illegal memory accesses that KASAN successfully detects.\n\n> [!CAUTION]\n> This driver contains INTENTIONALLY INCORRECT code. Neither this driver nor its sample programs are intended for use in a production environment. Instead, they are intended for educational purposes.\n\n> [!CAUTION]\n> This driver will cause KASAN to bugcheck your system.\n\n## Run the sample\n\nTo run this sample, enable KASAN in your system, load the `kasantrigger.sys` driver, and then run the `kasanagent.exe` application.\n","frontmatter":{"page_type":"sample","description":"Demonstrates KASAN.","languages":["cpp"],"products":["windows","windows-wdk"]},"isInternal":false,"tokens":197,"sizeBytes":903},{"name":"README.md","path":"tools/sdv/samples/SDV-FailDriver-KMDF/README.md","rawUrl":"https://raw.githubusercontent.com/microsoft/Windows-driver-samples/HEAD/tools/sdv/samples/SDV-FailDriver-KMDF/README.md","title":"SDV-FailDriver-KMDF Documentation","category":"plugin-manifest","format":"markdown","content":"---\npage_type: sample\ndescription: \"Demonstrates how Static Driver Verifier (SDV) can find errors in a KMDF driver.\"\nlanguages:\n- cpp\nproducts:\n- windows\n- windows-wdk\n---\n\n# SDV-FailDriver-KMDF\n\nThe SDV-FailDriver-KMDF sample driver contains intentional code errors that are designed to show the capabilities and features of [Static Driver Verifier](https://docs.microsoft.com/windows-hardware/drivers/devtest/static-driver-verifier) (SDV). SDV is a static verification tool that systematically analyzes the source code of Windows kernel-mode drivers. SDV is included in the Windows Driver Kit (WDK) and can be run from Microsoft Visual Studio. The sample demonstrates how SDV can find errors in a KMDF driver.\n\n> [!CAUTION]\n> These sample drivers contain intentional code errors that are designed to show the capabilities and features of SDV. These sample drivers are not functional and are not intended as examples for real driver development projects.\n\n## Run the sample\n\n1. In the **Solutions Explorer** window, select the driver project (fail\\_driver1).\n\n    From the **Driver** menu, click **Launch Static Driver Verifier...**.\n\n    This opens the Static Driver Verifier application, where you can control, configure, and schedule when Static Driver Verifier performs an analysis.\n\n1. The fail\\_driver1 sample driver includes a library. To add the library, click the **Libraries** tab and click **Add Library**.\n\n    Browse to the sample library directory and select the library project file (fail\\_library1.vcxProj). The library must be added before SDV analyzes the driver. For more information, see [Library Processing in Static Driver Verifier](https://docs.microsoft.com/windows-hardware/drivers/devtest/library-processing-in-static-driver-verifier).\n\n1. Click the **Rules** tab to select which driver DDI usage rules to verify when you start the analysis.\n\n    Static Driver Verifier detects the type of driver you are analyzing (WDF, WDM, NDIS, or Storport) and selects the default set of rules for your driver type. If this is the first time you are running SDV on your driver, you should run the default rule set. To shorten the amount of time it takes to analyze the fail\\_driver1 driver sample, you can select the **Custom rule selection**.\n\n    Use the default rule set, or select **Custom rule selection**, click **Clear All**, and then select the following rules for the KMDF fail\\_driver1 sample:\n\n    - [DriverCreate](https://docs.microsoft.com/windows-hardware/drivers/devtest/kmdf-drivercreate)\n\n    - [DeviceInitAPI](https://docs.microsoft.com/windows-hardware/drivers/devtest/kmdf-deviceinitapi)\n\n    - [CtlDeviceFinishInitDeviceAdd](https://docs.microsoft.com/windows-hardware/drivers/devtest/kmdf-ctldevicefinishinitdeviceadd)\n\n    - [MdlAfterReqCompletedIoctl](https://docs.microsoft.com/windows-hardware/drivers/devtest/kmdf-mdlafterreqcompletedioctl)\n\n    - [MemAfterReqCompletedIntIoctlA](https://docs.microsoft.com/windows-hardware/drivers/devtest/kmdf-memafterreqcompletedintioctla)\n\n    - [MdlAfterReqCompletedIntIoctlA](https://docs.microsoft.com/windows-hardware/drivers/devtest/kmdf-mdlafterreqcompletedintioctla)\n\n    - [MarkCancOnCancReqLocal](https://docs.microsoft.com/windows-hardware/drivers/devtest/kmdf-markcanconcancreqlocal)\n\n    - [StopAckWithinEvtIoStop](https://docs.microsoft.com/windows-hardware/drivers/devtest/kmdf-stopackwithinevtiostop)\n\n    For information about the rules, see [DDI Compliance Rules](https://docs.microsoft.com/windows-hardware/drivers/devtest/static-driver-verifier-rules).\n\n1. Start the static analysis. Click the **Main** tab, and then click **Start**. When you click **Start**, a message is displayed to let you know that static analysis is scheduled and that the analysis can take a long time to run. Click **OK** to continue.\n\n## View and analyze the results\n\nAs the static analysis proceeds, SDV reports the status of the analysis. When the analysis is complete, SDV reports the results and statistics. If the driver fails to satisfy a DDI usage rule, the result is reported as a defect. SDV finds 8 defects in this sample.\n\nOn the **Main** tab, under **Results**, click the **Rules** tab. This tab displays the name of each rule that was verified in the last run and the results of the analysis. To view the reported defects, click the **Defect** link in the **Results** column. This opens the [Static Driver Verifier Report Page](https://docs.microsoft.com/windows-hardware/drivers/devtest/static-driver-verifier-report) and the [Trace Viewer](https://docs.microsoft.com/windows-hardware/drivers/devtest/defect-viewer), which displays a trace of the code path to the rule violation. For more information, see [Interpreting Static Driver Verifier Results](https://docs.microsoft.com/windows-hardware/drivers/devtest/interpreting-static-driver-verifier-results).\n","frontmatter":{"page_type":"sample","description":"Demonstrates how Static Driver Verifier (SDV) can find errors in a KMDF driver.","languages":["cpp"],"products":["windows","windows-wdk"]},"isInternal":false,"tokens":1097,"sizeBytes":4846},{"name":"README.md","path":"tools/sdv/samples/SDV-FailDriver-NDIS/README.md","rawUrl":"https://raw.githubusercontent.com/microsoft/Windows-driver-samples/HEAD/tools/sdv/samples/SDV-FailDriver-NDIS/README.md","title":"SDV-FailDriver-NDIS Documentation","category":"plugin-manifest","format":"markdown","content":"---\npage_type: sample\ndescription: \"Demonstrates how Static Driver Verifier (SDV) can find errors in a NDIS driver.\"\nlanguages:\n- cpp\nproducts:\n- windows\n- windows-wdk\n---\n\n# SDV-FailDriver-NDIS\n\nThe SDV-FailDriver-NDIS sample driver contains intentional code errors that are designed to show the capabilities and features of [Static Driver Verifier](https://docs.microsoft.com/windows-hardware/drivers/devtest/static-driver-verifier) (SDV). SDV is a static verification tool that systematically analyzes the source code of Windows kernel-mode drivers. SDV is included in the Windows Driver Kit (WDK) and can be run from Microsoft Visual Studio. The sample demonstrates how SDV can find errors in an NDIS driver.\n\n> [!CAUTION]\n> These sample drivers contain intentional code errors that are designed to show the capabilities and features of SDV. These sample drivers are not functional and are not intended as examples for real driver development projects.\n\n## Run the sample\n\n1. In the **Solutions Explorer** window, select the driver project (sdvmp.vcxProj).\n\n    From the **Driver** menu, click **Launch Static Driver Verifier...**.\n\n    This opens the Static Driver Verifier application, where you can control, configure, and schedule when Static Driver Verifier performs an analysis.\n\n1. Click the **Rules** tab to select which driver DDI usage rules to verify when you start the analysis.\n\n    Static Driver Verifier detects the type of driver you are analyzing (WDF, WDM, NDIS, or Storport) and selects the default set of rules for your driver type. If this is the first time you are running SDV on your driver, you should run the default rule set. To shorten the amount of time it takes to analyze the sample driver, you can select the **Custom rule selection**.\n\n    Use the default rule set, or select **Custom rule selection**, click **Clear All**, and then select the following rules for the NDIS sdvmp sample:\n\n    - [NdisAllocateMemoryWithTagPriority](https://docs.microsoft.com/windows-hardware/drivers/devtest/ndis-ndisallocatememorywithtagpriority)\n\n    - [Init\\_RegisterSG](https://docs.microsoft.com/windows-hardware/drivers/devtest/ndis-init-registersg)\n\n    - [NdisStallExecution\\_Delay](https://docs.microsoft.com/windows-hardware/drivers/devtest/ndis-ndisstallexecution-delay)\n\n    - [Flags\\_Irql](https://docs.microsoft.com/windows-hardware/drivers/devtest/ndis-flags-irql)\n\n    - [Irql\\_Synch\\_Function](https://docs.microsoft.com/windows-hardware/drivers/devtest/ndis-irql-synch-function)\n\n    For information about the rules, see [DDI Compliance Rules](https://docs.microsoft.com/windows-hardware/drivers/devtest/static-driver-verifier-rules).\n\n1. Start the static analysis. Click the **Main** tab, and click **Start**. When you click **Start**, a message is displayed to let you know that static analysis is scheduled and that the analysis can take a long time to run. Click **OK** to continue.\n\n## View and analyze the results\n\nAs the static analysis proceeds, SDV reports the status of the analysis. When the analysis is complete, SDV reports the results and statistics. If the driver fails to satisfy a DDI usage rule, the result is reported as a defect. SDV finds 5 defects in this sample.\n\nOn the **Main** tab, under **Results**, click the **Rules** tab. This tab displays the name of each rule that was verified in the last run and the results of the analysis. To view the reported defects, click the **Defect** link in the **Results** column. This opens the [Static Driver Verifier Report Page](https://docs.microsoft.com/windows-hardware/drivers/devtest/static-driver-verifier-report) and the [Trace Viewer](https://docs.microsoft.com/windows-hardware/drivers/devtest/defect-viewer), which displays a trace of the code path to the rule violation. For more information, see [Interpreting Static Driver Verifier Results](https://docs.microsoft.com/windows-hardware/drivers/devtest/interpreting-static-driver-verifier-results).\n","frontmatter":{"page_type":"sample","description":"Demonstrates how Static Driver Verifier (SDV) can find errors in a NDIS driver.","languages":["cpp"],"products":["windows","windows-wdk"]},"isInternal":false,"tokens":898,"sizeBytes":3961},{"name":"README.md","path":"tools/sdv/samples/SDV-FailDriver-STORPORT/README.md","rawUrl":"https://raw.githubusercontent.com/microsoft/Windows-driver-samples/HEAD/tools/sdv/samples/SDV-FailDriver-STORPORT/README.md","title":"SDV-FailDriver-STORPORT Documentation","category":"plugin-manifest","format":"markdown","content":"---\npage_type: sample\ndescription: \"Demonstrates how Static Driver Verifier (SDV) can find errors in a Storport driver.\"\nlanguages:\n- cpp\nproducts:\n- windows\n- windows-wdk\n---\n\n# SDV-FailDriver-STORPORT\n\nThe SDV-FailDriver-Storport sample driver contains intentional code errors that are designed to show the capabilities and features of [Static Driver Verifier](https://docs.microsoft.com/windows-hardware/drivers/devtest/static-driver-verifier) (SDV). SDV is a static verification tool that systematically analyzes the source code of Windows kernel-mode drivers. SDV is included in the Windows Driver Kit (WDK) and can be run from Microsoft Visual Studio. The sample demonstrates how SDV can find errors in a Storport driver.\n\n> [!CAUTION]\n> These sample drivers contain intentional code errors that are designed to show the capabilities and features of SDV. These sample drivers are not functional and are not intended as examples for real driver development projects.\n\n## Run the sample\n\n1. In the **Solutions Explorer** window, select the driver project (lsi\\_u3.vcxProj).\n\n    From the **Driver** menu, click **Launch Static Driver Verifier...**.\n\n    This opens the Static Driver Verifier application, where you can control, configure, and schedule when Static Driver Verifier performs an analysis.\n\n1. Click the **Rules** tab to select which driver DDI usage rules to verify when you start the analysis.\n\n    Static Driver Verifier detects the type of driver you are analyzing (WDF, WDM, NDIS, or Storport) and selects the default set of rules for your driver type. If this is the first time you are running SDV on your driver, you should run the default rule set. To shorten the amount of time it takes to analyze the sample driver, you can select the **Custom rule selection**.\n\n    Use the default rule set, or select **Custom rule selection**, click **Clear All**, and then select the following rules for the Storport sample:\n\n    - [StorPortAllocatePool2 Rule (Storport)](https://docs.microsoft.com/windows-hardware/drivers/devtest/storport-storportallocatepool2)\n\n    - [StorPortDeprecated Rule (Storport)](https://docs.microsoft.com/windows-hardware/drivers/devtest/storport-storportdeprecated)\n\n    - [StorPortEnablePassive Rule (Storport)](https://docs.microsoft.com/windows-hardware/drivers/devtest/storport-storportenablepassive)\n\n    - [StorPortNotification2 Rule (Storport)](https://docs.microsoft.com/windows-hardware/drivers/devtest/storport-storportnotification2)\n\n    - [StorPortSpinLock Rule (Storport)](https://docs.microsoft.com/windows-hardware/drivers/devtest/storport-storportspinlock)\n\n    - [StorPortStartIo Rule (Storport)](https://docs.microsoft.com/windows-hardware/drivers/devtest/storport-storportstartio)\n\n    - [StorPortStatusPending Rule (Storport)](https://docs.microsoft.com/windows-hardware/drivers/devtest/storport-storportstatuspending)\n\n    For information about the rules, see [DDI Compliance Rules](https://docs.microsoft.com/windows-hardware/drivers/devtest/static-driver-verifier-rules).\n\n1. Start the static analysis. Click the **Main** tab, and click **Start**. When you click **Start**, a message is displayed to let you know that static analysis is scheduled and that the analysis can take a long time to run. Click **OK** to continue.\n\n## View and analyze the results\n\nAs the static analysis proceeds, SDV reports the status of the analysis. When the analysis is complete, SDV reports the results and statistics. If the driver fails to satisfy a DDI usage rule, the result is reported as a defect. SDV finds 7 defects in this sample.\n\nOn the **Main** tab, under **Results**, click the **Rules** tab. This tab displays the name of each rule that was verified in the last run and the results of the analysis. To view the reported defects, click the **Defect** link in the **Results** column. This opens the [Static Driver Verifier Report Page](https://docs.microsoft.com/windows-hardware/drivers/devtest/static-driver-verifier-report) and the [Trace Viewer](https://docs.microsoft.com/windows-hardware/drivers/devtest/defect-viewer), which displays a trace of the code path to the rule violation. For more information, see [Interpreting Static Driver Verifier Results](https://docs.microsoft.com/windows-hardware/drivers/devtest/interpreting-static-driver-verifier-results).\n","frontmatter":{"page_type":"sample","description":"Demonstrates how Static Driver Verifier (SDV) can find errors in a Storport driver.","languages":["cpp"],"products":["windows","windows-wdk"]},"isInternal":false,"tokens":990,"sizeBytes":4329},{"name":"README.md","path":"tools/sdv/samples/SDV-FailDriver-WDM/README.md","rawUrl":"https://raw.githubusercontent.com/microsoft/Windows-driver-samples/HEAD/tools/sdv/samples/SDV-FailDriver-WDM/README.md","title":"SDV-FailDriver-WDM Documentation","category":"plugin-manifest","format":"markdown","content":"---\npage_type: sample\ndescription: \"Demonstrates how Static Driver Verifier (SDV) can find errors in a WDM driver.\"\nlanguages:\n- cpp\nproducts:\n- windows\n- windows-wdk\n---\n\n# SDV-FailDriver-WDM\n\nThe SDV-FailDriver-WDM sample driver contains intentional code errors that are designed to show the capabilities and features of [Static Driver Verifier](https://docs.microsoft.com/windows-hardware/drivers/devtest/static-driver-verifier) (SDV). SDV is a static verification tool that systematically analyzes the source code of Windows kernel-mode drivers. SDV is included in the Windows Driver Kit (WDK) and can be run from Microsoft Visual Studio. The sample demonstrates how SDV can find errors in a WDM driver.\n\n> [!CAUTION]\n> These sample drivers contain intentional code errors that are designed to show the capabilities and features of SDV. These sample drivers are not functional and are not intended as examples for real driver development projects.\n\n## Run the sample\n\n1. In the **Solutions Explorer** window, select the driver project (fail\\_driver1).\n\n    From the **Driver** menu, click **Launch Static Driver Verifier...**.\n\n    This opens the Static Driver Verifier application, where you can control, configure, and schedule when Static Driver Verifier performs an analysis.\n\n1. Click the **Rules** tab to select which driver DDI usage rules to verify when you start the analysis.\n\n    Static Driver Verifier detects the type of driver you are analyzing (WDF, WDM, NDIS, or Storport) and selects the default set of rules for your driver type. If this is the first time you are running SDV on your driver, you should run the default rule set. To shorten the amount of time it takes to analyze the fail\\_driver1 driver sample, you can select the **Custom rule selection**.\n\n    Use the default rule set, or select **Custom rule selection**, click **Clear All**, and then select the following rules for the WDM fail\\_driver1 sample:\n\n    - [CancelSpinLock](https://docs.microsoft.com/windows-hardware/drivers/devtest/wdm-cancelspinlock)\n\n    - [IrqlIoApcLte](https://docs.microsoft.com/windows-hardware/drivers/devtest/wdm-irqlioapclte)\n\n    - [IrqlKeSetEvent](https://docs.microsoft.com/windows-hardware/drivers/devtest/wdm-irqlkesetevent)\n\n    - [LowerDriverReturn](https://docs.microsoft.com/windows-hardware/drivers/devtest/wdm-lowerdriverreturn)\n\n    - [SpinLock (WDM)](https://docs.microsoft.com/windows-hardware/drivers/devtest/wdm-spinlock)\n\n    For information about the rules, see [DDI Compliance Rules](https://docs.microsoft.com/windows-hardware/drivers/devtest/static-driver-verifier-rules).\n\n1. Start the static analysis. Click the **Main** tab, and click **Start**. When you click **Start**, a message is displayed to let you know that static analysis is scheduled and that the analysis can take a long time to run. Click **OK** to continue.\n\n## View and analyze the results\n\nAs the static analysis proceeds, SDV reports the status of the analysis. When the analysis is complete, SDV reports the results and statistics. If the driver fails to satisfy a DDI usage rule, the result is reported as a defect. SDV finds 5 defects in this sample.\n\nOn the **Main** tab, under **Results**, click the **Rules** tab. This tab displays the name of each rule that was verified in the last run and the results of the analysis. To view the reported defects, click the **Defect** link in the **Results** column. This opens the [Static Driver Verifier Report Page](https://docs.microsoft.com/windows-hardware/drivers/devtest/static-driver-verifier-report) and the [Trace Viewer](https://docs.microsoft.com/windows-hardware/drivers/devtest/defect-viewer), which displays a trace of the code path to the rule violation. For more information, see [Interpreting Static Driver Verifier Results](https://docs.microsoft.com/windows-hardware/drivers/devtest/interpreting-static-driver-verifier-results).\n","frontmatter":{"page_type":"sample","description":"Demonstrates how Static Driver Verifier (SDV) can find errors in a WDM driver.","languages":["cpp"],"products":["windows","windows-wdk"]},"isInternal":false,"tokens":881,"sizeBytes":3901}],"systemPromptSnippet":"<yakaai_skills repo=\"microsoft/Windows-driver-samples\">\n<!-- File: storage/tools/spti/README.md (Tokens: ~448 | Category: plugin-manifest) -->\n---\npage_type: sample\ndescription: \"Demonstrates how to communicate with a SCSI device using pass-through IOCTLs in an application using DeviceIoControl API.\"\nlanguages:\n- cpp\nproducts:\n- windows\n- windows-wdk\n---\n\n# SCSI Pass-Through Interface Tool\n\nThe SCSI Pass Through Interface sample demonstrates how to communicate with a SCSI device from Microsoft Win32 applications by using the **DeviceIoControl** API.\n\n## Installation and Operation\n\nThe storage port drivers provide an interface for Win32 applications to send SCSI CBDs (Command Descriptor Block) to SCSI devices. The interfaces are [**IOCTL\\_SCSI\\_PASS\\_THROUGH**](https://docs.microsoft.com/windows-hardware/drivers/ddi/content/ntddscsi/ni-ntddscsi-ioctl_scsi_pass_through) and [**IOCTL\\_SCSI\\_PASS\\_THROUGH\\_DIRECT**](https://docs.microsoft.com/windows-hardware/drivers/ddi/content/ntddscsi/ni-ntddscsi-ioctl_scsi_pass_through_direct). Applications can build a pass-through request and send it to the device by using this IOCTL.\n\nTwo command line parameters can be used with *SPTI.EXE*. The first parameter is mandatory. It is the name of the device to be opened. Typical values for this are drive letters such as \"C:\", or device names as defined by a class driver such as Scanner0, or the SCSI port driver name, ScsiN:, where N = 0, 1, 2, etc. The second parameter is optional and is used to set the share mode (note that access mode and share mode are different things) and sector size. The default share mode is (FILE\\_SHARE\\_READ | FILE\\_SHARE\\_WRITE) and the default sector size is 512. A parameter of \"r\" changes the share mode to only FILE\\_SHARE\\_READ. A parameter of \"w\" changes the share mode to only FILE\\_SHARE\\_WRITE. A parameter of \"c\" changes the share mode to only FILE\\_SHARE\\_READ and also changes the sector size to 2048. Typically, a CD-ROM device would use the \"c\" parameter.\n\n<!-- File: tools/dv/samples/DV-FailDriver-WDM/README.md (Tokens: ~690 | Category: plugin-manifest) -->\n---\npage_type: sample\ndescription: \"Demonstrates how Driver Verifier (DV) can find errors in a WDM driver.\"\nlanguages:\n- cpp\nproducts:\n- windows\n- windows-wdk\n---\n\n# DV-FailDriver-WDM\n\nThe DV-FailDriver-WDM sample driver contains intentional code errors that are designed to show the capabilities and features of [Driver Verifier](https://docs.microsoft.com/windows-hardware/drivers/devtest/driver-verifier) (DV) and the [Device Fundamentals tests](https://docs.microsoft.com/windows-hardware/drivers/devtest/device-fundamentals-tests).  Driver Verifier is a component of the Windows kernel designed to detect drivers that are behaving poorly and stop their execution via a bugcheck; the Device Fundamentals tests are a series of tests provided in the Windows Driver Kit (WDK) designed to provide a good basic set of tests against a driver.\n\n> [!CAUTION]\n> This sample driver contains intentional code errors that are designed to show the capabilities and features of DV and SDV. This sample driver is not intended as an example for real driver development projects.\n\n## Build the sample for desktop\n\n1. In the **Solutions Explorer** window, select the driver solution (DV-FailDriver-WDM).\n\n1. From the **Build** menu, select **Build Solution**.\n\n## Deploy the sample\n\nSee [Deploying a Driver to a Test Computer](https://docs.microsoft.com/windows-hardware/drivers/develop/deploying-a-driver-to-a-test-computer) for details on how to deploy the sample.\n\n#### New\n\nIt is highly encouraged when testing a driver to use [DevGen](https://learn.microsoft.com/windows-hardware/drivers/devtest/devgen) to create a [SwDevice](https://learn.microsoft.com/windows/win32/api/_swdevice/).\n\n__DevGen Usage Example__\n\n1. From a terminal (running as admin) on test computer go to the WDK tools path and run `.\\devgen /add /bus SWD /hardwareid root\\defect_toastmon`. ***If WDK is not available on test computer, simply copy over `devgen.exe`***\n\n2. There is now a `Generic software device` available in the system. ***Use Device Manager as a simple means to inspect or from a terminal run `pnputil /enum-devices /deviceid \"root\\defect_toastmon\"`.***\n\n3. Now that there is a device with the appropriate hardware ID, deploy/install driver sample accordingly.\n\n> Note: Use `.\\devgen /remove \"<Device instance path>\"` to remove SW device (the path can be copied from output of `.\\devgen /add` or from Device Manager).\n>\n> Device instance path example `\"SWD\\DEVGEN\\{D0299946-2EC2-C146-B00B-E01144166F8B}\"`\n\n## Test the sample\n\nSee [How to test a driver at runtime](https://docs.microsoft.com/windows-hardware/drivers/develop/how-to-test-a-driver-at-runtime-from-a-command-prompt) for details on how to run tests on the Toastmon driver.\n\nTo observe the injected defect being caught by DV, you should enable DV on the Toastmon driver, and then run the \"DF - PNP Surprise Remove (Development and Integration)\" test on the Toastmon sample driver and device.\n\n<!-- File: tools/kasan/samples/KasanDemo-WDM/README.md (Tokens: ~197 | Category: plugin-manifest) -->\n---\npage_type: sample\ndescription: \"Demonstrates KASAN.\"\nlanguages:\n- cpp\nproducts:\n- windows\n- windows-wdk\n---\n\n# KasanDemo\n\nThis sample demonstrates how KASAN detects illegal memory accesses.\n\nThe sample consists of a legacy device driver that contains intentionally incorrect code that performs illegal memory accesses, and a Win32 console agent that interacts with the driver to trigger different types of illegal memory accesses that KASAN successfully detects.\n\n> [!CAUTION]\n> This driver contains INTENTIONALLY INCORRECT code. Neither this driver nor its sample programs are intended for use in a production environment. Instead, they are intended for educational purposes.\n\n> [!CAUTION]\n> This driver will cause KASAN to bugcheck your system.\n\n## Run the sample\n\nTo run this sample, enable KASAN in your system, load the `kasantrigger.sys` driver, and then run the `kasanagent.exe` application.\n\n<!-- File: tools/sdv/samples/SDV-FailDriver-KMDF/README.md (Tokens: ~1097 | Category: plugin-manifest) -->\n---\npage_type: sample\ndescription: \"Demonstrates how Static Driver Verifier (SDV) can find errors in a KMDF driver.\"\nlanguages:\n- cpp\nproducts:\n- windows\n- windows-wdk\n---\n\n# SDV-FailDriver-KMDF\n\nThe SDV-FailDriver-KMDF sample driver contains intentional code errors that are designed to show the capabilities and features of [Static Driver Verifier](https://docs.microsoft.com/windows-hardware/drivers/devtest/static-driver-verifier) (SDV). SDV is a static verification tool that systematically analyzes the source code of Windows kernel-mode drivers. SDV is included in the Windows Driver Kit (WDK) and can be run from Microsoft Visual Studio. The sample demonstrates how SDV can find errors in a KMDF driver.\n\n> [!CAUTION]\n> These sample drivers contain intentional code errors that are designed to show the capabilities and features of SDV. These sample drivers are not functional and are not intended as examples for real driver development projects.\n\n## Run the sample\n\n1. In the **Solutions Explorer** window, select the driver project (fail\\_driver1).\n\n    From the **Driver** menu, click **Launch Static Driver Verifier...**.\n\n    This opens the Static Driver Verifier application, where you can control, configure, and schedule when Static Driver Verifier performs an analysis.\n\n1. The fail\\_driver1 sample driver includes a library. To add the library, click the **Libraries** tab and click **Add Library**.\n\n    Browse to the sample library directory and select the library project file (fail\\_library1.vcxProj). The library must be added before SDV analyzes the driver. For more information, see [Library Processing in Static Driver Verifier](https://docs.microsoft.com/windows-hardware/drivers/devtest/library-processing-in-static-driver-verifier).\n\n1. Click the **Rules** tab to select which driver DDI usage rules to verify when you start the analysis.\n\n    Static Driver Verifier detects the type of driver you are analyzing (WDF, WDM, NDIS, or Storport) and selects the default set of rules for your driver type. If this is the first time you are running SDV on your driver, you should run the default rule set. To shorten the amount of time it takes to analyze the fail\\_driver1 driver sample, you can select the **Custom rule selection**.\n\n    Use the default rule set, or select **Custom rule selection**, click **Clear All**, and then select the following rules for the KMDF fail\\_driver1 sample:\n\n    - [DriverCreate](https://docs.microsoft.com/windows-hardware/drivers/devtest/kmdf-drivercreate)\n\n    - [DeviceInitAPI](https://docs.microsoft.com/windows-hardware/drivers/devtest/kmdf-deviceinitapi)\n\n    - [CtlDeviceFinishInitDeviceAdd](https://docs.microsoft.com/windows-hardware/drivers/devtest/kmdf-ctldevicefinishinitdeviceadd)\n\n    - [MdlAfterReqCompletedIoctl](https://docs.microsoft.com/windows-hardware/drivers/devtest/kmdf-mdlafterreqcompletedioctl)\n\n    - [MemAfterReqCompletedIntIoctlA](https://docs.microsoft.com/windows-hardware/drivers/devtest/kmdf-memafterreqcompletedintioctla)\n\n    - [MdlAfterReqCompletedIntIoctlA](https://docs.microsoft.com/windows-hardware/drivers/devtest/kmdf-mdlafterreqcompletedintioctla)\n\n    - [MarkCancOnCancReqLocal](https://docs.microsoft.com/windows-hardware/drivers/devtest/kmdf-markcanconcancreqlocal)\n\n    - [StopAckWithinEvtIoStop](https://docs.microsoft.com/windows-hardware/drivers/devtest/kmdf-stopackwithinevtiostop)\n\n    For information about the rules, see [DDI Compliance Rules](https://docs.microsoft.com/windows-hardware/drivers/devtest/static-driver-verifier-rules).\n\n1. Start the static analysis. Click the **Main** tab, and then click **Start**. When you click **Start**, a message is displayed to let you know that static analysis is scheduled and that the analysis can take a long time to run. Click **OK** to continue.\n\n## View and analyze the results\n\nAs the static analysis proceeds, SDV reports the status of the analysis. When the analysis is complete, SDV reports the results and statistics. If the driver fails to satisfy a DDI usage rule, the result is reported as a defect. SDV finds 8 defects in this sample.\n\nOn the **Main** tab, under **Results**, click the **Rules** tab. This tab displays the name of each rule that was verified in the last run and the results of the analysis. To view the reported defects, click the **Defect** link in the **Results** column. This opens the [Static Driver Verifier Report Page](https://docs.microsoft.com/windows-hardware/drivers/devtest/static-driver-verifier-report) and the [Trace Viewer](https://docs.microsoft.com/windows-hardware/drivers/devtest/defect-viewer), which displays a trace of the code path to the rule violation. For more information, see [Interpreting Static Driver Verifier Results](https://docs.microsoft.com/windows-hardware/drivers/devtest/interpreting-static-driver-verifier-results).\n\n<!-- File: tools/sdv/samples/SDV-FailDriver-NDIS/README.md (Tokens: ~898 | Category: plugin-manifest) -->\n---\npage_type: sample\ndescription: \"Demonstrates how Static Driver Verifier (SDV) can find errors in a NDIS driver.\"\nlanguages:\n- cpp\nproducts:\n- windows\n- windows-wdk\n---\n\n# SDV-FailDriver-NDIS\n\nThe SDV-FailDriver-NDIS sample driver contains intentional code errors that are designed to show the capabilities and features of [Static Driver Verifier](https://docs.microsoft.com/windows-hardware/drivers/devtest/static-driver-verifier) (SDV). SDV is a static verification tool that systematically analyzes the source code of Windows kernel-mode drivers. SDV is included in the Windows Driver Kit (WDK) and can be run from Microsoft Visual Studio. The sample demonstrates how SDV can find errors in an NDIS driver.\n\n> [!CAUTION]\n> These sample drivers contain intentional code errors that are designed to show the capabilities and features of SDV. These sample drivers are not functional and are not intended as examples for real driver development projects.\n\n## Run the sample\n\n1. In the **Solutions Explorer** window, select the driver project (sdvmp.vcxProj).\n\n    From the **Driver** menu, click **Launch Static Driver Verifier...**.\n\n    This opens the Static Driver Verifier application, where you can control, configure, and schedule when Static Driver Verifier performs an analysis.\n\n1. Click the **Rules** tab to select which driver DDI usage rules to verify when you start the analysis.\n\n    Static Driver Verifier detects the type of driver you are analyzing (WDF, WDM, NDIS, or Storport) and selects the default set of rules for your driver type. If this is the first time you are running SDV on your driver, you should run the default rule set. To shorten the amount of time it takes to analyze the sample driver, you can select the **Custom rule selection**.\n\n    Use the default rule set, or select **Custom rule selection**, click **Clear All**, and then select the following rules for the NDIS sdvmp sample:\n\n    - [NdisAllocateMemoryWithTagPriority](https://docs.microsoft.com/windows-hardware/drivers/devtest/ndis-ndisallocatememorywithtagpriority)\n\n    - [Init\\_RegisterSG](https://docs.microsoft.com/windows-hardware/drivers/devtest/ndis-init-registersg)\n\n    - [NdisStallExecution\\_Delay](https://docs.microsoft.com/windows-hardware/drivers/devtest/ndis-ndisstallexecution-delay)\n\n    - [Flags\\_Irql](https://docs.microsoft.com/windows-hardware/drivers/devtest/ndis-flags-irql)\n\n    - [Irql\\_Synch\\_Function](https://docs.microsoft.com/windows-hardware/drivers/devtest/ndis-irql-synch-function)\n\n    For information about the rules, see [DDI Compliance Rules](https://docs.microsoft.com/windows-hardware/drivers/devtest/static-driver-verifier-rules).\n\n1. Start the static analysis. Click the **Main** tab, and click **Start**. When you click **Start**, a message is displayed to let you know that static analysis is scheduled and that the analysis can take a long time to run. Click **OK** to continue.\n\n## View and analyze the results\n\nAs the static analysis proceeds, SDV reports the status of the analysis. When the analysis is complete, SDV reports the results and statistics. If the driver fails to satisfy a DDI usage rule, the result is reported as a defect. SDV finds 5 defects in this sample.\n\nOn the **Main** tab, under **Results**, click the **Rules** tab. This tab displays the name of each rule that was verified in the last run and the results of the analysis. To view the reported defects, click the **Defect** link in the **Results** column. This opens the [Static Driver Verifier Report Page](https://docs.microsoft.com/windows-hardware/drivers/devtest/static-driver-verifier-report) and the [Trace Viewer](https://docs.microsoft.com/windows-hardware/drivers/devtest/defect-viewer), which displays a trace of the code path to the rule violation. For more information, see [Interpreting Static Driver Verifier Results](https://docs.microsoft.com/windows-hardware/drivers/devtest/interpreting-static-driver-verifier-results).\n\n<!-- File: tools/sdv/samples/SDV-FailDriver-STORPORT/README.md (Tokens: ~990 | Category: plugin-manifest) -->\n---\npage_type: sample\ndescription: \"Demonstrates how Static Driver Verifier (SDV) can find errors in a Storport driver.\"\nlanguages:\n- cpp\nproducts:\n- windows\n- windows-wdk\n---\n\n# SDV-FailDriver-STORPORT\n\nThe SDV-FailDriver-Storport sample driver contains intentional code errors that are designed to show the capabilities and features of [Static Driver Verifier](https://docs.microsoft.com/windows-hardware/drivers/devtest/static-driver-verifier) (SDV). SDV is a static verification tool that systematically analyzes the source code of Windows kernel-mode drivers. SDV is included in the Windows Driver Kit (WDK) and can be run from Microsoft Visual Studio. The sample demonstrates how SDV can find errors in a Storport driver.\n\n> [!CAUTION]\n> These sample drivers contain intentional code errors that are designed to show the capabilities and features of SDV. These sample drivers are not functional and are not intended as examples for real driver development projects.\n\n## Run the sample\n\n1. In the **Solutions Explorer** window, select the driver project (lsi\\_u3.vcxProj).\n\n    From the **Driver** menu, click **Launch Static Driver Verifier...**.\n\n    This opens the Static Driver Verifier application, where you can control, configure, and schedule when Static Driver Verifier performs an analysis.\n\n1. Click the **Rules** tab to select which driver DDI usage rules to verify when you start the analysis.\n\n    Static Driver Verifier detects the type of driver you are analyzing (WDF, WDM, NDIS, or Storport) and selects the default set of rules for your driver type. If this is the first time you are running SDV on your driver, you should run the default rule set. To shorten the amount of time it takes to analyze the sample driver, you can select the **Custom rule selection**.\n\n    Use the default rule set, or select **Custom rule selection**, click **Clear All**, and then select the following rules for the Storport sample:\n\n    - [StorPortAllocatePool2 Rule (Storport)](https://docs.microsoft.com/windows-hardware/drivers/devtest/storport-storportallocatepool2)\n\n    - [StorPortDeprecated Rule (Storport)](https://docs.microsoft.com/windows-hardware/drivers/devtest/storport-storportdeprecated)\n\n    - [StorPortEnablePassive Rule (Storport)](https://docs.microsoft.com/windows-hardware/drivers/devtest/storport-storportenablepassive)\n\n    - [StorPortNotification2 Rule (Storport)](https://docs.microsoft.com/windows-hardware/drivers/devtest/storport-storportnotification2)\n\n    - [StorPortSpinLock Rule (Storport)](https://docs.microsoft.com/windows-hardware/drivers/devtest/storport-storportspinlock)\n\n    - [StorPortStartIo Rule (Storport)](https://docs.microsoft.com/windows-hardware/drivers/devtest/storport-storportstartio)\n\n    - [StorPortStatusPending Rule (Storport)](https://docs.microsoft.com/windows-hardware/drivers/devtest/storport-storportstatuspending)\n\n    For information about the rules, see [DDI Compliance Rules](https://docs.microsoft.com/windows-hardware/drivers/devtest/static-driver-verifier-rules).\n\n1. Start the static analysis. Click the **Main** tab, and click **Start**. When you click **Start**, a message is displayed to let you know that static analysis is scheduled and that the analysis can take a long time to run. Click **OK** to continue.\n\n## View and analyze the results\n\nAs the static analysis proceeds, SDV reports the status of the analysis. When the analysis is complete, SDV reports the results and statistics. If the driver fails to satisfy a DDI usage rule, the result is reported as a defect. SDV finds 7 defects in this sample.\n\nOn the **Main** tab, under **Results**, click the **Rules** tab. This tab displays the name of each rule that was verified in the last run and the results of the analysis. To view the reported defects, click the **Defect** link in the **Results** column. This opens the [Static Driver Verifier Report Page](https://docs.microsoft.com/windows-hardware/drivers/devtest/static-driver-verifier-report) and the [Trace Viewer](https://docs.microsoft.com/windows-hardware/drivers/devtest/defect-viewer), which displays a trace of the code path to the rule violation. For more information, see [Interpreting Static Driver Verifier Results](https://docs.microsoft.com/windows-hardware/drivers/devtest/interpreting-static-driver-verifier-results).\n\n<!-- File: tools/sdv/samples/SDV-FailDriver-WDM/README.md (Tokens: ~881 | Category: plugin-manifest) -->\n---\npage_type: sample\ndescription: \"Demonstrates how Static Driver Verifier (SDV) can find errors in a WDM driver.\"\nlanguages:\n- cpp\nproducts:\n- windows\n- windows-wdk\n---\n\n# SDV-FailDriver-WDM\n\nThe SDV-FailDriver-WDM sample driver contains intentional code errors that are designed to show the capabilities and features of [Static Driver Verifier](https://docs.microsoft.com/windows-hardware/drivers/devtest/static-driver-verifier) (SDV). SDV is a static verification tool that systematically analyzes the source code of Windows kernel-mode drivers. SDV is included in the Windows Driver Kit (WDK) and can be run from Microsoft Visual Studio. The sample demonstrates how SDV can find errors in a WDM driver.\n\n> [!CAUTION]\n> These sample drivers contain intentional code errors that are designed to show the capabilities and features of SDV. These sample drivers are not functional and are not intended as examples for real driver development projects.\n\n## Run the sample\n\n1. In the **Solutions Explorer** window, select the driver project (fail\\_driver1).\n\n    From the **Driver** menu, click **Launch Static Driver Verifier...**.\n\n    This opens the Static Driver Verifier application, where you can control, configure, and schedule when Static Driver Verifier performs an analysis.\n\n1. Click the **Rules** tab to select which driver DDI usage rules to verify when you start the analysis.\n\n    Static Driver Verifier detects the type of driver you are analyzing (WDF, WDM, NDIS, or Storport) and selects the default set of rules for your driver type. If this is the first time you are running SDV on your driver, you should run the default rule set. To shorten the amount of time it takes to analyze the fail\\_driver1 driver sample, you can select the **Custom rule selection**.\n\n    Use the default rule set, or select **Custom rule selection**, click **Clear All**, and then select the following rules for the WDM fail\\_driver1 sample:\n\n    - [CancelSpinLock](https://docs.microsoft.com/windows-hardware/drivers/devtest/wdm-cancelspinlock)\n\n    - [IrqlIoApcLte](https://docs.microsoft.com/windows-hardware/drivers/devtest/wdm-irqlioapclte)\n\n    - [IrqlKeSetEvent](https://docs.microsoft.com/windows-hardware/drivers/devtest/wdm-irqlkesetevent)\n\n    - [LowerDriverReturn](https://docs.microsoft.com/windows-hardware/drivers/devtest/wdm-lowerdriverreturn)\n\n    - [SpinLock (WDM)](https://docs.microsoft.com/windows-hardware/drivers/devtest/wdm-spinlock)\n\n    For information about the rules, see [DDI Compliance Rules](https://docs.microsoft.com/windows-hardware/drivers/devtest/static-driver-verifier-rules).\n\n1. Start the static analysis. Click the **Main** tab, and click **Start**. When you click **Start**, a message is displayed to let you know that static analysis is scheduled and that the analysis can take a long time to run. Click **OK** to continue.\n\n## View and analyze the results\n\nAs the static analysis proceeds, SDV reports the status of the analysis. When the analysis is complete, SDV reports the results and statistics. If the driver fails to satisfy a DDI usage rule, the result is reported as a defect. SDV finds 5 defects in this sample.\n\nOn the **Main** tab, under **Results**, click the **Rules** tab. This tab displays the name of each rule that was verified in the last run and the results of the analysis. To view the reported defects, click the **Defect** link in the **Results** column. This opens the [Static Driver Verifier Report Page](https://docs.microsoft.com/windows-hardware/drivers/devtest/static-driver-verifier-report) and the [Trace Viewer](https://docs.microsoft.com/windows-hardware/drivers/devtest/defect-viewer), which displays a trace of the code path to the rule violation. For more information, see [Interpreting Static Driver Verifier Results](https://docs.microsoft.com/windows-hardware/drivers/devtest/interpreting-static-driver-verifier-results).\n</yakaai_skills>"}