From 5876c2b65820df6b92d07d467f7d812e7e90f257 Mon Sep 17 00:00:00 2001 From: Skyth <19259897+blueskythlikesclouds@users.noreply.github.com> Date: Wed, 4 Dec 2024 12:48:38 +0300 Subject: [PATCH] Add missing files. --- UnleashedRecomp/CMakeLists.txt | 1 + UnleashedRecomp/framework.h | 9 ++++++++- UnleashedRecomp/kernel/platform.cpp | 24 ++++++++++++++++++++++++ UnleashedRecomp/kernel/platform.h | 11 +++++++++++ 4 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 UnleashedRecomp/kernel/platform.cpp create mode 100644 UnleashedRecomp/kernel/platform.h diff --git a/UnleashedRecomp/CMakeLists.txt b/UnleashedRecomp/CMakeLists.txt index 2690905..72975fd 100644 --- a/UnleashedRecomp/CMakeLists.txt +++ b/UnleashedRecomp/CMakeLists.txt @@ -41,6 +41,7 @@ set(SWA_KERNEL_CXX_SOURCES "kernel/xdm.cpp" "kernel/heap.cpp" "kernel/memory.cpp" + "kernel/platform.cpp" "kernel/xam.cpp" "kernel/io/file_system.cpp" ) diff --git a/UnleashedRecomp/framework.h b/UnleashedRecomp/framework.h index a8a8759..e870fec 100644 --- a/UnleashedRecomp/framework.h +++ b/UnleashedRecomp/framework.h @@ -14,6 +14,13 @@ #define SWA_API extern "C" SWA_DLLIMPORT #endif +#define PROC_ADDRESS(libraryName, procName) \ + GetProcAddress(LoadLibrary(TEXT(libraryName)), procName) + +#define LIB_FUNCTION(returnType, libraryName, procName, ...) \ + typedef returnType _##procName(__VA_ARGS__); \ + _##procName* procName = (_##procName*)PROC_ADDRESS(libraryName, #procName); + template void ByteSwap(T& value) { @@ -66,4 +73,4 @@ constexpr size_t FirstBitLow(TValue value) } return 0; -} \ No newline at end of file +} diff --git a/UnleashedRecomp/kernel/platform.cpp b/UnleashedRecomp/kernel/platform.cpp new file mode 100644 index 0000000..97c072f --- /dev/null +++ b/UnleashedRecomp/kernel/platform.cpp @@ -0,0 +1,24 @@ +#include + +#if _WIN32 +LIB_FUNCTION(LONG, "ntdll.dll", RtlGetVersion, PRTL_OSVERSIONINFOW); +#endif + +PlatformVersion GetPlatformVersion() +{ + auto result = PlatformVersion{}; + +#if _WIN32 + OSVERSIONINFOEXW osvi = { 0 }; + osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEXW); + + if (RtlGetVersion((PRTL_OSVERSIONINFOW)&osvi) != 0) + return result; + + result.Major = osvi.dwMajorVersion; + result.Minor = osvi.dwMinorVersion; + result.Build = osvi.dwBuildNumber; +#endif + + return result; +} diff --git a/UnleashedRecomp/kernel/platform.h b/UnleashedRecomp/kernel/platform.h new file mode 100644 index 0000000..a03379a --- /dev/null +++ b/UnleashedRecomp/kernel/platform.h @@ -0,0 +1,11 @@ +#pragma once + +struct PlatformVersion +{ +public: + uint32_t Major{}; + uint32_t Minor{}; + uint32_t Build{}; +}; + +extern PlatformVersion GetPlatformVersion();