Building KMDF driver for Windows 7-32bit using 7600WDK

Hi,

I am developing a makefile to build KMDF driver for Windows 7 using 7600WDK. The build is successful. But when I try to install the driver on the target windows 7 machine. I observe the exception BugCheck 7E, {c0000005, 0, 8a91f4e8, 8a91f0c0}
when WdfDriverCreate function call is made.
Following are my linker options in make file
-MERGE:_PAGE=PAGE -MERGE:_TEXT=.text -SECTION:INIT,d \
-OPT:REF -OPT:ICF \
-IGNORE:4010,4037,4039,4065,4070,4078,4087,4089,4198,4221 \
-INCREMENTAL:NO -FULLBUILD /release -NODEFAULTLIB /WX \
-debug:FULL -debugtype:cv -version:6 -osversion:6 \
-STACK:0x40000,0x1000 /DRIVER -base:0x10000 \
-align:0x80 -subsystem:native -entry:xxxxx@8 \
-map /MACHINE:IX86

From different discussion on forums I learn that the there is a problem with KMDF binding so I have used the KMDF_VERSION_MAJOR=1 option in the build flags. Is there any additional option I need to enable to solve this problem.

Regards,
Vinayak

Without a !analyze -v of the dump it is unlikely that your bug can be
explained. Give us the analsis.

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

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of
xxxxx@gmail.com
Sent: Thursday, January 16, 2014 8:45 AM
To: Windows System Software Devs Interest List
Subject: [ntdev] Building KMDF driver for Windows 7-32bit using 7600WDK

Hi,

I am developing a makefile to build KMDF driver for Windows 7 using 7600WDK.
The build is successful. But when I try to install the driver on the target
windows 7 machine. I observe the exception BugCheck 7E, {c0000005, 0,
8a91f4e8, 8a91f0c0}
when WdfDriverCreate function call is made.
Following are my linker options in make file
-MERGE:_PAGE=PAGE -MERGE:_TEXT=.text -SECTION:INIT,d \
-OPT:REF -OPT:ICF \

-IGNORE:4010,4037,4039,4065,4070,4078,4087,4089,4198,4221 \
-INCREMENTAL:NO -FULLBUILD /release -NODEFAULTLIB
/WX \
-debug:FULL -debugtype:cv -version:6 -osversion:6 \
-STACK:0x40000,0x1000 /DRIVER -base:0x10000 \
-align:0x80 -subsystem:native -entry:xxxxx@8 \
-map /MACHINE:IX86

From different discussion on forums I learn that the there is a problem with
KMDF binding so I have used the KMDF_VERSION_MAJOR=1 option in the build
flags. Is there any additional option I need to enable to solve this
problem.

Regards,
Vinayak


NTDEV is sponsored by OSR

Visit the list at: http://www.osronline.com/showlists.cfm?list=ntdev

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

Why ate you specifying all of these linker flags directly? Are you actually using the wdk build or rolling your own build environment?

d

Bent from my phone


From: xxxxx@gmail.commailto:xxxxx
Sent: ?1/?16/?2014 5:42 AM
To: Windows System Software Devs Interest Listmailto:xxxxx
Subject: [ntdev] Building KMDF driver for Windows 7-32bit using 7600WDK

Hi,

I am developing a makefile to build KMDF driver for Windows 7 using 7600WDK. The build is successful. But when I try to install the driver on the target windows 7 machine. I observe the exception BugCheck 7E, {c0000005, 0, 8a91f4e8, 8a91f0c0}
when WdfDriverCreate function call is made.
Following are my linker options in make file
-MERGE:_PAGE=PAGE -MERGE:_TEXT=.text -SECTION:INIT,d <br> -OPT:REF -OPT:ICF <br> -IGNORE:4010,4037,4039,4065,4070,4078,4087,4089,4198,4221 <br> -INCREMENTAL:NO -FULLBUILD /release -NODEFAULTLIB /WX <br> -debug:FULL -debugtype:cv -version:6 -osversion:6 <br> -STACK:0x40000,0x1000 /DRIVER -base:0x10000 <br> -align:0x80 -subsystem:native -entry:xxxxx@8 <br> -map /MACHINE:IX86

From different discussion on forums I learn that the there is a problem with KMDF binding so I have used the KMDF_VERSION_MAJOR=1 option in the build flags. Is there any additional option I need to enable to solve this problem.

Regards,
Vinayak


NTDEV is sponsored by OSR

Visit the list at: http://www.osronline.com/showlists.cfm?list=ntdev

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</mailto:xxxxx></mailto:xxxxx>

Make ‘sources’ file. Don’t write your own makefile. Use build.exe to build drivers.

Hi Doron, Alex,

