Access to parallel ports from Win32

Hi All,

I am trying to access the parallel port directly from a win32 application,
so I can read and write directly to it. Also I am interested in querying the
IEEE 1284 device ID of the connected devices.

I have enumerated all devices that support the GUID_PARALLEL_DEVICE
interface using SetupDiGetClassDevsEx, and I am then opening then devices
(with CreateFile) by using the device path returned from
SetupDiGetDeviceInterfaceDetail.

Now I would like to request the IEEE 1284 ID by sending
IOCTL_PAR_QUERY_RAW_DEVICE_ID to the handle with DeviceIoConrol, but the
function returns with “The request is not supported”
Also I am not able to read from this handle, as the ReadFile operation does
time out.

So obvious I do something wrong, but I am running out of ideas on how to
solve this puzzle.

So I would be real happy if some of you fine people could throw me a bone!
Maybe even some example code :slight_smile:

Kind regards,
Christoph Lindemann

I’m not sure if this would be an issue or not but - what mode do you
have the LPT ports set to in the system BIOS?

-p

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Christoph
Lindemann
Sent: Wednesday, September 14, 2005 9:00 AM
To: Windows System Software Devs Interest List
Subject: [ntdev] Access to parallel ports from Win32

Hi All,

I am trying to access the parallel port directly from a win32
application, so I can read and write directly to it. Also I am
interested in querying the IEEE 1284 device ID of the connected devices.

I have enumerated all devices that support the GUID_PARALLEL_DEVICE
interface using SetupDiGetClassDevsEx, and I am then opening then
devices (with CreateFile) by using the device path returned from
SetupDiGetDeviceInterfaceDetail.

Now I would like to request the IEEE 1284 ID by sending
IOCTL_PAR_QUERY_RAW_DEVICE_ID to the handle with DeviceIoConrol, but the
function returns with “The request is not supported”
Also I am not able to read from this handle, as the ReadFile operation
does time out.

So obvious I do something wrong, but I am running out of ideas on how to
solve this puzzle.

So I would be real happy if some of you fine people could throw me a
bone!
Maybe even some example code :slight_smile:

Kind regards,
Christoph Lindemann


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

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

HI,

I will be VERY interested to see how this thread unwinds. I have been
trying to do a similar thing for way too long now and have explored several
dead ends in the process. I believe that the problem Christoph is seeing
when he sends an IOCTL_PAR_QUERY_RAW_DEVICE_ID request to the handle with
DeviceIoConrol is because the parport.sys driver will not allow any user
mode application access to the “RAW” device. I ran into the same roadblock
when I tried to send an IOCTL_PAR_QUERY_INFORMATION to LPT1:

I have no concrete proof that I am correct about the reason for the failure,
I have only bits and pieces of information from users groups and the DDK to
support my assumption. What I have started to do to fix this problem is: I
have begun to write a WDM filter driver for the parport.sys driver. I am
hoping that the DispatchRead and DispatchWrite functions of the filter
driver can solve the problem. My assumption is that the filter driver can
run in kernel-mode. My problem is, I am not sure how to handle the code in
the DispatchRead and DispatchWrite functions. I don’t yet know what is best
and/or allowed:

  1. Should I send IOCTL_INTERNAL_LOCK_PORT, then
    IOCTL_INTERNAL_PARCLASS_CONNECT, then use the PPARALLEL_READ or
    PPARALLEL_WRITE callback function???
  2. Should I send IOCTL_INTERNAL_GET_PARALLEL_PORT_INFO, then use
    READ_PORT_UCHAR or WRITE_PORT_UCHAR???
  3. Should I create a new proprietary IOCTL and do one of the above in that
    function???

I have purchased Walter Oneys book, “Programming the Microsoft Windows
Driver Model” and it has been quite helpful, but as you can see, I still
have questions.

I hope that we can help each other solve this.

Regards,
Stacy
“Peter Wieland” wrote in message
news:xxxxx@ntdev…
I’m not sure if this would be an issue or not but - what mode do you
have the LPT ports set to in the system BIOS?

-p

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Christoph
Lindemann
Sent: Wednesday, September 14, 2005 9:00 AM
To: Windows System Software Devs Interest List
Subject: [ntdev] Access to parallel ports from Win32

Hi All,

I am trying to access the parallel port directly from a win32
application, so I can read and write directly to it. Also I am
interested in querying the IEEE 1284 device ID of the connected devices.

I have enumerated all devices that support the GUID_PARALLEL_DEVICE
interface using SetupDiGetClassDevsEx, and I am then opening then
devices (with CreateFile) by using the device path returned from
SetupDiGetDeviceInterfaceDetail.

Now I would like to request the IEEE 1284 ID by sending
IOCTL_PAR_QUERY_RAW_DEVICE_ID to the handle with DeviceIoConrol, but the
function returns with “The request is not supported”
Also I am not able to read from this handle, as the ReadFile operation
does time out.

So obvious I do something wrong, but I am running out of ideas on how to
solve this puzzle.

So I would be real happy if some of you fine people could throw me a
bone!
Maybe even some example code :slight_smile:

Kind regards,
Christoph Lindemann


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

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

Hi Peter,

I have set the port to ECP in the BIOS. Also when i do the enumeration, the
port is returned as an ECP port. So bidi and IEEE 1284 should be supported.
I can also see in the registry, that the LPTENUM’erator is able to read the
IEEE1284 ID correctly, but i think that thing probably lives in kernel
space.

Kind regards,
Christoph Lindemann

-----Original Message-----
From: Peter Wieland [mailto:xxxxx@windows.microsoft.com]
Sent: Wednesday, September 14, 2005 6:48 PM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] Access to parallel ports from Win32

I’m not sure if this would be an issue or not but - what mode do you
have the LPT ports set to in the system BIOS?

-p

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Christoph
Lindemann
Sent: Wednesday, September 14, 2005 9:00 AM
To: Windows System Software Devs Interest List
Subject: [ntdev] Access to parallel ports from Win32

Hi All,

I am trying to access the parallel port directly from a win32
application, so I can read and write directly to it. Also I am
interested in querying the IEEE 1284 device ID of the
connected devices.

I have enumerated all devices that support the GUID_PARALLEL_DEVICE
interface using SetupDiGetClassDevsEx, and I am then opening then
devices (with CreateFile) by using the device path returned from
SetupDiGetDeviceInterfaceDetail.

Now I would like to request the IEEE 1284 ID by sending
IOCTL_PAR_QUERY_RAW_DEVICE_ID to the handle with
DeviceIoConrol, but the
function returns with “The request is not supported”
Also I am not able to read from this handle, as the ReadFile operation
does time out.

So obvious I do something wrong, but I am running out of
ideas on how to
solve this puzzle.

So I would be real happy if some of you fine people could throw me a
bone!
Maybe even some example code :slight_smile:

Kind regards,
Christoph Lindemann


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

