Windows 7 - DDK and SDK

Asked By Leela on 13-Nov-08 02:51 AM
Hi,

I wish to develop a kernel USB driver usnig the windows DDK 3790.1830 from
within the Visual Studio.

Can someone out there help? How to get started?

Thanks,




Don Burn replied on 13-Nov-08 06:53 AM
WRONG, WRONG WRONG.  First DDK 3790.1830 is obsolete, get WDK 6001.18002 the
DDK you choose is way out of date.   Second, you have to use the BUILD tools
of WDK, if you want to wrap it in Visual Studio get DDKBUILD from
http://www.hollistech.com/.

For a USB device depening on the type I would not use a kernel driver, use
the User Mode Driver Framework, if you need a kernel driver use the Kernel
Mode Driver Framework.  There are examples on USB devices in the WDK.

--
Don Burn (MVP, Windows DDK)
Windows Filesystem and Driver Consulting
Website: http://www.windrvr.com
Blog: http://msmvps.com/blogs/WinDrvr
Remove StopSpam to reply
Le Chaud Lapin replied on 16-Nov-08 03:32 PM
m

The most important thing is the linker. Using IDE in Linker section,

1. Set SubSystem to (/SUBSYSTEM:NATIVE) [it's a driver, not user-mode
EXE]
2. Set Ignore All Default Libraries to Yes (/NODEFAULTLIB) [can't have
all that C stuff in kernel mode]
3. Define Additional Dependencies to include libraries needed to make
your .SYS
Example: ndis.lib hal.lib ntoskrnl.lib wdm.lib wdmsec.lib
BufferOverflowK.lib sehupd.lib wmilib.lib $(NOINHERIT)
4. Set Output File to $(OutDir)\$(ProjectName).sys

Change your lib include path to include paths of DDK libs as
appropriate.

Write your "main()" function, DriverEntry, and use DbgPrint instead of
printf to print out "Hello, World!" to see if all is working.

You must avoid setting AddDevice function to be able to dynamically
load/unload driver in this manner.
http://www.osronline.com/ddkx/kmarch/drvrrtns_4d6a.htm.

Write a companion user-mode application to create and control the
loading and unloading of the driver using the Service Control
functions. You will need CreateService to create a service that is the
driver. Then OpenService, StartService.

Use:
http://technet.microsoft.com/en-us/sysinternals/bb896647.aspx
to see the debug output and consequently determine if driver is
loading and unloading.

You can also see if driver is loaded by checking loaded DLL's of
System process using Process Explorer:
http://technet.microsoft.com/en-us/sysinternals/bb896653.aspx

-Le Chaud Lapin-
Don Burn replied on 15-Nov-08 06:36 PM
To the OP, feel free to do this and then call an expert to fix your driver.
I have collected a fair amount from idiots who used the IDE such as
suggested below, and then hit one of the many subtle bugs.  Using anything
other than the WDK build environment is a good step to a crappy driver.


--
Don Burn (MVP, Windows DDK)
Windows Filesystem and Driver Consulting
Website: http://www.windrvr.com
Blog: http://msmvps.com/blogs/WinDrvr
Remove StopSpam to reply




The most important thing is the linker. Using IDE in Linker section,

1. Set SubSystem to (/SUBSYSTEM:NATIVE) [it's a driver, not user-mode
EXE]
2. Set Ignore All Default Libraries to Yes (/NODEFAULTLIB) [can't have
all that C stuff in kernel mode]
3. Define Additional Dependencies to include libraries needed to make
your .SYS
Example: ndis.lib hal.lib ntoskrnl.lib wdm.lib wdmsec.lib
BufferOverflowK.lib sehupd.lib wmilib.lib $(NOINHERIT)
4. Set Output File to $(OutDir)\$(ProjectName).sys

Change your lib include path to include paths of DDK libs as
appropriate.

Write your "main()" function, DriverEntry, and use DbgPrint instead of
printf to print out "Hello, World!" to see if all is working.

