Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Reallocating (or resizing) driver memory

56 views
Skip to first unread message

David M

unread,
Sep 2, 2004, 8:25:27 AM9/2/04
to
Hi

(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

unread,
Sep 7, 2004, 7:20:33 AM9/7/04
to
David,
I am not all that familiar with these calls what you mentioned either.
But, my guess is that, some of the calls which you expect to be
wrapper functions may be doing something more than acting as a
wrapper, so there could be some side effect of one of this wrapper
which is causing the trobule, carefully look through the
implementation of these functions. Or the best way to get rid of the
problem is to use set of APIs all of which are compatible.

Tawalai


dav...@southcom.com.au (David M) wrote in message news:<6d08b094.0409...@posting.google.com>...

0 new messages