John
2009-08-12 23:09:28 UTC
I have the following struct:
typedef struct _MINE
{
UCHAR a[6];
UCHAR B[6];
USHORT C;
USHORT D;
USHORT E;
UCHAR F;
UCHAR G;
USHORT H;
UCHAR I[6];
UINT J;
UCHAR K[6];
UINT L;
} MINE, *PMINE;
When I try to use this in code, I have this ...
PMINE a;
a = (PMINE) someBuffer;
Now, someBuffer has all of the correct stuff filled into it. When I set "a"
to point to it, everything in "a" is fine except the last UINT L. For some
reason, I get this:
a->A == OK;
a->B == OK;
a->C == OK;
a->D == OK;
a->E == OK;
a->F == OK;
a->G == OK;
a->H == OK;
a->I == OK;
a->J == OK;
a->K == OK;
a->L == NOT OK;
a->L = Almost OK. It appears as though a->L is really only 2 bytes instead
of 4 in the debugger. Also, it also appears as though a->L starts pointing
2 bytes after a->K. So, in memory, it looks like this:
a->K 00, 01, 02, 03, 04, 05; FINE
06 07; Two bytes that I need but are skipped
a->L = 08, 09;
Then a bunch of zeros appear after 09. If I set my struct to this:
typedef struct _MINE
{
UCHAR a[6];
UCHAR B[6];
UCHAR C[2];
UCHAR D[2];
UCHAR E[2];
UCHAR F;
UCHAR G;
UCHAR H[2];
UCHAR I[6];
UCHAR J[4];
UCHAR K[6];
UCHAR L[4];
} MINE, *PMINE;
Everything appears to point to the right stuff. However, if I do this then
I have to do some type of memcpy from L into a UINT. I don't want to do
that because it is extrememly ghetto, and this should be working. Can
anybody tell what's wrong? BTW, this is a kernel driver.
Thanks.
typedef struct _MINE
{
UCHAR a[6];
UCHAR B[6];
USHORT C;
USHORT D;
USHORT E;
UCHAR F;
UCHAR G;
USHORT H;
UCHAR I[6];
UINT J;
UCHAR K[6];
UINT L;
} MINE, *PMINE;
When I try to use this in code, I have this ...
PMINE a;
a = (PMINE) someBuffer;
Now, someBuffer has all of the correct stuff filled into it. When I set "a"
to point to it, everything in "a" is fine except the last UINT L. For some
reason, I get this:
a->A == OK;
a->B == OK;
a->C == OK;
a->D == OK;
a->E == OK;
a->F == OK;
a->G == OK;
a->H == OK;
a->I == OK;
a->J == OK;
a->K == OK;
a->L == NOT OK;
a->L = Almost OK. It appears as though a->L is really only 2 bytes instead
of 4 in the debugger. Also, it also appears as though a->L starts pointing
2 bytes after a->K. So, in memory, it looks like this:
a->K 00, 01, 02, 03, 04, 05; FINE
06 07; Two bytes that I need but are skipped
a->L = 08, 09;
Then a bunch of zeros appear after 09. If I set my struct to this:
typedef struct _MINE
{
UCHAR a[6];
UCHAR B[6];
UCHAR C[2];
UCHAR D[2];
UCHAR E[2];
UCHAR F;
UCHAR G;
UCHAR H[2];
UCHAR I[6];
UCHAR J[4];
UCHAR K[6];
UCHAR L[4];
} MINE, *PMINE;
Everything appears to point to the right stuff. However, if I do this then
I have to do some type of memcpy from L into a UINT. I don't want to do
that because it is extrememly ghetto, and this should be working. Can
anybody tell what's wrong? BTW, this is a kernel driver.
Thanks.