ReactOS  0.4.15-dev-3163-gf17c2c0
bootlog.c File Reference
#include <ntoskrnl.h>
#include <debug.h>
Include dependency graph for bootlog.c:

Go to the source code of this file.

Macros

#define NDEBUG
 

Functions

VOID IopInitBootLog (BOOLEAN StartBootLog)
 
VOID IopStartBootLog (VOID)
 
VOID IopStopBootLog (VOID)
 
VOID IopBootLog (PUNICODE_STRING DriverName, BOOLEAN Success)
 
static NTSTATUS IopWriteLogFile (PWSTR LogText)
 
static NTSTATUS IopCreateLogFile (VOID)
 
VOID IopSaveBootLogToFile (VOID)
 

Variables

static BOOLEAN IopBootLogCreate = FALSE
 
static BOOLEAN IopBootLogEnabled = FALSE
 
static BOOLEAN IopLogFileEnabled = FALSE
 
static ULONG IopLogEntryCount = 0
 
static ERESOURCE IopBootLogResource
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 13 of file bootlog.c.

Function Documentation

◆ IopBootLog()

VOID IopBootLog ( PUNICODE_STRING  DriverName,
BOOLEAN  Success 
)

Definition at line 53 of file bootlog.c.

55 {
57  WCHAR Buffer[256];
58  WCHAR ValueNameBuffer[8];
61  HANDLE ControlSetKey;
62  HANDLE BootLogKey;
64 
65  if (IopBootLogEnabled == FALSE)
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 }
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:35
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
#define TRUE
Definition: types.h:120
NTSYSAPI NTSTATUS NTAPI ZwClose(_In_ HANDLE Handle)
LONG NTSTATUS
Definition: precomp.h:26
static ULONG IopLogEntryCount
Definition: bootlog.c:21
#define swprintf
Definition: precomp.h:40
static ERESOURCE IopBootLogResource
Definition: bootlog.c:22
#define OBJ_OPENIF
Definition: winternl.h:229
BOOLEAN NTAPI ExAcquireResourceExclusiveLite(IN PERESOURCE Resource, IN BOOLEAN Wait)
Definition: resource.c:770
static BOOLEAN IopBootLogEnabled
Definition: bootlog.c:19
#define FALSE
Definition: types.h:117
Definition: bufpool.h:45
_Must_inspect_result_ _In_ WDFDEVICE _In_ PCUNICODE_STRING KeyName
Definition: wdfdevice.h:2697
Status
Definition: gdiplustypes.h:24
#define REG_OPTION_NON_VOLATILE
Definition: nt_native.h:1057
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
VOID FASTCALL ExReleaseResourceLite(IN PERESOURCE Resource)
Definition: resource.c:1817
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING ValueName
Definition: wdfregistry.h:240
static const WCHAR L[]
Definition: oid.c:1250
#define KEY_ALL_ACCESS
Definition: nt_native.h:1041
#define NULL
Definition: types.h:112
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define DPRINT1
Definition: precomp.h:8
unsigned int ULONG
Definition: retypes.h:1
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
#define DPRINT
Definition: sndvol32.h:71
#define REG_SZ
Definition: layer.c:22

◆ IopCreateLogFile()

static NTSTATUS IopCreateLogFile ( VOID  )
static

