6 BOOLEAN
LogMessage(PCHAR szFormat
, ...)
11 IO_STATUS_BLOCK IoStatus
;
12 OBJECT_ATTRIBUTES objectAttributes
;
15 UNICODE_STRING fileName
;
19 va_start(va
,szFormat
);
20 vsprintf(messagebuf
,szFormat
,va
);
23 //get a handle to the log file object
24 fileName
.Buffer
= NULL
;
26 fileName
.MaximumLength
= sizeof(DEFAULT_LOG_FILE_NAME
) + sizeof(UNICODE_NULL
);
27 fileName
.Buffer
= ExAllocatePool(PagedPool
,
28 fileName
.MaximumLength
);
33 RtlZeroMemory(fileName
.Buffer
, fileName
.MaximumLength
);
34 status
= RtlAppendUnicodeToString(&fileName
, (PWSTR
)DEFAULT_LOG_FILE_NAME
);
36 //DbgPrint("\n Initializing Object attributes");
38 InitializeObjectAttributes (&objectAttributes
,
39 (PUNICODE_STRING
)&fileName
,
44 DbgPrint("\n BusLogic - Creating the file");
46 status
= ZwCreateFile(&FileHandle
,
51 FILE_ATTRIBUTE_NORMAL
,
54 FILE_SYNCHRONOUS_IO_NONALERT
,
58 if(NT_SUCCESS(status
))
62 KeQuerySystemTime(&time
);
64 DbgPrint("\n BusLogic - Created the file");
66 //put a time stamp on the output message
67 sprintf(buf
,"%10u-%10u %s",time
.HighPart
,time
.LowPart
,messagebuf
);
69 //format the string to make sure it appends a newline carrage-return to the
72 if(buf
[Length
-1]=='\n')
85 DbgPrint("\n BusLogic - Writing to the file");
86 DbgPrint("\n BusLogic - Buf = %s", buf
);
88 status
= ZwWriteFile(FileHandle
,
101 ExFreePool (fileName
.Buffer
);
103 return STATUS_SUCCESS
;