0

I'm writing a Windows DLL and I need some functions from wdm.h. I'm linking with ntoskrnl.lib and it compiles just find with no warnings or errors and when it runs the application, it says cannot find ntoskrnl.exe. However, that EXE is in my C:\Windows\System32 folder. What is going on?

Caleb Merchant
  • 289
  • 1
  • 5
  • 16

2 Answers2

1

The error is confusing. It doesn't mean it can't find the file, it means it can't load it. You can't load ntoskrnl.exe in usermode because it is a kernel mode DLL. In fact it is the kernel. Loading it again doesn't make any sense. wdm.h is not meant to be included by user mode components.

Stewart
  • 3,978
  • 17
  • 20
  • That makes sense. Thank you. However, I have the WDK from Windows and I set my project type as a DLL the commincates with Kernel Drivers. I must need to add something in order to use ntoskrnl.exe. Would you happen to know what I need to do? – Caleb Merchant Jun 04 '15 at 18:54
  • What are you actually trying to do? What makes you think that you need to use ntoskrnl.exe in order to do it? – Harry Johnston Jun 05 '15 at 01:34
  • I'm making a kernel (audio) streaming driver. I need it for some IO stuff. – Caleb Merchant Jun 05 '15 at 01:52
1

Ah, I think I have fixed the problem. Then I got a warning that said .crt section exists. I found out I can't use the CRT library when I'm in kernel mode. So I fixed that. Now I have one question. If I create this driver in kernel mode, will I be able to access it with a C/C++ program in user mode?

Caleb Merchant
  • 289
  • 1
  • 5
  • 16
  • https://msdn.microsoft.com/en-us/library/windows/desktop/aa363219%28v=vs.85%29.aspx and https://msdn.microsoft.com/en-us/library/windows/hardware/ff543287%28v=vs.85%29.aspx – Harry Johnston Jun 05 '15 at 03:56
  • Thanks for your help. I think part of my problem is I need to research Windows drivers a little more. – Caleb Merchant Jun 05 '15 at 04:10
  • Sounds sensible. :-) Note that some kinds of drivers are radically different to others; the links above are applicable to generic drivers but might not necessarily apply to your particular scenario. – Harry Johnston Jun 05 '15 at 04:13
  • Well glancing over them it looks like pretty useful information. – Caleb Merchant Jun 05 '15 at 04:16