Tightened the compatibility mode check

This commit is contained in:
NovaRain
2025-01-26 11:31:01 +08:00
parent 0604112a2e
commit d07d27fcec
5 changed files with 20 additions and 12 deletions
+2 -2
View File
@@ -124,7 +124,7 @@ DWORD __stdcall KeyDown(DWORD key) {
// combined use of DINPUT states + confirmation from GetAsyncKeyState()
if (key < MAX_KEYS) {
if (keysDown[key]) { // confirm pressed state
DWORD keyVK = MapVirtualKeyEx(key, MAPVK_VSC_TO_VK, keyboardLayout);
DWORD keyVK = MapVirtualKeyExA(key, MAPVK_VSC_TO_VK, keyboardLayout);
if (keyVK) keysDown[key] = (GetAsyncKeyState(keyVK) & 0x8000);
}
return (keysDown[key] > 0);
@@ -306,7 +306,7 @@ public:
DWORD oldState = keysDown[dxKey];
keysDown[dxKey] = state;
HookCommon::KeyPressHook(&dxKey, (state > 0), MapVirtualKeyEx(dxKey, MAPVK_VSC_TO_VK, keyboardLayout));
HookCommon::KeyPressHook(&dxKey, (state > 0), MapVirtualKeyExA(dxKey, MAPVK_VSC_TO_VK, keyboardLayout));
if ((signed)dxKey > 0 && dxKey != buf[i].dwOfs) {
keysDown[buf[i].dwOfs] = oldState;
+1 -1
View File
@@ -203,7 +203,7 @@ noFile:
static void FallbackEnglishCredits() {
const char* lang;
if (fo::func::get_game_config_string(&lang, "system", "language") && stricmp(lang, "english") != 0) {
if (fo::func::get_game_config_string(&lang, "system", "language") && _stricmp(lang, "english") != 0) {
HookCall(0x42C900, CreditsFileHook);
}
}
+2 -2
View File
@@ -1055,7 +1055,7 @@ static void PerkAndTraitSetup() {
char *stat, *mod;
stat = strtok(buf, "|");
mod = strtok(0, "|");
while (stat&&mod) {
while (stat && mod) {
int _stat = atoi(stat), _mod = atoi(mod);
if (_stat >= 0 && _stat <= fo::STAT_max_derived) traitStatBonuses[_stat * fo::Trait::TRAIT_count + i] = _mod;
stat = strtok(0, "|");
@@ -1067,7 +1067,7 @@ static void PerkAndTraitSetup() {
char *stat, *mod;
stat = strtok(buf, "|");
mod = strtok(0, "|");
while (stat&&mod) {
while (stat && mod) {
int _stat = atoi(stat), _mod = atoi(mod);
if (_stat >= 0 && _stat < 18) traitSkillBonuses[_stat * fo::Trait::TRAIT_count + i] = _mod;
stat = strtok(0, "|");
+1 -1
View File
@@ -167,7 +167,7 @@ static void CreateSndWnd() {
wcx.hInstance = GetModuleHandleA(0);
wcx.lpszClassName = "sfallSndWnd";
RegisterClassEx(&wcx);
RegisterClassExA(&wcx);
soundwindow = CreateWindowA("sfallSndWnd", "SndWnd", 0, 0, 0, 0, 0, HWND_MESSAGE, 0, wcx.hInstance, 0);
dlogr(" Done", DL_INIT);
}
+14 -6
View File
@@ -182,18 +182,26 @@ static void InitModules() {
static void CompatModeCheck(HKEY root, const char* filepath, int extra) {
HKEY key;
char buf[MAX_PATH];
char buf[MAX_PATH] = {0};
DWORD size = MAX_PATH;
DWORD type;
if (!(type = RegOpenKeyEx(root, "Software\\Microsoft\\Windows NT\\CurrentVersion\\AppCompatFlags\\Layers", 0, extra | STANDARD_RIGHTS_READ | KEY_QUERY_VALUE, &key))) {
if (!RegQueryValueEx(key, filepath, 0, &type, (BYTE*)buf, &size)) {
if (!RegOpenKeyExA(root, "Software\\Microsoft\\Windows NT\\CurrentVersion\\AppCompatFlags\\Layers", 0, extra | STANDARD_RIGHTS_READ | KEY_QUERY_VALUE, &key)) {
if (!RegQueryValueExA(key, filepath, 0, &type, (BYTE*)buf, &size)) {
if (size >= MAX_PATH) {
size = MAX_PATH - 1; // prevent overflow
}
buf[size] = '\0'; // null-terminate the buffer
if (size && (type == REG_EXPAND_SZ || type == REG_MULTI_SZ || type == REG_SZ)) {
if (strstr(buf, "256COLOR") || strstr(buf, "640X480") || strstr(buf, "WIN")) {
char* pos = strstr(buf, "DISABLEDXMAXIMIZEDWINDOWEDMODE"); // "Disable fullscreen optimizations" in Win10
if (pos) std::memmove(pos, pos + 30, strlen(pos + 30) + 1); // remove the substring
if (strstr(buf, "256COLOR") || strstr(buf, "640X480") || strstr(buf, "WIN") || strstr(buf, "NT4") || strstr(buf, "VISTA")) {
RegCloseKey(key);
MessageBoxA(0, "Fallout appears to be running in compatibility mode.\n" //, and sfall was not able to disable it.\n"
"Please check the compatibility tab of fallout2.exe, and ensure that the following settings are unchecked:\n"
"Run this program in compatibility mode for..., run in 256 colours, and run in 640x480 resolution.\n"
"Run this program in compatibility mode for..., run in 256 colors, and run in 640x480 resolution.\n"
"If these options are disabled, click the 'change settings for all users' button and see if that enables them.", 0, MB_TASKMODAL | MB_ICONERROR);
ExitProcess(-1);
@@ -240,7 +248,7 @@ static HMODULE SfallInit() {
if (IniReader::GetIntDefaultConfig("Debugging", "SkipCompatModeCheck", 0) == 0) {
int is64bit;
typedef int (__stdcall *chk64bitproc)(HANDLE, int*);
HMODULE h = LoadLibrary("Kernel32.dll");
HMODULE h = LoadLibraryA("Kernel32.dll");
chk64bitproc proc = (chk64bitproc)GetProcAddress(h, "IsWow64Process");
if (proc)
proc(GetCurrentProcess(), &is64bit);