WDK - build a driver example

Hi,

I installed last WDK and trying to build its examples (using BUILD.EXE) works fine. Then I tried to build this simple driver Driver Development Part 1: Introduction to Drivers - CodeProject

the example driver folder contain this makefile:

TARGET = example
TARGETDIR = ........\bin

ASM = ml
CPP = cl
RSC = rc.exe
F90 = df.exe
MTL = midl.exe
REBASE = rebase.exe

OBJDIR = .\obj\i386

ASM_PROJ=/coff /c /Fo$(OBJDIR)\

CPP_PROJ=/nologo /MD /W3 /Oxs /Gz /Zi \
/I "........\inc" \
/I "\NTDDK\inc" \
/D "WIN32" /D "_WINDOWS" \
/Fr$(OBJDIR)\ /Fo$(OBJDIR)\ /Fd$(OBJDIR)\ /c

LIB32= link.exe
LIB32_FLAGS = /LIBPATH:........\lib /LIBPATH:\NTDDK\libfre\i386 /DEBUG /PDB:$(TARGETDIR)\SYMBOLS$(TARGET).PDB -entry:DriverEntry /SUBSYSTEM:NATIVE /nologo $(LIBS) /out:$(TARGETDIR)$(TARGET).sys

OBJS = \
$(OBJDIR)\entry.obj \
$(OBJDIR)\functions.obj

LIBS = \
wdm.lib \
ntoskrnl.lib

This is a comment

$(TARGETDIR)$(TARGET): $(OBJDIR) $(TARGETDIR) $(OBJS) $(RESFILE)
$(LIB32) $(LIB32_FLAGS) $(OBJS) $(LIBS) $(RESFILE)
$(REBASE) -b 0x00400000 -x $(TARGETDIR)\SYMBOLS -a $(TARGETDIR)$(TARGET)

{.}.c{$(OBJDIR)}.obj::
$(CPP) $(CPP_PROJ) $<

{.}.cpp{$(OBJDIR)}.obj::
$(CPP) $(CPP_PROJ) $<

{.}.asm{$(OBJDIR)}.obj::
$(ASM) $(ASM_PROJ) $<

{.}.rc{$(OBJDIR)}.res::
$(RSC) $(RES_PROJ) $<

$(OBJDIR):
if not exist "$(OBJDIR)/$(NULL)" mkdir "$(OBJDIR)"

$(TARGETDIR):
if not exist "$(TARGETDIR)/$(NULL)" mkdir "$(TARGETDIR)"

CLEAN:
xxxxx@erase /S /Q $(OBJDIR)

The very first thing I made was rename the lib/include paths (renaming NTDDK with right WDK folder name) and then I tried to build using NMAKE getting some warnings/errors...

Now, the very first question is: which are the differences in building process between BUILD.EXE and NMAKE.EXE ?

Thanks

i know this is not the answer you are looking for
but i have played with the toby opferman’s series a lot making it
build a windbg extension with old borland compiler that i know it is a
pretty might headache to use nmake and stuff
delete the makefile in the folder

put the two files instead of it

C:\driverdev_src\Programming\development\DEBUG\private\src\drivers\example>type
makefile
!INCLUDE $(NTMAKEENV)\makefile.def
C:\driverdev_src\Programming\development\DEBUG\private\src\drivers\example>type
sources
TARGETNAME=example
TARGETTYPE=DRIVER
TARGETPATH=obj
SOURCES = entry.c \
functions.c

remove the #define X86 in both the source file
change the TYPE_ALIGNMENT MAcro to named or simple go to old style
like sizeof(char) line 220

and invoke build
it should ggive you an example.sys
i havent checked if it loads before posting

