CreateFileMapping always returns ERROR_ALREADY_EXISTS

Discussion in 'Win32' started by timr, Oct 1, 2006.

  1. timr

    timr New Member

    Joined:
    Oct 1, 2006
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    I'm debugging problem with an application that memory maps a file for use as an inter process comm buffer. The call

    HANDLE h = CreateFileMapping((HANDLE) 0xFFFFFFFF,NULL,PAGE_READWRITE,0,SHARED_MEM_SIZE,"TheMappedObject");

    always returns successful with a handle, but when I call GetLastError() it identifies the file as already existing. This occurs even after a reboot of the computer. The trouble is, the memory size of the returned handle's object is limited to 4096 bytes, not the SHARED_MEM_SIZE specified in the call (which is 32k). So when the file is mapped, any access beyond 4096 bytes causes a crash/exception.

    The functional calls worked for quite a few months before this problem appeared. Some users of this application (though not many) also report a problem that I believe is directly associated with this issue.

    Does anyone know about this type of issue? . Is there a way of forcing the memory mapped file to be deleted or purged before starting the application? Can you find all open handles given the memory mapped name?

    thanks.
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice