Anything related to MS Windows Kernel API (part of Windows API), residing in the `kernel32.dll` library. This library provides basic kernel services to user code, e.g. copying or locking a file, creating a mutex or a process, allocating memory, etc. This library is used by both 32-bit and 64-bit Windows, despite the name.
Questions tagged [kernel32]
307 questions
5
votes
1 answer
CreateFile in Kernel32.dll does not allow me to open a physical disk
I am trying to use the following code to get the MBR from PhysicalDrive0:
private static byte[] ReadMbr(string lpFileName)
{
byte[] mbr = new byte[512];
using (SafeFileHandle drive = CreateFile(
lpFileName: lpFileName,
…

Dan Balthaser
- 702
- 7
- 10
5
votes
1 answer
Is there a C# & VB compatible System.Void* in F#? (To close a pointer to nonmanaged Alloc?)
[]
extern bool CloseHandle(System.Void* handle);
//System.Void also throws same error
//extern bool CloseHandle(System.Void handle);
gives the error:
'System.Void' can only be used as 'typeof' in F#
but
…

turkinator
- 905
- 9
- 25
5
votes
1 answer
Change the PowerShell console font programmatically
I've developed a script that acts as a console based application (think ncurses) using PowerShell.
The font Lucida Console is configured within a shortcut to the script.
I'd like to provide the user with the ability to change the font size. The…

Fitzroy
- 229
- 2
- 7
5
votes
1 answer
Calling kernel32's ReadProcessMemory in Go
I'm trying to manipulate processes on Windows using Go language,
and I'm starting off by reading other process' memory by using ReadProcessMemory.
However, for most of the addresses I get Error: Only part of a ReadProcessMemory or WriteProcessMemory…

Hongweng
- 129
- 1
- 8
5
votes
2 answers
JMeter - Webdriver error : java.lang.NoClassDefFoundError: com/sun/jna/platform/win32/Kernel32
This error:
jmeter log,
appears everytime I run a testscript in Jmeter.
But everything works...
It is just this error that appears everytime in log after the actual script had run.
Can I ignore this error? Or will it influences my…

Paili
- 825
- 5
- 18
- 30
5
votes
3 answers
What does mandatory integrity level value of 0x2010 stand for?
I'm running the following snippet of code in my user-mode process that starts up when a Windows user account logs in to the workstation. Or, in other words, its path is placed in the HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run…

c00000fd
- 20,994
- 29
- 177
- 400
4
votes
3 answers
How to identify where an exception is being thrown during finalization in a Delphi application?
I am working onsite with a client, and I am trying to help them with a complicated problem. I am hoping that there is a tool or feature in Delphi that we can use to peer into the inner workings to help us locate the problem.
Here is a high level…

Cary Jensen
- 3,751
- 3
- 32
- 55
4
votes
4 answers
Unable to find an entry point named 'InterlockedIncrement' in DLL 'kernel32.dll' - VS2005@Win7 64 bit
I have a problem with my Visual Studio 2005 C# project. I have been using it under Windows XP, since Monday. Then my laptop broke down and on my new one I have Windows 7 64 bit and I am still using VS 2005.
There is no problem with compilation of…

MPękalski
- 6,873
- 4
- 26
- 36
4
votes
2 answers
P/Invoke call just stops
I'm trying to write data to a serial port via P/Invoke (explicitly not with the SerialPort-class). Here's what I have so far:
[DllImport("kernel32", SetLastError = true)]
static extern IntPtr CreateFile(string filename, // file name
…

Papa Mufflon
- 17,558
- 5
- 27
- 35
4
votes
2 answers
Why does GetFileVersionInfo on kernel32.dll in Windows 10 return version 6.2?
I am trying to retrieve kernel32.dll version in order to perform a Windows version check. Yet, for some reason, even though kernel32.dll's version (as seen in file properties) is 10.0.10586.0, the returned version is: 6.2.10586.0
how come?
DWORD…

RanH
- 740
- 1
- 11
- 31
4
votes
0 answers
How does a Windows EXE find LoadLibrary
The LoadLibrary function in kernel32.dll can be used to dynamically load a dll, but how is LoadLibrary itself located? To find it we would need to know the address where the dictionary for kernel32.dll is, and the ordinal of the LoadLibrary call.…

Tyler Durden
- 11,156
- 9
- 64
- 126
4
votes
2 answers
C# EntryPointNotFoundException Unable to find an entry point named 'SetDllDirectory' in DLL 'kernel32.dll'
I am trying to use several functions from kernal32.dll. However, when my application tries to call the first function it throws an EntryPointNotFoundException Unable to find an entry point named 'SetDllDirectory' in DLL 'kernel32.dll'.
public class…

Jim Fell
- 13,750
- 36
- 127
- 202
4
votes
0 answers
Access SYSTEM_POWER_STATE_CONTEXT from user-mode code
I'm curious if there's a way (even if undocumented) to access SYSTEM_POWER_STATE_CONTEXT from a Windows local service written in C++ running in user-mode?
My goal is to distinguish between the system waking from sleep vs. hibernation, similar to…

c00000fd
- 20,994
- 29
- 177
- 400
4
votes
0 answers
C# benchmarking: How accurate is Process.TotalProcessorTime
I'm trying to measure the execution time of processes within C#. This is the code I'm using to do this:
private static double TimeProcess(string name, string workingDirectory, string arguments)
{
Process process = new Process();
…

Asoto
- 39
- 2
4
votes
2 answers
SetFileTime returning error code 5
I am trying to P/Invoke SetFileTime, but I can't seem to get it to work. It always returns an error code of 5 for me (access denied), and I am not sure why. Here is the code I am using:
void Main()
{
var pointer =…

Alexandru
- 12,264
- 17
- 113
- 208