Fix #281: Check if CPU has SSE2 to avoid client crash

This commit is contained in:
yuanyuanxiang
2026-01-12 22:54:15 +01:00
parent 2c15b842ca
commit e5872dc0b8
7 changed files with 29 additions and 7 deletions

View File

@@ -17,6 +17,15 @@
#include "X264Encoder.h"
#include "common/file_upload.h"
inline bool HasSSE2() {
#ifdef _DEBUG
return false;
#else
auto static has = IsProcessorFeaturePresent(PF_XMMI64_INSTRUCTIONS_AVAILABLE);
return has;
#endif
}
class ThreadPool
{
public:
@@ -304,7 +313,7 @@ public:
virtual ULONG CompareBitmap(LPBYTE CompareSourData, LPBYTE CompareDestData, LPBYTE szBuffer,
DWORD ulCompareLength, BYTE algo, int startPostion = 0)
{
if (UsingDXGI())
if (UsingDXGI() || !HasSSE2())
return CompareBitmapDXGI(CompareSourData, CompareDestData, szBuffer, ulCompareLength, algo, startPostion);
LPBYTE p = szBuffer;

View File

@@ -110,7 +110,7 @@ public:
// 9. 初始化 BITMAPINFO
m_BitmapInfor_Full = ConstructBitmapInfo(32, m_ulFullWidth, m_ulFullHeight);
iniFile cfg(CLIENT_PATH);
int strategy = cfg.GetInt("settings", "ScreenStrategy", 0);
int strategy = HasSSE2() ? cfg.GetInt("settings", "ScreenStrategy", 0) : 1;
switch (strategy) {
case 1:
break;

View File

@@ -332,6 +332,11 @@ BOOL IsRunningAsSystem()
BOOL CScreenManager::OnReconnect()
{
auto duration = GetTickCount64() - m_nReconnectTime;
if (duration <= 3000)
Sleep(3000 - duration);
m_nReconnectTime = GetTickCount64();
m_SendFirst = FALSE;
BOOL r = m_ClientObject ? m_ClientObject->Reconnect(this) : FALSE;
Mprintf("CScreenManager OnReconnect '%s'\n", r ? "succeed" : "failed");

View File

@@ -75,6 +75,7 @@ public:
bool SwitchScreen();
bool RestartScreen();
virtual BOOL OnReconnect();
uint64_t m_nReconnectTime = 0; // 重连开始时间
uint64_t m_DlgID = 0;
BOOL m_SendFirst = FALSE;

View File

@@ -20,7 +20,7 @@ CScreenSpy::CScreenSpy(ULONG ulbiBitCount, BYTE algo, BOOL vDesk, int gop, BOOL
m_BitmapInfor_Full = ConstructBitmapInfo(ulbiBitCount, m_ulFullWidth, m_ulFullHeight);
iniFile cfg(CLIENT_PATH);
int strategy = cfg.GetInt("settings", "ScreenStrategy", 0);
int strategy = HasSSE2() ? cfg.GetInt("settings", "ScreenStrategy", 0) : 1;
m_BitmapInfor_Send = new BITMAPINFO(*m_BitmapInfor_Full);
switch (strategy) {
case 1: // 1 - Original size