You are currently subscribed to ntdev as:
xxxxx@windows.microsoft.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

Hi Stacy,

I was wondering if you (or anyone else on this list) have had any success
reading from the port, as I am only able to write to it.
I guess that should be possible from user land, as the windows print spooler
does this (to support language monitors). But then again, the Microsoft
might have implemented some other stuff to enable the spooler to communicate
with the ports in kernel space, like a special “spooler driver”.

Kind regards,
Christoph Lindemann

-----Original Message-----
From: Stacy [mailto:xxxxx@sensorswitch.com]
Sent: Wednesday, September 14, 2005 7:41 PM
To: Windows System Software Devs Interest List
Subject: Re:[ntdev] Access to parallel ports from Win32

HI,

I will be VERY interested to see how this thread unwinds. I
have been
trying to do a similar thing for way too long now and have
explored several
dead ends in the process. I believe that the problem
Christoph is seeing
when he sends an IOCTL_PAR_QUERY_RAW_DEVICE_ID request to
the handle with
DeviceIoConrol is because the parport.sys driver will not
allow any user
mode application access to the “RAW” device. I ran into the
same roadblock
when I tried to send an IOCTL_PAR_QUERY_INFORMATION to LPT1:

I have no concrete proof that I am correct about the reason
for the failure,
I have only bits and pieces of information from users groups
and the DDK to
support my assumption. What I have started to do to fix this
problem is: I
have begun to write a WDM filter driver for the parport.sys
driver. I am
hoping that the DispatchRead and DispatchWrite functions of
the filter
driver can solve the problem. My assumption is that the
filter driver can
run in kernel-mode. My problem is, I am not sure how to
handle the code in
the DispatchRead and DispatchWrite functions. I don’t yet
know what is best
and/or allowed:

  1. Should I send IOCTL_INTERNAL_LOCK_PORT, then
    IOCTL_INTERNAL_PARCLASS_CONNECT, then use the PPARALLEL_READ or
    PPARALLEL_WRITE callback function???
  2. Should I send IOCTL_INTERNAL_GET_PARALLEL_PORT_INFO, then use
    READ_PORT_UCHAR or WRITE_PORT_UCHAR???
  3. Should I create a new proprietary IOCTL and do one of the
    above in that
    function???

I have purchased Walter Oneys book, “Programming the
Microsoft Windows
Driver Model” and it has been quite helpful, but as you can
see, I still
have questions.

I hope that we can help each other solve this.

Regards,
Stacy
“Peter Wieland” wrote in message
> news:xxxxx@ntdev…
> I’m not sure if this would be an issue or not but - what mode do you
> have the LPT ports set to in the system BIOS?
>
> -p
>
> -----Original Message-----
> From: xxxxx@lists.osr.com
> [mailto:xxxxx@lists.osr.com] On Behalf Of Christoph
> Lindemann
> Sent: Wednesday, September 14, 2005 9:00 AM
> To: Windows System Software Devs Interest List
> Subject: [ntdev] Access to parallel ports from Win32
>
> Hi All,
>
> I am trying to access the parallel port directly from a win32
> application, so I can read and write directly to it. Also I am
> interested in querying the IEEE 1284 device ID of the
> connected devices.
>
> I have enumerated all devices that support the GUID_PARALLEL_DEVICE
> interface using SetupDiGetClassDevsEx, and I am then opening then
> devices (with CreateFile) by using the device path returned from
> SetupDiGetDeviceInterfaceDetail.
>
> Now I would like to request the IEEE 1284 ID by sending
> IOCTL_PAR_QUERY_RAW_DEVICE_ID to the handle with
> DeviceIoConrol, but the
> function returns with “The request is not supported”
> Also I am not able to read from this handle, as the ReadFile operation
> does time out.
>
> So obvious I do something wrong, but I am running out of
> ideas on how to
> solve this puzzle.
>
> So I would be real happy if some of you fine people could throw me a
> bone!
> Maybe even some example code :slight_smile:
>
> Kind regards,
> Christoph Lindemann
>
> —
> Questions? First check the Kernel Driver FAQ at
> http://www.osronline.com/article.cfm?id=256
>
> You are currently subscribed to ntdev as:
> xxxxx@windows.microsoft.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:
> xxxxx@printassociates.com
> To unsubscribe send a blank email to xxxxx@lists.osr.com
>

Hi, Guys,

I’m having an annoying problem that’s simple enough that I feel
I should know the answer, yet it’s buried within the structure
of the Microsoft DDK toolset that I’m reluctant to dig into. So
I wonder if someone has some wisdom to share with me ?

The problem is this, whenever I have a structure on the stack
that’s larger than a certain size, the C compiler generates a
call to __chkstk() in my checked builds. That reference, for
this or that reason, is not satisfied by the linker. I want to
either suppress the generation of that code or to find which
library that function is defined; I’d prefer that the compiler
doesn’t generate that call to begin with.

Do any of you know how to do it ? Tks,

Alberto.

Christoph,

I’m afraid that I have not successfully written or read the parallel port
yet. I had tried the same path you seem to be on, to attach into the
existing parport.sys driver with CreateFile and issue WriteFile and ReadFile
calls. The result was that the read would return but with 0 bytes read, the
write would ‘hang’ the application that made the calls.

I did have success reading and writing with the portio driver in the DDK,
but what I really need is a driver that I can build into a DLL and whose
existence is transparent to the user.

After much frustration, I decided that the “most correct” path to take would
be to write a kernel-mode filter driver. That task has proven much more
complicated than I anticipated. The documentation is difficult to navigate
and often (in my opinion) lacking. There are so many sample drivers out
there, and that has helped. None, however show how the path I have taken
should be implemented: the path of filtering the IRP_MJ_READ and
IRP_MJ_WRITE. I am still waiting for some kind driver developer to help me,
but so far, I haven’t gotten any responses. Perhaps my question has been
answered before, if it has, I have spent days (No, weeks) searching the
forum and have not found the details I seem to need. I just don’t seem to
be putting in the correct search phrases I guess.

I have also read that there are ‘illegal’ functions that you can use to map
the ports (Ke386IoSetAccessProcess and Ke386SetIoAccessMap). Microsoft does
not recommend this, but maybe you don’t mind that. Those functions are
utilized by winIO on the following site: http://www.lvr.com/parport.htm

