how to add additional c and h files to an existing WDM project

Hi,

I got the task to fix some errors in existing WDM drivers. Therefore I got the existing code of those drivers. There is a common folder, that contains code, which is used in several drivers.

Now I tried to add a couple of files ( a *.c and a *.h file ) to the common folder.

From within the existing driver sources I called functions of the added source file.

When compiling the existing drivers they did not used the added source code files.

I searched in the make, source, etc… file of the existing driver to figure out, where the new added source files has to be entered. I was not able to find the location where the new added source file should be added, to be taken in account during the driver building / compilation process.

Where must those added sources file be mentioned?

In which makefile, source file, or else I have to add the added *.c / *.h files.

Thanks in advance for good answers.

You need to append the name of each source module - c, cpp, rc, but NOT h,
hpp, et. c. - to the definition of the ‘SOURCES’ macro in the ‘SOURCES’ file
of the target (directory) to which you wish to add the files.

For example, say you created these new files:

file1.c
file1.h

And the existing sources file looked like this:

SOURCES = a.c \
b.c \
a.rc

You’d change it to:

SOURCES = a.c \
b.c \
a.rc \
file.c

If the files are in a common directory, then you’ll need to adjust the path
accordingly. The thing is, the rule on the SOURCES macro is that it can
only specify files that are in the same directory as the SOURCES file, or in
the parent directory of the one that contains the sources file (there are
also a few special cases for architecture specific files, but that’s
important here).

The usual scenario for this is something like this:

Dir1:
File1.c
Dir2:
Sources
File2.c
Dir3:
Sources
File3.c

Where the SOURCES statement in ‘Dir1/Dir2/Sources’ would look something
like:

SOURCES = File2.c \
…\File1.c

If you’ve got a src tree that is along the lines of:

Dir1:
Dirs
Common:
File1.c
Driver:
Sources
File2.c

And ‘Common/File1.c’ is actually getting included in the build of the
‘Driver’ directory, then unfortunately, the situation is more complicated,
but let’s see what your src tree actually looks like.

Good luck,

mm

(This question really should have been posted to the ntdev list. It’s not
a big deal or anything, but in addition to it being more suitable, many,
many, many more people participate in the ntdev list than the windbg list,
so you’re odds of getting more/better/faster help are much better there.)

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of
xxxxx@siemens.com
Sent: Thursday, February 10, 2011 6:16 PM
To: Kernel Debugging Interest List
Subject: [windbg] how to add additional c and h files to an existing WDM
project

Hi,

I got the task to fix some errors in existing WDM drivers. Therefore I got
the existing code of those drivers. There is a common folder, that contains
code, which is used in several drivers.

Now I tried to add a couple of files ( a *.c and a *.h file ) to the common
folder.

From within the existing driver sources I called functions of the added
source file.

When compiling the existing drivers they did not used the added source code
files.

I searched in the make, source, etc… file of the existing driver to figure
out, where the new added source files has to be entered. I was not able to
find the location where the new added source file should be added, to be
taken in account during the driver building / compilation process.

Where must those added sources file be mentioned?

In which makefile, source file, or else I have to add the added *.c / *.h
files.

Thanks in advance for good answers.


WINDBG is sponsored by OSR

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

Thanks for that fast and detailed answers.

Glad to help.

Did it work?

mm

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of
xxxxx@siemens.com
Sent: Friday, February 11, 2011 7:26 AM
To: Kernel Debugging Interest List
Subject: RE:[windbg] how to add additional c and h files to an existing WDM
project

Thanks for that fast and detailed answers.


WINDBG is sponsored by OSR

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