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

rtrest2.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 KeyPath
WCHAR KeyPathBuffer [WORK_SIZE]
UNICODE_STRING FileName
WCHAR FileNameBuffer [WORK_SIZE]


Define Documentation

#define WORK_SIZE   1024
 

Definition at line 37 of file rtrest2.c.


Function Documentation

void __cdecl main int  argc,
char *  argv[]
 

Definition at line 49 of file rtrest2.c.

References exit, FileName, FileNameBuffer, KeyPath, KeyPathBuffer, L, NT_SUCCESS, NtCreateFile(), NtOpenKey(), NtRestoreKey(), NTSTATUS(), NULL, ObjectAttributes, processargs(), and WORK_SIZE.

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

void __cdecl main int  ,
char * 
 

void processargs int  argc,
char *  argv[]
 

Definition at line 140 of file rtrest2.c.

References exit, FileName, KeyPath, RtlAnsiStringToUnicodeString(), RtlInitAnsiString(), and TRUE.

00144 { 00145 ANSI_STRING temp; 00146 00147 if ( (argc != 3) ) 00148 { 00149 printf("Usage: %s <KeyName> <FileName>\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 &FileName, 00172 &temp, 00173 TRUE 00174 ); 00175 00176 return; 00177 }

void processargs  ) 
 


Variable Documentation

UNICODE_STRING FileName
 

Definition at line 45 of file rtrest2.c.

WCHAR FileNameBuffer[WORK_SIZE]
 

Definition at line 46 of file rtrest2.c.

UNICODE_STRING KeyPath
 

Definition at line 42 of file rtrest2.c.

WCHAR KeyPathBuffer[WORK_SIZE]
 

Definition at line 43 of file rtrest2.c.


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