Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

rtunload.c

Go to the documentation of this file.
00001 /*++ 00002 00003 Copyright (c) 1991 Microsoft Corporation 00004 00005 Module Name: 00006 00007 rtunload.c 00008 00009 Abstract: 00010 00011 NT level registry api test program, basic non-error paths. 00012 00013 Perform an NtUnloadKey call to unlink a hive file from the registry. 00014 00015 rtunload <KeyPath> 00016 00017 Example: 00018 00019 rtunload \registry\user\JVert 00020 00021 Author: 00022 00023 John Vert (jvert) 17-Apr-92 00024 00025 Revision History: 00026 00027 --*/ 00028 #include <nt.h> 00029 #include <ntrtl.h> 00030 #include <nturtl.h> 00031 00032 #include <stdio.h> 00033 #include <stdlib.h> 00034 #include <string.h> 00035 00036 #define WORK_SIZE 1024 00037 00038 void __cdecl main(int, char *); 00039 void processargs(); 00040 00041 UNICODE_STRING KeyPath; 00042 WCHAR KeyPathBuffer[WORK_SIZE]; 00043 00044 void 00045 __cdecl main( 00046 int argc, 00047 char *argv[] 00048 ) 00049 { 00050 NTSTATUS status; 00051 OBJECT_ATTRIBUTES KeyAttributes; 00052 IO_STATUS_BLOCK IoStatus; 00053 HANDLE FileHandle; 00054 HANDLE KeyHandle; 00055 BOOLEAN WasEnabled; 00056 00057 // 00058 // Process args 00059 // 00060 00061 KeyPath.MaximumLength = WORK_SIZE; 00062 KeyPath.Length = 0L; 00063 KeyPath.Buffer = &(KeyPathBuffer[0]); 00064 00065 processargs(argc, argv); 00066 00067 00068 printf("rtunload: starting\n"); 00069 00070 RtlAdjustPrivilege(SE_RESTORE_PRIVILEGE, TRUE, FALSE, &WasEnabled); 00071 // 00072 // Set up KeyPath 00073 // 00074 00075 InitializeObjectAttributes( 00076 &KeyAttributes, 00077 &KeyPath, 00078 OBJ_CASE_INSENSITIVE, 00079 (HANDLE)NULL, 00080 NULL 00081 ); 00082 00083 status = NtUnloadKey(&KeyAttributes); 00084 00085 RtlAdjustPrivilege(SE_RESTORE_PRIVILEGE, WasEnabled, FALSE, &WasEnabled); 00086 00087 if (!NT_SUCCESS(status)) { 00088 printf("rtunload: key unload failed status = %08lx\n", status); 00089 exit(1); 00090 } else { 00091 printf("rtunload: success!\n"); 00092 } 00093 00094 exit(0); 00095 } 00096 00097 void 00098 processargs( 00099 int argc, 00100 char *argv[] 00101 ) 00102 { 00103 ANSI_STRING temp; 00104 00105 if ( (argc != 2) ) 00106 { 00107 printf("Usage: %s <KeyName>\n", 00108 argv[0]); 00109 exit(1); 00110 } 00111 00112 RtlInitAnsiString( 00113 &temp, 00114 argv[1] 00115 ); 00116 00117 RtlAnsiStringToUnicodeString( 00118 &KeyPath, 00119 &temp, 00120 TRUE 00121 ); 00122 00123 return; 00124 }

Generated on Sat May 15 19:41:41 2004 for test by doxygen 1.3.7