#include "stdafx.h"

//#include "MainFrame.h"		// For g_pFrame.
#include "Communicate.h"

#define FDSENDER_START_CODE	0x1f2e3d4c
#define FDRECEIVER_START_CODE	0x4c3d2e1f

// _xZkqqHx_iLkEjHeMiDiBiDiCiDiKiCmFiCfAiJpBiCmJjDfNjBjHiClHiCoJiNmFjBoFiDfEiDeDiDfJiBeC_xHqqkZx_
const long s_lMapBuffSize = 0x1000;	// 4096_xZkqqHx_iDgPiDeDiDgHiBeC_xHqqkZx_
// _xZkqqHx_iDhNiDgCiDhGiDhEiDeAiDeDiDiLiCmFiOmAiNnLiCmJiKgNjFnLiClDiCoKiCoJjHmMiIoGiBeC_xHqqkZx_
const long s_lFileMapSize = sizeof(s_lMapBuffSize) + s_lMapBuffSize;

/*************************************************************************
 * <_xZkqqHx_iKnGjAjE_xHqqkZx_>	WaitForReceiver
 *
 * <_xZkqqHx_iLeAjEfM_xHqqkZx_>	_xZkqqHx_jBjHjAeNiMlDiCkKjBjHjAeNiClFiClNiDgGiBfLiDfOiCpAiBeBiOpDjAeNiMlDiCkKiOpDjAeNiClHiCoJiCnMiCmFjBnCiCmCiBeC_xHqqkZx_
 *
 * <_xZkqqHx_iIpIjAjE_xHqqkZx_>	hMutex		:_xZkqqHx_iDhOiDiFiBfLiDgFiDgCiDeOiDfIiBeC_xHqqkZx_
 *			lpMapBuff	:_xZkqqHx_iLkEjHeMiDiBiDiCiDiKiBeC_xHqqkZx_
 *
 * <_xZkqqHx_jFnEjCgM_xHqqkZx_>	_xZkqqHx_jAlDiPoNiPeJjHlJiCmIiCoHiCmO_xHqqkZx_ TRUE_xZkqqHx_iBeBiInJiPoNiPeJjHlJiCmIiCoHiCmO_xHqqkZx_ FALSE_xZkqqHx_iCpAjFnEiClHiBeC_xHqqkZx_
 *
 * <_xZkqqHx_jHjKjHpA_xHqqkZx_>	99.01.08 Fukushiro M. _xZkqqHx_iNoMjAkM_xHqqkZx_
 *************************************************************************/
static BOOL WaitForReceiver (HANDLE hMutex, LPVOID lpMapBuff)
{
	long  lSize;
	short lCount = 0;

	ReleaseMutex(hMutex);
	for (;;)
	{
		// _xZkqqHx_iOpDjAeNiMlDiCkKiDgGiBfLiDfOiCpAiOpDjAeNiClHiCoJiCmMiCpAjBnCiCmC_xHqqkZx_.
		if (WaitForSingleObject(hMutex, 3000L) == WAIT_TIMEOUT) return FALSE;
			// _xZkqqHx_iDfOiDeDiDiAiDeBiDeFiDgHiCmMiPoKiNiHiBeBiDeHiDiJiBfLjFjMiLeBiBeC_xHqqkZx_

		// _xZkqqHx_iLkEjHeMiDiBiDiCiDiKiCmMjAoGjDkKiCpAjClCiCnHiCoJiBeC_xHqqkZx_
		memcpy(&lSize, lpMapBuff, sizeof(lSize));
		// _xZkqqHx_iDgGiBfLiDfOiCkKiOpDjAeNiClDiCoKiCmEiCkCiCoKiCmOiPeJjHlJiBeC_xHqqkZx_
		if (lSize == 0) break;
		// _xZkqqHx_iDhOiDiFiBfLiDgFiDgCiDeOiDfIiCpAiJpAjFpKiBeC_xHqqkZx_
		ReleaseMutex(hMutex);
		// _xZkqqHx_iDiLiBfLiDhGiCkK_xHqqkZx_300_xZkqqHx_iJpBiCpAiJhKiCkGiClNiCoHiDeHiDiJiBfLiPeJjHlJiBeC_xHqqkZx_
		if (300 < lCount++) return FALSE;
		// 10msec_xZkqqHx_iLhIiMgFiBeC_xHqqkZx_
		Sleep(10L);
	}
	return TRUE;
} // WaitForReceiver.

