diff --git a/.gitignore b/.gitignore
index 07f703e..a7832c6 100644
--- a/.gitignore
+++ b/.gitignore
@@ -362,4 +362,6 @@ MigrationBackup/
.ionide/
# Fody - auto-generated XML schema
-FodyWeavers.xsd
\ No newline at end of file
+FodyWeavers.xsd
+
+CMakeFiles/
\ No newline at end of file
diff --git a/.idea/editor.xml b/.idea/editor.xml
index 66c8679..226ca24 100644
--- a/.idea/editor.xml
+++ b/.idea/editor.xml
@@ -98,5 +98,483 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
index 79b3c94..0b76fe5 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -1,4 +1,7 @@
+
+
+
\ No newline at end of file
diff --git a/BuildTools/upx.exe b/BuildTools/upx.exe
deleted file mode 100644
index 32c1284..0000000
Binary files a/BuildTools/upx.exe and /dev/null differ
diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100644
index 0000000..41dd7db
--- /dev/null
+++ b/CMakeLists.txt
@@ -0,0 +1,55 @@
+cmake_minimum_required(VERSION 3.15)
+project(xpmgr CXX)
+
+set(CMAKE_CXX_STANDARD 17)
+set(CMAKE_CXX_STANDARD_REQUIRED ON)
+
+set(SOURCES xpmgr.cpp)
+
+# ==== x86 build ====
+set(RES_X86 ${CMAKE_BINARY_DIR}/icon_x86.res)
+
+# Create a custom target for the x86 resource compilation
+add_custom_command(
+ OUTPUT ${RES_X86}
+ COMMAND windres -F pe-i386 -O coff ${CMAKE_SOURCE_DIR}/icon.rc -o ${RES_X86}
+ DEPENDS ${CMAKE_SOURCE_DIR}/icon.rc ${CMAKE_SOURCE_DIR}/icon.ico
+ COMMENT "Compiling icon.rc for x86"
+)
+
+add_custom_target(xpmgr_x86_res ALL DEPENDS ${RES_X86})
+
+# Now define the executable and link dependencies
+add_executable(xpmgr_x86 ${SOURCES})
+add_dependencies(xpmgr_x86 xpmgr_x86_res)
+
+target_compile_options(xpmgr_x86 PRIVATE -m32)
+target_link_options(xpmgr_x86 PRIVATE -m32)
+
+# Link .res file as a resource
+target_link_libraries(xpmgr_x86 PRIVATE ole32 oleaut32 uuid)
+target_link_options(xpmgr_x86 PRIVATE -Wl,--subsystem,console ${RES_X86})
+
+# ==== x64 build ====
+set(RES_X64 ${CMAKE_BINARY_DIR}/icon_x64.res)
+
+# Create a custom target for the x64 resource compilation
+add_custom_command(
+ OUTPUT ${RES_X64}
+ COMMAND windres -O coff ${CMAKE_SOURCE_DIR}/icon.rc -o ${RES_X64}
+ DEPENDS ${CMAKE_SOURCE_DIR}/icon.rc ${CMAKE_SOURCE_DIR}/icon.ico
+ COMMENT "Compiling icon.rc for x64"
+)
+
+add_custom_target(xpmgr_x64_res ALL DEPENDS ${RES_X64})
+
+# Now define the executable and link dependencies
+add_executable(xpmgr_x64 ${SOURCES})
+add_dependencies(xpmgr_x64 xpmgr_x64_res)
+
+target_compile_options(xpmgr_x64 PRIVATE -m64)
+target_link_options(xpmgr_x64 PRIVATE -m64)
+
+# Link .res file as a resource
+target_link_libraries(xpmgr_x64 PRIVATE ole32 oleaut32 uuid)
+target_link_options(xpmgr_x64 PRIVATE -Wl,--subsystem,console ${RES_X64})
diff --git a/xpmgr.ico b/icon.ico
similarity index 100%
rename from xpmgr.ico
rename to icon.ico
diff --git a/icon.rc b/icon.rc
index 63d11cd..1690989 100644
--- a/icon.rc
+++ b/icon.rc
@@ -1 +1 @@
-id ICON "xpmgr.ico"
\ No newline at end of file
+1 ICON "icon.ico"
\ No newline at end of file
diff --git a/xpmgr.cpp b/xpmgr.cpp
index f60a36d..ec1c7b2 100644
--- a/xpmgr.cpp
+++ b/xpmgr.cpp
@@ -531,7 +531,9 @@ static BSTR XP_GetWPALeft() {
if (dwWPALeft == 0x7FFFFFFF) {
return SysAllocString(L"An error occurred at GetWPALeft: Windows is activated");
}
- return SysAllocString(_bstr_t(dwWPALeft).Detach());
+ wchar_t buffer[16];
+ swprintf_s(buffer, 16, L"%lu", dwWPALeft);
+ return SysAllocString(buffer);
}
static BSTR XP_GetEvalLeft() {
@@ -556,7 +558,9 @@ static BSTR XP_GetEvalLeft() {
if (dwEvalLeft == 0x7FFFFFFF) {
return SysAllocString(L"An error occurred at GetEvalLeft: Not an evaluation copy");
}
- return SysAllocString(_bstr_t(dwEvalLeft).Detach());
+ wchar_t buffer[16];
+ swprintf_s(buffer, 16, L"%lu", dwWPALeft);
+ return SysAllocString(buffer);
}
static BSTR XP_VerifyCheckDigits(BSTR cidChunk) {
@@ -868,7 +872,7 @@ int main(int argc, char* argv[])
std::cout << "An error occurred at systemInfo: Windows Product Activation does not exist on this platform.";
}
else { // is PPC, megafart 386, whatever else
- std::cout << "An error occurred at systemInfo: Incorrect version of xpmgr. Go to https://umskt.zulipchat.com if you want to help us make a version for your platform!";
+ std::cout << "An error occurred at systemInfo: Incorrect version of xpmgr. Send an issue at https://github.com/UMSKT/xpmgr/issues if you want to help us make a version for your platform!";
}
return 1;
}