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

rtdmpval.c

Go to the documentation of this file.
00001 /*++ 00002 00003 Copyright (c) 1991 Microsoft Corporation 00004 00005 Module Name: 00006 00007 rtdmpval.c 00008 00009 Abstract: 00010 00011 NT level registry api test program, basic non-error paths. 00012 00013 dump a key's value entry (field) 00014 00015 rtdmpval <KeyPath> <value entry name> 00016 00017 Example: 00018 00019 rtdmpval \REGISTRY\MACHINE\TEST\bigkey first_value_field 00020 00021 Author: 00022 00023 John Vert (jvert) 25-Mar-1993 (written expressly for reading JimK's 00024 supersecret file) 00025 00026 Revision History: 00027 00028 --*/ 00029 00030 #include "cmp.h" 00031 #include <stdio.h> 00032 #include <stdlib.h> 00033 #include <string.h> 00034 00035 #define WORK_SIZE 1024 00036 00037 void __cdecl main(int, char *); 00038 void processargs(); 00039 00040 void 00041 Delete( 00042 HANDLE Handle 00043 ); 00044 00045 UNICODE_STRING WorkName; 00046 WCHAR workbuffer[WORK_SIZE]; 00047 00048 UNICODE_STRING ValueName; 00049 WCHAR valuebuffer[WORK_SIZE]; 00050 00051 void 00052 __cdecl main( 00053 int argc, 00054 char *argv[] 00055 ) 00056 { 00057 NTSTATUS status; 00058 OBJECT_ATTRIBUTES ObjectAttributes; 00059 HANDLE BaseHandle; 00060 KEY_VALUE_PARTIAL_INFORMATION PartialInfo; 00061 PKEY_VALUE_PARTIAL_INFORMATION pInfo; 00062 ULONG i; 00063 ULONG Count; 00064 00065 00066 // 00067 // Process args 00068 // 00069 00070 WorkName.MaximumLength = WORK_SIZE; 00071 WorkName.Length = 0L; 00072 WorkName.Buffer = &(workbuffer[0]); 00073 00074 00075 ValueName.MaximumLength = WORK_SIZE; 00076 ValueName.Length = 0L; 00077 ValueName.Buffer = &(valuebuffer[0]); 00078 00079 processargs(argc, argv); 00080 00081 00082 // 00083 // Set up and open KeyPath 00084 // 00085 00086 printf("rtdmpval: starting\n"); 00087 00088 InitializeObjectAttributes( 00089 &ObjectAttributes, 00090 &WorkName, 00091 0, 00092 (HANDLE)NULL, 00093 NULL 00094 ); 00095 ObjectAttributes.Attributes |= OBJ_CASE_INSENSITIVE; 00096 00097 status = NtOpenKey( 00098 &BaseHandle, 00099 KEY_READ, 00100 &ObjectAttributes 00101 ); 00102 if (!NT_SUCCESS(status)) { 00103 printf("rtdmpval: t0: %08lx\n", status); 00104 exit(1); 00105 } 00106 00107 status = NtQueryValueKey(BaseHandle, 00108 &ValueName, 00109 KeyValuePartialInformation, 00110 &PartialInfo, 00111 sizeof(PartialInfo), 00112 &Count); 00113 00114 pInfo=malloc(PartialInfo.DataLength+sizeof(PartialInfo)); 00115 status = NtQueryValueKey(BaseHandle, 00116 &ValueName, 00117 KeyValuePartialInformation, 00118 pInfo, 00119 PartialInfo.DataLength+sizeof(PartialInfo), 00120 &Count); 00121 if (!NT_SUCCESS(status)) { 00122 printf("rtdmpval: t2: %08lx\n", status); 00123 exit(1); 00124 } 00125 00126 for (i=0; i<PartialInfo.DataLength; i++) { 00127 printf("%c",pInfo->Data[i]); 00128 } 00129 00130 free(pInfo); 00131 NtClose(BaseHandle); 00132 exit(0); 00133 } 00134 00135 void 00136 processargs( 00137 int argc, 00138 char *argv[] 00139 ) 00140 { 00141 ANSI_STRING temp; 00142 00143 if ( (argc != 3) ) 00144 { 00145 printf("Usage: %s <KeyPath> <value entry name>\n", 00146 argv[0]); 00147 exit(1); 00148 } 00149 00150 RtlInitAnsiString( 00151 &temp, 00152 argv[1] 00153 ); 00154 00155 RtlAnsiStringToUnicodeString( 00156 &WorkName, 00157 &temp, 00158 TRUE 00159 ); 00160 00161 RtlInitAnsiString( 00162 &temp, 00163 argv[2] 00164 ); 00165 00166 RtlAnsiStringToUnicodeString( 00167 &ValueName, 00168 &temp, 00169 TRUE 00170 ); 00171 00172 return; 00173 }

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