diff --git a/CMakeLists.txt b/CMakeLists.txt index 4bb0cfb..759817f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,31 +1,31 @@ -CMAKE_MINIMUM_REQUIRED(VERSION 2.8.11) +CMAKE_MINIMUM_REQUIRED(VERSION 3.9) PROJECT(WindowsXPKg) SET(CMAKE_CXX_STANDARD 17) -set(OPENSSL_USE_STATIC_LIBS TRUE) -find_package(PkgConfig REQUIRED) -pkg_search_module(OPENSSL REQUIRED openssl) +SET(OPENSSL_USE_STATIC_LIBS TRUE) +FIND_PACKAGE(PkgConfig REQUIRED) +PKG_SEARCH_MODULE(OPENSSL REQUIRED openssl) -if (!OPENSSL_FOUND) - message(FATAL_ERROR "OpenSSL Development Libraries Not Found") -endif() +IF(!OPENSSL_FOUND) + MESSAGE(FATAL_ERROR "OpenSSL Development Libraries Not Found") +ENDIF() -include(cmake/CPM.cmake) +INCLUDE(cmake/CPM.cmake) -# include json runtime library +# Include JSON runtime library CPMAddPackage( NAME nlohmann_json GITHUB_REPOSITORY nlohmann/json VERSION 3.11.2) -configure_file(keys.json keys.json COPYONLY) +CONFIGURE_FILE(keys.json keys.json COPYONLY) -set(BUILD_SHARED_LIBS OFF) -set(CMAKE_EXE_LINKER_FLAGS "-static") -ADD_EXECUTABLE(xpkey main.cpp xp.cpp key.cpp util.cpp cli.cpp) +SET(BUILD_SHARED_LIBS OFF) +SET(CMAKE_EXE_LINKER_FLAGS "-static") +ADD_EXECUTABLE(xpkey src/main.cpp src/xp.cpp src/key.cpp src/util.cpp src/cli.cpp) TARGET_INCLUDE_DIRECTORIES(xpkey PUBLIC crypto) TARGET_LINK_LIBRARIES(xpkey PUBLIC crypto nlohmann_json::nlohmann_json) -ADD_EXECUTABLE(srv2003key server.cpp key.cpp util.cpp cli.cpp) +ADD_EXECUTABLE(srv2003key src/server.cpp src/key.cpp src/util.cpp src/cli.cpp) TARGET_INCLUDE_DIRECTORIES(srv2003key PUBLIC crypto) TARGET_LINK_LIBRARIES(srv2003key PUBLIC crypto nlohmann_json::nlohmann_json) \ No newline at end of file diff --git a/cli.cpp b/src/cli.cpp similarity index 100% rename from cli.cpp rename to src/cli.cpp diff --git a/header.h b/src/header.h similarity index 97% rename from header.h rename to src/header.h index 93ed1e3..ec361d5 100644 --- a/header.h +++ b/src/header.h @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -31,7 +32,7 @@ #define FIELD_BYTES_2003 64 typedef unsigned char byte; -typedef uint32_t ul32; +typedef unsigned int ul32; extern char charset[]; diff --git a/key.cpp b/src/key.cpp similarity index 100% rename from key.cpp rename to src/key.cpp diff --git a/main.cpp b/src/main.cpp similarity index 98% rename from main.cpp rename to src/main.cpp index 6e18c7e..0a76a48 100644 --- a/main.cpp +++ b/src/main.cpp @@ -80,7 +80,7 @@ int main() { ul32 nRaw = 640 * 1000000 ; /* <- change */ //nRaw += rand() & 999999; - printf("> PID: %lu\n", nRaw); + printf("> PID: %u\n", nRaw); // generate a key BN_sub(privateKey, genOrder, privateKey); diff --git a/server.cpp b/src/server.cpp similarity index 100% rename from server.cpp rename to src/server.cpp diff --git a/util.cpp b/src/util.cpp similarity index 99% rename from util.cpp rename to src/util.cpp index 2984fdf..f378c63 100644 --- a/util.cpp +++ b/src/util.cpp @@ -4,6 +4,11 @@ #include "header.h" +int randomRange() { + + +} + /* Convert data between endianness types. */ void endian(byte *data, int length) { for (int i = 0; i < length / 2; i++) { diff --git a/xp.cpp b/src/xp.cpp similarity index 98% rename from xp.cpp rename to src/xp.cpp index f27a14c..f29d488 100644 --- a/xp.cpp +++ b/src/xp.cpp @@ -231,7 +231,7 @@ void generateXPKey(char *pKey, EC_GROUP *eCurve, EC_POINT *generator, BIGNUM *or // Pack product key. packXP(bKey, pRaw, &hash, sig); - printf("PID: %.8lX\nHash: %.8lX\nSig: %.8lX %.8lX\n", pRaw[0], hash, sig[1], sig[0]); + printf("PID: %.8X\nHash: %.8X\nSig: %.8X %.8X\n", pRaw[0], hash, sig[1], sig[0]); } while (bKey[3] >= 0x40000); // ↑ ↑ ↑ // bKey[3] can't be longer than 18 bits, else the signature part will make