Home » U++ Library support » U++ Library : Other (not classified elsewhere) » FileMapping::Create is broken on Windows [BUG]
FileMapping::Create is broken on Windows [BUG] [message #10410] |
Sat, 07 July 2007 00:17 |
benoitc
Messages: 17 Registered: July 2007 Location: Nice (France)
|
Promising Member |
|
|
Hello,
I'm using the latest 705-dev3, and FileMapping::Create seems to be broken for at least two reasons.
- line 1255: hmap = CreateFileMapping(hfile, NULL, PAGE_READWRITE, 0, 0, NULL);
That API failed and return 0 because it should not be called with a null size.
- line 1290 : rawbase = (byte *)MapViewOfFile(hmap, /*write ? FILE_MAP_WRITE*/ : FILE_MAP_READ,
For some reason, the write flag is commented, which prevent any write access to the file.
After fixing these two bugs, the API seems to work fine.
Regards,
Benoit
[Updated on: Thu, 11 October 2007 10:02] Report message to a moderator
|
|
|
|
Re: FileMapping::Create is broken on Windows [message #10433 is a reply to message #10427] |
Mon, 09 July 2007 10:33 |
benoitc
Messages: 17 Registered: July 2007 Location: Nice (France)
|
Promising Member |
|
|
No problem, here are the modification I did:
- line 1255: Replace 0 by maplen
hmap = CreateFileMapping(hfile, NULL, PAGE_READWRITE, 0, maplen, NULL);
- line 1290 : remove the comments
rawbase = (byte *)MapViewOfFile(hmap, write ? FILE_MAP_WRITE : FILE_MAP_READ,
I'm still wondering why it has that comment, it was probably done for a good reason, do you know why it was added?
Regards,
Benoit
|
|
|
Re: FileMapping::Create is broken on Windows [message #10456 is a reply to message #10433] |
Tue, 10 July 2007 08:50 |
rylek
Messages: 79 Registered: November 2005
|
Member |
|
|
Hello!
According to UVS archive, both changes are due to me, I'm ready to take the blame. Just for one of them, though; I believe that CreateFileMapping with 0, 0 is OK; according to MSDN,
Quote: |
dwMaximumSizeLow
[in] The low-order DWORD of the maximum size of the file mapping object.
If this parameter and dwMaximumSizeHigh are 0 (zero), the maximum size of the file mapping object is equal to the current size of the file that hFile identifies.
|
I'm afraid the commented FILE_MAP_WRITE was a temporary hack I tried during some debugging session and I forgot to undo it, I'm sorry for that. I didn't notice afterwards because to this day I've been using FileMapping for read-only file access.
Looking at it, there's another bug you didn't mention: the Expand method is implemented for Posix only, its Win32 implementation is omitted. If you have already fixed it and tested it successfully, please post your patch, I'm reluctant to make patches I cannot directly test in read life situations; but if you don't have the patch, I'll fix it somehow.
Regards
Tomas
[Updated on: Tue, 10 July 2007 08:54] Report message to a moderator
|
|
|
|
|
Goto Forum:
Current Time: Fri Apr 19 00:50:20 CEST 2024
Total time taken to generate the page: 0.02412 seconds
|