On 1/29/13, xxxxx@alice.it wrote:
> Hi,
>
> I installed last WDK and trying to build its examples (using BUILD.EXE)
> works fine. Then I tried to build this simple driver
> http://www.codeproject.com/Articles/9504/Driver-Development-Part-1-Introduction-to-Drivers
>
> the example driver folder contain this makefile:
>
> TARGET = example
> TARGETDIR = …......\bin
>
> ASM = ml
> CPP = cl
> RSC = rc.exe
> F90 = df.exe
> MTL = midl.exe
> REBASE = rebase.exe
>
> OBJDIR = .\obj\i386
>
> ASM_PROJ=/coff /c /Fo$(OBJDIR)\
>
> CPP_PROJ=/nologo /MD /W3 /Oxs /Gz /Zi <br>> /I “…......\inc” <br>> /I “\NTDDK\inc” <br>> /D “WIN32” /D “_WINDOWS” <br>> /Fr$(OBJDIR)\ /Fo$(OBJDIR)\ /Fd$(OBJDIR)\ /c
>
> LIB32= link.exe
> LIB32_FLAGS = /LIBPATH:…......\lib /LIBPATH:\NTDDK\libfre\i386 /DEBUG
> /PDB:$(TARGETDIR)\SYMBOLS$(TARGET).PDB -entry:DriverEntry
> /SUBSYSTEM:NATIVE /nologo $(LIBS) /out:$(TARGETDIR)$(TARGET).sys
>
> OBJS = <br>> $(OBJDIR)\entry.obj <br>> $(OBJDIR)\functions.obj
>
> LIBS = <br>> wdm.lib <br>> ntoskrnl.lib
>
> # This is a comment
> $(TARGETDIR)$(TARGET): $(OBJDIR) $(TARGETDIR) $(OBJS) $(RESFILE)
> $(LIB32) $(LIB32_FLAGS) $(OBJS) $(LIBS) $(RESFILE)
> $(REBASE) -b 0x00400000 -x $(TARGETDIR)\SYMBOLS -a
> $(TARGETDIR)$(TARGET)
>
> {.}.c{$(OBJDIR)}.obj::
> $(CPP) $(CPP_PROJ) $<
>
> {.}.cpp{$(OBJDIR)}.obj::
> $(CPP) $(CPP_PROJ) $<
>
> {.}.asm{$(OBJDIR)}.obj::
> $(ASM) $(ASM_PROJ) $<
>
> {.}.rc{$(OBJDIR)}.res::
> $(RSC) $(RES_PROJ) $<
>
> $(OBJDIR):
> if not exist “$(OBJDIR)/$(NULL)” mkdir “$(OBJDIR)”
>
> $(TARGETDIR):
> if not exist “$(TARGETDIR)/$(NULL)” mkdir “$(TARGETDIR)”
>
> CLEAN:
> xxxxx@erase /S /Q $(OBJDIR)
>
> The very first thing I made was rename the lib/include paths (renaming NTDDK
> with right WDK folder name) and then I tried to build using NMAKE getting
> some warnings/errors…
>
> Now, the very first question is: which are the differences in building
> process between BUILD.EXE and NMAKE.EXE ?
>
> Thanks
>
> —
> NTDEV is sponsored by OSR
>
> OSR is HIRING!! See http://www.osr.com/careers
>
> For our schedule of WDF, WDM, debugging and other seminars visit:
> http://www.osr.com/seminars
>
> To unsubscribe, visit the List Server section of OSR Online at
> http://www.osronline.com/page.cfm?name=ListServer
>

> the example driver folder contain this makefile:

Bad and dirty way. Not supported. Use SOURCES or the new Win8/Visual Studio build env.

Lots of code on CodeProject is bad and dirty.


Maxim S. Shatskih
Windows DDK MVP
xxxxx@storagecraft.com
http://www.storagecraft.com

well to echo maxim
it contains a lot of things that prefast oacr etc would barf
try using wdk samples if you want your questions to get a reasonable answer or
it is you your machine the dark of night :slight_smile: and lots of caffeine /
energy drink :slight_smile:

On 1/29/13, Maxim S. Shatskih wrote:
>> the example driver folder contain this makefile:
>
> Bad and dirty way. Not supported. Use SOURCES or the new Win8/Visual Studio
> build env.
>
> Lots of code on CodeProject is bad and dirty.
>
> –
> Maxim S. Shatskih
> Windows DDK MVP
> xxxxx@storagecraft.com
> http://www.storagecraft.com
>
>
> —
> NTDEV is sponsored by OSR
>
> OSR is HIRING!! See http://www.osr.com/careers
>
> For our schedule of WDF, WDM, debugging and other seminars visit:
> http://www.osr.com/seminars
>
> To unsubscribe, visit the List Server section of OSR Online at
> http://www.osronline.com/page.cfm?name=ListServer
>

xxxxx@alice.it wrote:

I installed last WDK and trying to build its examples (using BUILD.EXE) works fine. Then I tried to build this simple driver http://www.codeproject.com/Articles/9504/Driver-Development-Part-1-Introduction-to-Drivers

The very first thing I made was rename the lib/include paths (renaming NTDDK with right WDK folder name) and then I tried to build using NMAKE getting some warnings/errors…

Now, the very first question is: which are the differences in building process between BUILD.EXE and NMAKE.EXE ?

Fundamentally, BUILD is supported, and NMAKE isn’t.

Now, that’s a bit snarky, because the way BUILD operates is to do a
quick scan for include file dependencies, and then invoke NMAKE, but
it’s doing it in a controlled way.

Your makefile only has two source files. It would be trivial to convert
this to a SOURCES file and then use BUILD, as God intended.


Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.

“Tim Roberts” wrote in message news:xxxxx@ntdev…

Your makefile only has two source files. It would be trivial to convert
this to a SOURCES file and then use BUILD, as God intended.

Hmmmm…I thought God intended us to use MSBuild? :slight_smile:

-scott
OSR

