Overview


The "“DevMgrTool"” program is tool that provides user some capabilities to interact with specified driver(s). Currently, this tool can do following things on specified driver(s):

1. Unload the driver(s)
2. Load driver(s) that previously unloaded by this tool. Also can apply ""AppVerifier"" shim layers to it after driver(s) get unloaded.
3. Unload and then immediately (with 2 sec delay) reload driver(s)
4. Unload the driver(s) and then warm-reset the system.
5. Enum all devices, print out device information.
6. Enum all PCI devices, print out PCI specific information of these drivers.



The tool provides eight ways to specify the driver(s):
1. By legacy name
2. By device name
3. By bus name
4. By GUID
5. By PCI bus/device/function number
6. By IRQ
7. By system interrupt
8. By the index number provided by this tool when unload action is previously performed.

Common Usage Scenarios


1. Enumerate devices.

You can either enumerate all devices or specified devices.
To enumerate all devices run: devmgrtool /enum
To enumerate device by legacy name devmgrtool /enum /legacyname ""NLD1:""
To enumerate NLED device by device name: devmgrtool /enum /devicename ""NLD1""
To enumerate NLED device by bus name: devmgrtool /enum /busname ""BuiltInPhase1014_0""
To enumerate device by GUID: devmgrtool /enum /guid {12345678-1234-1234-1212-123456789abc}

It should list all devices that loaded in the current system. The device information listed is like this:

		 name 'NLD1:', hDevice 0x00034050, [hParentDevice] 0x00031920
		 key ""'Drivers\BuiltIn\NLed'"", device name ""'$device\NLD1'"", bus name ""'$bus\BuiltInPhase1_0_14_0'""
	

To enumerate all PCI devices, run: devmgrtool /pcienum
This should list all PCI devices that loaded in the current system. The device information listed is like this:
		 Bus/Device/Function = 0/18/0, Ethernet Network Controller
		   VendorID = 0x1106, DeviceID = 0x3065, Command = 0x0097, Status = 0x0210
		   RevisionID = 0x74, [ProgIf] = 0x00, [SubClass] = 0x00, [BaseClass] = 0x02
		   [CacheLineSize] = 0x08, [LatencyTimer] = 0x20, [HeaderType] = 0x00, BIST = 0x00
		   [BaseAddresses:]
		     0x0000A801  0xF3000000  0x00000000  0x00000000  0x00000000  0x00000000
		   CIS = 0x00000000, [SubVendorID] = 0x1043, [SubSystemID] = 0x80A1
		   [ROMBaseAddress] = 0x00000000
		   [InterruptLine] = 0x0A, [InterruptPin] = 0x01, [MinGrant] = 0x03, [MaxLatency] = 0x08
	

2. Unload device and load device back

You can specify the devices to be unloaded by methods ""1~7"" mentioned above. Here are some examples against the NLED device that get enumerated above:
To unload NLED device by legacy name: devmgrtool /unload /legacyname ""NLD1:""
To unload NLED device by device name: devmgrtool /unload /devicename ""NLD1""
To unload NLED device by bus name: devmgrtool /unload /busname ""BuiltInPhase1014_0""

Unload by PCI bus/device/function number, IRQ number or system interrupt number can only be applied to PCI devices:
To unload PCI device with bus/device/function number 0/18/0: devmgrtool /unload /pcibus 0180
To unload all PCI devices:devmgrtool /unload /pcibus
To unload PCI device on bus 0: devmgrtool /unload /pcibus 0
To unload PCI device that using IRQ 5: devmgrtool /unload /irq 5
To unload PCI device using system interrupt 23: devmgrtool /unload /sysintr 23

If device get unloaded successfully, the tool will give an index for this device, and you can load this device back by using this index. For example, after running:
		 devmgrtool  /unload /legacyname NLD1:
	

You may see following output:
		 	----------------Device unload operation SUCCEEDED--------------
	