/*************************************************************************
 * <_xZkqqHx_iKnGjAjE_xHqqkZx_>	WaitForSender
 *
 * <_xZkqqHx_iLeAjEfM_xHqqkZx_>	_xZkqqHx_iOpDjAeNiMlDiCkKiDgGiBfLiDfOiCpAiOpDjAeNiClFiClNiMoDiCmJiBeBjBjHjAeNiMlDiCkKiDgGiBfLiDfOiCpAjBjHjAeNiClHiCoJiCnMiCmFjBnCiCmCiBeC_xHqqkZx_
 *
 * <_xZkqqHx_iIpIjAjE_xHqqkZx_>	hMutex		:_xZkqqHx_iDhOiDiFiBfLiDgFiDgCiDeOiDfIiBeC_xHqqkZx_
 *			lpMapBuff	:_xZkqqHx_iLkEjHeMiDiBiDiCiDiKiBeC_xHqqkZx_
 *
 * <_xZkqqHx_jFnEjCgM_xHqqkZx_>	_xZkqqHx_jAlDiPoNiPeJjHlJiCmIiCoHiCmO_xHqqkZx_ TRUE_xZkqqHx_iBeBiInJiPoNiPeJjHlJiCmIiCoHiCmO_xHqqkZx_ FALSE_xZkqqHx_iCpAjFnEiClHiBeC_xHqqkZx_
 *
 * <_xZkqqHx_jHjKjHpA_xHqqkZx_>	99.01.08 Fukushiro M. _xZkqqHx_iNoMjAkM_xHqqkZx_
 *************************************************************************/
static BOOL WaitForSender (HANDLE hMutex, LPVOID lpMapBuff)
{
	long  lSize;
	short lCount = 0;

	ReleaseMutex(hMutex);
	for (;;)
	{
		// _xZkqqHx_jBjHjAeNiMlDiCkKiDgGiBfLiDfOiCpAjBjHjAeNiClHiCoJiCmMiCpAjBnCiCmC_xHqqkZx_.
		if (WaitForSingleObject(hMutex, 3000L) == WAIT_TIMEOUT) return FALSE;
			// _xZkqqHx_iDfOiDeDiDiAiDeBiDeFiDgHiCmMiPoKiNiHiBeBiDeHiDiJiBfLjFjMiLeBiBeC_xHqqkZx_

		// _xZkqqHx_iLkEjHeMiDiBiDiCiDiKiCmMjAoGjDkKiCpAjClCiCnHiCoJiBeC_xHqqkZx_
		memcpy(&lSize, lpMapBuff, sizeof(lSize));
		// _xZkqqHx_iDgGiBfLiDfOiCkKjBjHjAeNiClDiCoKiCmEiCkCiCoKiCmOiPeJjHlJiBeC_xHqqkZx_
		if (lSize != 0) break;
		// _xZkqqHx_iDhOiDiFiBfLiDgFiDgCiDeOiDfIiCpAiJpAjFpKiBeC_xHqqkZx_
		ReleaseMutex(hMutex);
		// _xZkqqHx_iDiLiBfLiDhGiCkK_xHqqkZx_300_xZkqqHx_iJpBiCpAiJhKiCkGiClNiCoHiDeHiDiJiBfLiPeJjHlJiBeC_xHqqkZx_
		if (300 < lCount++) return FALSE;
		// 10msec_xZkqqHx_iLhIiMgFiBeC_xHqqkZx_
		Sleep(10L);
	}
	return TRUE;
} // WaitForSender.

/*************************************************************************
 * <_xZkqqHx_iKnGjAjE_xHqqkZx_>	SendData
 *
 * <_xZkqqHx_iLeAjEfM_xHqqkZx_>	_xZkqqHx_iDgGiBfLiDfOiCpAiOpDjAeNiMlDiCmJjBmOiClFiCmEjBjHjAeNiClHiCoJiBeC_xHqqkZx_
 *
 * <_xZkqqHx_iIpIjAjE_xHqqkZx_>	hWnd		:_xZkqqHx_iOpDjAeNiMlDiCmMiDhEiDiMiBfLiDiAiDeFiDeCiDjDiDgIiDeFiBeC_xHqqkZx_
 *			lDataSize	:_xZkqqHx_jBjHjAeNiClHiCoJiDgGiBfLiDfOiCmMiDfEiDeDiDfJiBeC_xHqqkZx_
 *			bypData		:_xZkqqHx_jBjHjAeNiClHiCoJiDgGiBfLiDfOiBeC_xHqqkZx_
 *
 * <_xZkqqHx_jFnEjCgM_xHqqkZx_>	_xZkqqHx_jAlDiPoNiPeJjHlJiCmIiCoHiCmO_xHqqkZx_ TRUE_xZkqqHx_iBeBiInJiPoNiPeJjHlJiCmIiCoHiCmO_xHqqkZx_ FALSE_xZkqqHx_iCpAjFnEiClHiBeC_xHqqkZx_
 *
 * <_xZkqqHx_jCiNiInD_xHqqkZx_>	lDataSize _xZkqqHx_iCmN_xHqqkZx_ 1_xZkqqHx_iImIiPoDiCmFiCmIiCkPiCoKiCmOiCmIiCoHiCmIiCkCiBeC_xHqqkZx_
 *			SendData_xZkqqHx_iCmNjIeBjBlBiClFiCmEiCmNiOgHiCkGiCmIiCkCiBeCjGiIiJpBiDhOiDiFiBfLiDgFiDgCiDeOiDfIiCpAiKeKjFpKiClHiCoJiCkKiBeB_xHqqkZx_
 *			_xZkqqHx_iClLiCmMjGlMjBePjAlGjAkMiCmMiLeLjBkFiCkKiIoKjCoIiCmFiCkAiCoJiClNiCnPiBeBiCfBiJpBjGnKiCmM_xHqqkZx_SendData_xZkqqHx_iCmG_xHqqkZx_
 *			_xZkqqHx_iCfAiJpBjGnKiCmM_xHqqkZx_ReceiveData_xZkqqHx_jBkEiCmMiDhOiDiFiBfLiDgFiDgCiDeOiDfIiCkKiPgEiCmIiCoJiJmCjEfMjAkLiCkKiCkAiCoJiBeC_xHqqkZx_
 *
 * <_xZkqqHx_jHjKjHpA_xHqqkZx_>	99.01.08 Fukushiro M. _xZkqqHx_iNoMjAkM_xHqqkZx_
 *************************************************************************/
