I use the IPC function to communicate between two processes.
Some string messages through the IPC callback function of madCodeHook are modified.
For example,
the string content of the sender's message:
"http://ko.wikipedia.org/wiki/%EC%B9%B4% ... C%EC%84%B1"
is modified through IPC communication. So the receiver get the modified the below message:
"http://ko.wikipedia.org/wiki/1.618954E- ... 3E+061C%B1"
%EC%B9%B4%EB%93
==> 1.618954E-319CB9B49.881313E-323B
Other string contents are not modified.
My code is as below:
1.receiver's code:
Code: Select all
static void WINAPI IPCRequestCallback(LPCSTR pIpc,
PVOID pMessageBuf,
DWORD dwMessageLen,
PVOID pAnswerBuf,
DWORD dwAnswerLen)
{
if(!pMessageBuf || dwMessageLen == 0)
{
sprintf((CHAR*)pAnswerBuf, "IPCRequestCallback message empty.");
return;
}
else
{
CString strCommand;
strCommand.SetString((TCHAR*)pMessageBuf, dwMessageLen);
CString strResult;
ProcessCommand(strCommand, strResult);
if(strResult.GetLength() > dwAnswerLen)
strResult = strResult.Left(dwAnswerLen);
if(pAnswerBuf && dwAnswerLen > 0)
sprintf((TCHAR*)pAnswerBuf, strResult);
}
}
2. sender's code
Code: Select all
BOOL CMailManager::SendMessageToScanWorker(CString strScanWorkerId, LPTSTR szCommand, UINT nCommandLength, LPTSTR szResponseBuffer, UINT nResponseBufferLength, UINT nTimeout)
{
//theApp.m_EventLog.FileLogWrite(90, _T("%s begin - scan workerid: %s, command: %s"), __TFUNCTION__, strScanWorkerId, szCommand);
//CHNIXLock lock(m_csCommToScanWorker);
BOOL bResult = SendIpcMessage(strScanWorkerId,
szCommand, nCommandLength,
szResponseBuffer, nResponseBufferLength,
nTimeout, TRUE
);
//theApp.m_EventLog.FileLogWrite(90, _T("%s end - result: %s, response: %s"), __TFUNCTION__, (bResult) ? _T("TRUE") : _T("FALSE"), szResponseBuffer);
return bResult;
}
Thanks in advance.