Leaked source code of windows server 2003
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.

172 lines
3.0 KiB

  1. /*++
  2. Copyright (c) 1991 Microsoft Corporation
  3. Module Name:
  4. rtrenval.c
  5. Abstract:
  6. NT level registry api test program, basic non-error paths.
  7. Rename a key value entry.
  8. rtrenval <KeyPath> <old value entry name> <new value entry name>
  9. Example:
  10. rtrenval \REGISTRY\MACHINE\TEST\bigkey apple banana
  11. Author:
  12. Bryan Willman (bryanwi) 26-Feb-92
  13. Revision History:
  14. --*/
  15. #include "cmp.h"
  16. #include <stdio.h>
  17. #include <stdlib.h>
  18. #include <string.h>
  19. #define WORK_SIZE 1024
  20. void __cdecl main(int, char *);
  21. void processargs();
  22. void
  23. Delete(
  24. HANDLE Handle
  25. );
  26. UNICODE_STRING WorkName;
  27. WCHAR workbuffer[WORK_SIZE];
  28. UNICODE_STRING ValueName;
  29. WCHAR valuebuffer[WORK_SIZE];
  30. UNICODE_STRING NewValueName;
  31. WCHAR newvaluebuffer[WORK_SIZE];
  32. void
  33. __cdecl main(
  34. int argc,
  35. char *argv[]
  36. )
  37. {
  38. NTSTATUS status;
  39. OBJECT_ATTRIBUTES ObjectAttributes;
  40. HANDLE BaseHandle;
  41. //
  42. // Process args
  43. //
  44. WorkName.MaximumLength = WORK_SIZE;
  45. WorkName.Length = 0L;
  46. WorkName.Buffer = &(workbuffer[0]);
  47. ValueName.MaximumLength = WORK_SIZE;
  48. ValueName.Length = 0L;
  49. ValueName.Buffer = &(valuebuffer[0]);
  50. NewValueName.MaximumLength = WORK_SIZE;
  51. NewValueName.Length = 0L;
  52. NewValueName.Buffer = &(newvaluebuffer[0]);
  53. processargs(argc, argv);
  54. //
  55. // Set up and open KeyPath
  56. //
  57. printf("rtrenval: 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_SET_VALUE,
  69. &ObjectAttributes
  70. );
  71. if (!NT_SUCCESS(status)) {
  72. printf("rtrenval: t0: %08lx\n", status);
  73. exit(1);
  74. }
  75. NtRenameValueKey(
  76. BaseHandle,
  77. &ValueName,
  78. &NewValueName,
  79. 42
  80. );
  81. if (!NT_SUCCESS(status)) {
  82. printf("rtrenval: t1: %08lx\n", status);
  83. exit(1);
  84. }
  85. NtClose(BaseHandle);
  86. exit(0);
  87. }
  88. void
  89. processargs(
  90. int argc,
  91. char *argv[]
  92. )
  93. {
  94. ANSI_STRING temp;
  95. if ( (argc != 4) )
  96. {
  97. printf("Usage: %s <KeyPath> <old value entry name> <new value entry name>\n",
  98. argv[0]);
  99. exit(1);
  100. }
  101. RtlInitAnsiString(
  102. &temp,
  103. argv[1]
  104. );
  105. RtlAnsiStringToUnicodeString(
  106. &WorkName,
  107. &temp,
  108. TRUE
  109. );
  110. RtlInitAnsiString(
  111. &temp,
  112. argv[2]
  113. );
  114. RtlAnsiStringToUnicodeString(
  115. &ValueName,
  116. &temp,
  117. TRUE
  118. );
  119. RtlInitAnsiString(
  120. &temp,
  121. argv[3]
  122. );
  123. RtlAnsiStringToUnicodeString(
  124. &NewValueName,
  125. &temp,
  126. TRUE
  127. );
  128. return;
  129. }