Back to index

lightning-sunbird  0.9+nobinonly
Classes | Defines | Typedefs | Functions
mapismem.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  tagCOPYDATASTRUCT
struct  CSharedMem

Defines

#define WM_COPYDATA   0x004A
#define LPCTSTR   LPCSTR

Typedefs

typedef struct tagCOPYDATASTRUCT COPYDATASTRUCT
typedef struct tagCOPYDATASTRUCTPCOPYDATASTRUCT

Functions

CSharedMemNSCreateSharedMemory (DWORD memSize, LPCTSTR memName, HANDLE *hSharedMemory)
CSharedMemNSOpenExistingSharedMemory (LPCTSTR memName, HANDLE *hSharedMemory)
void NSCloseSharedMemory (CSharedMem *pData, HANDLE hSharedMemory)

Class Documentation

struct tagCOPYDATASTRUCT

Definition at line 50 of file mapismem.h.

Class Members
DWORD cbData
DWORD dwData
LPVOID lpData
struct CSharedMem

Definition at line 68 of file mapismem.h.

Class Members
BYTE m_buf
DWORD m_dwSize

Define Documentation

#define LPCTSTR   LPCSTR

Definition at line 57 of file mapismem.h.

#define WM_COPYDATA   0x004A

Definition at line 45 of file mapismem.h.


Typedef Documentation


Function Documentation

void NSCloseSharedMemory ( CSharedMem pData,
HANDLE  hSharedMemory 
)

Definition at line 150 of file mapismem.cpp.

{
#ifdef WIN32
  if(pData != 0) 
  { 
    UnmapViewOfFile(pData); 
    pData = 0; 
  } 

  if(hSharedMemory != 0) 
  { 
    CloseHandle(hSharedMemory); 
    hSharedMemory = 0; 
  } 
#else

       if (pData != NULL)
       {
              GlobalFreePtr(pData);
              pData = NULL;
       }

#endif // WIN32
}

Here is the caller graph for this function:

CSharedMem* NSCreateSharedMemory ( DWORD  memSize,
LPCTSTR  memName,
HANDLE hSharedMemory 
)

Definition at line 63 of file mapismem.cpp.

{
#ifdef WIN32

  BOOL bExistedBefore;
  CSharedMem *pData;

  LPCTSTR szObjectName = memName; 
  DWORD dwSize = sizeof(CSharedMem) + memSize; 
  *hSharedMemory = CreateFileMapping( 
    (HANDLE)0xFFFFFFFF,0,PAGE_READWRITE,0,dwSize,szObjectName); 
  if(*hSharedMemory == 0) 
  { 
    return NULL; 
  } 
  bExistedBefore = (GetLastError() == ERROR_ALREADY_EXISTS); 
  if(bExistedBefore) 
  { 
       return NULL;
  } 

  pData = (CSharedMem *)MapViewOfFile( 
            *hSharedMemory, FILE_MAP_ALL_ACCESS, 0, 0, 0); 
  if(pData == NULL) 
  { 
    return NULL; 
  } 

  ZeroMemory(pData, dwSize); 
  pData->m_dwSize = memSize; 

  return pData;
#else
  CSharedMem  *sMemChunk = NULL;
  DWORD dwSize = memSize = (sizeof(CSharedMem) + memSize); 

  if (sMemChunk != NULL)
         return(sMemChunk);

  sMemChunk = (CSharedMem *) GlobalAllocPtr(GMEM_MOVEABLE, dwSize);
  ZeroMemory(sMemChunk, (size_t) dwSize);
  sMemChunk->m_dwSize = dwSize;   // Missing in Communicator code!
  return(sMemChunk);

#endif // WIN32
}

Here is the caller graph for this function:

CSharedMem* NSOpenExistingSharedMemory ( LPCTSTR  memName,
HANDLE hSharedMemory 
)

Definition at line 116 of file mapismem.cpp.

{
#ifdef WIN32
  CSharedMem *pData;
  DWORD dwSize;

  LPCTSTR szObjectName = memName; 
  *hSharedMemory = OpenFileMapping( 
    FILE_MAP_WRITE,FALSE,szObjectName); 
  if(*hSharedMemory == 0) 
  { 
    return NULL; 
  } 

  pData = (CSharedMem *)MapViewOfFile( 
              *hSharedMemory,FILE_MAP_ALL_ACCESS,0,0,0); 
  if(pData == NULL) 
  { 
    return NULL; 
  } 
  
  dwSize = pData->m_dwSize; 
  return pData;
#else

  return(NULL);   // In Win16, this is really meaningless...

#endif
}  

Here is the caller graph for this function: