diff options
-rw-r--r-- | LauncherInjector/resources.rc | 4 | ||||
-rw-r--r-- | NorthstarDedicatedTest/NorthstarDedicatedTest.vcxproj | 8 | ||||
-rw-r--r-- | NorthstarDedicatedTest/NorthstarDedicatedTest.vcxproj.filters | 6 | ||||
-rw-r--r-- | NorthstarDedicatedTest/dllmain.cpp | 2 | ||||
-rw-r--r-- | NorthstarDedicatedTest/masterserver.cpp | 19 | ||||
-rw-r--r-- | NorthstarDedicatedTest/version.cpp | 59 | ||||
-rw-r--r-- | NorthstarDedicatedTest/version.h | 6 |
7 files changed, 90 insertions, 14 deletions
diff --git a/LauncherInjector/resources.rc b/LauncherInjector/resources.rc index 8a1cde40..99fcc41e 100644 --- a/LauncherInjector/resources.rc +++ b/LauncherInjector/resources.rc @@ -61,8 +61,8 @@ IDI_ICON1 ICON "ns_icon.ico" // VS_VERSION_INFO VERSIONINFO - FILEVERSION 0,0,0,0 - PRODUCTVERSION 0,0,0,0 + FILEVERSION 0,0,0,1 + PRODUCTVERSION 0,0,0,1 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L diff --git a/NorthstarDedicatedTest/NorthstarDedicatedTest.vcxproj b/NorthstarDedicatedTest/NorthstarDedicatedTest.vcxproj index 4a383d37..e9a27ad9 100644 --- a/NorthstarDedicatedTest/NorthstarDedicatedTest.vcxproj +++ b/NorthstarDedicatedTest/NorthstarDedicatedTest.vcxproj @@ -66,7 +66,7 @@ <SubSystem>Windows</SubSystem> <GenerateDebugInformation>true</GenerateDebugInformation> <EnableUAC>false</EnableUAC> - <AdditionalDependencies>$(ProjectDir)include\MinHook.x64.lib;$(ProjectDir)include\libcurl\lib\libcurl_a.lib;dbghelp.lib;Wldap32.lib;Normaliz.lib;%(AdditionalDependencies)</AdditionalDependencies> + <AdditionalDependencies>$(ProjectDir)include\MinHook.x64.lib;$(ProjectDir)include\libcurl\lib\libcurl_a.lib;dbghelp.lib;Wldap32.lib;Normaliz.lib;version.lib;%(AdditionalDependencies)</AdditionalDependencies> <ForceSymbolReferences> </ForceSymbolReferences> <AdditionalLibraryDirectories>%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories> @@ -96,7 +96,7 @@ <OptimizeReferences>true</OptimizeReferences> <GenerateDebugInformation>true</GenerateDebugInformation> <EnableUAC>false</EnableUAC> - <AdditionalDependencies>$(ProjectDir)include\MinHook.x64.lib;$(ProjectDir)include\libcurl\lib\libcurl_a.lib;dbghelp.lib;Wldap32.lib;Normaliz.lib;%(AdditionalDependencies)</AdditionalDependencies> + <AdditionalDependencies>$(ProjectDir)include\MinHook.x64.lib;$(ProjectDir)include\libcurl\lib\libcurl_a.lib;dbghelp.lib;Wldap32.lib;Normaliz.lib;version.lib;%(AdditionalDependencies)</AdditionalDependencies> <ForceSymbolReferences> </ForceSymbolReferences> <AdditionalLibraryDirectories>%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories> @@ -562,6 +562,7 @@ <ClInclude Include="ExploitFixes.h" /> <ClInclude Include="ExploitFixes_UTF8Parser.h" /> <ClInclude Include="NSMem.h" /> + <ClInclude Include="version.h" /> </ItemGroup> <ItemGroup> <ClCompile Include="audio.cpp" /> @@ -619,6 +620,7 @@ <ClCompile Include="sourceinterface.cpp" /> <ClCompile Include="squirrel.cpp" /> <ClCompile Include="ExploitFixes.cpp" /> + <ClCompile Include="version.cpp" /> </ItemGroup> <ItemGroup> <None Include="include\crypto\bn_conf.h.in" /> @@ -657,4 +659,4 @@ <ImportGroup Label="ExtensionTargets"> <Import Project="$(VCTargetsPath)\BuildCustomizations\masm.targets" /> </ImportGroup> -</Project> +</Project>
\ No newline at end of file diff --git a/NorthstarDedicatedTest/NorthstarDedicatedTest.vcxproj.filters b/NorthstarDedicatedTest/NorthstarDedicatedTest.vcxproj.filters index c03d822f..3cc20b58 100644 --- a/NorthstarDedicatedTest/NorthstarDedicatedTest.vcxproj.filters +++ b/NorthstarDedicatedTest/NorthstarDedicatedTest.vcxproj.filters @@ -1500,6 +1500,9 @@ <ClInclude Include="ExploitFixes_UTF8Parser.h"> <Filter>Source Files\Shared\Exploit Fixes\UTF8Parser</Filter> </ClInclude> + <ClInclude Include="version.h"> + <Filter>Header Files</Filter> + </ClInclude> </ItemGroup> <ItemGroup> <ClCompile Include="dllmain.cpp"> @@ -1658,6 +1661,9 @@ <ClCompile Include="ExploitFixes.cpp"> <Filter>Source Files\Shared\Exploit Fixes</Filter> </ClCompile> + <ClCompile Include="version.cpp"> + <Filter>Source Files</Filter> + </ClCompile> </ItemGroup> <ItemGroup> <MASM Include="audio_asm.asm"> diff --git a/NorthstarDedicatedTest/dllmain.cpp b/NorthstarDedicatedTest/dllmain.cpp index 55951b66..524235cf 100644 --- a/NorthstarDedicatedTest/dllmain.cpp +++ b/NorthstarDedicatedTest/dllmain.cpp @@ -41,6 +41,7 @@ #include "plugins.h" #include "clientvideooverrides.h" #include <string.h> +#include "version.h" #include "pch.h" #include "rapidjson/document.h" @@ -194,6 +195,7 @@ bool InitialiseNorthstar() initialised = true; parseConfigurables(); + InitialiseVersion(); SetEnvironmentVariableA("OPENSSL_ia32cap", "~0x200000200000000"); curl_global_init_mem(CURL_GLOBAL_DEFAULT, _malloc_base, _free_base, _realloc_base, _strdup_base, _calloc_base); diff --git a/NorthstarDedicatedTest/masterserver.cpp b/NorthstarDedicatedTest/masterserver.cpp index b5f87274..076c0a14 100644 --- a/NorthstarDedicatedTest/masterserver.cpp +++ b/NorthstarDedicatedTest/masterserver.cpp @@ -13,6 +13,7 @@ #include "misccommands.h" #include <cstring> #include <regex> +#include "version.h" // NOTE for anyone reading this: we used to use httplib for requests here, but it had issues, so we're moving to curl now for masterserver // requests so httplib is used exclusively for server stuff now @@ -169,6 +170,7 @@ void MasterServerManager::SetCommonHttpClientOptions(CURL* curl) { curl_easy_setopt(curl, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4); curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); + curl_easy_setopt(curl, CURLOPT_USERAGENT, &NSUserAgent); // curl_easy_setopt(curl, CURLOPT_STDERR, stdout); if (CommandLine()->FindParm("-msinsecure")) // TODO: this check doesn't seem to work { @@ -210,7 +212,6 @@ void MasterServerManager::AuthenticateOriginWithMasterServer(char* uid, char* or CURL* curl = curl_easy_init(); SetCommonHttpClientOptions(curl); - std::string readBuffer; curl_easy_setopt( curl, CURLOPT_URL, @@ -556,7 +557,7 @@ void MasterServerManager::AuthenticateWithOwnServer(char* uid, char* playerToken curl_easy_setopt( curl, CURLOPT_URL, fmt::format("{}/client/auth_with_self?id={}&playerToken={}", Cvar_ns_masterserver_hostname->GetString(), uidStr, tokenStr) - .c_str()); + .c_str()); curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "POST"); curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, CurlWriteToStringBufferCallback); curl_easy_setopt(curl, CURLOPT_WRITEDATA, &readBuffer); @@ -698,7 +699,7 @@ void MasterServerManager::AuthenticateWithServer(char* uid, char* playerToken, c fmt::format( "{}/client/auth_with_server?id={}&playerToken={}&server={}&password={}", Cvar_ns_masterserver_hostname->GetString(), uidStr, tokenStr, serverIdStr, escapedPassword) - .c_str()); + .c_str()); curl_free(escapedPassword); } @@ -832,7 +833,7 @@ void MasterServerManager::AddSelfToServerList( "{}/server/add_server?port={}&authPort={}&name={}&description={}&map={}&playlist={}&maxPlayers={}&password={}", Cvar_ns_masterserver_hostname->GetString(), port, authPort, nameEscaped, descEscaped, mapEscaped, playlistEscaped, maxPlayers, passwordEscaped) - .c_str()); + .c_str()); curl_free(nameEscaped); curl_free(descEscaped); @@ -936,7 +937,7 @@ void MasterServerManager::AddSelfToServerList( Cvar_ns_player_auth_port->GetInt(), escapedNameNew, escapedDescNew, escapedMapNew, escapedPlaylistNew, g_ServerAuthenticationManager->m_additionalPlayerData.size(), maxPlayers, escapedPasswordNew) - .c_str()); + .c_str()); curl_free(escapedNameNew); curl_free(escapedDescNew); @@ -1037,7 +1038,7 @@ void MasterServerManager::UpdateServerMapAndPlaylist(char* map, char* playlist, fmt::format( "{}/server/update_values?id={}&map={}&playlist={}&maxPlayers={}", Cvar_ns_masterserver_hostname->GetString(), m_ownServerId, mapEscaped, playlistEscaped, maxPlayers) - .c_str()); + .c_str()); curl_free(mapEscaped); curl_free(playlistEscaped); @@ -1076,7 +1077,7 @@ void MasterServerManager::UpdateServerPlayerCount(int playerCount) curl, CURLOPT_URL, fmt::format( "{}/server/update_values?id={}&playerCount={}", Cvar_ns_masterserver_hostname->GetString(), m_ownServerId, playerCount) - .c_str()); + .c_str()); CURLcode result = curl_easy_perform(curl); @@ -1116,7 +1117,7 @@ void MasterServerManager::WritePlayerPersistentData(char* playerId, char* pdata, fmt::format( "{}/accounts/write_persistence?id={}&serverId={}", Cvar_ns_masterserver_hostname->GetString(), strPlayerId, m_ownServerId) - .c_str()); + .c_str()); curl_easy_setopt(curl, CURLOPT_POST, 1L); curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, CurlWriteToStringBufferCallback); curl_easy_setopt(curl, CURLOPT_WRITEDATA, &readBuffer); @@ -1261,7 +1262,7 @@ void CHostState__State_GameShutdownHook(CHostState* hostState) CHostState__State_GameShutdown(hostState); } -MasterServerManager::MasterServerManager() : m_pendingConnectionInfo{}, m_ownServerId{""}, m_ownClientAuthToken{""} {} +MasterServerManager::MasterServerManager() : m_pendingConnectionInfo{}, m_ownServerId{ "" }, m_ownClientAuthToken{ "" } {} void InitialiseSharedMasterServer(HMODULE baseAddress) { diff --git a/NorthstarDedicatedTest/version.cpp b/NorthstarDedicatedTest/version.cpp new file mode 100644 index 00000000..dfeb9670 --- /dev/null +++ b/NorthstarDedicatedTest/version.cpp @@ -0,0 +1,59 @@ +#include "version.h" +#include "pch.h" + +char version[16]; +char NSUserAgent[32]; + +void InitialiseVersion() { + HRSRC hResInfo; + DWORD dwSize; + HGLOBAL hResData; + LPVOID pRes, pResCopy; + UINT uLen = 0; + VS_FIXEDFILEINFO* lpFfi = NULL; + HINSTANCE hInst = ::GetModuleHandle(NULL); + + hResInfo = FindResourceW(hInst, MAKEINTRESOURCE(1), RT_VERSION); + if (hResInfo != NULL) { + dwSize = SizeofResource(hInst, hResInfo); + hResData = LoadResource(hInst, hResInfo); + if (hResData != NULL) { + pRes = LockResource(hResData); + pResCopy = LocalAlloc(LMEM_FIXED, dwSize); + if (pResCopy != 0) { + CopyMemory(pResCopy, pRes, dwSize); + VerQueryValueW(pResCopy, L"\\", (LPVOID*)&lpFfi, &uLen); + + DWORD dwFileVersionMS = lpFfi->dwFileVersionMS; + DWORD dwFileVersionLS = lpFfi->dwFileVersionLS; + + DWORD dwLeftMost = HIWORD(dwFileVersionMS); + DWORD dwSecondLeft = LOWORD(dwFileVersionMS); + DWORD dwSecondRight = HIWORD(dwFileVersionLS); + DWORD dwRightMost = LOWORD(dwFileVersionLS); + + // We actually use the rightmost integer do determine whether or not we're a debug/dev build + // If it is set to 1 (as in resources.rc), we are a dev build + // On github CI, we set this 1 to a 0 automatically as we replace the 0.0.0.1 with the real version number + if (dwRightMost == 1) { + sprintf(version, "%d.%d.%d.%d+dev", dwLeftMost, dwSecondLeft, dwSecondRight, dwRightMost); + sprintf(NSUserAgent, "R2Northstar/%d.%d.%d+dev", dwLeftMost, dwSecondLeft, dwSecondRight); + } + else { + sprintf(version, "%d.%d.%d.%d", dwLeftMost, dwSecondLeft, dwSecondRight, dwRightMost); + sprintf(NSUserAgent, "R2Northstar/%d.%d.%d", dwLeftMost, dwSecondLeft, dwSecondRight); + } + UnlockResource(hResData); + FreeResource(hResData); + LocalFree(pResCopy); + return; + } + UnlockResource(hResData); + FreeResource(hResData); + LocalFree(pResCopy); + } + } + // Could not locate version info for whatever reason + spdlog::error("Failed to load version info:\n{}", std::system_category().message(GetLastError())); + sprintf(NSUserAgent, "R2Northstar/0.0.0"); +} diff --git a/NorthstarDedicatedTest/version.h b/NorthstarDedicatedTest/version.h new file mode 100644 index 00000000..d9d29fec --- /dev/null +++ b/NorthstarDedicatedTest/version.h @@ -0,0 +1,6 @@ +#pragma once + +extern char version[16]; +extern char NSUserAgent[32]; + +void InitialiseVersion();
\ No newline at end of file |