From 05f085c9055fa5bd13bdba40fc40fb3f00d69fab Mon Sep 17 00:00:00 2001 From: Amlal Date: Sat, 26 Oct 2024 07:59:10 +0200 Subject: IMP: Fixes and improvements. Signed-off-by: Amlal --- tools/Common.h | 14 +++++++++ tools/Framework.h | 13 ++++++++ tools/common_zka.h | 7 ----- tools/framework.h | 13 -------- tools/make_framework.json | 2 +- tools/make_zxd.json | 13 -------- tools/src/MakeFramework.cc | 42 ++++++++++++++++++++++++++ tools/src/make_framework.cc | 42 -------------------------- tools/src/make_zxd.cc | 72 --------------------------------------------- tools/zxd.h | 50 ------------------------------- 10 files changed, 70 insertions(+), 198 deletions(-) create mode 100644 tools/Common.h create mode 100644 tools/Framework.h delete mode 100644 tools/common_zka.h delete mode 100644 tools/framework.h delete mode 100644 tools/make_zxd.json create mode 100644 tools/src/MakeFramework.cc delete mode 100644 tools/src/make_framework.cc delete mode 100644 tools/src/make_zxd.cc delete mode 100644 tools/zxd.h (limited to 'tools') diff --git a/tools/Common.h b/tools/Common.h new file mode 100644 index 00000000..e80f1d11 --- /dev/null +++ b/tools/Common.h @@ -0,0 +1,14 @@ +/** + Sat Oct 26 07:03:28 AM CEST 2024 + (C) ZKA Web Services Co. +*/ + +#pragma once + +#include +#include +#include +#include +#include +#include +#include diff --git a/tools/Framework.h b/tools/Framework.h new file mode 100644 index 00000000..0572a521 --- /dev/null +++ b/tools/Framework.h @@ -0,0 +1,13 @@ +/** + Thu Oct 17 07:57:43 CEST 2024 + (C) ZKA Web Services Co. +*/ + +#pragma once + +#include + +#define kFKDLLDirectory "ZKA/DLL/" +#define kFKManifestDirectory "ZKA/Manifests/" +#define kFKRootDirectory "ZKA/" +#define kFKExtension ".framework" diff --git a/tools/common_zka.h b/tools/common_zka.h deleted file mode 100644 index 3b7a1b19..00000000 --- a/tools/common_zka.h +++ /dev/null @@ -1,7 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include diff --git a/tools/framework.h b/tools/framework.h deleted file mode 100644 index 66a8e497..00000000 --- a/tools/framework.h +++ /dev/null @@ -1,13 +0,0 @@ -/** - Thu Oct 17 07:57:43 CEST 2024 - (C) ZKA Web Services Co. -*/ - -#pragma once - -#include - -#define kFKDLLDirectory "ZKA/DLL/" -#define kFKManifestDirectory "ZKA/Manifests/" -#define kFKRootDirectory "ZKA/" -#define kFKExtension ".framework" 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/MakeFramework.cc b/tools/src/MakeFramework.cc new file mode 100644 index 00000000..11077ddf --- /dev/null +++ b/tools/src/MakeFramework.cc @@ -0,0 +1,42 @@ +/* + * Created on Thu Oct 17 08:00:42 CEST 2024 + * + * Copyright (c) 2024 ZKA Web Services Co + */ + +#include +#include + +/// @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_framework: Framework Creation Tool.\n"; + std::cout << "make_framework: © ZKA Web Services Co, all rights reserved.\n"; + + return 0; + } + } + + auto path = std::string(argv[1]); + + if (!path.ends_with(kFKExtension)) + return 1; + + std::filesystem::path path_arg = path; + + if (std::filesystem::create_directory(path_arg)) + { + std::filesystem::create_directory(path_arg / kFKRootDirectory); + std::filesystem::create_directory(path_arg / kFKManifestDirectory); + std::filesystem::create_directory(path_arg / kFKDLLDirectory); + + return 0; + } + + return 1; +} diff --git a/tools/src/make_framework.cc b/tools/src/make_framework.cc deleted file mode 100644 index 718a9ad1..00000000 --- a/tools/src/make_framework.cc +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Created on Thu Oct 17 08:00:42 CEST 2024 - * - * Copyright (c) 2024 ZKA Web Services Co - */ - -#include -#include - -/// @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_framework: Framework Tool.\n"; - std::cout << "make_framework: © ZKA Web Services Co, all rights reserved.\n"; - - return 0; - } - } - - auto path = std::string(argv[1]); - - if (!path.ends_with(kFKExtension)) - return 1; - - std::filesystem::path path_arg = path; - - if (std::filesystem::create_directory(path_arg)) - { - std::filesystem::create_directory(path_arg / kFKRootDirectory); - std::filesystem::create_directory(path_arg / kFKManifestDirectory); - std::filesystem::create_directory(path_arg / kFKDLLDirectory); - - return 0; - } - - return 1; -} 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 - -/// @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 - -#define kDriverSignedExt ".zxd" -#define kDriverExt ".sys" -#define kSignedDriverMagic " ZXD" - -#define cZXDPaddingSize (512) -#define cZXDMagicSize (5) - -namespace ZXD -{ - /// - /// ZXD header. - /// - 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 -- cgit v1.2.3