Definition at line 225 of file bootlog.c.

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,
250  &IoStatusBlock,
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,
271  &IoStatusBlock,
272  (PVOID)&Signature,
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 }
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:35
#define FILE_ALL_ACCESS
Definition: nt_native.h:651
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
#define TRUE
Definition: types.h:120
NTSYSAPI NTSTATUS NTAPI ZwClose(_In_ HANDLE Handle)
LONG NTSTATUS
Definition: precomp.h:26
static ERESOURCE IopBootLogResource
Definition: bootlog.c:22
#define OBJ_OPENIF
Definition: winternl.h:229
BOOLEAN NTAPI ExAcquireResourceExclusiveLite(IN PERESOURCE Resource, IN BOOLEAN Wait)
Definition: resource.c:770
HANDLE FileHandle
Definition: stats.c:38
Status
Definition: gdiplustypes.h:24
int64_t LONGLONG
Definition: typedefs.h:68
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
static const WCHAR L[]
Definition: oid.c:1250
#define FILE_NON_DIRECTORY_FILE
Definition: constants.h:492
struct _FileName FileName
Definition: fatprocs.h:893
static OUT PIO_STATUS_BLOCK IoStatusBlock
Definition: pipe.c:75
#define NULL
Definition: types.h:112
#define DPRINT1
Definition: precomp.h:8
#define FILE_SYNCHRONOUS_IO_NONALERT
Definition: from_kernel.h:31
#define FILE_SUPERSEDE
Definition: from_kernel.h:53
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
#define DPRINT
Definition: sndvol32.h:71
static const WCHAR Signature[]
Definition: parser.c:141
IN PDCB IN PCCB IN VBO IN OUT PULONG OUT PDIRENT OUT PBCB OUT PVBO ByteOffset
Definition: fatprocs.h:725

Referenced by IopSaveBootLogToFile().

◆ IopInitBootLog()

VOID IopInitBootLog ( BOOLEAN  StartBootLog)

Definition at line 29 of file bootlog.c.

30 {
32  if (StartBootLog) IopStartBootLog();
33 }
NTSTATUS ExInitializeResourceLite(PULONG res)
Definition: env_spec_w32.h:641
static ERESOURCE IopBootLogResource
Definition: bootlog.c:22
VOID IopStartBootLog(VOID)
Definition: bootlog.c:38

◆ IopSaveBootLogToFile()

VOID IopSaveBootLogToFile ( VOID  )

Definition at line 288 of file bootlog.c.

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,
372  BufferSize,
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 }
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:35
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
_Must_inspect_result_ _Out_ PNDIS_STATUS _In_ NDIS_HANDLE _In_ ULONG _Out_ PNDIS_STRING _Out_ PNDIS_HANDLE KeyHandle
Definition: ndis.h:4711
#define TRUE
Definition: types.h:120
NTSYSAPI NTSTATUS NTAPI ZwClose(_In_ HANDLE Handle)
uint16_t * PWSTR
Definition: typedefs.h:56
LONG NTSTATUS
Definition: precomp.h:26
static BOOLEAN IopBootLogCreate
Definition: bootlog.c:18
NTSYSAPI NTSTATUS NTAPI ZwDeleteValueKey(__in IN HANDLE Key, __in IN PUNICODE_STRING ValueName)
#define swprintf
Definition: precomp.h:40
static ERESOURCE IopBootLogResource
Definition: bootlog.c:22
BOOLEAN NTAPI ExAcquireResourceExclusiveLite(IN PERESOURCE Resource, IN BOOLEAN Wait)
Definition: resource.c:770
#define FALSE
Definition: types.h:117
_Must_inspect_result_ _In_ WDFDEVICE _In_ PCUNICODE_STRING KeyName
Definition: wdfdevice.h:2697
Status
Definition: gdiplustypes.h:24
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
VOID FASTCALL ExReleaseResourceLite(IN PERESOURCE Resource)
Definition: resource.c:1817
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING ValueName
Definition: wdfregistry.h:240
static const WCHAR L[]
Definition: oid.c:1250
#define ExAllocatePool(type, size)
Definition: fbtusb.h:44
static BOOLEAN IopLogFileEnabled
Definition: bootlog.c:20
#define STATUS_OBJECT_NAME_NOT_FOUND
Definition: udferr_usr.h:149
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
#define KEY_ALL_ACCESS
Definition: nt_native.h:1041
struct _KEY_VALUE_PARTIAL_INFORMATION KEY_VALUE_PARTIAL_INFORMATION
#define NULL
Definition: types.h:112
static NTSTATUS IopCreateLogFile(VOID)
Definition: bootlog.c:225
#define DPRINT1
Definition: precomp.h:8
unsigned int ULONG
Definition: retypes.h:1
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY _In_ ULONG _Out_ PULONG ResultLength
Definition: wdfdevice.h:3776
#define DPRINT
Definition: sndvol32.h:71
static NTSTATUS IopWriteLogFile(PWSTR LogText)
Definition: bootlog.c:146
#define ExFreePool(addr)
Definition: env_spec_w32.h:352
#define BufferSize
Definition: mmc.h:75
_In_ WDFMEMORY _Out_opt_ size_t * BufferSize
Definition: wdfmemory.h:251

