Jump to content

WdmStub


jds

Recommended Posts

One question that regularly arises here, is whether something like KernelEx exists for drivers (or indeed, whether KernelEx can help with driver compatibility). Occasionally, 'WdmStub' is mentioned as a possibility, eg. by dencorso here :

I can't confirm how successful 'WdmStub' is in this regard, but I have found some useful information about it for anyone wishing to try it.

Now, 'WdmStub' is a "sample/example" filter driver that was/is included in Walter Oney's book, "Programming the Microsoft Windows Driver Model". Note that 'WdmStub' was originally written as a VXD driver, and you can find a link to this version at the Internet Archive, as posted by dencorso here :

For the current version of 'WdmStub', you can obtain just the SYS file (and a few associated files that you can discard, however, you should keep 'wdmcheck.exe') as follows :

1. Create a directory structure "Something\AppendixA\Newstub\objchk_wxp_x86\i386"

2. Download 'wdmbook2_3.exe' from : http://web.archive.org/web/20111221045614/http://www.oneysoft.com/newpack.htm

3. Run 'wdmbook2_3.exe' and point it at the "Something" directory

4. Click through all the error messages due to missing paths

BTW, the licensing of 'WdmStub' basically says that you need to ask Walter Oney for permission to redistribute it and that he will grant this subject to some non-monetary conditions to ensure the quality of the end result.

OK, now that you have 'WdmStub.sys', how to use it?

Basically, you need to edit the INF file for the driver you are trying to install, identify the section that is invoked by the "AddReg=" directive, and add the following line to that section :

HKR,,NTMPDriver,,"wdmstub.sys,yourdvr.sys"

(where 'yourdvr.sys' is the name of the driver binary that needs assistance).

You also need to add 'wdmstub.sys' to the section invoked by the "CopyFiles=" directive or manually pre-copy it to the same destination directory as "yourdvr.sys" (possibly "c:\windows\system32\drivers").

Finally, for the technically minded, you can obtain all the contents of the companion CD to Walter Oney's book, except stuff restricted by licensing conditions, as follows:

1. Download '9780735618039_files.zip' via the "Download Example Code" link at : http://shop.oreilly.com/product/9780735618039.do

2. Download 'wdmbook2.exe' (despite its name, this is the "cumulative service pack 3" update) via : http://web.archive.org/web/20111221045614/http://www.oneysoft.com/newpack.htm

3. Unzip "9780735618039_files" and apply the "wdmbook2" update to the "Samples" subdirectory.

Notes :

1. The '9780735618039_files.zip' file is huge because it also includes IE6SP1!

2. When you apply the updates, you will encounter an error due to a missing path "objchk"; create it by duplicating the corresponding "objchk_wxp_x86" directory and re-apply the update.

3. If you don't want to download the huge ZIP file, you can select what you want via O'Reilly Media's german site at : http://examples.oreilly.de/english_examples/9780735618039/cd_contents/ (excepting 'ServicePack.htm', 'wdmbook.htm' and 'wdmwiz.awx', which can be obtained from the 'wdmbook2.exe' or 'wdmbook2_3.exe' updates).

4. If you need to add more stubs or implement more functions in "WdmStub", Walter Oney requests that you contact him about including them in the official release.

Additional references/resources :

1. Links to Windows Driver Model articles

2. Driver compatibility issues for W9X

3. minf - minimize an INF file

4. New licensing conditions

5. WdmCheck info. and download link (also see update packs above)

Joe.

Edits :

1. Minor corrections and details added.

2. Corrected syntax error (extra comma), as identified here.

3. Added "Additional references/resources" section.

4. Added link to new licensing conditions.

5. Changed OneySoft links to Internet Archive copies (Walter has retired).

6. Added link for WdmCheck.

Edited by jds
Link to comment
Share on other sites


@jds: Congratulations for your good and comprehensive sleuthing! th_sherlock.gif

I'll just add two small bits of info, to make it easier for those looking for WDMSTUB.SYS.

