diff options
| author | Amlal <amlal.elmahrouss@icloud.com> | 2024-10-26 07:59:10 +0200 |
|---|---|---|
| committer | Amlal <amlal.elmahrouss@icloud.com> | 2024-10-26 07:59:10 +0200 |
| commit | 05f085c9055fa5bd13bdba40fc40fb3f00d69fab (patch) | |
| tree | eccb2acb77b05c0e8ca073a3cea845acc0a35eec /tools | |
| parent | 0d0829659be019b3695795e1604d36591a3c3785 (diff) | |
IMP: Fixes and improvements.
Signed-off-by: Amlal <amlal.elmahrouss@icloud.com>
Diffstat (limited to 'tools')
| -rw-r--r-- | tools/Common.h (renamed from tools/common_zka.h) | 7 | ||||
| -rw-r--r-- | tools/Framework.h (renamed from tools/framework.h) | 2 | ||||
| -rw-r--r-- | tools/make_framework.json | 2 | ||||
| -rw-r--r-- | tools/make_zxd.json | 13 | ||||
| -rw-r--r-- | tools/src/MakeFramework.cc (renamed from tools/src/make_framework.cc) | 2 | ||||
| -rw-r--r-- | tools/src/make_zxd.cc | 72 | ||||
| -rw-r--r-- | tools/zxd.h | 50 |
7 files changed, 10 insertions, 138 deletions
diff --git a/tools/common_zka.h b/tools/Common.h index 3b7a1b19..e80f1d11 100644 --- a/tools/common_zka.h +++ b/tools/Common.h @@ -1,3 +1,10 @@ +/** + Sat Oct 26 07:03:28 AM CEST 2024 + (C) ZKA Web Services Co. +*/ + +#pragma once + #include <cstdint> #include <iostream> #include <fstream> diff --git a/tools/framework.h b/tools/Framework.h index 66a8e497..0572a521 100644 --- a/tools/framework.h +++ b/tools/Framework.h @@ -5,7 +5,7 @@ #pragma once -#include <common_zka.h> +#include <Common.h> #define kFKDLLDirectory "ZKA/DLL/" #define kFKManifestDirectory "ZKA/Manifests/" diff --git a/tools/make_framework.json b/tools/make_framework.json index c597e5d6..4ef2d7b6 100644 --- a/tools/make_framework.json +++ b/tools/make_framework.json @@ -2,7 +2,7 @@ "compiler_path": "g++", "compiler_std": "c++20", "headers_path": ["./"], - "sources_path": ["src/make_framework.cxx"], + "sources_path": ["src/MakeFramework.cc"], "output_name": "make_framework.exe", "cpp_macros": [ "__MKF_AMD64__", diff --git a/tools/make_zxd.json b/tools/make_zxd.json deleted file mode 100644 index 1c25c1a2..00000000 --- a/tools/make_zxd.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "compiler_path": "g++", - "compiler_std": "c++20", - "headers_path": ["./"], - "sources_path": ["src/make_zxd.cxx"], - "output_name": "make_zxd.exe", - "cpp_macros": [ - "__DRVSIGN_AMD64__", - "cDSVersion=0x0100", - "cDSVersionHighest=0x0100", - "cDSVersionLowest=0x0100" - ] -} diff --git a/tools/src/make_framework.cc b/tools/src/MakeFramework.cc index 718a9ad1..11077ddf 100644 --- a/tools/src/make_framework.cc +++ b/tools/src/MakeFramework.cc @@ -15,7 +15,7 @@ int main(int argc, char* argv[]) { if (strcmp(argv[i], "/?") == 0) { - std::cout << "make_framework: Framework Tool.\n"; + std::cout << "make_framework: Framework Creation Tool.\n"; std::cout << "make_framework: © ZKA Web Services Co, all rights reserved.\n"; return 0; diff --git a/tools/src/make_zxd.cc b/tools/src/make_zxd.cc deleted file mode 100644 index 535b51db..00000000 --- a/tools/src/make_zxd.cc +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Created on Thu Aug 22 09:29:13 CEST 2024 - * - * Copyright (c) 2024 ZKA Web Services Co - */ - -#include <zxd.h> - -/// @brief This program converts a PE32+ driver, into a custom format, the ZXD. -/// @note ZXD is a format for ZKA signed drivers. -int main(int argc, char* argv[]) -{ - for (size_t i = 1ul; i < argc; ++i) - { - if (strcmp(argv[i], "/?") == 0) - { - std::cout << "make_zxd: ZXD Tool.\n"; - std::cout << "make_zxd: © ZKA Web Services Co, all rights reserved.\n"; - - return 0; - } - } - - if (!std::filesystem::exists(argv[1]) || - !std::string(argv[1]).ends_with(kDriverExt)) - return -1; - - ZXD::ZXD_HEADER zxd_hdr{0}; - - zxd_hdr.d_binary_version = 1; - - memcpy(zxd_hdr.d_binary_magic, kSignedDriverMagic, strlen(kSignedDriverMagic)); - memcpy(zxd_hdr.d_binary_name, argv[1], strlen(argv[1])); - - zxd_hdr.d_binary_size = std::filesystem::file_size(argv[1]); - - memset(zxd_hdr.d_binary_padding, 0x00, 512); - - zxd_hdr.d_binary_checksum = 0; - - std::string signed_path = argv[1]; - signed_path.erase(signed_path.find(kDriverExt), strlen(kDriverExt)); - signed_path += kDriverSignedExt; - - std::ofstream of_drv(signed_path, std::ios::binary); - std::ifstream if_drv(argv[1], std::ios::binary); - - std::stringstream ss; - ss << if_drv.rdbuf(); - - if (!ZXD::zxd_check_for_mz(ss.str())) - { - std::filesystem::remove(signed_path); - std::cout << "zxdmake: Couldn't sign current driver, Input driver isn't a valid executable.\n"; - - return 1; - } - - for (auto ch : ss.str()) - { - zxd_hdr.d_binary_checksum |= ch; - } - - zxd_hdr.d_binary_checksum ^= zxd_hdr.d_binary_size; - - of_drv.write((char*)&zxd_hdr, sizeof(ZXD::ZXD_HEADER)); - of_drv.write(ss.str().c_str(), ss.str().size()); - - std::cout << "zxdmake: Signing is done, quiting, Checksum: " << zxd_hdr.d_binary_checksum << ".\n"; - - return 0; -} diff --git a/tools/zxd.h b/tools/zxd.h deleted file mode 100644 index 07702595..00000000 --- a/tools/zxd.h +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Created on Thu Aug 22 09:29:13 CEST 2024 - * - * Copyright (c) 2024 ZKA Web Services Co - */ - -#pragma once - -#include <common_zka.h> - -#define kDriverSignedExt ".zxd" -#define kDriverExt ".sys" -#define kSignedDriverMagic " ZXD" - -#define cZXDPaddingSize (512) -#define cZXDMagicSize (5) - -namespace ZXD -{ - /// <summary> - /// ZXD header. - /// </summary> - struct ZXD_HEADER final - { - char d_binary_padding[cZXDPaddingSize]; - // doesn't change. - char d_binary_magic[cZXDMagicSize]; - std::int32_t d_binary_version; - // can change. - char d_binary_name[4096]; - std::uint64_t d_binary_checksum; - std::uint64_t d_binary_size; - }; - - /***********************************************************************************/ - /* @brief These two handles the detection of a MZ header. */ - /***********************************************************************************/ - - inline bool zxd_check_for_mz(const char* mz_blob) noexcept - { - return mz_blob[0] == 'M' && - mz_blob[1] == 'Z'; - } - - inline bool zxd_check_for_mz(std::string mz_blob) noexcept - { - return mz_blob[0] == 'M' && - mz_blob[1] == 'Z'; - } -} // namespace ZXD |
