From ed89882328ab3354d3f50f7b8a6c4e9807402823 Mon Sep 17 00:00:00 2001 From: Requiem <114197630+NotRequiem@users.noreply.github.com> Date: Sat, 7 Sep 2024 09:48:17 +0200 Subject: [PATCH] stupid change to avoid compiler warning **Warning** ``` Warning C4244 'initializing': conversion from '_Ty' to '_Ty2', possible loss of data with [ _Ty=int ] and [ _Ty2=VM::u8 ] C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.41.34120\include\utility 247 ``` **Explanation** The warning suggests that converting between these types (i.e., from DWORD to u8) may cause data loss since DWORD is 32-bit and u8 is only 8-bit. **Solution** All the values you're assigning to the u8 type are valid and will fit within uint8_t. Therefore, casting them as static_cast will work fine to supress the MSVC compiler warning without any data loss: - The first value, 6, is well within the range of uint8_t (0-255). - The rest of the values (7, 8, 10, 11) also fit within the valid range of uint8_t. By explictly casting the values to "u8" (which is an alias for uint8_t) during initialization, we make it clear that we're aware of the conversion to the compiler. --- src/vmaware.hpp | 44 ++++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/src/vmaware.hpp b/src/vmaware.hpp index 4d09a8ec..0427a35f 100644 --- a/src/vmaware.hpp +++ b/src/vmaware.hpp @@ -1982,27 +1982,27 @@ struct VM { typedef NTSTATUS(WINAPI* RtlGetVersionFunc)(PRTL_OSVERSIONINFOW); const std::map windowsVersions = { - { 6002, 6 }, // windows vista, technically no number but this function is just for great than operations anyway so it doesn't matter - { 7601, 7 }, - { 9200, 8 }, - { 9600, 8 }, - { 10240, 10 }, - { 10586, 10 }, - { 14393, 10 }, - { 15063, 10 }, - { 16299, 10 }, - { 17134, 10 }, - { 17763, 10 }, - { 18362, 10 }, - { 18363, 10 }, - { 19041, 10 }, - { 19042, 10 }, - { 19043, 10 }, - { 19044, 10 }, - { 19045, 10 }, - { 22000, 11 }, - { 22621, 11 }, - { 22631, 11 } + { 6002, static_cast(6) }, // windows vista, technically no number but this function is just for great than operations anyway so it doesn't matter + { 7601, static_cast(7) }, + { 9200, static_cast(8) }, + { 9600, static_cast(8) }, + { 10240, static_cast(10) }, + { 10586, static_cast(10) }, + { 14393, static_cast(10) }, + { 15063, static_cast(10) }, + { 16299, static_cast(10) }, + { 17134, static_cast(10) }, + { 17763, static_cast(10) }, + { 18362, static_cast(10) }, + { 18363, static_cast(10) }, + { 19041, static_cast(10) }, + { 19042, static_cast(10) }, + { 19043, static_cast(10) }, + { 19044, static_cast(10) }, + { 19045, static_cast(10) }, + { 22000, static_cast(11) }, + { 22621, static_cast(11) }, + { 22631, static_cast(11) } }; HMODULE ntdll = LoadLibraryW(L"ntdll.dll"); @@ -10293,4 +10293,4 @@ const std::map VM::core::technique_table = { VM::SMBIOS_VM_BIT, { 50, VM::smbios_vm_bit, false } }, { VM::PODMAN_FILE, { 15, VM::podman_file, true } }, { VM::WSL_PROC, { 30, VM::wsl_proc_subdir, false } } -}; \ No newline at end of file +};