(i) W. Oney's book's floppies only provide the debug version of WDMSTUB.SYS ("checked" or "chk" in MS parlance), which is ~20 KiB for v. 5.0.0.6 (the latest).

(ii) NUSB30e includes the release version of it (without debugging information inside), which is ~13 KiB for v. 5.0.0.6 (the latest).

While both work equally well, the release wastes less memory, because its smaller.

All versions of NUSB can be found here, of course.

Link to comment
Share on other sites

(i) W. Oney's book's floppies only provide the debug version of WDMSTUB.SYS ("checked" or "chk" in MS parlance), which is ~20 KiB for v. 5.0.0.6 (the latest).

(ii) NUSB30e includes the release version of it (without debugging information inside), which is ~13 KiB for v. 5.0.0.6 (the latest).

Thanks Den!

I wasn't aware there was both a production and a debug build of 'wdmstub.sys'. Well, I may as well try the production build (unless some debugging is needed, in which case, I'd have to learn how to do such debugging).

There's probably also some "strip" tool available in VS that can convert debug builds into something equivalent to a production build, but I haven't checked. Useful for shrinking larger binaries.

Joe.

Link to comment
Share on other sites

Basically, you need to edit the INF file for the driver you are trying to install, identify the section that is invoked by the "AddReg=" directive, and add the following line to that section :

HKR,,NTMPDriver,,"wdmstub.sys,,yourdvr.sys"

(where 'yourdvr.sys' is the name of the driver binary that needs assistance).

You also need to add 'wdmstub.sys' to the section invoked by the "CopyFiles=" directive or manually pre-copy it to the same destination directory as "yourdvr.sys" (possibly "c:\windows\system32\drivers").

