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

rtdelkey.c File Reference

#include "cmp.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

Go to the source code of this file.

Defines

#define WORK_SIZE   1024

Functions

void __cdecl main (int, char *)
void processargs ()
void Delete (HANDLE Handle)
void __cdecl main (int argc, char *argv[])
void processargs (int argc, char *argv[])

Variables

UNICODE_STRING WorkName
WCHAR workbuffer [WORK_SIZE]


Define Documentation

#define WORK_SIZE   1024
 

Definition at line 34 of file rtdelkey.c.


Function Documentation

void Delete HANDLE  Handle  ) 
 

Definition at line 103 of file rtdeltre.c.

References Delete(), exit, Handle, NT_SUCCESS, NtClose(), NtDeleteKey(), NtEnumerateKey(), NtOpenKey(), NTSTATUS(), NULL, ObjectAttributes, RtlAppendStringToString(), TRUE, WORK_SIZE, and WorkName.

Referenced by RtlpDeleteFromMergedRange().

00106 { 00107 NTSTATUS status; 00108 PKEY_BASIC_INFORMATION KeyInformation; 00109 OBJECT_ATTRIBUTES ObjectAttributes; 00110 ULONG NamePos; 00111 ULONG index; 00112 STRING enumname; 00113 HANDLE WorkHandle; 00114 ULONG ResultLength; 00115 static char buffer[WORK_SIZE]; 00116 00117 KeyInformation = (PKEY_BASIC_INFORMATION)buffer; 00118 NamePos = WorkName.Length; 00119 00120 // 00121 // Enumerate node's children and apply ourselves to each one 00122 // 00123 00124 index = 0; 00125 do { 00126 00127 RtlZeroMemory(KeyInformation, WORK_SIZE); 00128 status = NtEnumerateKey( 00129 Handle, 00130 index, 00131 KeyBasicInformation, 00132 KeyInformation, 00133 WORK_SIZE, 00134 &ResultLength 00135 ); 00136 00137 if (status == STATUS_NO_MORE_ENTRIES) { 00138 00139 WorkName.Length = NamePos; 00140 break; 00141 00142 } else if (!NT_SUCCESS(status)) { 00143 00144 printf("regtest3: dump1: status = %08lx\n", status); 00145 exit(1); 00146 00147 } 00148 00149 enumname.Buffer = &(KeyInformation->Name[0]); 00150 enumname.Length = KeyInformation->NameLength; 00151 enumname.MaximumLength = KeyInformation->NameLength; 00152 00153 RtlAppendStringToString((PSTRING)&WorkName, (PSTRING)&enumname); 00154 00155 InitializeObjectAttributes( 00156 &ObjectAttributes, 00157 &enumname, 00158 OBJ_CASE_INSENSITIVE, 00159 Handle, 00160 NULL 00161 ); 00162 00163 status = NtOpenKey( 00164 &WorkHandle, 00165 DELETE | KEY_ENUMERATE_SUB_KEYS, 00166 &ObjectAttributes 00167 ); 00168 if (!NT_SUCCESS(status)) { 00169 printf("regtest3: couldn't delete %wZ: %08lx\n", &enumname,status); 00170 index++; 00171 } else { 00172 Delete(WorkHandle); 00173 NtClose(WorkHandle); 00174 } 00175 00176 WorkName.Length = NamePos; 00177 00178 } while (TRUE); 00179 00180 // 00181 // If we're here, then we have delt with all children, so deal with 00182 // the node we were applied to 00183 // 00184 00185 NtDeleteKey(Handle); 00186 NtClose(Handle); // Force it to actually go away 00187 return; 00188 }

void __cdecl main int  argc,
char *  argv[]
 

Definition at line 48 of file rtdelkey.c.

References exit, L, NT_SUCCESS, NtClose(), NtDeleteKey(), NtOpenKey(), NTSTATUS(), NULL, ObjectAttributes, processargs(), WORK_SIZE, workbuffer, and WorkName.

00052 { 00053 NTSTATUS status; 00054 OBJECT_ATTRIBUTES ObjectAttributes; 00055 HANDLE BaseHandle; 00056 00057 // 00058 // Process args 00059 // 00060 00061 WorkName.MaximumLength = WORK_SIZE; 00062 WorkName.Length = 0L; 00063 WorkName.Buffer = &(workbuffer[0]); 00064 00065 processargs(argc, argv); 00066 00067 00068 // 00069 // Set up and open KeyPath 00070 // 00071 00072 printf("rtdelkey: starting\n"); 00073 00074 InitializeObjectAttributes( 00075 &ObjectAttributes, 00076 &WorkName, 00077 0, 00078 (HANDLE)NULL, 00079 NULL 00080 ); 00081 ObjectAttributes.Attributes |= OBJ_CASE_INSENSITIVE; 00082 00083 status = NtOpenKey( 00084 &BaseHandle, 00085 DELETE, 00086 &ObjectAttributes 00087 ); 00088 if (!NT_SUCCESS(status)) { 00089 printf("rtdelkey: t0: %08lx\n", status); 00090 exit(1); 00091 } 00092 00093 status = NtDeleteKey(BaseHandle); 00094 if (!NT_SUCCESS(status)) { 00095 printf("rtdelkey: t1: %08lx\n", status); 00096 exit(1); 00097 } 00098 00099 NtClose(BaseHandle); 00100 exit(0); 00101 }

void __cdecl main int  ,
char * 
 

void processargs int  argc,
char *  argv[]
 

Definition at line 104 of file rtdelkey.c.

References exit, RtlAnsiStringToUnicodeString(), RtlInitAnsiString(), TRUE, and WorkName.

00108 { 00109 ANSI_STRING temp; 00110 00111 if ( (argc != 2) ) 00112 { 00113 printf("Usage: %s <KeyPath>\n", 00114 argv[0]); 00115 exit(1); 00116 } 00117 00118 RtlInitAnsiString( 00119 &temp, 00120 argv[1] 00121 ); 00122 00123 RtlAnsiStringToUnicodeString( 00124 &WorkName, 00125 &temp, 00126 TRUE 00127 ); 00128 00129 return; 00130 }

void processargs  ) 
 


Variable Documentation

WCHAR workbuffer[WORK_SIZE]
 

Definition at line 45 of file rtdelkey.c.

UNICODE_STRING WorkName
 

Definition at line 44 of file rtdelkey.c.


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