diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index e054e77..1a7612e 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -66,16 +66,11 @@ build_windows: - wget 'https://gitlab.com/Mr_Goldberg/goldberg_emulator/uploads/48db8f434a193aae872279dc4f5dde6a/sdk_standalone.7z' - wget 'https://gitlab.com/Mr_Goldberg/goldberg_emulator/uploads/0119304e030098b4821d73170fe52084/protobuf_x64-windows-static.7z' - wget 'https://gitlab.com/Mr_Goldberg/goldberg_emulator/uploads/4185a97ab363ddc1859127e59ec68581/protobuf_x86-windows-static.7z' + # Ancient CI version of wine doesn't support the where.exe cmd. (It's a stub.) Use the version from wine-10.0. + - wget 'https://dl.fedoraproject.org/pub/fedora/linux/updates/41/Everything/x86_64/Packages/w/wine-core-10.0-1.fc41.i686.rpm' - mkdir wine - # Ancient CI version of wine doesn't support the where.exe cmd. (It's a stub.) Use the version from wine-10.1. - # Note: This can use the fedora archive once f40 goes eol (~ 5/28/2025) and wine 10.x gets locked into their archive server. - # (Can't use it before then due to newer wine point releases changing the URL....) - #- wget 'https://archives.fedoraproject.org/pub/archive/fedora/linux/releases/39/Everything/x86_64/os/Packages/w/wine-core-10.0-1.fc41.i686.rpm' - #- echo './usr/lib/wine/i386-windows/where.exe' > extract.txt; rpm2cpio wine-core-10.0-1.fc41.i686.rpm | cpio -ivdE extract.txt; rm -f extract.txt - #- /usr/bin/mv -f ./usr/lib/wine/i386-windows/where.exe wine/; rm -rf ./usr/ - - wget 'https://dl.winehq.org/wine-builds/fedora/41/x86_64/wine-devel-10.0.0-1.1.x86_64.rpm' - - echo './opt/wine-devel/lib64/wine/i386-windows/where.exe' > extract.txt; rpm2cpio wine-devel-10.0.0-1.1.x86_64.rpm | cpio -ivdE extract.txt; rm -f extract.txt - - /usr/bin/mv -f ./opt/wine-devel/lib64/wine/i386-windows/where.exe wine/; rm -rf ./opt/ + - echo './usr/lib/wine/i386-windows/where.exe' > extract.txt; rpm2cpio wine-core-10.0-1.fc41.i686.rpm | cpio -ivdE extract.txt; rm -f extract.txt + - /usr/bin/mv -f ./usr/lib/wine/i386-windows/where.exe wine/; rm -rf ./usr/ - /usr/bin/cp -f wine/where.exe /usr/lib/wine/i386-windows/where.exe; /usr/bin/cp -f wine/where.exe /usr/lib64/wine/x86_64-windows/where.exe - 7za x protobuf_x86-windows-static.7z -oprotobuf_x86-windows-static - 7za x protobuf_x64-windows-static.7z -oprotobuf_x64-windows-static diff --git a/build_win_debug_lobby_connect.bat b/build_win_debug_lobby_connect.bat index 7ad250e..4bb67f1 100644 --- a/build_win_debug_lobby_connect.bat +++ b/build_win_debug_lobby_connect.bat @@ -16,6 +16,7 @@ setlocal "%PROTOC_X86_EXE%" -I.\dll\ --cpp_out=.\dll\ .\dll\net.proto call build_env_x86.bat cd %OLD_DIR%\build\lobby_connect\debug\x86 +cl @%CDS_DIR%\RTLGENRANDOM.BLD cl /c @%CDS_DIR%\DEBUG.BLD @%CDS_DIR%\PROTOBUF_X86.BLD @%CDS_DIR%\LOBBY_CONNECT.BLD IF EXIST %CDS_DIR%\DEBUG_LOBBY_CONNECT_X86.LKS ( DEL /F /Q %CDS_DIR%\DEBUG_LOBBY_CONNECT_X86.LKS ) @@ -32,6 +33,7 @@ setlocal "%PROTOC_X86_EXE%" -I.\dll\ --cpp_out=.\dll\ .\dll\net.proto call build_env_x64.bat cd %OLD_DIR%\build\lobby_connect\debug\x64 +cl @%CDS_DIR%\RTLGENRANDOM.BLD cl /c @%CDS_DIR%\DEBUG.BLD @%CDS_DIR%\PROTOBUF_X64.BLD @%CDS_DIR%\LOBBY_CONNECT.BLD IF EXIST %CDS_DIR%\DEBUG_LOBBY_CONNECT_X64.LKS ( DEL /F /Q %CDS_DIR%\DEBUG_LOBBY_CONNECT_X64.LKS ) diff --git a/build_win_lobby_connect.bat b/build_win_lobby_connect.bat index 09f194b..d3dd8b1 100755 --- a/build_win_lobby_connect.bat +++ b/build_win_lobby_connect.bat @@ -16,6 +16,7 @@ setlocal "%PROTOC_X86_EXE%" -I.\dll\ --cpp_out=.\dll\ .\dll\net.proto call build_env_x86.bat cd %OLD_DIR%\build\lobby_connect\release\x86 +cl @%CDS_DIR%\RTLGENRANDOM.BLD cl /c @%CDS_DIR%\RELEASE.BLD @%CDS_DIR%\PROTOBUF_X86.BLD @%CDS_DIR%\LOBBY_CONNECT.BLD IF EXIST %CDS_DIR%\RELEASE_LOBBY_CONNECT_X86.LKS ( DEL /F /Q %CDS_DIR%\RELEASE_LOBBY_CONNECT_X86.LKS ) @@ -32,6 +33,7 @@ setlocal "%PROTOC_X86_EXE%" -I.\dll\ --cpp_out=.\dll\ .\dll\net.proto call build_env_x64.bat cd %OLD_DIR%\build\lobby_connect\release\x64 +cl @%CDS_DIR%\RTLGENRANDOM.BLD cl /c @%CDS_DIR%\RELEASE.BLD @%CDS_DIR%\PROTOBUF_X64.BLD @%CDS_DIR%\LOBBY_CONNECT.BLD IF EXIST %CDS_DIR%\RELEASE_LOBBY_CONNECT_X64.LKS ( DEL /F /Q %CDS_DIR%\RELEASE_LOBBY_CONNECT_X64.LKS ) diff --git a/build_win_release.bat b/build_win_release.bat index 31e3854..dba8b04 100755 --- a/build_win_release.bat +++ b/build_win_release.bat @@ -18,6 +18,7 @@ setlocal "%PROTOC_X86_EXE%" -I.\dll\ --cpp_out=.\dll\ .\dll\net.proto call build_env_x86.bat cd %OLD_DIR%\build\release\x86 +cl @%CDS_DIR%\RTLGENRANDOM.BLD cl /c @%CDS_DIR%\RELEASE.BLD @%CDS_DIR%\PROTOBUF_X86.BLD @%CDS_DIR%\DLL_MAIN_CPP.BLD IF EXIST %CDS_DIR%\RELEASE_BASE_DLL_X86.LKS ( DEL /F /Q %CDS_DIR%\RELEASE_BASE_DLL_X86.LKS ) @@ -33,6 +34,7 @@ setlocal "%PROTOC_X64_EXE%" -I.\dll\ --cpp_out=.\dll\ .\dll\net.proto call build_env_x64.bat cd %OLD_DIR%\build\release\x64 +cl @%CDS_DIR%\RTLGENRANDOM.BLD cl /c @%CDS_DIR%/RELEASE.BLD @%CDS_DIR%/PROTOBUF_X64.BLD @%CDS_DIR%/DLL_MAIN_CPP.BLD IF EXIST %CDS_DIR%\RELEASE_BASE_DLL_X64.LKS ( DEL /F /Q %CDS_DIR%\RELEASE_BASE_DLL_X64.LKS ) diff --git a/dll/base.cpp b/dll/base.cpp index 3499f2d..dc1effc 100644 --- a/dll/base.cpp +++ b/dll/base.cpp @@ -19,37 +19,14 @@ #ifdef __WINDOWS__ -HMODULE hadvapi32 = NULL; -BOOLEAN (NTAPI *real_RtlGenRandom)(PVOID,ULONG) = NULL; - static void randombytes(char * const buf, const size_t size) { - PRINT_DEBUG("%s %p %" PRI_ZU ".\n", "mine_RtlGenRandom() called.", buf, size); - if (hadvapi32 == NULL) { - hadvapi32 = GetModuleHandleW(L"advapi32.dll"); - if (hadvapi32 == NULL) { - PRINT_DEBUG("%s.\n", "GetModuleHandle() failed for advapi32.dll"); - } - PRINT_DEBUG("advapi32.dll handle: 0x%p.\n", hadvapi32); + while (!RtlGenRandom((PVOID) buf, (ULONG) size)) { + PRINT_DEBUG("RtlGenRandom ERROR\n"); + Sleep(100); } - if (hadvapi32 != NULL && - real_RtlGenRandom == NULL) { - real_RtlGenRandom = (BOOLEAN(NTAPI *)(PVOID,ULONG))GetProcAddress(hadvapi32, "SystemFunction036"); - if (real_RtlGenRandom == NULL) { - PRINT_DEBUG("%s.\n", "GetProcAddress() failed for RtlGenRandom()"); - } - PRINT_DEBUG("real_RtlGenRandom address: 0x%p.\n", real_RtlGenRandom); - } - if (real_RtlGenRandom != NULL) { - PRINT_DEBUG("%s.\n", "Calling real_RtlGenRandom"); - while (!real_RtlGenRandom((PVOID) buf, (ULONG) size)) { - PRINT_DEBUG("RtlGenRandom ERROR\n"); - Sleep(100); - } - PRINT_DEBUG("%s.\n", "real_RtlGenRandom returned"); - } - return; + } std::string get_env_variable(std::string name) diff --git a/dll/common_includes.h b/dll/common_includes.h index a00cc04..f29bef5 100644 --- a/dll/common_includes.h +++ b/dll/common_includes.h @@ -174,7 +174,6 @@ inline void reset_LastError() #include #include #include -#include #include #include diff --git a/dll/rtlgenrandom.c b/dll/rtlgenrandom.c new file mode 100644 index 0000000..e160da4 --- /dev/null +++ b/dll/rtlgenrandom.c @@ -0,0 +1,4 @@ +#include +#define RtlGenRandom SystemFunction036 +#define DLLEXPORT __declspec(dllexport) +DLLEXPORT BOOLEAN WINAPI RtlGenRandom(PVOID in, ULONG len) {} \ No newline at end of file diff --git a/dll/rtlgenrandom.def b/dll/rtlgenrandom.def new file mode 100644 index 0000000..3f23d20 --- /dev/null +++ b/dll/rtlgenrandom.def @@ -0,0 +1,3 @@ +LIBRARY advapi32.dll +EXPORTS +SystemFunction036 \ No newline at end of file diff --git a/dll/settings_parser.cpp b/dll/settings_parser.cpp index 79ceec4..8f8e737 100644 --- a/dll/settings_parser.cpp +++ b/dll/settings_parser.cpp @@ -217,39 +217,9 @@ uint32 create_localstorage_settings(Settings **settings_client_out, Settings **s load_custom_broadcasts(Local_Storage::get_game_settings_path() + "custom_master_server.txt", custom_master_server); // Acount name - char name[32] = { '\0' }; + char name[32] = {}; if (local_storage->get_data_settings("account_name.txt", name, sizeof(name) - 1) <= 0) { - PRINT_DEBUG("%s.\n", "Attempting to set steam user name from system user name"); -#if defined(STEAM_WIN32) - DWORD username_dword = 32; - wchar_t username[32] = { '\0' }; - if (GetUserNameW((wchar_t*)&username, &username_dword) == TRUE) { - std::wstring username_wstr(username); - std::string username_str = utf8_encode(username_wstr); - size_t username_len = username_str.length(); - if (username_len > 0 && - username_len < 31) { - memcpy(&name, username_str.c_str(), username_len); - name[31] = '\0'; - } - } -#else - char * env_username = getenv("USER"); - if (env_username != NULL) { - size_t username_len = strlen(env_username); - if (username_len > 0 && - username_len < 31) { - memcpy(&name, env_username, username_len); - name[31] = '\0'; - } - } -#endif - char empty_name[32] = { '\0' }; - if (memcmp(name, empty_name, 32) == 0) { - PRINT_DEBUG("%s %s.\n", "Setting steam user name to", DEFAULT_NAME); - strcpy(name, DEFAULT_NAME); - } - PRINT_DEBUG("Username: %s.\n", name); + strcpy(name, DEFAULT_NAME); local_storage->store_data_settings("account_name.txt", name, strlen(name)); } diff --git a/dll/steam_user_stats.h b/dll/steam_user_stats.h index 50352a4..ff42133 100644 --- a/dll/steam_user_stats.h +++ b/dll/steam_user_stats.h @@ -139,33 +139,14 @@ int32 achievement_image_data_gray_find(std::string key) { void load_achievements_db() { uint64 count = 0; - uint64 bad_count = 0; - uint64 corrupt_count = 0; - uint64 missing_normal_images = 0; - uint64 missing_gray_images = 0; - uint64 unreadable_normal_images = 0; - uint64 unreadable_gray_images = 0; - std::string name = ""; std::string file_path = Local_Storage::get_game_settings_path() + achievements_user_file; local_storage->load_json(file_path, defined_achievements); for (auto & it : defined_achievements) { - name = ""; try { - auto name_it = it.find("name"); - if (name_it != it.end()) { - name = static_cast(*name_it); - } + std::string name = static_cast(it["name"]); if (name.length() > 0) { - auto normal_it = it.find("icon"); - auto gray_it = it.find("icon_gray"); - std::string normal = ""; - std::string gray = ""; - if (normal_it != it.end()) { - normal = Local_Storage::get_game_settings_path() + static_cast(*normal_it); - } - if (gray_it != it.end()) { - gray = Local_Storage::get_game_settings_path() + static_cast(*gray_it); - } + std::string normal = Local_Storage::get_game_settings_path() + static_cast(it["icon"]); + std::string gray = Local_Storage::get_game_settings_path() + static_cast(it["icongray"]); if (normal.length() > 0 && gray.length() > 0) { uint32 normal_height = 0; uint32 normal_width = 0; @@ -194,56 +175,13 @@ void load_achievements_db() achievement_image_data_normal[name] = settings->add_image(normalStr, normal_width, normal_height); achievement_image_data_gray[name] = settings->add_image(grayStr, gray_width, gray_height); count++; - } else { - corrupt_count++; - if (normal_width <= 0 || normal_height <= 0) - unreadable_normal_images++; - if (gray_width <= 0 || gray_height <= 0) - unreadable_gray_images++; - PRINT_DEBUG("%s %s %s.\n", - "Unable to load images for achievement", - name.c_str(), - "unable to get resolution from images."); } - } else { - corrupt_count++; - if (normal.length() <= 0) - missing_normal_images++; - if (gray.length() <= 0) - missing_gray_images++; - PRINT_DEBUG("%s %s %s.\n", - "Unable to load images for achievement", - name.c_str(), - "an image path is not configured"); } - } else { - bad_count++; - PRINT_DEBUG("%s %s %s %" PRIu64 " %s.\n", - "Invalid achievement json at", - file_path.c_str(), - "for achievement number", - count + corrupt_count + bad_count + 1, - "is invalid"); } - } catch (std::exception &e) { - bad_count++; - PRINT_DEBUG("Loading image data for achievement %s failed. Exception type: %s Reason: %s.\n", - (name.length() > 0) ? name.c_str() : "ERROR: NAME PARSING FROM JSON FAILED", - typeid(e).name(), - e.what()); - } + } catch (...) {} } - PRINT_DEBUG("loaded %" PRIu64 " achievement images.\npartial loaded %" PRIu64 " achievements.\nskipped %" PRIu64 " invalid achievements.\n", - count, - corrupt_count, - bad_count); - PRINT_DEBUG("ignored %" PRIu64 " missing normal achievement images.\nignored %" PRIu64 " missing gray achievement images.\n", - missing_normal_images, - missing_gray_images); - PRINT_DEBUG("ignored %" PRIu64 " unreadable normal achievement images.\nignored %" PRIu64 " unreadable gray achievement images.\n", - unreadable_normal_images, - unreadable_gray_images); + PRINT_DEBUG("loaded %llu achievement images.\n", count); } void load_achievements() diff --git a/generate_all_deps.bat b/generate_all_deps.bat index 974ec06..621808e 100644 --- a/generate_all_deps.bat +++ b/generate_all_deps.bat @@ -15,6 +15,7 @@ setlocal call build_env_x86.bat SET OLD_DIR=%cd% cd "build\all_deps\debug\x86" +cl @%CDS_DIR%/RTLGENRANDOM.BLD cl /c @%CDS_DIR%/DEBUG.BLD @%CDS_DIR%/PROTOBUF_X86.BLD @%CDS_DIR%\ALL_DEPS.BLD IF EXIST %CDS_DIR%\DEBUG_ALL_DEPS_X86.LKS ( DEL /F /Q %CDS_DIR%\DEBUG_ALL_DEPS_X86.LKS ) where "*.obj" > %CDS_DIR%\DEBUG_ALL_DEPS_X86.LKS @@ -26,6 +27,7 @@ setlocal call build_env_x64.bat SET OLD_DIR=%cd% cd "build\all_deps\debug\x64" +cl @%CDS_DIR%/RTLGENRANDOM.BLD cl /c @%CDS_DIR%/DEBUG.BLD @%CDS_DIR%/PROTOBUF_X64.BLD @%CDS_DIR%\ALL_DEPS.BLD IF EXIST %CDS_DIR%\DEBUG_ALL_DEPS_X64.LKS ( DEL /F /Q %CDS_DIR%\DEBUG_ALL_DEPS_X64.LKS ) where "*.obj" > %CDS_DIR%\DEBUG_ALL_DEPS_X64.LKS @@ -37,6 +39,7 @@ setlocal call build_env_x86.bat SET OLD_DIR=%cd% cd "build\all_deps\release\x86" +cl @%CDS_DIR%/RTLGENRANDOM.BLD cl /c @%CDS_DIR%/RELEASE.BLD @%CDS_DIR%/PROTOBUF_X86.BLD @%CDS_DIR%\ALL_DEPS.BLD IF EXIST %CDS_DIR%\RELEASE_ALL_DEPS_X86.LKS ( DEL /F /Q %CDS_DIR%\RELEASE_ALL_DEPS_X86.LKS ) where "*.obj" > %CDS_DIR%\RELEASE_ALL_DEPS_X86.LKS @@ -48,6 +51,7 @@ setlocal call build_env_x64.bat SET OLD_DIR=%cd% cd "build\all_deps\release\x64" +cl @%CDS_DIR%/RTLGENRANDOM.BLD cl /c @%CDS_DIR%/RELEASE.BLD @%CDS_DIR%/PROTOBUF_X64.BLD @%CDS_DIR%\ALL_DEPS.BLD IF EXIST %CDS_DIR%\RELEASE_ALL_DEPS_X64.LKS ( DEL /F /Q %CDS_DIR%\RELEASE_ALL_DEPS_X64.LKS ) where "*.obj" > %CDS_DIR%\RELEASE_ALL_DEPS_X64.LKS diff --git a/generate_build_win.bat b/generate_build_win.bat index 3b7b231..24e3a38 100644 --- a/generate_build_win.bat +++ b/generate_build_win.bat @@ -114,8 +114,8 @@ copy %CDS_DIR%\RELEASE.ARG %CDS_DIR%\RELEASE.BLD type %CDS_DIR%\RELEASE.ARG > %CDS_DIR%\RELEASE.LKS REM DISABLE the PDB builds if we are running on the CI. (It can't build them currently.) -IF EXIST %OLD_DIR%\CI_BUILD.TAG ( echo /link /DEBUG:NONE >> %CDS_DIR%\RELEASE.LKS ) -IF NOT EXIST %OLD_DIR%\CI_BUILD.TAG ( echo /link /DEBUG:FULL /OPT:REF /OPT:ICF >> %CDS_DIR%\RELEASE.LKS ) +IF EXIST %OLD_DIR%\CI_BUILD.TAG ( echo /link /DEBUG:NONE > %CDS_DIR%\RELEASE.LKS ) +IF NOT EXIST %OLD_DIR%\CI_BUILD.TAG ( echo /link /DEBUG:FULL /OPT:REF /OPT:ICF > %CDS_DIR%\RELEASE.LKS ) REM BASE DLL Flags. IF EXIST %CDS_DIR%\DLL_MAIN_CPP.ARG ( DEL /F /S /Q %CDS_DIR%\DLL_MAIN_CPP.ARG ) @@ -182,7 +182,6 @@ echo dbghelp.lib > %CDS_DIR%\DLL_MAIN_CPP.OS echo Iphlpapi.lib >> %CDS_DIR%\DLL_MAIN_CPP.OS echo Ws2_32.lib >> %CDS_DIR%\DLL_MAIN_CPP.OS echo Shell32.lib >> %CDS_DIR%\DLL_MAIN_CPP.OS -echo advapi32.lib >> %CDS_DIR%\DLL_MAIN_CPP.OS REM EXPERIMENTAL. IF EXIST %CDS_DIR%\EXPERIMENTAL.OS ( DEL /F /S /Q %CDS_DIR%\EXPERIMENTAL.OS ) @@ -227,6 +226,11 @@ REM DETOURS. IF EXIST %CDS_DIR%\DETOURS.FLS ( DEL /F /S /Q %CDS_DIR%\DETOURS.FLS ) where "%cd%\detours\:*.cpp" > %CDS_DIR%\DETOURS.FLS +REM rtlgenrandom. +IF EXIST %CDS_DIR%\RTLGENRANDOM.FLS ( DEL /F /S /Q %CDS_DIR%\RTLGENRANDOM.FLS ) +where "%cd%\dll\:rtlgenrandom.c" > %CDS_DIR%\RTLGENRANDOM.FLS +where "%cd%\dll\:rtlgenrandom.def" >> %CDS_DIR%\RTLGENRANDOM.FLS + REM CONTROLLER. IF EXIST %CDS_DIR%\CONTROLLER.FLS ( DEL /F /S /Q CONTROLLER.FLS ) where "%cd%\controller\:gamepad.c" > %CDS_DIR%\CONTROLLER.FLS @@ -278,6 +282,10 @@ type %CDS_DIR%\PROTOBUF_X64.ICD > %CDS_DIR%\PROTOBUF_X64.BLD type %CDS_DIR%\PROTOBUF_X64.BLD > %CDS_DIR%\PROTOBUF_X64.LKS type %CDS_DIR%\PROTOBUF_X64.OS >> %CDS_DIR%\PROTOBUF_X64.LKS +REM rtlgenrandom. +IF EXIST %CDS_DIR%\RTLGENRANDOM.BLD ( DEL /F /S /Q %CDS_DIR%\RTLGENRANDOM.BLD ) +type %CDS_DIR%\RTLGENRANDOM.FLS > %CDS_DIR%\RTLGENRANDOM.BLD + REM SC_DEPS IF EXIST %CDS_DIR%\SC_DEPS.BLD ( DEL /F /S /Q %CDS_DIR%\SC_DEPS.BLD ) type %CDS_DIR%\NORMAL_ARGS.ARG > %CDS_DIR%\SC_DEPS.BLD diff --git a/overlay_experimental/steam_overlay.cpp b/overlay_experimental/steam_overlay.cpp index 75b59c9..004b096 100644 --- a/overlay_experimental/steam_overlay.cpp +++ b/overlay_experimental/steam_overlay.cpp @@ -2062,9 +2062,6 @@ int Steam_Overlay::display_imgui_image(uint32_t displayImageType, } } } - if (ret != 1) { - ImGui::Dummy(image_size); - } break; case displayImageTypeAvatar: // User Avatars