00053 {
00054
NTSTATUS status;
00055 OBJECT_ATTRIBUTES
ObjectAttributes;
00056 IO_STATUS_BLOCK IoStatus;
00057 HANDLE FileHandle;
00058 HANDLE KeyHandle;
00059
00060
00061
00062
00063
00064
KeyPath.MaximumLength =
WORK_SIZE;
00065
KeyPath.Length = 0
L;
00066
KeyPath.Buffer = &(
KeyPathBuffer[0]);
00067
00068
FileName.MaximumLength =
WORK_SIZE;
00069
FileName.Length = 0
L;
00070
FileName.Buffer = &(
FileNameBuffer[0]);
00071
00072
processargs(argc, argv);
00073
00074
00075
00076
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,
00096 FILE_ATTRIBUTE_NORMAL,
00097 0,
00098 FILE_OPEN_IF,
00099 FILE_SYNCHRONOUS_IO_NONALERT,
00100 NULL,
00101 0
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 }