mirror of https://github.com/UMSKT/xpmgr.git
rewrite to GCC instead of MSVC
This commit is contained in:
parent
f1931a4cde
commit
ce6b706251
|
@ -10,47 +10,29 @@ jobs:
|
||||||
build:
|
build:
|
||||||
runs-on: windows-latest
|
runs-on: windows-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Install Windows XP Support for Visual Studio
|
|
||||||
run: |
|
|
||||||
Set-Location "C:\Program Files (x86)\Microsoft Visual Studio\Installer\"
|
|
||||||
$InstallPath = "C:\Program Files\Microsoft Visual Studio\2022\Enterprise"
|
|
||||||
$componentsToAdd = @(
|
|
||||||
"Microsoft.VisualStudio.Component.WinXP"
|
|
||||||
)
|
|
||||||
[string]$workloadArgs = $componentsToAdd | ForEach-Object {" --add " + $_}
|
|
||||||
$Arguments = ('/c', "vs_installer.exe", 'modify', '--installPath', "`"$InstallPath`"",$workloadArgs, '--quiet', '--norestart', '--nocache')
|
|
||||||
$process = Start-Process -FilePath cmd.exe -ArgumentList $Arguments -Wait -PassThru -WindowStyle Hidden
|
|
||||||
if ($process.ExitCode -eq 0)
|
|
||||||
{
|
|
||||||
Write-Host "components have been successfully added"
|
|
||||||
Get-ChildItem C:\ProgramData\Microsoft\VisualStudio\Packages\Microsoft.Windows.XPSupport.*
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Write-Host "components were not installed"
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
|
|
||||||
- name: Checkout Source Tree
|
- name: Checkout Source Tree
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
- name: Setup MSBuild
|
- name: Setup folder directories
|
||||||
uses: microsoft/setup-msbuild@v1
|
run: |
|
||||||
|
mkdir build
|
||||||
|
mkdir build\x86
|
||||||
|
mkdir build\x64
|
||||||
|
|
||||||
- name: Build xpmgr (x86)
|
- name: Build xpmgr (x86)
|
||||||
run: msbuild xpmgr.vcxproj /P:Configuration=Release /P:Platform=Win32
|
run: g++ -m32 -o build\x86\xpmgr_x86 xpmgr.cpp -lole32 -luuid -loleaut32
|
||||||
|
|
||||||
- name: Build xpmgr (x64)
|
- name: Build xpmgr (x64)
|
||||||
run: msbuild xpmgr.vcxproj /P:Configuration=Release /P:Platform=x64
|
run: g++ -o build\x64\xpmgr_x64 xpmgr.cpp -lole32 -luuid -loleaut32
|
||||||
|
|
||||||
- name: Upload build artifact (x86)
|
- name: Upload build artifact (x86)
|
||||||
uses: actions/upload-artifact@v3.1.2
|
uses: actions/upload-artifact@v3.1.2
|
||||||
with:
|
with:
|
||||||
name: xpmgr (x86)
|
name: xpmgr (x86)
|
||||||
path: .\Win32\Release
|
path: .\build\x86
|
||||||
|
|
||||||
- name: Upload build artifact (x64)
|
- name: Upload build artifact (x64)
|
||||||
uses: actions/upload-artifact@v3.1.2
|
uses: actions/upload-artifact@v3.1.2
|
||||||
with:
|
with:
|
||||||
name: xpmgr (x64)
|
name: xpmgr (x64)
|
||||||
path: .\x64\Release
|
path: .\build\x64
|
||||||
|
|
|
@ -32,6 +32,8 @@ bld/
|
||||||
[Oo]ut/
|
[Oo]ut/
|
||||||
[Ll]og/
|
[Ll]og/
|
||||||
[Ll]ogs/
|
[Ll]ogs/
|
||||||
|
[Bb]uild/
|
||||||
|
cmake-build-debug/
|
||||||
|
|
||||||
# Visual Studio 2015/2017 cache/options directory
|
# Visual Studio 2015/2017 cache/options directory
|
||||||
.vs/
|
.vs/
|
||||||
|
|
|
@ -0,0 +1,8 @@
|
||||||
|
# Default ignored files
|
||||||
|
/shelf/
|
||||||
|
/workspace.xml
|
||||||
|
# Editor-based HTTP Client requests
|
||||||
|
/httpRequests/
|
||||||
|
# Datasource local storage ignored files
|
||||||
|
/dataSources/
|
||||||
|
/dataSources.local.xml
|
|
@ -0,0 +1,4 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="CMakeWorkspace" PROJECT_DIR="$PROJECT_DIR$" />
|
||||||
|
</project>
|
|
@ -0,0 +1,8 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="ProjectModuleManager">
|
||||||
|
<modules>
|
||||||
|
<module fileurl="file://$PROJECT_DIR$/.idea/xpmgr.iml" filepath="$PROJECT_DIR$/.idea/xpmgr.iml" />
|
||||||
|
</modules>
|
||||||
|
</component>
|
||||||
|
</project>
|
|
@ -0,0 +1,6 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="VcsDirectoryMappings">
|
||||||
|
<mapping directory="" vcs="Git" />
|
||||||
|
</component>
|
||||||
|
</project>
|
|
@ -0,0 +1,2 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<module classpath="CMake" type="CPP_MODULE" version="4" />
|
|
@ -0,0 +1,3 @@
|
||||||
|
14037188531115461057117122732036502128316172554233
|
||||||
|
|
||||||
|
115654-870803-633253-538651-586936-689612-768696
|
55
xpmgr.cpp
55
xpmgr.cpp
|
@ -2,13 +2,10 @@ typedef struct IUnknown IUnknown;
|
||||||
|
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <comutil.h>
|
#include <comdef.h>
|
||||||
#include <regex>
|
#include <regex>
|
||||||
#include <TlHelp32.h>
|
#include <TlHelp32.h>
|
||||||
|
|
||||||
#pragma comment(lib, "comsuppw.lib")
|
|
||||||
#pragma comment(lib, "kernel32.lib")
|
|
||||||
|
|
||||||
// Check windows
|
// Check windows
|
||||||
#if _WIN32 || _WIN64
|
#if _WIN32 || _WIN64
|
||||||
#if _WIN64
|
#if _WIN64
|
||||||
|
@ -286,7 +283,7 @@ static BOOL O2003_LoadLicenseManager()
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma region Internals
|
#pragma region Internals
|
||||||
bool RegistryKeyExists(HKEY rootKey, const wchar_t* keyPath) {
|
bool RegistryKeyExists(HKEY rootKey, const char* keyPath) {
|
||||||
HKEY hKey;
|
HKEY hKey;
|
||||||
LSTATUS result = RegOpenKeyEx(rootKey, keyPath, 0, KEY_READ, &hKey);
|
LSTATUS result = RegOpenKeyEx(rootKey, keyPath, 0, KEY_READ, &hKey);
|
||||||
|
|
||||||
|
@ -353,6 +350,31 @@ OLECHAR SizeToOLECHAR(size_t value)
|
||||||
return oChar;
|
return oChar;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BSTR ConvertToBSTR(const std::string& str) {
|
||||||
|
int size = MultiByteToWideChar(CP_UTF8, 0, str.c_str(), -1, NULL, 0);
|
||||||
|
BSTR bstr = SysAllocStringLen(NULL, size - 1);
|
||||||
|
MultiByteToWideChar(CP_UTF8, 0, str.c_str(), -1, bstr, size);
|
||||||
|
return bstr;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string ConvertToStdString(BSTR bstr) {
|
||||||
|
int size = WideCharToMultiByte(CP_UTF8, 0, bstr, -1, NULL, 0, NULL, NULL);
|
||||||
|
char* buffer = new char[size];
|
||||||
|
WideCharToMultiByte(CP_UTF8, 0, bstr, -1, buffer, size, NULL, NULL);
|
||||||
|
|
||||||
|
std::string result(buffer);
|
||||||
|
delete[] buffer;
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
BSTR ConvertCharToBSTR(const char* charString) {
|
||||||
|
int size = MultiByteToWideChar(CP_UTF8, 0, charString, -1, NULL, 0);
|
||||||
|
BSTR bstr = SysAllocStringLen(NULL, size - 1);
|
||||||
|
MultiByteToWideChar(CP_UTF8, 0, charString, -1, bstr, size);
|
||||||
|
return bstr;
|
||||||
|
}
|
||||||
|
|
||||||
bool IsProcessRunning(const wchar_t* processName)
|
bool IsProcessRunning(const wchar_t* processName)
|
||||||
{
|
{
|
||||||
HANDLE snapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
|
HANDLE snapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
|
||||||
|
@ -508,7 +530,7 @@ static BSTR XP_SetConfirmationID(BSTR confirmationID) {
|
||||||
for (size_t i = 0; i < inputString.length(); i += 6) {
|
for (size_t i = 0; i < inputString.length(); i += 6) {
|
||||||
std::string substring = inputString.substr(i, 6);
|
std::string substring = inputString.substr(i, 6);
|
||||||
const char* cstr = substring.c_str();
|
const char* cstr = substring.c_str();
|
||||||
if (0 != wcscmp(XP_VerifyCheckDigits(_com_util::ConvertStringToBSTR(cstr)), L"Successfully verified CID chunk")) {
|
if (0 != wcscmp(XP_VerifyCheckDigits(ConvertCharToBSTR(cstr)), L"Successfully verified CID chunk")) {
|
||||||
return SysAllocString(L"An error occurred at XP_VerifyCheckDigits: Check for misspelling");
|
return SysAllocString(L"An error occurred at XP_VerifyCheckDigits: Check for misspelling");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -623,7 +645,7 @@ static BSTR O2003_SetConfirmationID(BSTR confirmationID) {
|
||||||
for (size_t i = 0; i < inputString.length(); i += 6) {
|
for (size_t i = 0; i < inputString.length(); i += 6) {
|
||||||
std::string substring = inputString.substr(i, 6);
|
std::string substring = inputString.substr(i, 6);
|
||||||
const char* cstr = substring.c_str();
|
const char* cstr = substring.c_str();
|
||||||
if (0 != wcscmp(XP_VerifyCheckDigits(_com_util::ConvertStringToBSTR(cstr)), L"Successfully verified CID chunk")) {
|
if (0 != wcscmp(XP_VerifyCheckDigits(ConvertToBSTR(cstr)), L"Successfully verified CID chunk")) {
|
||||||
return SysAllocString(L"An error occurred at XP_VerifyCheckDigits: Check for misspelling");
|
return SysAllocString(L"An error occurred at XP_VerifyCheckDigits: Check for misspelling");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -683,7 +705,7 @@ int main(int argc, char* argv[])
|
||||||
|
|
||||||
if (cmdOptionExists(argv, argv + argc, "--Office2003")) {
|
if (cmdOptionExists(argv, argv + argc, "--Office2003")) {
|
||||||
#ifdef ENVIRONMENT32
|
#ifdef ENVIRONMENT32
|
||||||
if (RegistryKeyExists(HKEY_CLASSES_ROOT, L"CLSID\\{000C0114-0000-0000-C000-000000000046}")) {
|
if (RegistryKeyExists(HKEY_CLASSES_ROOT, "CLSID\\{000C0114-0000-0000-C000-000000000046}")) {
|
||||||
specifiedProduct = "Office2003";
|
specifiedProduct = "Office2003";
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -749,18 +771,18 @@ int main(int argc, char* argv[])
|
||||||
|
|
||||||
if (cmdOptionExists(argv, argv + argc, "--GetInstallationID")) {
|
if (cmdOptionExists(argv, argv + argc, "--GetInstallationID")) {
|
||||||
if (specifiedProduct == "Office2003") {
|
if (specifiedProduct == "Office2003") {
|
||||||
std::cout << _com_util::ConvertBSTRToString(O2003_GetInstallationID());
|
std::cout << ConvertToStdString(O2003_GetInstallationID());
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
std::cout << _com_util::ConvertBSTRToString(XP_GetInstallationID());
|
std::cout << ConvertToStdString(XP_GetInstallationID());
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
else if (cmdOptionExists(argv, argv + argc, "--SetConfirmationID")) {
|
else if (cmdOptionExists(argv, argv + argc, "--SetConfirmationID")) {
|
||||||
if (specifiedProduct == "Office2003") {
|
if (specifiedProduct == "Office2003") {
|
||||||
std::cout << _com_util::ConvertBSTRToString(O2003_SetConfirmationID(_com_util::ConvertStringToBSTR(getCmdOption(argv, argv + argc, "--SetConfirmationID"))));
|
std::cout << ConvertToStdString(O2003_SetConfirmationID(ConvertCharToBSTR(getCmdOption(argv, argv + argc, "--SetConfirmationID"))));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
std::cout << _com_util::ConvertBSTRToString(XP_SetConfirmationID(_com_util::ConvertStringToBSTR(getCmdOption(argv, argv + argc, "--SetConfirmationID"))));
|
std::cout << ConvertToStdString(XP_SetConfirmationID(ConvertCharToBSTR(getCmdOption(argv, argv + argc, "--SetConfirmationID"))));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -769,7 +791,7 @@ int main(int argc, char* argv[])
|
||||||
std::cout << "An error occurred at specifiedProduct: This command is for Windows management only.";
|
std::cout << "An error occurred at specifiedProduct: This command is for Windows management only.";
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
std::cout << _com_util::ConvertBSTRToString(XP_GetWPALeft());
|
std::cout << ConvertToStdString(XP_GetWPALeft());
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
else if (cmdOptionExists(argv, argv + argc, "--GetEvalLeft")) {
|
else if (cmdOptionExists(argv, argv + argc, "--GetEvalLeft")) {
|
||||||
|
@ -777,7 +799,7 @@ int main(int argc, char* argv[])
|
||||||
std::cout << "An error occurred at specifiedProduct: This command is for Windows management only.";
|
std::cout << "An error occurred at specifiedProduct: This command is for Windows management only.";
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
std::cout << _com_util::ConvertBSTRToString(XP_GetEvalLeft());
|
std::cout << ConvertToStdString(XP_GetEvalLeft());
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -786,7 +808,7 @@ int main(int argc, char* argv[])
|
||||||
std::cout << "An error occurred at specifiedProduct: This command is for Windows management only.";
|
std::cout << "An error occurred at specifiedProduct: This command is for Windows management only.";
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
std::cout << _com_util::ConvertBSTRToString(XP_SetProductKey(convertCharArrayToLPCWSTR(getCmdOption(argv, argv + argc, "--SetProductKey"))));
|
std::cout << ConvertToStdString(XP_SetProductKey(convertCharArrayToLPCWSTR(getCmdOption(argv, argv + argc, "--SetProductKey"))));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
else if (cmdOptionExists(argv, argv + argc, "--GetProductID")) {
|
else if (cmdOptionExists(argv, argv + argc, "--GetProductID")) {
|
||||||
|
@ -794,7 +816,7 @@ int main(int argc, char* argv[])
|
||||||
std::cout << "An error occurred at specifiedProduct: This command is for Windows management only.";
|
std::cout << "An error occurred at specifiedProduct: This command is for Windows management only.";
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
std::cout << _com_util::ConvertBSTRToString(XP_GetProductID());
|
std::cout << ConvertToStdString(XP_GetProductID());
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -802,5 +824,4 @@ int main(int argc, char* argv[])
|
||||||
std::cout << text;
|
std::cout << text;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return 0;
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue