<P>I am having a problem with compilation of the driver. I've traced it to the new layout_check() routine which finds discrepancies between actual and expected structure sizes, and fails loading of the driver (better be more verbose about that, too - took me a while to track that "Can't load module: exec format error" error while trying various compiler/linker options).</P>
<P>I'm reading MSDN now, and it seems that the expected offsets are wrong in the routine, but need someone to confitm :)</P>
<P>Points in question:</P>
<P>* Microsoft definition of the <STRONG>IO_STACK_LOCATION</STRONG> structure, i.e.</P>
<P><A href="http://msdn.microsoft.com/en-us/library/windows/hardware/ff550659(v=vs.85).aspx">http://msdn.microsoft.com/en-us/library/windows/hardware/ff550659(v=vs.85).aspx</A></P>
<P>typedef struct _IO_STACK_LOCATION {<BR> UCHAR MajorFunction;<BR> UCHAR MinorFunction;<BR> UCHAR Flags;<BR> UCHAR Control;<BR> union {<BR>...</P>
<P> struct {<BR> ULONG Length;<BR> ULONG POINTER_ALIGNMENT Key;<BR> LARGE_INTEGER ByteOffset;<BR> } Read;<BR>...</P>
<P> </P>
<P>ULONG seems to be defined as a 32-bit word, though I can't be certain now.</P>
<P> </P>
<P>* ndis driver definition in include/ntoskrnl_var.h (~line 835):</P>
<P>/* See <A href="http://msdn.microsoft.com/en-us/library/windows/hardware/ff550659(v=vs.85).aspx">http://msdn.microsoft.com/en-us/library/windows/hardware/ff550659(v=vs.85).aspx</A> */<BR>struct io_stack_location {<BR> uint8_t isl_major;<BR> uint8_t isl_minor;<BR> uint8_t isl_flags;<BR> uint8_t isl_ctl;<BR>...</P>
<P> union {<BR> struct {<BR> uint32_t isl_len;<BR> /* "POINTER_ALIGNMENT" according to msdn */<BR> uint32_t *isl_key;<BR> uint64_t isl_byteoff;<BR> } isl_read;<BR>...</P>
<P> </P>
<P>* validation in if_ndis.c (~line 480):</P>
<P> || (offsetof(struct io_stack_location,<BR> isl_parameters.isl_read.isl_len) != 8)<BR> || (offsetof(struct io_stack_location,<BR> isl_parameters.isl_read.isl_byteoff) != 24)<BR> || (offsetof(struct io_stack_location,<BR> isl_parameters.isl_ioctl.isl_obuflen) != 8)<BR> || (offsetof(struct io_stack_location,<BR> isl_parameters.isl_ioctl.isl_ibuflen) != 16)<BR> || (offsetof(struct io_stack_location,<BR> isl_parameters.isl_ioctl.isl_iocode) != 24)<BR> || (offsetof(struct io_stack_location,<BR> isl_devobj) != 40)<BR> || (offsetof(struct io_stack_location,<BR> isl_completionfunc) != 56));<BR></P>
<P> </P>
<P>I can't get where the offset 8 for first component in unions comes into play? Before it are only four 1-byte variables, and the offsetof also returns 4...</P>
<P>The header does define padding for amd64 cases, but for later-occurring variables.</P>
<P> </P>
<P>So I guess it is a question for Jean-Pierre: where did you derive the numbers in layout_check from? Are they really correct?</P>
<P> </P>
<P>//Jim</P>