Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
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 Go to next message
benoitc is currently offline  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 #10427 is a reply to message #10410] Mon, 09 July 2007 09:27 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
I bet the fix is trivial, but to be sure, can you post the patch please?

Mirek
Re: FileMapping::Create is broken on Windows [message #10433 is a reply to message #10427] Mon, 09 July 2007 10:33 Go to previous messageGo to next message
benoitc is currently offline  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 Go to previous messageGo to next message
rylek is currently offline  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

Re: FileMapping::Create is broken on Windows [message #10457 is a reply to message #10456] Tue, 10 July 2007 11:17 Go to previous messageGo to next message
benoitc is currently offline  benoitc
Messages: 17
Registered: July 2007
Location: Nice (France)
Promising Member
Hi Tomas,

MSDN is correct, but the point is that for a Create the file size is not known when you call CreateFile and CreateFileMapping whereas in the Open case you know it after CreateFile so during the CreateFileMapping you do not need to give it.

I didn't use Expand yet, that why I didn't notice it was not implemented. So sorry, I don't have patch for it.

Regards,
Benoit
FileMapping::Create is broken on Windows [BUG] [message #12109 is a reply to message #10410] Thu, 11 October 2007 10:01 Go to previous message
benoitc is currently offline  benoitc
Messages: 17
Registered: July 2007
Location: Nice (France)
Promising Member
Hi,

The bug is still there on 710-dev1. Do you want me to apply the patch? In that case, I guess I need access to your uvs tool?

Regards,
Benoit
Previous Topic: LOG_DBG does not work correctly [BUG]
Next Topic: Remote folder/ remote printer dialogs
Goto Forum:
  


Current Time: Fri Apr 19 00:50:20 CEST 2024

Total time taken to generate the page: 0.02412 seconds