BOOL SendData (HWND hWnd, long lDataSize, const BYTE* bypData)
{
	CString strMutexName;
	CString	strMapName;
	DWORD dwSenderPID;
	DWORD dwReceiverPID;
	long  lSize;
	const BYTE* pTmp;
	HANDLE hFileMap;
	HANDLE hMutex;
	LPVOID lpMapBuff;

	SECURITY_ATTRIBUTES	SecAttr;
	SecAttr.nLength = sizeof(SecAttr);
	SecAttr.bInheritHandle = TRUE;
	SecAttr.lpSecurityDescriptor = NULL;

	// _xZkqqHx_jBjHjAeNiMlDiCmMiDhGiDiNiDfKiDfI_xHqqkZx_ID_xZkqqHx_iCpAiOoGjDlOiBeC_xHqqkZx_
	dwSenderPID = GetCurrentProcessId();
	// _xZkqqHx_iDeFiDeCiDjDiDgIiDeFiDgOiDjDiDgIiDiLiCkJiCoHiOpDjAeNiMlDiCmMiDhGiDiNiDfKiDfI_xHqqkZx_ID_xZkqqHx_iCpAiOoGjDlOiBeC_xHqqkZx_
	GetWindowThreadProcessId(hWnd, &dwReceiverPID);
	// _xZkqqHx_iDhOiDiFiBfLiDgFiDgCiDeOiDfIiCmMjGlMjBePiCpAjAlGjAkMiBeC_xHqqkZx_
	strMutexName.Format(_T("MolipDraw.Mutex:%x:%x"), dwSenderPID, dwReceiverPID);
	// _xZkqqHx_iDhEiDeAiDeDiDiLiDhNiDgCiDhGiCmMjGlMjBePiCpAjAlGjAkMiBeC_xHqqkZx_
	strMapName.Format(_T("MolipDraw.FileMap:%x:%x"), dwSenderPID, dwReceiverPID);

	/*----- _xZkqqHx_iDhEiDeAiDeDiDiLiDhNiDgCiDhGiCpAiNoMjAkM_xHqqkZx_ -----*/
	hFileMap = CreateFileMapping(reinterpret_cast<HANDLE>(0xffffffff),
						NULL, PAGE_READWRITE, 0, s_lFileMapSize, strMapName);
	if (hFileMap == NULL) goto L_ERR;
	/*----- _xZkqqHx_iDhEiDeAiDeDiDiLiDhNiDgCiDhGiCpAiClBiCmMiDhGiDiNiDfKiDfIiCmMiDiBiDiCiDiKiPoDiCmJiDhNiDgCiDhG_xHqqkZx_ -----*/
	lpMapBuff = MapViewOfFile(hFileMap, FILE_MAP_ALL_ACCESS, 0, 0, 0);
	if (lpMapBuff == NULL) goto L_ERR;

	// _xZkqqHx_iDhOiDiFiBfLiDgFiDgCiDeOiDfIiCpAiNoMjAkMiBeCiDeJiBfLiDgJiBfLiCmJiCmNiCmIiCoHiCmIiCkCiBeC_xHqqkZx_
	hMutex = CreateMutex(&SecAttr, FALSE, strMutexName);
	if (hMutex == NULL) goto L_ERR;

	/*----- _xZkqqHx_iOpDjAeNiMlDiCmGiNmFiPiJiCmMjDkPiKpKiCpAiCmGiCoJ_xHqqkZx_ (Communicate.doc) -----*/
	// _xZkqqHx_iDhOiDiFiBfLiDgFiDgCiDeOiDfIiCpAiKgNjFnLiBeC_xHqqkZx_
	if (WaitForSingleObject(hMutex, 10000L) == WAIT_TIMEOUT) goto L_ERR;
	for (;;)
	{
		lSize = FDSENDER_START_CODE;
		// _xZkqqHx_iLkEjHeMiDiBiDiCiDiKiCmJiDfIiDfOiBfLiDgHiDfCiBfLiDgIiCpAiLeMjIfOiBeC_xHqqkZx_
		memcpy(lpMapBuff, &lSize, sizeof(lSize));
		// _xZkqqHx_iLkEjHeMiDiBiDiCiDiKiCpAiDhEiDiJiDgCiDfGiDiFiBeC_xHqqkZx_
		FlushViewOfFile(lpMapBuff, 0);
		// _xZkqqHx_iDhOiDiFiBfLiDgFiDgCiDeOiDfIiCpAiJpAjFpKiBeC_xHqqkZx_
		ReleaseMutex(hMutex);
		// _xZkqqHx_iDhOiDiFiBfLiDgFiDgCiDeOiDfIiCpAiKgNjFnLiBeC_xHqqkZx_
		if (WaitForSingleObject(hMutex, 10000L) == WAIT_TIMEOUT) goto L_ERR;
		// _xZkqqHx_iOpDjAeNiMlDiCmMiPiAjEpFiCkKiCmFiCkLiCmEiCkCiCoJiCkJiDgAiDeGiDgCiDeOiBeC_xHqqkZx_
		memcpy(&lSize, lpMapBuff, sizeof(lSize));
		if (lSize == 0) break;	// 0_xZkqqHx_iCmIiCoHiCmOiOpDjAeNiMlDiPiAjEpFiKkOjHlJiBeC_xHqqkZx_
		// 10msec_xZkqqHx_iLhIiMgFiBeC_xHqqkZx_
		Sleep(10L);
	}

	// _xZkqqHx_iLkEjHeMiDiBiDiCiDiKiCmJjBfDiDgGiBfLiDfOiDfEiDeDiDfJiCpAiLeMjIfOiBeC_xHqqkZx_
	memcpy(lpMapBuff, &lDataSize, sizeof(lDataSize));
	// _xZkqqHx_iLkEjHeMiDiBiDiCiDiKiCpAiDhEiDiJiDgCiDfGiDiFiBeC_xHqqkZx_
	FlushViewOfFile(lpMapBuff, 0);
	// _xZkqqHx_iOpDjAeNiMlDiCkKiDgGiBfLiDfOiOpDjAeNiClHiCoJiCmMiCpAjBnCiCmCiBeC_xHqqkZx_
	if (!WaitForReceiver(hMutex, lpMapBuff)) goto L_ERR;

	/*----- _xZkqqHx_iDgGiBfLiDfOiCpAiDhEiDeAiDeDiDiLiDhNiDgCiDhGiDfEiDeDiDfJiCmJjFkKiKiEiClFiCmEjDfNjBjH_xHqqkZx_ -----*/
	pTmp = bypData;
	while (s_lMapBuffSize < lDataSize)
	{
		// _xZkqqHx_iLkEjHeMiDiBiDiCiDiKiCmJjDfNjBjHiClHiCoJiDgGiBfLiDfOiCpAiLeMjIfOiBeC_xHqqkZx_
		memcpy(lpMapBuff, &s_lMapBuffSize, sizeof(s_lMapBuffSize));
		memcpy((BYTE*)lpMapBuff + sizeof(s_lMapBuffSize), pTmp, s_lMapBuffSize);
		pTmp += s_lMapBuffSize;
		lDataSize -= s_lMapBuffSize;
		// _xZkqqHx_iLkEjHeMiDiBiDiCiDiKiCpAiDhEiDiJiDgCiDfGiDiFiBeC_xHqqkZx_
		FlushViewOfFile(lpMapBuff, 0);
		// _xZkqqHx_iOpDjAeNiMlDiCkKiDgGiBfLiDfOiOpDjAeNiClHiCoJiCmMiCpAjBnCiCmCiBeC_xHqqkZx_
		if (!WaitForReceiver(hMutex, lpMapBuff)) goto L_ERR;
	}

	/*----- _xZkqqHx_iNmFiMoDiCmMiDgGiBfLiDfOiCpAjDfNjBjH_xHqqkZx_ -----*/
	memcpy(lpMapBuff, &lDataSize, sizeof(lDataSize));
	memcpy((BYTE*)lpMapBuff + sizeof(lDataSize), pTmp, lDataSize);
	// _xZkqqHx_iLkEjHeMiDiBiDiCiDiKiCpAiDhEiDiJiDgCiDfGiDiFiBeC_xHqqkZx_
	FlushViewOfFile(lpMapBuff, 0);
	// _xZkqqHx_iOpDjAeNiMlDiCkKiDgGiBfLiDfOiOpDjAeNiClHiCoJiCmMiCpAjBnCiCmCiBeC_xHqqkZx_
	if (!WaitForReceiver(hMutex, lpMapBuff)) goto L_ERR;

	ReleaseMutex(hMutex);		// _xZkqqHx_iDhOiDiFiBfLiDgFiDgCiDeOiDfIiCpAiJpAjFpKiBeC_xHqqkZx_
	CloseHandle(hMutex);		// _xZkqqHx_iDhOiDiFiBfLiDgFiDgCiDeOiDfIiCpAiDeOiDiNiBfLiDfJiBeC_xHqqkZx_
	UnmapViewOfFile(lpMapBuff);	// _xZkqqHx_iClBiClPiCoHiCmM_xHqqkZx_FileMap_xZkqqHx_iCpA_xHqqkZx_Unmap.
	CloseHandle(hFileMap);		// FileMap_xZkqqHx_iCpAiDeOiDiNiBfLiDfJ_xHqqkZx_.
	return TRUE;

L_ERR:
	if (hMutex != NULL)
	{
		ReleaseMutex(hMutex);		// _xZkqqHx_iDhOiDiFiBfLiDgFiDgCiDeOiDfIiCpAiJpAjFpKiBeC_xHqqkZx_
		CloseHandle(hMutex);		// _xZkqqHx_iDhOiDiFiBfLiDgFiDgCiDeOiDfIiCpAiDeOiDiNiBfLiDfJiBeC_xHqqkZx_
	}
	if (lpMapBuff != NULL) UnmapViewOfFile(lpMapBuff);	// _xZkqqHx_iClBiClPiCoHiCmM_xHqqkZx_FileMap_xZkqqHx_iCpA_xHqqkZx_Unmap.
	if (hFileMap != NULL) CloseHandle(hFileMap);		// FileMap_xZkqqHx_iCpAiDeOiDiNiBfLiDfJ_xHqqkZx_.
	return FALSE;
} // SendData.

