[Win32utils-devel] Need some help with latest win32-mmap

Berger, Daniel Daniel.Berger at qwest.com
Wed Oct 11 14:39:45 EDT 2006

> -----Original Message-----
> From: win32utils-devel-bounces at rubyforge.org 
> [mailto:win32utils-devel-bounces at rubyforge.org] On Behalf Of 
> Johan Nilsson
> Sent: Wednesday, October 11, 2006 1:13 AM
> To: Development and ideas for win32utils projects
> Subject: Re: [Win32utils-devel] Need some help with latest win32-mmap

> I haven't tried this myself, and judging from the MSDN docs it's also
> not entirely clear that it will work, but: Try using zero(0) 
> as the size
> when calling MapViewOfFile, and then use VirtualQuery to retrieve the
> size of the view.

I've been tinkering with this a bit.  I think I'm doing something wrong.
Here's a private method I created to get the view size.  Note that this
requires modifying the "VirtualQuery" (in windows/memory.rb) method
signature to "LPL":

def get_view_size
   mbi = [0,0,0,0,0,0,0].pack('LLLLLLL') # MEMORY_BASIC_INFORMATION
   VirtualQuery(@base_address, mbi, mbi.size)         
   return mbi[12,4].unpack('L').first # RegionSize

Then, in MMap.new, I have this:

if @open
   size = get_view_size()
   @address = MapViewOfFileEx(@mh, @access, 0, 0, size, @base_address)
   @address = MapViewOfFileEx(@mh, @access, 0, 0, 0, @base_address)

The first issue, I think, is that get_view_size always returns 65536
(64k).  I'm guessing 64k is a default amount of memory to allocate or
something.  Using the examples I provided previously, I would expect
this to be 20.

The second issue is that MapViewOfFileEx fails if I try to pass a size.
I think I'm misreading the docs.

I'd make some more commits so you could just check this out from
RubyForge, but I'm getting timeouts at the moment from rubyforge.org...



This communication is the property of Qwest and may contain confidential or
privileged information. Unauthorized use of this communication is strictly 
prohibited and may be unlawful.  If you have received this communication 
in error, please immediately notify the sender by reply e-mail and destroy 
all copies of the communication and any attachments.

More information about the win32utils-devel mailing list