WindowsXPKg/src/cli.h

98 lines
2.5 KiB
C
Raw Normal View History

/**
2023-06-17 00:58:22 +03:00
* This file is a part of the UMSKT Project
*
2023-06-17 00:58:22 +03:00
* Copyleft (C) 2019-2023 UMSKT Contributors (et.al.)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @FileCreated by Neo on 6/6/2023
* @Maintainer Neo
*/
2023-06-07 22:23:59 +03:00
2023-06-17 00:58:22 +03:00
#ifndef UMSKT_CLI_H
#define UMSKT_CLI_H
2023-06-07 22:23:59 +03:00
#include "header.h"
Refactor/Overhaul (#40) * major refactor/overhaul move generation implementation to libumskt/* decouple CLI/Options (and JSON) from generation implementation set groundwork for future shared library use standardized PIDGEN2/PIDGEN3 naming convention create a Windows Docker file for quick compilation add Windows resouce file/header so we have an application icon on windows use icon from @Endermanch (used with permission) add support for fully-static linux/muslc-based compilation add support for a dos/windows (i486+) binary using djgpp add Dockerfile to compile gcc/djgpp/watt32/openssl to provide DOS (DPMI) binaries add @Endermanch 's Vista+ documentation update Readme for recent credits * begin work on C linkage and emscripten buildpath * Update CMake to include and build Crypto++ * move dllmain.cpp to the correct directory * add rust port info to README.md * re-add dropped changes from rebase * update build config, specify windows XP version number for crypto++ * update dos-djgpp action to use new cmake builder and options * update dos-djgpp to use UMSKT hosted forks * update other workflows to include standard header * remove crypto++ from build config for now * use the new `shell` parameter in `threeal/cmake-action` TODO: move to a stable version (v1.3.0) when ready * use full commit hash because a shortened hash is unsupported * add the required {0} parameter? * add openssl 3.1.1 to windows github runners * ensure linux matrix build compiles on the correct arch --------- Co-authored-by: Neo <321592+Neo-Desktop@users.noreply.github.com>
2023-07-09 06:08:43 +03:00
#include <cmrc/cmrc.hpp>
#include "libumskt/libumskt.h"
#include "libumskt/pidgen2/PIDGEN2.h"
#include "libumskt/pidgen3/PIDGEN3.h"
#include "libumskt/pidgen3/BINK1998.h"
#include "libumskt/pidgen3/BINK2002.h"
#include "libumskt/confid/confid.h"
CMRC_DECLARE(umskt);
enum MODE {
MODE_BINK1998_GENERATE = 0,
MODE_BINK2002_GENERATE = 1,
2023-09-02 16:23:59 +03:00
MODE_CONFIRMATION_ID = 2,
Refactor/Overhaul (#40) * major refactor/overhaul move generation implementation to libumskt/* decouple CLI/Options (and JSON) from generation implementation set groundwork for future shared library use standardized PIDGEN2/PIDGEN3 naming convention create a Windows Docker file for quick compilation add Windows resouce file/header so we have an application icon on windows use icon from @Endermanch (used with permission) add support for fully-static linux/muslc-based compilation add support for a dos/windows (i486+) binary using djgpp add Dockerfile to compile gcc/djgpp/watt32/openssl to provide DOS (DPMI) binaries add @Endermanch 's Vista+ documentation update Readme for recent credits * begin work on C linkage and emscripten buildpath * Update CMake to include and build Crypto++ * move dllmain.cpp to the correct directory * add rust port info to README.md * re-add dropped changes from rebase * update build config, specify windows XP version number for crypto++ * update dos-djgpp action to use new cmake builder and options * update dos-djgpp to use UMSKT hosted forks * update other workflows to include standard header * remove crypto++ from build config for now * use the new `shell` parameter in `threeal/cmake-action` TODO: move to a stable version (v1.3.0) when ready * use full commit hash because a shortened hash is unsupported * add the required {0} parameter? * add openssl 3.1.1 to windows github runners * ensure linux matrix build compiles on the correct arch --------- Co-authored-by: Neo <321592+Neo-Desktop@users.noreply.github.com>
2023-07-09 06:08:43 +03:00
MODE_BINK1998_VALIDATE = 3,
MODE_BINK2002_VALIDATE = 4,
};
struct Options {
std::string binkid;
std::string keysFilename;
std::string instid;
std::string keyToCheck;
2023-09-02 16:23:59 +03:00
std::string productid;
Refactor/Overhaul (#40) * major refactor/overhaul move generation implementation to libumskt/* decouple CLI/Options (and JSON) from generation implementation set groundwork for future shared library use standardized PIDGEN2/PIDGEN3 naming convention create a Windows Docker file for quick compilation add Windows resouce file/header so we have an application icon on windows use icon from @Endermanch (used with permission) add support for fully-static linux/muslc-based compilation add support for a dos/windows (i486+) binary using djgpp add Dockerfile to compile gcc/djgpp/watt32/openssl to provide DOS (DPMI) binaries add @Endermanch 's Vista+ documentation update Readme for recent credits * begin work on C linkage and emscripten buildpath * Update CMake to include and build Crypto++ * move dllmain.cpp to the correct directory * add rust port info to README.md * re-add dropped changes from rebase * update build config, specify windows XP version number for crypto++ * update dos-djgpp action to use new cmake builder and options * update dos-djgpp to use UMSKT hosted forks * update other workflows to include standard header * remove crypto++ from build config for now * use the new `shell` parameter in `threeal/cmake-action` TODO: move to a stable version (v1.3.0) when ready * use full commit hash because a shortened hash is unsupported * add the required {0} parameter? * add openssl 3.1.1 to windows github runners * ensure linux matrix build compiles on the correct arch --------- Co-authored-by: Neo <321592+Neo-Desktop@users.noreply.github.com>
2023-07-09 06:08:43 +03:00
int channelID;
int serial;
int numKeys;
2023-08-10 09:45:50 +03:00
bool upgrade;
Refactor/Overhaul (#40) * major refactor/overhaul move generation implementation to libumskt/* decouple CLI/Options (and JSON) from generation implementation set groundwork for future shared library use standardized PIDGEN2/PIDGEN3 naming convention create a Windows Docker file for quick compilation add Windows resouce file/header so we have an application icon on windows use icon from @Endermanch (used with permission) add support for fully-static linux/muslc-based compilation add support for a dos/windows (i486+) binary using djgpp add Dockerfile to compile gcc/djgpp/watt32/openssl to provide DOS (DPMI) binaries add @Endermanch 's Vista+ documentation update Readme for recent credits * begin work on C linkage and emscripten buildpath * Update CMake to include and build Crypto++ * move dllmain.cpp to the correct directory * add rust port info to README.md * re-add dropped changes from rebase * update build config, specify windows XP version number for crypto++ * update dos-djgpp action to use new cmake builder and options * update dos-djgpp to use UMSKT hosted forks * update other workflows to include standard header * remove crypto++ from build config for now * use the new `shell` parameter in `threeal/cmake-action` TODO: move to a stable version (v1.3.0) when ready * use full commit hash because a shortened hash is unsupported * add the required {0} parameter? * add openssl 3.1.1 to windows github runners * ensure linux matrix build compiles on the correct arch --------- Co-authored-by: Neo <321592+Neo-Desktop@users.noreply.github.com>
2023-07-09 06:08:43 +03:00
bool serialSet;
bool verbose;
bool help;
bool error;
bool list;
2023-09-02 18:37:38 +03:00
bool nonewlines;
Refactor/Overhaul (#40) * major refactor/overhaul move generation implementation to libumskt/* decouple CLI/Options (and JSON) from generation implementation set groundwork for future shared library use standardized PIDGEN2/PIDGEN3 naming convention create a Windows Docker file for quick compilation add Windows resouce file/header so we have an application icon on windows use icon from @Endermanch (used with permission) add support for fully-static linux/muslc-based compilation add support for a dos/windows (i486+) binary using djgpp add Dockerfile to compile gcc/djgpp/watt32/openssl to provide DOS (DPMI) binaries add @Endermanch 's Vista+ documentation update Readme for recent credits * begin work on C linkage and emscripten buildpath * Update CMake to include and build Crypto++ * move dllmain.cpp to the correct directory * add rust port info to README.md * re-add dropped changes from rebase * update build config, specify windows XP version number for crypto++ * update dos-djgpp action to use new cmake builder and options * update dos-djgpp to use UMSKT hosted forks * update other workflows to include standard header * remove crypto++ from build config for now * use the new `shell` parameter in `threeal/cmake-action` TODO: move to a stable version (v1.3.0) when ready * use full commit hash because a shortened hash is unsupported * add the required {0} parameter? * add openssl 3.1.1 to windows github runners * ensure linux matrix build compiles on the correct arch --------- Co-authored-by: Neo <321592+Neo-Desktop@users.noreply.github.com>
2023-07-09 06:08:43 +03:00
MODE applicationMode;
2023-09-02 16:23:59 +03:00
ACTIVATION_ALGORITHM activationMode;
Refactor/Overhaul (#40) * major refactor/overhaul move generation implementation to libumskt/* decouple CLI/Options (and JSON) from generation implementation set groundwork for future shared library use standardized PIDGEN2/PIDGEN3 naming convention create a Windows Docker file for quick compilation add Windows resouce file/header so we have an application icon on windows use icon from @Endermanch (used with permission) add support for fully-static linux/muslc-based compilation add support for a dos/windows (i486+) binary using djgpp add Dockerfile to compile gcc/djgpp/watt32/openssl to provide DOS (DPMI) binaries add @Endermanch 's Vista+ documentation update Readme for recent credits * begin work on C linkage and emscripten buildpath * Update CMake to include and build Crypto++ * move dllmain.cpp to the correct directory * add rust port info to README.md * re-add dropped changes from rebase * update build config, specify windows XP version number for crypto++ * update dos-djgpp action to use new cmake builder and options * update dos-djgpp to use UMSKT hosted forks * update other workflows to include standard header * remove crypto++ from build config for now * use the new `shell` parameter in `threeal/cmake-action` TODO: move to a stable version (v1.3.0) when ready * use full commit hash because a shortened hash is unsupported * add the required {0} parameter? * add openssl 3.1.1 to windows github runners * ensure linux matrix build compiles on the correct arch --------- Co-authored-by: Neo <321592+Neo-Desktop@users.noreply.github.com>
2023-07-09 06:08:43 +03:00
};
2023-06-07 22:23:59 +03:00
class CLI {
Options options;
json keys;
const char* BINKID;
BIGNUM *privateKey, *genOrder;
EC_POINT *genPoint, *pubPoint;
EC_GROUP *eCurve;
char pKey[25];
int count, total;
public:
CLI(Options options, json keys);
2023-09-25 14:05:23 +03:00
~CLI();
2023-06-07 22:23:59 +03:00
static bool loadJSON(const fs::path& filename, json *output);
static void showHelp(char *argv[]);
static int parseCommandLine(int argc, char* argv[], Options *options);
static int validateCommandLine(Options* options, char *argv[], json *keys);
2023-06-10 20:52:32 +03:00
static void printID(DWORD *pid);
static void printKey(char *pk);
static bool stripKey(const char *in_key, char out_key[PK_LENGTH]);
2023-06-07 22:23:59 +03:00
int BINK1998Generate();
int BINK2002Generate();
int BINK1998Validate();
int BINK2002Validate();
2023-06-07 22:23:59 +03:00
int ConfirmationID();
};
2023-06-17 00:58:22 +03:00
#endif //UMSKT_CLI_H