Re: byte alignment/dynamic memory from heap x64
- From: Mike L <MikeL@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Mon, 17 Sep 2007 10:12:02 -0700
Tim,
Thanks for the help. I had seen the definition in the WDK header that uses
declspec(align(16)) and I was compiling with x64 compiler.
I had read on msdn that declspec(align(n)) did not work for dynamic
allocation from the heap. At any rate, all is working when I am using
ExAllocatePoolWithTag and casting to my pointer.
thanks,
Mike
"Tim Roberts" wrote:
Mike L <MikeL@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote:.
My IM driver uses SLIST_ENTRY and SLIST_HEADER(s) and they are declared in a
struct and when my driver is loaded I dynamically allocate memory using these
structs.
for example(not my real struct...)
struct X {
int y;
PNDIS_BUFFER pBuf;
....
SLIST_HEADER ListHeader;
SLIST_ENTRY ListEntry;
...
};
The documention for x64 states that SLIST_ENTRY and SLIST_HEADER must be 16
byte aligned.
How do I force this to happen ?
You don't have to. A few minutes browsing through the include files will
show that SLIST_HEADER and SLIST_ENTRY are already declared with 16-byte
alignment. As long as your structure starts on a 16-byte boundary, the
header and entry structures will be so aligned.
Any advice is appreciated, I might have a bug in my code for one of the
above methods, so I really just need someone to tell me how this is normally
done and I can figure out the details. I saw another function
_align_memory, but did not want to link an NDIS driver to the c runtime for
memory management, but maybe that is another alternative.
You're sure you are compiling for x64? In the 32-bit build environments,
they aren't 16-byte aligned because they don't need to be.
--
Tim Roberts, timr@xxxxxxxxx
Providenza & Boekelheide, Inc.
- References:
- Re: byte alignment/dynamic memory from heap x64
- From: Tim Roberts
- Re: byte alignment/dynamic memory from heap x64
- Prev by Date: Re: A bluescreen caused by tcpip.sys.
- Next by Date: Re: 10 Commandments for WDM driver Development
- Previous by thread: Re: byte alignment/dynamic memory from heap x64
- Next by thread: How to set a default DATA FORMAT value for Pin in TestCap
- Index(es):
Relevant Pages
|