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/src/MakeFramework.cc | 42 ++++++++++++++++++++++++++ tools/src/make_framework.cc | 42 -------------------------- tools/src/make_zxd.cc | 72 --------------------------------------------- 3 files changed, 42 insertions(+), 114 deletions(-) create mode 100644 tools/src/MakeFramework.cc delete mode 100644 tools/src/make_framework.cc delete mode 100644 tools/src/make_zxd.cc (limited to 'tools/src') 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; -} -- cgit v1.2.3