Hope this helps some,
Stacy
“Christoph Lindemann” wrote in
message news:xxxxx@ntdev…
> Hi Stacy,
>
> I was wondering if you (or anyone else on this list) have had any success
> reading from the port, as I am only able to write to it.
> I guess that should be possible from user land, as the windows print
> spooler
> does this (to support language monitors). But then again, the Microsoft
> might have implemented some other stuff to enable the spooler to
> communicate
> with the ports in kernel space, like a special “spooler driver”.
>
> Kind regards,
> Christoph Lindemann
>
>> -----Original Message-----
>> From: Stacy [mailto:xxxxx@sensorswitch.com]
>> Sent: Wednesday, September 14, 2005 7:41 PM
>> To: Windows System Software Devs Interest List
>> Subject: Re:[ntdev] Access to parallel ports from Win32
>>
>>
>> HI,
>>
>> I will be VERY interested to see how this thread unwinds. I
>> have been
>> trying to do a similar thing for way too long now and have
>> explored several
>> dead ends in the process. I believe that the problem
>> Christoph is seeing
>> when he sends an IOCTL_PAR_QUERY_RAW_DEVICE_ID request to
>> the handle with
>> DeviceIoConrol is because the parport.sys driver will not
>> allow any user
>> mode application access to the “RAW” device. I ran into the
>> same roadblock
>> when I tried to send an IOCTL_PAR_QUERY_INFORMATION to LPT1:
>>
>> I have no concrete proof that I am correct about the reason
>> for the failure,
>> I have only bits and pieces of information from users groups
>> and the DDK to
>> support my assumption. What I have started to do to fix this
>> problem is: I
>> have begun to write a WDM filter driver for the parport.sys
>> driver. I am
>> hoping that the DispatchRead and DispatchWrite functions of
>> the filter
>> driver can solve the problem. My assumption is that the
>> filter driver can
>> run in kernel-mode. My problem is, I am not sure how to
>> handle the code in
>> the DispatchRead and DispatchWrite functions. I don’t yet
>> know what is best
>> and/or allowed:
>> 1. Should I send IOCTL_INTERNAL_LOCK_PORT, then
>> IOCTL_INTERNAL_PARCLASS_CONNECT, then use the PPARALLEL_READ or
>> PPARALLEL_WRITE callback function???
>> 2. Should I send IOCTL_INTERNAL_GET_PARALLEL_PORT_INFO, then use
>> READ_PORT_UCHAR or WRITE_PORT_UCHAR???
>> 3. Should I create a new proprietary IOCTL and do one of the
>> above in that
>> function???
>>
>> I have purchased Walter Oneys book, “Programming the
>> Microsoft Windows
>> Driver Model” and it has been quite helpful, but as you can
>> see, I still
>> have questions.
>>
>> I hope that we can help each other solve this.
>>
>> Regards,
>> Stacy
>> “Peter Wieland” wrote in message
>> news:xxxxx@ntdev…
>> I’m not sure if this would be an issue or not but - what mode do you
>> have the LPT ports set to in the system BIOS?
>>
>> -p
>>
>> -----Original Message-----
>> From: xxxxx@lists.osr.com
>> [mailto:xxxxx@lists.osr.com] On Behalf Of Christoph
>> Lindemann
>> Sent: Wednesday, September 14, 2005 9:00 AM
>> To: Windows System Software Devs Interest List
>> Subject: [ntdev] Access to parallel ports from Win32
>>
>> Hi All,
>>
>> I am trying to access the parallel port directly from a win32
>> application, so I can read and write directly to it. Also I am
>> interested in querying the IEEE 1284 device ID of the
>> connected devices.
>>
>> I have enumerated all devices that support the GUID_PARALLEL_DEVICE
>> interface using SetupDiGetClassDevsEx, and I am then opening then
>> devices (with CreateFile) by using the device path returned from
>> SetupDiGetDeviceInterfaceDetail.
>>
>> Now I would like to request the IEEE 1284 ID by sending
>> IOCTL_PAR_QUERY_RAW_DEVICE_ID to the handle with
>> DeviceIoConrol, but the
>> function returns with “The request is not supported”
>> Also I am not able to read from this handle, as the ReadFile operation
>> does time out.
>>
>> So obvious I do something wrong, but I am running out of
>> ideas on how to
>> solve this puzzle.
>>
>> So I would be real happy if some of you fine people could throw me a
>> bone!
>> Maybe even some example code :slight_smile:
>>
>> Kind regards,
>> Christoph Lindemann
>>
>> —
>> Questions? First check the Kernel Driver FAQ at
>> http://www.osronline.com/article.cfm?id=256
>>
>> You are currently subscribed to ntdev as:
>> xxxxx@windows.microsoft.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:
>> xxxxx@printassociates.com
>> To unsubscribe send a blank email to xxxxx@lists.osr.com
>>
>

In order to be able to access parallel ports, you’ve got to stop the
spooler.

As far as retrieving the 1284 strings, the IOCTL_PAR_QUERY_DEVICE_ID
request has worked well for me for both parallel and USB ports.
There are some hoops to jump through in the USB case, but this request
ultimately works there as well.

Regards,
-Ilya

-----Original Message-----
Subject: Re: Access to parallel ports from Win32
From: “Stacy”
Date: Wed, 14 Sep 2005 13:40:36 -0400
X-Message-Number: 20

HI,

I will be VERY interested to see how this thread unwinds. I have been
trying to do a similar thing for way too long now and have explored several
dead ends in the process. I believe that the problem Christoph is seeing
when he sends an IOCTL_PAR_QUERY_RAW_DEVICE_ID request to the handle with
DeviceIoConrol is because the parport.sys driver will not allow any user
mode application access to the “RAW” device. I ran into the same roadblock
when I tried to send an IOCTL_PAR_QUERY_INFORMATION to LPT1:

I have no concrete proof that I am correct about the reason for the failure,
I have only bits and pieces of information from users groups and the DDK to
support my assumption. What I have started to do to fix this problem is: I
have begun to write a WDM filter driver for the parport.sys driver. I am
hoping that the DispatchRead and DispatchWrite functions of the filter
driver can solve the problem. My assumption is that the filter driver can
run in kernel-mode. My problem is, I am not sure how to handle the code in
the DispatchRead and DispatchWrite functions. I don’t yet know what is best
and/or allowed:
1. Should I send IOCTL_INTERNAL_LOCK_PORT, then
IOCTL_INTERNAL_PARCLASS_CONNECT, then use the PPARALLEL_READ or
PPARALLEL_WRITE callback function???
2. Should I send IOCTL_INTERNAL_GET_PARALLEL_PORT_INFO, then use
READ_PORT_UCHAR or WRITE_PORT_UCHAR???
3. Should I create a new proprietary IOCTL and do one of the above in that
function???

I have purchased Walter Oneys book, “Programming the Microsoft Windows
Driver Model” and it has been quite helpful, but as you can see, I still
have questions.

I hope that we can help each other solve this.

Regards,
Stacy
“Peter Wieland” wrote in message
news:xxxxx@ntdev…
I’m not sure if this would be an issue or not but - what mode do you
have the LPT ports set to in the system BIOS?

-p

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Christoph
Lindemann
Sent: Wednesday, September 14, 2005 9:00 AM
To: Windows System Software Devs Interest List
Subject: [ntdev] Access to parallel ports from Win32

Hi All,

I am trying to access the parallel port directly from a win32
application, so I can read and write directly to it. Also I am
interested in querying the IEEE 1284 device ID of the connected devices.