◆ IopStartBootLog()

VOID IopStartBootLog ( VOID  )

Definition at line 38 of file bootlog.c.

39 {
42 }
#define TRUE
Definition: types.h:120
static BOOLEAN IopBootLogCreate
Definition: bootlog.c:18
static BOOLEAN IopBootLogEnabled
Definition: bootlog.c:19

Referenced by IopInitBootLog().

◆ IopStopBootLog()

VOID IopStopBootLog ( VOID  )

Definition at line 46 of file bootlog.c.

47 {
49 }
static BOOLEAN IopBootLogEnabled
Definition: bootlog.c:19
#define FALSE
Definition: types.h:117

◆ IopWriteLogFile()

static NTSTATUS IopWriteLogFile ( PWSTR  LogText)
static

Definition at line 146 of file bootlog.c.

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,
168  &IoStatusBlock,
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,
188  &IoStatusBlock,
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,
206  &IoStatusBlock,
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 }
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:35
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
NTSYSAPI NTSTATUS NTAPI ZwClose(_In_ HANDLE Handle)
uint16_t * PWSTR
Definition: typedefs.h:56
LONG NTSTATUS
Definition: precomp.h:26
#define FILE_APPEND_DATA
Definition: nt_native.h:634
#define OBJ_OPENIF
Definition: winternl.h:229
HANDLE FileHandle
Definition: stats.c:38
Status
Definition: gdiplustypes.h:24
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
static const WCHAR L[]
Definition: oid.c:1250
#define FILE_NON_DIRECTORY_FILE
Definition: constants.h:492
#define SYNCHRONIZE
Definition: nt_native.h:61
#define FILE_OPEN
Definition: from_kernel.h:54
struct _FileName FileName
Definition: fatprocs.h:893
static OUT PIO_STATUS_BLOCK IoStatusBlock
Definition: pipe.c:75
#define NULL
Definition: types.h:112
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define DPRINT1
Definition: precomp.h:8
#define FILE_SYNCHRONOUS_IO_NONALERT
Definition: from_kernel.h:31
unsigned int ULONG
Definition: retypes.h:1
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
#define DPRINT
Definition: sndvol32.h:71

Referenced by IopSaveBootLogToFile().

Variable Documentation

◆ IopBootLogCreate

BOOLEAN IopBootLogCreate = FALSE
static

Definition at line 18 of file bootlog.c.

Referenced by IopSaveBootLogToFile(), and IopStartBootLog().

◆ IopBootLogEnabled

BOOLEAN IopBootLogEnabled = FALSE
static

Definition at line 19 of file bootlog.c.

Referenced by IopBootLog(), IopStartBootLog(), and IopStopBootLog().

◆ IopBootLogResource

ERESOURCE IopBootLogResource
static

Definition at line 22 of file bootlog.c.

Referenced by IopBootLog(), IopCreateLogFile(), IopInitBootLog(), and IopSaveBootLogToFile().

◆ IopLogEntryCount

ULONG IopLogEntryCount = 0
static

Definition at line 21 of file bootlog.c.

Referenced by IopBootLog().

◆ IopLogFileEnabled

BOOLEAN IopLogFileEnabled = FALSE
static

Definition at line 20 of file bootlog.c.

Referenced by IopSaveBootLogToFile().