I am using the existing build system(Existing system is for WinXP and WDM driver). I am trying to reuse the existing build system for Win7 and KMDF driver. It uses cl.exe along with linker options mentioned before.
As Alex suggested I could use build.exe. But I am trying to reuse existing system.
@Alex: Would build.exe by default support KMDF driver build. Also could you suggest where I can find the information on using build.exe for building drivers.

Regards,
Vinayak

Get rid of the existing system, every time I have ever encountered one of
these with a client (i.e. where they did not use BUILD), there were bugs
that occurred because they tried to roll their own. Even if it all works
perfectly, you are shutting yourself off from tools that Microsoft provides
such as PreFast that expect BUILD. Using a non-standard build environment
is about the stupidest thing you can do when developing Windows drivers.

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

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of
xxxxx@gmail.com
Sent: Thursday, January 16, 2014 1:16 PM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] Building KMDF driver for Windows 7-32bit using 7600WDK

Hi Doron, Alex,

I am using the existing build system(Existing system is for WinXP and WDM
driver). I am trying to reuse the existing build system for Win7 and KMDF
driver. It uses cl.exe along with linker options mentioned before.
As Alex suggested I could use build.exe. But I am trying to reuse existing
system.
@Alex: Would build.exe by default support KMDF driver build. Also could you
suggest where I can find the information on using build.exe for building
drivers.

Regards,
Vinayak


NTDEV is sponsored by OSR

Visit the list at: http://www.osronline.com/showlists.cfm?list=ntdev

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@gmail.com wrote:

I am using the existing build system(Existing system is for WinXP and WDM driver). I am trying to reuse the existing build system for Win7 and KMDF driver. It uses cl.exe along with linker options mentioned before.

That has NEVER been a supported scenario. Never.

As Alex suggested I could use build.exe. But I am trying to reuse existing system.
@Alex: Would build.exe by default support KMDF driver build. Also could you suggest where I can find the information on using build.exe for building drivers.

As an example, you can look at every sample driver in every WDK up
through 7600. They ALL use “build”.

Note that “build” is not a foreign world for someone used to makefiles,
because “build” is just a preprocessor for “nmake”. “Build” scans the
source code for include file dependencies, sets up environment
variables, and then calls “nmake” to do the real work. Your directory
has a “makefile” that includes the WDK’s “makefile.def”, which
eventually includes your “sources” file.


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

Thst bugcheck tells that you are getting an access-denied error (c0000005)
when reading (0) memory at [if I recall correctly, but I may have swapped
these two…] at location 8a9114e8, by an istruction at location
08a91f0c0. The output of !analyze -v would help isolate this. Make sure
windbg has the .pdb file for your driver. This may help a lot in figuring
out just what happened.
joe

Hi,

I am developing a makefile to build KMDF driver for Windows 7 using
7600WDK. The build is successful. But when I try to install the driver on
the target windows 7 machine. I observe the exception BugCheck 7E,
{c0000005, 0, 8a91f4e8, 8a91f0c0}
when WdfDriverCreate function call is made.
Following are my linker options in make file
-MERGE:_PAGE=PAGE -MERGE:_TEXT=.text -SECTION:INIT,d \
-OPT:REF -OPT:ICF \
-IGNORE:4010,4037,4039,4065,4070,4078,4087,4089,4198,4221 \
-INCREMENTAL:NO -FULLBUILD /release -NODEFAULTLIB /WX \
-debug:FULL -debugtype:cv -version:6 -osversion:6 \
-STACK:0x40000,0x1000 /DRIVER -base:0x10000 \
-align:0x80 -subsystem:native -entry:xxxxx@8 \
-map /MACHINE:IX86

From different discussion on forums I learn that the there is a problem
with KMDF binding so I have used the KMDF_VERSION_MAJOR=1 option in the
build flags. Is there any additional option I need to enable to solve this
problem.

Regards,
Vinayak


NTDEV is sponsored by OSR

Visit the list at: http://www.osronline.com/showlists.cfm?list=ntdev

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

Hi,

Here is the !analyze -v output
kd> !analyze -v
*******************************************************************************
* *
* Bugcheck Analysis *
* *
*******************************************************************************

SYSTEM_THREAD_EXCEPTION_NOT_HANDLED (7e)
This is a very common bugcheck. Usually the exception address pinpoints
the driver/function that caused the problem. Always note this address
as well as the link date of the driver/image that contains this address.
Arguments:
Arg1: c0000005, The exception code that was not handled
Arg2: 00000000, The address that the exception occurred at
Arg3: 8a9134f8, Exception Record Address
Arg4: 8a9130d0, Context Record Address

Debugging Details:

EXCEPTION_CODE: (NTSTATUS) 0xc0000005 - The instruction at 0x%08lx referenced memory at 0x%08lx. The memory could not be %s.

FAULTING_IP:
+57d6952f0231de84
00000000 ?? ???

EXCEPTION_RECORD: 8a9134f8 – (.exr 0xffffffff8a9134f8)
ExceptionAddress: 00000000
ExceptionCode: c0000005 (Access violation)
ExceptionFlags: 00000000
NumberParameters: 2
Parameter[0]: 00000008
Parameter[1]: 00000000
Attempt to execute non-executable address 00000000

CONTEXT: 8a9130d0 – (.cxr 0xffffffff8a9130d0)
eax=84df5000 ebx=00000000 ecx=84e500d0 edx=00000000 esi=84e500d0 edi=84df5000
eip=00000000 esp=8a9135c0 ebp=8a9135dc iopl=0 nv up ei pl nz na po nc
cs=0008 ss=0010 ds=0023 es=0023 fs=0030 gs=0000 efl=00010202
00000000 ?? ???
Resetting default scope

DEFAULT_BUCKET_ID: VISTA_DRIVER_FAULT

PROCESS_NAME: System

CURRENT_IRQL: 2

ERROR_CODE: (NTSTATUS) 0xc0000005 - The instruction at 0x%08lx referenced memory at 0x%08lx. The memory could not be %s.

EXCEPTION_PARAMETER1: 00000008

EXCEPTION_PARAMETER2: 00000000

WRITE_ADDRESS: 00000000

FOLLOWUP_IP:
XXXXXX!WdfDriverCreate+24 [c:\tools\msdev\7600wdk\inc\wdf\kmdf\1.9\wdfdriver.h @ 219]
96259864 5d pop ebp

FAILED_INSTRUCTION_ADDRESS:
+57d6952f0231de84
00000000 ?? ???

BUGCHECK_STR: 0x7E

LOCK_ADDRESS: 8297df60 – (!locks 8297df60)

Resource @ nt!PiEngineLock (0x8297df60) Exclusively owned
Contention Count = 10
Threads: 848dba70-01<*>
1 total locks, 1 locks currently held

PNP_TRIAGE:
Lock address : 0x8297df60
Thread Count : 1
Thread address: 0x848dba70
Thread wait : 0x1f74e

LAST_CONTROL_TRANSFER: from 828f4c9d to 82882554

STACK_TEXT:
WARNING: Frame IP not in any known module. Following frames may be wrong.
8a9135bc 96259864 00000000 84e500d0 84df5000 0x0
8a9135dc 96259670 84e500d0 84df5000 00000000 xxxxxx!WdfDriverCreate+0x24 [c:\tools\msdev\7600wdk\inc\wdf\kmdf\1.9\wdfdriver.h @ 219]
8a913668 829bb7da 84e500d0 84df5000 c000035f xxxxxx!DriverEntry+0x60 [z:.….…\xx_xxx.c @ 1455]
8a91384c 829c3099 00000000 00000000 8a913874 nt!IopLoadDriver+0x7ed
8a9138f8 82a07f7d 9ee38610 00000001 9ee385fc nt!PipCallDriverAddDeviceQueryRoutine+0x34b
8a913934 82a1030c 8a913a2c 8a913988 95ba8b00 nt!RtlpCallQueryRegistryRoutine+0x292
8a9139cc 829c01ba 40000000 80000370 8a913a48 nt!RtlQueryRegistryValues+0x414
8a913aa8 829bf928 8486d880 8a913cd0 84cfad60 nt!PipCallDriverAddDevice+0x383
8a913ca4 829c871b 8486d880 84cfad60 8a913cd0 nt!PipProcessDevNodeTree+0x15d
8a913cd8 8282bf56 8297be80 848dba70 829525bc nt!PiRestartDevice+0x8a
8a913d00 8288510b 00000000 00000000 848dba70 nt!PnpDeviceActionWorker+0x1fb
8a913d50 82a26b6f 00000001 22265ea4 00000000 nt!ExpWorkerThread+0x10d
8a913d90 828d8299 82884ffe 00000001 00000000 nt!PspSystemThreadStartup+0x9e
00000000 00000000 00000000 00000000 00000000 nt!KiThreadStartup+0x19

FAULTING_SOURCE_CODE:
No source found for ‘c:\tools\msdev\7600wdk\inc\wdf\kmdf\1.9\wdfdriver.h’

SYMBOL_STACK_INDEX: 1

SYMBOL_NAME: xxxxxx!WdfDriverCreate+24

FOLLOWUP_NAME: MachineOwner

MODULE_NAME: xxxxxx

