Re[2]: Debugging Code - new to windbg

> Where do I find out more about this stuff. I would never have known that

that member existed, never mind what it was there for.

If you’re going to take this stuff seriously I know of no substitute
for getting Walter Oney’s book, Programming the Microsoft Windows
Driver Model.

There are lots of other sources of information available (including
DDK documentation) but this is, IMHO, the best starting point).

Another list member mentioned dbgview from sysinternals. I use this
all the time and find it invaluable.

Robert Newton

Try KdPrint((“My Message %d”, 10));

Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
xxxxx@storagecraft.com
http://www.storagecraft.com

----- Original Message -----
From: “Hylton Tregenza”
To: “Windows System Software Devs Interest List”
Sent: Thursday, January 06, 2005 7:04 PM
Subject: RE: [ntdev] Debugging Code - new to windbg

> And yep you did.
>
> Where do I find out more about this stuff. I would never have known that
> that member existed, never mind what it was there for.
>
> Thanks to all who did supply this answer.
>
> Any takers on the second part of the question How do get the debugger to
> show these messages (then I would have known that the driver was getting the
> call) when working on a single machine.
>
> This is a “got to tell someone moment”. My first ever response from a driver
> with ioctl (never mind my own driver).
>
> Very grateful
> Hylton
>
>
>
> -----Original Message-----
> From: xxxxx@lists.osr.com
> [mailto:xxxxx@lists.osr.com] On Behalf Of Bohannon, Ivan
> Sent: 06 January 2005 05:15 PM
> To: Windows System Software Devs Interest List
> Subject: RE: [ntdev] Debugging Code - new to windbg
>
> Ooh I can fix this one…
>
>
> For returning information back from your driver to user mode you need to set
> your Irp->IoStatus.Information to the number of bytes being returned.
>
>
> -----Original Message-----
> From: xxxxx@lists.osr.com
> [mailto:xxxxx@lists.osr.com] On Behalf Of Hylton Tregenza
> Sent: Thursday, January 06, 2005 10:03 AM
> To: Windows System Software Devs Interest List
> Subject: [ntdev] Debugging Code - new to windbg
>
> Hi all
>
> Still busy with my first foray into driver depths. Could someone please
> supply an answer (or location to the answer) of the following question.
> This
> has to do with debugging.
>
> I am trying to communicate with a test driver that I have created. I am
> using a consol app and sending
> DeviceIoControl(DriverHandle,IOCTL_IMPACKETCOUNTER_GETPACKETS, (LPVOID)
> szBuffer, sizeof(szBuffer), (LPVOID) szBuffer, sizeof(szBuffer), &Returned,
> NULL )) to the driver. (I coppied the CTL_CODE marco from the DDK to ensure
> the same number was generated)
>
> In the driver code I have the following
>
> DBGPRINT((“==>Pt Dispatch\n”));
> irpStack = IoGetCurrentIrpStackLocation(Irp);
>
> switch (irpStack->MajorFunction)
> {
> case IRP_MJ_CREATE:
> break;
>
> case IRP_MJ_CLEANUP:
> break;
>
> case IRP_MJ_CLOSE:
> break;
>
> case IRP_MJ_DEVICE_CONTROL:
>
> DBGPRINT((“DrvFltIp.SYS: IRP_MJ_DEVICE_CONTROL\n”));
> ioControlCode =
> irpStack->Parameters.DeviceIoControl.IoControlCode;
> switch (ioControlCode)
> {
> case IOCTL_IMPACKETCOUNTER_GETPACKETS:
> {
>
> memcpy(Irp->AssociatedIrp.SystemBuffer, “Hello There”, sizeof(“Hello
> There”));
> }
> break;
> }
> break;
> default:
> break;
> }
>
> I am not sure what is happening with this call. The return code from
> DeviceIoControl is O (OK).
> The buffer is not populated with the result.
>
> I have the disadvantage of only working on one machine at the moment (other
> one is being built).
> How do I get the debugger (never used it before :frowning: ) to show the dbgmessages
> while working local. I think I need to select a process or something but the
> driver does not appear anywhere.
>
> Apologies if I have supplies surplus information. As this driver fog slowly
> lifts, I am sure I will be able to ask more sensible questions.
>
> Hylton
>
>
>
> —
> Questions? First check the Kernel Driver FAQ at
> http://www.osronline.com/article.cfm?id=256
>
> You are currently subscribed to ntdev as: xxxxx@nsisoftware.com To
> unsubscribe send a blank email to xxxxx@lists.osr.com
>
> —
> Questions? First check the Kernel Driver FAQ at
> http://www.osronline.com/article.cfm?id=256
>
> You are currently subscribed to ntdev as: unknown lmsubst tag argument: ‘’
> To unsubscribe send a blank email to xxxxx@lists.osr.com
>
>
>
> —
> Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256
>
> You are currently subscribed to ntdev as: xxxxx@storagecraft.com
> To unsubscribe send a blank email to xxxxx@lists.osr.com