You must avoid setting AddDevice function to be able to dynamically
load/unload driver in this manner.
http://www.osronline.com/ddkx/kmarch/drvrrtns_4d6a.htm.

Write a companion user-mode application to create and control the
loading and unloading of the driver using the Service Control
functions. You will need CreateService to create a service that is the
driver. Then OpenService, StartService.

Use:
http://technet.microsoft.com/en-us/sysinternals/bb896647.aspx
to see the debug output and consequently determine if driver is
loading and unloading.

You can also see if driver is loaded by checking loaded DLL's of
System process using Process Explorer:
http://technet.microsoft.com/en-us/sysinternals/bb896653.aspx

-Le Chaud Lapin-
Le Chaud Lapin replied on 16-Nov-08 03:33 PM
r.
ing

I do not think it is the IDE that leads to crappy drivers, but a lack
of understanding of what's going on that might. I would venture to say
that Leelaf is willing to tolerate a potential for Death-By-IDE if he
can benefit from writing from the comfort of the IDE. He might be just
trying to get started, and in his mind, the IDE is easier than BUILD.
Otherwise he never would have made the post, but started using BUILD
immediately.

I think the key is here is to not assume that he is an idiot, but lay
out the pro's and con's and let him decide for himself what's best for
him.

Note that there are non-idiots [world-class experts] who use the IDE
to build drivers, "in the raw", without DDKBUILD or anything similar.

-Le Chaud Lapin-
Don Burn replied on 16-Nov-08 08:58 AM
No it is people who think they can reproduce the settings of BUILD.  I've
gotten drivers build by some of the "world-class experts" who built them
with IDE's and in one case made many 10 of thousands of dollars proving the
bug was their build environment.   Sorry, using anyything other than BUILD
is placing a huge handicap on your effort (with suble bugs of the type
people will say "not the IDE" when they are) before you get going.   Giving
advice for a newbie to use anything other than BUILD is almost criminal.



--
Don Burn (MVP, Windows DDK)
Windows Filesystem and Driver Consulting
Website: http://www.windrvr.com
Blog: http://msmvps.com/blogs/WinDrvr
Remove StopSpam to reply






I do not think it is the IDE that leads to crappy drivers, but a lack
of understanding of what's going on that might. I would venture to say
that Leelaf is willing to tolerate a potential for Death-By-IDE if he
can benefit from writing from the comfort of the IDE. He might be just
trying to get started, and in his mind, the IDE is easier than BUILD.
Otherwise he never would have made the post, but started using BUILD
immediately.

I think the key is here is to not assume that he is an idiot, but lay
out the pro's and con's and let him decide for himself what's best for
him.

Note that there are non-idiots [world-class experts] who use the IDE
to build drivers, "in the raw", without DDKBUILD or anything similar.

-Le Chaud Lapin-
Tim Roberts replied on 16-Nov-08 03:53 PM
The OP said he wanted to write a USB driver.  That means writing a PnP
driver, which means using AddDevice.
--
Tim Roberts, timr@probo.com
Providenza & Boekelheide, Inc.
Le Chaud Lapin replied on 19-Nov-08 06:39 AM
from

Yeah, but the way the request is worded, it looks like he might be
driver newbie.

I figured he could build his context in a less painful manner by
writing experimental legacy driver. Later, after he has experimented
with various driver elements/concepts, he could decide what to do
next, including relying on PnP machinery, dumping the IDE in favor of
BUILD or DDKBUILD, using real debugger setup, etc.

-Le Chaud Lapin-
Maxim S. Shatskih replied on 27-Nov-08 01:01 PM
IDE has a bit easier learning curve, but its project/build management =
options are by far worse and lesser intuitive then BUILD's. Lack of =
!include and !ifdef in the project script is a very, very bad handicap.

So, BUILD is just more professional tool.

Most of the important platform software - both in Windows and in open =
source world - is built using MAKE or its close relative BUILD, not =
using IDEs.

