This commit is contained in:
爱编程的叶一笑 2024-04-27 13:09:38 -04:00 committed by GitHub
commit 693db14c32
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 127 additions and 3 deletions

View File

@ -416,7 +416,18 @@ _FX BOOLEAN Gui_Init(HMODULE module)
GUI_IMPORT___(ClipCursor);
GUI_IMPORT___(GetClipCursor);
GUI_IMPORT___(GetCursorPos);
GUI_IMPORT___(SetCursorPos);
GUI_IMPORT___(SetCursorPos);
GUI_IMPORT___(SetTimer);
HMODULE temp = module;
module = Dll_Kernel32;
GUI_IMPORT___(Sleep);
GUI_IMPORT___(SleepEx);
GUI_IMPORT___(GetTickCount);
GUI_IMPORT___(GetTickCount64);
GUI_IMPORT___(QueryUnbiasedInterruptTime);
GUI_IMPORT___(QueryPerformanceCounter);
module = temp;
GUI_IMPORT___(MsgWaitForMultipleObjects);
GUI_IMPORT_AW(PeekMessage);

View File

@ -100,6 +100,29 @@ typedef void (*P_SwitchToThisWindow)(HWND hWnd, BOOL fAlt);
typedef HWND(*P_SetActiveWindow)(HWND hWnd);
typedef DWORD(*P_GetTickCount)();
typedef ULONGLONG (*P_GetTickCount64)();
typedef BOOL(*P_QueryUnbiasedInterruptTime)(
PULONGLONG UnbiasedTime
);
typedef void(*P_Sleep)(DWORD dwMiSecond);
typedef DWORD(*P_SleepEx)(DWORD dwMiSecond, BOOL bAlert);
typedef BOOL (*P_QueryPerformanceCounter)(
LARGE_INTEGER* lpPerformanceCount
);
typedef UINT_PTR (*P_SetTimer)(
HWND hWnd,
UINT_PTR nIDEvent,
UINT uElapse,
TIMERPROC lpTimerFunc
);
typedef BOOL (*P_GetCursorPos)(LPPOINT lpPoint);
typedef BOOL (*P_SetCursorPos)(int x, int y);
@ -618,6 +641,14 @@ GUI_SYS_VAR_2(PostMessage)
GUI_SYS_VAR_2(PostThreadMessage)
GUI_SYS_VAR_2(DispatchMessage)
GUI_SYS_VAR(Sleep)
GUI_SYS_VAR(SleepEx)
GUI_SYS_VAR(GetTickCount)
GUI_SYS_VAR(QueryUnbiasedInterruptTime)
GUI_SYS_VAR(GetTickCount64)
GUI_SYS_VAR(QueryPerformanceCounter)
GUI_SYS_VAR(SetTimer)
GUI_SYS_VAR(MapWindowPoints)
GUI_SYS_VAR(ClientToScreen)
GUI_SYS_VAR(ScreenToClient)

View File

