ReactOS 0.4.16-dev-122-g325d74c
bootlog.c
Go to the documentation of this file.
1/*
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS kernel
4 * FILE: ntoskrnl/io/iomgr/bootlog.c
5 * PURPOSE: Boot log file support
6 *
7 * PROGRAMMERS: Eric Kohl
8 */
9
10/* INCLUDES *****************************************************************/
11
12#include <ntoskrnl.h>
13#define NDEBUG
14#include <debug.h>
15
16/* GLOBALS ******************************************************************/
17
23
24
25/* FUNCTIONS ****************************************************************/
26
27CODE_SEG("INIT")
28VOID
30{
32 if (StartBootLog) IopStartBootLog();
33}
34
35
36CODE_SEG("INIT")
37VOID
39{
42}
43
44
45VOID
47{
49}
50
51
52VOID
55{
57 WCHAR Buffer[256];
58 WCHAR ValueNameBuffer[8];
61 HANDLE ControlSetKey;
62 HANDLE BootLogKey;
64
66 return;
67
69
70 DPRINT("Boot log: %wS %wZ\n",
71 Success ? L"Loaded driver" : L"Did not load driver",
72 DriverName);
73
75 L"%ws %wZ",
76 Success ? L"Loaded driver" : L"Did not load driver",
77 DriverName);
78
79 swprintf(ValueNameBuffer,
80 L"%lu",
82
84 L"\\Registry\\Machine\\System\\CurrentControlSet");
86 &KeyName,
88 NULL,
89 NULL);
90 Status = ZwOpenKey(&ControlSetKey,
93 if (!NT_SUCCESS(Status))
94 {
95 DPRINT1("ZwOpenKey() failed (Status %lx)\n", Status);
97 return;
98 }
99
100 RtlInitUnicodeString(&KeyName, L"BootLog");
102 &KeyName,
104 ControlSetKey,
105 NULL);
106 Status = ZwCreateKey(&BootLogKey,
109 0,
110 NULL,
112 NULL);
113 if (!NT_SUCCESS(Status))
114 {
115 DPRINT1("ZwCreateKey() failed (Status %lx)\n", Status);
116 ZwClose(ControlSetKey);
118 return;
119 }
120
121 RtlInitUnicodeString(&ValueName, ValueNameBuffer);
122 Status = ZwSetValueKey(BootLogKey,
123 &ValueName,
124 0,
125 REG_SZ,
126 (PVOID)Buffer,
127 (ULONG)(wcslen(Buffer) + 1) * sizeof(WCHAR));
128 ZwClose(BootLogKey);
129 ZwClose(ControlSetKey);
130
131 if (!NT_SUCCESS(Status))
132 {
133 DPRINT1("NtSetValueKey() failed (Status %lx)\n", Status);
134 }
135 else
136 {
138 }
139
141}
142
143
144static
147{
152 PWSTR CrLf = L"\r\n";
154
155 DPRINT("IopWriteLogFile() called\n");
156
158 L"\\SystemRoot\\rosboot.log");
160 &FileName,
162 NULL,
163 NULL);
164
165 Status = ZwCreateFile(&FileHandle,
169 NULL,
170 0,
171 0,
172 FILE_OPEN,
174 NULL,
175 0);
176 if (!NT_SUCCESS(Status))
177 {
178 DPRINT1("ZwCreateFile() failed (Status %lx)\n", Status);
179 return Status;
180 }
181
182 if (LogText != NULL)
183 {
184 Status = ZwWriteFile(FileHandle,
185 NULL,
186 NULL,
187 NULL,
189 LogText,
190 (ULONG)wcslen(LogText) * sizeof(WCHAR),
191 NULL,
192 NULL);
193 if (!NT_SUCCESS(Status))
194 {
195 DPRINT1("ZwWriteFile() failed (Status %lx)\n", Status);
197 return Status;
198 }
199 }
200
201 /* L"\r\n" */
202 Status = ZwWriteFile(FileHandle,
203 NULL,
204 NULL,
205 NULL,
207 (PVOID)CrLf,
208 2 * sizeof(WCHAR),
209 NULL,
210 NULL);
211
213
214 if (!NT_SUCCESS(Status))
215 {
216 DPRINT1("ZwWriteFile() failed (Status %lx)\n", Status);
217 }
218
219 return Status;
220}
221
222
223static
226{
234
235 DPRINT("IopSaveBootLogToFile() called\n");
236
238
240 L"\\SystemRoot\\rosboot.log");
242 &FileName,
244 NULL,
245 NULL);
246
247 Status = ZwCreateFile(&FileHandle,
251 NULL,
252 0,
253 0,
256 NULL,
257 0);
258 if (!NT_SUCCESS(Status))
259 {
260 DPRINT1("ZwCreateFile() failed (Status %lx)\n", Status);
261 return Status;
262 }
263
264 ByteOffset.QuadPart = (LONGLONG)0;
265
266 Signature = 0xFEFF;
267 Status = ZwWriteFile(FileHandle,
268 NULL,
269 NULL,
270 NULL,
273 sizeof(WCHAR),
274 &ByteOffset,
275 NULL);
276 if (!NT_SUCCESS(Status))
277 {
278 DPRINT1("ZwWriteKey() failed (Status %lx)\n", Status);
279 }
280
282
283 return Status;
284}
285
286
287VOID
289{
291 WCHAR ValueNameBuffer[8];
298 ULONG i;
300
301 if (IopBootLogCreate == FALSE)
302 return;
303
304 DPRINT("IopSaveBootLogToFile() called\n");
305
307
309 if (!NT_SUCCESS(Status))
310 {
311 DPRINT1("IopCreateLogFile() failed (Status %lx)\n", Status);
313 return;
314 }
315
316 //Status = IopWriteLogFile(L"ReactOS "KERNEL_VERSION_STR);
317
318 if (!NT_SUCCESS(Status))
319 {
320 DPRINT1("IopWriteLogFile() failed (Status %lx)\n", Status);
322 return;
323 }
324
326 if (!NT_SUCCESS(Status))
327 {
328 DPRINT1("IopWriteLogFile() failed (Status %lx)\n", Status);
330 return;
331 }
332
333
334 BufferSize = sizeof(KEY_VALUE_PARTIAL_INFORMATION) + 256 * sizeof(WCHAR);
335 KeyInfo = ExAllocatePool(PagedPool,
336 BufferSize);
337 if (KeyInfo == NULL)
338 {
340 return;
341 }
342
344 L"\\Registry\\Machine\\System\\CurrentControlSet\\BootLog");
346 &KeyName,
348 NULL,
349 NULL);
350 Status = ZwOpenKey(&KeyHandle,
353 if (!NT_SUCCESS(Status))
354 {
355 ExFreePool(KeyInfo);
357 return;
358 }
359
360 for (i = 0; ; i++)
361 {
362 swprintf(ValueNameBuffer,
363 L"%lu", i);
364
366 ValueNameBuffer);
367
368 Status = ZwQueryValueKey(KeyHandle,
369 &ValueName,
371 KeyInfo,
373 &ResultLength);
375 {
376 break;
377 }
378
379 if (!NT_SUCCESS(Status))
380 {
382 ExFreePool(KeyInfo);
384 return;
385 }
386
387 Status = IopWriteLogFile((PWSTR)&KeyInfo->Data);
388 if (!NT_SUCCESS(Status))
389 {
391 ExFreePool(KeyInfo);
393 return;
394 }
395
396 /* Delete keys */
398 &ValueName);
399 }
400
402
403 ExFreePool(KeyInfo);
404
407
408 DPRINT("IopSaveBootLogToFile() done\n");
409}
410
411/* EOF */
#define CODE_SEG(...)
unsigned char BOOLEAN
LONG NTSTATUS
Definition: precomp.h:26
#define FILE_NON_DIRECTORY_FILE
Definition: constants.h:492
#define DPRINT1
Definition: precomp.h:8
static ULONG IopLogEntryCount
Definition: bootlog.c:21
static NTSTATUS IopCreateLogFile(VOID)
Definition: bootlog.c:225
VOID IopStartBootLog(VOID)
Definition: bootlog.c:38
static NTSTATUS IopWriteLogFile(PWSTR LogText)
Definition: bootlog.c:146
VOID IopSaveBootLogToFile(VOID)
Definition: bootlog.c:288
static ERESOURCE IopBootLogResource
Definition: bootlog.c:22
static BOOLEAN IopLogFileEnabled
Definition: bootlog.c:20
VOID IopInitBootLog(BOOLEAN StartBootLog)
Definition: bootlog.c:29
VOID IopStopBootLog(VOID)
Definition: bootlog.c:46
static BOOLEAN IopBootLogCreate
Definition: bootlog.c:18
VOID IopBootLog(PUNICODE_STRING DriverName, BOOLEAN Success)
Definition: bootlog.c:53
static BOOLEAN IopBootLogEnabled
Definition: bootlog.c:19
Definition: bufpool.h:45
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:36
#define BufferSize
Definition: mmc.h:75
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
static const WCHAR Signature[]
Definition: parser.c:141
#define swprintf
Definition: precomp.h:40
NTSTATUS ExInitializeResourceLite(PULONG res)
Definition: env_spec_w32.h:641
#define ExFreePool(addr)
Definition: env_spec_w32.h:352
#define ExAcquireResourceExclusiveLite(res, wait)
Definition: env_spec_w32.h:615
ULONG ERESOURCE
Definition: env_spec_w32.h:594
#define PagedPool
Definition: env_spec_w32.h:308
@ Success
Definition: eventcreate.c:712
IN PDCB IN PCCB IN VBO IN OUT PULONG OUT PDIRENT OUT PBCB OUT PVBO ByteOffset
Definition: fatprocs.h:732
#define ExAllocatePool(type, size)
Definition: fbtusb.h:44
struct _FileName FileName
Definition: fatprocs.h:897
_Must_inspect_result_ _In_opt_ PFLT_INSTANCE _Out_ PHANDLE FileHandle
Definition: fltkernel.h:1231
#define FILE_OPEN
Definition: from_kernel.h:54
#define FILE_SYNCHRONOUS_IO_NONALERT
Definition: from_kernel.h:31
#define FILE_SUPERSEDE
Definition: from_kernel.h:53
NTSYSAPI NTSTATUS NTAPI ZwDeleteValueKey(__in IN HANDLE Key, __in IN PUNICODE_STRING ValueName)
Status
Definition: gdiplustypes.h:25
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define OBJ_OPENIF
Definition: winternl.h:229
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
#define REG_SZ
Definition: layer.c:22
static OUT PIO_STATUS_BLOCK IoStatusBlock
Definition: pipe.c:75
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
_Must_inspect_result_ _Out_ PNDIS_STATUS _In_ NDIS_HANDLE _In_ ULONG _Out_ PNDIS_STRING _Out_ PNDIS_HANDLE KeyHandle
Definition: ndis.h:4715
NTSYSAPI NTSTATUS NTAPI ZwClose(_In_ HANDLE Handle)
#define SYNCHRONIZE
Definition: nt_native.h:61
@ KeyValuePartialInformation
Definition: nt_native.h:1182
#define KEY_ALL_ACCESS
Definition: nt_native.h:1041
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define REG_OPTION_NON_VOLATILE
Definition: nt_native.h:1057
struct _KEY_VALUE_PARTIAL_INFORMATION KEY_VALUE_PARTIAL_INFORMATION
#define FILE_APPEND_DATA
Definition: nt_native.h:634
#define FILE_ALL_ACCESS
Definition: nt_native.h:651
VOID FASTCALL ExReleaseResourceLite(IN PERESOURCE Resource)
Definition: resource.c:1822
#define L(x)
Definition: ntvdm.h:50
#define DPRINT
Definition: sndvol32.h:73
uint16_t * PWSTR
Definition: typedefs.h:56
int64_t LONGLONG
Definition: typedefs.h:68
uint32_t ULONG
Definition: typedefs.h:59
#define STATUS_OBJECT_NAME_NOT_FOUND
Definition: udferr_usr.h:149
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY _In_ ULONG _Out_ PULONG ResultLength
Definition: wdfdevice.h:3776
_Must_inspect_result_ _In_ WDFDEVICE _In_ PCUNICODE_STRING KeyName
Definition: wdfdevice.h:2699
_In_ WDFMEMORY _Out_opt_ size_t * BufferSize
Definition: wdfmemory.h:254
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING ValueName
Definition: wdfregistry.h:243
__wchar_t WCHAR
Definition: xmlstorage.h:180