void comm_serv::create_sec_attribute() { char secDesc[ SECURITY_DESCRIPTOR_MIN_LENGTH ]; secAttr.nLength = sizeof(secAttr); secAttr.bInheritHandle = FALSE; secAttr.lpSecurityDescriptor = &secDesc; InitializeSecurityDescriptor(secAttr.lpSecurityDescriptor, SECURITY_DESCRIPTOR_REVISION); SetSecurityDescriptorDacl(secAttr.lpSecurityDescriptor, TRUE, 0, FALSE); TCHAR * szSD = TEXT("D:") // Discretionary ACL //TEXT("(D;OICI;GA;;;BG)") // Deny access to built-in guests //TEXT("(D;OICI;GA;;;AN)") // Deny access to anonymous logon TEXT("(A;OICI;GRGWGX;;;AU)") // Allow read/write/execute to authenticated users TEXT("(A;OICI;GA;;;BA)"); // Allow full control to administrators PSECURITY_DESCRIPTOR pSD; BOOL retcode =ConvertStringSecurityDescriptorToSecurityDescriptor("S:(ML;;NW;;;LW)",SDDL_REVISION_1,&pSD,NULL); DWORD aa=GetLastError(); if(retcode != 0){ PACL pSacl = NULL; BOOL fSaclPresent = FALSE; BOOL fSaclDefaulted = FALSE; retcode =GetSecurityDescriptorSacl( pSD, &fSaclPresent, &pSacl, &fSaclDefaulted); if (pSacl) retcode =SetSecurityDescriptorSacl(secAttr.lpSecurityDescriptor, TRUE, pSacl, FALSE); } }
static int vboxTraySetupSeamless(void) { OSVERSIONINFO info; gMajorVersion = 5; /* Default to Windows XP. */ info.dwOSVersionInfoSize = sizeof(info); if (GetVersionEx(&info)) { Log(("VBoxTray: Windows version %ld.%ld\n", info.dwMajorVersion, info.dwMinorVersion)); gMajorVersion = info.dwMajorVersion; } /* We need to setup a security descriptor to allow other processes modify access to the seamless notification event semaphore. */ SECURITY_ATTRIBUTES SecAttr; DWORD dwErr = ERROR_SUCCESS; char secDesc[SECURITY_DESCRIPTOR_MIN_LENGTH]; BOOL fRC; SecAttr.nLength = sizeof(SecAttr); SecAttr.bInheritHandle = FALSE; SecAttr.lpSecurityDescriptor = &secDesc; InitializeSecurityDescriptor(SecAttr.lpSecurityDescriptor, SECURITY_DESCRIPTOR_REVISION); fRC = SetSecurityDescriptorDacl(SecAttr.lpSecurityDescriptor, TRUE, 0, FALSE); if (!fRC) { dwErr = GetLastError(); Log(("VBoxTray: SetSecurityDescriptorDacl failed with last error = %08X\n", dwErr)); } else { /* For Vista and up we need to change the integrity of the security descriptor, too. */ if (gMajorVersion >= 6) { BOOL (WINAPI * pfnConvertStringSecurityDescriptorToSecurityDescriptorA)(LPCSTR StringSecurityDescriptor, DWORD StringSDRevision, PSECURITY_DESCRIPTOR *SecurityDescriptor, PULONG SecurityDescriptorSize); HMODULE hModule = LoadLibrary("ADVAPI32.DLL"); if (!hModule) { dwErr = GetLastError(); Log(("VBoxTray: Loading module ADVAPI32.DLL failed with last error = %08X\n", dwErr)); } else { PSECURITY_DESCRIPTOR pSD; PACL pSacl = NULL; BOOL fSaclPresent = FALSE; BOOL fSaclDefaulted = FALSE; *(uintptr_t *)&pfnConvertStringSecurityDescriptorToSecurityDescriptorA = (uintptr_t)GetProcAddress(hModule, "ConvertStringSecurityDescriptorToSecurityDescriptorA"); Log(("VBoxTray: pfnConvertStringSecurityDescriptorToSecurityDescriptorA = %x\n", pfnConvertStringSecurityDescriptorToSecurityDescriptorA)); if (pfnConvertStringSecurityDescriptorToSecurityDescriptorA) { fRC = pfnConvertStringSecurityDescriptorToSecurityDescriptorA("S:(ML;;NW;;;LW)", /* this means "low integrity" */ SDDL_REVISION_1, &pSD, NULL); if (!fRC) { dwErr = GetLastError(); Log(("VBoxTray: ConvertStringSecurityDescriptorToSecurityDescriptorA failed with last error = %08X\n", dwErr)); } else { fRC = GetSecurityDescriptorSacl(pSD, &fSaclPresent, &pSacl, &fSaclDefaulted); if (!fRC) { dwErr = GetLastError(); Log(("VBoxTray: GetSecurityDescriptorSacl failed with last error = %08X\n", dwErr)); } else { fRC = SetSecurityDescriptorSacl(SecAttr.lpSecurityDescriptor, TRUE, pSacl, FALSE); if (!fRC) { dwErr = GetLastError(); Log(("VBoxTray: SetSecurityDescriptorSacl failed with last error = %08X\n", dwErr)); } } } } } } if ( dwErr == ERROR_SUCCESS && gMajorVersion >= 5) /* Only for W2K and up ... */ { ghSeamlessNotifyEvent = CreateEvent(&SecAttr, FALSE, FALSE, VBOXHOOK_GLOBAL_EVENT_NAME); if (ghSeamlessNotifyEvent == NULL) { dwErr = GetLastError(); Log(("VBoxTray: CreateEvent for Seamless failed, last error = %08X\n", dwErr)); } } } return RTErrConvertFromWin32(dwErr); }
HRESULT COpcSecurity::Attach(PSECURITY_DESCRIPTOR pSelfRelativeSD) { PACL pDACL = NULL; PACL pSACL = NULL; BOOL bDACLPresent, bSACLPresent; BOOL bDefaulted; PACL m_pDACL = NULL; ACCESS_ALLOWED_ACE* pACE; HRESULT hr; PSID pUserSid; PSID pGroupSid; hr = Initialize(); if(FAILED(hr)) return hr; // get the existing DACL. if (!GetSecurityDescriptorDacl(pSelfRelativeSD, &bDACLPresent, &pDACL, &bDefaulted)) goto failed; if (bDACLPresent) { if (pDACL) { // allocate new DACL. m_pDACL = (PACL) malloc(pDACL->AclSize); if (m_pDACL == NULL) { hr = E_OUTOFMEMORY; goto failedMemory; } // initialize the DACL if (!InitializeAcl(m_pDACL, pDACL->AclSize, ACL_REVISION)) goto failed; // copy the ACES for (int i = 0; i < pDACL->AceCount; i++) { if (!GetAce(pDACL, i, (void **)&pACE)) goto failed; if (!AddAccessAllowedAce(m_pDACL, ACL_REVISION, pACE->Mask, (PSID)&(pACE->SidStart))) goto failed; } if (!IsValidAcl(m_pDACL)) goto failed; } // set the DACL if (!SetSecurityDescriptorDacl(m_pSD, m_pDACL ? TRUE : FALSE, m_pDACL, bDefaulted)) goto failed; } // get the existing SACL. if (!GetSecurityDescriptorSacl(pSelfRelativeSD, &bSACLPresent, &pSACL, &bDefaulted)) goto failed; if (bSACLPresent) { if (pSACL) { // allocate new SACL. m_pSACL = (PACL) malloc(pSACL->AclSize); if (m_pSACL == NULL) { hr = E_OUTOFMEMORY; goto failedMemory; } // initialize the SACL if (!InitializeAcl(m_pSACL, pSACL->AclSize, ACL_REVISION)) goto failed; // copy the ACES for (int i = 0; i < pSACL->AceCount; i++) { if (!GetAce(pSACL, i, (void **)&pACE)) goto failed; if (!AddAccessAllowedAce(m_pSACL, ACL_REVISION, pACE->Mask, (PSID)&(pACE->SidStart))) goto failed; } if (!IsValidAcl(m_pSACL)) goto failed; } // set the SACL if (!SetSecurityDescriptorSacl(m_pSD, m_pSACL ? TRUE : FALSE, m_pSACL, bDefaulted)) goto failed; } if (!GetSecurityDescriptorOwner(m_pSD, &pUserSid, &bDefaulted)) goto failed; if (FAILED(SetOwner(pUserSid, bDefaulted))) goto failed; if (!GetSecurityDescriptorGroup(m_pSD, &pGroupSid, &bDefaulted)) goto failed; if (FAILED(SetGroup(pGroupSid, bDefaulted))) goto failed; if (!IsValidSecurityDescriptor(m_pSD)) goto failed; return hr; failed: hr = HRESULT_FROM_WIN32(hr); failedMemory: if (m_pDACL) { free(m_pDACL); m_pDACL = NULL; } if (m_pSD) { free(m_pSD); m_pSD = NULL; } return hr; }
int Event_Create( PVOID pVoid, BOOL bManualReset, BOOL bInitialState, const char *szName ) { PEVENT pEvent; #if FIX_NAMED_OBJECT_NAMESPACE char szFixedUpNameBuffer[255] = {0}; #endif const char* lpszFixedObjectName = szName; LPSECURITY_ATTRIBUTES pSecurityAttributes = 0; SECURITY_DESCRIPTOR secDesc = {0}; SECURITY_ATTRIBUTES attr = {0}; PSECURITY_DESCRIPTOR pSD = NULL; if(!pVoid) return ERROR_INVALID_ARGUMENT; pEvent = (PEVENT) pVoid; if(pEvent->hEvent != NULL) return SUCCESS; //if this is a named object then we are going to open up the permissions on it //so people in other accounts / sessions can also use the same shared named object. //Starting w/ vista services and the logged in users are no longer in the same session anymore aswell. if(szName) { #if FIX_SECURITY_DACL if(InitializeSecurityDescriptor(&secDesc,SECURITY_DESCRIPTOR_REVISION)) { //all access to this object for everyone if(SetSecurityDescriptorDacl(&secDesc, TRUE, NULL, FALSE)) { attr.nLength = sizeof(attr); attr.lpSecurityDescriptor = &secDesc; pSecurityAttributes = &attr; //Vista introduces "integrity" check levels. We are going to set this to "low" //to prevent us from locking out a low-integrity process if someone in //a service uses the api to open the mutex first. if(IsVistaOrBetter()) { if(ConvertStringSecurityDescriptorToSecurityDescriptor( "S:(ML;;NW;;;LW)", // "low integrity" SDDL_REVISION_1, &pSD, NULL)) { PACL pSacl = NULL; // not allocated BOOL fSaclPresent = FALSE; BOOL fSaclDefaulted = FALSE; GetSecurityDescriptorSacl( pSD, &fSaclPresent, &pSacl, &fSaclDefaulted); SetSecurityDescriptorSacl(attr.lpSecurityDescriptor, TRUE, pSacl, FALSE); } } } } #endif #if FIX_NAMED_OBJECT_NAMESPACE //For creating the event in the global namespace strcat(szFixedUpNameBuffer,"Global\\"); strcat(szFixedUpNameBuffer,szName); lpszFixedObjectName = szFixedUpNameBuffer; #endif } pEvent->hEvent = CreateEvent( pSecurityAttributes, /* no security attributes */ bManualReset, /* manual-reset event flag */ bInitialState, /* initial state flag */ lpszFixedObjectName /* object name */ ); //local free if needed if(pSD) { //preserve last error DWORD dwLastError = GetLastError(); LocalFree((HLOCAL)pSD); SetLastError(dwLastError); } if(pEvent->hEvent == NULL) return ERROR_CREATE_EVENT_FAILED; return SUCCESS; }
int Mutex_Create(PVOID pVoid, const char *szName) { PMUTEX pMutex; #if FIX_NAMED_OBJECT_NAMESPACE char szFixedUpNameBuffer[255] = {0}; #endif const char* lpszFixedObjectName = szName; LPSECURITY_ATTRIBUTES pSecurityAttributes = 0; SECURITY_DESCRIPTOR secDesc = {0}; SECURITY_ATTRIBUTES attr = {0}; PSECURITY_DESCRIPTOR pSD = NULL; if(!pVoid) return ERROR_INVALID_ARGUMENT; pMutex = (PMUTEX)pVoid; if(pMutex->hMutex != NULL) return SUCCESS; //if this is a named object then we are going to open up the permissions on it //so people in other accounts / sessions can also use the same shared named object. //Starting w/ vista services and the logged in users are no longer in the same session anymore aswell. if(szName) { #if FIX_SECURITY_DACL if(InitializeSecurityDescriptor(&secDesc,SECURITY_DESCRIPTOR_REVISION)) { //Give a NULL DACL for all access to everyone if(SetSecurityDescriptorDacl(&secDesc, TRUE, NULL, FALSE)) { attr.nLength = sizeof(attr); attr.lpSecurityDescriptor = &secDesc; pSecurityAttributes = &attr; //Vista introduces "integrity" check levels. We are going to set this to "low" //to prevent us from locking out a low-integrity process if someone in //a service uses the api to open the mutex first. if(IsVistaOrBetter()) { if(ConvertStringSecurityDescriptorToSecurityDescriptor( "S:(ML;;NW;;;LW)", // "low integrity" SDDL_REVISION_1, &pSD, NULL)) { PACL pSacl = NULL; // not allocated BOOL fSaclPresent = FALSE; BOOL fSaclDefaulted = FALSE; GetSecurityDescriptorSacl( pSD, &fSaclPresent, &pSacl, &fSaclDefaulted); //Set the SACL w/ low-integrity checks SetSecurityDescriptorSacl(attr.lpSecurityDescriptor, TRUE, pSacl, FALSE); } } } } #endif #if FIX_NAMED_OBJECT_NAMESPACE //now fix up the namespace on the object... strcat(szFixedUpNameBuffer,"Global\\"); strcat(szFixedUpNameBuffer,szName); lpszFixedObjectName = szFixedUpNameBuffer; #endif } /* Create a mutex with specified params */ pMutex->hMutex = CreateMutex( pSecurityAttributes, FALSE, lpszFixedObjectName ); //local free if needed if(pSD) { //preserve last error DWORD dwLastError = GetLastError(); LocalFree((HLOCAL)pSD); SetLastError(dwLastError); } if(pMutex->hMutex == NULL) return ERROR_CREATE_MUTEX_FAILED; return SUCCESS; }
bool InitializeProfAPISharedObj() { gCAProfAPISharedMapFile = OpenFileMappingW(FILE_MAP_ALL_ACCESS, // read/write access FALSE, // do not inherit the name CPU_PROF_SHARED_OBJ); // name of mapping object if (!gCAProfAPISharedMapFile) { SECURITY_ATTRIBUTES secAttr; char secDesc[ SECURITY_DESCRIPTOR_MIN_LENGTH ]; secAttr.nLength = sizeof(secAttr); secAttr.bInheritHandle = FALSE; secAttr.lpSecurityDescriptor = &secDesc; bool bHasSD = false; OSVERSIONINFO osVersionInfo; osVersionInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); if (GetVersionEx(&osVersionInfo)) { if (osVersionInfo.dwMajorVersion >= 6) { // Vista, Longhorn or later; bHasSD = true; } } if (bHasSD) { PSECURITY_DESCRIPTOR pSD; PACL pSacl = nullptr; // not allocated BOOL fSaclPresent = FALSE; BOOL fSaclDefaulted = FALSE; ConvertStringSecurityDescriptorToSecurityDescriptorW(L"S:(ML;;NW;;;LW)", // this means "low integrity" SDDL_REVISION_1, &pSD, nullptr); GetSecurityDescriptorSacl(pSD, &fSaclPresent, &pSacl, &fSaclDefaulted); SetSecurityDescriptorSacl(secAttr.lpSecurityDescriptor, TRUE, pSacl, FALSE); } InitializeSecurityDescriptor(secAttr.lpSecurityDescriptor, SECURITY_DESCRIPTOR_REVISION); SetSecurityDescriptorDacl(secAttr.lpSecurityDescriptor, TRUE, 0, FALSE); gCAProfAPISharedMapFile = CreateFileMappingW(INVALID_HANDLE_VALUE, &secAttr, // default security PAGE_READWRITE, // read/write access 0, // max. object size CPU_PROF_SHARED_MEM_SIZE, // buffer size CPU_PROF_SHARED_OBJ); // name of mapping object } if (gCAProfAPISharedMapFile) { return true; } else { return false; } }
bool comm_serv::Init(char *name,int IN_datasize_IN,int IN_datasize_OUT,bool app,bool master) { datasize_IN=IN_datasize_IN; datasize_OUT=IN_datasize_OUT; char secDesc[ SECURITY_DESCRIPTOR_MIN_LENGTH ]; secAttr.nLength = sizeof(secAttr); secAttr.bInheritHandle = FALSE; secAttr.lpSecurityDescriptor = &secDesc; InitializeSecurityDescriptor(secAttr.lpSecurityDescriptor, SECURITY_DESCRIPTOR_REVISION); SetSecurityDescriptorDacl(secAttr.lpSecurityDescriptor, TRUE, 0, FALSE); TCHAR * szSD = TEXT("D:") // Discretionary ACL //TEXT("(D;OICI;GA;;;BG)") // Deny access to built-in guests //TEXT("(D;OICI;GA;;;AN)") // Deny access to anonymous logon TEXT("(A;OICI;GRGWGX;;;AU)") // Allow read/write/execute to authenticated users TEXT("(A;OICI;GA;;;BA)"); // Allow full control to administrators PSECURITY_DESCRIPTOR pSD; BOOL retcode =ConvertStringSecurityDescriptorToSecurityDescriptor("S:(ML;;NW;;;LW)",SDDL_REVISION_1,&pSD,NULL); DWORD aa=GetLastError(); if(retcode != 0){ PACL pSacl = NULL; BOOL fSaclPresent = FALSE; BOOL fSaclDefaulted = FALSE; retcode =GetSecurityDescriptorSacl( pSD, &fSaclPresent, &pSacl, &fSaclDefaulted); if (pSacl) retcode =SetSecurityDescriptorSacl(secAttr.lpSecurityDescriptor, TRUE, pSacl, FALSE); } char savename[42]; strcpy_s(savename,42,name); if (app) { strcpy_s(filemapping_IN,64,""); strcpy_s(filemapping_OUT,64,""); strcpy_s(event_IN,64,""); strcpy_s(event_IN_DONE,64,""); strcpy_s(event_OUT,64,""); strcpy_s(event_OUT_DONE,64,""); strcat_s(filemapping_IN,64,name); strcat_s(filemapping_IN,64,"fm_IN"); strcat_s(filemapping_OUT,64,name); strcat_s(filemapping_OUT,64,"fm_OUT"); strcat_s(event_IN,64,name); strcat_s(event_IN,64,"event_IN"); strcat_s(event_IN_DONE,64,name); strcat_s(event_IN_DONE,64,"event_IN_DONE"); strcat_s(event_OUT,64,name); strcat_s(event_OUT,64,"event_OUT"); strcat_s(event_OUT_DONE,64,name); strcat_s(event_OUT_DONE,64,"event_OUT_DONE"); } else { strcpy_s(filemapping_IN,64,"Global\\"); strcpy_s(filemapping_OUT,64,"Global\\"); strcpy_s(event_IN,64,"Global\\"); strcpy_s(event_IN_DONE,64,"Global\\"); strcpy_s(event_OUT,64,"Global\\"); strcpy_s(event_OUT_DONE,64,"Global\\"); strcat_s(filemapping_IN,64,name); strcat_s(filemapping_IN,64,"fm_IN"); strcat_s(filemapping_OUT,64,name); strcat_s(filemapping_OUT,64,"fm_OUT"); strcat_s(event_IN,64,name); strcat_s(event_IN,64,"event_IN"); strcat_s(event_IN_DONE,64,name); strcat_s(event_IN_DONE,64,"event_IN_DONE"); strcat_s(event_OUT,64,name); strcat_s(event_OUT,64,"event_OUT"); strcat_s(event_OUT_DONE,64,name); strcat_s(event_OUT_DONE,64,"event_OUT_DONE"); } if (master) { if (!app) { if (datasize_IN!=0) { hMapFile_IN = CreateFileMapping(INVALID_HANDLE_VALUE,&secAttr,PAGE_READWRITE,0,datasize_IN,filemapping_IN); if (hMapFile_IN == NULL) return false; data_IN=(char*)MapViewOfFile(hMapFile_IN,FILE_MAP_ALL_ACCESS,0,0,datasize_IN); if(data_IN==NULL) return false; } event_E_IN=CreateEvent(&secAttr, FALSE, FALSE, event_IN); if(event_E_IN==NULL) return false; event_E_IN_DONE=CreateEvent(&secAttr, FALSE, FALSE, event_IN_DONE); if(event_IN_DONE==NULL) return false; if (datasize_OUT!=0) { hMapFile_OUT = CreateFileMapping(INVALID_HANDLE_VALUE,&secAttr,PAGE_READWRITE,0,datasize_OUT,filemapping_OUT); if (hMapFile_OUT == NULL) return false; data_OUT=(char*)MapViewOfFile(hMapFile_OUT,FILE_MAP_ALL_ACCESS,0,0,datasize_OUT); if(data_OUT==NULL) return false; } event_E_OUT=CreateEvent(&secAttr, FALSE, FALSE, event_OUT); if(event_E_OUT==NULL) return false; event_E_OUT_DONE=CreateEvent(&secAttr, FALSE, FALSE, event_OUT_DONE); if(event_OUT_DONE==NULL) return false; } else { if (datasize_IN!=0) { hMapFile_IN = CreateFileMapping(INVALID_HANDLE_VALUE,NULL,PAGE_READWRITE,0,datasize_IN,filemapping_IN); if (hMapFile_IN == NULL) return false; data_IN=(char*)MapViewOfFile(hMapFile_IN,FILE_MAP_ALL_ACCESS,0,0,datasize_IN); if(data_IN==NULL) return false; } event_E_IN=CreateEvent(NULL, FALSE, FALSE, event_IN); if(event_E_IN==NULL) return false; event_E_IN_DONE=CreateEvent(NULL, FALSE, FALSE, event_IN_DONE); if(event_IN_DONE==NULL) return false; if (datasize_OUT!=0) { hMapFile_OUT = CreateFileMapping(INVALID_HANDLE_VALUE,NULL,PAGE_READWRITE,0,datasize_OUT,filemapping_OUT); if (hMapFile_OUT == NULL) return false; data_OUT=(char*)MapViewOfFile(hMapFile_OUT,FILE_MAP_ALL_ACCESS,0,0,datasize_OUT); if(data_OUT==NULL) return false; } event_E_OUT=CreateEvent(NULL, FALSE, FALSE, event_OUT); if(event_E_OUT==NULL) return false; event_E_OUT_DONE=CreateEvent(NULL, FALSE, FALSE, event_OUT_DONE); if(event_OUT_DONE==NULL) return false; } } else { if (!app) { if (datasize_IN!=0) { hMapFile_IN = OpenFileMapping(FILE_MAP_ALL_ACCESS,FALSE,filemapping_IN); DWORD aa=GetLastError(); if (hMapFile_IN == NULL) return false; data_IN=(char*)MapViewOfFile(hMapFile_IN,FILE_MAP_ALL_ACCESS,0,0,datasize_IN); if(data_IN==NULL) return false; } event_E_IN=OpenEvent(EVENT_ALL_ACCESS, FALSE, event_IN); if(event_E_IN==NULL) return false; ResetEvent(event_E_IN); event_E_IN_DONE=OpenEvent(EVENT_ALL_ACCESS, FALSE, event_IN_DONE); if(event_IN_DONE==NULL) return false; ResetEvent(event_IN_DONE); if (datasize_OUT!=0) { hMapFile_OUT = OpenFileMapping(FILE_MAP_ALL_ACCESS,FALSE,filemapping_OUT); if (hMapFile_OUT == NULL) return false; data_OUT=(char*)MapViewOfFile(hMapFile_OUT,FILE_MAP_ALL_ACCESS,0,0,datasize_OUT); if(data_OUT==NULL) return false; } event_E_OUT=OpenEvent(EVENT_ALL_ACCESS, FALSE, event_OUT); if(event_E_OUT==NULL) return false; ResetEvent(event_E_OUT); event_E_OUT_DONE=OpenEvent(EVENT_ALL_ACCESS, FALSE, event_OUT_DONE); if(event_OUT_DONE==NULL) return false; ResetEvent(event_OUT_DONE); } else { if (datasize_IN!=0) { hMapFile_IN = OpenFileMapping(FILE_MAP_ALL_ACCESS,FALSE,filemapping_IN); if (hMapFile_IN == NULL) return false; data_IN=(char*)MapViewOfFile(hMapFile_IN,FILE_MAP_ALL_ACCESS,0,0,datasize_IN); if(data_IN==NULL) return false; } event_E_IN=OpenEvent(EVENT_ALL_ACCESS, FALSE, event_IN); if(event_E_IN==NULL) return false; ResetEvent(event_E_IN); event_E_IN_DONE=OpenEvent(EVENT_ALL_ACCESS, FALSE, event_IN_DONE); if(event_IN_DONE==NULL) return false; ResetEvent(event_IN_DONE); if (datasize_OUT!=0) { hMapFile_OUT =OpenFileMapping(FILE_MAP_ALL_ACCESS,FALSE,filemapping_OUT); if (hMapFile_OUT == NULL) return false; data_OUT=(char*)MapViewOfFile(hMapFile_OUT,FILE_MAP_ALL_ACCESS,0,0,datasize_OUT); if(data_OUT==NULL) return false; } event_E_OUT=OpenEvent(EVENT_ALL_ACCESS, FALSE, event_OUT); if(event_E_OUT==NULL) return false; ResetEvent(event_E_OUT); event_E_OUT_DONE=OpenEvent(EVENT_ALL_ACCESS, FALSE, event_OUT_DONE); if(event_OUT_DONE==NULL) return false; ResetEvent(event_OUT_DONE); } } return true; }