For your first question, the DDK src\ directory has many, many useful
examples. The only problem might be to find the most useful. In your case, I
suggest src\general\IoCtl; that would have shown how to reply to IRPs like
yours. Later, you can try your hand at PnP as seen in src\general\Toaster.

For the second question, as some have said already, you really need a
2-system setup, for lots of reasons.


James Antognini
Windows DDK Support

This posting is provided “AS IS” with no warranties, and confers no rights.

“Hylton Tregenza” wrote in message news:xxxxx@ntdev…
> And yep you did.
>
> Where do I find out more about this stuff. I would never have known that
> that member existed, never mind what it was there for.
>
> Thanks to all who did supply this answer.
>
> Any takers on the second part of the question How do get the debugger to
> show these messages (then I would have known that the driver was getting
> the
> call) when working on a single machine.
>
> This is a “got to tell someone moment”. My first ever response from a
> driver
> with ioctl (never mind my own driver).
>
> Very grateful
> Hylton
>
>
>
> -----Original Message-----
> From: xxxxx@lists.osr.com
> [mailto:xxxxx@lists.osr.com] On Behalf Of Bohannon, Ivan
> Sent: 06 January 2005 05:15 PM
> To: Windows System Software Devs Interest List
> Subject: RE: [ntdev] Debugging Code - new to windbg
>
> Ooh I can fix this one…
>
>
> For returning information back from your driver to user mode you need to
> set
> your Irp->IoStatus.Information to the number of bytes being returned.
>
>
> -----Original Message-----
> From: xxxxx@lists.osr.com
> [mailto:xxxxx@lists.osr.com] On Behalf Of Hylton Tregenza
> Sent: Thursday, January 06, 2005 10:03 AM
> To: Windows System Software Devs Interest List
> Subject: [ntdev] Debugging Code - new to windbg
>
> Hi all
>
> Still busy with my first foray into driver depths. Could someone please
> supply an answer (or location to the answer) of the following question.
> This
> has to do with debugging.
>
> I am trying to communicate with a test driver that I have created. I am
> using a consol app and sending
> DeviceIoControl(DriverHandle,IOCTL_IMPACKETCOUNTER_GETPACKETS, (LPVOID)
> szBuffer, sizeof(szBuffer), (LPVOID) szBuffer, sizeof(szBuffer),
> &Returned,
> NULL )) to the driver. (I coppied the CTL_CODE marco from the DDK to
> ensure
> the same number was generated)
>
> In the driver code I have the following
>
> DBGPRINT((“==>Pt Dispatch\n”));
> irpStack = IoGetCurrentIrpStackLocation(Irp);
>
> switch (irpStack->MajorFunction)
> {
> case IRP_MJ_CREATE:
> break;
>
> case IRP_MJ_CLEANUP:
> break;
>
> case IRP_MJ_CLOSE:
> break;
>
> case IRP_MJ_DEVICE_CONTROL:
>
> DBGPRINT((“DrvFltIp.SYS: IRP_MJ_DEVICE_CONTROL\n”));
> ioControlCode =
> irpStack->Parameters.DeviceIoControl.IoControlCode;
> switch (ioControlCode)
> {
> case IOCTL_IMPACKETCOUNTER_GETPACKETS:
> {
>
> memcpy(Irp->AssociatedIrp.SystemBuffer, “Hello There”, sizeof(“Hello
> There”));
> }
> break;
> }
> break;
> default:
> break;
> }
>
> I am not sure what is happening with this call. The return code from
> DeviceIoControl is O (OK).
> The buffer is not populated with the result.
>
> I have the disadvantage of only working on one machine at the moment
> (other
> one is being built).
> How do I get the debugger (never used it before :frowning: ) to show the
> dbgmessages
> while working local. I think I need to select a process or something but
> the
> driver does not appear anywhere.
>
> Apologies if I have supplies surplus information. As this driver fog
> slowly
> lifts, I am sure I will be able to ask more sensible questions.
>
> Hylton
>
>
>
> —
> Questions? First check the Kernel Driver FAQ at
> http://www.osronline.com/article.cfm?id=256
>
> You are currently subscribed to ntdev as: xxxxx@nsisoftware.com To
> unsubscribe send a blank email to xxxxx@lists.osr.com
>
> —
> Questions? First check the Kernel Driver FAQ at
> http://www.osronline.com/article.cfm?id=256
>
> You are currently subscribed to ntdev as: unknown lmsubst tag argument: ‘’
> To unsubscribe send a blank email to xxxxx@lists.osr.com
>
>
>

Thanks to Mark and all other that responded to my question.

Mark, no offence taken by reference to my ignorance. They are quite
accurate.
I know nothing about writing drivers and will freely admit it too. :). But I
am up to the challenge of learning. The books recommended are on my “to get”
list.

Source code comes from the DDk sample - NTIS IMDriver (passthru example) to
be exact. Only modification in the code was to see if I could get it to
respond to a IOCTL from my own app.

I am working through the DDK documentation so expect my questions to make
more sense soon. Until then please bear with me. I will ask only when I am
at my wits end.

As to attending a seminar. I have yet to find one out here. (Have not looked
much yet though as one usually has to sell the family farm to attend).
Should there be anyone reading this list from South Africa that can
recommend such a facility I would be glad to consider it.

Hylton

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Roddy, Mark
Sent: 06 January 2005 06:45 PM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] Debugging Code - new to windbg

Ok, I was going to stay out of this mess, but I’ve reached my limit here.

Debugging: use windbg. You need two systems, a test system and a development
system. DbgView is a very nice program, but new developers should start out
with the correct tool sets. They are confused enough, why prolong the
confusion?

IrpView: nice tool, not for his problem. The OP has no clue how to write a
driver, as his code sample and comments clearly show, and as I think he
would freely admit. Viewing IRP traces is not likely to help. You might as
well suggest that he learn sanskrit.

Hylton needs to get a good book on WDM drivers, Walter Oney’s “Programming
the Windows Driver Model”, Microsoft Press, would be a good start. Then he
needs to read the book, and maybe work through a couple of the examples.
Then he needs to go read the ddk and study the source code samples there. If
possible he should consider attending one of the seminars offered by the
various training companies.

Finally, I have no idea where Hylton got his source code model from, but he
should throw that crap out and use the samples in the DDK as a starting
point.

=====================
Mark Roddy

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Bohannon, Ivan
Sent: Thursday, January 06, 2005 11:16 AM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] Debugging Code - new to windbg

An IRP viewer might have helped debug this problem, I think the download
page on OSR has an IRP viewer util, I haven’t used it tho.

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Hylton Tregenza
Sent: Thursday, January 06, 2005 11:04 AM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] Debugging Code - new to windbg

And yep you did.

Where do I find out more about this stuff. I would never have known that
that member existed, never mind what it was there for.

Thanks to all who did supply this answer.

Any takers on the second part of the question How do get the debugger to
show these messages (then I would have known that the driver was getting the
call) when working on a single machine.

This is a “got to tell someone moment”. My first ever response from a driver
with ioctl (never mind my own driver).

Very grateful
Hylton

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Bohannon, Ivan
Sent: 06 January 2005 05:15 PM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] Debugging Code - new to windbg

Ooh I can fix this one…

For returning information back from your driver to user mode you need to set
your Irp->IoStatus.Information to the number of bytes being returned.

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Hylton Tregenza
Sent: Thursday, January 06, 2005 10:03 AM
To: Windows System Software Devs Interest List
Subject: [ntdev] Debugging Code - new to windbg

Hi all

Still busy with my first foray into driver depths. Could someone please
supply an answer (or location to the answer) of the following question.
This
has to do with debugging.

I am trying to communicate with a test driver that I have created. I am
using a consol app and sending
DeviceIoControl(DriverHandle,IOCTL_IMPACKETCOUNTER_GETPACKETS, (LPVOID)
szBuffer, sizeof(szBuffer), (LPVOID) szBuffer, sizeof(szBuffer), &Returned,
NULL )) to the driver. (I coppied the CTL_CODE marco from the DDK to ensure
the same number was generated)

In the driver code I have the following

DBGPRINT((“==>Pt Dispatch\n”));
irpStack = IoGetCurrentIrpStackLocation(Irp);

switch (irpStack->MajorFunction)
{
case IRP_MJ_CREATE:
break;

case IRP_MJ_CLEANUP:
break;

case IRP_MJ_CLOSE:
break;

case IRP_MJ_DEVICE_CONTROL:

DBGPRINT((“DrvFltIp.SYS: IRP_MJ_DEVICE_CONTROL\n”));
ioControlCode =
irpStack->Parameters.DeviceIoControl.IoControlCode;
switch (ioControlCode)
{
case IOCTL_IMPACKETCOUNTER_GETPACKETS:
{

memcpy(Irp->AssociatedIrp.SystemBuffer, “Hello There”, sizeof(“Hello
There”));
}
break;
}
break;
default:
break;
}

I am not sure what is happening with this call. The return code from
DeviceIoControl is O (OK).
The buffer is not populated with the result.

I have the disadvantage of only working on one machine at the moment (other
one is being built).
How do I get the debugger (never used it before :frowning: ) to show the dbgmessages
while working local. I think I need to select a process or something but the
driver does not appear anywhere.

Apologies if I have supplies surplus information. As this driver fog slowly
lifts, I am sure I will be able to ask more sensible questions.

Hylton


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: xxxxx@nsisoftware.com To
unsubscribe send a blank email to xxxxx@lists.osr.com


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: unknown lmsubst tag argument:
‘’
To unsubscribe send a blank email to xxxxx@lists.osr.com


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: xxxxx@nsisoftware.com To
unsubscribe send a blank email to xxxxx@lists.osr.com


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: unknown lmsubst tag argument: ‘’
To unsubscribe send a blank email to xxxxx@lists.osr.com


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: xxxxx@infofx.co.za To unsubscribe
send a blank email to xxxxx@lists.osr.com