(Also posted to comp.os.ms-windows.programmer.nt.kernel-mode)
I'm very new to driver development, so I apologise in advance if this
is a ridiculously simple question. I have Googled a fair amount
though, and haven't found anything.
My basic problem is that, in an NDIS passthru driver, I have a pointer
to some dynamically allocated memory that I've allocated with
ExAllocatePoolWithTag. I want to reallocate it - that is, do the same
thing to it that the standard C library function realloc would do. At
the moment I'm using a realloc-like function I wrote, but reading
memory past the original allocation size causes an exception, and if I
don't catch it, a bsod.
So, I don't know what I'm doing, and I'd like to be able to have
equivalents of malloc and realloc and free and so forth. how do I do
it?
(Extra details if you can be bothered reading them: My realloc-like
function takes the old pointer, old allocation size and required new
allocation size, and returns a pointer to newly allocated memory like
so:
void * gbh_realloc(void * ptr, size_t oldamount, size_t amount)
{
// allocate new memory
void * new_ptr = gbh_malloc(amount);
if (new_ptr == NULL)
return NULL;
// if got this far, must be successful
// copy from old to new
NdisMoveMemory(new_ptr, ptr, oldamount);
// free the old memory
gbh_free(ptr);
// return the new pointer
return new_ptr;
}
I think I'm mixing NDIS and other memory functions a bit, but it
doesn't seem to make any difference. gbh_malloc as I said above is a
wrapper for ExAllocatePoolWithTag, and seems to work fine - it's only
when I reallocate or free that I have a problem. gbh_free currently
does nothing, but at various times has been a wrapper for
ExFreePool(ptr) or NdisFreeMemory(ptr, 0, 0). Using either led me
straight to a bsod.)
Thanks for your help,
David.
Tawalai
dav...@southcom.com.au (David M) wrote in message news:<6d08b094.0409...@posting.google.com>...