/*************************************************************************
 * <_xZkqqHx_iKnGjAjE_xHqqkZx_>	ReceiveData
 *
 * <_xZkqqHx_iLeAjEfM_xHqqkZx_>	_xZkqqHx_jBjHjAeNiMlDiCkJiCoHiCmMiDgGiBfLiDfOiCpAiOpDjAeNiClHiCoJiBeC_xHqqkZx_
 *
 * <_xZkqqHx_iIpIjAjE_xHqqkZx_>	hWnd		:_xZkqqHx_jBjHjAeNiMlDiCmMiDhEiDiMiBfLiDiAiDeFiDeCiDjDiDgIiDeFiBeC_xHqqkZx_
 *			lDataSize	:_xZkqqHx_iOpDjAeNiClFiClNiDgGiBfLiDfOiCmMiDfEiDeDiDfJiCpAjFnEiClHiBeC_xHqqkZx_
 *			bypData		:_xZkqqHx_iOpDjAeNiClFiClNiDgGiBfLiDfOiCmMjHmMiIoGiCpAjFnEiClHiBeC_xHqqkZx_
 *
 * <_xZkqqHx_jFnEjCgM_xHqqkZx_>	_xZkqqHx_jAlDiPoNiPeJjHlJiCmIiCoHiCmO_xHqqkZx_ TRUE_xZkqqHx_iBeBiInJiPoNiPeJjHlJiCmIiCoHiCmO_xHqqkZx_ FALSE_xZkqqHx_iCpAjFnEiClHiBeC_xHqqkZx_
 *
 * <_xZkqqHx_jCiNiInD_xHqqkZx_>	bypData_xZkqqHx_jFmPjAjEiCmJiCmNiBeB_xHqqkZx_new_xZkqqHx_iCmFiKgNjFnLiClDiCoKiClNjHmMiIoGiCkKjAnNjCoIiClDiCoKiCoJiBeC_xHqqkZx_
 *			_xZkqqHx_jFhDjHhGiCmJiCmIiCmBiClNiMoDiBeB_xHqqkZx_delete[]_xZkqqHx_iCmFiJpAjFpKiClHiCoJjFeLjHhGiCkKiCkAiCoJiBeC_xHqqkZx_
 *			lDataSize _xZkqqHx_iCmN_xHqqkZx_ 1_xZkqqHx_iImIiPoDiCmFiCmIiCkPiCoKiCmOiCmIiCoHiCmIiCkCiBeC_xHqqkZx_
 *			SendData/ReceiveData_xZkqqHx_iCmNjIeBjBlBiClFiCmEiCmNiOgHiCkGiCmIiCkCiBeCjGiIiJpBiDhOiDiFiBfLiDgFiDgCiDeOiDfIiCpA_xHqqkZx_
 *			_xZkqqHx_iKeKjFpKiClHiCoJiCkKiBeBiClLiCmMjGlMjBePjAlGjAkMiCmMiLeLjBkFiCkKiIoKjCoIiCmFiCkAiCoJiClNiCnPiBeBiCfBiJpBjGnKiCmM_xHqqkZx_SendData_xZkqqHx_iCmG_xHqqkZx_
 *			_xZkqqHx_iCfAiJpBjGnKiCmM_xHqqkZx_ReceiveData_xZkqqHx_jBkEiCmMiDhOiDiFiBfLiDgFiDgCiDeOiDfIiCkKiPgEiCmIiCoJiJmCjEfMjAkLiCkKiCkAiCoJiBeC_xHqqkZx_
 *
 * <_xZkqqHx_jHjKjHpA_xHqqkZx_>	99.01.08 Fukushiro M. _xZkqqHx_iNoMjAkM_xHqqkZx_
 *************************************************************************/
