News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

KMD include file collision

Started by shlomok, April 28, 2012, 04:47:56 PM

Previous topic - Next topic

shlomok

Hi,
My KMD driver inc has the following import statements (this is the standard):

include w2k\ntstatus.inc
include w2k\ntddk.inc
include w2k\ntoskrnl.inc   
include \masm32\Macros\Strings.mac

includelib \masm32\lib\w2k\ntoskrnl.lib


Now, I want to print the current date and time using DbgPrint, however the declaration of SYSTEMTIME and GetLocalTime for instance is not in my include files.

I tried including window.inc etc ... which I know is forbidden inside a KMD.


getCurrentDateAndTime proc

LOCAL lpDateBuf[12] :BYTE
LOCAL lpTimeBuf[12] :BYTE
LOCAL lpLocalTime :SYSTEMTIME
   
;Get the local time
invoke GetLocalTime, addr lpLocalTime

;Format the date
invoke GetDateFormat,0,0,addr lpLocalTime,addr hDateFormat,addr lpDateBuf,12

;Format the time
invoke GetTimeFormat,0,0,addr lpLocalTime, addr hTimeFormat, addr lpTimeBuf, 12
invoke StdOut, addr lpDateBuf
invoke StdOut, addr lpTimeBuf        
ret
getCurrentDateAndTime endp



How can I resolve this issue?

And another question, accessing the GDI directly from KMD is also forbidden, is there an option to delegate the GDI calls from my own driver to my own  DLL that I will write so that the DLL will call the GDI functions?
(i am not talking at all about DLL proxying)
I mean, will the DLL used by my KMD driver have to obey the same restrictions as the driver itself?

Thanks,

shlomok

These are answers from the author of KMD:

Quote1-GetLocalTime is a user-mode function exported from kernel32.dll.
Kernel-mode drivers can't be linked with the user-mode code and
can't call any user-mode code.

Call kernel-mode KeQuerySystemTime/ExSystemTimeToLocalTime instead.

2-Kernel-mode code can't call any user-mode stuff regardless of whether
it is the driver or dll.

3-Yes, kernel-mode dll have the same restrictions as the drivers.