[Win32utils-devel] Need some help with latest win32-mmap
Heesob Park
phasis at gmail.com
Wed Oct 11 21:09:05 EDT 2006
Hi,
2006/10/12, Berger, Daniel <Daniel.Berger at qwest.com>:
>
> > -----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
>
> <snip>
>
> > 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
> end
should be:
def get_view_size
mbi = [0,0,0,0,0,0,0].pack('LLLLLLL') # MEMORY_BASIC_INFORMATION
VirtualQuery(@address, mbi, mbi.size)
return mbi[12,4].unpack('L').first # RegionSize
end
Then, in MMap.new, I have this:
>
> if @open
> size = get_view_size()
> @address = MapViewOfFileEx(@mh, @access, 0, 0, size, @base_address)
> else
> @address = MapViewOfFileEx(@mh, @access, 0, 0, 0, @base_address)
> end
should be:
if @open
@address = MapViewOfFileEx(@mh, @access, 0, 0, 0, @base_address)
@size = get_view_size()
else
@address = MapViewOfFileEx(@mh, @access, 0, 0, 0, @base_address)
end
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...
>
> Regards,
>
> Dan
It seems the memory map in windows aligns 4k boundary.
When created with 20, get_view_size returns 4096
When created with 20000, get_view_size returns 20480.
Regards,
Park Heesob
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://rubyforge.org/pipermail/win32utils-devel/attachments/20061012/ce212b83/attachment.html
More information about the win32utils-devel
mailing list