Then you can load the device back by index:
		 devmgrtool  /load /index 2
	
Also there are some other ways to load driver(s) back.
load the last-unloaded device back: devmgrtool /load
load the back by legacy name: devmgrtool /load /legacyname ""NLD1:""
load the back by bus name: devmgrtool /load /busname ""$Bus\BuiltInPhase014_0""

Please be aware that for unload devices, you can use wild cards to specify the devices, like ""“COM?:”"", while loading device back, you must specify the exact device name.

When you unload device, you can ask the tool to load two shim layers for this device: shimhleak and shimheap:
		 devmgrtool  /unload /legacyname NLD1: /appver
	

By calling this command, this tool will unload ""NLD1:"", and call ""AppVerifier.exe"", and load those two shim dlls for this device. Then you can load the device back, exercise it, the unload it again. By doing so you will get memory/handle leak information about this driver.

If you have some other shim dlls to load instead of these two default ones, you can either call appverifier directly, or, use this tool:
		 devmgrtool  /launchappver /dllname drv_foo.dll /shimname shim_foo.dll
	

This will apply shim shimfoo.dll to your device dll drvfoo.dll.

3. Other usages

You can also use this tool to do two other variations:
To unload device(s), then reload it(them) back immediately:
		 devmgrtool  /reload /legacyname NLD1:
	
To unload device(s), then warm-reset the system:
		 devmgrtool  /reset /legacyname NLD1:
	

Method ""1-7"" of specifying devices all apply to these two usages.


4. Summary

		 Devmgrtool  </unload|/load|/reload|/reset|/pcienum|/enum|/lunchappver>
		 </legacyname|/devicename|/busname|/guid|/pcibus|/irq|/sysinter|/index>  [namestringirq or sysintr number|index] </appver> 
	

		 </unload|/load|/reload|/reset|/pcienum|/enum|/launchappver>: action, only one of the six options can chosen:
		 /unload : unload specified device(s)
		 /load : load specified device(s) back
		 /reload : unload specified device(s), then reload them
		 /reset : unload specified device(s), then warm-reset the system
		 /pcienum : enumerate all PCI devices currently loaded in the system
		 /enum : enum all devices currently loaded in the system or specified devices
	

		 </legacyname|/devicename|/busname|/guid|/pcibus|/irq|/sysinter|/index>: options on how to specify the devices:
		 /legacyname: specify device(s) by device’s legacy name, should following the name string.
		 /devicename: specify device(s) by device name, should be followed by the device name string, no $device prefix needed
		 /busname: specify device(s) by bus name, should be followed by the bus name string, no$bus prefix needed 
		 /guid: specify device(s) by guid, should be followed by the GUID string in the format like: 
	
{%08lX%04X%04X%02X%02X%02X%02X%02X%02X%02X%02X}
		   Example: devmgrtool /unload /guid  {12345678-1234-1234-1234-123456789abc} 
		   Note: the GUID format used  here is just the normal GUID expression format without hypens.
	

		 /pcibus: specify device(s) by pcibus bus,device and function number, in the format of bus_device_function, if not specified, will match all
		 /irq: specify device(s) by irq number, should be followed by the number of the irq
		 /sysintr: specify device(s) by sysintr number, should be followed by the number of the sysintr
		 /index: specify device by index, the index is given by unload action. It should be followed by the index number.
	

If you want to use this tool load specific shim dll to specific driver, the syntax is:
		 Devmgrtool  /launchappver /shimname [shimnamestring] /dllname [devicedllnamestring]
	

User can use ‘-‘ instead of ‘/’ in the command line. For example:
		 devmgrtool  -reload -legacyname NLD1:
	




Go up to Features of a BSP
Go up to Big Book of BSP


Thank you for contributing to this BSP Wiki. To ensure your comments and concerns receive proper exposure, include bspwiki""@""microsoft"".""com when providing feedback or topical suggestions.





Microsoft Communities