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

rtqval.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 __cdecl main (int argc, char *argv[])
void processargs (int argc, char *argv[])

Variables

UNICODE_STRING WorkName
WCHAR workbuffer [WORK_SIZE]
UNICODE_STRING WorkName2
WCHAR workbuffer2 [WORK_SIZE]
UCHAR Buffer [1024 *64]
ULONG InfoType = KeyValueFullInformation
ULONG BufferSize = -1


Define Documentation

#define WORK_SIZE   1024
 

Definition at line 34 of file rtqval.c.


Function Documentation

void __cdecl main int  argc,
char *  argv[]
 

Definition at line 54 of file rtqval.c.

References Buffer, BufferSize, exit, InfoType, L, NT_SUCCESS, NtClose(), NtOpenKey(), NtQueryValueKey(), NTSTATUS(), NULL, ObjectAttributes, processargs(), WORK_SIZE, workbuffer, workbuffer2, WorkName, and WorkName2.

00058 { 00059 NTSTATUS status; 00060 OBJECT_ATTRIBUTES ObjectAttributes; 00061 HANDLE BaseHandle; 00062 ULONG Sizes[] = { sizeof(KEY_VALUE_BASIC_INFORMATION), 00063 sizeof(KEY_VALUE_FULL_INFORMATION) }; 00064 ULONG ResultLength; 00065 PKEY_VALUE_BASIC_INFORMATION pbasic; 00066 PKEY_VALUE_FULL_INFORMATION pfull; 00067 PKEY_VALUE_PARTIAL_INFORMATION ppartial; 00068 00069 // 00070 // Process args 00071 // 00072 00073 WorkName.MaximumLength = WORK_SIZE; 00074 WorkName.Length = 0L; 00075 WorkName.Buffer = &(workbuffer[0]); 00076 00077 WorkName2.MaximumLength = WORK_SIZE; 00078 WorkName2.Length = 0L; 00079 WorkName2.Buffer = &(workbuffer2[0]); 00080 00081 processargs(argc, argv); 00082 00083 00084 // 00085 // Set up and open KeyPath 00086 // 00087 00088 printf("rtqkey: starting\n"); 00089 00090 InitializeObjectAttributes( 00091 &ObjectAttributes, 00092 &WorkName, 00093 0, 00094 (HANDLE)NULL, 00095 NULL 00096 ); 00097 ObjectAttributes.Attributes |= OBJ_CASE_INSENSITIVE; 00098 00099 status = NtOpenKey( 00100 &BaseHandle, 00101 KEY_QUERY_VALUE, 00102 &ObjectAttributes 00103 ); 00104 if (!NT_SUCCESS(status)) { 00105 printf("rtqkey: t0: %08lx\n", status); 00106 exit(1); 00107 } 00108 00109 // 00110 // make test call 00111 // 00112 RtlFillMemory((PVOID)&(Buffer[0]), 1024*64, 0xaa); 00113 00114 if (BufferSize == -1) { 00115 BufferSize = Sizes[InfoType]; 00116 } 00117 00118 status = NtQueryValueKey( 00119 BaseHandle, 00120 &WorkName2, 00121 InfoType, 00122 (PVOID)&(Buffer[0]), 00123 BufferSize, 00124 &ResultLength 00125 ); 00126 00127 printf("status = %08lx ResultLength = %08lx\n", status, ResultLength); 00128 switch (InfoType) { 00129 case KeyValueBasicInformation: 00130 pbasic = (PKEY_VALUE_BASIC_INFORMATION)Buffer; 00131 printf("TitleIndex: %08lx\n", pbasic->TitleIndex); 00132 printf(" Type: %08lx\n", pbasic->Type); 00133 printf("NameLength: %08lx\n", pbasic->NameLength); 00134 printf(" Name: '%.*ws'\n", pbasic->NameLength/2, &(pbasic->Name)); 00135 break; 00136 00137 case KeyValueFullInformation: 00138 pfull = (PKEY_VALUE_FULL_INFORMATION)Buffer; 00139 printf("TitleIndex: %08lx\n", pfull->TitleIndex); 00140 printf(" Type: %08lx\n", pfull->Type); 00141 printf("DataOffset: %08lx\n", pfull->DataOffset); 00142 printf("DataLength: %08lx\n", pfull->DataLength); 00143 printf("NameLength: %08lx\n", pfull->NameLength); 00144 printf(" Name: '%.*ws'\n", pfull->NameLength/2, &(pfull->Name)); 00145 printf(" Data: '%.*ws'\n", pfull->DataLength/2, 00146 ((PUCHAR)pfull + pfull->DataOffset) ); 00147 break; 00148 00149 case KeyValuePartialInformation: 00150 ppartial = (PKEY_VALUE_PARTIAL_INFORMATION)Buffer; 00151 printf("TitleIndex: %08lx\n", ppartial->TitleIndex); 00152 printf(" Type: %08lx\n", ppartial->Type); 00153 printf("DataLength: %08lx\n", ppartial->DataLength); 00154 printf(" Data: '%.*ws'\n", ppartial->DataLength/2, 00155 ((PUCHAR)&(ppartial->Data))); 00156 break; 00157 } 00158 00159 NtClose(BaseHandle); 00160 exit(0); 00161 }

void __cdecl main int  ,
char * 
 

void processargs int  argc,
char *  argv[]
 

Definition at line 164 of file rtqval.c.

References BufferSize, exit, InfoType, RtlAnsiStringToUnicodeString(), RtlInitAnsiString(), TRUE, WorkName, and WorkName2.

00168 { 00169 ANSI_STRING temp; 00170 00171 if ( (argc < 2) ) 00172 { 00173 printf("Usage: %s <KeyPath> [infotype] [bufferlen]\n", 00174 argv[0]); 00175 exit(1); 00176 } 00177 00178 RtlInitAnsiString( 00179 &temp, 00180 argv[1] 00181 ); 00182 00183 RtlAnsiStringToUnicodeString( 00184 &WorkName, 00185 &temp, 00186 TRUE 00187 ); 00188 00189 RtlInitAnsiString( 00190 &temp, 00191 argv[2] 00192 ); 00193 00194 RtlAnsiStringToUnicodeString( 00195 &WorkName2, 00196 &temp, 00197 TRUE 00198 ); 00199 00200 if (argc > 3) { 00201 InfoType = atoi(argv[3]); 00202 } 00203 00204 if (argc > 4) { 00205 BufferSize = atoi(argv[4]); 00206 } 00207 00208 return; 00209 }

void processargs  ) 
 


Variable Documentation

UCHAR Buffer[1024 *64]
 

Definition at line 48 of file rtqval.c.

ULONG BufferSize = -1
 

Definition at line 51 of file rtqval.c.

ULONG InfoType = KeyValueFullInformation
 

Definition at line 50 of file rtqval.c.

WCHAR workbuffer[WORK_SIZE]
 

Definition at line 40 of file rtqval.c.

WCHAR workbuffer2[WORK_SIZE]
 

Definition at line 45 of file rtqval.c.

Referenced by main().

UNICODE_STRING WorkName
 

Definition at line 39 of file rtqval.c.

UNICODE_STRING WorkName2
 

Definition at line 44 of file rtqval.c.

Referenced by main(), and processargs().


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