mirror of
https://github.com/spice2x/spice2x.github.io.git
synced 2026-11-29 10:48:56 -08:00
Compare commits
2
Commits
3e3db7a411
...
8c864f69b5
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8c864f69b5 | ||
|
|
5bb526c4ba |
No files matched your search
@@ -1,4 +1,7 @@
|
||||
on: [push, pull_request]
|
||||
on:
|
||||
push:
|
||||
pull_request:
|
||||
workflow_dispatch:
|
||||
name: Continuous Integration
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.ref }}
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include "hooks/devicehook.h"
|
||||
#include "hooks/libraryhook.h"
|
||||
#ifdef SPICE64
|
||||
#include <psapi.h>
|
||||
#include "hooks/graphics/nvapi_impl.h"
|
||||
#endif
|
||||
#include "hooks/graphics/nvapi_hook.h"
|
||||
@@ -40,6 +41,9 @@ static decltype(RegEnumKeyA) *RegEnumKeyA_orig = nullptr;
|
||||
static decltype(RegOpenKeyA) *RegOpenKeyA_orig = nullptr;
|
||||
static decltype(RegOpenKeyExA) *RegOpenKeyExA_orig = nullptr;
|
||||
static decltype(RegQueryValueExA) *RegQueryValueExA_orig = nullptr;
|
||||
#ifdef SPICE64
|
||||
static decltype(K32GetPerformanceInfo) *K32GetPerformanceInfo_orig = nullptr;
|
||||
#endif
|
||||
|
||||
namespace games::sdvx {
|
||||
|
||||
@@ -200,6 +204,29 @@ namespace games::sdvx {
|
||||
}
|
||||
|
||||
#ifdef SPICE64
|
||||
|
||||
static BOOL WINAPI K32GetPerformanceInfo_hook(PPERFORMANCE_INFORMATION info, DWORD cb) {
|
||||
if (info == nullptr) {
|
||||
SetLastError(ERROR_INVALID_PARAMETER);
|
||||
return FALSE;
|
||||
}
|
||||
if (cb < sizeof(*info)) {
|
||||
SetLastError(ERROR_BAD_LENGTH);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// store a cached copy of the first successful call to K32GetPerformanceInfo
|
||||
static PERFORMANCE_INFORMATION cached {};
|
||||
static const BOOL cached_valid = K32GetPerformanceInfo_orig(&cached, sizeof(cached));
|
||||
if (!cached_valid) {
|
||||
return K32GetPerformanceInfo_orig(info, cb);
|
||||
}
|
||||
|
||||
// return the cached copy to avoid performance issues with the game calling this every frame
|
||||
*info = cached;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static bool sdvx64_spam_remover(void *user, const std::string &data, logger::Style style, std::string &out) {
|
||||
if (data.empty() || data[0] != '[') {
|
||||
return false;
|
||||
@@ -534,6 +561,14 @@ namespace games::sdvx {
|
||||
if (is_valkyrie_model()) {
|
||||
sysutils::hook_EnumDisplayDevicesA();
|
||||
}
|
||||
|
||||
// keep one real snapshot for the session instead of querying statistics every frame
|
||||
K32GetPerformanceInfo_orig = detour::iat_try(
|
||||
"K32GetPerformanceInfo", K32GetPerformanceInfo_hook, avs::game::DLL_INSTANCE);
|
||||
if (K32GetPerformanceInfo_orig != nullptr) {
|
||||
log_info("sdvx", "installed cached hook for K32GetPerformanceInfo");
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user