diff --git a/xpmgr.cpp b/xpmgr.cpp index 48675b8..f0bd42a 100644 --- a/xpmgr.cpp +++ b/xpmgr.cpp @@ -21,7 +21,6 @@ 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 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} }; @@ -45,56 +44,56 @@ DECLARE_INTERFACE_(ICOMLicenseAgent, IDispatch) /*** ICOMLicenseAgent methods ***/ STDMETHOD(Initialize)(THIS_ ULONG dwBPC, ULONG dwMode, BSTR bstrLicSource, ULONG * pdwRetCode) PURE; - STDMETHOD(GetFirstName)(THIS_ BSTR * pbstrVal) PURE; // implemented - STDMETHOD(SetFirstName)(THIS_ BSTR bstrNewVal) PURE; // implemented - STDMETHOD(GetLastName)(THIS_ BSTR * pbstrVal) PURE; // implemented - STDMETHOD(SetLastName)(THIS_ BSTR bstrNewVal) PURE; // implemented - STDMETHOD(GetOrgName)(THIS_ BSTR * pbstrVal) PURE; // implemented - STDMETHOD(SetOrgName)(THIS_ BSTR bstrNewVal) PURE; // implemented - STDMETHOD(GetEmail)(THIS_ BSTR * pbstrVal) PURE; // implemented - STDMETHOD(SetEmail)(THIS_ BSTR bstrNewVal) PURE; // implemented - STDMETHOD(GetPhone)(THIS_ BSTR * pbstrVal) PURE; // implemented - STDMETHOD(SetPhone)(THIS_ BSTR bstrNewVal) PURE; // implemented - STDMETHOD(GetAddress1)(THIS_ BSTR * pbstrVal) PURE; // implemented - STDMETHOD(SetAddress1)(THIS_ BSTR bstrNewVal) PURE; // implemented - STDMETHOD(GetCity)(THIS_ BSTR * pbstrVal) PURE; // implemented - STDMETHOD(SetCity)(THIS_ BSTR bstrNewVal) PURE; // implemented - STDMETHOD(GetState)(THIS_ BSTR * pbstrVal) PURE; // implemented - STDMETHOD(SetState)(THIS_ BSTR bstrNewVal) PURE; // implemented - STDMETHOD(GetCountryCode)(THIS_ BSTR * pbstrVal) PURE; // implemented - STDMETHOD(SetCountryCode)(THIS_ BSTR bstrNewVal) PURE; // implemented - STDMETHOD(GetCountryDesc)(THIS_ BSTR * pbstrVal) PURE; // implemented - STDMETHOD(SetCountryDesc)(THIS_ BSTR bstrNewVal) PURE; // implemented - STDMETHOD(GetZip)(THIS_ BSTR * pbstrVal) PURE; // implemented - STDMETHOD(SetZip)(THIS_ BSTR bstrNewVal) PURE; // implemented - STDMETHOD(GetIsoLanguage)(THIS_ ULONG * pdwVal) PURE; // implemented - STDMETHOD(SetIsoLanguage)(THIS_ ULONG dwNewVal) PURE; // implemented - STDMETHOD(GetMSUpdate)(THIS_ BSTR * pbstrVal) PURE; // implemented - STDMETHOD(SetMSUpdate)(THIS_ BSTR bstrNewVal) PURE; // implemented - STDMETHOD(GetMSOffer)(THIS_ BSTR * pbstrVal) PURE; // implemented - STDMETHOD(SetMSOffer)(THIS_ BSTR bstrNewVal) PURE; // implemented - STDMETHOD(GetOtherOffer)(THIS_ BSTR * pbstrVal) PURE; // implemented - STDMETHOD(SetOtherOffer)(THIS_ BSTR bstrNewVal) PURE; // implemented - STDMETHOD(GetAddress2)(THIS_ BSTR * pbstrVal) PURE; // implemented - STDMETHOD(SetAddress2)(THIS_ BSTR bstrNewVal) PURE; // implemented + STDMETHOD(GetFirstName)(THIS_ BSTR * pbstrVal) PURE; + STDMETHOD(SetFirstName)(THIS_ BSTR bstrNewVal) PURE; + STDMETHOD(GetLastName)(THIS_ BSTR * pbstrVal) PURE; + STDMETHOD(SetLastName)(THIS_ BSTR bstrNewVal) PURE; + STDMETHOD(GetOrgName)(THIS_ BSTR * pbstrVal) PURE; + STDMETHOD(SetOrgName)(THIS_ BSTR bstrNewVal) PURE; + STDMETHOD(GetEmail)(THIS_ BSTR * pbstrVal) PURE; + STDMETHOD(SetEmail)(THIS_ BSTR bstrNewVal) PURE; + STDMETHOD(GetPhone)(THIS_ BSTR * pbstrVal) PURE; + STDMETHOD(SetPhone)(THIS_ BSTR bstrNewVal) PURE; + STDMETHOD(GetAddress1)(THIS_ BSTR * pbstrVal) PURE; + STDMETHOD(SetAddress1)(THIS_ BSTR bstrNewVal) PURE; + STDMETHOD(GetCity)(THIS_ BSTR * pbstrVal) PURE; + STDMETHOD(SetCity)(THIS_ BSTR bstrNewVal) PURE; + STDMETHOD(GetState)(THIS_ BSTR * pbstrVal) PURE; + STDMETHOD(SetState)(THIS_ BSTR bstrNewVal) PURE; + STDMETHOD(GetCountryCode)(THIS_ BSTR * pbstrVal) PURE; + STDMETHOD(SetCountryCode)(THIS_ BSTR bstrNewVal) PURE; + STDMETHOD(GetCountryDesc)(THIS_ BSTR * pbstrVal) PURE; + STDMETHOD(SetCountryDesc)(THIS_ BSTR bstrNewVal) PURE; + STDMETHOD(GetZip)(THIS_ BSTR * pbstrVal) PURE; + STDMETHOD(SetZip)(THIS_ BSTR bstrNewVal) PURE; + STDMETHOD(GetIsoLanguage)(THIS_ ULONG * pdwVal) PURE; + STDMETHOD(SetIsoLanguage)(THIS_ ULONG dwNewVal) PURE; + STDMETHOD(GetMSUpdate)(THIS_ BSTR * pbstrVal) PURE; + STDMETHOD(SetMSUpdate)(THIS_ BSTR bstrNewVal) PURE; + STDMETHOD(GetMSOffer)(THIS_ BSTR * pbstrVal) PURE; + STDMETHOD(SetMSOffer)(THIS_ BSTR bstrNewVal) PURE; + STDMETHOD(GetOtherOffer)(THIS_ BSTR * pbstrVal) PURE; + STDMETHOD(SetOtherOffer)(THIS_ BSTR bstrNewVal) PURE; + STDMETHOD(GetAddress2)(THIS_ BSTR * pbstrVal) PURE; + STDMETHOD(SetAddress2)(THIS_ BSTR bstrNewVal) PURE; STDMETHOD(AsyncProcessHandshakeRequest)(THIS_ LONG bReviseCustInfo) PURE; STDMETHOD(AsyncProcessNewLicenseRequest)(THIS) PURE; STDMETHOD(AsyncProcessReissueLicenseRequest)(THIS) PURE; STDMETHOD(AsyncProcessReviseCustInfoRequest)(THIS) PURE; STDMETHOD(GetAsyncProcessReturnCode)(THIS_ ULONG * pdwRetCode) PURE; STDMETHOD(AsyncProcessDroppedLicenseRequest)(THIS) PURE; - STDMETHOD(GenerateInstallationId)(THIS_ BSTR * pbstrVal) PURE; // implemented - STDMETHOD(DepositConfirmationId)(THIS_ BSTR bstrVal, ULONG * pdwRetCode) PURE; // implemented - STDMETHOD(GetExpirationInfo)(THIS_ ULONG * pdwWPALeft, ULONG * pdwEvalLeft) PURE; // implemented + STDMETHOD(GenerateInstallationId)(THIS_ BSTR * pbstrVal) PURE; + STDMETHOD(DepositConfirmationId)(THIS_ BSTR bstrVal, ULONG * pdwRetCode) PURE; + STDMETHOD(GetExpirationInfo)(THIS_ ULONG * pdwWPALeft, ULONG * pdwEvalLeft) PURE; STDMETHOD(AsyncProcessRegistrationRequest)(THIS) PURE; STDMETHOD(ProcessHandshakeRequest)(THIS_ LONG bReviseCustInfo) PURE; - STDMETHOD(ProcessNewLicenseRequest)(THIS) PURE; // implemented - STDMETHOD(ProcessDroppedLicenseRequest)(THIS) PURE; // implemented - STDMETHOD(ProcessReissueLicenseRequest)(THIS) PURE; // implemented - STDMETHOD(ProcessReviseCustInfoRequest)(THIS) PURE; // implemented - STDMETHOD(EnsureInternetConnection)(THIS) PURE; // implemented - STDMETHOD(SetProductKey)(THIS_ LPWSTR pszNewProductKey) PURE; // implemented - STDMETHOD(GetProductID)(THIS_ BSTR * pbstrVal) PURE; // implemented + STDMETHOD(ProcessNewLicenseRequest)(THIS) PURE; + STDMETHOD(ProcessDroppedLicenseRequest)(THIS) PURE; + STDMETHOD(ProcessReissueLicenseRequest)(THIS) PURE; + STDMETHOD(ProcessReviseCustInfoRequest)(THIS) PURE; + STDMETHOD(EnsureInternetConnection)(THIS) PURE; + STDMETHOD(SetProductKey)(THIS_ LPWSTR pszNewProductKey) PURE; + STDMETHOD(GetProductID)(THIS_ BSTR * pbstrVal) PURE; STDMETHOD(VerifyCheckDigits)(THIS_ BSTR bstrCIDIID, LONG * pbValue) PURE; }; @@ -265,496 +264,6 @@ bool TerminateProcessByName(const wchar_t* processName) #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()) { @@ -921,147 +430,14 @@ static BSTR GetProductID() { } #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"; @@ -1098,154 +474,9 @@ int main(int argc, char* argv[]) return 0; } } - free(&info); + //free(&info); - // For some reason, anything Microsoft Registration related just doesn't work - //if (cmdOptionExists(argv, argv + argc, "--GetFirstName")) { - // std::cout << _com_util::ConvertBSTRToString(GetFirstName()); - // return 0; - //} - //else if (cmdOptionExists(argv, argv + argc, "--SetFirstName")) { - // std::cout << _com_util::ConvertBSTRToString(SetFirstName(_com_util::ConvertStringToBSTR(getCmdOption(argv, argv + argc, "--SetFirstName")))); - // return 0; - //} - // - //else if (cmdOptionExists(argv, argv + argc, "--GetLastName")) { - // std::cout << _com_util::ConvertBSTRToString(GetLastName()); - // return 0; - //} - //else if (cmdOptionExists(argv, argv + argc, "--SetLastName")) { - // std::cout << _com_util::ConvertBSTRToString(SetLastName(_com_util::ConvertStringToBSTR(getCmdOption(argv, argv + argc, "--SetLastName")))); - // return 0; - //} - // - //else if (cmdOptionExists(argv, argv + argc, "--GetOrgName")) { - // std::cout << _com_util::ConvertBSTRToString(GetOrgName()); - // return 0; - //} - //else if (cmdOptionExists(argv, argv + argc, "--SetOrgName")) { - // std::cout << _com_util::ConvertBSTRToString(SetOrgName(_com_util::ConvertStringToBSTR(getCmdOption(argv, argv + argc, "--SetOrgName")))); - // return 0; - //} - // - //else if (cmdOptionExists(argv, argv + argc, "--GetEmail")) { - // std::cout << _com_util::ConvertBSTRToString(GetEmail()); - // return 0; - //} - //else if (cmdOptionExists(argv, argv + argc, "--SetEmail")) { - // std::cout << _com_util::ConvertBSTRToString(SetEmail(_com_util::ConvertStringToBSTR(getCmdOption(argv, argv + argc, "--SetEmail")))); - // return 0; - //} - // - //else if (cmdOptionExists(argv, argv + argc, "--GetPhone")) { - // std::cout << _com_util::ConvertBSTRToString(GetPhoneNumber()); - // return 0; - //} - //else if (cmdOptionExists(argv, argv + argc, "--SetPhone")) { - // std::cout << _com_util::ConvertBSTRToString(SetPhoneNumber(_com_util::ConvertStringToBSTR(getCmdOption(argv, argv + argc, "--SetPhone")))); - // return 0; - //} - // - //else if (cmdOptionExists(argv, argv + argc, "--GetAddress1")) { - // std::cout << _com_util::ConvertBSTRToString(GetAddress1()); - // return 0; - //} - //else if (cmdOptionExists(argv, argv + argc, "--SetAddress1")) { - // std::cout << _com_util::ConvertBSTRToString(SetAddress1(_com_util::ConvertStringToBSTR(getCmdOption(argv, argv + argc, "--SetAddress1")))); - // return 0; - //} - // - //else if (cmdOptionExists(argv, argv + argc, "--GetAddress2")) { - // std::cout << _com_util::ConvertBSTRToString(GetAddress2()); - // return 0; - //} - //else if (cmdOptionExists(argv, argv + argc, "--SetAddress2")) { - // std::cout << _com_util::ConvertBSTRToString(SetAddress2(_com_util::ConvertStringToBSTR(getCmdOption(argv, argv + argc, "--SetAddress2")))); - // return 0; - //} - // - //else if (cmdOptionExists(argv, argv + argc, "--GetCity")) { - // std::cout << _com_util::ConvertBSTRToString(GetCity()); - // return 0; - //} - //else if (cmdOptionExists(argv, argv + argc, "--SetCity")) { - // std::cout << _com_util::ConvertBSTRToString(SetCity(_com_util::ConvertStringToBSTR(getCmdOption(argv, argv + argc, "--SetCity")))); - // return 0; - //} - // - //else if (cmdOptionExists(argv, argv + argc, "--GetState")) { - // std::cout << _com_util::ConvertBSTRToString(GetState()); - // return 0; - //} - //else if (cmdOptionExists(argv, argv + argc, "--SetState")) { - // std::cout << _com_util::ConvertBSTRToString(SetState(_com_util::ConvertStringToBSTR(getCmdOption(argv, argv + argc, "--SetState")))); - // return 0; - //} - // - //else if (cmdOptionExists(argv, argv + argc, "--GetCountryCode")) { - // std::cout << _com_util::ConvertBSTRToString(GetCountryCode()); - // return 0; - //} - //else if (cmdOptionExists(argv, argv + argc, "--SetCountryCode")) { - // std::cout << _com_util::ConvertBSTRToString(SetCountryCode(_com_util::ConvertStringToBSTR(getCmdOption(argv, argv + argc, "--SetCountryCode")))); - // return 0; - //} - // - //else if (cmdOptionExists(argv, argv + argc, "--GetCountryDesc")) { - // std::cout << _com_util::ConvertBSTRToString(GetCountryDesc()); - // return 0; - //} - //else if (cmdOptionExists(argv, argv + argc, "--SetCountryDesc")) { - // std::cout << _com_util::ConvertBSTRToString(SetCountryDesc(_com_util::ConvertStringToBSTR(getCmdOption(argv, argv + argc, "--SetCountryDesc")))); - // return 0; - //} - // - //else if (cmdOptionExists(argv, argv + argc, "--GetZip")) { - // std::cout << _com_util::ConvertBSTRToString(GetZipCode()); - // return 0; - //} - //else if (cmdOptionExists(argv, argv + argc, "--SetZip")) { - // std::cout << _com_util::ConvertBSTRToString(SetZipCode(_com_util::ConvertStringToBSTR(getCmdOption(argv, argv + argc, "--SetZipCode")))); - // return 0; - //} - // - //else if (cmdOptionExists(argv, argv + argc, "--GetIsoLanguage")) { - // std::cout << _com_util::ConvertBSTRToString(GetIsoLanguage()); - // return 0; - //} - //else if (cmdOptionExists(argv, argv + argc, "--SetIsoLanguage")) { - // std::cout << _com_util::ConvertBSTRToString(SetIsoLanguage(_com_util::ConvertStringToBSTR(getCmdOption(argv, argv + argc, "--SetIsoLanguage")))); - // return 0; - //} - // - //else if (cmdOptionExists(argv, argv + argc, "--GetMSUpdate")) { - // std::cout << _com_util::ConvertBSTRToString(GetMSUpdate()); - // return 0; - //} - //else if (cmdOptionExists(argv, argv + argc, "--SetMSUpdate")) { - // std::cout << _com_util::ConvertBSTRToString(SetMSUpdate(_com_util::ConvertStringToBSTR(getCmdOption(argv, argv + argc, "--SetMSUpdate")))); - // return 0; - //} - // - //else if (cmdOptionExists(argv, argv + argc, "--GetMSOffer")) { - // std::cout << _com_util::ConvertBSTRToString(GetMSOffer()); - // return 0; - //} - //else if (cmdOptionExists(argv, argv + argc, "--SetMSOffer")) { - // std::cout << _com_util::ConvertBSTRToString(SetMSOffer(_com_util::ConvertStringToBSTR(getCmdOption(argv, argv + argc, "--SetMSOffer")))); - // return 0; - //} - // - //else if (cmdOptionExists(argv, argv + argc, "--GetOtherOffer")) { - // std::cout << _com_util::ConvertBSTRToString(GetOtherOffer()); - // return 0; - //} - //else if (cmdOptionExists(argv, argv + argc, "--SetOtherOffer")) { - // std::cout << _com_util::ConvertBSTRToString(SetOtherOffer(_com_util::ConvertStringToBSTR(getCmdOption(argv, argv + argc, "--SetOtherOffer")))); - // return 0; - //} - - /*else*/ if (cmdOptionExists(argv, argv + argc, "--GetInstallationID")) { + if (cmdOptionExists(argv, argv + argc, "--GetInstallationID")) { std::cout << _com_util::ConvertBSTRToString(GetInstallationID()); return 0; } @@ -1263,27 +494,6 @@ int main(int argc, char* argv[]) return 0; } - //else if (cmdOptionExists(argv, argv + argc, "--ProcNewLicense")) { - // std::cout << _com_util::ConvertBSTRToString(NewLicenseRequest()); - // return 0; - //} - //else if (cmdOptionExists(argv, argv + argc, "--ProcDropLicense")) { - // std::cout << _com_util::ConvertBSTRToString(DroppedLicenseRequest()); - // return 0; - //} - //else if (cmdOptionExists(argv, argv + argc, "--ProcReisLicense")) { - // std::cout << _com_util::ConvertBSTRToString(ReissueLicenseRequest()); - // return 0; - //} - //else if (cmdOptionExists(argv, argv + argc, "--ReviseCustInfo")) { - // std::cout << _com_util::ConvertBSTRToString(ReviseCustomerInfo()); - // return 0; - //} - //else if (cmdOptionExists(argv, argv + argc, "--CheckOnline")) { - // std::cout << _com_util::ConvertBSTRToString(EnsureInternetConnection()); - // return 0; - //} - else if (cmdOptionExists(argv, argv + argc, "--SetProductKey")) { std::cout << _com_util::ConvertBSTRToString(SetProductKey(convertCharArrayToLPCWSTR(getCmdOption(argv, argv + argc, "--SetProductKey")))); return 0;