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.

Re: Serial Out from Kernel Mode by Phil

Phil
Tue Jul 20 19:10:40 CDT 2004

"sunny" <sun_vjti@rediffmail.com> wrote in message
news:11465406.0407201512.186d843d@posting.google.com...
> 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:

[Lots of code trying to reinvent the kernel debugger snipped]

> But cant open handle this way.
>
> Can anyone suggest what is a best way to do this.

Stop trying to re-implement the kernel debugger. Just use KdPrint() or
DbgPrint(), and hookup Windbg (or kdb or cdb) through the serial port or
1394 to your target machine. It's very well documented in the Windbg docs.

Get windbg here:
http://www.microsoft.com/whdc/DevTools/Debugging/default.mspx

If all you want is a passive view of debug prints, you can use windbg for
single system debug viewing, or get DebugView from
http://www.sysinternals.com/ to do the same thing.

Phil
--
Philip D. Barila Windows DDK MVP
Seagate Technology LLC
(720) 684-1842
As if I need to say it: Not speaking for Seagate.
E-mail address is pointed at a domain squatter. Use reply-to instead.




Re: Serial Out from Kernel Mode by Slobodan

Slobodan
Wed Jul 21 04:40:06 CDT 2004

Hi Sunny,

Or if you really need serial port read thread:
http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&c2coff=1&threadm=%23%23XxVYwREHA.3628%40TK2MSFTNGP12.phx.gbl&rnum=1&prev=/groups%3Fq%3DIoGetDeviceObjectPointer%2BSlobodan%26hl%3Den%26lr%3D%26ie%3DUTF-8%26c2coff%3D1%26selm%3D%2523%2523XxVYwREHA.3628%2540TK2MSFTNGP12.phx.gbl%26rnum%3D1

Best regards,
Slobodan


"sunny" <sun_vjti@rediffmail.com> wrote in message news:11465406.0407201512.186d843d@posting.google.com...
> 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.



Re: Serial Out from Kernel Mode by sun_vjti

sun_vjti
Wed Jul 21 09:44:20 CDT 2004

Hi Phil,
The problem is that the target audience for such a driver has very
little tech knowledge...To ask them to use a Windbg is out of
question.Cuz if they have the use the Windbg then they need to place
the windbg in Verbose mode,edit the boot.ini file on target
machine,etc etc.

So i wanted to make it as easy as possible so was looking to implement
this in the utility as well.
Still any help would be highly appreciated.
Sunil.


At max they can use the Hyperterminal.
"Phil Barila" <PBarila@Barila.com> wrote in message news:<np-dnQfkFt4cKWDdRVn-sQ@4dv.net>...
> "sunny" <sun_vjti@rediffmail.com> wrote in message
> news:11465406.0407201512.186d843d@posting.google.com...
> > 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:
>
> [Lots of code trying to reinvent the kernel debugger snipped]
>
> > But cant open handle this way.
> >
> > Can anyone suggest what is a best way to do this.
>
> Stop trying to re-implement the kernel debugger. Just use KdPrint() or
> DbgPrint(), and hookup Windbg (or kdb or cdb) through the serial port or
> 1394 to your target machine. It's very well documented in the Windbg docs.
>
> Get windbg here:
> http://www.microsoft.com/whdc/DevTools/Debugging/default.mspx
>
> If all you want is a passive view of debug prints, you can use windbg for
> single system debug viewing, or get DebugView from
> http://www.sysinternals.com/ to do the same thing.
>
> Phil

Re: Serial Out from Kernel Mode by Gary

Gary
Wed Jul 21 11:35:54 CDT 2004

Ever hear of event logging? Use the message compiler to create error codes
and log them to a system even. That works in even areas you don't want to
put debug statements. You then use EventVwr to read your logs and when
needed have the customer send them to you.

--
Gary G. Little
Seagate Technologies, LLC

"sunny" <sun_vjti@rediffmail.com> wrote in message
news:11465406.0407210644.4963856d@posting.google.com...
> Hi Phil,
> The problem is that the target audience for such a driver has very
> little tech knowledge...To ask them to use a Windbg is out of
> question.Cuz if they have the use the Windbg then they need to place
> the windbg in Verbose mode,edit the boot.ini file on target
> machine,etc etc.
>
> So i wanted to make it as easy as possible so was looking to implement
> this in the utility as well.
> Still any help would be highly appreciated.
> Sunil.
>
>
> At max they can use the Hyperterminal.
> "Phil Barila" <PBarila@Barila.com> wrote in message
news:<np-dnQfkFt4cKWDdRVn-sQ@4dv.net>...
> > "sunny" <sun_vjti@rediffmail.com> wrote in message
> > news:11465406.0407201512.186d843d@posting.google.com...
> > > 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:
> >
> > [Lots of code trying to reinvent the kernel debugger snipped]
> >
> > > But cant open handle this way.
> > >
> > > Can anyone suggest what is a best way to do this.
> >
> > Stop trying to re-implement the kernel debugger. Just use KdPrint() or
> > DbgPrint(), and hookup Windbg (or kdb or cdb) through the serial port or
> > 1394 to your target machine. It's very well documented in the Windbg
docs.
> >
> > Get windbg here:
> > http://www.microsoft.com/whdc/DevTools/Debugging/default.mspx
> >
> > If all you want is a passive view of debug prints, you can use windbg
for
> > single system debug viewing, or get DebugView from
> > http://www.sysinternals.com/ to do the same thing.
> >
> > Phil



Re: Serial Out from Kernel Mode by Ray

Ray
Wed Jul 21 17:55:48 CDT 2004

Oh, come on. Anyone who has an actual need to see debug output from your
kernel mode driver must be smart enough to take the very minimal steps
needed to use WinDbg.

If following 3-4 simple instructions is too difficult for them, you can
even write a couple of simple .bat files to enable debugging on the
target and run WinDbg with the right parameters on the host.

Starting your utility isn't going to be any easier than this.

What problem are you actually trying to solve here?

sunny wrote:

> Hi Phil,
> The problem is that the target audience for such a driver has very
> little tech knowledge...To ask them to use a Windbg is out of
> question.Cuz if they have the use the Windbg then they need to place
> the windbg in Verbose mode,edit the boot.ini file on target
> machine,etc etc.
>
> So i wanted to make it as easy as possible so was looking to implement
> this in the utility as well.
> Still any help would be highly appreciated.
> Sunil.
>
>
> At max they can use the Hyperterminal.
> "Phil Barila" <PBarila@Barila.com> wrote in message news:<np-dnQfkFt4cKWDdRVn-sQ@4dv.net>...
>
>>"sunny" <sun_vjti@rediffmail.com> wrote in message
>>news:11465406.0407201512.186d843d@posting.google.com...
>>
>>>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:
>>
>>[Lots of code trying to reinvent the kernel debugger snipped]
>>
>>
>>>But cant open handle this way.
>>>
>>>Can anyone suggest what is a best way to do this.
>>
>>Stop trying to re-implement the kernel debugger. Just use KdPrint() or
>>DbgPrint(), and hookup Windbg (or kdb or cdb) through the serial port or
>>1394 to your target machine. It's very well documented in the Windbg docs.
>>
>>Get windbg here:
>>http://www.microsoft.com/whdc/DevTools/Debugging/default.mspx
>>
>>If all you want is a passive view of debug prints, you can use windbg for
>>single system debug viewing, or get DebugView from
>>http://www.sysinternals.com/ to do the same thing.
>>
>>Phil