Working implementation using kernel32.dll