The above description contains one small error, which comes directly from the source (the same typo is actually present also in W. Oney's own instructions):

It should be: HKR,,NTMPDriver,,"wdmstub.sys,yourdvr.sys" instead of HKR,,NTMPDriver,,"wdmstub.sys,,yourdvr.sys"

Just one comma goes after wdmstub,sys, not two.

I've attached the inf from the Garmin GPS (one of the products using it), taken from their driver, as a further example of an working installation of wdmstub.sys. I've also included an inf taken from a SoundMAX audio driver, which also uses wdmstub.sys, albeit it's a more complicated example.

And, just to keep things as together as possible, here I quote another post of mine, from another thread.

I understood what you said only that I'd like to read the technical details so-to-say.

Well, the bible of WDM is Walter Oney's book, Programming the MS WDM, but his site has a lot of interesting info, too.

This old version of WDMSTUB, when it was still a VxD, is also interesting. Then there is his classic article on WDM: Part 1, Part 2 and Errata. Enjoy!

And a link for Walter Oney's WDMCheck page.

There! I think now we have all info that's needed together in this thread. :yes:

inf_archive.7z

Link to comment
Share on other sites

After running WDMCHECK for XNACC.SYS 6.0.5435.0 which can be found here

http://www.microsoft.com/download/en/details.aspx?id=4190

I get the following error

WDMCHECK caused an invalid page fault in
module WDMCHECK.EXE at 017f:00401d83.
Registers:
EAX=0040ba6e CS=017f EIP=00401d83 EFLGS=00010202
EBX=00000000 SS=0187 ESP=0063fbb8 EBP=0063fbc4
ECX=0063fbf4 DS=0187 ESI=0040909d FS=2c37
EDX=3c883c78 ES=0187 EDI=00000000 GS=0000
Bytes at CS:EIP:
8a 27 47 38 c4 74 f2 2c 41 3c 1a 1a c9 80 e1 20
Stack dump:
00000000 00409050 00000000 8350f0d8 00401530 00000000 0040909c 0063fe38 00000000 00000000 00530000 00000001 00760e90 00408108 00000010 004080f0

Link to comment
Share on other sites

Wishlist for a next version of WDMSTUB:

_vsnwprintf

HidNotifyPresence

InterlockedPopEntrySList

InterlockedPushEntrySList

TdiCopyBufferToMdl

TdiCopyMdlToBuffer

ZwDeleteValueKey

With those, there'd be a chance to add the Bluetooth stack to 9x/ME using MS files, although it's a long shot.

Anyone knows of any Bluetooth drivers for 9x/ME, whatever publisher may it come from (I'd guess Widcomm or Blue Soleil)?

Link to comment
Share on other sites

Anyone knows of any Bluetooth drivers for 9x/ME, whatever publisher may it come from (I'd guess Widcomm or Blue Soleil)?

Hmmm :unsure::

What about D-link?

http://www.dlink.com.au/tech/Download/download.aspx?product=DBT-122&revision=REV_C&filetype=Drivers

ftp://files.dlink.com.au/products/DBT-122/REV_C/Drivers//DBT-122_C_Driver_5.1.0.1100/DBT-122_C_Driver_v5.1.0.1100.zip

or EMTEC?:

http://www.emtec-international.com/en-eu/old_drivers

http://www.emtec-international.com/sites/default/files/drivers/driverbluetooth.zip

WARNING! Senselessly HUGE packages, tens of Mbytes!. :ph34r:

(the above are Widcomm)

jaclaz

Edited by jaclaz
Link to comment
Share on other sites

@ jaclaz

Do the drivers you listed work with any bluetooth or are they specific to its own devices.

I do like dencorso approach using the microsoft files. I hope someone will take on this task, so we all can benefit.

Edited by PROBLEMCHYLD
Link to comment
Share on other sites

It should be: HKR,,NTMPDriver,,"wdmstub.sys,yourdvr.sys" instead of HKR,,NTMPDriver,,"wdmstub.sys,,yourdvr.sys"

Just one comma goes after wdmstub,sys, not two.

I've attached the inf from the Garmin GPS (one of the products using it), taken from their driver, as a further example of an working installation of wdmstub.sys. I've also included an inf taken from a SoundMAX audio driver, which also uses wdmstub.sys, albeit it's a more complicated example.

Thanks, Den! You've saved a lot of confusion and head-scratching over that subtle little error. :)

And the real-world samples are not only instructive, they also give encouragement that this stuff can really work!

Joe.

Link to comment
Share on other sites

@jds: The Garmin drivers also contain a release version of WDMSTUB.SYS v. 5.0.0.6, but its PE Timestamp shows it's a complation less than one year earlier (and about 1 KiB smaller) than the one in NUSB3.0e, which AFAIK is the latest one available. The SoundMAX driver contains a WDMSTUB.SYS v. 5.0.0.4, which is not relevant, unless for study purposes. However it shows how to get WDMSTUB.SYS permanently loaded, by using it as a lower filter for a device permanently present, such as the onboard soundcard. This approach could be applied even for soundcards not needing WDMSTUB, just to get it permanently loaded, but cannot be generalized: one has to identify a suitable dispositive device in one's own machine and modify the apropriated inf. by hand, on a case-by-case basis.

@jaclaz: Thanks a lot for the pointers! the D-Link stack seems promising enough for general use. I'll give it a finer look tomorrow and see what I can do.

Link to comment
Share on other sites

After running WDMCHECK for XNACC.SYS 6.0.5435.0 which can be found here

http://www.microsoft.com/download/en/details.aspx?id=4190

I get the following error

WDMCHECK caused an invalid page fault in
module WDMCHECK.EXE at 017f:00401d83.
Registers:
EAX=0040ba6e CS=017f EIP=00401d83 EFLGS=00010202
EBX=00000000 SS=0187 ESP=0063fbb8 EBP=0063fbc4
ECX=0063fbf4 DS=0187 ESI=0040909d FS=2c37
EDX=3c883c78 ES=0187 EDI=00000000 GS=0000
Bytes at CS:EIP:
8a 27 47 38 c4 74 f2 2c 41 3c 1a 1a c9 80 e1 20
Stack dump:
00000000 00409050 00000000 8350f0d8 00401530 00000000 0040909c 0063fe38 00000000 00000000 00530000 00000001 00760e90 00408108 00000010 004080f0

Yeah, I get the same thing.

The downloaded SYS file has the following version string :

6.0.5435.0 (vbl_ux_nisd_gamesux(mmbuild).060601-1414)

From Quick View, we get :

Linker Version: 8.00

Operating System Version: 6.00

Image Version: 6.00

Subsystem Version: 6.00

So despite the description at the MS download page, this SYS file looks to be for Vista, not XP. I don't know the compatiility of Vista drivers on XP. However, for Vista, the "recommended" driver model is "Kernel Mode", whereas what we're interested in is "Windows Driver Model", which is (98)/2000/XP. I don't know what the actual difference is between the two driver models, but suspect this is what is confusing/crashing 'WdmCheck'.

@jds: The Garmin drivers also contain a release version of WDMSTUB.SYS v. 5.0.0.6, but its PE Timestamp shows it's a complation less than one year earlier (and about 1 KiB smaller) than the one in NUSB3.0e, which AFAIK is the latest one available. The SoundMAX driver contains a WDMSTUB.SYS v. 5.0.0.4, which is not relevant, unless for study purposes. However it shows how to get WDMSTUB.SYS permanently loaded, by using it as a lower filter for a device permanently present, such as the onboard soundcard. This approach could be applied even for soundcards not needing WDMSTUB, just to get it permanently loaded, but cannot be generalized: one has to identify a suitable dispositive in one's machine and modify the apropriated inf. by hand, on a case-by-case basis.

Hmmm ... so it seems we can't rely on the version number when looking at different builds of 'WdmStub'.

Anyway, can you please explain what you mean by "one has to identify a suitable dispositive in one's machine and modify the apropriated inf. by hand"? I can't quite figure it out. I figure "apropriated" should probably be "appropriate", but "dispositive" is a very obscure word (and I was none the wiser after looking it up).

Joe.

Link to comment
Share on other sites

Hmmm ... so it seems we can't rely on the version number when looking at different builds of 'WdmStub'.

Yes. I know of at least 3 builds of v. 5.0.0.6, with different PE Timestamps. Of course, any of them is more up-to-date than v. 5.0.0.4, of which I know of just one build, the one that comes with the SoundMAX drivers.

Anyway, can you please explain what you mean by "one has to identify a suitable dispositive in one's machine and modify the apropriated inf. by hand"? I can't quite figure it out. I figure "apropriated" should probably be "appropriate", but "dispositive" is a very obscure word (and I was none the wiser after looking it up).

Sorry! I'm a native speaker of Portuguese, and despite my best efforts at expressing myself clearly in English, it sometimes shows. :blushing: By "dispositive" I intended to mean gadget, gizmo, resource, device, but that's a meaning "dispositive" has in Portuguese, not in English. They are "false friends". So I was thinking about an onboard soundcard, or an onboard modem, or perhaps even an onboard graphics card... in any case, something that uses a WDM device driver, but which does not necessarily need WDMSTUB.SYS, and which cannot be removed, so that once the driver is loaded it also loads WDMSTUB.SYS, and it never gets unloaded, because the device cannot be removed. My own board uses the SoundMAX driver, so I do have WDMSTUB.SYS loaded all the time. But I'm talking of using any WDM driver, even one that doesn't actually need WDMSTUB.SYS, just to load it in memory and have it remain there.

Link to comment
Share on other sites

Sorry! I'm a native speaker of Portuguese, and despite my best efforts at expressing myself clearly in English, it sometimes shows. :blushing: By "dispositive" I intended to mean gadget, gizmo, resource, device, but that's a meaning "dispositive" has in Portuguese, not in English. They are "false friends". So I was thinking about an onboard soundcard, or an onboard modem, or perhaps even an onboard graphics card... in any case, something that uses a WDM device driver, but which does not necessarily need WDMSTUB.SYS, and which cannot be removed, so that once the driver is loaded it also loads WDMSTUB.SYS, and it never gets unloaded, because the device cannot be removed. My own board uses the SoundMAX driver, so I do have WDMSTUB.SYS loaded all the time. But I'm talking of using any WDM driver, even one that doesn't actually need WDMSTUB.SYS, just to load it in memory and have it remain there.

No worries, your English is usually exemplary (if I were more proficient in Portuguese, I might have figured out what you meant).

Anyway, what is it in 'smwdmVI3.inf' which makes it different, "never unloaded"? I looked at the INF file, which is somewhat large and complex, but couldn't figure it out. Also, what advantage does this bring?

Joe.

Link to comment
Share on other sites

Nothing is different in the .inf. The fact that the sound card cannot possibly be removed while the system is running is what makes WDMSTUB.SYS remain always loaded. The thing is in the WDM model itself. While VxDs can be created to be unloadable, they can also be permanent. WDM drivers usually are unloadable (and I'm not sure whether they can be caused to be permananent, probably so, I would have to study this question some more). But, when one loads, as most of us do, WDMSTUB with USBSTOR, it'll only be loaded when a pendrive (or other USB Mass Storage device) is inserted, and then will be unloaded when it's removed. PROBLEMCHYLD and I just faced a situation where this can be a problem (well, sort of...) because the newer USBSER he adopted needs WDMSTUB. So, the situation created by this is the following: when one inserts a USB Mass Storage device, WDMSTUB is loaded, when one inserts another USB Mass Storage device, WDMSTUB is loaded again, and if, then, one inserts a USB Serial device, WDMSTUB is loaded yet again, and so on. This is harmless, but eats memory, so I think it would be nicer if we could avoid it. Now, in my machine, in which WDMSTUB gets loaded during start-up (by the onboard sound card, thanks to smwdmVI3.inf) and remains in memory, I found out I can omit WDMSTUB as a lower-filter for both (in the .infs), *because* it aready has been loaded by the SoundMAX driver, and provides the needed stubs for everybody else. So, it's more a question of saving memory and avoiding multiple, albeit harmless, loadings of the same lower-filter. Of course, the SoundMAX driver comes with an older version of the WDMSTUB.SYS, so I've just updated it to the newest version and compilation of it I know of. A more general solution, one that involves some intensive programing, but is general, would be to convert the current WDMSTUB.SYS back to VxD (and have it loaded from SYSTEM.INI).

Link to comment
Share on other sites

Nothing is different in the .inf. The fact that the sound card cannot possibly be removed while the system is running is what makes WDMSTUB.SYS remain always loaded. The thing is in the WDM model itself. While VxDs can be created to be unloadable, they can also be permanent. WDM drivers usually are unloadable (and I'm not sure whether they can be caused to be permananent, probably so, I would have to study this question some more). But, when one loads, as most of us do, WDMSTUB with USBSTOR, it'll only be loaded when a pendrive (or other USB Mass Storage device) is inserted, and then will be unloaded when it's removed. PROBLEMCHYLD and I just faced a situation where this can be a problem (well, sort of...) because the newer USBSER he adopted needs WDMSTUB. So, the situation created by this is the following: when one inserts a USB Mass Storage device, WDMSTUB is loaded, when one inserts another USB Mass Storage device, WDMSTUB is loaded again, and if, then, one inserts a USB Serial device, WDMSTUB is loaded yet again, and so on. This is harmless, but eats memory, so I think it would be nicer if we could avoid it. Now, in my machine, in which WDMSTUB gets loaded during start-up (by the onboard sound card, thanks to smwdmVI3.inf) and remains in memory, I found out I can omit WDMSTUB as a lower-filter for both (in the .infs), *because* it aready has been loaded by the SoundMAX driver, and provides the needed stubs for everybody else. So, it's more a question of saving memory and avoiding multiple, albeit harmless, loadings of the same lower-filter. Of course, the SoundMAX driver comes with an older version of the WDMSTUB.SYS, so I've just updated it to the newest version and compilation of it I know of. A more general solution, one that involves some intensive programing, but is general, would be to convert the current WDMSTUB.SYS back to VxD (and have it loaded from SYSTEM.INI).

Now I understand.

How about??? :

HKR,,NTMPDriver,,"wdmstub.sys,usbd.sys"

Joe.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...