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

Robert Jordan robertj at gmx.net
Wed Sep 28 08:07:36 EDT 2005


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




More information about the Mono-devel-list mailing list