From 85aaea76bfd6feafd21ddb81446ff2343a5620d3 Mon Sep 17 00:00:00 2001 From: TheTank20 <57580668+thepwrtank18@users.noreply.github.com> Date: Sat, 5 Aug 2023 17:21:37 -0500 Subject: [PATCH] Preparation of Office support --- xpmgr.cpp | 689 +++--------------------------------------------------- 1 file changed, 26 insertions(+), 663 deletions(-) diff --git a/xpmgr.cpp b/xpmgr.cpp index 48675b8..0f30521 100644 --- a/xpmgr.cpp +++ b/xpmgr.cpp @@ -1,5 +1,3 @@ -typedef struct IUnknown IUnknown; - #include #include #include @@ -18,18 +16,16 @@ typedef struct IUnknown IUnknown; #endif #endif +typedef struct IUnknown IUnknown; + // The magic numbers, interface, and LoadLicenseManager() function was made by diamondggg on MyDigitalLife. // LoadLicenseManager() was modified to suit a CLI rather than a GUI. // Everything else was either made by TheTank20 or copy pasted from StackOverflow. -static wchar_t strings[14][256]; +static CLSID xp_licdllCLSID = { 0xACADF079, 0xCBCD, 0x4032, {0x83, 0xF2, 0xFA, 0x47, 0xC4, 0xDB, 0x09, 0x6F} }; +static IID xp_licenseAgentIID = { 0xB8CBAD79, 0x3F1F, 0x481A, {0xBB, 0x0C, 0xE7, 0xBB, 0xD7, 0x7B, 0xDD, 0xD1} }; -static CLSID licdllCLSID = { 0xACADF079, 0xCBCD, 0x4032, {0x83, 0xF2, 0xFA, 0x47, 0xC4, 0xDB, 0x09, 0x6F} }; -static IID licenseAgentIID = { 0xB8CBAD79, 0x3F1F, 0x481A, {0xBB, 0x0C, 0xE7, 0xBB, 0xD7, 0x7B, 0xDD, 0xD1} }; -//IID for ICOMLicenseAgent2, with three extra functions -//static IID licenseAgentIID2 = {0x6A07C5A3, 0x9C67, 0x4BB6, {0xB0, 0x20, 0xEC, 0xBE, 0x7F, 0xDF, 0xD3, 0x26}}; - -#undef INTERFACE -#define INTERFACE ICOMLicenseAgent +#undef XP_INTERFACE +#define XP_INTERFACE ICOMLicenseAgent DECLARE_INTERFACE_(ICOMLicenseAgent, IDispatch) { /*** IUnknown methods ***/ @@ -98,31 +94,31 @@ DECLARE_INTERFACE_(ICOMLicenseAgent, IDispatch) STDMETHOD(VerifyCheckDigits)(THIS_ BSTR bstrCIDIID, LONG * pbValue) PURE; }; -static BOOL ComInitialized = FALSE; -static ICOMLicenseAgent* LicenseAgent = NULL; +static BOOL XP_ComInitialized = FALSE; +static ICOMLicenseAgent* XP_LicenseAgent = NULL; static BOOL LoadLicenseManager() { - if (!ComInitialized) { + if (!XP_ComInitialized) { HRESULT status = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED); if (FAILED(status)) { std::cout << "An error occurred at CoInitializeEx: ", status; return FALSE; } - ComInitialized = TRUE; + XP_ComInitialized = TRUE; } - if (!LicenseAgent) { - HRESULT status = CoCreateInstance(licdllCLSID, NULL, CLSCTX_INPROC_SERVER, licenseAgentIID, (void**)&LicenseAgent); + if (!XP_LicenseAgent) { + HRESULT status = CoCreateInstance(xp_licdllCLSID, NULL, CLSCTX_INPROC_SERVER, xp_licenseAgentIID, (void**)&XP_LicenseAgent); int good = 0; if (SUCCEEDED(status)) { ULONG dwRetCode; - status = LicenseAgent->Initialize(0xC475, 3, 0, &dwRetCode); + status = XP_LicenseAgent->Initialize(0xC475, 3, 0, &dwRetCode); if (SUCCEEDED(status) && dwRetCode == 0) { good = 1; } else { - LicenseAgent->Release(); - LicenseAgent = NULL; + XP_LicenseAgent->Release(); + XP_LicenseAgent = NULL; } } if (!good) { @@ -133,7 +129,6 @@ static BOOL LoadLicenseManager() return TRUE; } -#pragma region Internals wchar_t* convertCharArrayToLPCWSTR(const char* charArray) { wchar_t* wString = new wchar_t[4096]; @@ -263,509 +258,16 @@ bool TerminateProcessByName(const wchar_t* processName) return false; // Process not found } -#pragma endregion - -//#pragma region FirstName -//static BSTR GetFirstName() { -// if (!LoadLicenseManager()) { -// return SysAllocString(L"An error occurred at LoadLicenseManager: Failed to load"); -// } -// -// BSTR firstName = NULL; -// HRESULT status = LicenseAgent->GetFirstName(&firstName); -// if (FAILED(status) || !firstName) { -// std::cout << "An error occurred at GetFirstName: " + status; -// return SysAllocString(L"Failed to get first name"); -// } -// else { -// return firstName; -// } -//} -// -//static BSTR SetFirstName(BSTR firstName) { -// if (!LoadLicenseManager()) { -// return SysAllocString(L"An error occurred at LoadLicenseManager: Failed to load"); -// } -// -// HRESULT status = LicenseAgent->SetFirstName(firstName); -// if (FAILED(status)) { -// std::cout << "An error occurred at SetFirstName: " + status; -// return SysAllocString(L"Failed to set first name"); -// } -// return SysAllocString(L"Successfully set first name"); -//} -//#pragma endregion -// -//#pragma region LastName -//static BSTR GetLastName() { -// if (!LoadLicenseManager()) { -// return SysAllocString(L"An error occurred at LoadLicenseManager: Failed to load"); -// } -// -// BSTR lastName = NULL; -// HRESULT status = LicenseAgent->GetLastName(&lastName); -// if (FAILED(status) || !lastName) { -// std::cout << "An error occurred at GetLastName: " + status; -// return SysAllocString(L"Failed to get last name"); -// } -// else { -// return lastName; -// } -//} -// -//static BSTR SetLastName(BSTR lastName) { -// if (!LoadLicenseManager()) { -// return SysAllocString(L"An error occurred at LoadLicenseManager: Failed to load"); -// } -// -// HRESULT status = LicenseAgent->SetLastName(lastName); -// if (FAILED(status)) { -// std::cout << "An error occurred at SetLastName: " + status; -// return SysAllocString(L"Failed to set last name"); -// } -// return SysAllocString(L"Successfully set last name"); -//} -//#pragma endregion -// -//#pragma region OrgName -//static BSTR GetOrgName() { -// if (!LoadLicenseManager()) { -// return SysAllocString(L"An error occurred at LoadLicenseManager: Failed to load"); -// } -// -// BSTR orgName = NULL; -// HRESULT status = LicenseAgent->GetOrgName(&orgName); -// if (FAILED(status) || !orgName) { -// std::cout << "An error occurred at GetOrgName: " + status; -// return SysAllocString(L"Failed to get org name"); -// } -// else { -// return orgName; -// } -//} -// -//static BSTR SetOrgName(BSTR orgName) { -// if (!LoadLicenseManager()) { -// return SysAllocString(L"An error occurred at LoadLicenseManager: Failed to load"); -// } -// -// HRESULT status = LicenseAgent->SetOrgName(orgName); -// if (FAILED(status)) { -// std::cout << "An error occurred at SetOrgName: " + status; -// return SysAllocString(L"Failed to set org name"); -// } -// return SysAllocString(L"Successfully set org name"); -//} -//#pragma endregion -// -//#pragma region Email -//static BSTR GetEmail() { -// if (!LoadLicenseManager()) { -// return SysAllocString(L"An error occurred at LoadLicenseManager: Failed to load"); -// } -// -// BSTR email = NULL; -// HRESULT status = LicenseAgent->GetEmail(&email); -// if (FAILED(status) || !email) { -// std::cout << "An error occurred at GetEmail: " + status; -// return SysAllocString(L"Failed to get email"); -// } -// else { -// return email; -// } -//} -// -//static BSTR SetEmail(BSTR email) { -// if (!LoadLicenseManager()) { -// return SysAllocString(L"An error occurred at LoadLicenseManager: Failed to load"); -// } -// -// HRESULT status = LicenseAgent->SetEmail(email); -// if (FAILED(status)) { -// std::cout << "An error occurred at SetEmail: " + status; -// return SysAllocString(L"Failed to set email"); -// } -// return SysAllocString(L"Successfully set email"); -//} -//#pragma endregion -// -//#pragma region Addresses -//static BSTR GetAddress1() { -// if (!LoadLicenseManager()) { -// return SysAllocString(L"An error occurred at LoadLicenseManager: Failed to load"); -// } -// -// BSTR address1 = NULL; -// HRESULT status = LicenseAgent->GetAddress1(&address1); -// if (FAILED(status) || !address1) { -// std::cout << "An error occurred at GetAddress1: " + status; -// return SysAllocString(L"Failed to get 1st address"); -// } -// else { -// return address1; -// } -//} -// -//static BSTR SetAddress1(BSTR address1) { -// if (!LoadLicenseManager()) { -// return SysAllocString(L"An error occurred at LoadLicenseManager: Failed to load"); -// } -// -// HRESULT status = LicenseAgent->SetAddress1(address1); -// if (FAILED(status)) { -// std::cout << "An error occurred at SetAddress1: " + status; -// return SysAllocString(L"Failed to set 1st address"); -// } -// return SysAllocString(L"Successfully set 1st address"); -//} -// -//static BSTR GetAddress2() { -// if (!LoadLicenseManager()) { -// return SysAllocString(L"An error occurred at LoadLicenseManager: Failed to load"); -// } -// -// BSTR address2 = NULL; -// HRESULT status = LicenseAgent->GetAddress2(&address2); -// if (FAILED(status) || !address2) { -// std::cout << "An error occurred at GetAddress2: " + status; -// return SysAllocString(L"Failed to get 2nd address"); -// } -// else { -// return address2; -// } -//} -// -//static BSTR SetAddress2(BSTR address2) { -// if (!LoadLicenseManager()) { -// return SysAllocString(L"An error occurred at LoadLicenseManager: Failed to load"); -// } -// -// HRESULT status = LicenseAgent->SetAddress2(address2); -// if (FAILED(status)) { -// std::cout << "An error occurred at SetAddress2: " + status; -// return SysAllocString(L"Failed to set 2nd address"); -// } -// return SysAllocString(L"Successfully set 2nd address"); -//} -//#pragma endregion -// -//#pragma region PhoneNumber -//static BSTR GetPhoneNumber() { -// if (!LoadLicenseManager()) { -// return SysAllocString(L"An error occurred at LoadLicenseManager: Failed to load"); -// } -// -// BSTR phoneNumber = NULL; -// HRESULT status = LicenseAgent->GetPhone(&phoneNumber); -// if (FAILED(status) || !phoneNumber) { -// std::cout << "An error occurred at GetPhone: " + status; -// return SysAllocString(L"Failed to get phone number"); -// } -// else { -// return phoneNumber; -// } -//} -// -//static BSTR SetPhoneNumber(BSTR phoneNumber) { -// if (!LoadLicenseManager()) { -// return SysAllocString(L"An error occurred at LoadLicenseManager: Failed to load"); -// } -// -// HRESULT status = LicenseAgent->SetPhone(phoneNumber); -// if (FAILED(status)) { -// std::cout << "An error occurred at SetPhone: " + status; -// return SysAllocString(L"Failed to set phone number"); -// } -// return SysAllocString(L"Successfully set phone number"); -//} -//#pragma endregion -// -//#pragma region City -//static BSTR GetCity() { -// if (!LoadLicenseManager()) { -// return SysAllocString(L"An error occurred at LoadLicenseManager: Failed to load"); -// } -// -// BSTR city = NULL; -// HRESULT status = LicenseAgent->GetCity(&city); -// if (FAILED(status) || !city) { -// std::cout << "An error occurred at GetCity: " + status; -// return SysAllocString(L"Failed to get city"); -// } -// else { -// return city; -// } -//} -// -//static BSTR SetCity(BSTR city) { -// if (!LoadLicenseManager()) { -// return SysAllocString(L"An error occurred at LoadLicenseManager: Failed to load"); -// } -// -// HRESULT status = LicenseAgent->SetCity(city); -// if (FAILED(status)) { -// std::cout << "An error occurred at SetCity: " + status; -// return SysAllocString(L"Failed to set city"); -// } -// return SysAllocString(L"Successfully set city"); -//} -//#pragma endregion -// -//#pragma region State -//static BSTR GetState() { -// if (!LoadLicenseManager()) { -// return SysAllocString(L"An error occurred at LoadLicenseManager: Failed to load"); -// } -// -// BSTR state = NULL; -// HRESULT status = LicenseAgent->GetState(&state); -// if (FAILED(status) || !state) { -// std::cout << "An error occurred at GetState: " + status; -// return SysAllocString(L"Failed to get state"); -// } -// else { -// return state; -// } -//} -// -//static BSTR SetState(BSTR state) { -// if (!LoadLicenseManager()) { -// return SysAllocString(L"An error occurred at LoadLicenseManager: Failed to load"); -// } -// -// HRESULT status = LicenseAgent->SetState(state); -// if (FAILED(status)) { -// std::cout << "An error occurred at SetState: " + status; -// return SysAllocString(L"Failed to set state"); -// } -// return SysAllocString(L"Successfully set state"); -//} -//#pragma endregion -// -//#pragma region CountryCode -//static BSTR GetCountryCode() { -// if (!LoadLicenseManager()) { -// return SysAllocString(L"An error occurred at LoadLicenseManager: Failed to load"); -// } -// -// BSTR countryCode = NULL; -// HRESULT status = LicenseAgent->GetCountryCode(&countryCode); -// if (FAILED(status) || !countryCode) { -// std::cout << "An error occurred at GetCountryCode: " + status; -// return SysAllocString(L"Failed to get country code"); -// } -// else { -// return countryCode; -// } -//} -// -//static BSTR SetCountryCode(BSTR countryCode) { -// if (!LoadLicenseManager()) { -// return SysAllocString(L"An error occurred at LoadLicenseManager: Failed to load"); -// } -// -// HRESULT status = LicenseAgent->SetCountryCode(countryCode); -// if (FAILED(status)) { -// std::cout << "An error occurred at SetCountryCode: " + status; -// return SysAllocString(L"Failed to set country code"); -// } -// return SysAllocString(L"Successfully set country code"); -//} -//#pragma endregion -// -//#pragma region CountryDesc -//static BSTR GetCountryDesc() { -// if (!LoadLicenseManager()) { -// return SysAllocString(L"An error occurred at LoadLicenseManager: Failed to load"); -// } -// -// BSTR countryDesc = NULL; -// HRESULT status = LicenseAgent->GetCountryDesc(&countryDesc); -// if (FAILED(status) || !countryDesc) { -// std::cout << "An error occurred at GetCountryDesc: " + status; -// return SysAllocString(L"Failed to get country desc"); -// } -// else { -// return countryDesc; -// } -//} -// -//static BSTR SetCountryDesc(BSTR countryDesc) { -// if (!LoadLicenseManager()) { -// return SysAllocString(L"An error occurred at LoadLicenseManager: Failed to load"); -// } -// -// HRESULT status = LicenseAgent->SetCountryDesc(countryDesc); -// if (FAILED(status)) { -// std::cout << "An error occurred at SetCountryDesc: " + status; -// return SysAllocString(L"Failed to set country desc"); -// } -// return SysAllocString(L"Successfully set country desc"); -//} -//#pragma endregion -// -//#pragma region ZipCode -//static BSTR GetZipCode() { -// if (!LoadLicenseManager()) { -// return SysAllocString(L"An error occurred at LoadLicenseManager: Failed to load"); -// } -// -// BSTR zipCode = NULL; -// HRESULT status = LicenseAgent->GetZip(&zipCode); -// if (FAILED(status) || !zipCode) { -// std::cout << "An error occurred at GetZip: " + status; -// return SysAllocString(L"Failed to get zip code"); -// } -// else { -// return zipCode; -// } -//} -// -//static BSTR SetZipCode(BSTR zipCode) { -// if (!LoadLicenseManager()) { -// return SysAllocString(L"An error occurred at LoadLicenseManager: Failed to load"); -// } -// -// HRESULT status = LicenseAgent->SetZip(zipCode); -// if (FAILED(status)) { -// std::cout << "An error occurred at SetZip: " + status; -// return SysAllocString(L"Failed to set zip code"); -// } -// return SysAllocString(L"Successfully set zip code"); -//} -//#pragma endregion -// -//#pragma region IsoLanguage -//static BSTR GetIsoLanguage() { -// if (!LoadLicenseManager()) { -// return SysAllocString(L"An error occurred at LoadLicenseManager: Failed to load"); -// } -// -// ULONG isoLanguage = 0; -// HRESULT status = LicenseAgent->GetIsoLanguage(&isoLanguage); -// if (FAILED(status) || !isoLanguage) { -// std::cout << "An error occurred at GetIsoLanguage: " + status; -// return SysAllocString(L"Failed to get ISO language"); -// } -// else { -// return SysAllocString(_bstr_t(isoLanguage).Detach()); -// } -//} -// -//static BSTR SetIsoLanguage(BSTR isoLanguage) { -// if (!LoadLicenseManager()) { -// return SysAllocString(L"An error occurred at LoadLicenseManager: Failed to load"); -// } -// -// HRESULT status = LicenseAgent->SetIsoLanguage(ConvertToULONG(BstrToChar(isoLanguage))); -// if (FAILED(status)) { -// std::cout << "An error occurred at SetIsoLangage: " + status; -// return SysAllocString(L"Failed to set zip code"); -// } -// return SysAllocString(L"Successfully set zip codes"); -//} -//#pragma endregion -// -//#pragma region UpdatesAndOffers -//static BSTR GetMSUpdate() { -// if (!LoadLicenseManager()) { -// return SysAllocString(L"An error occurred at LoadLicenseManager: Failed to load"); -// } -// -// BSTR msUpdate = NULL; -// HRESULT status = LicenseAgent->GetMSUpdate(&msUpdate); -// if (FAILED(status) || !msUpdate) { -// std::cout << "An error occurred at GetMSUpdate: " + status; -// return SysAllocString(L"Failed to get MS Update"); -// } -// else { -// return msUpdate; -// } -//} -// -//static BSTR SetMSUpdate(BSTR msUpdate) { -// if (!LoadLicenseManager()) { -// return SysAllocString(L"An error occurred at LoadLicenseManager: Failed to load"); -// } -// -// HRESULT status = LicenseAgent->SetMSUpdate(msUpdate); -// if (FAILED(status)) { -// std::cout << "An error occurred at SetMSUpdate: " + status; -// return SysAllocString(L"Failed to set MS Update"); -// } -// return SysAllocString(L"Successfully set MS Update"); -//} -// -//static BSTR GetMSOffer() { -// if (!LoadLicenseManager()) { -// return SysAllocString(L"An error occurred at LoadLicenseManager: Failed to load"); -// } -// -// BSTR msOffer = NULL; -// HRESULT status = LicenseAgent->GetMSOffer(&msOffer); -// if (FAILED(status) || !msOffer) { -// std::cout << "An error occurred at GetMSOffer: " + status; -// return SysAllocString(L"Failed to get MS Offer"); -// } -// else { -// return msOffer; -// } -//} -// -//static BSTR SetMSOffer(BSTR msOffer) { -// if (!LoadLicenseManager()) { -// return SysAllocString(L"An error occurred at LoadLicenseManager: Failed to load"); -// } -// -// HRESULT status = LicenseAgent->SetMSOffer(msOffer); -// if (FAILED(status)) { -// std::cout << "An error occurred at SetMSOffer: " + status; -// return SysAllocString(L"Failed to set MS Offer"); -// } -// return SysAllocString(L"Successfully set MS Offer"); -//} -// -//static BSTR GetOtherOffer() { -// if (!LoadLicenseManager()) { -// return SysAllocString(L"An error occurred at LoadLicenseManager: Failed to load"); -// } -// -// BSTR otherOffer = NULL; -// HRESULT status = LicenseAgent->GetOtherOffer(&otherOffer); -// if (FAILED(status) || !otherOffer) { -// std::cout << "An error occurred at GetOtherOffer: " + status; -// return SysAllocString(L"Failed to get other offer"); -// } -// else { -// return otherOffer; -// } -//} -// -//static BSTR SetOtherOffer(BSTR otherOffer) { -// if (!LoadLicenseManager()) { -// return SysAllocString(L"An error occurred at LoadLicenseManager: Failed to load"); -// } -// -// HRESULT status = LicenseAgent->SetOtherOffer(otherOffer); -// if (FAILED(status)) { -// std::cout << "An error occurred at SetOtherOffer: " + status; -// return SysAllocString(L"Failed to set other offer"); -// } -// return SysAllocString(L"Successfully set other offer"); -//} -//#pragma endregion - -#pragma region ExpirationDate static BSTR GetWPALeft() { if (!LoadLicenseManager()) { return SysAllocString(L"An error occurred at LoadLicenseManager: Failed to load"); } ULONG dwWPALeft = 0, dwEvalLeft = 0; - HRESULT status = LicenseAgent->GetExpirationInfo(&dwWPALeft, &dwEvalLeft); + HRESULT status = XP_LicenseAgent->GetExpirationInfo(&dwWPALeft, &dwEvalLeft); if (FAILED(status)) { - LicenseAgent->Release(); - LicenseAgent = NULL; + XP_LicenseAgent->Release(); + XP_LicenseAgent = NULL; return SysAllocString(L"An error occurred at GetExpirationInfo: " + status); } if (dwWPALeft == 0x7FFFFFFF) { @@ -780,10 +282,10 @@ static BSTR GetEvalLeft() { } ULONG dwWPALeft = 0, dwEvalLeft = 0; - HRESULT status = LicenseAgent->GetExpirationInfo(&dwWPALeft, &dwEvalLeft); + HRESULT status = XP_LicenseAgent->GetExpirationInfo(&dwWPALeft, &dwEvalLeft); if (FAILED(status)) { - LicenseAgent->Release(); - LicenseAgent = NULL; + XP_LicenseAgent->Release(); + XP_LicenseAgent = NULL; return SysAllocString(L"An error occurred at GetExpirationInfo: " + status); } if (dwEvalLeft == 0x7FFFFFFF) { @@ -791,9 +293,6 @@ static BSTR GetEvalLeft() { } return SysAllocString(_bstr_t(dwEvalLeft).Detach()); } -#pragma endregion - -#pragma region OfflineActivation static BSTR VerifyCheckDigits(BSTR cidChunk) { if (!LoadLicenseManager()) { @@ -805,7 +304,7 @@ static BSTR VerifyCheckDigits(BSTR cidChunk) { } LONG pbValue; - HRESULT status = LicenseAgent->VerifyCheckDigits(cidChunk, &pbValue); + HRESULT status = XP_LicenseAgent->VerifyCheckDigits(cidChunk, &pbValue); if (FAILED(status) || !pbValue) { return SysAllocString(L"An error occurred at VerifyCheckDigits: " + pbValue); } @@ -843,7 +342,7 @@ static BSTR SetConfirmationID(BSTR confirmationID) { free(&inputString); ULONG dwRetCode; - HRESULT status = LicenseAgent->DepositConfirmationId(confirmationID, &dwRetCode); + HRESULT status = XP_LicenseAgent->DepositConfirmationId(confirmationID, &dwRetCode); if (FAILED(status) || dwRetCode) { return SysAllocString(L"An error occurred at DepositConfirmationId: " + status + dwRetCode); } @@ -867,7 +366,7 @@ static BSTR GetInstallationID() { } BSTR installationID = NULL; - HRESULT status = LicenseAgent->GenerateInstallationId(&installationID); + HRESULT status = XP_LicenseAgent->GenerateInstallationId(&installationID); if (FAILED(status) || !installationID) { return SysAllocString(L"An error occurred at GenerateInstallationId: " + status); } @@ -875,9 +374,7 @@ static BSTR GetInstallationID() { return installationID; } } -#pragma endregion -#pragma region ProductKeyAndID static BSTR SetProductKey(LPWSTR productKey) { if (!LoadLicenseManager()) { return SysAllocString(L"An error occurred at LoadLicenseManager: Failed to load"); @@ -895,7 +392,7 @@ static BSTR SetProductKey(LPWSTR productKey) { return SysAllocString(L"An error occurred at GetWPALeft: Windows is activated"); } - HRESULT status = LicenseAgent->SetProductKey(productKey); + HRESULT status = XP_LicenseAgent->SetProductKey(productKey); if (FAILED(status)) { return SysAllocString(L"An error occurred at SetProductKey: " + status); } @@ -911,7 +408,7 @@ static BSTR GetProductID() { BSTR productID = NULL; - HRESULT status = LicenseAgent->GetProductID(&productID); + HRESULT status = XP_LicenseAgent->GetProductID(&productID); if (FAILED(status)) { return SysAllocString(L"An error occurred at GetProductID: " + status); } @@ -919,149 +416,15 @@ static BSTR GetProductID() { return productID; } } -#pragma endregion - -//#pragma region OnlineActivation -//static BSTR EnsureInternetConnection() { -// if (!LoadLicenseManager()) { -// return SysAllocString(L"An error occurred at LoadLicenseManager: Failed to load"); -// } -// -// HRESULT status = LicenseAgent->EnsureInternetConnection(); -// if (FAILED(status)) { -// std::cout << "An error occurred at EnsureInternetConnection: " + status; -// return SysAllocString(L"Failed to ensure internet connection (offline?)"); -// } -// else { -// return SysAllocString(L"Connected to the Internet"); -// } -//} -// -//static BSTR NewLicenseRequest() { -// if (!LoadLicenseManager()) { -// return SysAllocString(L"An error occurred at LoadLicenseManager: Failed to load"); -// } -// -// if (EnsureInternetConnection() != SysAllocString(L"Connected to the Internet")) { -// return SysAllocString(L"Internet required to process new license request"); -// } -// -// HRESULT status = LicenseAgent->ProcessNewLicenseRequest(); -// if (FAILED(status)) { -// std::cout << "An error occurred at ProcessNewLicenseRequest: " + status; -// return SysAllocString(L"Failed to process new license request"); -// } -// else { -// return SysAllocString(L"Successfully processed new license request"); -// } -//} -// -//static BSTR DroppedLicenseRequest() { -// if (!LoadLicenseManager()) { -// return SysAllocString(L"An error occurred at LoadLicenseManager: Failed to load"); -// } -// -// if (EnsureInternetConnection() != SysAllocString(L"Connected to the Internet")) { -// return SysAllocString(L"Internet required to process dropped license request"); -// } -// -// HRESULT status = LicenseAgent->ProcessDroppedLicenseRequest(); -// if (FAILED(status)) { -// std::cout << "An error occurred at ProcessDroppedLicenseRequest: " + status; -// return SysAllocString(L"Failed to process dropped license request"); -// } -// else { -// return SysAllocString(L"Successfully processed dropped license request"); -// } -//} -// -//static BSTR ReissueLicenseRequest() { -// if (!LoadLicenseManager()) { -// return SysAllocString(L"An error occurred at LoadLicenseManager: Failed to load"); -// } -// -// if (EnsureInternetConnection() != SysAllocString(L"Connected to the Internet")) { -// return SysAllocString(L"Internet required to process reissue license request"); -// } -// -// HRESULT status = LicenseAgent->ProcessReissueLicenseRequest(); -// if (FAILED(status)) { -// std::cout << "An error occurred at ProcessReissueLicenseRequest: " + status; -// return SysAllocString(L"Failed to process reissue license request"); -// } -// else { -// return SysAllocString(L"Successfully processed reissue license request"); -// } -//} -// -//static BSTR ReviseCustomerInfo() { -// if (!LoadLicenseManager()) { -// return SysAllocString(L"An error occurred at LoadLicenseManager: Failed to load"); -// } -// -// if (EnsureInternetConnection() != SysAllocString(L"Connected to the Internet")) { -// return SysAllocString(L"Internet required to revise customer info"); -// } -// -// HRESULT status = LicenseAgent->ProcessReviseCustInfoRequest(); -// if (FAILED(status)) { -// std::cout << "An error occurred at ProcessReviseCustInfoRequest: " + status; -// return SysAllocString(L"Failed to revise customer info"); -// } -// else { -// return SysAllocString(L"Successfully revised customer info"); -// } -//} -// -//#pragma endregion - - int main(int argc, char* argv[]) { const char* text = "Usage: \n" - //"--GetFirstName: Gets first name registered in the system\n" - //"--SetFirstName [name]: Sets first name registered in the system\n" - //"--GetLastName: Gets last name registered in the system\n" - //"--SetLastName [name]: Sets last name registered in the system\n" - //"--GetOrgName: Gets organization name registered in the system\n" - //"--SetOrgName [name]: Sets organization name registered in the system\n" - //"--GetEmail: Gets email registered in the system\n" - //"--SetEmail [email@domain.net]: Sets email registered in the system\n" - //"--GetPhone: Gets phone number registered in the system\n" - //"--SetPhone [##########]: Sets phone number registered in the system\n" - //"--GetAddress1: Gets 1st address registered in the system\n" - //"--SetAddress1 [any string]: Sets 1st address registered in the system\n" - //"--GetAddress2: Gets 2nd address registered in the system\n" - //"--SetAddress2 [any string]: Sets 2nd address registered in the system\n" - //"--GetCity: Gets city registered in the system\n" - //"--SetCity [any string]: Sets city registered in the system\n" - //"--GetState: Gets state/province registered in the system\n" - //"--SetState [any string]: Sets state/province registered in the system\n" - //"--GetCountryCode: Gets country/region code registered in the system\n" - //"--SetCountryCode [xx-XX]: Sets country/region code registered in the system\n" - //"--GetCountryDesc: Gets country desc registered in the system\n" - //"--SetCountryDesc [?]: Sets country desc registered in the system\n" - //"--GetZip: Gets zip code registered in the system\n" - //"--SetZip [#####]: Sets zip code registered in the system\n" - //"--GetIsoLanguage: Gets ISO 3166-1 language code registered in the system\n" - //"--SetIsoLanguage [###]: Sets ISO 3166-1 language code registered in the system\n" - //"--GetMSUpdate: Gets whether Windows Update is enabled or not (?)\n" - //"--SetMSUpdate [?]: Sets whether Windows Update is enabled or not (?)\n" - //"--GetMSOffer: Gets if the user registered for offers from Microsoft or not\n" - //"--SetMSOffer [?]: Sets if the user registered for offers from Microsoft or not\n" - //"--GetOtherOffer: Gets if the user registered for offers from MS partners or not\n" - //"--SetOtherOffer [?]: Sets if the user registered for offers from MS partners or not\n" "--GetInstallationID: Gets the Installation ID\n" "--SetConfirmationID [cid]: Sets Confirmation ID (If successful, activates Windows)\n" "--GetWPALeft: Gets the days before activation is required (Grace period)\n" "--GetEvalLeft: Gets the days before the evaluation period expires (Eval. copies only)\n" - //"--ProcNewLicense: Processes new license request (Requires Internet connection)\n" - //"--ProcDropLicense: Processes dropped license request (Requires Internet connection)\n" - //"--ProcReisLicense: Processes reissue license request (Requires Internet connection)\n" - //"--ReviseCustInfo: Revise customer info (Requires Internet connection)\n" - //"--CheckOnline: Checks if connected to Microsoft's servers\n" "--SetProductKey [pkey]: Sets/changes product key\n" "--GetProductID: Gets the product ID of Windows\n" "--GetUsage: Displays this message";