void PipeIODevice::writeMessage(const char* buffer, std::size_t count) { DWORD timeout = _timeout == EventLoop::WaitInfinite ? INFINITE : static_cast<std::size_t>(_timeout); if( FALSE == WriteMsgQueue(handle(), (LPVOID) buffer, count, timeout, 0) ) throw IOError("WriteMsgQueue failed"); }
std::size_t PipeIODevice::onEndWrite(EventLoop& loop, const char* buffer, std::size_t n) { loop.selector().disable(_ioh); DWORD bytesToWrite = std::min<DWORD>(_wbuflen, _msgSize); if ( FALSE == WriteMsgQueue(handle(), (LPVOID) _wbuf, bytesToWrite, 0, 0)) { throw IOError( PT_ERROR_MSG("WriteMsgQueue failed") ); } return bytesToWrite; }
static void workDirtyRect(RECT rect) { if (g_bDirtyRect) { IMAGERECT imgRect = {NULL, &rect}; // NULL(GPE BUFFER), rect(DIRTY RECT) EnterCriticalSection(&g_CS); S1d13521DrvEscape(DRVESC_IMAGE_UPDATE, sizeof(IMAGERECT), (PVOID)&imgRect, 0, NULL); LeaveCriticalSection(&g_CS); } if (g_bDirtyRectNotify) { DIRTYRECTINFO dri = {0,}; DWORD dwFlags = 0; // MSGQUEUE_MSGALERT; memcpy(&dri.rect, &rect, sizeof(rect)); dri.time = GetTickCount(); if (FALSE == WriteMsgQueue(g_hMQ, (LPVOID)&dri, sizeof(dri), 0, dwFlags)) { DWORD dwError = GetLastError(); MYERR((_T("[S1D13521_ERR] WriteMsgQueue() == %d, "), dwError)); switch (dwError) { case ERROR_OUTOFMEMORY: MYERR((_T("ERROR_OUTOFMEMORY\r\n"))); break; case ERROR_INSUFFICIENT_BUFFER: MYERR((_T("ERROR_INSUFFICIENT_BUFFER\r\n"))); break; case ERROR_PIPE_NOT_CONNECTED: MYERR((_T("ERROR_PIPE_NOT_CONNECTED. Notify Stop.\r\n"))); g_bDirtyRectNotify = FALSE; break; case ERROR_TIMEOUT: MYERR((_T("ERROR_TIMEOUT\r\n"))); break; default: MYERR((_T("ERROR_UNKNOWN ???\r\n"))); break; } } } if (g_dwDebugLevel) { RETAILMSG((DRVESC_SET_DIRTYRECT==g_dwDebugLevel || DRVESC_GET_DIRTYRECT==g_dwDebugLevel), (_T("%d workDirtyRect(%d, %d, %d, %d)\r\n"), g_bDirtyRect, rect.left, rect.top, rect.right, rect.bottom)); } }
std::size_t PipeIODevice::onWrite(const char* buffer, std::size_t count) { if( Write != _mode ) throw IOError( PT_ERROR_MSG("Could not write on a read only pipe") ); DWORD timeout = _timeout == EventLoop::WaitInfinite ? INFINITE : static_cast<std::size_t>(_timeout); DWORD bytesToWrite = std::min<DWORD>(count, _msgSize); if ( FALSE == WriteMsgQueue(handle(), (LPVOID) buffer, bytesToWrite, timeout, 0)) { throw IOError("WriteMsgQueue failed"); } return bytesToWrite; }