#171 Missing "_AMD64_" for DDK-Headers, structs broken alignment

closed-fixed
nobody
header (101)
5
2010-07-23
2010-06-08
Henry N.
No

Inside DDK-Headers often is checked "_AMD64_" as the only check for 64 bit.
On MinGW-w64 is only defined "__amd64", "_AMD64_" is not set ane non of the headers set it.

Many structs and unions fails with badly attribute for "aligned".

An example for IO_STACK_LOCATION have attached. The file is an userland example for simple test.
You can put the same check into a driver to see the same problem with DbgPrint.

Headers ddk + psdk used as include path from ReactOS SVN revision 47668.

The buggy output is:
OutputBufferLength sizeof 4, offset 0
InputBufferLength sizeof 4, offset 4
IoControlCode sizeof 4, offset 8
Type3InputBuffer sizeof 8, offset 12
DeviceIoControl sizeof 20
Parameters sizeof 32

The right output, what you also have under WDK with MS-Compiler would be:
OutputBufferLength sizeof 4, offset 0
InputBufferLength sizeof 4, offset 8
IoControlCode sizeof 4, offset 16
Type3InputBuffer sizeof 8, offset 24
DeviceIoControl sizeof 32
Parameters sizeof 32

A workaround is to set _AMD64_ before the DDK headers will include, for example in GCC command line.

Discussion

  • Henry N.
    Henry N.
    2010-06-08

    Prints offsets of elements in struct IO_STACK_LOCATION

     
    Attachments
  • Henry N.
    Henry N.
    2010-06-08

    • summary: Missing "AMD64" for DDK-Headers --> Missing "AMD64" for DDK-Headers, structs broken alignment
     
  • Henry N.
    Henry N.
    2010-06-09

    Thanks. You are very fast.

    Yes, that fixed the problem.
    Unless, I would use __amd64 or __amd64__ for that part. Not __x86_64.

    Index: experimental/ddk_test/include/ntdef.h

    --- experimental/ddk_test/include/ntdef.h (revision 2482)
    +++ experimental/ddk_test/include/ntdef.h (working copy)
    @@ -5,7 +5,7 @@
    #define I_X86_
    #endif

    -#if !defined(I_X86_) && !defined(_IA64_) && !defined(_AMD64_) && defined(__x86_64)
    +#if !defined(I_X86_) && !defined(_IA64_) && !defined(_AMD64_) && defined(__amd64)
    #define _AMD64_
    #endif

     
  • Henry N.
    Henry N.
    2010-07-23

    • status: open --> closed-fixed
     
  • Henry N.
    Henry N.
    2010-07-23

    This is working now, I will close this bug.