Hi All,
I need to pass the debug statements from a kernel driver thru the
serial port to a different machine.
I have tried the following code:
fileName.Buffer = NULL;
fileName.Length = 0;
fileName.MaximumLength = sizeof(DEFAULT_LOG_FILE_NAME) +
sizeof(UNICODE_NULL);
fileName.Buffer = (PWSTR)ExAllocatePool(PagedPool,
fileName.MaximumLength);
if (!fileName.Buffer) {
//DD(NULL,DDE,"LogMessage: FAIL. ExAllocatePool Failed.\n");
KdPrint((DRIVERNAME " LogMessage: FAIL. ExAllocatePool Failed"));
return FALSE;
}
RtlZeroMemory(fileName.Buffer, fileName.MaximumLength);
status = RtlAppendUnicodeToString(&fileName,
(PWSTR)DEFAULT_LOG_FILE_NAME);
InitializeObjectAttributes (&objectAttributes,
(PUNICODE_STRING)&fileName,
OBJ_CASE_INSENSITIVE|OBJ_KERNEL_HANDLE,
NULL,
NULL );
status = ZwCreateFile( &FileHandle,
//FILE_APPEND_DATA,
FILE_WRITE_DATA,
&objectAttributes,
&IoStatus,
0,
FILE_ATTRIBUTE_NORMAL,
FILE_SHARE_WRITE,
FILE_OPEN_IF,
FILE_SYNCHRONOUS_IO_NONALERT,
NULL,
0 );
ZwWriteFile( FileHandle, NULL, NULL, NULL, &IoStatus, buf, Length,
NULL, NULL );
to do this...
But More often than not I dont get the Serial out messages.
At some times I do get a few Serial outs on the remote machine but
there seems to be some baudrate problem.
I Also tried this:
PDEVICE_OBJECT SerialDevice;
PFILE_OBJECT FileObject;
UNICODE_STRING uszDevName;
WCHAR szDevName[] = L"\\Device\\Serial0";
RtlInitUnicodeString (&uszDevName, szDevName);
status = IoGetDeviceObjectPointer (&uszDevName,
SYNCHRONIZE|GENERIC_READ|GENERIC_WRITE,
&FileObject, &SerialDevice);
if (!NT_SUCCESS(status)) {
KdPrint((DRIVERNAME " IoGetDeviceObjectPointer:Error cant open File
"));
return FALSE;
} // if
else
{
KdPrint((DRIVERNAME " Bingo Got it"));
}
But cant open handle this way.
Can anyone suggest what is a best way to do this.
Sunil.