PocketMatrix forums

A read-only archive of the PocketMatrix forums (2001–2014). Posting and accounts are closed.

How to switch to kernel mode?

I need to switch my application to kernel mode.
The docs say that this can be done using SetKMode() but that function is not available in the WM5 SDK.

Any ideas?

thanks,
Daniel
SetKMode() is part of the DDK, not the SDK.

The signature is:

Code:

DWORD SetKMode( DWORD );


The function is in coredll.dll. So you will have to dynamically bind to it.

Usage:

Code:


DWORD previousMode = SetKMode( 1 );

// Do something that requires kernel mode

SetKMode( previousMode );

Thanks a lot Thierry. The method is obvious, works and I should have guessed it myself.

Now another question: Is there a better way to find out if switching to kernel mode worked than switching back and checking the return value of SetKMode?

Daniel
I don't know of any way. I always surround my kernel mode code with a __try / __catch pair, just in case.

Even if SetKMode() succeeds, I've run into cases where the opcodes I was executing were not supported by a given CPU.