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.

128 lines
2.1 KiB

  1. /*++
  2. Copyright (c) 1992 Microsoft Corporation
  3. Module Name:
  4. rtflush.c
  5. Abstract:
  6. NT level registry test program, basic non-error paths.
  7. Flush a key.
  8. rtflush <KeyPath>
  9. Will flush the key named by <KeyPath>
  10. Example:
  11. rtflush \REGISTRY\MACHINE\TEST\bigkey
  12. Author:
  13. Bryan Willman (bryanwi) 10-Jan-92
  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. UNICODE_STRING WorkName;
  24. WCHAR workbuffer[WORK_SIZE];
  25. void
  26. __cdecl main(
  27. int argc,
  28. char *argv[]
  29. )
  30. {
  31. NTSTATUS status;
  32. OBJECT_ATTRIBUTES ObjectAttributes;
  33. HANDLE BaseHandle;
  34. //
  35. // Process args
  36. //
  37. WorkName.MaximumLength = WORK_SIZE;
  38. WorkName.Length = 0L;
  39. WorkName.Buffer = &(workbuffer[0]);
  40. processargs(argc, argv);
  41. //
  42. // Set up and open KeyPath
  43. //
  44. printf("rtflush: starting\n");
  45. InitializeObjectAttributes(
  46. &ObjectAttributes,
  47. &WorkName,
  48. 0,
  49. (HANDLE)NULL,
  50. NULL
  51. );
  52. ObjectAttributes.Attributes |= OBJ_CASE_INSENSITIVE;
  53. status = NtOpenKey(
  54. &BaseHandle,
  55. MAXIMUM_ALLOWED,
  56. &ObjectAttributes
  57. );
  58. if (!NT_SUCCESS(status)) {
  59. printf("rtflush: t0: %08lx\n", status);
  60. exit(1);
  61. }
  62. status = NtFlushKey(BaseHandle);
  63. if (!NT_SUCCESS(status)) {
  64. printf("rtflush: t0: %08lx\n", status);
  65. exit(1);
  66. }
  67. NtClose(BaseHandle);
  68. exit(0);
  69. }
  70. void
  71. processargs(
  72. int argc,
  73. char *argv[]
  74. )
  75. {
  76. ANSI_STRING temp;
  77. if ( (argc != 2) )
  78. {
  79. printf("Usage: %s <KeyPath>\n",
  80. argv[0]);
  81. exit(1);
  82. }
  83. RtlInitAnsiString(
  84. &temp,
  85. argv[1]
  86. );
  87. RtlAnsiStringToUnicodeString(
  88. &WorkName,
  89. &temp,
  90. FALSE
  91. );
  92. return;
  93. }