mirror of
https://github.com/RPCS3/rpcs3.git
synced 2024-12-27 06:21:02 +00:00
Print OS info to log
Credit to @maximilian578 for help
This commit is contained in:
parent
243df38360
commit
be6d9af1ab
@ -602,6 +602,17 @@ logs::file_listener::file_listener(const std::string& name)
|
||||
file_writer::log(logs::level::always, ver.text.data(), ver.text.size());
|
||||
file_writer::log(logs::level::always, "\n", 1);
|
||||
messages.emplace_back(std::move(ver));
|
||||
|
||||
// Write OS version
|
||||
stored_message os;
|
||||
os.m.ch = nullptr;
|
||||
os.m.sev = level::notice;
|
||||
os.stamp = 0;
|
||||
os.text = utils::get_OS_version();
|
||||
|
||||
file_writer::log(logs::level::notice, os.text.data(), os.text.size());
|
||||
file_writer::log(logs::level::notice, "\n", 1);
|
||||
messages.emplace_back(std::move(os));
|
||||
}
|
||||
|
||||
void logs::file_listener::log(u64 stamp, const logs::message& msg, const std::string& prefix, const std::string& _text)
|
||||
|
@ -5,8 +5,13 @@
|
||||
|
||||
#ifdef _WIN32
|
||||
#include "windows.h"
|
||||
#include "sysinfoapi.h"
|
||||
#include "subauth.h"
|
||||
#include "stringapiset.h"
|
||||
#else
|
||||
#include <unistd.h>
|
||||
#include <sys/utsname.h>
|
||||
#include <errno.h>
|
||||
#endif
|
||||
|
||||
bool utils::has_ssse3()
|
||||
@ -153,3 +158,46 @@ std::string utils::get_firmware_version()
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
std::string utils::get_OS_version()
|
||||
{
|
||||
std::string output = "";
|
||||
#ifdef _WIN32
|
||||
// GetVersionEx is deprecated, RtlGetVersion is kernel-mode only and AnalyticsInfo is UWP only.
|
||||
// So we're forced to read PEB instead to get Windows version info. It's ugly but works.
|
||||
|
||||
const DWORD peb_offset = 0x60;
|
||||
const INT_PTR peb = __readgsqword(peb_offset);
|
||||
|
||||
const DWORD version_major = *reinterpret_cast<const DWORD*>(peb + 0x118);
|
||||
const DWORD version_minor = *reinterpret_cast<const DWORD*>(peb + 0x11c);
|
||||
const WORD build = *reinterpret_cast<const WORD*>(peb + 0x120);
|
||||
const UNICODE_STRING service_pack = *reinterpret_cast<const UNICODE_STRING*>(peb + 0x02E8);
|
||||
const u64 compatibility_mode = *reinterpret_cast<const u64*>(peb + 0x02C8); // Two DWORDs, major & minor version
|
||||
|
||||
const bool has_sp = service_pack.Length > 0;
|
||||
std::vector<char> holder(service_pack.Length + 1, '\0');
|
||||
if (has_sp)
|
||||
{
|
||||
WideCharToMultiByte(CP_UTF8, NULL, service_pack.Buffer, service_pack.Length,
|
||||
(LPSTR) holder.data(), static_cast<int>(holder.size()), NULL, NULL);
|
||||
}
|
||||
|
||||
fmt::append(output,
|
||||
"Operating system: Windows, Major: %lu, Minor: %lu, Build: %u, Service Pack: %s, Compatibility mode: %llu",
|
||||
version_major, version_minor, build, has_sp ? holder.data() : "none", compatibility_mode);
|
||||
#else
|
||||
struct utsname details = {};
|
||||
|
||||
if (!uname(&details))
|
||||
{
|
||||
fmt::append(output, "Operating system: POSIX, Name: %s, Release: %s, Version: %s",
|
||||
details.sysname, details.release, details.version);
|
||||
}
|
||||
else
|
||||
{
|
||||
fmt::append(output, "Operating system: POSIX, Unknown version! (Error: %d)", errno);
|
||||
}
|
||||
#endif
|
||||
return output;
|
||||
}
|
||||
|
@ -46,4 +46,6 @@ namespace utils
|
||||
std::string get_system_info();
|
||||
|
||||
std::string get_firmware_version();
|
||||
|
||||
std::string get_OS_version();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user