IMAGE_NAME: xxxxxx.sys

DEBUG_FLR_IMAGE_TIMESTAMP: 52d7c9e4

STACK_COMMAND: .cxr 0xffffffff8a9130d0 ; kb

FAILURE_BUCKET_ID: 0x7E_NULL_IP_xxxxxx!WdfDriverCreate+24

BUCKET_ID: 0x7E_NULL_IP_xxxxxx!WdfDriverCreate+24

Followup: MachineOwner

Tim,

I am using the existing build system(Existing system is for WinXP and WDM
driver). I am trying to reuse the existing build system for Win7 and KMDF
driver. It uses cl.exe along with linker options mentioned before.

>That has NEVER been a supported scenario. Never.

Sorry, I could not get what you meant. Did you mean KMDF driver for Win7 using 7600WDK is never supported for cl.exe in specific? Or is it that even build.exe environment does not support building KMDF driver for Win7 using 7600wdk? Because I see the wdf\kmdf\1.9 support being available in 7600wdk.

Regards,
Vinayak

What he means is the only supported method for building a kmdf driver in the win7 wdk is to use the wdk build environment and build.exe to invoke it.

d

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@gmail.com
Sent: Thursday, January 16, 2014 10:17 PM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] Building KMDF driver for Windows 7-32bit using 7600WDK

Tim,

I am using the existing build system(Existing system is for WinXP and
WDM
driver). I am trying to reuse the existing build system for Win7 and KMDF driver. It uses cl.exe along with linker options mentioned before.

>That has NEVER been a supported scenario. Never.

Sorry, I could not get what you meant. Did you mean KMDF driver for Win7 using 7600WDK is never supported for cl.exe in specific? Or is it that even build.exe environment does not support building KMDF driver for Win7 using 7600wdk? Because I see the wdf\kmdf\1.9 support being available in 7600wdk.

Regards,
Vinayak


NTDEV is sponsored by OSR

Visit the list at: http://www.osronline.com/showlists.cfm?list=ntdev

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

Manual meddling into cl.exe options is not supported.

Use BUILD (or, for Win8 WDK, the MSVC plugin) to build a KMDF driver. There are samples for this.


Maxim S. Shatskih
Microsoft MVP on File System And Storage
xxxxx@storagecraft.com
http://www.storagecraft.com

wrote in message news:xxxxx@ntdev…
> Tim,
>> I am using the existing build system(Existing system is for WinXP and WDM
> driver). I am trying to reuse the existing build system for Win7 and KMDF
> driver. It uses cl.exe along with linker options mentioned before.
>
>>>That has NEVER been a supported scenario. Never.
>
> Sorry, I could not get what you meant. Did you mean KMDF driver for Win7 using 7600WDK is never supported for cl.exe in specific? Or is it that even build.exe environment does not support building KMDF driver for Win7 using 7600wdk? Because I see the wdf\kmdf\1.9 support being available in 7600wdk.
>
> Regards,
> Vinayak
>
>

xxxxx@gmail.com wrote:

Tim,
>> That has NEVER been a supported scenario. Never.
Sorry, I could not get what you meant. Did you mean KMDF driver for Win7 using 7600WDK is never supported for cl.exe in specific? Or is it that even build.exe environment does not support building KMDF driver for Win7 using 7600wdk? Because I see the wdf\kmdf\1.9 support being available in 7600wdk.

No, what I mean is that building drivers by constructing your own
makefiles without using build.exe has never been supported.


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

Thanks everyone for your suggestions. As per your suggestion I am now using the build.exe in my make file and I am able to build the driver project.
Now when I try installing the new driver I am still getting a similar exception as above, for which I have shared !analyze -v.
I am not sure but I suspect it could be due to the wdf library dependency which I am using during the build. Like I am using following three libraries ndis.lib, wdf/kmdf/i386/1.9/wdfdriverentry.lib and wdf/kmdf/i386/1.9/wdfldr.lib for resolving wdf related linker errors. Is this library inclusion correct? or Is there any other way?

Also in the target computer I have same 7600wdk. Also I have exported the path of libraries in the Environment variable path setting. Please let me know is this the right approach for setting the target PC environment?

Regards,
Vinayak

Are you able to successfully build and install one of the WDK sample drivers with your current setup?

I would also try building your driver the standard WDK way, forgoing your custom build process for now, and see if that results in a working binary. Also put ‘KMDF_VERSION_MAJOR=1’ and ‘KMDF_VERSION_MINOR=9’ in your sources file just in case.

DO NOT put KMDF libraries in your ‘sources’ file. As Alex Margarit said, you MUST specify KMDF_VERSION_MAJOR and KMDF_VERSION_MINOR in ‘sources’.