I have to allocate some memory in DriverEntry that needs to then be
passed to my FDO. The memory allocated represents unpopulated memory
from xen that may or may not be populated later (this in turn is managed
by the FDO). If I don’t allocate the unpopulated memory away from
windows right at the start of DriverEntry though then Windows tends to
try and use it which results in an instant crash.
Is a global variable the best way to do this? there will only ever be
one FDO created for any given instance of the driver. I hear that global
driver data tends to be frowned upon without having a good reason but I
think my reason is good enough 
Thanks
James
A global would be fine in this case, but it seems you are just masking the underlying problem by changing the time of the allocation .
d
dent from a phine with no keynoard
-----Original Message-----
From: James Harper
Sent: Saturday, February 26, 2011 7:44 PM
To: Windows System Software Devs Interest List
Subject: [ntdev] Allocating memory in DriverEntry for use by FDO
I have to allocate some memory in DriverEntry that needs to then be
passed to my FDO. The memory allocated represents unpopulated memory
from xen that may or may not be populated later (this in turn is managed
by the FDO). If I don’t allocate the unpopulated memory away from
windows right at the start of DriverEntry though then Windows tends to
try and use it which results in an instant crash.
Is a global variable the best way to do this? there will only ever be
one FDO created for any given instance of the driver. I hear that global
driver data tends to be frowned upon without having a good reason but I
think my reason is good enough 
Thanks
James
NTDEV is sponsored by OSR
For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars
To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer
>
A global would be fine in this case, but it seems you are just masking
the
underlying problem by changing the time of the allocation .
In theory yes, but it seems to work in practice.
Under xen, the two applicable settings are ‘memory’ and ‘maxmem’.
‘maxmem’ represents the amount of memory that Windows sees is actually
available, ‘memory’ is the amount of memory that is actually available
to be populated. Once the populated memory is all allocated to pages in
the VM, any further attempt to access a page will result in a hard crash
that the VM can’t trap.
Before I changed to allocating memory in DriverEntry, settings of
memory=512 and maxmem=1024 (units are megabytes) would result in a crash
before DriverEntry even completed (during trying to read the registry I
think). Now I can go as low as memory=128, and possibly lower - I
haven’t tried anything lower because running Windows 2008 on anything
less than 512, even for testing purposes, is probably a bit dumb. A bare
Windows 2008 x32 Standard Edition VM with 128MB of memory available out
of a total of 1GB does seem almost useable though (although my network
driver fails to start… I should investigate that).
If it turns out to have problems, I can always write a tiny WDM driver
that loads even earlier to allocate the memory there - it only needs
MmAllocatePagesForMdl/Ex and ExAllocatePoolWithTag initially.
Does Hyper-V allow adding memory to an already running VM? Does it use
any special tricks or is it just tightly integrated with Hyper-V?
James
Hi James - Dynamic Memory in SP1…
See Implementing_and_Configuring_Dynamic_ Memory.docx
I can’t figure out how to get the link out of Google.