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

rtreplac.c File Reference

#include <nt.h>
#include <ntrtl.h>
#include <nturtl.h>
#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 KeyPath
WCHAR KeyPathBuffer [WORK_SIZE]
UNICODE_STRING NewName
WCHAR NewNameBuffer [WORK_SIZE]
UNICODE_STRING OldName
WCHAR OldNameBuffer [WORK_SIZE]


Define Documentation

#define WORK_SIZE   1024
 

Definition at line 37 of file rtreplac.c.


Function Documentation

void __cdecl main int  argc,
char *  argv[]
 

Definition at line 51 of file rtreplac.c.

References exit, FALSE, KeyPath, KeyPathBuffer, L, NewName, NewNameBuffer, NT_SUCCESS, NtOpenKey(), NtReplaceKey(), NTSTATUS(), NULL, ObjectAttributes, OldName, OldNameBuffer, processargs(), RtlAdjustPrivilege(), TRUE, and WORK_SIZE.

00055 { 00056 NTSTATUS status; 00057 OBJECT_ATTRIBUTES NewAttributes; 00058 OBJECT_ATTRIBUTES OldAttributes; 00059 OBJECT_ATTRIBUTES ObjectAttributes; 00060 IO_STATUS_BLOCK IoStatus; 00061 HANDLE FileHandle; 00062 HANDLE KeyHandle; 00063 BOOLEAN WasEnabled; 00064 00065 // 00066 // Process args 00067 // 00068 00069 KeyPath.MaximumLength = WORK_SIZE; 00070 KeyPath.Length = 0L; 00071 KeyPath.Buffer = &(KeyPathBuffer[0]); 00072 00073 NewName.MaximumLength = WORK_SIZE; 00074 NewName.Length = 0L; 00075 NewName.Buffer = &(NewNameBuffer[0]); 00076 00077 OldName.MaximumLength = WORK_SIZE; 00078 OldName.Length = 0L; 00079 OldName.Buffer = &(OldNameBuffer[0]); 00080 00081 processargs(argc, argv); 00082 00083 // 00084 // Set up and open FileName 00085 // 00086 00087 printf("rtreplac: starting\n"); 00088 00089 InitializeObjectAttributes( 00090 &NewAttributes, 00091 &NewName, 00092 OBJ_CASE_INSENSITIVE, 00093 (HANDLE)NULL, 00094 NULL 00095 ); 00096 00097 InitializeObjectAttributes( 00098 &OldAttributes, 00099 &OldName, 00100 OBJ_CASE_INSENSITIVE, 00101 (HANDLE)NULL, 00102 NULL 00103 ); 00104 00105 InitializeObjectAttributes( 00106 &ObjectAttributes, 00107 &KeyPath, 00108 OBJ_CASE_INSENSITIVE, 00109 (HANDLE)NULL, 00110 NULL 00111 ); 00112 00113 status = NtOpenKey( 00114 &KeyHandle, 00115 MAXIMUM_ALLOWED, 00116 &ObjectAttributes 00117 ); 00118 if (!NT_SUCCESS(status)) { 00119 printf("rtreplac: key open failed status = %08lx\n", status); 00120 exit(1); 00121 } 00122 00123 RtlAdjustPrivilege(SE_RESTORE_PRIVILEGE, TRUE, FALSE, &WasEnabled); 00124 status = NtReplaceKey(&NewAttributes, 00125 KeyHandle, 00126 &OldAttributes); 00127 RtlAdjustPrivilege(SE_RESTORE_PRIVILEGE, WasEnabled, FALSE, &WasEnabled); 00128 00129 if (!NT_SUCCESS(status)) { 00130 printf("rtreplac: NtReplaceKey failed status = %08lx\n", status); 00131 exit(1); 00132 } 00133 00134 printf("rtreplac: success\n"); 00135 exit(0); 00136 }

void __cdecl main int  ,
char * 
 

void processargs int  argc,
char *  argv[]
 

Definition at line 139 of file rtreplac.c.

References exit, KeyPath, NewName, NULL, OldName, RtlAnsiStringToUnicodeString(), RtlDosPathNameToNtPathName_U(), RtlInitAnsiString(), and TRUE.

00143 { 00144 ANSI_STRING temp; 00145 UNICODE_STRING DosFileName; 00146 00147 if ( (argc != 4) ) 00148 { 00149 printf("Usage: %s <KeyName> <NewFileName> <OldFileName>\n", 00150 argv[0]); 00151 exit(1); 00152 } 00153 00154 RtlInitAnsiString( 00155 &temp, 00156 argv[1] 00157 ); 00158 00159 RtlAnsiStringToUnicodeString( 00160 &KeyPath, 00161 &temp, 00162 TRUE 00163 ); 00164 00165 RtlInitAnsiString( 00166 &temp, 00167 argv[2] 00168 ); 00169 00170 RtlAnsiStringToUnicodeString( 00171 &DosFileName, 00172 &temp, 00173 TRUE 00174 ); 00175 00176 RtlDosPathNameToNtPathName_U( DosFileName.Buffer, 00177 &NewName, 00178 NULL, 00179 NULL ); 00180 00181 RtlInitAnsiString( 00182 &temp, 00183 argv[3] 00184 ); 00185 00186 RtlAnsiStringToUnicodeString( 00187 &DosFileName, 00188 &temp, 00189 TRUE 00190 ); 00191 00192 RtlDosPathNameToNtPathName_U( DosFileName.Buffer, 00193 &OldName, 00194 NULL, 00195 NULL ); 00196 00197 return; 00198 }

void processargs  ) 
 


Variable Documentation

UNICODE_STRING KeyPath
 

Definition at line 42 of file rtreplac.c.

WCHAR KeyPathBuffer[WORK_SIZE]
 

Definition at line 43 of file rtreplac.c.

UNICODE_STRING NewName
 

Definition at line 45 of file rtreplac.c.

Referenced by CmpAddSubKey(), CmpAddToLeaf(), CmpLoadHiveVolatile(), CmpSelectLeaf(), main(), MiSessionWideInsertImageAddress(), ObpLookupObjectName(), ObpParseSymbolicLink(), and processargs().

WCHAR NewNameBuffer[WORK_SIZE]
 

Definition at line 46 of file rtreplac.c.

Referenced by main().

UNICODE_STRING OldName
 

Definition at line 47 of file rtreplac.c.

Referenced by main(), and processargs().

WCHAR OldNameBuffer[WORK_SIZE]
 

Definition at line 48 of file rtreplac.c.

Referenced by main().


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