[Mono-dev] MapViewOfFile - I think there is a bug

Kornél Pál kornelpal at hotmail.com
Wed Sep 28 11:51:30 EDT 2005


Robert, you are wrong, when you state that uint should be used for SIZE_T.
SIZE_T is an unsigned integer with the size of void* that is UIntPtr.

Paul, you are right, this is a bug in mcs, I reported it:
http://bugzilla.ximian.com/show_bug.cgi?id=76256

If you declare dwNumberOfBytesToMap as IntPtr and cast BUFFERLEN to IntPtr
it will compile on mcs as well, and you will get the same result.

Kornél

----- Original Message -----
From: "Robert Jordan" <robertj at gmx.net>
To: <mono-devel-list at lists.ximian.com>
Sent: Wednesday, September 28, 2005 2:07 PM
Subject: Re: [Mono-dev] MapViewOfFile - I think there is a bug


> Paul F. Johnson wrote:
>> Hi,
>>
>> According to MSDN, MapViewOfFile should be
>>
>> LPVOID MapViewOfFile(
>>   HANDLE hFileMappingObject,
>>   DWORD dwDesiredAccess,
>>   DWORD dwFileOffsetHigh,
>>   DWORD dwFileOffsetLow,
>>   SIZE_T dwNumberOfBytesToMap
>> );
>>
>> I have some code which looks like this
>>
>> dataView = MapViewOfFile(dataMap, FILE_MAP_WRITE, 0, 0,
>> (UIntPtr)BUFFERLEN);
>
> Are you using that declaration?
>
> http://www.pinvoke.net/default.aspx/kernel32.MapViewOfFile
>
> It has a bug. This is the correct DllImport:
>
> [DllImport("kernel32.dll")]
> static extern IntPtr MapViewOfFile(
>    IntPtr hFileMappingObject,
>    uint dwDesiredAccess,
>    uint dwFileOffsetHigh,
>    uint dwFileOffsetLow,
>    uint dwNumberOfBytesToMap
>    );
>
>
> dataView = MapViewOfFile(dataMap, FILE_MAP_WRITE, 0, 0,
>  (uint) BUFFERLEN);
>
>
> Rob
>
> _______________________________________________
> Mono-devel-list mailing list
> Mono-devel-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-devel-list
>




More information about the Mono-devel-list mailing list