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.

173 lines
3.2 KiB

  1. /*++
  2. Copyright (c) 1991 Microsoft Corporation
  3. Module Name:
  4. rtdmpval.c
  5. Abstract:
  6. NT level registry api test program, basic non-error paths.
  7. dump a key's value entry (field)
  8. rtdmpval <KeyPath> <value entry name>
  9. Example:
  10. rtdmpval \REGISTRY\MACHINE\TEST\bigkey first_value_field
  11. Author:
  12. John Vert (jvert) 25-Mar-1993 (written expressly for reading JimK's
  13. supersecret file)
  14. Revision History:
  15. --*/
  16. #include "cmp.h"
  17. #include <stdio.h>
  18. #include <stdlib.h>
  19. #include <string.h>
  20. #define WORK_SIZE 1024
  21. void __cdecl main(int, char *);
  22. void processargs();
  23. void
  24. Delete(
  25. HANDLE Handle
  26. );
  27. UNICODE_STRING WorkName;
  28. WCHAR workbuffer[WORK_SIZE];
  29. UNICODE_STRING ValueName;
  30. WCHAR valuebuffer[WORK_SIZE];
  31. void
  32. __cdecl main(
  33. int argc,
  34. char *argv[]
  35. )
  36. {
  37. NTSTATUS status;
  38. OBJECT_ATTRIBUTES ObjectAttributes;
  39. HANDLE BaseHandle;
  40. KEY_VALUE_PARTIAL_INFORMATION PartialInfo;
  41. PKEY_VALUE_PARTIAL_INFORMATION pInfo;
  42. ULONG i;
  43. ULONG Count;
  44. //
  45. // Process args
  46. //
  47. WorkName.MaximumLength = WORK_SIZE;
  48. WorkName.Length = 0L;
  49. WorkName.Buffer = &(workbuffer[0]);
  50. ValueName.MaximumLength = WORK_SIZE;
  51. ValueName.Length = 0L;
  52. ValueName.Buffer = &(valuebuffer[0]);
  53. processargs(argc, argv);
  54. //
  55. // Set up and open KeyPath
  56. //
  57. printf("rtdmpval: starting\n");
  58. InitializeObjectAttributes(
  59. &ObjectAttributes,
  60. &WorkName,
  61. 0,
  62. (HANDLE)NULL,
  63. NULL
  64. );
  65. ObjectAttributes.Attributes |= OBJ_CASE_INSENSITIVE;
  66. status = NtOpenKey(
  67. &BaseHandle,
  68. KEY_READ,
  69. &ObjectAttributes
  70. );
  71. if (!NT_SUCCESS(status)) {
  72. printf("rtdmpval: t0: %08lx\n", status);
  73. exit(1);
  74. }
  75. status = NtQueryValueKey(BaseHandle,
  76. &ValueName,
  77. KeyValuePartialInformation,
  78. &PartialInfo,
  79. sizeof(PartialInfo),
  80. &Count);
  81. pInfo=malloc(PartialInfo.DataLength+sizeof(PartialInfo));
  82. status = NtQueryValueKey(BaseHandle,
  83. &ValueName,
  84. KeyValuePartialInformation,
  85. pInfo,
  86. PartialInfo.DataLength+sizeof(PartialInfo),
  87. &Count);
  88. if (!NT_SUCCESS(status)) {
  89. printf("rtdmpval: t2: %08lx\n", status);
  90. exit(1);
  91. }
  92. for (i=0; i<PartialInfo.DataLength; i++) {
  93. printf("%c",pInfo->Data[i]);
  94. }
  95. free(pInfo);
  96. NtClose(BaseHandle);
  97. exit(0);
  98. }
  99. void
  100. processargs(
  101. int argc,
  102. char *argv[]
  103. )
  104. {
  105. ANSI_STRING temp;
  106. if ( (argc != 3) )
  107. {
  108. printf("Usage: %s <KeyPath> <value entry name>\n",
  109. argv[0]);
  110. exit(1);
  111. }
  112. RtlInitAnsiString(
  113. &temp,
  114. argv[1]
  115. );
  116. RtlAnsiStringToUnicodeString(
  117. &WorkName,
  118. &temp,
  119. TRUE
  120. );
  121. RtlInitAnsiString(
  122. &temp,
  123. argv[2]
  124. );
  125. RtlAnsiStringToUnicodeString(
  126. &ValueName,
  127. &temp,
  128. TRUE
  129. );
  130. return;
  131. }