Author SHA1 Message Date
TheTank20 c02f2ac27e Update README.md 2023-06-18 11:02:40 -05:00
thepwrtank18 25058b9cad Merge branch 'master' of https://github.com/UMSKT/xpmgr 2023-06-18 11:00:02 -05:00
thepwrtank18 545b33b4c0 added GetWPALeft and GetEvalLeft 2023-06-18 10:59:54 -05:00
TheTank20 fee22a67c6 Update README.md 2023-06-18 01:04:37 -05:00
2 changed files with 85 additions and 6 deletions

No files matched your search

+7
View File
@@ -10,8 +10,15 @@ Command line interface for Windows XP license management, inspired by Microsoft'
`--SetConfirmationID`: Sets a Confirmation ID (tested to work with dashes).
`--GetWPALeft`: Gets the number of days before activation is required, in days.
`--GetEvalLeft`: Gets the number of days before the evaluation period expires, in days. In most cases, this should be 2147483647.
Make sure you do commands right, since, as of now, there's no checking to make sure it's correct or not!
## Releases
https://github.com/UMSKT/xpmgr/releases
## Building
Due to GitHub not wanting to cooperate with auto-building for Windows XP (who would have thought?), you need to build it yourself.
+78 -6
View File
@@ -6,6 +6,8 @@
#include <commctrl.h>
#include <stdint.h>
#include <intrin.h>
#include <algorithm>
#include <atlconv.h>
#include <iostream>
#include <comutil.h>
@@ -141,6 +143,51 @@ static BOOL LoadLicenseManager()
return TRUE;
}
static BSTR GetWPALeft() {
if (!LoadLicenseManager()) {
return SysAllocString(L"Failed to load license manager");
}
ULONG dwWPALeft = 0, dwEvalLeft = 0;
HRESULT status = LicenseAgent->GetExpirationInfo(&dwWPALeft, &dwEvalLeft);
if (FAILED(status)) {
std::cout << "An error occurred at GetExpirationInfo: " + status;
LicenseAgent->Release();
LicenseAgent = NULL;
return SysAllocString(L"Failed to get expiration info");
}
if (dwWPALeft == 0x7FFFFFFF) {
std::cout << "An error occurred: dwWPALeft is 0x7FFFFFFF";
LicenseAgent->Release();
LicenseAgent = NULL;
return SysAllocString(L"Failed to get expiration info");
}
return SysAllocString(_bstr_t(dwWPALeft).Detach());
}
static BSTR GetEvalLeft() {
if (!LoadLicenseManager()) {
return SysAllocString(L"Failed to load license manager");
}
ULONG dwWPALeft = 0, dwEvalLeft = 0;
HRESULT status = LicenseAgent->GetExpirationInfo(&dwWPALeft, &dwEvalLeft);
if (FAILED(status)) {
std::cout << "An error occurred at GetExpirationInfo: " + status;
LicenseAgent->Release();
LicenseAgent = NULL;
return SysAllocString(L"Failed to get expiration info");
}
if (dwWPALeft == 0x7FFFFFFF) {
std::cout << "An error occurred: dwWPALeft is 0x7FFFFFFF";
LicenseAgent->Release();
LicenseAgent = NULL;
return SysAllocString(L"Failed to get expiration info");
}
return SysAllocString(_bstr_t(dwEvalLeft).Detach());
}
static BSTR SetConfirmationID(BSTR confirmationID) {
if (!LoadLicenseManager()) {
return SysAllocString(L"Failed to load license manager");
@@ -210,25 +257,50 @@ wchar_t* convertCharArrayToLPCWSTR(const char* charArray)
return wString;
}
char* getCmdOption(char** begin, char** end, const std::string& option)
{
char** itr = std::find(begin, end, option);
if (itr != end && ++itr != end)
{
return *itr;
}
return 0;
}
bool cmdOptionExists(char** begin, char** end, const std::string& option)
{
return std::find(begin, end, option) != end;
}
int main(int argc, char* argv[])
{
if (std::string(argv[1]) == "--GetInstallationID") {
if (cmdOptionExists(argv, argv+argc, "--GetInstallationID")) {
std::cout << _com_util::ConvertBSTRToString(GetInstallationID());
return 0;
}
else if (std::string(argv[1]) == "--SetConfirmationID") {
std::cout << _com_util::ConvertBSTRToString(SetConfirmationID(_com_util::ConvertStringToBSTR(argv[2])));
else if (cmdOptionExists(argv, argv + argc, "--SetConfirmationID")) {
std::cout << _com_util::ConvertBSTRToString(SetConfirmationID(_com_util::ConvertStringToBSTR(getCmdOption(argv, argv+argc, "--SetConfirmationID"))));
return 0;
}
else if (std::string(argv[1]) == "--SetProductKey") {
std::cout << _com_util::ConvertBSTRToString(SetProductKey(convertCharArrayToLPCWSTR(argv[2])));
else if (cmdOptionExists(argv, argv + argc, "--SetProductKey")) {
std::cout << _com_util::ConvertBSTRToString(SetProductKey(convertCharArrayToLPCWSTR(getCmdOption(argv, argv + argc, "--SetProductKey"))));
return 0;
}
else if (std::string(argv[1]) == "--GetProductID") {
else if (cmdOptionExists(argv, argv + argc, "--GetProductID")) {
std::cout << _com_util::ConvertBSTRToString(GetProductID());
return 0;
}
else if (cmdOptionExists(argv, argv + argc, "--GetWPALeft")) {
std::cout << _com_util::ConvertBSTRToString(GetWPALeft());
return 0;
}
else if (cmdOptionExists(argv, argv + argc, "--GetEvalLeft")) {
std::cout << _com_util::ConvertBSTRToString(GetEvalLeft());
return 0;
}
else {
std::cout << "Please put in arguments";
return 0;
}
return 0;
}