While others have pointed out that the build process you are trying
sucks. Someone should point out the whole sample is A TOTAL PIECE OF
CRAP. This driver was last appropriate for Windows NT 4.0 back before
the turn of the century.

Tell us what you are trying to do and we can recommend a good sample
from either WDK or from OSR, but why you would want to use a legacy
driver like the sample are beyond comprehension.

Don Burn
Windows Filesystem and Driver Consulting
Website: http://www.windrvr.com
Blog: http://msmvps.com/blogs/WinDrvr

“xxxxx@alice.it” wrote in message
news:xxxxx@ntdev:

> Hi,
>
> I installed last WDK and trying to build its examples (using BUILD.EXE) works fine. Then I tried to build this simple driver http://www.codeproject.com/Articles/9504/Driver-Development-Part-1-Introduction-to-Drivers
>
> the example driver folder contain this makefile:
>
> TARGET = example
> TARGETDIR = …......\bin
>
> ASM = ml
> CPP = cl
> RSC = rc.exe
> F90 = df.exe
> MTL = midl.exe
> REBASE = rebase.exe
>
> OBJDIR = .\obj\i386
>
> ASM_PROJ=/coff /c /Fo$(OBJDIR)\
>
> CPP_PROJ=/nologo /MD /W3 /Oxs /Gz /Zi <br>> /I “…......\inc” <br>> /I “\NTDDK\inc” <br>> /D “WIN32” /D “_WINDOWS” <br>> /Fr$(OBJDIR)\ /Fo$(OBJDIR)\ /Fd$(OBJDIR)\ /c
>
> LIB32= link.exe
> LIB32_FLAGS = /LIBPATH:…......\lib /LIBPATH:\NTDDK\libfre\i386 /DEBUG /PDB:$(TARGETDIR)\SYMBOLS$(TARGET).PDB -entry:DriverEntry /SUBSYSTEM:NATIVE /nologo $(LIBS) /out:$(TARGETDIR)$(TARGET).sys
>
> OBJS = <br>> $(OBJDIR)\entry.obj <br>> $(OBJDIR)\functions.obj
>
> LIBS = <br>> wdm.lib <br>> ntoskrnl.lib
>
> # This is a comment
> $(TARGETDIR)$(TARGET): $(OBJDIR) $(TARGETDIR) $(OBJS) $(RESFILE)
> $(LIB32) $(LIB32_FLAGS) $(OBJS) $(LIBS) $(RESFILE)
> $(REBASE) -b 0x00400000 -x $(TARGETDIR)\SYMBOLS -a $(TARGETDIR)$(TARGET)
>
> {.}.c{$(OBJDIR)}.obj::
> $(CPP) $(CPP_PROJ) $<
>
> {.}.cpp{$(OBJDIR)}.obj::
> $(CPP) $(CPP_PROJ) $<
>
> {.}.asm{$(OBJDIR)}.obj::
> $(ASM) $(ASM_PROJ) $<
>
> {.}.rc{$(OBJDIR)}.res::
> $(RSC) $(RES_PROJ) $<
>
> $(OBJDIR):
> if not exist “$(OBJDIR)/$(NULL)” mkdir “$(OBJDIR)”
>
> $(TARGETDIR):
> if not exist “$(TARGETDIR)/$(NULL)” mkdir “$(TARGETDIR)”
>
> CLEAN:
> xxxxx@erase /S /Q $(OBJDIR)
>
> The very first thing I made was rename the lib/include paths (renaming NTDDK with right WDK folder name) and then I tried to build using NMAKE getting some warnings/errors…
>
> Now, the very first question is: which are the differences in building process between BUILD.EXE and NMAKE.EXE ?
>
> Thanks

Thanks all for answers…

My goal is just build my first driver…so I’m interested only in basic operations (i.e. loading/unloading, message print calling DbgPrint(), device name registering and so on…)

it seems creating a
prefast/oacr happy
loading and
working driver
from that sample is not much of a deal

annotated with __drv_dispatchType( IRP_MJ_CREATE ) etc in example.h
for the functions that are declared

and lumped all other IRP_MJ_XXX into
__drv_dispatchType_other
DRIVER_DISPATCH Example_UnSupportedFunction;

