Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

54 lines
1.4 KiB

  1. #include "ntos.h"
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4. #include <string.h>
  5. void
  6. main(
  7. )
  8. {
  9. NTSTATUS Status;
  10. OBJECT_ATTRIBUTES Attr1;
  11. OBJECT_ATTRIBUTES Attr2;
  12. UNICODE_STRING Name1;
  13. UNICODE_STRING Name2;
  14. HANDLE Handle1;
  15. HANDLE Handle2;
  16. IO_STATUS_BLOCK IoStatusBlock;
  17. RtlInitUnicodeString(&Name1, L"\\DosDevices");
  18. RtlInitUnicodeString(&Name2, L"C:\\Nt");
  19. InitializeObjectAttributes(&Attr1,
  20. &Name1,
  21. OBJ_CASE_INSENSITIVE,
  22. NULL,
  23. NULL);
  24. Status = NtOpenDirectoryObject(&Handle1,
  25. DIRECTORY_QUERY,
  26. &Attr1);
  27. if (!NT_SUCCESS(Status)) {
  28. printf("NtOpenDirectoryObject failed %08lx\n",Status);
  29. exit(1);
  30. }
  31. InitializeObjectAttributes(&Attr2,
  32. &Name2,
  33. OBJ_CASE_INSENSITIVE,
  34. Handle1,
  35. NULL);
  36. Status = NtOpenFile(&Handle2,
  37. FILE_LIST_DIRECTORY,
  38. &Attr2,
  39. &IoStatusBlock,
  40. FILE_SHARE_READ | FILE_SHARE_WRITE,
  41. 0);
  42. if (!NT_SUCCESS(Status)) {
  43. printf("NtOpenFile failed %08lx\n",Status);
  44. exit(1);
  45. }
  46. printf("success\n");
  47. }
  48.