Also, you cannot debug drivers from IDE, so, its "comfort" is out of =
question. It is just a text editor.

--=20
Maxim S. Shatskih
Windows DDK MVP
maxim@storagecraft.com
http://www.storagecraft.com
Le Chaud Lapin replied on 29-Nov-08 06:29 PM
On Nov 27, 12:01=A0pm, "Maxim S. Shatskih"

Hi Max,

ions are by far worse and lesser intuitive then BUILD's. Lack of !include a=
nd !ifdef in the project script is a very, very bad handicap.

Well I am glad that you wrote this, because it validates what I have
suspected all along in these IDE vs. BUILD discussions:

For all of you who think that the IDE is less intuitive than
BUILD...please...please...please know that we who prefer the IDE are
not mistaken, deluded, deranged, misguided, uninformed, ignorant,
wimpy, etc when we say that, for *us*, the exact opposite is true.  By
experienced engineers who have been programming for 20+ years.

Take me for example: I am thorougly familiar with the MAKE model. My
first experience with C was on and old AT&T running Unix. I did the
entire entourage of Unix-based machines, Sun, DEC, IBM, ...the works.
I was a diehard Emacs fan with my own compilation scripts. Had my
macros just the way I wanted them. I wrote my technical papers in
Scribe/Latex with piped processing. I would read the 3000+ page manual
for Unix during my free time in lab, page by page, to learn various
commands (as best I could) and new ways to script them.  And before
that, I was just as much into DOS-based systems, with batch files,
etc. The first thing I did when I came to a new compiler was go
through command-line options, item-by-item, to try, as best as I
could, to understand their implication. I did this with CP/M also.  I
had .BAT files everywhere.

You get the point..I have had, and more importantly, _enjoyed_, the
experience of the command-line model.

I now prefer the IDE.

The key here is that, when *I* look at the switches inside the IDE,
*I* do not feel bereft of my intuition whatsoever. If anything, I am
acutely aware of what the build system is doing behind-the-scenes as I
tweak each option the way I want it.


So is the IDE.

rce world - is built using MAKE or its close relative BUILD, not using IDEs=
.

Seeing a system involving MAKE does not bother me at all, although I
must admit that I have taking a mess of scripts and done away with
them with IDE. There is no comparison between the dependency facility
offered by the IDE vs. that offered by BUILD. The IDE is far better,
IMO.

tion. It is just a text editor.

I think the important thing here is to give the OP what s/he asks for.

The fact that they are looking to write a driver means that they might
already have the experience and intellectually capacity to determine
what is right for them, certain subtleties that Don mentioned
notwithstanding.

And yes, I build my drivers, namespace extensions, libraries, EXE's,
active-X controls, DirectShow filters, and everything else, all 33
projects, from the comfort of my IDE. :)

-Le Chaud Lapin-
Wilhelm Noeker replied on 28-Nov-08 03:48 AM
Oh please, it's more than that. It has auto-completion of long symbols,
can go to definition/reference, and in case of compiler errors, it will
take me to the line where I made the typo.

I wouldn't want to go without the IDE, but I do respect the
recommendation to use BUILD. So what do I do? I've got a Visual C
project that thinks it is building a console application, and I've got a
SOURCES file that will let me build the actual driver from the same
source files.
David Craig replied on 28-Nov-08 04:59 AM
Use DDKBUILD.  Use SlickEdit and it can run the build for you with DDKBUILD
or you can continue to use the Visual Studio editor to do the same.  Mark
has a good tutorial (VC6 based, but easily adapted) on how to set up a
makefile project.  You can even get browser symbols too.
Wilhelm Noeker replied on 28-Nov-08 06:39 AM
Well, of course. Don Burn already said that near the start of the
thread. I just wanted to point out another way to have comfortable
editing and still get the final binaries made by BUILD.
Tim Roberts replied on 28-Nov-08 01:32 PM
So can gvim, which is what I use for 99% of my editing.
--
Tim Roberts, timr@probo.com
Providenza & Boekelheide, Inc.