On 25 May 2006 19:43:40 +0100, [EMAIL PROTECTED] wrote:

>I am new to python win32, and i cannot figure out how to format the data 
>string for deviceiocontrol code with win32file.
>
>I have the following c struct in my driver file:
>typedef struct _WRITE_DEVICE_DATA_INPARAMS
>{
>       UCHAR ucMemorySpace;            // 0: I/O Space, 1: Mem Space.
>       ULONG ulPhysicalAddress;        // Dword-aligned offset to write to.
>       ULONG ulItemSize;                       // 1: Byte, 2: Word, 4: Dword.
>       ULONG ulItemCount;                      // Number of bytes, words or 
> dwords.
>
>       union{
>               UCHAR vucDataBuf[1];
>               USHORT vusDataBuf[1];
>               ULONG vulDataBuf[1];
>       }data;
>
>}WRITE_DEVICE_DATA_INPARAMS, *PWRITE_DEVICE_DATA_INPARAMS;
>  
>

This is not a good design, because it leaves open the question of
padding.  Unless you have overridden the normal #pragma pack, there will
be three bytes of padding between "ucMemorySpace" and
"ulPhysicalAddress".  If you should happen to use different packing in
your driver and your app, disaster will ensue.  You should probably just
make MemorySpace a ULONG so there is no possibility for confusion.

If ulPhysicalAddress is an offset, you should call it "ulOffset".  The
term "physical address" has a very specific meaning in Windows, and
32-bit is not enough to hold a real physical address.

-- 
Tim Roberts, [EMAIL PROTECTED]
Providenza & Boekelheide, Inc.

_______________________________________________
Python-win32 mailing list
Python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32

Reply via email to