I have enumerated all devices that support the GUID_PARALLEL_DEVICE
interface using SetupDiGetClassDevsEx, and I am then opening then
devices (with CreateFile) by using the device path returned from
SetupDiGetDeviceInterfaceDetail.

Now I would like to request the IEEE 1284 ID by sending
IOCTL_PAR_QUERY_RAW_DEVICE_ID to the handle with DeviceIoConrol, but the
function returns with “The request is not supported”
Also I am not able to read from this handle, as the ReadFile operation
does time out.

So obvious I do something wrong, but I am running out of ideas on how to
solve this puzzle.

So I would be real happy if some of you fine people could throw me a
bone!
Maybe even some example code :slight_smile:

Kind regards,
Christoph Lindemann


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

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

Hi Alberto
Have you looked at the /Gs option or the check_stack pragma ??

Regards

Mark

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Alberto Moreira
Sent: 15 September 2005 13:50
To: Windows System Software Devs Interest List
Subject: Re: [ntdev] Access to parallel ports from Win32

Hi, Guys,

I’m having an annoying problem that’s simple enough that I feel
I should know the answer, yet it’s buried within the structure
of the Microsoft DDK toolset that I’m reluctant to dig into. So
I wonder if someone has some wisdom to share with me ?

The problem is this, whenever I have a structure on the stack
that’s larger than a certain size, the C compiler generates a
call to __chkstk() in my checked builds. That reference, for
this or that reason, is not satisfied by the linker. I want to
either suppress the generation of that code or to find which
library that function is defined; I’d prefer that the compiler
doesn’t generate that call to begin with.

Do any of you know how to do it ? Tks,

Alberto.


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

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

Hi Ilya,

I have also have success with USB. But to use the LPT port, is what you are
saying:?

  1. Stop the spooler
  2. Now the ports kan be used?

Could you please in more detail on how you succeeded?

Best regards,
Christoph

-----Original Message-----
From: Ilya Faenson [mailto:xxxxx@hotmail.com]
Sent: Thursday, September 15, 2005 2:55 PM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] Access to parallel ports from Win32

In order to be able to access parallel ports, you’ve got to stop the
spooler.

As far as retrieving the 1284 strings, the IOCTL_PAR_QUERY_DEVICE_ID
request has worked well for me for both parallel and USB ports.
There are some hoops to jump through in the USB case, but this request
ultimately works there as well.

Regards,
-Ilya

-----Original Message-----
Subject: Re: Access to parallel ports from Win32
From: “Stacy”
> Date: Wed, 14 Sep 2005 13:40:36 -0400
> X-Message-Number: 20
>
> HI,
>
> I will be VERY interested to see how this thread unwinds. I have been
> trying to do a similar thing for way too long now and have
> explored several
> dead ends in the process. I believe that the problem
> Christoph is seeing
> when he sends an IOCTL_PAR_QUERY_RAW_DEVICE_ID request to
> the handle with
> DeviceIoConrol is because the parport.sys driver will not
> allow any user
> mode application access to the “RAW” device. I ran into the
> same roadblock
> when I tried to send an IOCTL_PAR_QUERY_INFORMATION to LPT1:
>
> I have no concrete proof that I am correct about the reason
> for the failure,
> I have only bits and pieces of information from users groups
> and the DDK to
> support my assumption. What I have started to do to fix this
> problem is: I
> have begun to write a WDM filter driver for the parport.sys
> driver. I am
> hoping that the DispatchRead and DispatchWrite functions of the filter
> driver can solve the problem. My assumption is that the
> filter driver can
> run in kernel-mode. My problem is, I am not sure how to
> handle the code in
> the DispatchRead and DispatchWrite functions. I don’t yet
> know what is best
> and/or allowed:
> 1. Should I send IOCTL_INTERNAL_LOCK_PORT, then
> IOCTL_INTERNAL_PARCLASS_CONNECT, then use the PPARALLEL_READ or
> PPARALLEL_WRITE callback function???
> 2. Should I send IOCTL_INTERNAL_GET_PARALLEL_PORT_INFO, then use
> READ_PORT_UCHAR or WRITE_PORT_UCHAR???
> 3. Should I create a new proprietary IOCTL and do one of the
> above in that
> function???
>
> I have purchased Walter Oneys book, “Programming the Microsoft Windows
> Driver Model” and it has been quite helpful, but as you can
> see, I still
> have questions.
>
> I hope that we can help each other solve this.
>
> Regards,
> Stacy
> “Peter Wieland” wrote in message
> news:xxxxx@ntdev…
> I’m not sure if this would be an issue or not but - what mode do you
> have the LPT ports set to in the system BIOS?
>
> -p
>
> -----Original Message-----
> From: xxxxx@lists.osr.com
> [mailto:xxxxx@lists.osr.com] On Behalf Of Christoph
> Lindemann
> Sent: Wednesday, September 14, 2005 9:00 AM
> To: Windows System Software Devs Interest List
> Subject: [ntdev] Access to parallel ports from Win32
>
> Hi All,
>
> I am trying to access the parallel port directly from a win32
> application, so I can read and write directly to it. Also I am
> interested in querying the IEEE 1284 device ID of the
> connected devices.
>
> I have enumerated all devices that support the GUID_PARALLEL_DEVICE
> interface using SetupDiGetClassDevsEx, and I am then opening then
> devices (with CreateFile) by using the device path returned from
> SetupDiGetDeviceInterfaceDetail.
>
> Now I would like to request the IEEE 1284 ID by sending
> IOCTL_PAR_QUERY_RAW_DEVICE_ID to the handle with
> DeviceIoConrol, but the
> function returns with “The request is not supported”
> Also I am not able to read from this handle, as the ReadFile operation
> does time out.
>
> So obvious I do something wrong, but I am running out of
> ideas on how to
> solve this puzzle.
>
> So I would be real happy if some of you fine people could throw me a
> bone!
> Maybe even some example code :slight_smile:
>
> Kind regards,
> Christoph Lindemann
>
> —
> Questions? First check the Kernel Driver FAQ at
> http://www.osronline.com/article.cfm?id=256
>
> You are currently subscribed to ntdev as:
> xxxxx@windows.microsoft.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:
xxxxx@printassociates.com
To unsubscribe send a blank email to xxxxx@lists.osr.com

As Ilya suggested i was able to connect to the microsoftrawport devices
(interface class GUID_PARCLASS_DEVICE) as soon as I had stopped the spooler.

So now, how to do the same without stopping the spooler :wink:

Kind regards,
Christoph

-----Original Message-----
From: Ilya Faenson [mailto:xxxxx@hotmail.com]
Sent: Thursday, September 15, 2005 2:55 PM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] Access to parallel ports from Win32

In order to be able to access parallel ports, you’ve got to stop the
spooler.

As far as retrieving the 1284 strings, the IOCTL_PAR_QUERY_DEVICE_ID
request has worked well for me for both parallel and USB ports.
There are some hoops to jump through in the USB case, but this request
ultimately works there as well.