@ -121,6 +121,27 @@ static BOOL Gui_ShutdownBlockReasonCreate(HWND hWnd, LPCWSTR pwszReason);
static EXECUTION_STATE Gui_SetThreadExecutionState(EXECUTION_STATE esFlags);
static DWORD Gui_GetTickCount();
static ULONGLONG Gui_GetTickCount64();
static BOOL Gui_QueryUnbiasedInterruptTime(
PULONGLONG UnbiasedTime
);
static void Gui_Sleep(DWORD dwMiSecond);
static DWORD Gui_SleepEx(DWORD dwMiSecond, BOOL bAlert);
static BOOL Gui_QueryPerformanceCounter(
LARGE_INTEGER* lpPerformanceCount
);
static UINT_PTR Gui_SetTimer(
HWND hWnd,
UINT_PTR nIDEvent,
UINT uElapse,
TIMERPROC lpTimerFunc
);
//---------------------------------------------------------------------------
@ -286,7 +307,7 @@ _FX BOOLEAN Gui_InitMisc(HMODULE module)
__sys_GetThreadDpiAwarenessContext = (P_GetThreadDpiAwarenessContext)
Ldr_GetProcAddrNew(DllName_user32, L"GetThreadDpiAwarenessContext","GetThreadDpiAwarenessContext");
HMODULE current = module;
if (SbieApi_QueryConfBool(NULL, L"BlockInterferePower", FALSE)) {
SBIEDLL_HOOK_GUI(ShutdownBlockReasonCreate);
@ -295,7 +316,26 @@ _FX BOOLEAN Gui_InitMisc(HMODULE module)
SBIEDLL_HOOK(Gui_, SetThreadExecutionState);
}
if (SbieApi_QueryConfBool(NULL, L"UseChangeSpeed", FALSE))
{
module = current;
P_SetTimer SetTimer = Ldr_GetProcAddrNew(DllName_user32, "SetTimer", "SetTimer");
if (SetTimer)
SBIEDLL_HOOK(Gui_, SetTimer);
module = Dll_Kernel32;
SBIEDLL_HOOK(Gui_, GetTickCount);
P_GetTickCount64 GetTickCount64 = Ldr_GetProcAddrNew(Dll_Kernel32, "GetTickCount64", "GetTickCount64");
if (GetTickCount64)
SBIEDLL_HOOK(Gui_, GetTickCount64);
P_QueryUnbiasedInterruptTime QueryUnbiasedInterruptTime = Ldr_GetProcAddrNew(Dll_Kernel32, "QueryUnbiasedInterruptTime", "QueryUnbiasedInterruptTime");
if (QueryUnbiasedInterruptTime)
SBIEDLL_HOOK(Gui_, QueryUnbiasedInterruptTime);
SBIEDLL_HOOK(Gui_, QueryPerformanceCounter);
SBIEDLL_HOOK(Gui_, Sleep);
SBIEDLL_HOOK(Gui_, SleepEx);
}
return TRUE;
}
@ -1699,3 +1739,45 @@ _FX void Gui_SwitchToThisWindow(HWND hWnd, BOOL fAlt)
return;
__sys_SwitchToThisWindow(hWnd, fAlt);
}
_FX DWORD Gui_GetTickCount() {
return __sys_GetTickCount() * SbieApi_QueryConfNumber(NULL, L"AddTickSpeed", 1) / SbieApi_QueryConfNumber(NULL,L"LowTickSpeed", 1);
}
_FX ULONGLONG Gui_GetTickCount64() {
return __sys_GetTickCount64() * SbieApi_QueryConfNumber(NULL, L"AddTickSpeed", 1) / SbieApi_QueryConfNumber(NULL, L"LowTickSpeed", 1);
}
_FX BOOL Gui_QueryUnbiasedInterruptTime(
PULONGLONG UnbiasedTime
) {
BOOL rtn = __sys_QueryUnbiasedInterruptTime(UnbiasedTime);
*UnbiasedTime *= SbieApi_QueryConfNumber(NULL, L"AddTickSpeed", 1) / SbieApi_QueryConfNumber(NULL, L"LowTickSpeed", 1);
return rtn;
}
_FX void Gui_Sleep(DWORD dwMiSecond) {
__sys_Sleep(dwMiSecond * SbieApi_QueryConfNumber(NULL, L"AddSleepSpeed", 1) / SbieApi_QueryConfNumber(NULL, L"LowSleepSpeed", 1));
}
_FX DWORD Gui_SleepEx(DWORD dwMiSecond, BOOL bAlert) {
return __sys_SleepEx(dwMiSecond * SbieApi_QueryConfNumber(NULL, L"AddSleepSpeed", 1) / SbieApi_QueryConfNumber(NULL, L"LowSleepSpeed", 1),bAlert);
}
_FX BOOL Gui_QueryPerformanceCounter(
LARGE_INTEGER* lpPerformanceCount
) {
BOOL rtn = __sys_QueryPerformanceCounter(lpPerformanceCount);
lpPerformanceCount->QuadPart = lpPerformanceCount->QuadPart*SbieApi_QueryConfNumber(NULL, L"AddTickSpeed", 1)/ SbieApi_QueryConfNumber(NULL, L"LowTickSpeed", 1);
return rtn;
}
_FX UINT_PTR Gui_SetTimer(
HWND hWnd,
UINT_PTR nIDEvent,
UINT uElapse,
TIMERPROC lpTimerFunc
)
{
return __sys_SetTimer(hWnd, nIDEvent, uElapse * SbieApi_QueryConfNumber(NULL, L"AddTimerSpeed", 1) / SbieApi_QueryConfNumber(NULL, L"LowTimerSpeed", 1), lpTimerFunc);
}