BOOL ReceiveData (HWND hWnd, long& lDataSize, BYTE*& bypData)
{
	CString strMutexName;
	CString	strMapName;
	DWORD dwSenderPID;
	DWORD dwReceiverPID;
	long lSize, lCount;
	HANDLE hFileMap;
	HANDLE hMutex;
	LPVOID lpMapBuff;

	SECURITY_ATTRIBUTES	SecAttr;
	SecAttr.nLength = sizeof(SecAttr);
	SecAttr.bInheritHandle = TRUE;
	SecAttr.lpSecurityDescriptor = NULL;

	// _xZkqqHx_iDeFiDeCiDjDiDgIiDeFiDgOiDjDiDgIiDiLiCkJiCoHjBjHjAeNiMlDiCmMiDhGiDiNiDfKiDfI_xHqqkZx_ID_xZkqqHx_iCpAiOoGjDlOiBeC_xHqqkZx_
	GetWindowThreadProcessId(hWnd, &dwSenderPID);
	// _xZkqqHx_iDeFiDeCiDjDiDgIiDeFiDgOiDjDiDgIiDiLiCkJiCoHiOpDjAeNiMlDiCmMiDhGiDiNiDfKiDfI_xHqqkZx_ID_xZkqqHx_iCpAiOoGjDlOiBeC_xHqqkZx_
	dwReceiverPID = GetCurrentProcessId();
	// _xZkqqHx_iDhOiDiFiBfLiDgFiDgCiDeOiDfIiCmMjGlMjBePiCpAjAlGjAkMiBeC_xHqqkZx_
	strMutexName.Format(_T("MolipDraw.Mutex:%x:%x"), dwSenderPID, dwReceiverPID);
	// _xZkqqHx_iDhEiDeAiDeDiDiLiDhNiDgCiDhGiCmMjGlMjBePiCpAjAlGjAkMiBeC_xHqqkZx_
	strMapName.Format(_T("MolipDraw.FileMap:%x:%x"), dwSenderPID, dwReceiverPID);

	// _xZkqqHx_iDhEiDeAiDeDiDiLiDhNiDgCiDhGiCmMiDeJiBfLiDhGiDjDiBeC_xHqqkZx_
	hFileMap = CreateFileMapping(reinterpret_cast<HANDLE>(0xffffffff),
						NULL, PAGE_READWRITE, 0, s_lFileMapSize, strMapName);
	if (hFileMap == NULL) goto L_ERR;
	// _xZkqqHx_iDhEiDeAiDeDiDiLiDhNiDgCiDhGiDhCiDiFiBfLiCpAiDiBiDiCiDiKiPoDiCmJiDhNiDgCiDhGiBeC_xHqqkZx_
	lpMapBuff = MapViewOfFile(hFileMap, FILE_MAP_ALL_ACCESS, 0, 0, 0);
	if (lpMapBuff == NULL) goto L_ERR;

	// _xZkqqHx_iDhOiDiFiBfLiDgFiDgCiDeOiDfIiCmMiDeJiBfLiDhGiDjDiBeCiDeJiBfLiDgJiBfLiCmJiCmIiCoHiCmIiCkCiBeC_xHqqkZx_
	hMutex = CreateMutex(&SecAttr, FALSE, strMutexName);
	if (hMutex == NULL) goto L_ERR;

	/*----- _xZkqqHx_jBjHjAeNiMlDiCmGiNmFiPiJiCmMjDkPiKpKiCpAiCmGiCoJ_xHqqkZx_ (Communicate.doc) -----*/
	// _xZkqqHx_iDhOiDiFiBfLiDgFiDgCiDeOiDfIiCpAiKgNjFnLiBeC_xHqqkZx_
	if (WaitForSingleObject(hMutex, 10000L) == WAIT_TIMEOUT) goto L_ERR;
	for (;;)
	{
		lSize = FDRECEIVER_START_CODE;
		// _xZkqqHx_iLkEjHeMiDiBiDiCiDiKiCmJiDfIiDfOiBfLiDgHiDfCiBfLiDgIiCpAiLeMjIfOiBeC_xHqqkZx_
		memcpy(lpMapBuff, &lSize, sizeof(lSize));
		// _xZkqqHx_iLkEjHeMiDiBiDiCiDiKiCpAiDhEiDiJiDgCiDfGiDiFiBeC_xHqqkZx_
		FlushViewOfFile(lpMapBuff, 0);
		// _xZkqqHx_iDhOiDiFiBfLiDgFiDgCiDeOiDfIiCpAiJpAjFpKiBeC_xHqqkZx_
		ReleaseMutex(hMutex);
		// _xZkqqHx_iDhOiDiFiBfLiDgFiDgCiDeOiDfIiCpAiKgNjFnLiBeC_xHqqkZx_
		if (WaitForSingleObject(hMutex, 10000L) == WAIT_TIMEOUT) goto L_ERR;
		// _xZkqqHx_jBjHjAeNiMlDiCmMiPiAjEpFiCkKiCmFiCkLiCmEiCkCiCoJiCkJiDgAiDeGiDgCiDeOiBeC_xHqqkZx_
		memcpy(&lSize, lpMapBuff, sizeof(lSize));
		if (lSize == FDSENDER_START_CODE) break;	// _xZkqqHx_jBjHjAeNiMlDiPiAjEpFiKkOjHlJiBeC_xHqqkZx_
		// 10msec_xZkqqHx_iLhIiMgFiBeC_xHqqkZx_
		Sleep(10L);
	}
	// _xZkqqHx_iLkEjHeMiDiBiDiCiDiKiCmJiPiAjEpFiKkOjHlJiDhNiBfLiDeOiCpAjAnNjCoIiBeC_xHqqkZx_
	memset(lpMapBuff, 0, sizeof(lDataSize));
	// _xZkqqHx_iLkEjHeMiDiBiDiCiDiKiCpAiDhEiDiJiDgCiDfGiDiFiBeC_xHqqkZx_
	FlushViewOfFile(lpMapBuff, 0);
	// _xZkqqHx_jBjHjAeNiMlDiCkKiDgGiBfLiDfOiCpAjBjHjAeNiClHiCoJiCmMiCpAjBnCiCmCiBeC_xHqqkZx_
	if (!WaitForSender(hMutex, lpMapBuff)) goto L_ERR;

	// _xZkqqHx_jBjHjAeNiDgGiBfLiDfOiCmMiDfEiDeDiDfJiOoGjDlOiBeC_xHqqkZx_
	memcpy(&lDataSize, lpMapBuff, sizeof(lDataSize));
	// _xZkqqHx_iLkEjHeMiDiBiDiCiDiKiCmJiOpDjAeNiNmPiCnNiCmMiDhNiBfLiDeOiCpAjAnNjCoIiBeC_xHqqkZx_
	memset(lpMapBuff, 0, sizeof(lDataSize));
	// _xZkqqHx_iLkEjHeMiDiBiDiCiDiKiCpAiDhEiDiJiDgCiDfGiDiFiBeC_xHqqkZx_
	FlushViewOfFile(lpMapBuff, 0);

	// _xZkqqHx_iDgGiBfLiDfOiOpDjAeNiDgPiDgCiDhEiDeAiCmMiKgNjFnLiBeC_xHqqkZx_
	bypData = new BYTE[lDataSize];

	lCount = 0;
	for (;;)
	{
		// _xZkqqHx_jBjHjAeNiMlDiCkKiDgGiBfLiDfOiCpAjBjHjAeNiClHiCoJiCmMiCpAjBnCiCmCiBeC_xHqqkZx_
		if (!WaitForSender(hMutex, lpMapBuff)) goto L_ERR;
		// _xZkqqHx_jBjHjAeNiDgGiBfLiDfOiCmMiDfEiDeDiDfJiOoGjDlOiBeC_xHqqkZx_
		memcpy(&lSize, lpMapBuff, sizeof(lSize));
		// _xZkqqHx_iDgGiBfLiDfOiCpAiDhEiDeAiDeDiDiLiDhNiDgCiDhGiDgPiDgCiDhEiDeAiCkJiCoHiOpDjAeNiDgPiDgCiDhEiDeAiCnGiDfCiDhDiBfLiBeC_xHqqkZx_
		memcpy(bypData + lCount, (BYTE*)lpMapBuff + sizeof(lSize), lSize);
		lCount += lSize;
		// _xZkqqHx_iLkEjHeMiDiBiDiCiDiKiCmJiOpDjAeNiNmPiCnNiCmMiDhNiBfLiDeOiCpAjAnNjCoIiBeC_xHqqkZx_
		memset(lpMapBuff, 0, sizeof(lDataSize));
		// _xZkqqHx_iLkEjHeMiDiBiDiCiDiKiCpAiDhEiDiJiDgCiDfGiDiFiBeC_xHqqkZx_
		FlushViewOfFile(lpMapBuff, 0);
		// _xZkqqHx_jBfDiDgGiBfLiDfOiOpDjAeNiPeJjHlJiCmMiPoKiNiHiBeC_xHqqkZx_
		if (lDataSize <= lCount) break;
	}

	ReleaseMutex(hMutex);		// _xZkqqHx_iDhOiDiFiBfLiDgFiDgCiDeOiDfIiCpAiJpAjFpKiBeC_xHqqkZx_
	CloseHandle(hMutex);		// _xZkqqHx_iDhOiDiFiBfLiDgFiDgCiDeOiDfIiCpAiDeOiDiNiBfLiDfJiBeC_xHqqkZx_
	UnmapViewOfFile(lpMapBuff);	// _xZkqqHx_iClBiClPiCoHiCmM_xHqqkZx_FileMap_xZkqqHx_iCpA_xHqqkZx_Unmap.
	CloseHandle(hFileMap);		// FileMap_xZkqqHx_iCpAiDeOiDiNiBfLiDfJ_xHqqkZx_.
	return TRUE;

L_ERR:
	if (hMutex != NULL)
	{
		ReleaseMutex(hMutex);		// _xZkqqHx_iDhOiDiFiBfLiDgFiDgCiDeOiDfIiCpAiJpAjFpKiBeC_xHqqkZx_
		CloseHandle(hMutex);		// _xZkqqHx_iDhOiDiFiBfLiDgFiDgCiDeOiDfIiCpAiDeOiDiNiBfLiDfJiBeC_xHqqkZx_
	}
	if (lpMapBuff != NULL) UnmapViewOfFile(lpMapBuff);	// _xZkqqHx_iClBiClPiCoHiCmM_xHqqkZx_FileMap_xZkqqHx_iCpA_xHqqkZx_Unmap.
	if (hFileMap != NULL) CloseHandle(hFileMap);		// FileMap_xZkqqHx_iCpAiDeOiDiNiBfLiDfJ_xHqqkZx_.
	return FALSE;
} // ReceiveData.