Regards,
-Ilya

-----Original Message-----
Subject: Re: Access to parallel ports from Win32
From: “Stacy”
> Date: Wed, 14 Sep 2005 13:40:36 -0400
> X-Message-Number: 20
>
> HI,
>
> I will be VERY interested to see how this thread unwinds. I have been
> trying to do a similar thing for way too long now and have
> explored several
> dead ends in the process. I believe that the problem
> Christoph is seeing
> when he sends an IOCTL_PAR_QUERY_RAW_DEVICE_ID request to
> the handle with
> DeviceIoConrol is because the parport.sys driver will not
> allow any user
> mode application access to the “RAW” device. I ran into the
> same roadblock
> when I tried to send an IOCTL_PAR_QUERY_INFORMATION to LPT1:
>
> I have no concrete proof that I am correct about the reason
> for the failure,
> I have only bits and pieces of information from users groups
> and the DDK to
> support my assumption. What I have started to do to fix this
> problem is: I
> have begun to write a WDM filter driver for the parport.sys
> driver. I am
> hoping that the DispatchRead and DispatchWrite functions of the filter
> driver can solve the problem. My assumption is that the
> filter driver can
> run in kernel-mode. My problem is, I am not sure how to
> handle the code in
> the DispatchRead and DispatchWrite functions. I don’t yet
> know what is best
> and/or allowed:
> 1. Should I send IOCTL_INTERNAL_LOCK_PORT, then
> IOCTL_INTERNAL_PARCLASS_CONNECT, then use the PPARALLEL_READ or
> PPARALLEL_WRITE callback function???
> 2. Should I send IOCTL_INTERNAL_GET_PARALLEL_PORT_INFO, then use
> READ_PORT_UCHAR or WRITE_PORT_UCHAR???
> 3. Should I create a new proprietary IOCTL and do one of the
> above in that
> function???
>
> I have purchased Walter Oneys book, “Programming the Microsoft Windows
> Driver Model” and it has been quite helpful, but as you can
> see, I still
> have questions.
>
> I hope that we can help each other solve this.
>
> Regards,
> Stacy
> “Peter Wieland” wrote in message
> news:xxxxx@ntdev…
> I’m not sure if this would be an issue or not but - what mode do you
> have the LPT ports set to in the system BIOS?
>
> -p
>
> -----Original Message-----
> From: xxxxx@lists.osr.com
> [mailto:xxxxx@lists.osr.com] On Behalf Of Christoph
> Lindemann
> Sent: Wednesday, September 14, 2005 9:00 AM
> To: Windows System Software Devs Interest List
> Subject: [ntdev] Access to parallel ports from Win32
>
> Hi All,
>
> I am trying to access the parallel port directly from a win32
> application, so I can read and write directly to it. Also I am
> interested in querying the IEEE 1284 device ID of the
> connected devices.
>
> I have enumerated all devices that support the GUID_PARALLEL_DEVICE
> interface using SetupDiGetClassDevsEx, and I am then opening then
> devices (with CreateFile) by using the device path returned from
> SetupDiGetDeviceInterfaceDetail.
>
> Now I would like to request the IEEE 1284 ID by sending
> IOCTL_PAR_QUERY_RAW_DEVICE_ID to the handle with
> DeviceIoConrol, but the
> function returns with “The request is not supported”
> Also I am not able to read from this handle, as the ReadFile operation
> does time out.
>
> So obvious I do something wrong, but I am running out of
> ideas on how to
> solve this puzzle.
>
> So I would be real happy if some of you fine people could throw me a
> bone!
> Maybe even some example code :slight_smile:
>
> Kind regards,
> Christoph Lindemann
>
> —
> Questions? First check the Kernel Driver FAQ at
> http://www.osronline.com/article.cfm?id=256
>
> You are currently subscribed to ntdev as:
> xxxxx@windows.microsoft.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:
xxxxx@printassociates.com
To unsubscribe send a blank email to xxxxx@lists.osr.com

I believe you can control this. The /Gs[n] option controls the threshold
for inserting stack probes. “#pragma check_stack(off)” can be used to
disable the behavior entirely.

– arlie

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Alberto Moreira
Sent: Thursday, September 15, 2005 8:50 AM
To: Windows System Software Devs Interest List
Subject: Re: [ntdev] Access to parallel ports from Win32

Hi, Guys,

I’m having an annoying problem that’s simple enough that I feel I should
know the answer, yet it’s buried within the structure of the Microsoft DDK
toolset that I’m reluctant to dig into. So I wonder if someone has some
wisdom to share with me ?

The problem is this, whenever I have a structure on the stack that’s larger
than a certain size, the C compiler generates a call to __chkstk() in my
checked builds. That reference, for this or that reason, is not satisfied by
the linker. I want to either suppress the generation of that code or to find
which library that function is defined; I’d prefer that the compiler doesn’t
generate that call to begin with.

Do any of you know how to do it ? Tks,

Alberto.


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

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

A couple of people provided advice to suppress this behavior, but I
disagree. Any local stack usage should be carefully examined and anything
large should be a pointer on the stack that is allocated from either the
paged or nonpaged pool. Try driver prefast and it will flag all allocations
larger than 1KB and the utility permits this to be varied so it will report
even smaller stack usage by a single function. I think anything about 256
bytes in a single function is probably excessive and a potential danger.

You can’t use the __chkstk() function in drivers since it is not aware of
the rules. It could be replaced by your own function that uses the correct
stack limits and usage calls, but I prefer to just not cause a problem. Of
course, this becomes far more critical in file system filters.

“Alberto Moreira” wrote in message news:xxxxx@ntdev…
> Hi, Guys,
>
> I’m having an annoying problem that’s simple enough that I feel I should
> know the answer, yet it’s buried within the structure of the Microsoft DDK
> toolset that I’m reluctant to dig into. So I wonder if someone has some
> wisdom to share with me ?
>
> The problem is this, whenever I have a structure on the stack that’s
> larger than a certain size, the C compiler generates a call to __chkstk()
> in my checked builds. That reference, for this or that reason, is not
> satisfied by the linker. I want to either suppress the generation of that
> code or to find which library that function is defined; I’d prefer that
> the compiler doesn’t generate that call to begin with.
>
> Do any of you know how to do it ? Tks,
>
>
> Alberto.
>
>

Christoph Lindemann wrote:

I have set the port to ECP in the BIOS. Also when i do the enumeration, the
port is returned as an ECP port. So bidi and IEEE 1284 should be supported.

All that means is that bidirectional modes will be AVAILABLE. When
nothing else is going on, parport.sys leaves the parallel port in
“standard parallel port” mode, which is NOT bidirectional. Thus, reads
will hang forever.

You have to specifically request that the port be placed in a bidi
mode. Are you doing that? Or are you just issuing a read and crossing
your fingers?


Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.

Cool! Thanks, Mark, very much. This is exactly what I needed!

Alberto.

----- Original Message -----
From: “Cook, Mark” <mark.cook>
To: “Windows System Software Devs Interest List”

Sent: Thursday, September 15, 2005 8:58 AM
Subject: RE: [ntdev] Access to parallel ports from Win32

Hi Alberto
Have you looked at the /Gs option or the check_stack pragma ??

Regards

Mark

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Alberto
Moreira
Sent: 15 September 2005 13:50
To: Windows System Software Devs Interest List
Subject: Re: [ntdev] Access to parallel ports from Win32

Hi, Guys,

I’m having an annoying problem that’s simple enough that I feel
I should know the answer, yet it’s buried within the structure
of the Microsoft DDK toolset that I’m reluctant to dig into. So
I wonder if someone has some wisdom to share with me ?

The problem is this, whenever I have a structure on the stack
that’s larger than a certain size, the C compiler generates a
call to __chkstk() in my checked builds. That reference, for
this or that reason, is not satisfied by the linker. I want to
either suppress the generation of that code or to find which
library that function is defined; I’d prefer that the compiler
doesn’t generate that call to begin with.

Do any of you know how to do it ? Tks,

Alberto.


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

You are currently subscribed to ntdev as: mark.cook@ca.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</mark.cook>

Thanks, Arlie! Much appreciated.

Alberto.

----- Original Message -----
From: “Arlie Davis”
To: “Windows System Software Devs Interest List”

Sent: Thursday, September 15, 2005 11:33 AM
Subject: RE: [ntdev] Access to parallel ports from Win32

>I believe you can control this. The /Gs[n] option controls the
>threshold
> for inserting stack probes. “#pragma check_stack(off)” can be
> used to
> disable the behavior entirely.
>
> – arlie
>
>
> -----Original Message-----
> From: xxxxx@lists.osr.com
> [mailto:xxxxx@lists.osr.com] On Behalf Of
> Alberto Moreira
> Sent: Thursday, September 15, 2005 8:50 AM
> To: Windows System Software Devs Interest List
> Subject: Re: [ntdev] Access to parallel ports from Win32
>
> Hi, Guys,
>
> I’m having an annoying problem that’s simple enough that I
> feel I should
> know the answer, yet it’s buried within the structure of the
> Microsoft DDK
> toolset that I’m reluctant to dig into. So I wonder if someone
> has some
> wisdom to share with me ?
>
> The problem is this, whenever I have a structure on the stack
> that’s larger
> than a certain size, the C compiler generates a call to
> __chkstk() in my
> checked builds. That reference, for this or that reason, is
> not satisfied by
> the linker. I want to either suppress the generation of that
> code or to find
> which library that function is defined; I’d prefer that the
> compiler doesn’t
> generate that call to begin with.
>
> Do any of you know how to do it ? Tks,
>
>
> Alberto.
>
>
> —
> Questions? First check the Kernel Driver FAQ at
> http://www.osronline.com/article.cfm?id=256
>
> You are currently subscribed to ntdev as:
> xxxxx@stonestreetone.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: xxxxx@ieee.org
> To unsubscribe send a blank email to
> xxxxx@lists.osr.com

You know, I don’t know if I like the idea of the compiler
inserting calls into my object code and the linker not filling
them up. Because this is a checked build, I’m not sure I care
about what kind of code they generate for me, as long as it
works! But I believe that if the compiler includes a call to
chkstk, the linker should fill it up; and I’m using the DDK
compiler, mind you. So, to me at least this looks like a bug.

Anyway, I’ll use the pragma, because I can do that without
messing up with batch and make files: I hate to do that kind of
thing. This buffer is a staging area for setting up a stream of
graphics rendering commands to my chip, and that stream can be
rather longish; the alternative is to put it in the nonpaged
pool, but why waste time allocating and deallocating memory if I
can do it otherwise ? Another consideration is, this is portable
code, it must run just the same under Windows, Linux and
Solaris, so, I can’t be too particular about API issues or I end
up multiplying by three the number of lines of code I have to
write.

The other thing is, this is a very high performance environment,
which uses a huge amount of memory, so, it can be quite tricky
to allocate and use resources without bringing the whole machine
to its knees! The driver is very carefully tuned to extract the
maximum throughput from the chip and from the bus, and that’s
the major consideration here. Trading performance for safety may
not be a feasible strategy in my case! So, even if the checked
build doesn’t like it, if it works in the production free build
I’m happy with it. But meanwhile I have a daily build to satisfy
and a QA manager that will be on my back in no time if I
systematically break that build!

Alberto.

----- Original Message -----
From: “David J. Craig”
Newsgroups: ntdev
To: “Windows System Software Devs Interest List”

Sent: Thursday, September 15, 2005 12:13 PM
Subject: Re:[ntdev] Access to parallel ports from Win32

>A couple of people provided advice to suppress this behavior,
>but I disagree. Any local stack usage should be carefully
>examined and anything large should be a pointer on the stack
>that is allocated from either the paged or nonpaged pool. Try
>driver prefast and it will flag all allocations larger than 1KB
>and the utility permits this to be varied so it will report
>even smaller stack usage by a single function. I think
>anything about 256 bytes in a single function is probably
>excessive and a potential danger.
>
> You can’t use the __chkstk() function in drivers since it is
> not aware of the rules. It could be replaced by your own
> function that uses the correct stack limits and usage calls,
> but I prefer to just not cause a problem. Of course, this
> becomes far more critical in file system filters.
>
> “Alberto Moreira” wrote in message
> news:xxxxx@ntdev…
>> Hi, Guys,
>>
>> I’m having an annoying problem that’s simple enough that I
>> feel I should know the answer, yet it’s buried within the
>> structure of the Microsoft DDK toolset that I’m reluctant to
>> dig into. So I wonder if someone has some wisdom to share
>> with me ?
>>
>> The problem is this, whenever I have a structure on the stack
>> that’s larger than a certain size, the C compiler generates a
>> call to__chkstk() in my checked builds. That reference, for
>> this or that reason, is not satisfied by the linker. I want
>> to either suppress the generation of that code or to find
>> which library that function is defined; I’d prefer that the
>> compiler doesn’t generate that call to begin with.
>>
>> Do any of you know how to do it ? Tks,
>>
>>
>> Alberto.
>>
>>
>
>
>
> —
> Questions? First check the Kernel Driver FAQ at
> http://www.osronline.com/article.cfm?id=256
>
> You are currently subscribed to ntdev as: xxxxx@ieee.org
> To unsubscribe send a blank email to
> xxxxx@lists.osr.com

I know you know this, but you can use look aside lists for memory
allocations. Since this is a video driver, I am not sure if they are as
restricted as file systems. It can work, but you will have to handle the
chkstk function. The one Microsoft supplies with the compiler is just for
user mode. It will not work in the kernel. How can it make the calls to
find the stack size and pointer properly? It is most probably an artifact
of the compiler that the DDK team didn’t or couldn’t get modified for their
version.

“Alberto Moreira” wrote in message news:xxxxx@ntdev…
> You know, I don’t know if I like the idea of the compiler inserting calls
> into my object code and the linker not filling them up. Because this is a
> checked build, I’m not sure I care about what kind of code they generate
> for me, as long as it works! But I believe that if the compiler includes
> a call to chkstk, the linker should fill it up; and I’m using the DDK
> compiler, mind you. So, to me at least this looks like a bug.
>
> Anyway, I’ll use the pragma, because I can do that without messing up with
> batch and make files: I hate to do that kind of thing. This buffer is a
> staging area for setting up a stream of graphics rendering commands to my
> chip, and that stream can be rather longish; the alternative is to put it
> in the nonpaged pool, but why waste time allocating and deallocating
> memory if I can do it otherwise ? Another consideration is, this is
> portable code, it must run just the same under Windows, Linux and Solaris,
> so, I can’t be too particular about API issues or I end up multiplying by
> three the number of lines of code I have to write.
>
> The other thing is, this is a very high performance environment, which
> uses a huge amount of memory, so, it can be quite tricky to allocate and
> use resources without bringing the whole machine to its knees! The driver
> is very carefully tuned to extract the maximum throughput from the chip
> and from the bus, and that’s the major consideration here. Trading
> performance for safety may not be a feasible strategy in my case! So, even
> if the checked build doesn’t like it, if it works in the production free
> build I’m happy with it. But meanwhile I have a daily build to satisfy and
> a QA manager that will be on my back in no time if I systematically break
> that build!
>
> Alberto.
>
>
> ----- Original Message -----
> From: “David J. Craig”
> Newsgroups: ntdev
> To: “Windows System Software Devs Interest List”
> Sent: Thursday, September 15, 2005 12:13 PM
> Subject: Re:[ntdev] Access to parallel ports from Win32
>
>
>>A couple of people provided advice to suppress this behavior, but I
>>disagree. Any local stack usage should be carefully examined and anything
>>large should be a pointer on the stack that is allocated from either the
>>paged or nonpaged pool. Try driver prefast and it will flag all
>>allocations larger than 1KB and the utility permits this to be varied so
>>it will report even smaller stack usage by a single function. I think
>>anything about 256 bytes in a single function is probably excessive and a
>>potential danger.
>>
>> You can’t use the __chkstk() function in drivers since it is not aware of
>> the rules. It could be replaced by your own function that uses the
>> correct stack limits and usage calls, but I prefer to just not cause a
>> problem. Of course, this becomes far more critical in file system
>> filters.
>>
>> “Alberto Moreira” wrote in message
>> news:xxxxx@ntdev…
>>> Hi, Guys,
>>>
>>> I’m having an annoying problem that’s simple enough that I feel I should
>>> know the answer, yet it’s buried within the structure of the Microsoft
>>> DDK toolset that I’m reluctant to dig into. So I wonder if someone has
>>> some wisdom to share with me ?
>>>
>>> The problem is this, whenever I have a structure on the stack that’s
>>> larger than a certain size, the C compiler generates a call to
>>>__chkstk() in my checked builds. That reference, for this or that
>>> reason, is not satisfied by the linker. I want to either suppress the
>>> generation of that code or to find which library that function is
>>> defined; I’d prefer that the compiler doesn’t generate that call to
>>> begin with.
>>>
>>> Do any of you know how to do it ? Tks,
>>>
>>>
>>> Alberto.
>>>
>>>
>>
>>
>>
>> —
>> Questions? First check the Kernel Driver FAQ at
>> http://www.osronline.com/article.cfm?id=256
>>
>> You are currently subscribed to ntdev as: xxxxx@ieee.org
>> To unsubscribe send a blank email to xxxxx@lists.osr.com
>
>

Why would the linker magically generate code to fill in a function
that’s not defined in the runtime library? Would you be happy about
such code or would you be calling that a bug too?

Are you worried about the performance lost by a single function call
being injected? Or are you explaining why you don’t want to allocate
the buffers from pool? I can’t actually tell (perhaps it’s just too
late)

-p

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Alberto Moreira
Sent: Thursday, September 15, 2005 7:01 PM
To: Windows System Software Devs Interest List
Subject: Re: Re:[ntdev] Access to parallel ports from Win32

You know, I don’t know if I like the idea of the compiler inserting
calls into my object code and the linker not filling them up. Because
this is a checked build, I’m not sure I care about what kind of code
they generate for me, as long as it works! But I believe that if the
compiler includes a call to chkstk, the linker should fill it up; and
I’m using the DDK compiler, mind you. So, to me at least this looks like
a bug.

Anyway, I’ll use the pragma, because I can do that without messing up
with batch and make files: I hate to do that kind of thing. This buffer
is a staging area for setting up a stream of graphics rendering commands
to my chip, and that stream can be rather longish; the alternative is to
put it in the nonpaged pool, but why waste time allocating and
deallocating memory if I can do it otherwise ? Another consideration is,
this is portable code, it must run just the same under Windows, Linux
and Solaris, so, I can’t be too particular about API issues or I end up
multiplying by three the number of lines of code I have to write.

The other thing is, this is a very high performance environment, which
uses a huge amount of memory, so, it can be quite tricky to allocate and
use resources without bringing the whole machine to its knees! The
driver is very carefully tuned to extract the maximum throughput from
the chip and from the bus, and that’s the major consideration here.
Trading performance for safety may not be a feasible strategy in my
case! So, even if the checked build doesn’t like it, if it works in the
production free build I’m happy with it. But meanwhile I have a daily
build to satisfy and a QA manager that will be on my back in no time if
I systematically break that build!

Alberto.

----- Original Message -----
From: “David J. Craig”
Newsgroups: ntdev
To: “Windows System Software Devs Interest List”

Sent: Thursday, September 15, 2005 12:13 PM
Subject: Re:[ntdev] Access to parallel ports from Win32

