Skip to content

CreateFile failed on WinServer2022 #1

@UEFI-code

Description

@UEFI-code

Run this with Administrator priv

#include <windows.h>
#include <stdio.h>

static HANDLE kbd;

void OpenKeyboardDevice()
{
  if(!DefineDosDevice(DDD_RAW_TARGET_PATH, "Kbd000000",
		      "\\Device\\KeyboardClass0"))
  {
    printf("Error DosDevice\n");
    exit(-1);
  }

  kbd = CreateFile("\\\\.\\Kbd000000", GENERIC_WRITE, 0,
		   NULL, OPEN_EXISTING, 0, NULL);
}

int main()
{
	OpenKeyboardDevice();
	printf("%llx\n", kbd);
}

Output: ffffffffffffffff
Any idea?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions