mirror of
https://github.com/UMSKT/xpmgr.git
synced 2026-11-05 22:47:54 +01:00
Compare commits
4
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c02f2ac27e | ||
|
|
25058b9cad | ||
|
|
545b33b4c0 | ||
|
|
fee22a67c6 |
No files matched your search
@@ -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).
|
`--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!
|
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
|
## Building
|
||||||
Due to GitHub not wanting to cooperate with auto-building for Windows XP (who would have thought?), you need to build it yourself.
|
Due to GitHub not wanting to cooperate with auto-building for Windows XP (who would have thought?), you need to build it yourself.
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,8 @@
|
|||||||
#include <commctrl.h>
|
#include <commctrl.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <intrin.h>
|
#include <intrin.h>
|
||||||
|
#include <algorithm>
|
||||||
|
#include <atlconv.h>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <comutil.h>
|
#include <comutil.h>
|
||||||
|
|
||||||
@@ -141,6 +143,51 @@ static BOOL LoadLicenseManager()
|
|||||||
return TRUE;
|
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) {
|
static BSTR SetConfirmationID(BSTR confirmationID) {
|
||||||
if (!LoadLicenseManager()) {
|
if (!LoadLicenseManager()) {
|
||||||
return SysAllocString(L"Failed to load license manager");
|
return SysAllocString(L"Failed to load license manager");
|
||||||
@@ -210,25 +257,50 @@ wchar_t* convertCharArrayToLPCWSTR(const char* charArray)
|
|||||||
return wString;
|
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[])
|
int main(int argc, char* argv[])
|
||||||
{
|
{
|
||||||
if (std::string(argv[1]) == "--GetInstallationID") {
|
if (cmdOptionExists(argv, argv+argc, "--GetInstallationID")) {
|
||||||
std::cout << _com_util::ConvertBSTRToString(GetInstallationID());
|
std::cout << _com_util::ConvertBSTRToString(GetInstallationID());
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
else if (std::string(argv[1]) == "--SetConfirmationID") {
|
else if (cmdOptionExists(argv, argv + argc, "--SetConfirmationID")) {
|
||||||
std::cout << _com_util::ConvertBSTRToString(SetConfirmationID(_com_util::ConvertStringToBSTR(argv[2])));
|
std::cout << _com_util::ConvertBSTRToString(SetConfirmationID(_com_util::ConvertStringToBSTR(getCmdOption(argv, argv+argc, "--SetConfirmationID"))));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
else if (std::string(argv[1]) == "--SetProductKey") {
|
else if (cmdOptionExists(argv, argv + argc, "--SetProductKey")) {
|
||||||
std::cout << _com_util::ConvertBSTRToString(SetProductKey(convertCharArrayToLPCWSTR(argv[2])));
|
std::cout << _com_util::ConvertBSTRToString(SetProductKey(convertCharArrayToLPCWSTR(getCmdOption(argv, argv + argc, "--SetProductKey"))));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
else if (std::string(argv[1]) == "--GetProductID") {
|
else if (cmdOptionExists(argv, argv + argc, "--GetProductID")) {
|
||||||
std::cout << _com_util::ConvertBSTRToString(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 {
|
else {
|
||||||
std::cout << "Please put in arguments";
|
std::cout << "Please put in arguments";
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user