>A couple of people provided advice to suppress this behavior,
>but I disagree. Any local stack usage should be carefully
>examined and anything large should be a pointer on the stack
>that is allocated from either the paged or nonpaged pool. Try
>driver prefast and it will flag all allocations larger than 1KB
>and the utility permits this to be varied so it will report
>even smaller stack usage by a single function. I think
>anything about 256 bytes in a single function is probably
>excessive and a potential danger.
>
> You can’t use the __chkstk() function in drivers since it is
> not aware of the rules. It could be replaced by your own
> function that uses the correct stack limits and usage calls,
> but I prefer to just not cause a problem. Of course, this
> becomes far more critical in file system filters.
>
> “Alberto Moreira” wrote in message
> news:xxxxx@ntdev…
>> Hi, Guys,
>>
>> I’m having an annoying problem that’s simple enough that I
>> feel I should know the answer, yet it’s buried within the
>> structure of the Microsoft DDK toolset that I’m reluctant to
>> dig into. So I wonder if someone has some wisdom to share
>> with me ?
>>
>> The problem is this, whenever I have a structure on the stack
>> that’s larger than a certain size, the C compiler generates a
>> call to__chkstk() in my checked builds. That reference, for
>> this or that reason, is not satisfied by the linker. I want
>> to either suppress the generation of that code or to find
>> which library that function is defined; I’d prefer that the
>> compiler doesn’t generate that call to begin with.
>>
>> Do any of you know how to do it ? Tks,
>>
>>
>> Alberto.
>>
>>
>
>
>
> —
> Questions? First check the Kernel Driver FAQ at
> http://www.osronline.com/article.cfm?id=256
>
> You are currently subscribed to ntdev as: xxxxx@ieee.org
> 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@windows.microsoft.com
To unsubscribe send a blank email to xxxxx@lists.osr.com

My main problem with this driver is, I want to avoid using OS
APIs, because the code must work transparently in all my OS’s
(including Linux 32 and 64 bit, Solaris, and I hear noises of
other flavors of Unix coming up) and I don’t want to write
multiple copies of this code: the driver has an OS-dependent
layer, but I want to keep that layer as small as I can! On the
other hand, things are kind of easier in the sense that this is
not a video driver but a high speed, dedicated, volume rendering
driver running on specialized hardware, and I do not have to
handle any system stuff such as GDI, Direct 3D or OpenGL. The
array is just a fixed-size local variable, and I use it to
compose the command stream I’m going to send out to the chip’s
hardware queues. The problem is, a whole lot of things can go
wrong while I’m building that command stream, so I set it up on
my own store, and I only commit the finished stream to the hw
queues when I know everything is nice and dandy. To complicate
things, I may have multiple boards in the system and multiple
devices in one board, which means that I may not only be
concurrently setting up multiple streams to different devices,
but I may also have multiple opens on the same device setting up
multiple streams too.

I believe that one problem I have here is that this is the DDK
compiler should by default generate kernel-safe code in all
circumstances. I can just as easy write my own version of
__chkstk(), but I wish the DDK included a version of it for me!

Alberto.

----- Original Message -----
From: “David J. Craig”
Newsgroups: ntdev
To: “Windows System Software Devs Interest List”

Sent: Friday, September 16, 2005 12:29 AM
Subject: Re:[ntdev] Re:Access to parallel ports from Win32

>I know you know this, but you can use look aside lists for
>memory allocations. Since this is a video driver, I am not
>sure if they are as restricted as file systems. It can work,
>but you will have to handle the chkstk function. The one
>Microsoft supplies with the compiler is just for user mode. It
>will not work in the kernel. How can it make the calls to find
>the stack size and pointer properly? It is most probably an
>artifact of the compiler that the DDK team didn’t or couldn’t
>get modified for their version.
>
> “Alberto Moreira” wrote in message
> news:xxxxx@ntdev…
>> You know, I don’t know if I like the idea of the compiler
>> inserting calls into my object code and the linker not
>> filling them up. Because this is a checked build, I’m not
>> sure I care about what kind of code they generate for me, as
>> long as it works! But I believe that if the compiler
>> includes a call to chkstk, the linker should fill it up; and
>> I’m using the DDK compiler, mind you. So, to me at least this
>> looks like a bug.
>>
>> Anyway, I’ll use the pragma, because I can do that without
>> messing up with batch and make files: I hate to do that kind
>> of thing. This buffer is a staging area for setting up a
>> stream of graphics rendering commands to my chip, and that
>> stream can be rather longish; the alternative is to put it in
>> the nonpaged pool, but why waste time allocating and
>> deallocating memory if I can do it otherwise ? Another
>> consideration is, this is portable code, it must run just the
>> same under Windows, Linux and Solaris, so, I can’t be too
>> particular about API issues or I end up multiplying by three
>> the number of lines of code I have to write.
>>
>> The other thing is, this is a very high performance
>> environment, which uses a huge amount of memory, so, it can
>> be quite tricky to allocate and use resources without
>> bringing the whole machine to its knees! The driver is very
>> carefully tuned to extract the maximum throughput from the
>> chip and from the bus, and that’s the major consideration
>> here. Trading performance for safety may not be a feasible
>> strategy in my case! So, even if the checked build doesn’t
>> like it, if it works in the production free build I’m happy
>> with it. But meanwhile I have a daily build to satisfy and a
>> QA manager that will be on my back in no time if I
>> systematically break that build!
>>
>> Alberto.
>>
>>
>> ----- Original Message -----
>> From: “David J. Craig”
>> Newsgroups: ntdev
>> To: “Windows System Software Devs Interest List”
>>
>> Sent: Thursday, September 15, 2005 12:13 PM
>> Subject: Re:[ntdev] Access to parallel ports from Win32
>>
>>
>>>A couple of people provided advice to suppress this behavior,
>>>but I disagree. Any local stack usage should be carefully
>>>examined and anything large should be a pointer on the stack
>>>that is allocated from either the paged or nonpaged pool.
>>>Try driver prefast and it will flag all allocations larger
>>>than 1KB and the utility permits this to be varied so it will
>>>report even smaller stack usage by a single function. I
>>>think anything about 256 bytes in a single function is
>>>probably excessive and a potential danger.
>>>
>>> You can’t use the __chkstk() function in drivers since it is
>>> not aware of the rules. It could be replaced by your own
>>> function that uses the correct stack limits and usage calls,
>>> but I prefer to just not cause a problem. Of course, this
>>> becomes far more critical in file system filters.
>>>
>>> “Alberto Moreira” wrote in message
>>> news:xxxxx@ntdev…
>>>> Hi, Guys,
>>>>
>>>> I’m having an annoying problem that’s simple enough that I
>>>> feel I should know the answer, yet it’s buried within the
>>>> structure of the Microsoft DDK toolset that I’m reluctant
>>>> to dig into. So I wonder if someone has some wisdom to
>>>> share with me ?
>>>>
>>>> The problem is this, whenever I have a structure on the
>>>> stack that’s larger than a certain size, the C compiler
>>>> generates a call to__chkstk() in my checked builds. That
>>>> reference, for this or that reason, is not satisfied by the
>>>> linker. I want to either suppress the generation of that
>>>> code or to find which library that function is defined; I’d
>>>> prefer that the compiler doesn’t generate that call to
>>>> begin with.
>>>>
>>>> Do any of you know how to do it ? Tks,
>>>>
>>>>
>>>> Alberto.
>>>>
>>>>
>>>
>>>
>>>
>>> —
>>> Questions? First check the Kernel Driver FAQ at
>>> http://www.osronline.com/article.cfm?id=256
>>>
>>> You are currently subscribed to ntdev as: xxxxx@ieee.org
>>> 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@ieee.org
> To unsubscribe send a blank email to
> xxxxx@lists.osr.com