Fix masked access violation in KERNEL32

Caused crashes under gdb in Windows and might cause other unknown problems.