(is other the right type or do we need to specify all IRP_MJ_XXX
doesnt seem to be clear in the docs also the docs seem to indicate a
_Dispatch_type (type) which isnt available in
wdk 7

C:\WinDDK\7600.16385.1>pss Dispatch_type

C:\WinDDK\7600.16385.1>python c:\python27\scripts\pss -i Dispatch_type

C:\WinDDK\7600.16385.1>

anyone has any insights on what to use

http://msdn.microsoft.com/en-us/library/windows/hardware/ff544652(v=vs.85).aspx

added PAGED_CODE(); macro to all functions that are #pragma’ed with
alloc_text(PAGE

added these 2 in entry.c
DRIVER_INITIALIZE DriverEntry;
DRIVER_UNLOAD Example_Unload;

and as posted earlier removed the x86 and type_alignment

and prefast seems to be happy build seems to be happy and the driver
loads in xp vm using osrloader

kd> g
DriverEntry Called
Example_Create Called
Example_WriteNeither Called
Hello from user mode!Example_UnSupportedFunction Called
Example_Close Called
Example_Unload Called
DriverEntry Called
Example_Create Called
Example_WriteNeither Called
Hello from user mode!Example_UnSupportedFunction Called
Example_Close Called
Example_Unload Called
DriverEntry Called

so i am curious to know why this sample is termed a PIECE OF CRAP ?

On 1/30/13, xxxxx@alice.it wrote:
> Thanks all for answers…
>
> My goal is just build my first driver…so I’m interested only in basic
> operations (i.e. loading/unloading, message print calling DbgPrint(), device
> name registering and so on…)
>
> —
> NTDEV is sponsored by OSR
>
> OSR is HIRING!! See http://www.osr.com/careers
>
> For our schedule of WDF, WDM, debugging and other seminars visit:
> http://www.osr.com/seminars
>
> To unsubscribe, visit the List Server section of OSR Online at
> http://www.osronline.com/page.cfm?name=ListServer
>

raj…

IIUC you are suggesting to do some modification to the driver code…

I’m not an expert…can you explain me the steps involved ?

I loaded the driver as you on XP/Win 7 using osrloader…how can I use WinDbg kd to get the messages as you have shown ?

Thanks in advance !

raj_r wrote:

it seems creating a
prefast/oacr happy
loading and
working driver
from that sample is not much of a deal

so i am curious to know why this sample is termed a PIECE OF CRAP ?

I don’t necessarily agree with Don’s snap judgment here, but the fact is
many things that seem to work are still stunningly bad examples.


Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.

My judgment was based on having run into this sample in the real world.
First as I pointed out this is a legacy driver. So even though it
implies it is going to help you get going on developing drivers for
devices, it in fact only has an extremely limited use for kernel
services extensions. If your goal is to learn how to program for a
device, of for that matter in general for a modern version of Windows
you should be using KMDF, not legacy. Even if your situation is that
you are forced by circumstances not to use KMDF, then without a good
example of PnP and Power this sample is worthless. Throw in that the
author pushes using an unsupported development environment which is
prone to create subtle bugs, and you have a total disaster.

In my case I was contacted by a company that indicated “we have the
driver basically written, we started with a great sample from the web”.
Of course it was this sample, and they wanted to use it on Vista! I
tried to explain they should throw the crap out and start over with
KMDF. Their answer was “no we invested a lot in this code”, so I
pointed out that the code was unusable unless completely reworked to
reflect PnP, cancelation and Power, and that KMDF would be cheaper.
They then said stop talking about KMDF, we spent 4 months on this driver
and we aren’t changing, they wanted a quote throwing in some PnP, Power
and handling cancel, I explained that this was a lot more work than they
had already done. In the end they shipped the driver out of the country
for the “simple fixes”, what they got back crashed all the time.

So if you are doing anything with real hardware or newer Windows, I
stand by my comment in fact this sample is A TOTAL UNMITIGATED PIECE OF
CRAP.

Don Burn
Windows Filesystem and Driver Consulting
Website: http://www.windrvr.com
Blog: http://msmvps.com/blogs/WinDrvr

“Tim Roberts” wrote in message news:xxxxx@ntdev:

> raj_r wrote:
> > it seems creating a
> > prefast/oacr happy
> > loading and
> > working driver
> > from that sample is not much of a deal
> > …
> > so i am curious to know why this sample is termed a PIECE OF CRAP ?
>
> I don’t necessarily agree with Don’s snap judgment here, but the fact is
> many things that seem to work are still stunningly bad examples.
>
> –
> Tim Roberts, xxxxx@probo.com
> Providenza & Boekelheide, Inc.

> energy drink :slight_smile:

They are evil for health. :slight_smile:


Maxim S. Shatskih
Windows DDK MVP
xxxxx@storagecraft.com
http://www.storagecraft.com

but the fact is many things that seem to work are still stunningly bad examples.

tx tim i am absolutely not disagreeing that it may be bad especially
when there is no pnp and power implemented in that sample
and i do remember jake oshins stating in one of a recent thread

i was just wondering how it is so bad as to be termed a PIECE OF CRAP
when all it does is spew a few dbgprints

It implies that it is starting a developer in the right direction to
develop drivers, this would be true 18 years ago, but for the last 16
years most of knew that the approaches days were numbered. Of course
this was not written more than 16 years ago, so the basis is bad. As I
pointed out it suggests an approach to building drivers that is totally
wrong (I’ve been in companies that fired people for cause for this). It
describes METHOD_NEITHER without any warnings and with code that opens a
security hole. I could go on for a long time here, but bottom line is
use this as a way to start and spend a lot of time unlearning the bad
habits it teaches.

Don Burn
Windows Filesystem and Driver Consulting
Website: http://www.windrvr.com
Blog: http://msmvps.com/blogs/WinDrvr

“raj_r” wrote in message news:xxxxx@ntdev:

> but the fact is many things that seem to work are still stunningly bad examples.
>
> tx tim i am absolutely not disagreeing that it may be bad especially
> when there is no pnp and power implemented in that sample
> and i do remember jake oshins stating in one of a recent thread
>
>


>
> i was just wondering how it is so bad as to be termed a PIECE OF CRAP
> when all it does is spew a few dbgprints

On 1/30/13, xxxxx@alice.it wrote:
> raj…
>
> IIUC you are suggesting to do some modification to the driver code…
>
> I’m not an expert…can you explain me the steps involved ?

follow the paste at the end of this post and you will endup with 24
warnings in prefast
most of them are annotations related and PAGED code related

provide annotations in example.h for all the function prototypes in the form of

__drv_dispatch_Type(type) where type = IRP_MJ_XXXX and
__drv_dispatch_Type_other for Example_Unsupported function

insert PAGED_CODE(); macro after data declarations in every function
that will be paged
in both functions.c and entry.c (refer #pragma alloc_text(PAGE for
list of functions

ADD DRIVER_INITIALIZE to DriverEntry
and DRIVER_UNLOAD to Example_Unload before the prototypes in entry.c

and that should fix the prefast warnings

copy paste the three folders to a target

run kd / windbg -k … in host

use osrloader to load the .sys file as loaddriver doesnt create the
registry keys though it seems to succeed

DriverEntry called dbgprint should be visible in kd

use usedriver.exe to send IRP_MJ_WRITE via WriteFile()

the other debug prints should be visible in kd

stop service and unregister service via osrloader the unload dbgprint
should be visible

paste of build process below

C:&gt;“c:\Program Files\7-Zip\7z.exe” x driverdev_src.zip -o* | findstr /i OK
Everything is Ok

C:&gt;md topferman

C:&gt;xcopy /s /q .\driverdev_src\Programming\development\DEBUG\private\src\driver
s*.* .\topferman
8 File(s) copied

C:&gt;cd topferman

C:\topferman>del /S makefile
Deleted file - C:\topferman\example\makefile
Deleted file - C:\topferman\LoadDriver\makefile
Deleted file - C:\topferman\usedriver\makefile

C:\topferman>copy con dirs
DIRS= <br>example <br>LoadDriver <br>useDriver
^Z
1 file(s) copied.

C:\topferman>cd example

C:\topferman\example>copy con sources
TARGETNAME=Example
TARGETTYPE=DRIVER
TARGETPATH=obj
SOURCES = entry.c <br> functions.c
^Z
1 file(s) copied.

C:\topferman\example>cd …

C:\topferman>cd LoadDriver

C:\topferman\LoadDriver>copy con sources
TARGETTYPE=PROGRAM
TARGETNAME=LoadDriver
TARGETPATH=obj
UMTYPE=console
SOURCES = load.c
USE_MSVCRT=1
^Z
1 file(s) copied.

C:\topferman\LoadDriver>cd …

C:\topferman>cd usedriver

C:\topferman\usedriver>copy con sources
TARGETNAME=UseDriver
TARGETTYPE=PROGRAM
TARGETPATH=obj
UMTYPE=console
USE_MSVCRT=1
SOURCES = load.c
^Z
1 file(s) copied.

C:\topferman\usedriver>copy c:\WinDDK\7600.16385.1\src\general\portio\sys\makefi
le .
1 file(s) copied.

C:\topferman\usedriver>cd …

C:\topferman>cd LoadDriver

C:\topferman\LoadDriver>copy c:\WinDDK\7600.16385.1\src\general\portio\sys\makef
ile .
1 file(s) copied.

C:\topferman\LoadDriver>cd …

C:\topferman>cd example

C:\topferman\example>copy c:\WinDDK\7600.16385.1\src\general\portio\sys\makefile
.
1 file(s) copied.

C:\topferman\example>C:\WinDDK\7600.16385.1\bin\setenv.bat C:\WinDDK\7600.16385.
1\ fre x86 WXP
OACR monitor running already

C:\WinDDK\7600.16385.1>cd c:\topferman

C:\topferman>build
BUILD: Compile and Link for x86
BUILD: Loading c:\winddk\7600.16385.1\build.dat…
BUILD: Computing Include file dependencies:
BUILD: Start time: Thu Jan 31 02:06:56 2013
BUILD: Examining c:\topferman directory tree for files to compile.
c:\topferman\example Invalidating OACR warning log for ‘root:x86fre’
BUILD: Saving c:\winddk\7600.16385.1\build.dat…
BUILD: Compiling and Linking c:\topferman\example directory
Configuring OACR for ‘root:x86fre’ -
NT_TARGET_VERSION SET TO WINXP
Compiling - example\entry.c
1>errors in directory c:\topferman\example
1>c:\topferman\example\entry.c(12) : error C2220: warning treated as error - no
‘object’ file generated
Compiling - example\functions.c
1>c:\topferman\example\functions.c(13) : error C2220: warning treated as error -
no ‘object’ file generated
Compiling - example\generating code…
Linking Executable - example\example\objfre_wxp_x86\i386\example.sys
1>link : error LNK1181: cannot open input file 'c:\topferman\example\objfre_wxp

x86\i386\entry.obj’
BUILD: Compiling and Linking c:\topferman\loaddriver directory
_NT_TARGET_VERSION SET TO WINXP
Compiling - loaddriver\load.c
Linking Executable - loaddriver\loaddriver\objfre_wxp_x86\i386\loaddriver.exe
BUILD: Compiling and Linking c:\topferman\usedriver directory
NT_TARGET_VERSION SET TO WINXP
Compiling - usedriver\load.c
Linking Executable - usedriver\usedriver\objfre_wxp_x86\i386\usedriver.exe
BUILD: Finish time: Thu Jan 31 02:07:12 2013
BUILD: Done

10 files compiled - 3 Warnings - 2 Errors - 569 LPS
3 executables built - 1 Error

C:\topferman>type buildfre_wxp_x86.err
1>errors in directory c:\topferman\example
1>c:\topferman\example\entry.c(12) : error C2220: warning treated as error - no
‘object’ file generated
1>c:\topferman\example\functions.c(13) : error C2220: warning treated as error -
no ‘object’ file generated
1>link : error LNK1181: cannot open input file 'c:\topferman\example\objfre_wxp

x86\i386\entry.obj’

C:\topferman>type buildfre_wxp_x86.wrn
1>warnings in directory c:\topferman\example
1>c:\topferman\example\entry.c(12) : warning C4005: ‘X86’ : macro redefinition

1>c:\topferman\example\functions.c(13) : warning C4005: ‘X86’ : macro redefini
tion
1>c:\topferman\example\functions.c(221) : warning C4116: unnamed type definition
in parentheses

C:\topferman>write example\entry.c

C:\topferman>write example\functions.c

C:\topferman>build
BUILD: Compile and Link for x86
BUILD: Loading c:\winddk\7600.16385.1\build.dat…
BUILD: Computing Include file dependencies:
BUILD: Start time: Thu Jan 31 02:13:17 2013
BUILD: Examining c:\topferman directory tree for files to compile.
c:\topferman\example Invalidating OACR warning log for ‘root:x86fre’
BUILD: Saving c:\winddk\7600.16385.1\build.dat…
BUILD: Compiling and Linking c:\topferman\example directory
Configuring OACR for ‘root:x86fre’ -
_NT_TARGET_VERSION SET TO WINXP
Compiling - example\entry.c
Compiling - example\functions.c
Compiling - example\generating code…
Linking Executable - example\example\objfre_wxp_x86\i386\example.sys
BUILD: Compiling and Linking c:\topferman\loaddriver directory
_NT_TARGET_VERSION SET TO WINXP
BUILD: Compiling and Linking c:\topferman\usedriver directory
_NT_TARGET_VERSION SET TO WINXP
BUILD: Finish time: Thu Jan 31 02:13:20 2013
BUILD: Done

4 files compiled
1 executable built

C:\topferman>type c:\WinDDK\7600.16385.1\OACR\x86\root.x86fre.warnings.xml | gre
p -i DEFECTCOUNT
24

C:\topferman>dir /s /b *.sys
C:\topferman\example\objfre_wxp_x86\i386\Example.sys

C:\topferman>dir /s /b *.exe
C:\topferman\LoadDriver\objfre_wxp_x86\i386\LoadDriver.exe
C:\topferman\usedriver\objfre_wxp_x86\i386\UseDriver.exe

C:\topferman>

and carlo please remember what don burn posted

he doesnt get into ALL CAPITALS without having enough reason

the code should be fine as long as you are interested in seeing a few
debugprints and that is it

dont waste 4 months and a lot of money to make a commercial driver
from this code

use KMDF as recommended

and for a simple KMDF sample look at osronline for a WDF_NOTHING
article to start with

On 1/31/13, raj_r wrote:
> On 1/30/13, xxxxx@alice.it wrote:
>> raj…
>>
>> IIUC you are suggesting to do some modification to the driver code…
>>
>> I’m not an expert…can you explain me the steps involved ?
>
> follow the paste at the end of this post and you will endup with 24
> warnings in prefast
> most of them are annotations related and PAGED code related
>
> provide annotations in example.h for all the function prototypes in the form
> of
>
> __drv_dispatch_Type(type) where type = IRP_MJ_XXXX and
>__drv_dispatch_Type_other for Example_Unsupported function
>
> insert PAGED_CODE(); macro after data declarations in every function
> that will be paged
> in both functions.c and entry.c (refer #pragma alloc_text(PAGE for
> list of functions
>
> ADD DRIVER_INITIALIZE to DriverEntry
> and DRIVER_UNLOAD to Example_Unload before the prototypes in entry.c
>
> and that should fix the prefast warnings
>
> copy paste the three folders to a target
>
> run kd / windbg -k … in host
>
> use osrloader to load the .sys file as loaddriver doesnt create the
> registry keys though it seems to succeed
>
> DriverEntry called dbgprint should be visible in kd
>
> use usedriver.exe to send IRP_MJ_WRITE via WriteFile()
>
> the other debug prints should be visible in kd
>
> stop service and unregister service via osrloader the unload dbgprint
> should be visible
>
>
>
> paste of build process below
>
>
> C:&gt;“c:\Program Files\7-Zip\7z.exe” x driverdev_src.zip -o* | findstr /i
> OK
> Everything is Ok
>
> C:&gt;md topferman
>
> C:&gt;xcopy /s /q
> .\driverdev_src\Programming\development\DEBUG\private\src\driver
> s*.* .\topferman
> 8 File(s) copied
>
> C:&gt;cd topferman
>
> C:\topferman>del /S makefile
> Deleted file - C:\topferman\example\makefile
> Deleted file - C:\topferman\LoadDriver\makefile
> Deleted file - C:\topferman\usedriver\makefile
>
> C:\topferman>copy con dirs
> DIRS= <br>> example <br>> LoadDriver <br>> useDriver
> ^Z
> 1 file(s) copied.
>
> C:\topferman>cd example
>
> C:\topferman\example>copy con sources
> TARGETNAME=Example
> TARGETTYPE=DRIVER
> TARGETPATH=obj
> SOURCES = entry.c <br>> functions.c
> ^Z
> 1 file(s) copied.
>
> C:\topferman\example>cd …
>
> C:\topferman>cd LoadDriver
>
> C:\topferman\LoadDriver>copy con sources
> TARGETTYPE=PROGRAM
> TARGETNAME=LoadDriver
> TARGETPATH=obj
> UMTYPE=console
> SOURCES = load.c
> USE_MSVCRT=1
> ^Z
> 1 file(s) copied.
>
> C:\topferman\LoadDriver>cd …
>
> C:\topferman>cd usedriver
>
> C:\topferman\usedriver>copy con sources
> TARGETNAME=UseDriver
> TARGETTYPE=PROGRAM
> TARGETPATH=obj
> UMTYPE=console
> USE_MSVCRT=1
> SOURCES = load.c
> ^Z
> 1 file(s) copied.
>
> C:\topferman\usedriver>copy
> c:\WinDDK\7600.16385.1\src\general\portio\sys\makefi
> le .
> 1 file(s) copied.
>
> C:\topferman\usedriver>cd …
>
> C:\topferman>cd LoadDriver
>
> C:\topferman\LoadDriver>copy
> c:\WinDDK\7600.16385.1\src\general\portio\sys\makef
> ile .
> 1 file(s) copied.
>
> C:\topferman\LoadDriver>cd …
>
> C:\topferman>cd example
>
> C:\topferman\example>copy
> c:\WinDDK\7600.16385.1\src\general\portio\sys\makefile
> .
> 1 file(s) copied.
>
> C:\topferman\example>C:\WinDDK\7600.16385.1\bin\setenv.bat
> C:\WinDDK\7600.16385.
> 1\ fre x86 WXP
> OACR monitor running already
>
> C:\WinDDK\7600.16385.1>cd c:\topferman
>
> C:\topferman>build
> BUILD: Compile and Link for x86
> BUILD: Loading c:\winddk\7600.16385.1\build.dat…
> BUILD: Computing Include file dependencies:
> BUILD: Start time: Thu Jan 31 02:06:56 2013
> BUILD: Examining c:\topferman directory tree for files to compile.
> c:\topferman\example Invalidating OACR warning log for ‘root:x86fre’
> BUILD: Saving c:\winddk\7600.16385.1\build.dat…
> BUILD: Compiling and Linking c:\topferman\example directory
> Configuring OACR for ‘root:x86fre’ -
> NT_TARGET_VERSION SET TO WINXP
> Compiling - example\entry.c
> 1>errors in directory c:\topferman\example
> 1>c:\topferman\example\entry.c(12) : error C2220: warning treated as error -
> no
> ‘object’ file generated
> Compiling - example\functions.c
> 1>c:\topferman\example\functions.c(13) : error C2220: warning treated as
> error -
> no ‘object’ file generated
> Compiling - example\generating code…
> Linking Executable - example\example\objfre_wxp_x86\i386\example.sys
> 1>link : error LNK1181: cannot open input file
> 'c:\topferman\example\objfre_wxp

> x86\i386\entry.obj’
> BUILD: Compiling and Linking c:\topferman\loaddriver directory
> _NT_TARGET_VERSION SET TO WINXP
> Compiling - loaddriver\load.c
> Linking Executable -
> loaddriver\loaddriver\objfre_wxp_x86\i386\loaddriver.exe
> BUILD: Compiling and Linking c:\topferman\usedriver directory
> NT_TARGET_VERSION SET TO WINXP
> Compiling - usedriver\load.c
> Linking Executable - usedriver\usedriver\objfre_wxp_x86\i386\usedriver.exe
> BUILD: Finish time: Thu Jan 31 02:07:12 2013
> BUILD: Done
>
> 10 files compiled - 3 Warnings - 2 Errors - 569 LPS
> 3 executables built - 1 Error
>
> C:\topferman>type buildfre_wxp_x86.err
> 1>errors in directory c:\topferman\example
> 1>c:\topferman\example\entry.c(12) : error C2220: warning treated as error -
> no
> ‘object’ file generated
> 1>c:\topferman\example\functions.c(13) : error C2220: warning treated as
> error -
> no ‘object’ file generated
> 1>link : error LNK1181: cannot open input file
> 'c:\topferman\example\objfre_wxp

> x86\i386\entry.obj’
>
> C:\topferman>type buildfre_wxp_x86.wrn
> 1>warnings in directory c:\topferman\example
> 1>c:\topferman\example\entry.c(12) : warning C4005: ‘X86’ : macro
> redefinition
>
> 1>c:\topferman\example\functions.c(13) : warning C4005: ‘X86’ : macro
> redefini
> tion
> 1>c:\topferman\example\functions.c(221) : warning C4116: unnamed type
> definition
> in parentheses
>
> C:\topferman>write example\entry.c
>
> C:\topferman>write example\functions.c
>
> C:\topferman>build
> BUILD: Compile and Link for x86
> BUILD: Loading c:\winddk\7600.16385.1\build.dat…
> BUILD: Computing Include file dependencies:
> BUILD: Start time: Thu Jan 31 02:13:17 2013
> BUILD: Examining c:\topferman directory tree for files to compile.
> c:\topferman\example Invalidating OACR warning log for ‘root:x86fre’
> BUILD: Saving c:\winddk\7600.16385.1\build.dat…
> BUILD: Compiling and Linking c:\topferman\example directory
> Configuring OACR for ‘root:x86fre’ -
> _NT_TARGET_VERSION SET TO WINXP
> Compiling - example\entry.c
> Compiling - example\functions.c
> Compiling - example\generating code…
> Linking Executable - example\example\objfre_wxp_x86\i386\example.sys
> BUILD: Compiling and Linking c:\topferman\loaddriver directory
> _NT_TARGET_VERSION SET TO WINXP
> BUILD: Compiling and Linking c:\topferman\usedriver directory
> _NT_TARGET_VERSION SET TO WINXP
> BUILD: Finish time: Thu Jan 31 02:13:20 2013
> BUILD: Done
>
> 4 files compiled
> 1 executable built
>
> C:\topferman>type c:\WinDDK\7600.16385.1\OACR\x86\root.x86fre.warnings.xml |
> gre
> p -i DEFECTCOUNT
> 24
>
> C:\topferman>dir /s /b *.sys
> C:\topferman\example\objfre_wxp_x86\i386\Example.sys
>
> C:\topferman>dir /s /b *.exe
> C:\topferman\LoadDriver\objfre_wxp_x86\i386\LoadDriver.exe
> C:\topferman\usedriver\objfre_wxp_x86\i386\UseDriver.exe
>
> C:\topferman>
>

raj r wrote:

and carlo please remember what don burn posted

he doesnt get into ALL CAPITALS without having enough reason

Ahem…

0n Thu, Jan 31, 2013 at 08:15:20AM +1100, raj_r wrote:

use KMDF as recommended
>
>and for a simple KMDF sample look at osronline for a WDF_NOTHING
>article to start with

Do you mean this one:

http://www.osronline.com/article.cfm?article=390

?

-Alex

************** IMPORTANT MESSAGE *****************************
This e-mail message is intended only for the addressee(s) and contains information which may be
confidential.
If you are not the intended recipient please advise the sender by return email, do not use or
disclose the contents, and delete the message and any attachments from your system. Unless
specifically indicated, this email does not constitute formal advice or commitment by the sender
or the Commonwealth Bank of Australia (ABN 48 123 123 124) or its subsidiaries.
We can be contacted through our web site: commbank.com.au.
If you no longer wish to receive commercial electronic messages from us, please reply to this
e-mail by typing Unsubscribe in the subject line.
**************************************************************

On 1/31/13, Wilkinson, Alex wrote:
> Do you mean this one:
>
> http://www.osronline.com/article.cfm?article=390

yes