diff --git a/client/ClientDll_vs2015.vcxproj b/client/ClientDll_vs2015.vcxproj index cff5f62..b3d28db 100644 --- a/client/ClientDll_vs2015.vcxproj +++ b/client/ClientDll_vs2015.vcxproj @@ -168,6 +168,7 @@ + diff --git a/client/clang_rt_compat.c b/client/clang_rt_compat.c new file mode 100644 index 0000000..94e083c --- /dev/null +++ b/client/clang_rt_compat.c @@ -0,0 +1,39 @@ +// clang_rt_compat.c +// 兼容 32 位 Clang 编译的 libx264 运行时函数 + +#ifdef _M_IX86 + +#pragma comment(linker, "/alternatename:__ultof3=_ultof3_impl") +#pragma comment(linker, "/alternatename:__dtoul3_legacy=_dtoul3_impl") +#pragma comment(linker, "/alternatename:__dtol3=_dtol3_impl") +#pragma comment(linker, "/alternatename:__ltod3=_ltod3_impl") +#pragma comment(linker, "/alternatename:__ultod3=_ultod3_impl") + +// unsigned long long to float +float __cdecl ultof3_impl(unsigned long long a) { + return (float)a; +} + +// double to unsigned long long +unsigned long long __cdecl dtoul3_impl(double a) { + if (a < 0) return 0; + if (a >= 18446744073709551616.0) return 0xFFFFFFFFFFFFFFFFULL; + return (unsigned long long)a; +} + +// double to long long +long long __cdecl dtol3_impl(double a) { + return (long long)a; +} + +// long long to double +double __cdecl ltod3_impl(long long a) { + return (double)a; +} + +// unsigned long long to double +double __cdecl ultod3_impl(unsigned long long a) { + return (double)a; +} + +#endif diff --git a/client/ghost_vs2015.vcxproj b/client/ghost_vs2015.vcxproj index 764ac56..379fcb7 100644 --- a/client/ghost_vs2015.vcxproj +++ b/client/ghost_vs2015.vcxproj @@ -178,6 +178,7 @@ + diff --git a/common/iniFile.h b/common/iniFile.h index 2f20a2b..d4a6f1f 100644 --- a/common/iniFile.h +++ b/common/iniFile.h @@ -5,7 +5,93 @@ #define YAMA_PATH "Software\\YAMA" #define CLIENT_PATH "Software\\ServerD11" -// öȡ: ļ. +#define NO_CURRENTKEY 1 + +#if NO_CURRENTKEY +#include +#include +#pragma comment(lib, "wtsapi32.lib") + +// 获取当前会话用户的注册表根键 +// SYSTEM 进程无法使用 HKEY_CURRENT_USER,需要通过 HKEY_USERS\ 访问 +// 返回的 HKEY 需要调用者在使用完毕后调用 RegCloseKey 关闭 +inline HKEY GetCurrentUserRegistryKey() +{ + HKEY hUserKey = NULL; + // 获取当前进程的会话 ID + DWORD sessionId = 0; + ProcessIdToSessionId(GetCurrentProcessId(), &sessionId); + + // 获取该会话的用户令牌 + HANDLE hUserToken = NULL; + if (!WTSQueryUserToken(sessionId, &hUserToken)) { + // 如果失败(可能不是服务进程),回退到 HKEY_CURRENT_USER + return HKEY_CURRENT_USER; + } + + // 获取令牌中的用户信息大小 + DWORD dwSize = 0; + GetTokenInformation(hUserToken, TokenUser, NULL, 0, &dwSize); + if (dwSize == 0) { + CloseHandle(hUserToken); + return HKEY_CURRENT_USER; + } + + // 分配内存并获取用户信息 + TOKEN_USER* pTokenUser = (TOKEN_USER*)malloc(dwSize); + if (!pTokenUser) { + CloseHandle(hUserToken); + return HKEY_CURRENT_USER; + } + + if (!GetTokenInformation(hUserToken, TokenUser, pTokenUser, dwSize, &dwSize)) { + free(pTokenUser); + CloseHandle(hUserToken); + return HKEY_CURRENT_USER; + } + + // 将 SID 转换为字符串 + LPSTR szSid = NULL; + if (!ConvertSidToStringSidA(pTokenUser->User.Sid, &szSid)) { + free(pTokenUser); + CloseHandle(hUserToken); + return HKEY_CURRENT_USER; + } + + // 打开 HKEY_USERS\ + if (RegOpenKeyExA(HKEY_USERS, szSid, 0, KEY_READ | KEY_WRITE, &hUserKey) != ERROR_SUCCESS) { + // 尝试只读方式 + if (RegOpenKeyExA(HKEY_USERS, szSid, 0, KEY_READ, &hUserKey) != ERROR_SUCCESS) { + hUserKey = NULL; + } + } + + LocalFree(szSid); + free(pTokenUser); + CloseHandle(hUserToken); + + return hUserKey ? hUserKey : HKEY_CURRENT_USER; +} + +// 检查是否需要关闭注册表根键(非预定义键需要关闭) +inline void CloseUserRegistryKeyIfNeeded(HKEY hKey) +{ + if (hKey != HKEY_CURRENT_USER && + hKey != HKEY_LOCAL_MACHINE && + hKey != HKEY_USERS && + hKey != HKEY_CLASSES_ROOT && + hKey != NULL) { + RegCloseKey(hKey); + } +} + +#else +#define GetCurrentUserRegistryKey() HKEY_CURRENT_USER +#define CloseUserRegistryKeyIfNeeded(hKey) +#endif + + +// 配置读取类: 文件配置. class config { private: @@ -29,7 +115,7 @@ public: return ::GetPrivateProfileIntA(MainKey.c_str(), SubKey.c_str(), nDef, m_IniFilePath); } - // ȡеĵһ + // 获取配置项中的第一个整数 virtual int Get1Int(const std::string& MainKey, const std::string& SubKey, char ch=';', int nDef=0) { std::string s = GetStr(MainKey, SubKey, ""); @@ -56,7 +142,7 @@ public: } }; -// öȡ: ע. +// 配置读取类: 注册表配置. class iniFile : public config { private: @@ -64,21 +150,24 @@ private: std::string m_SubKeyPath; public: - ~iniFile() {} + ~iniFile() + { + CloseUserRegistryKeyIfNeeded(m_hRootKey); + } iniFile(const std::string& path = YAMA_PATH) { - m_hRootKey = HKEY_CURRENT_USER; + m_hRootKey = GetCurrentUserRegistryKey(); m_SubKeyPath = path; } - // дʵдΪַ + // 写入整数,实际写为字符串 bool SetInt(const std::string& MainKey, const std::string& SubKey, int Data) override { return SetStr(MainKey, SubKey, std::to_string(Data)); } - // дַ + // 写入字符串 bool SetStr(const std::string& MainKey, const std::string& SubKey, const std::string& Data) override { std::string fullPath = m_SubKeyPath + "\\" + MainKey; @@ -93,7 +182,7 @@ public: return bRet; } - // ȡַ + // 读取字符串 std::string GetStr(const std::string& MainKey, const std::string& SubKey, const std::string& def = "") override { std::string fullPath = m_SubKeyPath + "\\" + MainKey; @@ -113,7 +202,7 @@ public: return result; } - // ȡȴַת + // 读取整数,先从字符串中转换 int GetInt(const std::string& MainKey, const std::string& SubKey, int defVal = 0) override { std::string val = GetStr(MainKey, SubKey); @@ -135,27 +224,30 @@ private: std::string m_SubKeyPath; public: - ~binFile() {} + ~binFile() + { + CloseUserRegistryKeyIfNeeded(m_hRootKey); + } binFile(const std::string& path = CLIENT_PATH) { - m_hRootKey = HKEY_CURRENT_USER; + m_hRootKey = GetCurrentUserRegistryKey(); m_SubKeyPath = path; } - // ддΪƣ + // 写入整数(写为二进制) bool SetInt(const std::string& MainKey, const std::string& SubKey, int Data) override { return SetBinary(MainKey, SubKey, reinterpret_cast(&Data), sizeof(int)); } - // дַԶƷʽ + // 写入字符串(以二进制方式) bool SetStr(const std::string& MainKey, const std::string& SubKey, const std::string& Data) override { return SetBinary(MainKey, SubKey, reinterpret_cast(Data.data()), static_cast(Data.size())); } - // ȡַӶת + // 读取字符串(从二进制数据转换) std::string GetStr(const std::string& MainKey, const std::string& SubKey, const std::string& def = "") override { std::vector buffer; @@ -165,7 +257,7 @@ public: return std::string(buffer.begin(), buffer.end()); } - // ȡӶƽ + // 读取整数(从二进制解析) int GetInt(const std::string& MainKey, const std::string& SubKey, int defVal = 0) override { std::vector buffer; diff --git a/compress/libyuv/libyuv_x64.lib b/compress/libyuv/libyuv_x64.lib index 6986469..c5308a3 100644 Binary files a/compress/libyuv/libyuv_x64.lib and b/compress/libyuv/libyuv_x64.lib differ diff --git a/compress/x264/libx264.lib b/compress/x264/libx264.lib index 6a47239..e4022ed 100644 Binary files a/compress/x264/libx264.lib and b/compress/x264/libx264.lib differ diff --git a/compress/x264/libx264_x64.lib b/compress/x264/libx264_x64.lib index 1fc4384..46d12aa 100644 Binary files a/compress/x264/libx264_x64.lib and b/compress/x264/libx264_x64.lib differ diff --git a/compress/zlib/zlib_x64.lib b/compress/zlib/zlib_x64.lib index 6a1f361..5e997f3 100644 Binary files a/compress/zlib/zlib_x64.lib and b/compress/zlib/zlib_x64.lib differ diff --git a/server/2015Remote/BuildDlg.cpp b/server/2015Remote/BuildDlg.cpp index 2bf6f73..df7abb0 100644 --- a/server/2015Remote/BuildDlg.cpp +++ b/server/2015Remote/BuildDlg.cpp @@ -9,7 +9,7 @@ #include "InputDlg.h" #include #include -#include +// #include enum Index { IndexTestRun_DLL,