Discussion:
wdk.h include file, errors need help!
(too old to reply)
buntehaare
2010-12-08 09:45:46 UTC
Permalink
how i can use the wdm.h header file from the Windows Driver Kit in a
Visual Sutio 2010 project.? the main problem is, i get a lot of errors
if i try to compile my project in VS2010!

how i can use the includes of the WDK?



--- code start ---

#include "stdfax.h"
#include "stdio.h"
#include "windows.h"
#include "wdm.h"

int main ...etc...
...
..
.

--- code end ---
Burkhardt Braun
2010-12-09 10:51:42 UTC
Permalink
Post by buntehaare
how i can use the wdm.h header file from the Windows Driver Kit in a
Visual Sutio 2010 project.? the main problem is, i get a lot of errors
if i try to compile my project in VS2010!
how i can  use the includes of the WDK?
--- code start ---
#include "stdfax.h"
#include "stdio.h"
#include "windows.h"
#include "wdm.h"
int main ...etc...
...
..
.
--- code end ---
You should not combine stdafx.h and wdm.h.
That will not work.
Use WDK example build files and import them into your DevStudio.

Kind regards
Burkhardt Braun
buntehaare
2010-12-09 14:04:55 UTC
Permalink
Post by Burkhardt Braun
Post by buntehaare
how i can use the wdm.h header file from the Windows Driver Kit in a
Visual Sutio 2010 project.? the main problem is, i get a lot of errors
if i try to compile my project in VS2010!
how i can use the includes of the WDK?
--- code start ---
#include "stdfax.h"
#include "stdio.h"
#include "windows.h"
#include "wdm.h"
int main ...etc...
...
..
.
--- code end ---
You should not combine stdafx.h and wdm.h.
That will not work.
Use WDK example build files and import them into your DevStudio.
Kind regards
Burkhardt Braun
i know i got it now, but there is a problem that my exe wanna have the
kdcom.dll file, also the hal.dll but this is not the problem, the
kdcom.dll is the problem, i copied the kdcom.dll file from the system
directory into my exe file directory but the exe terminates than witch
error code 0xc00007b i think.. it depends on the kdcom.dll even when i
just call the RtlInitUnicodeString function from the kernel.dll.!

can i disable in my exe that it needs to use the kdcom.dll file?


-------- examplecode starts here ------

#define _X86_
#include <wdm.h>
#include <ntdef.h>
#include <../crt/ctype.h> // auf WDK includes linken!
#include <stdio.h>
#pragma comment (lib,"Ntoskrnl.lib")
#pragma comment (lib,"Kernel32.lib") // im project auf das i386
verzeichnis der Libs linken!

#define _DEBUG_PRINT 0x01
int main(void){
UNICODE_STRING uniName;
RtlInitUnicodeString(&uniName, L"\\Device\\PhysicalMemory");

return 0;
}

-------- examplecode ends here .-------
Burkhardt Braun
2010-12-09 16:15:52 UTC
Permalink
Post by buntehaare
can i disable in my exe that it needs to use the kdcom.dll file?
You could probably, but that will not solve your problem.
Post by buntehaare
#define _DEBUG_PRINT 0x01
int main(void){
UNICODE_STRING     uniName;
RtlInitUnicodeString(&uniName, L"\\Device\\PhysicalMemory");
You're mxing user and kernel code. That might link, as it does, but
will not work.
If you take a look at MSDN Online help for RtlInitUnicodeString:
"Callers of RtlInitUnicodeString can be running at IRQL <=
DISPATCH_LEVEL if the DestinationString buffer is nonpageable. "

You can neither guarantee anything about "IRQL in user mode" nor afaik
that the DestinationString buffer is nonpageable.
IIRC User mode memory is always pageable.

I would write a kernel mode driver or import the required data by hand
in my application.
Kind regards
Burkhardt Braun
buntehaare
2010-12-09 16:48:26 UTC
Permalink
so u think i should define Structs and types per hand ?
RtlInitUnicodeString define new in my own header file and
get the functin direktly out of hand loaded DLL??

hmmm well i think about it, maybe it's the only way :(

thought first, i would save a lot of work with the wdm.h and the
ntoskrnl.lib but, no! must do it per hand as i saw!

thanx for help!

nice greetings
buntehaare :)
Post by Burkhardt Braun
Post by buntehaare
can i disable in my exe that it needs to use the kdcom.dll file?
You could probably, but that will not solve your problem.
Post by buntehaare
#define _DEBUG_PRINT 0x01
int main(void){
UNICODE_STRING uniName;
RtlInitUnicodeString(&uniName, L"\\Device\\PhysicalMemory");
You're mxing user and kernel code. That might link, as it does, but
will not work.
"Callers of RtlInitUnicodeString can be running at IRQL<=
DISPATCH_LEVEL if the DestinationString buffer is nonpageable. "
You can neither guarantee anything about "IRQL in user mode" nor afaik
that the DestinationString buffer is nonpageable.
IIRC User mode memory is always pageable.
I would write a kernel mode driver or import the required data by hand
in my application.
Kind regards
Burkhardt Braun
Burkhardt Braun
2010-12-09 17:21:00 UTC
Permalink
Post by buntehaare
so u think i should define Structs and types per hand ?
Well I personally prefer the clipboard ;)
Post by buntehaare
RtlInitUnicodeString define new in my own header file and
get the functin direktly out of hand loaded DLL??
No! In user mode I would try to access the Object with CreateFile(),
although this will not work under Server 2003 sp1.
Calling RtlInitUnicodeString from user mode will not work.
Post by buntehaare
hmmm well i think about it, maybe it's the only way :(
From my point of view a device driver is the right choice, finally you
have a wdk.
Kind regards
Burkhardt Braun
buntehaare
2010-12-09 17:56:56 UTC
Permalink
in Windows XP and under, i sucessfully accessed the object in usermode
with a kernel object!

but yes i have WDK maybe i think about a kernel driver !

regards
buntehaare
Post by Burkhardt Braun
Post by buntehaare
so u think i should define Structs and types per hand ?
Well I personally prefer the clipboard ;)
Post by buntehaare
RtlInitUnicodeString define new in my own header file and
get the functin direktly out of hand loaded DLL??
No! In user mode I would try to access the Object with CreateFile(),
although this will not work under Server 2003 sp1.
Calling RtlInitUnicodeString from user mode will not work.
Post by buntehaare
hmmm well i think about it, maybe it's the only way :(
From my point of view a device driver is the right choice, finally you
have a wdk.
Kind regards
Burkhardt Braun
Loading...