parent
0afcb00ec7
commit
0275821f95
59
src/main.cpp
59
src/main.cpp
@ -73,6 +73,60 @@ namespace big
|
|||||||
}
|
}
|
||||||
return patched;
|
return patched;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string ReadRegistryKeySZ(HKEY hKeyParent, std::string subkey, std::string valueName)
|
||||||
|
{
|
||||||
|
HKEY hKey;
|
||||||
|
char value[1024];
|
||||||
|
DWORD value_length = 1024;
|
||||||
|
LONG ret = RegOpenKeyEx(hKeyParent, subkey.c_str(), 0, KEY_READ, &hKey);
|
||||||
|
if (ret != ERROR_SUCCESS)
|
||||||
|
{
|
||||||
|
LOG(INFO) << "Unable to read registry key " << subkey;
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
ret = RegQueryValueEx(hKey, valueName.c_str(), NULL, NULL, (LPBYTE)&value, &value_length);
|
||||||
|
RegCloseKey(hKey);
|
||||||
|
if (ret != ERROR_SUCCESS)
|
||||||
|
{
|
||||||
|
LOG(INFO) << "Unable to read registry key " << valueName;
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
return std::string(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
DWORD ReadRegistryKeyDWORD(HKEY hKeyParent, std::string subkey, std::string valueName)
|
||||||
|
{
|
||||||
|
HKEY hKey;
|
||||||
|
DWORD value;
|
||||||
|
DWORD value_length = sizeof(DWORD);
|
||||||
|
LONG ret = RegOpenKeyEx(hKeyParent, subkey.c_str(), 0, KEY_READ, &hKey);
|
||||||
|
if (ret != ERROR_SUCCESS)
|
||||||
|
{
|
||||||
|
LOG(INFO) << "Unable to read registry key " << subkey;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
ret = RegQueryValueEx(hKey, valueName.c_str(), NULL, NULL, (LPBYTE)&value, &value_length);
|
||||||
|
RegCloseKey(hKey);
|
||||||
|
if (ret != ERROR_SUCCESS)
|
||||||
|
{
|
||||||
|
LOG(INFO) << "Unable to read registry key " << valueName;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
LPSTR GetWindowsVersion()
|
||||||
|
{
|
||||||
|
typedef LPWSTR(WINAPI * BFS)(LPCWSTR);
|
||||||
|
LPWSTR UTF16 = BFS(GetProcAddress(LoadLibrary("winbrand.dll"), "BrandingFormatString"))(L"%WINDOWS_LONG%");
|
||||||
|
int BufferSize = WideCharToMultiByte(CP_UTF8, 0, UTF16, -1, NULL, 0, NULL, NULL);
|
||||||
|
LPSTR UTF8 = new char[BufferSize];
|
||||||
|
WideCharToMultiByte(CP_UTF8, 0, UTF16, -1, UTF8, BufferSize, NULL, NULL);
|
||||||
|
// BrandingFormatString requires a GlobalFree.
|
||||||
|
GlobalFree(UTF16);
|
||||||
|
return UTF8;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL APIENTRY DllMain(HMODULE hmod, DWORD reason, PVOID)
|
BOOL APIENTRY DllMain(HMODULE hmod, DWORD reason, PVOID)
|
||||||
@ -104,6 +158,11 @@ BOOL APIENTRY DllMain(HMODULE hmod, DWORD reason, PVOID)
|
|||||||
LOG(INFO) << "Yim's Menu Initializing";
|
LOG(INFO) << "Yim's Menu Initializing";
|
||||||
LOGF(INFO, "Git Info\n\tBranch:\t{}\n\tHash:\t{}\n\tDate:\t{}", version::GIT_BRANCH, version::GIT_SHA1, version::GIT_DATE);
|
LOGF(INFO, "Git Info\n\tBranch:\t{}\n\tHash:\t{}\n\tDate:\t{}", version::GIT_BRANCH, version::GIT_SHA1, version::GIT_DATE);
|
||||||
|
|
||||||
|
auto display_version = ReadRegistryKeySZ(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion", "DisplayVersion");
|
||||||
|
auto current_build = ReadRegistryKeySZ(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion", "CurrentBuild");
|
||||||
|
auto UBR = ReadRegistryKeyDWORD(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion", "UBR");
|
||||||
|
LOG(INFO) << GetWindowsVersion() << " Version " << display_version << " (OS Build " << current_build << "." << UBR << ")";
|
||||||
|
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
LOG(WARNING) << "Debug Build. Switch to RelWithDebInfo or Release Build for a more stable experience";
|
LOG(WARNING) << "Debug Build. Switch to RelWithDebInfo or Release Build for a more stable experience";
|
||||||
#endif
|
#endif
|
||||||
|
@ -39,6 +39,11 @@ namespace big
|
|||||||
file font_file_path = windows_fonts.get_file("./msyh.ttc");
|
file font_file_path = windows_fonts.get_file("./msyh.ttc");
|
||||||
if (!font_file_path.exists())
|
if (!font_file_path.exists())
|
||||||
font_file_path = windows_fonts.get_file("./msyh.ttf");
|
font_file_path = windows_fonts.get_file("./msyh.ttf");
|
||||||
|
if (!font_file_path.exists())
|
||||||
|
{
|
||||||
|
LOG(WARNING) << "Failed to find msyh font, falling back to Arial!";
|
||||||
|
font_file_path = windows_fonts.get_file("./arial.ttf");
|
||||||
|
}
|
||||||
auto font_file = std::ifstream(font_file_path.get_path(), std::ios::binary | std::ios::ate);
|
auto font_file = std::ifstream(font_file_path.get_path(), std::ios::binary | std::ios::ate);
|
||||||
const auto font_data_size = static_cast<int>(font_file.tellg());
|
const auto font_data_size = static_cast<int>(font_file.tellg());
|
||||||
const auto font_data = std::make_unique<uint8_t[]>(font_data_size);
|
const auto font_data = std::make_unique<uint8_t[]>(font_data_size);
|
||||||
|
Reference in New Issue
Block a user