├── .gitignore ├── Main.cpp ├── README.md ├── VIFTools.cpp ├── VIFTools.hpp ├── VMPImportFixer.cpp ├── VMPImportFixer.hpp ├── VMPImportFixer.sln ├── VMPImportFixer.vcxproj ├── VMPImportFixer.vcxproj.filters ├── msc ├── Process.cpp ├── Process.hpp └── ScopedHandle.hpp └── vendor ├── pepp ├── ExportDirectory.cpp ├── ExportDirectory.hpp ├── FileHeader.hpp ├── Image.cpp ├── Image.hpp ├── ImportDirectory.cpp ├── ImportDirectory.hpp ├── OptionalHeader.cpp ├── OptionalHeader.hpp ├── PEHeader.cpp ├── PEHeader.hpp ├── PELibrary.hpp ├── PEUtil.cpp ├── PEUtil.hpp ├── RelocationDirectory.cpp ├── RelocationDirectory.hpp ├── SectionHeader.cpp ├── SectionHeader.hpp └── misc │ ├── Address.hpp │ ├── ByteVector.hpp │ ├── Concept.hpp │ ├── File.cpp │ ├── File.hpp │ └── NonCopyable.hpp ├── spdlog ├── include │ └── spdlog │ │ ├── async.h │ │ ├── async_logger-inl.h │ │ ├── async_logger.h │ │ ├── cfg │ │ ├── argv.h │ │ ├── env.h │ │ ├── helpers-inl.h │ │ └── helpers.h │ │ ├── common-inl.h │ │ ├── common.h │ │ ├── details │ │ ├── backtracer-inl.h │ │ ├── backtracer.h │ │ ├── circular_q.h │ │ ├── console_globals.h │ │ ├── file_helper-inl.h │ │ ├── file_helper.h │ │ ├── fmt_helper.h │ │ ├── log_msg-inl.h │ │ ├── log_msg.h │ │ ├── log_msg_buffer-inl.h │ │ ├── log_msg_buffer.h │ │ ├── mpmc_blocking_q.h │ │ ├── null_mutex.h │ │ ├── os-inl.h │ │ ├── os.h │ │ ├── periodic_worker-inl.h │ │ ├── periodic_worker.h │ │ ├── registry-inl.h │ │ ├── registry.h │ │ ├── synchronous_factory.h │ │ ├── tcp_client-windows.h │ │ ├── tcp_client.h │ │ ├── thread_pool-inl.h │ │ ├── thread_pool.h │ │ └── windows_include.h │ │ ├── fmt │ │ ├── bin_to_hex.h │ │ ├── bundled │ │ │ ├── args.h │ │ │ ├── chrono.h │ │ │ ├── color.h │ │ │ ├── compile.h │ │ │ ├── core.h │ │ │ ├── format-inl.h │ │ │ ├── format.h │ │ │ ├── locale.h │ │ │ ├── os.h │ │ │ ├── ostream.h │ │ │ ├── printf.h │ │ │ ├── ranges.h │ │ │ └── xchar.h │ │ ├── chrono.h │ │ ├── fmt.h │ │ ├── ostr.h │ │ └── xchar.h │ │ ├── formatter.h │ │ ├── fwd.h │ │ ├── logger-inl.h │ │ ├── logger.h │ │ ├── pattern_formatter-inl.h │ │ ├── pattern_formatter.h │ │ ├── sinks │ │ ├── android_sink.h │ │ ├── ansicolor_sink-inl.h │ │ ├── ansicolor_sink.h │ │ ├── base_sink-inl.h │ │ ├── base_sink.h │ │ ├── basic_file_sink-inl.h │ │ ├── basic_file_sink.h │ │ ├── daily_file_sink.h │ │ ├── dist_sink.h │ │ ├── dup_filter_sink.h │ │ ├── hourly_file_sink.h │ │ ├── mongo_sink.h │ │ ├── msvc_sink.h │ │ ├── null_sink.h │ │ ├── ostream_sink.h │ │ ├── ringbuffer_sink.h │ │ ├── rotating_file_sink-inl.h │ │ ├── rotating_file_sink.h │ │ ├── sink-inl.h │ │ ├── sink.h │ │ ├── stdout_color_sinks-inl.h │ │ ├── stdout_color_sinks.h │ │ ├── stdout_sinks-inl.h │ │ ├── stdout_sinks.h │ │ ├── syslog_sink.h │ │ ├── systemd_sink.h │ │ ├── tcp_sink.h │ │ ├── win_eventlog_sink.h │ │ ├── wincolor_sink-inl.h │ │ └── wincolor_sink.h │ │ ├── spdlog-inl.h │ │ ├── spdlog.h │ │ ├── stopwatch.h │ │ ├── tweakme.h │ │ └── version.h └── src │ ├── async.cpp │ ├── cfg.cpp │ ├── color_sinks.cpp │ ├── file_sinks.cpp │ ├── fmt.cpp │ ├── spdlog.cpp │ └── stdout_sinks.cpp ├── unicorn ├── include │ ├── list.h │ ├── qemu.h │ ├── uc_priv.h │ └── unicorn │ │ ├── arm.h │ │ ├── arm64.h │ │ ├── m68k.h │ │ ├── mips.h │ │ ├── platform.h │ │ ├── sparc.h │ │ ├── unicorn.h │ │ └── x86.h └── lib │ └── x64 │ └── unicorn_static.lib ├── zycore ├── include │ ├── Zycore │ │ ├── API │ │ │ ├── Memory.h │ │ │ ├── Process.h │ │ │ ├── Synchronization.h │ │ │ ├── Terminal.h │ │ │ └── Thread.h │ │ ├── Allocator.h │ │ ├── ArgParse.h │ │ ├── Bitset.h │ │ ├── Comparison.h │ │ ├── Defines.h │ │ ├── Format.h │ │ ├── LibC.h │ │ ├── List.h │ │ ├── Object.h │ │ ├── Status.h │ │ ├── String.h │ │ ├── Types.h │ │ ├── Vector.h │ │ ├── Zycore.h │ │ └── ZycoreExportConfig.h │ └── ZycoreExportConfig.h └── src │ ├── API │ ├── Memory.c │ ├── Process.c │ ├── Synchronization.c │ ├── Terminal.c │ └── Thread.c │ ├── Allocator.c │ ├── ArgParse.c │ ├── Bitset.c │ ├── Format.c │ ├── List.c │ ├── String.c │ ├── Vector.c │ └── Zycore.c └── zydis ├── include ├── Zydis │ ├── Decoder.h │ ├── DecoderTypes.h │ ├── Formatter.h │ ├── FormatterBuffer.h │ ├── Generated │ │ ├── EnumISAExt.h │ │ ├── EnumISASet.h │ │ ├── EnumInstructionCategory.h │ │ ├── EnumMnemonic.h │ │ └── EnumRegister.h │ ├── Internal │ │ ├── DecoderData.h │ │ ├── FormatterATT.h │ │ ├── FormatterBase.h │ │ ├── FormatterIntel.h │ │ ├── SharedData.h │ │ └── String.h │ ├── MetaInfo.h │ ├── Mnemonic.h │ ├── Register.h │ ├── SharedTypes.h │ ├── ShortString.h │ ├── Status.h │ ├── Utils.h │ └── Zydis.h └── ZydisExportConfig.h ├── lib ├── ReleaseX64 │ ├── Zycore.lib │ └── Zydis.lib └── ReleaseX86 │ ├── Zycore.lib │ └── Zydis.lib └── src ├── Decoder.c ├── DecoderData.c ├── Formatter.c ├── FormatterATT.c ├── FormatterBase.c ├── FormatterBuffer.c ├── FormatterIntel.c ├── Generated ├── AccessedFlags.inc ├── DecoderTables.inc ├── EncodableInstructions.inc ├── EnumISAExt.inc ├── EnumISASet.inc ├── EnumInstructionCategory.inc ├── EnumMnemonic.inc ├── EnumRegister.inc ├── FormatterStrings.inc ├── InstructionDefinitions.inc ├── InstructionEncodings.inc └── OperandDefinitions.inc ├── MetaInfo.c ├── Mnemonic.c ├── Register.c ├── SharedData.c ├── String.c ├── Utils.c └── Zydis.c /README.md: -------------------------------------------------------------------------------- 1 | # VMPImportFixer 2 | 3 | VMPImportFixer is a tool aimed to resolve import calls in a VMProtect'd (3.x) binary. 4 | 5 | # Information 6 | 7 | VMPImportFixer attempts to resolve all obfuscated API calls in a VMProtect'd binary. A binary which has VMProtect's "Import Protection" option enabled will have all it's `CALL NEAR` instructions replaced with near relative call instructions (see [ImportCallObfuscator](https://github.com/mike1k/ImportCallObfuscator) for a similar method of obfuscating imports). 8 | 9 | VMProtect usually has two different variations of import calls which seem to be chosen at random once the binary is protected. The first, being `push reg; call func`, and the other being `call func; ret/int3`. 10 | 11 | ![call/int3](https://i.imgur.com/X15Aps6.png) 12 | ![push/call](https://i.imgur.com/cgA8ecy.png) 13 | 14 | Following these calls lead into the VMProtect section, which, by default is named `.vmp0`. Each stub can vary in complexity and size, however the concept is generally the same. Through a series of arithmetic which is used to calculate the real import address, the final operation usually sets `[rsp]`/`[esp]` to the import address before the final RET instruction. 15 | 16 | Based on the variant of the call (`push reg; call func` or `call func; int3/ret`), the stub may increment the return address. This use of the extra byte and return address incrementing is used to break various decompilers from properly analyzing a function due to the decompiler not recognizing that the byte will be skipped over in runtime. 17 | 18 | With this information combined, I decided to write a tool over the day that solves these calls. I was not happy with public implementations due to various reasons. One was closed-source, and seemed to be limited to a debugger, and the other lifts these stubs into a IL which seems impractical. I decided to go the emulation route as this trivially tackles the problem and supports both X86 and X86-64 flawlessly. 19 | 20 | VMPImportFixer is an all-in-one tool; it will support X86 processes regardless of being in a X64 context. This means that there is no need for architecture dependent versions of the binary. 21 | 22 | # Usage 23 | 24 | ``` 25 | Usage: VMPImportFixer 26 | -p (required) process name/process id 27 | -mod: (optional) name of module to dump. 28 | -section: (optional) VMP section name to use if changed from default (VMP allows custom names) 29 | ``` 30 | 31 | # Examples 32 |
33 | Images 34 | 35 | * Before 36 | ![b1](https://i.imgur.com/wzraZfe.png) 37 | * After 38 | ![a1](https://i.imgur.com/E12Gnxc.png) 39 | 40 | * Before 41 | ![b2](https://i.imgur.com/eKdCdtm.png) 42 | * After 43 | ![a2](https://i.imgur.com/acPdGVt.png) 44 |
45 | 46 | # TODO 47 | 48 | * Add support for loading binaries off the disk into a state where it can be monitored at specific stages (such as unpacking) then fixed. 49 | * Add relocation handling on X86 binaries. 50 | * Kernel support. 51 | 52 | # Dependencies 53 | * [pepp](https://github.com/mike1k/pepp) 54 | * [Unicorn](https://github.com/unicorn-engine/unicorn) 55 | * [Zydis](https://github.com/zyantific/zydis) 56 | * [spdlog](https://github.com/gabime/spdlog) 57 | 58 | # Credits 59 | 60 | [mrexodia](https://github.com/mrexodia) for his contribution to [HookHunter](https://github.com/mike1k/HookHunter) regarding `ReadMemory` inside the `Process` class. 61 | -------------------------------------------------------------------------------- /VIFTools.cpp: -------------------------------------------------------------------------------- 1 | #include "VMPImportFixer.hpp" 2 | 3 | DWORD VifSearchForProcess(std::string_view process_name) noexcept 4 | { 5 | PROCESSENTRY32 pe32{}; 6 | pe32.dwSize = sizeof pe32; 7 | 8 | vif::nt::ScopedHandle hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0); 9 | if (static_cast(hSnapshot) == INVALID_HANDLE_VALUE) 10 | return -1; 11 | 12 | if (Process32First(hSnapshot, &pe32)) 13 | { 14 | do 15 | { 16 | std::string_view this_proc = pe32.szExeFile; 17 | if (this_proc.find(process_name) != this_proc.npos && pe32.th32ProcessID != GetCurrentProcessId()) 18 | return pe32.th32ProcessID; 19 | } while (Process32Next(hSnapshot, &pe32)); 20 | } 21 | 22 | return static_cast(-1); 23 | } 24 | 25 | bool VifFindModuleInProcess(HANDLE hProc, std::string_view module_name, VIFModuleInformation_t* info) 26 | { 27 | HMODULE hMods[1024]; 28 | DWORD cbNeeded; 29 | unsigned int i; 30 | 31 | if (!info) 32 | return false; 33 | 34 | if (EnumProcessModulesEx(hProc, hMods, sizeof(hMods), &cbNeeded, LIST_MODULES_ALL)) 35 | { 36 | for (i = 0; i < (cbNeeded / sizeof(HMODULE)); i++) 37 | { 38 | TCHAR szModName[MAX_PATH]; 39 | 40 | if (GetModuleFileNameEx(hProc, hMods[i], szModName, 41 | sizeof(szModName) / sizeof(TCHAR))) 42 | { 43 | MODULEINFO mdi{}; 44 | GetModuleInformation(hProc, hMods[i], &mdi, sizeof mdi); 45 | 46 | info->module_path = szModName; 47 | 48 | if (info->module_path.find(module_name) != std::string::npos) 49 | { 50 | info->base_address = (std::uint64_t)hMods[i]; 51 | info->module_size = mdi.SizeOfImage; 52 | } 53 | } 54 | } 55 | } 56 | 57 | return info->base_address != 0; 58 | } 59 | 60 | bool VifFindModulesInProcess(HANDLE hProc, std::vector& modules) 61 | { 62 | HMODULE hMods[1024]; 63 | DWORD cbNeeded; 64 | unsigned int i; 65 | 66 | if (EnumProcessModulesEx(hProc, hMods, sizeof(hMods), &cbNeeded, LIST_MODULES_ALL)) 67 | { 68 | for (i = 0; i < (cbNeeded / sizeof(HMODULE)); i++) 69 | { 70 | TCHAR szModName[MAX_PATH]; 71 | 72 | // Get the full path to the module's file. 73 | if (GetModuleFileNameEx(hProc, hMods[i], szModName, 74 | sizeof(szModName) / sizeof(TCHAR))) 75 | { 76 | MODULEINFO info{}; 77 | GetModuleInformation(hProc, hMods[i], &info, sizeof info); 78 | 79 | modules.emplace_back(szModName, (std::uint64_t)hMods[i], info.SizeOfImage); 80 | } 81 | } 82 | } 83 | 84 | return modules.size() > 0; 85 | } 86 | -------------------------------------------------------------------------------- /VIFTools.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | struct VIFModuleInformation_t 4 | { 5 | std::string module_path; 6 | std::uint64_t base_address; 7 | std::uint32_t module_size; 8 | }; 9 | 10 | 11 | DWORD VifSearchForProcess(std::string_view process_name) noexcept; 12 | bool VifFindModuleInProcess(HANDLE hProc, std::string_view module_name, VIFModuleInformation_t* info); 13 | bool VifFindModulesInProcess(HANDLE hProc, std::vector& modules); 14 | 15 | -------------------------------------------------------------------------------- /VMPImportFixer.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // 4 | // Emulation engine. 5 | #include 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #pragma comment(lib, "psapi.lib") 19 | 20 | //! PE parsing and manipulation and some other utils. 21 | #include "msc/Process.hpp" 22 | #include "msc/ScopedHandle.hpp" 23 | #include 24 | 25 | //! Include Zydis disassembler 26 | #include 27 | #include 28 | #include 29 | 30 | //! Include spdlog 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | 37 | #include "VIFTools.hpp" 38 | 39 | class IVMPImportFixer 40 | { 41 | public: 42 | virtual ~IVMPImportFixer() = default; 43 | virtual bool GetModuleFromAddress(std::uintptr_t ptr, VIFModuleInformation_t* mod) = 0; 44 | virtual void DumpInMemory(HANDLE hProcess, std::string_view sModName) = 0; 45 | virtual bool GetExportData(std::uintptr_t mod, std::uintptr_t rva, pepp::ExportData_t* exp) = 0; 46 | }; 47 | 48 | template 49 | class VMPImportFixer : public pepp::msc::NonCopyable, public IVMPImportFixer 50 | { 51 | public: 52 | VMPImportFixer(std::string_view vmpsn) noexcept; 53 | 54 | void DumpInMemory(HANDLE hProcess, std::string_view sModName) final override; 55 | 56 | //! Zydis disassemble an instruction. 57 | bool DecodeInsn(pepp::Address<> address, ZydisDecodedInstruction& insn) const noexcept; 58 | std::uintptr_t CalculateAbsoluteAddress(std::uintptr_t runtime_address, ZydisDecodedInstruction& insn) const noexcept; 59 | 60 | bool GetModuleFromAddress(std::uintptr_t ptr, VIFModuleInformation_t* mod) final override; 61 | bool GetExportData(std::uintptr_t mod, std::uintptr_t rva, pepp::ExportData_t* exp) final override; 62 | private: 63 | ZydisDecoder m_decoder; 64 | std::string m_strVMPSectionName; 65 | std::vector m_vecModuleList; 66 | std::vector> m_vecImageList; 67 | std::map, pepp::Image*> m_ImageMap; 68 | }; 69 | 70 | 71 | 72 | extern std::shared_ptr logger; 73 | 74 | template 75 | inline VMPImportFixer::VMPImportFixer(std::string_view vmpsn) noexcept 76 | : m_strVMPSectionName(vmpsn) 77 | { 78 | } 79 | 80 | 81 | -------------------------------------------------------------------------------- /VMPImportFixer.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.31321.278 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "VMPImportFixer", "VMPImportFixer.vcxproj", "{701E6AB3-4569-476C-8F49-C9BEACA20247}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|x64 = Debug|x64 11 | Debug|x86 = Debug|x86 12 | Release|x64 = Release|x64 13 | Release|x86 = Release|x86 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {701E6AB3-4569-476C-8F49-C9BEACA20247}.Debug|x64.ActiveCfg = Debug|x64 17 | {701E6AB3-4569-476C-8F49-C9BEACA20247}.Debug|x64.Build.0 = Debug|x64 18 | {701E6AB3-4569-476C-8F49-C9BEACA20247}.Debug|x86.ActiveCfg = Debug|Win32 19 | {701E6AB3-4569-476C-8F49-C9BEACA20247}.Debug|x86.Build.0 = Debug|Win32 20 | {701E6AB3-4569-476C-8F49-C9BEACA20247}.Release|x64.ActiveCfg = Release|x64 21 | {701E6AB3-4569-476C-8F49-C9BEACA20247}.Release|x64.Build.0 = Release|x64 22 | {701E6AB3-4569-476C-8F49-C9BEACA20247}.Release|x86.ActiveCfg = Release|Win32 23 | {701E6AB3-4569-476C-8F49-C9BEACA20247}.Release|x86.Build.0 = Release|Win32 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | GlobalSection(ExtensibilityGlobals) = postSolution 29 | SolutionGuid = {21943CCC-6FAC-415F-9887-DF76EF36C965} 30 | EndGlobalSection 31 | EndGlobal 32 | -------------------------------------------------------------------------------- /msc/Process.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "Process.hpp" 3 | 4 | using namespace vif::nt; 5 | 6 | Process::Process(std::uint32_t processId) noexcept 7 | : m_processId(processId) 8 | { 9 | } 10 | 11 | Process::Process(HANDLE processHandle) noexcept 12 | : m_handle(processHandle), m_processId(GetProcessId(processHandle)) 13 | { 14 | } 15 | 16 | bool Process::CreateHandle(std::uint32_t flags) noexcept 17 | { 18 | m_handle = OpenProcess(flags, FALSE, m_processId); 19 | return m_handle != INVALID_HANDLE_VALUE; 20 | } 21 | 22 | bool Process::CreateHandle(std::uint32_t processId, std::uint32_t flags) noexcept 23 | { 24 | m_processId = processId; 25 | m_handle = OpenProcess(flags, FALSE, m_processId); 26 | return m_handle != INVALID_HANDLE_VALUE; 27 | } 28 | 29 | // ReadProcessMemory will fail if the page has PAGE_NOACCESS or PAGE_GUARD, so try to change the protection and then read 30 | static bool ReadPage(HANDLE handle, LPVOID address, LPVOID buffer, std::size_t size, SIZE_T* bytesRead) 31 | { 32 | if (!ReadProcessMemory(handle, address, buffer, size, bytesRead)) 33 | { 34 | DWORD oldProtect = 0; 35 | if (!VirtualProtectEx(handle, address, size, PAGE_READONLY, &oldProtect)) 36 | { 37 | return false; 38 | } 39 | auto result = !!ReadProcessMemory(handle, address, buffer, size, bytesRead); 40 | VirtualProtectEx(handle, address, size, oldProtect, &oldProtect); 41 | return result; 42 | } 43 | return true; 44 | } 45 | 46 | bool Process::ReadMemory(pepp::Address<> address, void* buffer, std::size_t size) noexcept 47 | { 48 | if (m_handle == INVALID_HANDLE_VALUE || !buffer || !size) 49 | return false; 50 | 51 | // Read page-by-page to maximize the likelyhook of reading successfully 52 | std::size_t bytesRead = 0; 53 | constexpr std::uintptr_t PAGE_SIZE = 0x1000; 54 | std::uintptr_t offset = 0; 55 | std::uintptr_t requestedSize = size; 56 | std::uintptr_t sizeLeftInFirstPage = PAGE_SIZE - (address.uintptr() & (PAGE_SIZE - 1)); 57 | std::uintptr_t readSize = min(sizeLeftInFirstPage, requestedSize); 58 | 59 | while (readSize) 60 | { 61 | SIZE_T bytesReadSafe = 0; 62 | auto readSuccess = ReadPage(m_handle, (PVOID)(address.uintptr() + offset), (PBYTE)buffer + offset, readSize, &bytesReadSafe); 63 | bytesRead += bytesReadSafe; 64 | if (!readSuccess) 65 | break; 66 | 67 | offset += readSize; 68 | requestedSize -= readSize; 69 | readSize = min(PAGE_SIZE, requestedSize); 70 | } 71 | 72 | auto success = bytesRead == size; 73 | SetLastError(success ? ERROR_SUCCESS : ERROR_PARTIAL_COPY); 74 | return success; 75 | } 76 | 77 | bool Process::WriteMemory(pepp::Address<> address, void* buffer, std::size_t size) noexcept 78 | { 79 | if (m_handle == INVALID_HANDLE_VALUE) 80 | return false; 81 | 82 | return static_cast(WriteProcessMemory(m_handle, address.as_ptr(), buffer, size, nullptr)); 83 | } -------------------------------------------------------------------------------- /msc/Process.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include "ScopedHandle.hpp" 5 | #include 6 | 7 | namespace vif::nt 8 | { 9 | class Process : pepp::msc::NonCopyable 10 | { 11 | public: 12 | Process() = default; 13 | Process(std::uint32_t processId) noexcept; 14 | Process(HANDLE processHandle) noexcept; 15 | 16 | 17 | //! Create a handle to the process 18 | //! - returns true or false depending OpenProcess status 19 | bool CreateHandle(std::uint32_t flags) noexcept; 20 | bool CreateHandle(std::uint32_t processId, std::uint32_t flags) noexcept; 21 | 22 | 23 | //! Read memory 24 | bool ReadMemory(pepp::Address<> address, void* buffer, std::size_t size) noexcept; 25 | 26 | //! Write memory 27 | bool WriteMemory(pepp::Address<> address, void* buffer, std::size_t size) noexcept; 28 | 29 | //! Get handle pointer 30 | HANDLE handle() noexcept { return m_handle.handle(); } 31 | 32 | private: 33 | std::uint16_t m_processId = 0; 34 | vif::nt::ScopedHandle m_handle; 35 | }; 36 | } -------------------------------------------------------------------------------- /msc/ScopedHandle.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace vif::nt 6 | { 7 | class ScopedHandle : pepp::msc::NonCopyable 8 | { 9 | HANDLE m_handle = INVALID_HANDLE_VALUE; 10 | 11 | public: 12 | ScopedHandle() = default; 13 | 14 | 15 | ScopedHandle(HANDLE handle) 16 | : m_handle(handle ? handle : INVALID_HANDLE_VALUE) 17 | { 18 | } 19 | 20 | ~ScopedHandle() 21 | { 22 | if (m_handle != INVALID_HANDLE_VALUE) 23 | CloseHandle(m_handle); 24 | } 25 | 26 | operator HANDLE () noexcept 27 | { 28 | return m_handle; 29 | } 30 | 31 | HANDLE handle() noexcept 32 | { 33 | return m_handle; 34 | } 35 | 36 | LPHANDLE lphandle() noexcept 37 | { 38 | return &m_handle; 39 | } 40 | 41 | void operator=(HANDLE rhs) noexcept 42 | { 43 | if (m_handle != INVALID_HANDLE_VALUE) 44 | CloseHandle(m_handle); 45 | 46 | m_handle = rhs ? rhs : INVALID_HANDLE_VALUE; 47 | } 48 | }; 49 | } -------------------------------------------------------------------------------- /vendor/pepp/ExportDirectory.cpp: -------------------------------------------------------------------------------- 1 | #include "PELibrary.hpp" 2 | 3 | using namespace pepp; 4 | 5 | template class ExportDirectory<32>; 6 | template class ExportDirectory<64>; 7 | 8 | template 9 | ExportData_t ExportDirectory::GetExport(std::uint32_t idx, bool demangle /*= true*/) const 10 | { 11 | if (!IsPresent()) 12 | return {}; 13 | 14 | if (idx < GetNumberOfNames()) { 15 | std::uint8_t* base{}; 16 | std::uint32_t funcAddresses{}; 17 | std::uint32_t funcNames{}; 18 | std::uint32_t funcOrdinals{}; 19 | std::uint32_t funcNamesOffset{}; 20 | mem::ByteVector const* buffer{}; 21 | 22 | funcOrdinals = m_image->GetPEHeader().RvaToOffset(GetAddressOfNameOrdinals()); 23 | uint16_t rlIdx = m_image->buffer().deref(funcOrdinals + (idx * sizeof uint16_t)); 24 | 25 | funcAddresses = m_image->GetPEHeader().RvaToOffset(GetAddressOfFunctions() + sizeof(std::uint32_t) * rlIdx); 26 | funcNames = m_image->GetPEHeader().RvaToOffset(GetAddressOfNames() + sizeof(std::uint32_t) * idx); 27 | funcNamesOffset = m_image->GetPEHeader().RvaToOffset(m_image->buffer().deref(funcNames)); 28 | 29 | 30 | if (funcAddresses && funcNames && funcOrdinals) 31 | { 32 | return 33 | { 34 | demangle ? DemangleName(m_image->buffer().as(funcNamesOffset)) : m_image->buffer().as(funcNamesOffset), 35 | m_image->buffer().deref(funcAddresses), 36 | rlIdx 37 | }; 38 | } 39 | } 40 | 41 | return {}; 42 | } 43 | 44 | template 45 | void ExportDirectory::TraverseExports(const std::function& cb_func) 46 | { 47 | for (int i = 0; i < GetNumberOfNames(); i++) 48 | { 49 | ExportData_t data = GetExport(i); 50 | if (data.rva != 0) 51 | cb_func(&data); 52 | } 53 | } 54 | 55 | template 56 | bool ExportDirectory::IsPresent() const noexcept 57 | { 58 | return m_image->GetPEHeader().GetOptionalHeader().GetDataDirectory(DIRECTORY_ENTRY_EXPORT).Size > 0; 59 | } 60 | 61 | template 62 | void ExportDirectory::AddExport(std::string_view name, std::uint32_t rva) 63 | { 64 | // TODO 65 | } 66 | -------------------------------------------------------------------------------- /vendor/pepp/ExportDirectory.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace pepp 6 | { 7 | struct ExportData_t 8 | { 9 | std::string name{}; 10 | std::uint32_t rva = 0; 11 | std::uint32_t ordinal = 0xffffffff; 12 | }; 13 | 14 | template 15 | class ExportDirectory : public pepp::msc::NonCopyable 16 | { 17 | friend class Image<32>; 18 | friend class Image<64>; 19 | 20 | Image* m_image; 21 | detail::Image_t<>::ExportDirectory_t *m_base; 22 | public: 23 | ExportData_t GetExport(std::uint32_t idx, bool demangle = true) const; 24 | void AddExport(std::string_view name, std::uint32_t rva); 25 | void TraverseExports(const std::function& cb_func); 26 | bool IsPresent() const noexcept; 27 | 28 | void SetNumberOfFunctions(std::uint32_t num) { 29 | m_base->NumberOfFunctions = num; 30 | } 31 | 32 | std::uint32_t GetNumberOfFunctions() const { 33 | return m_base->NumberOfFunctions; 34 | } 35 | 36 | void SetNumberOfNames(std::uint32_t num) { 37 | m_base->NumberOfNames = num; 38 | } 39 | 40 | std::uint32_t GetNumberOfNames() const { 41 | return m_base->NumberOfNames; 42 | } 43 | 44 | void SetCharacteristics(std::uint32_t chrs) { 45 | m_base->Characteristics = chrs; 46 | } 47 | 48 | std::uint32_t GetCharacteristics() const { 49 | return m_base->Characteristics; 50 | } 51 | 52 | void SetTimeDateStamp(std::uint32_t TimeDateStamp) { 53 | m_base->TimeDateStamp = TimeDateStamp; 54 | } 55 | 56 | std::uint32_t GetTimeDateStamp() const { 57 | return m_base->TimeDateStamp; 58 | } 59 | 60 | void SetAddressOfFunctions(std::uint32_t AddressOfFunctions) { 61 | m_base->AddressOfFunctions = AddressOfFunctions; 62 | } 63 | 64 | std::uint32_t GetAddressOfFunctions() const { 65 | return m_base->AddressOfFunctions; 66 | } 67 | 68 | void SetAddressOfNames(std::uint32_t AddressOfNames) { 69 | m_base->AddressOfNames = AddressOfNames; 70 | } 71 | 72 | std::uint32_t GetAddressOfNames() const { 73 | return m_base->AddressOfNames; 74 | } 75 | 76 | void SetAddressOfNameOrdinals(std::uint32_t AddressOfNamesOrdinals) { 77 | m_base->AddressOfNameOrdinals = AddressOfNamesOrdinals; 78 | } 79 | 80 | std::uint32_t GetAddressOfNameOrdinals() const { 81 | return m_base->AddressOfNameOrdinals; 82 | } 83 | 84 | 85 | constexpr std::size_t size() const { 86 | return sizeof(decltype(*m_base)); 87 | } 88 | 89 | private: 90 | //! Setup the directory 91 | void _setup(Image* image) { 92 | m_image = image; 93 | m_base = reinterpret_cast( 94 | &image->base()[image->GetPEHeader().RvaToOffset( 95 | image->GetPEHeader().GetOptionalHeader().GetDataDirectory(DIRECTORY_ENTRY_EXPORT).VirtualAddress)]); 96 | } 97 | }; 98 | } -------------------------------------------------------------------------------- /vendor/pepp/FileHeader.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace pepp 4 | { 5 | enum class PEMachine 6 | { 7 | MACHINE_I386 = 0x14c, 8 | MACHINE_IA64 = 0x200, 9 | MACHINE_AMD64 = 0x8664 10 | }; 11 | 12 | class FileHeader : pepp::msc::NonCopyable 13 | { 14 | friend class PEHeader<32>; 15 | friend class PEHeader<64>; 16 | 17 | IMAGE_FILE_HEADER* m_base; 18 | public: 19 | FileHeader() 20 | { 21 | } 22 | 23 | void SetMachine(PEMachine machine) { 24 | m_base->Machine = static_cast(machine); 25 | } 26 | 27 | PEMachine GetMachine() const { 28 | return static_cast(m_base->Machine); 29 | } 30 | 31 | void SetNumberOfSections(std::uint16_t numSections) { 32 | m_base->NumberOfSections = numSections; 33 | } 34 | 35 | std::uint16_t GetNumberOfSections() const { 36 | return m_base->NumberOfSections; 37 | } 38 | 39 | void SetTimeDateStamp(std::uint32_t dwTimeDateStamp) { 40 | m_base->TimeDateStamp = dwTimeDateStamp; 41 | } 42 | 43 | std::uint32_t GetTimeDateStamp() const { 44 | return m_base->TimeDateStamp; 45 | } 46 | 47 | void SetPointerToSymbolTable(std::uint32_t dwPointerToSymbolTable) { 48 | m_base->PointerToSymbolTable = dwPointerToSymbolTable; 49 | } 50 | 51 | std::uint32_t GetPointerToSymbolTable() const { 52 | return m_base->PointerToSymbolTable; 53 | } 54 | 55 | void SetNumberOfSymbols(std::uint32_t numSymbols) { 56 | m_base->NumberOfSymbols = numSymbols; 57 | } 58 | 59 | std::uint32_t GetNumberOfSymbols() const { 60 | return m_base->NumberOfSymbols; 61 | } 62 | 63 | void SetSizeOfOptionalHeader(std::uint16_t size) { 64 | m_base->SizeOfOptionalHeader = size; 65 | } 66 | 67 | std::uint16_t GetSizeOfOptionalHeader() const { 68 | return m_base->SizeOfOptionalHeader; 69 | } 70 | 71 | void SetCharacteristics(std::uint16_t chars) { 72 | m_base->Characteristics = chars; 73 | } 74 | 75 | std::uint16_t GetCharacteristics() const { 76 | return m_base->Characteristics; 77 | } 78 | 79 | IMAGE_FILE_HEADER* native() const { 80 | return m_base; 81 | } 82 | private: 83 | template 84 | void _setup(Image* image) { 85 | m_base = &image->GetPEHeader().native()->FileHeader; 86 | } 87 | }; 88 | } -------------------------------------------------------------------------------- /vendor/pepp/ImportDirectory.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | namespace pepp 8 | { 9 | struct ModuleImportData_t 10 | { 11 | std::uint32_t module_name_rva; 12 | std::string module_name; 13 | std::uint32_t import_name_rva; 14 | std::variant import_variant; 15 | std::uint32_t import_rva; 16 | bool ordinal; 17 | }; 18 | 19 | static constexpr auto IMPORT_ORDINAL_FLAG_32 = IMAGE_ORDINAL_FLAG32; 20 | static constexpr auto IMPORT_ORDINAL_FLAG_64 = IMAGE_ORDINAL_FLAG64; 21 | 22 | template 23 | class ImportDirectory : pepp::msc::NonCopyable 24 | { 25 | friend class Image<32>; 26 | friend class Image<64>; 27 | 28 | Image* m_image; 29 | detail::Image_t<>::ImportDescriptor_t* m_base; 30 | detail::Image_t<>::ImportAddressTable_t m_iat_base; 31 | public: 32 | ImportDirectory() = default; 33 | 34 | bool ImportsModule(std::string_view module, std::uint32_t* name_rva = nullptr) const; 35 | bool HasModuleImport(std::string_view module, std::string_view import, std::uint32_t* rva = nullptr) const; 36 | void AddModuleImport(std::string_view module, std::string_view import, std::uint32_t* rva = nullptr); 37 | void AddModuleImports(std::string_view module, std::initializer_list imports, std::uint32_t* rva = nullptr); 38 | void TraverseImports(const std::function& cb_func); 39 | 40 | void SetCharacteristics(std::uint32_t chrs) { 41 | m_base->Characteristics = chrs; 42 | } 43 | 44 | std::uint32_t GetCharacteristics() const { 45 | return m_base->Characteristics; 46 | } 47 | 48 | void SetTimeDateStamp(std::uint32_t TimeDateStamp) { 49 | m_base->TimeDateStamp = TimeDateStamp; 50 | } 51 | 52 | std::uint32_t GetTimeDateStamp() const { 53 | return m_base->TimeDateStamp; 54 | } 55 | 56 | //! Util 57 | template 58 | bool IsImportOrdinal(T ord) const requires pepp::msc::MemoryAddress { 59 | if constexpr (bitsize == 64) 60 | return (ord & IMPORT_ORDINAL_FLAG_64) != 0; 61 | return (ord & IMPORT_ORDINAL_FLAG_32) != 0; 62 | } 63 | 64 | void GetIATOffsets(std::uint32_t& begin, std::uint32_t& end) noexcept; 65 | 66 | private: 67 | //! Setup the directory 68 | void _setup(Image* image) { 69 | m_image = image; 70 | m_base = reinterpret_cast( 71 | &image->base()[image->GetPEHeader().RvaToOffset( 72 | image->GetPEHeader().GetOptionalHeader().GetDataDirectory(DIRECTORY_ENTRY_IMPORT).VirtualAddress)]); 73 | m_iat_base = reinterpret_cast( 74 | &image->base()[image->GetPEHeader().RvaToOffset( 75 | image->GetPEHeader().GetOptionalHeader().GetDataDirectory(DIRECTORY_ENTRY_IAT).VirtualAddress)]); 76 | } 77 | }; 78 | } -------------------------------------------------------------------------------- /vendor/pepp/OptionalHeader.cpp: -------------------------------------------------------------------------------- 1 | #include "PELibrary.hpp" 2 | 3 | using namespace pepp; 4 | 5 | // Explicit templates. 6 | template class OptionalHeader<32>; 7 | template class OptionalHeader<64>; 8 | 9 | template 10 | inline OptionalHeader::OptionalHeader() 11 | { 12 | } 13 | 14 | template 15 | void OptionalHeader::SetMagic(PEMagic magic) 16 | { 17 | m_base->Magic = static_cast(magic); 18 | } 19 | 20 | template 21 | PEMagic OptionalHeader::GetMagic() const 22 | { 23 | return static_cast(m_base->Magic); 24 | } 25 | 26 | 27 | template 28 | void OptionalHeader::SetImageBase(detail::Image_t::Address_t address) 29 | { 30 | m_base->ImageBase = address; 31 | } 32 | 33 | template 34 | detail::Image_t::Address_t OptionalHeader::GetImageBase() const 35 | { 36 | return m_base->ImageBase; 37 | } 38 | 39 | template 40 | void OptionalHeader::SetSizeOfImage(std::uint32_t size) 41 | { 42 | m_base->SizeOfImage = size; 43 | } 44 | 45 | template 46 | std::uint32_t OptionalHeader::GetSizeOfImage() const 47 | { 48 | return m_base->SizeOfImage; 49 | } 50 | 51 | template 52 | void OptionalHeader::SetSizeOfCode(std::uint32_t dwSize) 53 | { 54 | m_base->SizeOfCode = dwSize; 55 | } 56 | 57 | template 58 | std::uint32_t OptionalHeader::GetSizeOfCode() const 59 | { 60 | return m_base->SizeOfCode; 61 | } 62 | 63 | template 64 | void OptionalHeader::SetSizeOfInitializedData(std::uint32_t dwSize) 65 | { 66 | m_base->SizeOfInitializedData = dwSize; 67 | } 68 | 69 | template 70 | std::uint32_t OptionalHeader::GetSizeOfInitializedData() const 71 | { 72 | return m_base->SizeOfInitializedData; 73 | } 74 | 75 | template 76 | void OptionalHeader::SetSizeOfUninitializedData(std::uint32_t dwSize) 77 | { 78 | m_base->SizeOfUninitializedData = dwSize; 79 | } 80 | 81 | template 82 | std::uint32_t OptionalHeader::GetSizeOfUninitializedData() const 83 | { 84 | return m_base->SizeOfUninitializedData; 85 | } 86 | 87 | template 88 | void OptionalHeader::SetBaseOfCode(std::uint32_t dwBase) 89 | { 90 | m_base->BaseOfCode = dwBase; 91 | } 92 | 93 | template 94 | std::uint32_t OptionalHeader::GetBaseOfCode() const 95 | { 96 | return m_base->BaseOfCode; 97 | } 98 | 99 | template 100 | void OptionalHeader::SetAddressOfEntryPoint(std::uint32_t dwBase) 101 | { 102 | m_base->AddressOfEntryPoint = dwBase; 103 | } 104 | 105 | template 106 | std::uint32_t OptionalHeader::GetAddressOfEntryPoint() const 107 | { 108 | return m_base->AddressOfEntryPoint; 109 | } 110 | 111 | template 112 | std::uint32_t OptionalHeader::GetFileAlignment() const 113 | { 114 | return m_base->FileAlignment; 115 | } 116 | 117 | template 118 | std::uint32_t OptionalHeader::GetSectionAlignment() const 119 | { 120 | return m_base->SectionAlignment; 121 | } 122 | 123 | template 124 | bool OptionalHeader::HasRelocations() const 125 | { 126 | return m_base->DataDirectory[DIRECTORY_ENTRY_BASERELOC].Size > 0; 127 | } 128 | -------------------------------------------------------------------------------- /vendor/pepp/PEHeader.cpp: -------------------------------------------------------------------------------- 1 | #include "PELibrary.hpp" 2 | 3 | using namespace pepp; 4 | 5 | // Explicit templates. 6 | template class PEHeader<32>; 7 | template class PEHeader<64>; 8 | 9 | template 10 | inline PEHeader::PEHeader() 11 | : m_Image(nullptr) 12 | { 13 | } 14 | 15 | 16 | template 17 | std::uint32_t PEHeader::GetSizeOfImage() 18 | { 19 | std::uint32_t dwLowestRva{ 0 }; 20 | std::uint32_t dwHighestRva{ 0 }; 21 | 22 | for (std::uint16_t n = 0; n < GetFileHeader().GetNumberOfSections(); n++) { 23 | // 24 | // Skip sections with bad Misc.VirtualSize 25 | if (m_Image->m_rawSectionHeaders[n].GetVirtualSize() == 0) 26 | continue; 27 | // 28 | // Fill in high/low rvas if possible. 29 | if (m_Image->m_rawSectionHeaders[n].GetVirtualAddress() < dwLowestRva) 30 | dwLowestRva = 31 | m_Image->m_rawSectionHeaders[n].GetVirtualAddress(); 32 | if (m_Image->m_rawSectionHeaders[n].GetVirtualAddress() > dwHighestRva) 33 | dwHighestRva = 34 | m_Image->m_rawSectionHeaders[n].GetVirtualAddress() + m_Image->m_rawSectionHeaders[n].GetVirtualSize(); 35 | } 36 | 37 | return (dwHighestRva - dwLowestRva); 38 | } 39 | 40 | template 41 | std::uint32_t PEHeader::GetStartOfCode() 42 | { 43 | return m_OptionalHeader.GetBaseOfCode(); 44 | } 45 | 46 | template 47 | std::uint32_t PEHeader::GetNextSectionOffset() 48 | { 49 | std::uint16_t nlastSecIdx = GetFileHeader().GetNumberOfSections() - 1; 50 | SectionHeader const& sec = GetSectionHeader(nlastSecIdx); 51 | std::uint32_t uNextOffset = sec.GetPointerToRawData() + sec.GetSizeOfRawData(); 52 | 53 | /* 54 | * FileAlignment 55 | * The alignment of the raw data of sections in the image file, in bytes. 56 | */ 57 | return Align(uNextOffset, GetOptionalHeader().GetFileAlignment()); 58 | } 59 | 60 | template 61 | std::uint32_t PEHeader::GetNextSectionRva() 62 | { 63 | std::uint16_t nlastSecIdx = GetFileHeader().GetNumberOfSections() - 1; 64 | SectionHeader const& sec = GetSectionHeader(nlastSecIdx); 65 | std::uint32_t uNextRva = sec.GetVirtualAddress() + sec.GetVirtualSize(); 66 | 67 | /* 68 | * SectionAlignment 69 | * The alignment of sections loaded in memory, in bytes. 70 | */ 71 | return Align(uNextRva, GetOptionalHeader().GetSectionAlignment()); 72 | } 73 | -------------------------------------------------------------------------------- /vendor/pepp/PELibrary.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | #include "misc/File.hpp" 11 | #include "misc/NonCopyable.hpp" 12 | #include "misc/ByteVector.hpp" 13 | #include "misc/Concept.hpp" 14 | #include "misc/Address.hpp" 15 | 16 | #include "Image.hpp" 17 | #include "PEHeader.hpp" 18 | #include "SectionHeader.hpp" 19 | #include "FileHeader.hpp" 20 | #include "OptionalHeader.hpp" 21 | #include "ExportDirectory.hpp" 22 | #include "ImportDirectory.hpp" 23 | #include "RelocationDirectory.hpp" 24 | #include "PEUtil.hpp" 25 | 26 | -------------------------------------------------------------------------------- /vendor/pepp/PEUtil.cpp: -------------------------------------------------------------------------------- 1 | #include "PELibrary.hpp" 2 | 3 | #include 4 | #pragma comment(lib, "dbghelp.lib") 5 | 6 | using namespace pepp; 7 | 8 | std::string pepp::DemangleName(std::string_view mangled_name) 9 | { 10 | // 11 | // TODO: Don't rely on DbgHelp?? 12 | char undecorated_name[1024]; 13 | UnDecorateSymbolName( 14 | mangled_name.data(), 15 | undecorated_name, 16 | sizeof undecorated_name, 17 | UNDNAME_32_BIT_DECODE | UNDNAME_NAME_ONLY); 18 | 19 | return undecorated_name; 20 | } 21 | 22 | -------------------------------------------------------------------------------- /vendor/pepp/PEUtil.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | 4 | namespace pepp 5 | { 6 | //! Windows 32/64bit declare the page size as 4kb (4096) 7 | static constexpr std::uint32_t PAGE_SIZE = 0x1000; 8 | 9 | //! Align a value 10 | template 11 | constexpr __forceinline auto Align(V_t value, std::uint32_t alignment) requires std::unsigned_integral 12 | { 13 | if (alignment == 0) 14 | return value; 15 | return ((value + alignment) & ~(alignment - 1)); 16 | } 17 | 18 | //! Make a value 4kb aligned (for section purposes) 19 | template 20 | constexpr __forceinline auto Align4kb(V_t v) requires std::unsigned_integral 21 | { 22 | return Align(v, PAGE_SIZE); 23 | } 24 | 25 | //! Demangle a mangled name (MS supplied) 26 | std::string DemangleName(std::string_view mangled_name); 27 | } -------------------------------------------------------------------------------- /vendor/pepp/RelocationDirectory.cpp: -------------------------------------------------------------------------------- 1 | #include "PELibrary.hpp" 2 | 3 | using namespace pepp; 4 | 5 | // Explicit templates. 6 | template class RelocationDirectory<32>; 7 | template class RelocationDirectory<64>; 8 | 9 | template 10 | int RelocationDirectory::GetNumberOfBlocks() const 11 | { 12 | auto base = m_base; 13 | int count = 0; 14 | 15 | while (base->VirtualAddress) 16 | { 17 | count++; 18 | base = decltype(base)((char*)base + base->SizeOfBlock); 19 | } 20 | 21 | return count; 22 | } 23 | 24 | template 25 | int RelocationDirectory::GetNumberOfEntries(detail::Image_t<>::RelocationBase_t* reloc) const 26 | { 27 | // MSDN: The Block Size field is then followed by any number of Type or Offset field entries. 28 | // Each entry is a WORD (2 bytes) 29 | return (reloc->SizeOfBlock - sizeof(decltype(*reloc))) / sizeof(std::uint16_t); 30 | } 31 | 32 | template 33 | std::uint32_t RelocationDirectory::GetRemainingFreeBytes() const 34 | { 35 | auto base = m_base; 36 | std::uint32_t count = 0; 37 | 38 | while (base->VirtualAddress) 39 | { 40 | count += base->SizeOfBlock; 41 | base = decltype(base)((char*)base + base->SizeOfBlock); 42 | } 43 | 44 | return std::max(m_section->GetVirtualSize() - count, 0); 45 | } 46 | 47 | template 48 | bool pepp::RelocationDirectory::ChangeRelocationType(std::uint32_t rva, RelocationType type) 49 | { 50 | auto base = m_base; 51 | std::vector entries; 52 | 53 | while (base->VirtualAddress) 54 | { 55 | int numEntries = GetNumberOfEntries(base); 56 | std::uint16_t* entry = (std::uint16_t*)(base + 1); 57 | 58 | for (int i = 0; i != numEntries; i++, entry++) 59 | { 60 | BlockEntry block(base->VirtualAddress, *entry); 61 | if (block.GetRva() == rva) 62 | { 63 | *entry = CraftRelocationBlockEntry(type, block.GetOffset()); 64 | return true; 65 | } 66 | } 67 | 68 | base = decltype(base)((char*)base + base->SizeOfBlock); 69 | } 70 | 71 | return false; 72 | } 73 | 74 | template 75 | std::vector RelocationDirectory::GetBlockEntries(int blockIdx) 76 | { 77 | auto base = m_base; 78 | int count = 0; 79 | std::vector entries; 80 | 81 | while (base->VirtualAddress) 82 | { 83 | if (count == blockIdx) 84 | { 85 | int numEntries = GetNumberOfEntries(base); 86 | std::uint16_t* entry = (std::uint16_t*)(base + 1); 87 | 88 | for (int i = 0; i != numEntries; i++, entry++) 89 | { 90 | entries.emplace_back(base->VirtualAddress, *entry); 91 | } 92 | } 93 | 94 | base = decltype(base)((char*)base + base->SizeOfBlock); 95 | count++; 96 | } 97 | 98 | return entries; 99 | } 100 | 101 | template 102 | BlockStream RelocationDirectory::CreateBlock(std::uint32_t rva, std::uint32_t num_entries) 103 | { 104 | std::uint32_t size = sizeof(detail::Image_t<>::RelocationBase_t) + num_entries * sizeof(std::uint16_t); 105 | 106 | detail::Image_t<>::RelocationBase_t* reloc; 107 | 108 | std::uint32_t remaining_bytes = GetRemainingFreeBytes(); 109 | if (remaining_bytes < size) 110 | { 111 | assert(m_image->ExtendSection(m_section->GetName(), size - remaining_bytes)); 112 | } 113 | 114 | auto base = m_base; 115 | int count = 0; 116 | 117 | while (base->VirtualAddress) 118 | { 119 | base = decltype(base)((char*)base + base->SizeOfBlock); 120 | } 121 | 122 | base->VirtualAddress = rva; 123 | base->SizeOfBlock = size; 124 | 125 | return BlockStream(base); 126 | } -------------------------------------------------------------------------------- /vendor/pepp/RelocationDirectory.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace pepp 4 | { 5 | /* 6 | * Relocations: research32.blogspot.com/2015/01/base-relocation-table.html 7 | * Format looks like 8 | * 00 10 00 00 | RVA of Block 9 | * 28 01 00 00 | Size of Block 10 | * ?? ?? ?? ?? ..... | Entries in block 11 | * (entry count = (reloc->SizeOfBlock - sizeof(IMAGE_BASE_RELOC)) / sizeof(WORD)) 12 | */ 13 | enum RelocationType : std::int8_t 14 | { 15 | REL_BASED_ABSOLUTE = 0, 16 | REL_BASED_HIGH = 1, 17 | REL_BASED_LOW = 2, 18 | REL_BASED_HIGHLOW = 3, 19 | REL_BASED_HIGHADJ = 4, 20 | REL_BASED_MACHINE_SPECIFIC_5 = 5, 21 | REL_BASED_RESERVED = 6, 22 | REL_BASED_MACHINE_SPECIFIC_7 = 7, 23 | REL_BASED_MACHINE_SPECIFIC_8 = 8, 24 | REL_BASED_MACHINE_SPECIFIC_9 = 9, 25 | REL_BASED_DIR64 = 10 26 | }; 27 | 28 | constexpr std::uint16_t CraftRelocationBlockEntry(RelocationType type, std::uint16_t offset) noexcept { 29 | return (offset & 0xfff) | (type << 12); 30 | } 31 | 32 | class BlockEntry 33 | { 34 | std::uint32_t m_va; 35 | std::uint16_t m_entry; 36 | public: 37 | BlockEntry(std::uint32_t va, std::uint16_t entry) 38 | : m_va(va) 39 | , m_entry(entry) 40 | { 41 | } 42 | 43 | RelocationType GetType() const 44 | { 45 | return static_cast(m_entry >> 12); 46 | } 47 | 48 | std::uint32_t GetOffset() const 49 | { 50 | // Single out the last 12 bits of the entry 51 | return static_cast(m_entry & ((1 << 12) - 1)); 52 | } 53 | 54 | std::uint32_t GetRva() const 55 | { 56 | return m_va + GetOffset(); 57 | } 58 | 59 | constexpr operator std::uint16_t() const 60 | { 61 | return m_entry; 62 | } 63 | }; 64 | 65 | class BlockStream 66 | { 67 | std::uint16_t* m_base; 68 | std::uint32_t m_idx; 69 | std::uint32_t m_max_size; 70 | public: 71 | BlockStream(detail::Image_t<>::RelocationBase_t* reloc) 72 | : m_base((std::uint16_t*)(reloc+1)) 73 | , m_idx(0) 74 | , m_max_size(reloc->SizeOfBlock) 75 | { 76 | } 77 | 78 | void Push(RelocationType type, std::uint16_t offset) 79 | { 80 | if (m_idx * sizeof(uint16_t) >= m_max_size) 81 | return; 82 | 83 | m_base[m_idx++] = CraftRelocationBlockEntry(type, offset); 84 | } 85 | }; 86 | 87 | template 88 | class RelocationDirectory : pepp::msc::NonCopyable 89 | { 90 | friend class Image<32>; 91 | friend class Image<64>; 92 | 93 | using PatchType_t = typename detail::Image_t::Address_t; 94 | 95 | Image* m_image; 96 | detail::Image_t<>::RelocationBase_t* m_base; 97 | SectionHeader* m_section; 98 | public: 99 | 100 | int GetNumberOfBlocks() const; 101 | int GetNumberOfEntries(detail::Image_t<>::RelocationBase_t* reloc) const; 102 | std::uint32_t GetRemainingFreeBytes() const; 103 | bool ChangeRelocationType(std::uint32_t rva, RelocationType type); 104 | std::vector GetBlockEntries(int blockIdx); 105 | BlockStream CreateBlock(std::uint32_t rva, std::uint32_t num_entries); 106 | 107 | bool IsPresent() const { 108 | return m_image->GetPEHeader().GetOptionalHeader().GetDataDirectory(DIRECTORY_ENTRY_BASERELOC).Size > 0; 109 | } 110 | private: 111 | //! Setup the directory 112 | void _setup(Image* image) { 113 | m_image = image; 114 | m_base = reinterpret_cast( 115 | &image->base()[image->GetPEHeader().RvaToOffset( 116 | image->GetPEHeader().GetOptionalHeader().GetDataDirectory(DIRECTORY_ENTRY_BASERELOC).VirtualAddress)]); 117 | m_section = 118 | &image->GetSectionHeaderFromVa(image->GetPEHeader().GetOptionalHeader().GetDataDirectory(DIRECTORY_ENTRY_BASERELOC).VirtualAddress); 119 | } 120 | }; 121 | } -------------------------------------------------------------------------------- /vendor/pepp/SectionHeader.cpp: -------------------------------------------------------------------------------- 1 | #include "PELibrary.hpp" 2 | 3 | using namespace pepp; 4 | 5 | void SectionHeader::SetName(std::string_view name) 6 | { 7 | std:memcpy(m_base.Name, name.data(), name.size()); 8 | } 9 | 10 | std::string SectionHeader::GetName() const 11 | { 12 | char szData[9]; 13 | std::memcpy(szData, m_base.Name, sizeof m_base.Name); 14 | szData[8] = '\0'; 15 | return szData; 16 | } 17 | 18 | std::uint32_t SectionHeader::GetFileAddress() const 19 | { 20 | return m_base.Misc.PhysicalAddress; 21 | } 22 | 23 | void SectionHeader::SetFileAddress(std::uint32_t fileAddress) 24 | { 25 | m_base.Misc.PhysicalAddress = fileAddress; 26 | } 27 | 28 | std::uint32_t SectionHeader::GetVirtualSize() const 29 | { 30 | return m_base.Misc.VirtualSize; 31 | } 32 | 33 | void SectionHeader::SetVirtualSize(std::uint32_t virtualSize) 34 | { 35 | m_base.Misc.VirtualSize = virtualSize; 36 | } 37 | 38 | std::uint32_t SectionHeader::GetVirtualAddress() const 39 | { 40 | return m_base.VirtualAddress; 41 | } 42 | 43 | void SectionHeader::SetVirtualAddress(std::uint32_t va) 44 | { 45 | m_base.VirtualAddress = va; 46 | } 47 | 48 | std::uint32_t SectionHeader::GetSizeOfRawData() const 49 | { 50 | return m_base.SizeOfRawData; 51 | } 52 | 53 | void SectionHeader::SetSizeOfRawData(std::uint32_t sz) 54 | { 55 | m_base.SizeOfRawData = sz; 56 | } 57 | 58 | std::uint32_t SectionHeader::GetPointerToRawData() const 59 | { 60 | return m_base.PointerToRawData; 61 | } 62 | 63 | void SectionHeader::SetPointerToRawData(std::uint32_t ptr) 64 | { 65 | m_base.PointerToRawData = ptr; 66 | } 67 | 68 | std::uint32_t SectionHeader::GetPointerToRelocations() const 69 | { 70 | return m_base.PointerToRelocations; 71 | } 72 | 73 | void SectionHeader::SetPointerToRelocations(std::uint32_t ptr) 74 | { 75 | m_base.PointerToRelocations = ptr; 76 | } 77 | 78 | std::uint32_t SectionHeader::GetPointerToLinenumbers() const 79 | { 80 | return m_base.PointerToLinenumbers; 81 | } 82 | 83 | void SectionHeader::SetPointerToLinenumbers(std::uint32_t ptr) 84 | { 85 | m_base.PointerToLinenumbers = ptr; 86 | } 87 | 88 | std::uint16_t SectionHeader::GetNumberOfRelocations() const 89 | { 90 | return m_base.NumberOfRelocations; 91 | } 92 | 93 | void SectionHeader::SetNumberOfRelocations(std::uint16_t num) 94 | { 95 | m_base.NumberOfRelocations = num; 96 | } 97 | 98 | std::uint16_t SectionHeader::GetNumberOfLinenumbers() const 99 | { 100 | return m_base.NumberOfLinenumbers; 101 | } 102 | 103 | void SectionHeader::SetNumberOfLinenumbers(std::uint16_t num) 104 | { 105 | m_base.NumberOfLinenumbers = num; 106 | } 107 | 108 | std::uint32_t SectionHeader::GetCharacteristics() const 109 | { 110 | return m_base.Characteristics; 111 | } 112 | 113 | void SectionHeader::SetCharacteristics(std::uint32_t chars) 114 | { 115 | m_base.Characteristics = chars; 116 | } 117 | -------------------------------------------------------------------------------- /vendor/pepp/misc/Concept.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace pepp::msc 6 | { 7 | template 8 | concept Arithmetic = std::is_arithmetic_v; 9 | template 10 | concept MemoryAddress = std::is_integral_v || std::is_pointer_v; 11 | } -------------------------------------------------------------------------------- /vendor/pepp/misc/File.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include "File.hpp" 7 | 8 | namespace pepp::io { 9 | 10 | File::File(std::string_view filename, int flags) 11 | : m_filename(filename) 12 | , m_flags(flags) 13 | { 14 | } 15 | 16 | File::File(File&& other) 17 | : m_filename(std::move(other.m_filename)) 18 | , m_flags(other.m_flags) 19 | { 20 | } 21 | 22 | void File::Write(std::string_view text) 23 | { 24 | m_out_file.open(m_filename, m_flags & ~FILE_INPUT); 25 | if (m_out_file.is_open()) { 26 | m_out_file << text; 27 | m_out_file.close(); 28 | } 29 | } 30 | 31 | void File::Write(const std::vector& data) 32 | { 33 | m_out_file.open(m_filename, m_flags & ~FILE_INPUT); 34 | if (m_out_file.is_open()) { 35 | m_out_file.write((const char*)data.data(), data.size()); 36 | m_out_file.close(); 37 | } 38 | } 39 | 40 | std::vector File::Read() 41 | { 42 | std::vector file_buffer; 43 | 44 | m_in_file.open(m_filename, m_flags & ~FILE_OUTPUT); 45 | 46 | if (m_in_file.is_open()) { 47 | file_buffer = std::vector(std::istreambuf_iterator(m_in_file), {}); 48 | m_in_file.close(); 49 | } 50 | 51 | return file_buffer; 52 | } 53 | 54 | std::uintmax_t File::GetSize() 55 | { 56 | return std::filesystem::file_size(m_filename); 57 | } 58 | 59 | File& io::File::operator=(File&& rhs) 60 | { 61 | if (this == &rhs) 62 | return *this; 63 | 64 | std::swap(m_filename, rhs.m_filename); 65 | std::swap(m_flags, rhs.m_flags); 66 | return *this; 67 | } 68 | 69 | } 70 | 71 | 72 | -------------------------------------------------------------------------------- /vendor/pepp/misc/File.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace pepp::io 6 | { 7 | enum FileFlags { 8 | FILE_INPUT = 1, 9 | FILE_OUTPUT = 2, 10 | FILE_APP = 8, 11 | FILE_TRUNC = 16, 12 | FILE_BINARY = 32 13 | }; 14 | 15 | class File { 16 | public: 17 | File() = default; 18 | File(const File& other) = default; 19 | 20 | File(std::string_view filename, int flags); 21 | File(File&& other); 22 | 23 | void Write(std::string_view text); 24 | void Write(const std::vector& data); 25 | std::vector Read(); 26 | std::uintmax_t GetSize(); 27 | 28 | File& operator=(File&& rhs); 29 | 30 | private: 31 | std::string m_filename; 32 | int m_flags; 33 | std::ofstream m_out_file; 34 | std::ifstream m_in_file; 35 | }; 36 | } -------------------------------------------------------------------------------- /vendor/pepp/misc/NonCopyable.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace pepp::msc 4 | { 5 | class NonCopyable { 6 | public: 7 | NonCopyable() = default; 8 | NonCopyable(const NonCopyable&) = delete; 9 | NonCopyable& operator=(const NonCopyable&) = delete; 10 | }; 11 | } -------------------------------------------------------------------------------- /vendor/spdlog/include/spdlog/async.h: -------------------------------------------------------------------------------- 1 | // Copyright(c) 2015-present, Gabi Melman & spdlog contributors. 2 | // Distributed under the MIT License (http://opensource.org/licenses/MIT) 3 | 4 | #pragma once 5 | 6 | // 7 | // Async logging using global thread pool 8 | // All loggers created here share same global thread pool. 9 | // Each log message is pushed to a queue along with a shared pointer to the 10 | // logger. 11 | // If a logger deleted while having pending messages in the queue, it's actual 12 | // destruction will defer 13 | // until all its messages are processed by the thread pool. 14 | // This is because each message in the queue holds a shared_ptr to the 15 | // originating logger. 16 | 17 | #include 18 | #include 19 | #include 20 | 21 | #include 22 | #include 23 | #include 24 | 25 | namespace spdlog { 26 | 27 | namespace details { 28 | static const size_t default_async_q_size = 8192; 29 | } 30 | 31 | // async logger factory - creates async loggers backed with thread pool. 32 | // if a global thread pool doesn't already exist, create it with default queue 33 | // size of 8192 items and single thread. 34 | template 35 | struct async_factory_impl 36 | { 37 | template 38 | static std::shared_ptr create(std::string logger_name, SinkArgs &&...args) 39 | { 40 | auto ®istry_inst = details::registry::instance(); 41 | 42 | // create global thread pool if not already exists.. 43 | 44 | auto &mutex = registry_inst.tp_mutex(); 45 | std::lock_guard tp_lock(mutex); 46 | auto tp = registry_inst.get_tp(); 47 | if (tp == nullptr) 48 | { 49 | tp = std::make_shared(details::default_async_q_size, 1U); 50 | registry_inst.set_tp(tp); 51 | } 52 | 53 | auto sink = std::make_shared(std::forward(args)...); 54 | auto new_logger = std::make_shared(std::move(logger_name), std::move(sink), std::move(tp), OverflowPolicy); 55 | registry_inst.initialize_logger(new_logger); 56 | return new_logger; 57 | } 58 | }; 59 | 60 | using async_factory = async_factory_impl; 61 | using async_factory_nonblock = async_factory_impl; 62 | 63 | template 64 | inline std::shared_ptr create_async(std::string logger_name, SinkArgs &&...sink_args) 65 | { 66 | return async_factory::create(std::move(logger_name), std::forward(sink_args)...); 67 | } 68 | 69 | template 70 | inline std::shared_ptr create_async_nb(std::string logger_name, SinkArgs &&...sink_args) 71 | { 72 | return async_factory_nonblock::create(std::move(logger_name), std::forward(sink_args)...); 73 | } 74 | 75 | // set global thread pool. 76 | inline void init_thread_pool(size_t q_size, size_t thread_count, std::function on_thread_start) 77 | { 78 | auto tp = std::make_shared(q_size, thread_count, on_thread_start); 79 | details::registry::instance().set_tp(std::move(tp)); 80 | } 81 | 82 | // set global thread pool. 83 | inline void init_thread_pool(size_t q_size, size_t thread_count) 84 | { 85 | init_thread_pool(q_size, thread_count, [] {}); 86 | } 87 | 88 | // get the global thread pool. 89 | inline std::shared_ptr thread_pool() 90 | { 91 | return details::registry::instance().get_tp(); 92 | } 93 | } // namespace spdlog 94 | -------------------------------------------------------------------------------- /vendor/spdlog/include/spdlog/async_logger-inl.h: -------------------------------------------------------------------------------- 1 | // Copyright(c) 2015-present, Gabi Melman & spdlog contributors. 2 | // Distributed under the MIT License (http://opensource.org/licenses/MIT) 3 | 4 | #pragma once 5 | 6 | #ifndef SPDLOG_HEADER_ONLY 7 | #include 8 | #endif 9 | 10 | #include 11 | #include 12 | 13 | #include 14 | #include 15 | 16 | SPDLOG_INLINE spdlog::async_logger::async_logger( 17 | std::string logger_name, sinks_init_list sinks_list, std::weak_ptr tp, async_overflow_policy overflow_policy) 18 | : async_logger(std::move(logger_name), sinks_list.begin(), sinks_list.end(), std::move(tp), overflow_policy) 19 | {} 20 | 21 | SPDLOG_INLINE spdlog::async_logger::async_logger( 22 | std::string logger_name, sink_ptr single_sink, std::weak_ptr tp, async_overflow_policy overflow_policy) 23 | : async_logger(std::move(logger_name), {std::move(single_sink)}, std::move(tp), overflow_policy) 24 | {} 25 | 26 | // send the log message to the thread pool 27 | SPDLOG_INLINE void spdlog::async_logger::sink_it_(const details::log_msg &msg) 28 | { 29 | if (auto pool_ptr = thread_pool_.lock()) 30 | { 31 | pool_ptr->post_log(shared_from_this(), msg, overflow_policy_); 32 | } 33 | else 34 | { 35 | throw_spdlog_ex("async log: thread pool doesn't exist anymore"); 36 | } 37 | } 38 | 39 | // send flush request to the thread pool 40 | SPDLOG_INLINE void spdlog::async_logger::flush_() 41 | { 42 | if (auto pool_ptr = thread_pool_.lock()) 43 | { 44 | pool_ptr->post_flush(shared_from_this(), overflow_policy_); 45 | } 46 | else 47 | { 48 | throw_spdlog_ex("async flush: thread pool doesn't exist anymore"); 49 | } 50 | } 51 | 52 | // 53 | // backend functions - called from the thread pool to do the actual job 54 | // 55 | SPDLOG_INLINE void spdlog::async_logger::backend_sink_it_(const details::log_msg &msg) 56 | { 57 | for (auto &sink : sinks_) 58 | { 59 | if (sink->should_log(msg.level)) 60 | { 61 | SPDLOG_TRY 62 | { 63 | sink->log(msg); 64 | } 65 | SPDLOG_LOGGER_CATCH() 66 | } 67 | } 68 | 69 | if (should_flush_(msg)) 70 | { 71 | backend_flush_(); 72 | } 73 | } 74 | 75 | SPDLOG_INLINE void spdlog::async_logger::backend_flush_() 76 | { 77 | for (auto &sink : sinks_) 78 | { 79 | SPDLOG_TRY 80 | { 81 | sink->flush(); 82 | } 83 | SPDLOG_LOGGER_CATCH() 84 | } 85 | } 86 | 87 | SPDLOG_INLINE std::shared_ptr spdlog::async_logger::clone(std::string new_name) 88 | { 89 | auto cloned = std::make_shared(*this); 90 | cloned->name_ = std::move(new_name); 91 | return cloned; 92 | } 93 | -------------------------------------------------------------------------------- /vendor/spdlog/include/spdlog/async_logger.h: -------------------------------------------------------------------------------- 1 | // Copyright(c) 2015-present, Gabi Melman & spdlog contributors. 2 | // Distributed under the MIT License (http://opensource.org/licenses/MIT) 3 | 4 | #pragma once 5 | 6 | // Fast asynchronous logger. 7 | // Uses pre allocated queue. 8 | // Creates a single back thread to pop messages from the queue and log them. 9 | // 10 | // Upon each log write the logger: 11 | // 1. Checks if its log level is enough to log the message 12 | // 2. Push a new copy of the message to a queue (or block the caller until 13 | // space is available in the queue) 14 | // Upon destruction, logs all remaining messages in the queue before 15 | // destructing.. 16 | 17 | #include 18 | 19 | namespace spdlog { 20 | 21 | // Async overflow policy - block by default. 22 | enum class async_overflow_policy 23 | { 24 | block, // Block until message can be enqueued 25 | overrun_oldest // Discard oldest message in the queue if full when trying to 26 | // add new item. 27 | }; 28 | 29 | namespace details { 30 | class thread_pool; 31 | } 32 | 33 | class SPDLOG_API async_logger final : public std::enable_shared_from_this, public logger 34 | { 35 | friend class details::thread_pool; 36 | 37 | public: 38 | template 39 | async_logger(std::string logger_name, It begin, It end, std::weak_ptr tp, 40 | async_overflow_policy overflow_policy = async_overflow_policy::block) 41 | : logger(std::move(logger_name), begin, end) 42 | , thread_pool_(std::move(tp)) 43 | , overflow_policy_(overflow_policy) 44 | {} 45 | 46 | async_logger(std::string logger_name, sinks_init_list sinks_list, std::weak_ptr tp, 47 | async_overflow_policy overflow_policy = async_overflow_policy::block); 48 | 49 | async_logger(std::string logger_name, sink_ptr single_sink, std::weak_ptr tp, 50 | async_overflow_policy overflow_policy = async_overflow_policy::block); 51 | 52 | std::shared_ptr clone(std::string new_name) override; 53 | 54 | protected: 55 | void sink_it_(const details::log_msg &msg) override; 56 | void flush_() override; 57 | void backend_sink_it_(const details::log_msg &incoming_log_msg); 58 | void backend_flush_(); 59 | 60 | private: 61 | std::weak_ptr thread_pool_; 62 | async_overflow_policy overflow_policy_; 63 | }; 64 | } // namespace spdlog 65 | 66 | #ifdef SPDLOG_HEADER_ONLY 67 | #include "async_logger-inl.h" 68 | #endif 69 | -------------------------------------------------------------------------------- /vendor/spdlog/include/spdlog/cfg/argv.h: -------------------------------------------------------------------------------- 1 | // Copyright(c) 2015-present, Gabi Melman & spdlog contributors. 2 | // Distributed under the MIT License (http://opensource.org/licenses/MIT) 3 | 4 | #pragma once 5 | #include 6 | #include 7 | 8 | // 9 | // Init log levels using each argv entry that starts with "SPDLOG_LEVEL=" 10 | // 11 | // set all loggers to debug level: 12 | // example.exe "SPDLOG_LEVEL=debug" 13 | 14 | // set logger1 to trace level 15 | // example.exe "SPDLOG_LEVEL=logger1=trace" 16 | 17 | // turn off all logging except for logger1 and logger2: 18 | // example.exe "SPDLOG_LEVEL=off,logger1=debug,logger2=info" 19 | 20 | namespace spdlog { 21 | namespace cfg { 22 | 23 | // search for SPDLOG_LEVEL= in the args and use it to init the levels 24 | inline void load_argv_levels(int argc, const char **argv) 25 | { 26 | const std::string spdlog_level_prefix = "SPDLOG_LEVEL="; 27 | for (int i = 1; i < argc; i++) 28 | { 29 | std::string arg = argv[i]; 30 | if (arg.find(spdlog_level_prefix) == 0) 31 | { 32 | auto levels_string = arg.substr(spdlog_level_prefix.size()); 33 | helpers::load_levels(levels_string); 34 | } 35 | } 36 | } 37 | 38 | inline void load_argv_levels(int argc, char **argv) 39 | { 40 | load_argv_levels(argc, const_cast(argv)); 41 | } 42 | 43 | } // namespace cfg 44 | } // namespace spdlog 45 | -------------------------------------------------------------------------------- /vendor/spdlog/include/spdlog/cfg/env.h: -------------------------------------------------------------------------------- 1 | // Copyright(c) 2015-present, Gabi Melman & spdlog contributors. 2 | // Distributed under the MIT License (http://opensource.org/licenses/MIT) 3 | 4 | #pragma once 5 | #include 6 | #include 7 | #include 8 | 9 | // 10 | // Init levels and patterns from env variables SPDLOG_LEVEL 11 | // Inspired from Rust's "env_logger" crate (https://crates.io/crates/env_logger). 12 | // Note - fallback to "info" level on unrecognized levels 13 | // 14 | // Examples: 15 | // 16 | // set global level to debug: 17 | // export SPDLOG_LEVEL=debug 18 | // 19 | // turn off all logging except for logger1: 20 | // export SPDLOG_LEVEL="*=off,logger1=debug" 21 | // 22 | 23 | // turn off all logging except for logger1 and logger2: 24 | // export SPDLOG_LEVEL="off,logger1=debug,logger2=info" 25 | 26 | namespace spdlog { 27 | namespace cfg { 28 | inline void load_env_levels() 29 | { 30 | auto env_val = details::os::getenv("SPDLOG_LEVEL"); 31 | if (!env_val.empty()) 32 | { 33 | helpers::load_levels(env_val); 34 | } 35 | } 36 | 37 | } // namespace cfg 38 | } // namespace spdlog 39 | -------------------------------------------------------------------------------- /vendor/spdlog/include/spdlog/cfg/helpers-inl.h: -------------------------------------------------------------------------------- 1 | // Copyright(c) 2015-present, Gabi Melman & spdlog contributors. 2 | // Distributed under the MIT License (http://opensource.org/licenses/MIT) 3 | 4 | #pragma once 5 | 6 | #ifndef SPDLOG_HEADER_ONLY 7 | #include 8 | #endif 9 | 10 | #include 11 | #include 12 | #include 13 | 14 | #include 15 | #include 16 | #include 17 | #include 18 | 19 | namespace spdlog { 20 | namespace cfg { 21 | namespace helpers { 22 | 23 | // inplace convert to lowercase 24 | inline std::string &to_lower_(std::string &str) 25 | { 26 | std::transform( 27 | str.begin(), str.end(), str.begin(), [](char ch) { return static_cast((ch >= 'A' && ch <= 'Z') ? ch + ('a' - 'A') : ch); }); 28 | return str; 29 | } 30 | 31 | // inplace trim spaces 32 | inline std::string &trim_(std::string &str) 33 | { 34 | const char *spaces = " \n\r\t"; 35 | str.erase(str.find_last_not_of(spaces) + 1); 36 | str.erase(0, str.find_first_not_of(spaces)); 37 | return str; 38 | } 39 | 40 | // return (name,value) trimmed pair from given "name=value" string. 41 | // return empty string on missing parts 42 | // "key=val" => ("key", "val") 43 | // " key = val " => ("key", "val") 44 | // "key=" => ("key", "") 45 | // "val" => ("", "val") 46 | 47 | inline std::pair extract_kv_(char sep, const std::string &str) 48 | { 49 | auto n = str.find(sep); 50 | std::string k, v; 51 | if (n == std::string::npos) 52 | { 53 | v = str; 54 | } 55 | else 56 | { 57 | k = str.substr(0, n); 58 | v = str.substr(n + 1); 59 | } 60 | return std::make_pair(trim_(k), trim_(v)); 61 | } 62 | 63 | // return vector of key/value pairs from sequence of "K1=V1,K2=V2,.." 64 | // "a=AAA,b=BBB,c=CCC,.." => {("a","AAA"),("b","BBB"),("c", "CCC"),...} 65 | inline std::unordered_map extract_key_vals_(const std::string &str) 66 | { 67 | std::string token; 68 | std::istringstream token_stream(str); 69 | std::unordered_map rv{}; 70 | while (std::getline(token_stream, token, ',')) 71 | { 72 | if (token.empty()) 73 | { 74 | continue; 75 | } 76 | auto kv = extract_kv_('=', token); 77 | rv[kv.first] = kv.second; 78 | } 79 | return rv; 80 | } 81 | 82 | SPDLOG_INLINE void load_levels(const std::string &input) 83 | { 84 | if (input.empty() || input.size() > 512) 85 | { 86 | return; 87 | } 88 | 89 | auto key_vals = extract_key_vals_(input); 90 | std::unordered_map levels; 91 | level::level_enum global_level = level::info; 92 | bool global_level_found = false; 93 | 94 | for (auto &name_level : key_vals) 95 | { 96 | auto &logger_name = name_level.first; 97 | auto level_name = to_lower_(name_level.second); 98 | auto level = level::from_str(level_name); 99 | // ignore unrecognized level names 100 | if (level == level::off && level_name != "off") 101 | { 102 | continue; 103 | } 104 | if (logger_name.empty()) // no logger name indicate global level 105 | { 106 | global_level_found = true; 107 | global_level = level; 108 | } 109 | else 110 | { 111 | levels[logger_name] = level; 112 | } 113 | } 114 | 115 | details::registry::instance().set_levels(std::move(levels), global_level_found ? &global_level : nullptr); 116 | } 117 | 118 | } // namespace helpers 119 | } // namespace cfg 120 | } // namespace spdlog 121 | -------------------------------------------------------------------------------- /vendor/spdlog/include/spdlog/cfg/helpers.h: -------------------------------------------------------------------------------- 1 | // Copyright(c) 2015-present, Gabi Melman & spdlog contributors. 2 | // Distributed under the MIT License (http://opensource.org/licenses/MIT) 3 | 4 | #pragma once 5 | 6 | #include 7 | #include 8 | 9 | namespace spdlog { 10 | namespace cfg { 11 | namespace helpers { 12 | // 13 | // Init levels from given string 14 | // 15 | // Examples: 16 | // 17 | // set global level to debug: "debug" 18 | // turn off all logging except for logger1: "off,logger1=debug" 19 | // turn off all logging except for logger1 and logger2: "off,logger1=debug,logger2=info" 20 | // 21 | SPDLOG_API void load_levels(const std::string &txt); 22 | } // namespace helpers 23 | 24 | } // namespace cfg 25 | } // namespace spdlog 26 | 27 | #ifdef SPDLOG_HEADER_ONLY 28 | #include "helpers-inl.h" 29 | #endif // SPDLOG_HEADER_ONLY 30 | -------------------------------------------------------------------------------- /vendor/spdlog/include/spdlog/common-inl.h: -------------------------------------------------------------------------------- 1 | // Copyright(c) 2015-present, Gabi Melman & spdlog contributors. 2 | // Distributed under the MIT License (http://opensource.org/licenses/MIT) 3 | 4 | #pragma once 5 | 6 | #ifndef SPDLOG_HEADER_ONLY 7 | #include 8 | #endif 9 | 10 | #include 11 | #include 12 | 13 | namespace spdlog { 14 | namespace level { 15 | 16 | #if __cplusplus >= 201703L 17 | constexpr 18 | #endif 19 | static string_view_t level_string_views[] SPDLOG_LEVEL_NAMES; 20 | 21 | static const char *short_level_names[] SPDLOG_SHORT_LEVEL_NAMES; 22 | 23 | SPDLOG_INLINE const string_view_t &to_string_view(spdlog::level::level_enum l) SPDLOG_NOEXCEPT 24 | { 25 | return level_string_views[l]; 26 | } 27 | 28 | SPDLOG_INLINE const char *to_short_c_str(spdlog::level::level_enum l) SPDLOG_NOEXCEPT 29 | { 30 | return short_level_names[l]; 31 | } 32 | 33 | SPDLOG_INLINE spdlog::level::level_enum from_str(const std::string &name) SPDLOG_NOEXCEPT 34 | { 35 | auto it = std::find(std::begin(level_string_views), std::end(level_string_views), name); 36 | if (it != std::end(level_string_views)) 37 | return static_cast(std::distance(std::begin(level_string_views), it)); 38 | 39 | // check also for "warn" and "err" before giving up.. 40 | if (name == "warn") 41 | { 42 | return level::warn; 43 | } 44 | if (name == "err") 45 | { 46 | return level::err; 47 | } 48 | return level::off; 49 | } 50 | } // namespace level 51 | 52 | SPDLOG_INLINE spdlog_ex::spdlog_ex(std::string msg) 53 | : msg_(std::move(msg)) 54 | {} 55 | 56 | SPDLOG_INLINE spdlog_ex::spdlog_ex(const std::string &msg, int last_errno) 57 | { 58 | memory_buf_t outbuf; 59 | fmt::format_system_error(outbuf, last_errno, msg.c_str()); 60 | msg_ = fmt::to_string(outbuf); 61 | } 62 | 63 | SPDLOG_INLINE const char *spdlog_ex::what() const SPDLOG_NOEXCEPT 64 | { 65 | return msg_.c_str(); 66 | } 67 | 68 | SPDLOG_INLINE void throw_spdlog_ex(const std::string &msg, int last_errno) 69 | { 70 | SPDLOG_THROW(spdlog_ex(msg, last_errno)); 71 | } 72 | 73 | SPDLOG_INLINE void throw_spdlog_ex(std::string msg) 74 | { 75 | SPDLOG_THROW(spdlog_ex(std::move(msg))); 76 | } 77 | 78 | } // namespace spdlog 79 | -------------------------------------------------------------------------------- /vendor/spdlog/include/spdlog/details/backtracer-inl.h: -------------------------------------------------------------------------------- 1 | // Copyright(c) 2015-present, Gabi Melman & spdlog contributors. 2 | // Distributed under the MIT License (http://opensource.org/licenses/MIT) 3 | 4 | #pragma once 5 | 6 | #ifndef SPDLOG_HEADER_ONLY 7 | #include 8 | #endif 9 | namespace spdlog { 10 | namespace details { 11 | SPDLOG_INLINE backtracer::backtracer(const backtracer &other) 12 | { 13 | std::lock_guard lock(other.mutex_); 14 | enabled_ = other.enabled(); 15 | messages_ = other.messages_; 16 | } 17 | 18 | SPDLOG_INLINE backtracer::backtracer(backtracer &&other) SPDLOG_NOEXCEPT 19 | { 20 | std::lock_guard lock(other.mutex_); 21 | enabled_ = other.enabled(); 22 | messages_ = std::move(other.messages_); 23 | } 24 | 25 | SPDLOG_INLINE backtracer &backtracer::operator=(backtracer other) 26 | { 27 | std::lock_guard lock(mutex_); 28 | enabled_ = other.enabled(); 29 | messages_ = std::move(other.messages_); 30 | return *this; 31 | } 32 | 33 | SPDLOG_INLINE void backtracer::enable(size_t size) 34 | { 35 | std::lock_guard lock{mutex_}; 36 | enabled_.store(true, std::memory_order_relaxed); 37 | messages_ = circular_q{size}; 38 | } 39 | 40 | SPDLOG_INLINE void backtracer::disable() 41 | { 42 | std::lock_guard lock{mutex_}; 43 | enabled_.store(false, std::memory_order_relaxed); 44 | } 45 | 46 | SPDLOG_INLINE bool backtracer::enabled() const 47 | { 48 | return enabled_.load(std::memory_order_relaxed); 49 | } 50 | 51 | SPDLOG_INLINE void backtracer::push_back(const log_msg &msg) 52 | { 53 | std::lock_guard lock{mutex_}; 54 | messages_.push_back(log_msg_buffer{msg}); 55 | } 56 | 57 | // pop all items in the q and apply the given fun on each of them. 58 | SPDLOG_INLINE void backtracer::foreach_pop(std::function fun) 59 | { 60 | std::lock_guard lock{mutex_}; 61 | while (!messages_.empty()) 62 | { 63 | auto &front_msg = messages_.front(); 64 | fun(front_msg); 65 | messages_.pop_front(); 66 | } 67 | } 68 | } // namespace details 69 | } // namespace spdlog 70 | -------------------------------------------------------------------------------- /vendor/spdlog/include/spdlog/details/backtracer.h: -------------------------------------------------------------------------------- 1 | // Copyright(c) 2015-present, Gabi Melman & spdlog contributors. 2 | // Distributed under the MIT License (http://opensource.org/licenses/MIT) 3 | 4 | #pragma once 5 | 6 | #include 7 | #include 8 | 9 | #include 10 | #include 11 | #include 12 | 13 | // Store log messages in circular buffer. 14 | // Useful for storing debug data in case of error/warning happens. 15 | 16 | namespace spdlog { 17 | namespace details { 18 | class SPDLOG_API backtracer 19 | { 20 | mutable std::mutex mutex_; 21 | std::atomic enabled_{false}; 22 | circular_q messages_; 23 | 24 | public: 25 | backtracer() = default; 26 | backtracer(const backtracer &other); 27 | 28 | backtracer(backtracer &&other) SPDLOG_NOEXCEPT; 29 | backtracer &operator=(backtracer other); 30 | 31 | void enable(size_t size); 32 | void disable(); 33 | bool enabled() const; 34 | void push_back(const log_msg &msg); 35 | 36 | // pop all items in the q and apply the given fun on each of them. 37 | void foreach_pop(std::function fun); 38 | }; 39 | 40 | } // namespace details 41 | } // namespace spdlog 42 | 43 | #ifdef SPDLOG_HEADER_ONLY 44 | #include "backtracer-inl.h" 45 | #endif 46 | 47 | -------------------------------------------------------------------------------- /vendor/spdlog/include/spdlog/details/console_globals.h: -------------------------------------------------------------------------------- 1 | // Copyright(c) 2015-present, Gabi Melman & spdlog contributors. 2 | // Distributed under the MIT License (http://opensource.org/licenses/MIT) 3 | 4 | #pragma once 5 | 6 | #include 7 | #include 8 | 9 | namespace spdlog { 10 | namespace details { 11 | 12 | struct console_mutex 13 | { 14 | using mutex_t = std::mutex; 15 | static mutex_t &mutex() 16 | { 17 | static mutex_t s_mutex; 18 | return s_mutex; 19 | } 20 | }; 21 | 22 | struct console_nullmutex 23 | { 24 | using mutex_t = null_mutex; 25 | static mutex_t &mutex() 26 | { 27 | static mutex_t s_mutex; 28 | return s_mutex; 29 | } 30 | }; 31 | } // namespace details 32 | } // namespace spdlog 33 | -------------------------------------------------------------------------------- /vendor/spdlog/include/spdlog/details/file_helper.h: -------------------------------------------------------------------------------- 1 | // Copyright(c) 2015-present, Gabi Melman & spdlog contributors. 2 | // Distributed under the MIT License (http://opensource.org/licenses/MIT) 3 | 4 | #pragma once 5 | 6 | #include 7 | #include 8 | 9 | namespace spdlog { 10 | namespace details { 11 | 12 | // Helper class for file sinks. 13 | // When failing to open a file, retry several times(5) with a delay interval(10 ms). 14 | // Throw spdlog_ex exception on errors. 15 | 16 | class SPDLOG_API file_helper 17 | { 18 | public: 19 | explicit file_helper() = default; 20 | 21 | file_helper(const file_helper &) = delete; 22 | file_helper &operator=(const file_helper &) = delete; 23 | ~file_helper(); 24 | 25 | void open(const filename_t &fname, bool truncate = false); 26 | void reopen(bool truncate); 27 | void flush(); 28 | void close(); 29 | void write(const memory_buf_t &buf); 30 | size_t size() const; 31 | const filename_t &filename() const; 32 | 33 | // 34 | // return file path and its extension: 35 | // 36 | // "mylog.txt" => ("mylog", ".txt") 37 | // "mylog" => ("mylog", "") 38 | // "mylog." => ("mylog.", "") 39 | // "/dir1/dir2/mylog.txt" => ("/dir1/dir2/mylog", ".txt") 40 | // 41 | // the starting dot in filenames is ignored (hidden files): 42 | // 43 | // ".mylog" => (".mylog". "") 44 | // "my_folder/.mylog" => ("my_folder/.mylog", "") 45 | // "my_folder/.mylog.txt" => ("my_folder/.mylog", ".txt") 46 | static std::tuple split_by_extension(const filename_t &fname); 47 | 48 | private: 49 | const int open_tries_ = 5; 50 | const unsigned int open_interval_ = 10; 51 | std::FILE *fd_{nullptr}; 52 | filename_t filename_; 53 | }; 54 | } // namespace details 55 | } // namespace spdlog 56 | 57 | #ifdef SPDLOG_HEADER_ONLY 58 | #include "file_helper-inl.h" 59 | #endif 60 | -------------------------------------------------------------------------------- /vendor/spdlog/include/spdlog/details/fmt_helper.h: -------------------------------------------------------------------------------- 1 | // Copyright(c) 2015-present, Gabi Melman & spdlog contributors. 2 | // Distributed under the MIT License (http://opensource.org/licenses/MIT) 3 | #pragma once 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | // Some fmt helpers to efficiently format and pad ints and strings 12 | namespace spdlog { 13 | namespace details { 14 | namespace fmt_helper { 15 | 16 | inline spdlog::string_view_t to_string_view(const memory_buf_t &buf) SPDLOG_NOEXCEPT 17 | { 18 | return spdlog::string_view_t{buf.data(), buf.size()}; 19 | } 20 | 21 | inline void append_string_view(spdlog::string_view_t view, memory_buf_t &dest) 22 | { 23 | auto *buf_ptr = view.data(); 24 | dest.append(buf_ptr, buf_ptr + view.size()); 25 | } 26 | 27 | template 28 | inline void append_int(T n, memory_buf_t &dest) 29 | { 30 | fmt::format_int i(n); 31 | dest.append(i.data(), i.data() + i.size()); 32 | } 33 | 34 | template 35 | inline unsigned int count_digits(T n) 36 | { 37 | using count_type = typename std::conditional<(sizeof(T) > sizeof(uint32_t)), uint64_t, uint32_t>::type; 38 | return static_cast(fmt:: 39 | // fmt 7.0.0 renamed the internal namespace to detail. 40 | // See: https://github.com/fmtlib/fmt/issues/1538 41 | #if FMT_VERSION < 70000 42 | internal 43 | #else 44 | detail 45 | #endif 46 | ::count_digits(static_cast(n))); 47 | } 48 | 49 | inline void pad2(int n, memory_buf_t &dest) 50 | { 51 | if (n >= 0 && n < 100) // 0-99 52 | { 53 | dest.push_back(static_cast('0' + n / 10)); 54 | dest.push_back(static_cast('0' + n % 10)); 55 | } 56 | else // unlikely, but just in case, let fmt deal with it 57 | { 58 | fmt::format_to(std::back_inserter(dest), "{:02}", n); 59 | } 60 | } 61 | 62 | template 63 | inline void pad_uint(T n, unsigned int width, memory_buf_t &dest) 64 | { 65 | static_assert(std::is_unsigned::value, "pad_uint must get unsigned T"); 66 | for (auto digits = count_digits(n); digits < width; digits++) 67 | { 68 | dest.push_back('0'); 69 | } 70 | append_int(n, dest); 71 | } 72 | 73 | template 74 | inline void pad3(T n, memory_buf_t &dest) 75 | { 76 | static_assert(std::is_unsigned::value, "pad3 must get unsigned T"); 77 | if (n < 1000) 78 | { 79 | dest.push_back(static_cast(n / 100 + '0')); 80 | n = n % 100; 81 | dest.push_back(static_cast((n / 10) + '0')); 82 | dest.push_back(static_cast((n % 10) + '0')); 83 | } 84 | else 85 | { 86 | append_int(n, dest); 87 | } 88 | } 89 | 90 | template 91 | inline void pad6(T n, memory_buf_t &dest) 92 | { 93 | pad_uint(n, 6, dest); 94 | } 95 | 96 | template 97 | inline void pad9(T n, memory_buf_t &dest) 98 | { 99 | pad_uint(n, 9, dest); 100 | } 101 | 102 | // return fraction of a second of the given time_point. 103 | // e.g. 104 | // fraction(tp) -> will return the millis part of the second 105 | template 106 | inline ToDuration time_fraction(log_clock::time_point tp) 107 | { 108 | using std::chrono::duration_cast; 109 | using std::chrono::seconds; 110 | auto duration = tp.time_since_epoch(); 111 | auto secs = duration_cast(duration); 112 | return duration_cast(duration) - duration_cast(secs); 113 | } 114 | 115 | } // namespace fmt_helper 116 | } // namespace details 117 | } // namespace spdlog 118 | -------------------------------------------------------------------------------- /vendor/spdlog/include/spdlog/details/log_msg-inl.h: -------------------------------------------------------------------------------- 1 | // Copyright(c) 2015-present, Gabi Melman & spdlog contributors. 2 | // Distributed under the MIT License (http://opensource.org/licenses/MIT) 3 | 4 | #pragma once 5 | 6 | #ifndef SPDLOG_HEADER_ONLY 7 | #include 8 | #endif 9 | 10 | #include 11 | 12 | namespace spdlog { 13 | namespace details { 14 | 15 | SPDLOG_INLINE log_msg::log_msg(spdlog::log_clock::time_point log_time, spdlog::source_loc loc, string_view_t a_logger_name, 16 | spdlog::level::level_enum lvl, spdlog::string_view_t msg) 17 | : logger_name(a_logger_name) 18 | , level(lvl) 19 | , time(log_time) 20 | #ifndef SPDLOG_NO_THREAD_ID 21 | , thread_id(os::thread_id()) 22 | #endif 23 | , source(loc) 24 | , payload(msg) 25 | {} 26 | 27 | SPDLOG_INLINE log_msg::log_msg( 28 | spdlog::source_loc loc, string_view_t a_logger_name, spdlog::level::level_enum lvl, spdlog::string_view_t msg) 29 | : log_msg(os::now(), loc, a_logger_name, lvl, msg) 30 | {} 31 | 32 | SPDLOG_INLINE log_msg::log_msg(string_view_t a_logger_name, spdlog::level::level_enum lvl, spdlog::string_view_t msg) 33 | : log_msg(os::now(), source_loc{}, a_logger_name, lvl, msg) 34 | {} 35 | 36 | } // namespace details 37 | } // namespace spdlog 38 | -------------------------------------------------------------------------------- /vendor/spdlog/include/spdlog/details/log_msg.h: -------------------------------------------------------------------------------- 1 | // Copyright(c) 2015-present, Gabi Melman & spdlog contributors. 2 | // Distributed under the MIT License (http://opensource.org/licenses/MIT) 3 | 4 | #pragma once 5 | 6 | #include 7 | #include 8 | 9 | namespace spdlog { 10 | namespace details { 11 | struct SPDLOG_API log_msg 12 | { 13 | log_msg() = default; 14 | log_msg(log_clock::time_point log_time, source_loc loc, string_view_t logger_name, level::level_enum lvl, string_view_t msg); 15 | log_msg(source_loc loc, string_view_t logger_name, level::level_enum lvl, string_view_t msg); 16 | log_msg(string_view_t logger_name, level::level_enum lvl, string_view_t msg); 17 | log_msg(const log_msg &other) = default; 18 | log_msg &operator=(const log_msg &other) = default; 19 | 20 | string_view_t logger_name; 21 | level::level_enum level{level::off}; 22 | log_clock::time_point time; 23 | size_t thread_id{0}; 24 | 25 | // wrapping the formatted text with color (updated by pattern_formatter). 26 | mutable size_t color_range_start{0}; 27 | mutable size_t color_range_end{0}; 28 | 29 | source_loc source; 30 | string_view_t payload; 31 | }; 32 | } // namespace details 33 | } // namespace spdlog 34 | 35 | #ifdef SPDLOG_HEADER_ONLY 36 | #include "log_msg-inl.h" 37 | #endif 38 | -------------------------------------------------------------------------------- /vendor/spdlog/include/spdlog/details/log_msg_buffer-inl.h: -------------------------------------------------------------------------------- 1 | // Copyright(c) 2015-present, Gabi Melman & spdlog contributors. 2 | // Distributed under the MIT License (http://opensource.org/licenses/MIT) 3 | 4 | #pragma once 5 | 6 | #ifndef SPDLOG_HEADER_ONLY 7 | #include 8 | #endif 9 | 10 | namespace spdlog { 11 | namespace details { 12 | 13 | SPDLOG_INLINE log_msg_buffer::log_msg_buffer(const log_msg &orig_msg) 14 | : log_msg{orig_msg} 15 | { 16 | buffer.append(logger_name.begin(), logger_name.end()); 17 | buffer.append(payload.begin(), payload.end()); 18 | update_string_views(); 19 | } 20 | 21 | SPDLOG_INLINE log_msg_buffer::log_msg_buffer(const log_msg_buffer &other) 22 | : log_msg{other} 23 | { 24 | buffer.append(logger_name.begin(), logger_name.end()); 25 | buffer.append(payload.begin(), payload.end()); 26 | update_string_views(); 27 | } 28 | 29 | SPDLOG_INLINE log_msg_buffer::log_msg_buffer(log_msg_buffer &&other) SPDLOG_NOEXCEPT 30 | : log_msg{other} 31 | , buffer{std::move(other.buffer)} 32 | { 33 | update_string_views(); 34 | } 35 | 36 | SPDLOG_INLINE log_msg_buffer &log_msg_buffer::operator=(const log_msg_buffer &other) 37 | { 38 | log_msg::operator=(other); 39 | buffer.clear(); 40 | buffer.append(other.buffer.data(), other.buffer.data() + other.buffer.size()); 41 | update_string_views(); 42 | return *this; 43 | } 44 | 45 | SPDLOG_INLINE log_msg_buffer &log_msg_buffer::operator=(log_msg_buffer &&other) SPDLOG_NOEXCEPT 46 | { 47 | log_msg::operator=(other); 48 | buffer = std::move(other.buffer); 49 | update_string_views(); 50 | return *this; 51 | } 52 | 53 | SPDLOG_INLINE void log_msg_buffer::update_string_views() 54 | { 55 | logger_name = string_view_t{buffer.data(), logger_name.size()}; 56 | payload = string_view_t{buffer.data() + logger_name.size(), payload.size()}; 57 | } 58 | 59 | } // namespace details 60 | } // namespace spdlog 61 | -------------------------------------------------------------------------------- /vendor/spdlog/include/spdlog/details/log_msg_buffer.h: -------------------------------------------------------------------------------- 1 | // Copyright(c) 2015-present, Gabi Melman & spdlog contributors. 2 | // Distributed under the MIT License (http://opensource.org/licenses/MIT) 3 | 4 | #pragma once 5 | 6 | #include 7 | 8 | namespace spdlog { 9 | namespace details { 10 | 11 | // Extend log_msg with internal buffer to store its payload. 12 | // This is needed since log_msg holds string_views that points to stack data. 13 | 14 | class SPDLOG_API log_msg_buffer : public log_msg 15 | { 16 | memory_buf_t buffer; 17 | void update_string_views(); 18 | 19 | public: 20 | log_msg_buffer() = default; 21 | explicit log_msg_buffer(const log_msg &orig_msg); 22 | log_msg_buffer(const log_msg_buffer &other); 23 | log_msg_buffer(log_msg_buffer &&other) SPDLOG_NOEXCEPT; 24 | log_msg_buffer &operator=(const log_msg_buffer &other); 25 | log_msg_buffer &operator=(log_msg_buffer &&other) SPDLOG_NOEXCEPT; 26 | }; 27 | 28 | } // namespace details 29 | } // namespace spdlog 30 | 31 | #ifdef SPDLOG_HEADER_ONLY 32 | #include "log_msg_buffer-inl.h" 33 | #endif 34 | -------------------------------------------------------------------------------- /vendor/spdlog/include/spdlog/details/null_mutex.h: -------------------------------------------------------------------------------- 1 | // Copyright(c) 2015-present, Gabi Melman & spdlog contributors. 2 | // Distributed under the MIT License (http://opensource.org/licenses/MIT) 3 | 4 | #pragma once 5 | 6 | #include 7 | #include 8 | // null, no cost dummy "mutex" and dummy "atomic" int 9 | 10 | namespace spdlog { 11 | namespace details { 12 | struct null_mutex 13 | { 14 | void lock() const {} 15 | void unlock() const {} 16 | bool try_lock() const 17 | { 18 | return true; 19 | } 20 | }; 21 | 22 | struct null_atomic_int 23 | { 24 | int value; 25 | null_atomic_int() = default; 26 | 27 | explicit null_atomic_int(int new_value) 28 | : value(new_value) 29 | {} 30 | 31 | int load(std::memory_order = std::memory_order_relaxed) const 32 | { 33 | return value; 34 | } 35 | 36 | void store(int new_value, std::memory_order = std::memory_order_relaxed) 37 | { 38 | value = new_value; 39 | } 40 | 41 | int exchange(int new_value, std::memory_order = std::memory_order_relaxed) 42 | { 43 | std::swap(new_value, value); 44 | return new_value; // return value before the call 45 | } 46 | }; 47 | 48 | } // namespace details 49 | } // namespace spdlog 50 | -------------------------------------------------------------------------------- /vendor/spdlog/include/spdlog/details/periodic_worker-inl.h: -------------------------------------------------------------------------------- 1 | // Copyright(c) 2015-present, Gabi Melman & spdlog contributors. 2 | // Distributed under the MIT License (http://opensource.org/licenses/MIT) 3 | 4 | #pragma once 5 | 6 | #ifndef SPDLOG_HEADER_ONLY 7 | #include 8 | #endif 9 | 10 | namespace spdlog { 11 | namespace details { 12 | 13 | SPDLOG_INLINE periodic_worker::periodic_worker(const std::function &callback_fun, std::chrono::seconds interval) 14 | { 15 | active_ = (interval > std::chrono::seconds::zero()); 16 | if (!active_) 17 | { 18 | return; 19 | } 20 | 21 | worker_thread_ = std::thread([this, callback_fun, interval]() { 22 | for (;;) 23 | { 24 | std::unique_lock lock(this->mutex_); 25 | if (this->cv_.wait_for(lock, interval, [this] { return !this->active_; })) 26 | { 27 | return; // active_ == false, so exit this thread 28 | } 29 | callback_fun(); 30 | } 31 | }); 32 | } 33 | 34 | // stop the worker thread and join it 35 | SPDLOG_INLINE periodic_worker::~periodic_worker() 36 | { 37 | if (worker_thread_.joinable()) 38 | { 39 | { 40 | std::lock_guard lock(mutex_); 41 | active_ = false; 42 | } 43 | cv_.notify_one(); 44 | worker_thread_.join(); 45 | } 46 | } 47 | 48 | } // namespace details 49 | } // namespace spdlog 50 | -------------------------------------------------------------------------------- /vendor/spdlog/include/spdlog/details/periodic_worker.h: -------------------------------------------------------------------------------- 1 | // Copyright(c) 2015-present, Gabi Melman & spdlog contributors. 2 | // Distributed under the MIT License (http://opensource.org/licenses/MIT) 3 | 4 | #pragma once 5 | 6 | // periodic worker thread - periodically executes the given callback function. 7 | // 8 | // RAII over the owned thread: 9 | // creates the thread on construction. 10 | // stops and joins the thread on destruction (if the thread is executing a callback, wait for it to finish first). 11 | 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | namespace spdlog { 18 | namespace details { 19 | 20 | class SPDLOG_API periodic_worker 21 | { 22 | public: 23 | periodic_worker(const std::function &callback_fun, std::chrono::seconds interval); 24 | periodic_worker(const periodic_worker &) = delete; 25 | periodic_worker &operator=(const periodic_worker &) = delete; 26 | // stop the worker thread and join it 27 | ~periodic_worker(); 28 | 29 | private: 30 | bool active_; 31 | std::thread worker_thread_; 32 | std::mutex mutex_; 33 | std::condition_variable cv_; 34 | }; 35 | } // namespace details 36 | } // namespace spdlog 37 | 38 | #ifdef SPDLOG_HEADER_ONLY 39 | #include "periodic_worker-inl.h" 40 | #endif 41 | -------------------------------------------------------------------------------- /vendor/spdlog/include/spdlog/details/synchronous_factory.h: -------------------------------------------------------------------------------- 1 | // Copyright(c) 2015-present, Gabi Melman & spdlog contributors. 2 | // Distributed under the MIT License (http://opensource.org/licenses/MIT) 3 | 4 | #pragma once 5 | 6 | #include "registry.h" 7 | 8 | namespace spdlog { 9 | 10 | // Default logger factory- creates synchronous loggers 11 | class logger; 12 | 13 | struct synchronous_factory 14 | { 15 | template 16 | static std::shared_ptr create(std::string logger_name, SinkArgs &&...args) 17 | { 18 | auto sink = std::make_shared(std::forward(args)...); 19 | auto new_logger = std::make_shared(std::move(logger_name), std::move(sink)); 20 | details::registry::instance().initialize_logger(new_logger); 21 | return new_logger; 22 | } 23 | }; 24 | } // namespace spdlog 25 | 26 | -------------------------------------------------------------------------------- /vendor/spdlog/include/spdlog/details/thread_pool-inl.h: -------------------------------------------------------------------------------- 1 | // Copyright(c) 2015-present, Gabi Melman & spdlog contributors. 2 | // Distributed under the MIT License (http://opensource.org/licenses/MIT) 3 | 4 | #pragma once 5 | 6 | #ifndef SPDLOG_HEADER_ONLY 7 | #include 8 | #endif 9 | 10 | #include 11 | #include 12 | 13 | namespace spdlog { 14 | namespace details { 15 | 16 | SPDLOG_INLINE thread_pool::thread_pool(size_t q_max_items, size_t threads_n, std::function on_thread_start) 17 | : q_(q_max_items) 18 | { 19 | if (threads_n == 0 || threads_n > 1000) 20 | { 21 | throw_spdlog_ex("spdlog::thread_pool(): invalid threads_n param (valid " 22 | "range is 1-1000)"); 23 | } 24 | for (size_t i = 0; i < threads_n; i++) 25 | { 26 | threads_.emplace_back([this, on_thread_start] { 27 | on_thread_start(); 28 | this->thread_pool::worker_loop_(); 29 | }); 30 | } 31 | } 32 | 33 | SPDLOG_INLINE thread_pool::thread_pool(size_t q_max_items, size_t threads_n) 34 | : thread_pool(q_max_items, threads_n, [] {}) 35 | {} 36 | 37 | // message all threads to terminate gracefully join them 38 | SPDLOG_INLINE thread_pool::~thread_pool() 39 | { 40 | SPDLOG_TRY 41 | { 42 | for (size_t i = 0; i < threads_.size(); i++) 43 | { 44 | post_async_msg_(async_msg(async_msg_type::terminate), async_overflow_policy::block); 45 | } 46 | 47 | for (auto &t : threads_) 48 | { 49 | t.join(); 50 | } 51 | } 52 | SPDLOG_CATCH_STD 53 | } 54 | 55 | void SPDLOG_INLINE thread_pool::post_log(async_logger_ptr &&worker_ptr, const details::log_msg &msg, async_overflow_policy overflow_policy) 56 | { 57 | async_msg async_m(std::move(worker_ptr), async_msg_type::log, msg); 58 | post_async_msg_(std::move(async_m), overflow_policy); 59 | } 60 | 61 | void SPDLOG_INLINE thread_pool::post_flush(async_logger_ptr &&worker_ptr, async_overflow_policy overflow_policy) 62 | { 63 | post_async_msg_(async_msg(std::move(worker_ptr), async_msg_type::flush), overflow_policy); 64 | } 65 | 66 | size_t SPDLOG_INLINE thread_pool::overrun_counter() 67 | { 68 | return q_.overrun_counter(); 69 | } 70 | 71 | size_t SPDLOG_INLINE thread_pool::queue_size() 72 | { 73 | return q_.size(); 74 | } 75 | 76 | void SPDLOG_INLINE thread_pool::post_async_msg_(async_msg &&new_msg, async_overflow_policy overflow_policy) 77 | { 78 | if (overflow_policy == async_overflow_policy::block) 79 | { 80 | q_.enqueue(std::move(new_msg)); 81 | } 82 | else 83 | { 84 | q_.enqueue_nowait(std::move(new_msg)); 85 | } 86 | } 87 | 88 | void SPDLOG_INLINE thread_pool::worker_loop_() 89 | { 90 | while (process_next_msg_()) {} 91 | } 92 | 93 | // process next message in the queue 94 | // return true if this thread should still be active (while no terminate msg 95 | // was received) 96 | bool SPDLOG_INLINE thread_pool::process_next_msg_() 97 | { 98 | async_msg incoming_async_msg; 99 | bool dequeued = q_.dequeue_for(incoming_async_msg, std::chrono::seconds(10)); 100 | if (!dequeued) 101 | { 102 | return true; 103 | } 104 | 105 | switch (incoming_async_msg.msg_type) 106 | { 107 | case async_msg_type::log: { 108 | incoming_async_msg.worker_ptr->backend_sink_it_(incoming_async_msg); 109 | return true; 110 | } 111 | case async_msg_type::flush: { 112 | incoming_async_msg.worker_ptr->backend_flush_(); 113 | return true; 114 | } 115 | 116 | case async_msg_type::terminate: { 117 | return false; 118 | } 119 | 120 | default: { 121 | assert(false); 122 | } 123 | } 124 | 125 | return true; 126 | } 127 | 128 | } // namespace details 129 | } // namespace spdlog 130 | -------------------------------------------------------------------------------- /vendor/spdlog/include/spdlog/details/thread_pool.h: -------------------------------------------------------------------------------- 1 | // Copyright(c) 2015-present, Gabi Melman & spdlog contributors. 2 | // Distributed under the MIT License (http://opensource.org/licenses/MIT) 3 | 4 | #pragma once 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | 16 | namespace spdlog { 17 | class async_logger; 18 | 19 | namespace details { 20 | 21 | using async_logger_ptr = std::shared_ptr; 22 | 23 | enum class async_msg_type 24 | { 25 | log, 26 | flush, 27 | terminate 28 | }; 29 | 30 | #include 31 | // Async msg to move to/from the queue 32 | // Movable only. should never be copied 33 | struct async_msg : log_msg_buffer 34 | { 35 | async_msg_type msg_type{async_msg_type::log}; 36 | async_logger_ptr worker_ptr; 37 | 38 | async_msg() = default; 39 | ~async_msg() = default; 40 | 41 | // should only be moved in or out of the queue.. 42 | async_msg(const async_msg &) = delete; 43 | 44 | // support for vs2013 move 45 | #if defined(_MSC_VER) && _MSC_VER <= 1800 46 | async_msg(async_msg &&other) 47 | : log_msg_buffer(std::move(other)) 48 | , msg_type(other.msg_type) 49 | , worker_ptr(std::move(other.worker_ptr)) 50 | {} 51 | 52 | async_msg &operator=(async_msg &&other) 53 | { 54 | *static_cast(this) = std::move(other); 55 | msg_type = other.msg_type; 56 | worker_ptr = std::move(other.worker_ptr); 57 | return *this; 58 | } 59 | #else // (_MSC_VER) && _MSC_VER <= 1800 60 | async_msg(async_msg &&) = default; 61 | async_msg &operator=(async_msg &&) = default; 62 | #endif 63 | 64 | // construct from log_msg with given type 65 | async_msg(async_logger_ptr &&worker, async_msg_type the_type, const details::log_msg &m) 66 | : log_msg_buffer{m} 67 | , msg_type{the_type} 68 | , worker_ptr{std::move(worker)} 69 | {} 70 | 71 | async_msg(async_logger_ptr &&worker, async_msg_type the_type) 72 | : log_msg_buffer{} 73 | , msg_type{the_type} 74 | , worker_ptr{std::move(worker)} 75 | {} 76 | 77 | explicit async_msg(async_msg_type the_type) 78 | : async_msg{nullptr, the_type} 79 | {} 80 | }; 81 | 82 | class SPDLOG_API thread_pool 83 | { 84 | public: 85 | using item_type = async_msg; 86 | using q_type = details::mpmc_blocking_queue; 87 | 88 | thread_pool(size_t q_max_items, size_t threads_n, std::function on_thread_start); 89 | thread_pool(size_t q_max_items, size_t threads_n); 90 | 91 | // message all threads to terminate gracefully join them 92 | ~thread_pool(); 93 | 94 | thread_pool(const thread_pool &) = delete; 95 | thread_pool &operator=(thread_pool &&) = delete; 96 | 97 | void post_log(async_logger_ptr &&worker_ptr, const details::log_msg &msg, async_overflow_policy overflow_policy); 98 | void post_flush(async_logger_ptr &&worker_ptr, async_overflow_policy overflow_policy); 99 | size_t overrun_counter(); 100 | size_t queue_size(); 101 | 102 | private: 103 | q_type q_; 104 | 105 | std::vector threads_; 106 | 107 | void post_async_msg_(async_msg &&new_msg, async_overflow_policy overflow_policy); 108 | void worker_loop_(); 109 | 110 | // process next message in the queue 111 | // return true if this thread should still be active (while no terminate msg 112 | // was received) 113 | bool process_next_msg_(); 114 | }; 115 | 116 | } // namespace details 117 | } // namespace spdlog 118 | 119 | #ifdef SPDLOG_HEADER_ONLY 120 | #include "thread_pool-inl.h" 121 | #endif 122 | -------------------------------------------------------------------------------- /vendor/spdlog/include/spdlog/details/windows_include.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifndef NOMINMAX 4 | #define NOMINMAX // prevent windows redefining min/max 5 | #endif 6 | 7 | #ifndef WIN32_LEAN_AND_MEAN 8 | #define WIN32_LEAN_AND_MEAN 9 | #endif 10 | 11 | #include 12 | -------------------------------------------------------------------------------- /vendor/spdlog/include/spdlog/fmt/bundled/locale.h: -------------------------------------------------------------------------------- 1 | #include "xchar.h" 2 | #warning fmt/locale.h is deprecated, include fmt/format.h or fmt/xchar.h instead 3 | -------------------------------------------------------------------------------- /vendor/spdlog/include/spdlog/fmt/chrono.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright(c) 2016 Gabi Melman. 3 | // Distributed under the MIT License (http://opensource.org/licenses/MIT) 4 | // 5 | 6 | #pragma once 7 | // 8 | // include bundled or external copy of fmtlib's chrono support 9 | // 10 | 11 | #if !defined(SPDLOG_FMT_EXTERNAL) 12 | #ifdef SPDLOG_HEADER_ONLY 13 | #ifndef FMT_HEADER_ONLY 14 | #define FMT_HEADER_ONLY 15 | #endif 16 | #endif 17 | #include 18 | #else 19 | #include 20 | #endif 21 | -------------------------------------------------------------------------------- /vendor/spdlog/include/spdlog/fmt/fmt.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright(c) 2016-2018 Gabi Melman. 3 | // Distributed under the MIT License (http://opensource.org/licenses/MIT) 4 | // 5 | 6 | #pragma once 7 | 8 | // 9 | // Include a bundled header-only copy of fmtlib or an external one. 10 | // By default spdlog include its own copy. 11 | // 12 | 13 | #if !defined(SPDLOG_FMT_EXTERNAL) 14 | #if !defined(SPDLOG_COMPILED_LIB) && !defined(FMT_HEADER_ONLY) 15 | #define FMT_HEADER_ONLY 16 | #endif 17 | #ifndef FMT_USE_WINDOWS_H 18 | #define FMT_USE_WINDOWS_H 0 19 | #endif 20 | // enable the 'n' flag in for backward compatibility with fmt 6.x 21 | #define FMT_DEPRECATED_N_SPECIFIER 22 | #include 23 | #include 24 | #else // SPDLOG_FMT_EXTERNAL is defined - use external fmtlib 25 | #include 26 | #include 27 | #endif 28 | 29 | -------------------------------------------------------------------------------- /vendor/spdlog/include/spdlog/fmt/ostr.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright(c) 2016 Gabi Melman. 3 | // Distributed under the MIT License (http://opensource.org/licenses/MIT) 4 | // 5 | 6 | #pragma once 7 | // 8 | // include bundled or external copy of fmtlib's ostream support 9 | // 10 | 11 | #if !defined(SPDLOG_FMT_EXTERNAL) 12 | #ifdef SPDLOG_HEADER_ONLY 13 | #ifndef FMT_HEADER_ONLY 14 | #define FMT_HEADER_ONLY 15 | #endif 16 | #endif 17 | #include 18 | #else 19 | #include 20 | #endif 21 | -------------------------------------------------------------------------------- /vendor/spdlog/include/spdlog/fmt/xchar.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright(c) 2016 Gabi Melman. 3 | // Distributed under the MIT License (http://opensource.org/licenses/MIT) 4 | // 5 | 6 | #pragma once 7 | // 8 | // include bundled or external copy of fmtlib's ostream support 9 | // 10 | 11 | #if !defined(SPDLOG_FMT_EXTERNAL) 12 | #ifdef SPDLOG_HEADER_ONLY 13 | #ifndef FMT_HEADER_ONLY 14 | #define FMT_HEADER_ONLY 15 | #endif 16 | #endif 17 | #include 18 | #else 19 | #include 20 | #endif 21 | -------------------------------------------------------------------------------- /vendor/spdlog/include/spdlog/formatter.h: -------------------------------------------------------------------------------- 1 | // Copyright(c) 2015-present, Gabi Melman & spdlog contributors. 2 | // Distributed under the MIT License (http://opensource.org/licenses/MIT) 3 | 4 | #pragma once 5 | 6 | #include 7 | #include 8 | 9 | namespace spdlog { 10 | 11 | class formatter 12 | { 13 | public: 14 | virtual ~formatter() = default; 15 | virtual void format(const details::log_msg &msg, memory_buf_t &dest) = 0; 16 | virtual std::unique_ptr clone() const = 0; 17 | }; 18 | } // namespace spdlog 19 | -------------------------------------------------------------------------------- /vendor/spdlog/include/spdlog/fwd.h: -------------------------------------------------------------------------------- 1 | // Copyright(c) 2015-present, Gabi Melman & spdlog contributors. 2 | // Distributed under the MIT License (http://opensource.org/licenses/MIT) 3 | 4 | #pragma once 5 | 6 | namespace spdlog { 7 | class logger; 8 | class formatter; 9 | 10 | namespace sinks { 11 | class sink; 12 | } 13 | 14 | } // namespace spdlog 15 | -------------------------------------------------------------------------------- /vendor/spdlog/include/spdlog/sinks/base_sink-inl.h: -------------------------------------------------------------------------------- 1 | // Copyright(c) 2015-present, Gabi Melman & spdlog contributors. 2 | // Distributed under the MIT License (http://opensource.org/licenses/MIT) 3 | 4 | #pragma once 5 | 6 | #ifndef SPDLOG_HEADER_ONLY 7 | #include 8 | #endif 9 | 10 | #include 11 | #include 12 | 13 | #include 14 | 15 | template 16 | SPDLOG_INLINE spdlog::sinks::base_sink::base_sink() 17 | : formatter_{details::make_unique()} 18 | {} 19 | 20 | template 21 | SPDLOG_INLINE spdlog::sinks::base_sink::base_sink(std::unique_ptr formatter) 22 | : formatter_{std::move(formatter)} 23 | {} 24 | 25 | template 26 | void SPDLOG_INLINE spdlog::sinks::base_sink::log(const details::log_msg &msg) 27 | { 28 | std::lock_guard lock(mutex_); 29 | sink_it_(msg); 30 | } 31 | 32 | template 33 | void SPDLOG_INLINE spdlog::sinks::base_sink::flush() 34 | { 35 | std::lock_guard lock(mutex_); 36 | flush_(); 37 | } 38 | 39 | template 40 | void SPDLOG_INLINE spdlog::sinks::base_sink::set_pattern(const std::string &pattern) 41 | { 42 | std::lock_guard lock(mutex_); 43 | set_pattern_(pattern); 44 | } 45 | 46 | template 47 | void SPDLOG_INLINE spdlog::sinks::base_sink::set_formatter(std::unique_ptr sink_formatter) 48 | { 49 | std::lock_guard lock(mutex_); 50 | set_formatter_(std::move(sink_formatter)); 51 | } 52 | 53 | template 54 | void SPDLOG_INLINE spdlog::sinks::base_sink::set_pattern_(const std::string &pattern) 55 | { 56 | set_formatter_(details::make_unique(pattern)); 57 | } 58 | 59 | template 60 | void SPDLOG_INLINE spdlog::sinks::base_sink::set_formatter_(std::unique_ptr sink_formatter) 61 | { 62 | formatter_ = std::move(sink_formatter); 63 | } 64 | -------------------------------------------------------------------------------- /vendor/spdlog/include/spdlog/sinks/base_sink.h: -------------------------------------------------------------------------------- 1 | // Copyright(c) 2015-present, Gabi Melman & spdlog contributors. 2 | // Distributed under the MIT License (http://opensource.org/licenses/MIT) 3 | 4 | #pragma once 5 | // 6 | // base sink templated over a mutex (either dummy or real) 7 | // concrete implementation should override the sink_it_() and flush_() methods. 8 | // locking is taken care of in this class - no locking needed by the 9 | // implementers.. 10 | // 11 | 12 | #include 13 | #include 14 | #include 15 | 16 | namespace spdlog { 17 | namespace sinks { 18 | template 19 | class base_sink : public sink 20 | { 21 | public: 22 | base_sink(); 23 | explicit base_sink(std::unique_ptr formatter); 24 | ~base_sink() override = default; 25 | 26 | base_sink(const base_sink &) = delete; 27 | base_sink(base_sink &&) = delete; 28 | 29 | base_sink &operator=(const base_sink &) = delete; 30 | base_sink &operator=(base_sink &&) = delete; 31 | 32 | void log(const details::log_msg &msg) final; 33 | void flush() final; 34 | void set_pattern(const std::string &pattern) final; 35 | void set_formatter(std::unique_ptr sink_formatter) final; 36 | 37 | protected: 38 | // sink formatter 39 | std::unique_ptr formatter_; 40 | mutable Mutex mutex_; 41 | 42 | virtual void sink_it_(const details::log_msg &msg) = 0; 43 | virtual void flush_() = 0; 44 | virtual void set_pattern_(const std::string &pattern); 45 | virtual void set_formatter_(std::unique_ptr sink_formatter); 46 | }; 47 | } // namespace sinks 48 | } // namespace spdlog 49 | 50 | #ifdef SPDLOG_HEADER_ONLY 51 | #include "base_sink-inl.h" 52 | #endif 53 | -------------------------------------------------------------------------------- /vendor/spdlog/include/spdlog/sinks/basic_file_sink-inl.h: -------------------------------------------------------------------------------- 1 | // Copyright(c) 2015-present, Gabi Melman & spdlog contributors. 2 | // Distributed under the MIT License (http://opensource.org/licenses/MIT) 3 | 4 | #pragma once 5 | 6 | #ifndef SPDLOG_HEADER_ONLY 7 | #include 8 | #endif 9 | 10 | #include 11 | #include 12 | 13 | namespace spdlog { 14 | namespace sinks { 15 | 16 | template 17 | SPDLOG_INLINE basic_file_sink::basic_file_sink(const filename_t &filename, bool truncate) 18 | { 19 | file_helper_.open(filename, truncate); 20 | } 21 | 22 | template 23 | SPDLOG_INLINE const filename_t &basic_file_sink::filename() const 24 | { 25 | return file_helper_.filename(); 26 | } 27 | 28 | template 29 | SPDLOG_INLINE void basic_file_sink::sink_it_(const details::log_msg &msg) 30 | { 31 | memory_buf_t formatted; 32 | base_sink::formatter_->format(msg, formatted); 33 | file_helper_.write(formatted); 34 | } 35 | 36 | template 37 | SPDLOG_INLINE void basic_file_sink::flush_() 38 | { 39 | file_helper_.flush(); 40 | } 41 | 42 | } // namespace sinks 43 | } // namespace spdlog 44 | -------------------------------------------------------------------------------- /vendor/spdlog/include/spdlog/sinks/basic_file_sink.h: -------------------------------------------------------------------------------- 1 | // Copyright(c) 2015-present, Gabi Melman & spdlog contributors. 2 | // Distributed under the MIT License (http://opensource.org/licenses/MIT) 3 | 4 | #pragma once 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | #include 12 | #include 13 | 14 | namespace spdlog { 15 | namespace sinks { 16 | /* 17 | * Trivial file sink with single file as target 18 | */ 19 | template 20 | class basic_file_sink final : public base_sink 21 | { 22 | public: 23 | explicit basic_file_sink(const filename_t &filename, bool truncate = false); 24 | const filename_t &filename() const; 25 | 26 | protected: 27 | void sink_it_(const details::log_msg &msg) override; 28 | void flush_() override; 29 | 30 | private: 31 | details::file_helper file_helper_; 32 | }; 33 | 34 | using basic_file_sink_mt = basic_file_sink; 35 | using basic_file_sink_st = basic_file_sink; 36 | 37 | } // namespace sinks 38 | 39 | // 40 | // factory functions 41 | // 42 | template 43 | inline std::shared_ptr basic_logger_mt(const std::string &logger_name, const filename_t &filename, bool truncate = false) 44 | { 45 | return Factory::template create(logger_name, filename, truncate); 46 | } 47 | 48 | template 49 | inline std::shared_ptr basic_logger_st(const std::string &logger_name, const filename_t &filename, bool truncate = false) 50 | { 51 | return Factory::template create(logger_name, filename, truncate); 52 | } 53 | 54 | } // namespace spdlog 55 | 56 | #ifdef SPDLOG_HEADER_ONLY 57 | #include "basic_file_sink-inl.h" 58 | #endif 59 | 60 | -------------------------------------------------------------------------------- /vendor/spdlog/include/spdlog/sinks/dist_sink.h: -------------------------------------------------------------------------------- 1 | // Copyright(c) 2015-present, Gabi Melman & spdlog contributors. 2 | // Distributed under the MIT License (http://opensource.org/licenses/MIT) 3 | 4 | #pragma once 5 | 6 | #include "base_sink.h" 7 | #include 8 | #include 9 | #include 10 | 11 | #include 12 | #include 13 | #include 14 | #include 15 | 16 | // Distribution sink (mux). Stores a vector of sinks which get called when log 17 | // is called 18 | 19 | namespace spdlog { 20 | namespace sinks { 21 | 22 | template 23 | class dist_sink : public base_sink 24 | { 25 | public: 26 | dist_sink() = default; 27 | explicit dist_sink(std::vector> sinks) 28 | : sinks_(sinks) 29 | {} 30 | 31 | dist_sink(const dist_sink &) = delete; 32 | dist_sink &operator=(const dist_sink &) = delete; 33 | 34 | void add_sink(std::shared_ptr sink) 35 | { 36 | std::lock_guard lock(base_sink::mutex_); 37 | sinks_.push_back(sink); 38 | } 39 | 40 | void remove_sink(std::shared_ptr sink) 41 | { 42 | std::lock_guard lock(base_sink::mutex_); 43 | sinks_.erase(std::remove(sinks_.begin(), sinks_.end(), sink), sinks_.end()); 44 | } 45 | 46 | void set_sinks(std::vector> sinks) 47 | { 48 | std::lock_guard lock(base_sink::mutex_); 49 | sinks_ = std::move(sinks); 50 | } 51 | 52 | std::vector> &sinks() 53 | { 54 | return sinks_; 55 | } 56 | 57 | protected: 58 | void sink_it_(const details::log_msg &msg) override 59 | { 60 | for (auto &sink : sinks_) 61 | { 62 | if (sink->should_log(msg.level)) 63 | { 64 | sink->log(msg); 65 | } 66 | } 67 | } 68 | 69 | void flush_() override 70 | { 71 | for (auto &sink : sinks_) 72 | { 73 | sink->flush(); 74 | } 75 | } 76 | 77 | void set_pattern_(const std::string &pattern) override 78 | { 79 | set_formatter_(details::make_unique(pattern)); 80 | } 81 | 82 | void set_formatter_(std::unique_ptr sink_formatter) override 83 | { 84 | base_sink::formatter_ = std::move(sink_formatter); 85 | for (auto &sink : sinks_) 86 | { 87 | sink->set_formatter(base_sink::formatter_->clone()); 88 | } 89 | } 90 | std::vector> sinks_; 91 | }; 92 | 93 | using dist_sink_mt = dist_sink; 94 | using dist_sink_st = dist_sink; 95 | 96 | } // namespace sinks 97 | } // namespace spdlog 98 | -------------------------------------------------------------------------------- /vendor/spdlog/include/spdlog/sinks/dup_filter_sink.h: -------------------------------------------------------------------------------- 1 | // Copyright(c) 2015-present, Gabi Melman & spdlog contributors. 2 | // Distributed under the MIT License (http://opensource.org/licenses/MIT) 3 | 4 | #pragma once 5 | 6 | #include "dist_sink.h" 7 | #include 8 | #include 9 | 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | // Duplicate message removal sink. 16 | // Skip the message if previous one is identical and less than "max_skip_duration" have passed 17 | // 18 | // Example: 19 | // 20 | // #include 21 | // 22 | // int main() { 23 | // auto dup_filter = std::make_shared(std::chrono::seconds(5)); 24 | // dup_filter->add_sink(std::make_shared()); 25 | // spdlog::logger l("logger", dup_filter); 26 | // l.info("Hello"); 27 | // l.info("Hello"); 28 | // l.info("Hello"); 29 | // l.info("Different Hello"); 30 | // } 31 | // 32 | // Will produce: 33 | // [2019-06-25 17:50:56.511] [logger] [info] Hello 34 | // [2019-06-25 17:50:56.512] [logger] [info] Skipped 3 duplicate messages.. 35 | // [2019-06-25 17:50:56.512] [logger] [info] Different Hello 36 | 37 | namespace spdlog { 38 | namespace sinks { 39 | template 40 | class dup_filter_sink : public dist_sink 41 | { 42 | public: 43 | template 44 | explicit dup_filter_sink(std::chrono::duration max_skip_duration) 45 | : max_skip_duration_{max_skip_duration} 46 | {} 47 | 48 | protected: 49 | std::chrono::microseconds max_skip_duration_; 50 | log_clock::time_point last_msg_time_; 51 | std::string last_msg_payload_; 52 | size_t skip_counter_ = 0; 53 | 54 | void sink_it_(const details::log_msg &msg) override 55 | { 56 | bool filtered = filter_(msg); 57 | if (!filtered) 58 | { 59 | skip_counter_ += 1; 60 | return; 61 | } 62 | 63 | // log the "skipped.." message 64 | if (skip_counter_ > 0) 65 | { 66 | char buf[64]; 67 | auto msg_size = ::snprintf(buf, sizeof(buf), "Skipped %u duplicate messages..", static_cast(skip_counter_)); 68 | if (msg_size > 0 && msg_size < sizeof(buf)) 69 | { 70 | details::log_msg skipped_msg{msg.logger_name, level::info, string_view_t{buf, static_cast(msg_size)}}; 71 | dist_sink::sink_it_(skipped_msg); 72 | } 73 | } 74 | 75 | // log current message 76 | dist_sink::sink_it_(msg); 77 | last_msg_time_ = msg.time; 78 | skip_counter_ = 0; 79 | last_msg_payload_.assign(msg.payload.data(), msg.payload.data() + msg.payload.size()); 80 | } 81 | 82 | // return whether the log msg should be displayed (true) or skipped (false) 83 | bool filter_(const details::log_msg &msg) 84 | { 85 | auto filter_duration = msg.time - last_msg_time_; 86 | return (filter_duration > max_skip_duration_) || (msg.payload != last_msg_payload_); 87 | } 88 | }; 89 | 90 | using dup_filter_sink_mt = dup_filter_sink; 91 | using dup_filter_sink_st = dup_filter_sink; 92 | 93 | } // namespace sinks 94 | } // namespace spdlog 95 | -------------------------------------------------------------------------------- /vendor/spdlog/include/spdlog/sinks/mongo_sink.h: -------------------------------------------------------------------------------- 1 | // Copyright(c) 2015-present, Gabi Melman & spdlog contributors. 2 | // Distributed under the MIT License (http://opensource.org/licenses/MIT) 3 | 4 | #pragma once 5 | 6 | // 7 | // Custom sink for mongodb 8 | // Building and using requires mongocxx library. 9 | // For building mongocxx library check the url below 10 | // http://mongocxx.org/mongocxx-v3/installation/ 11 | // 12 | 13 | #include "spdlog/common.h" 14 | #include "spdlog/details/log_msg.h" 15 | #include "spdlog/sinks/base_sink.h" 16 | #include 17 | 18 | #include 19 | #include 20 | #include 21 | 22 | #include 23 | #include 24 | #include 25 | 26 | namespace spdlog { 27 | namespace sinks { 28 | template class mongo_sink : public base_sink { 29 | public: 30 | mongo_sink(const std::string &db_name, const std::string &collection_name, 31 | const std::string &uri = "mongodb://localhost:27017") { 32 | try { 33 | client_ = std::make_unique(mongocxx::uri{uri}); 34 | db_name_ = db_name; 35 | coll_name_ = collection_name; 36 | } catch (const std::exception) { 37 | throw spdlog_ex("Error opening database"); 38 | } 39 | } 40 | 41 | ~mongo_sink() { flush_(); } 42 | 43 | protected: 44 | void sink_it_(const details::log_msg &msg) override { 45 | using bsoncxx::builder::stream::document; 46 | using bsoncxx::builder::stream::finalize; 47 | 48 | if (client_ != nullptr) { 49 | auto doc = document{} 50 | << "timestamp" << bsoncxx::types::b_date(msg.time) << "level" 51 | << level::to_string_view(msg.level).data() << "message" 52 | << std::string(msg.payload.begin(), msg.payload.end()) 53 | << "logger_name" 54 | << std::string(msg.logger_name.begin(), msg.logger_name.end()) 55 | << "thread_id" << static_cast(msg.thread_id) << finalize; 56 | client_->database(db_name_).collection(coll_name_).insert_one(doc.view()); 57 | } 58 | } 59 | 60 | void flush_() override {} 61 | 62 | private: 63 | static mongocxx::instance instance_; 64 | std::string db_name_; 65 | std::string coll_name_; 66 | std::unique_ptr client_ = nullptr; 67 | }; 68 | mongocxx::instance mongo_sink::instance_{}; 69 | 70 | #include "spdlog/details/null_mutex.h" 71 | #include 72 | using mongo_sink_mt = mongo_sink; 73 | using mongo_sink_st = mongo_sink; 74 | 75 | } // namespace sinks 76 | 77 | template 78 | inline std::shared_ptr 79 | mongo_logger_mt(const std::string &logger_name, const std::string &db_name, 80 | const std::string &collection_name, 81 | const std::string &uri = "mongodb://localhost:27017") { 82 | return Factory::template create(logger_name, db_name, 83 | collection_name, uri); 84 | } 85 | 86 | template 87 | inline std::shared_ptr 88 | mongo_logger_st(const std::string &logger_name, const std::string &db_name, 89 | const std::string &collection_name, 90 | const std::string &uri = "mongodb://localhost:27017") { 91 | return Factory::template create(logger_name, db_name, 92 | collection_name, uri); 93 | } 94 | 95 | } // namespace spdlog 96 | 97 | -------------------------------------------------------------------------------- /vendor/spdlog/include/spdlog/sinks/msvc_sink.h: -------------------------------------------------------------------------------- 1 | // Copyright(c) 2016 Alexander Dalshov. 2 | // Distributed under the MIT License (http://opensource.org/licenses/MIT) 3 | 4 | #pragma once 5 | 6 | #if defined(_WIN32) 7 | 8 | #include 9 | #include 10 | 11 | #include 12 | #include 13 | 14 | 15 | // Avoid including windows.h (https://stackoverflow.com/a/30741042) 16 | extern "C" __declspec(dllimport) void __stdcall OutputDebugStringA(const char *lpOutputString); 17 | 18 | namespace spdlog { 19 | namespace sinks { 20 | /* 21 | * MSVC sink (logging using OutputDebugStringA) 22 | */ 23 | template 24 | class msvc_sink : public base_sink 25 | { 26 | public: 27 | msvc_sink() = default; 28 | 29 | protected: 30 | void sink_it_(const details::log_msg &msg) override 31 | { 32 | memory_buf_t formatted; 33 | base_sink::formatter_->format(msg, formatted); 34 | OutputDebugStringA(fmt::to_string(formatted).c_str()); 35 | } 36 | 37 | void flush_() override {} 38 | }; 39 | 40 | using msvc_sink_mt = msvc_sink; 41 | using msvc_sink_st = msvc_sink; 42 | 43 | using windebug_sink_mt = msvc_sink_mt; 44 | using windebug_sink_st = msvc_sink_st; 45 | 46 | } // namespace sinks 47 | } // namespace spdlog 48 | 49 | #endif 50 | -------------------------------------------------------------------------------- /vendor/spdlog/include/spdlog/sinks/null_sink.h: -------------------------------------------------------------------------------- 1 | // Copyright(c) 2015-present, Gabi Melman & spdlog contributors. 2 | // Distributed under the MIT License (http://opensource.org/licenses/MIT) 3 | 4 | #pragma once 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | #include 11 | 12 | namespace spdlog { 13 | namespace sinks { 14 | 15 | template 16 | class null_sink : public base_sink 17 | { 18 | protected: 19 | void sink_it_(const details::log_msg &) override {} 20 | void flush_() override {} 21 | }; 22 | 23 | using null_sink_mt = null_sink; 24 | using null_sink_st = null_sink; 25 | 26 | } // namespace sinks 27 | 28 | template 29 | inline std::shared_ptr null_logger_mt(const std::string &logger_name) 30 | { 31 | auto null_logger = Factory::template create(logger_name); 32 | null_logger->set_level(level::off); 33 | return null_logger; 34 | } 35 | 36 | template 37 | inline std::shared_ptr null_logger_st(const std::string &logger_name) 38 | { 39 | auto null_logger = Factory::template create(logger_name); 40 | null_logger->set_level(level::off); 41 | return null_logger; 42 | } 43 | 44 | } // namespace spdlog 45 | -------------------------------------------------------------------------------- /vendor/spdlog/include/spdlog/sinks/ostream_sink.h: -------------------------------------------------------------------------------- 1 | // Copyright(c) 2015-present, Gabi Melman & spdlog contributors. 2 | // Distributed under the MIT License (http://opensource.org/licenses/MIT) 3 | 4 | #pragma once 5 | 6 | #include 7 | #include 8 | 9 | #include 10 | #include 11 | 12 | namespace spdlog { 13 | namespace sinks { 14 | template 15 | class ostream_sink final : public base_sink 16 | { 17 | public: 18 | explicit ostream_sink(std::ostream &os, bool force_flush = false) 19 | : ostream_(os) 20 | , force_flush_(force_flush) 21 | {} 22 | ostream_sink(const ostream_sink &) = delete; 23 | ostream_sink &operator=(const ostream_sink &) = delete; 24 | 25 | protected: 26 | void sink_it_(const details::log_msg &msg) override 27 | { 28 | memory_buf_t formatted; 29 | base_sink::formatter_->format(msg, formatted); 30 | ostream_.write(formatted.data(), static_cast(formatted.size())); 31 | if (force_flush_) 32 | { 33 | ostream_.flush(); 34 | } 35 | } 36 | 37 | void flush_() override 38 | { 39 | ostream_.flush(); 40 | } 41 | 42 | std::ostream &ostream_; 43 | bool force_flush_; 44 | }; 45 | 46 | using ostream_sink_mt = ostream_sink; 47 | using ostream_sink_st = ostream_sink; 48 | 49 | } // namespace sinks 50 | } // namespace spdlog 51 | -------------------------------------------------------------------------------- /vendor/spdlog/include/spdlog/sinks/ringbuffer_sink.h: -------------------------------------------------------------------------------- 1 | // Copyright(c) 2015-present, Gabi Melman & spdlog contributors. 2 | // Distributed under the MIT License (http://opensource.org/licenses/MIT) 3 | 4 | #pragma once 5 | 6 | #include "spdlog/sinks/base_sink.h" 7 | #include "spdlog/details/circular_q.h" 8 | #include "spdlog/details/log_msg_buffer.h" 9 | #include "spdlog/details/null_mutex.h" 10 | 11 | #include 12 | #include 13 | #include 14 | 15 | namespace spdlog { 16 | namespace sinks { 17 | /* 18 | * Ring buffer sink 19 | */ 20 | template 21 | class ringbuffer_sink final : public base_sink 22 | { 23 | public: 24 | explicit ringbuffer_sink(size_t n_items) 25 | : q_{n_items} 26 | {} 27 | 28 | std::vector last_raw(size_t lim = 0) 29 | { 30 | std::lock_guard lock(base_sink::mutex_); 31 | auto items_available = q_.size(); 32 | auto n_items = lim > 0 ? (std::min)(lim, items_available) : items_available; 33 | std::vector ret; 34 | ret.reserve(n_items); 35 | for (size_t i = (items_available - n_items); i < items_available; i++) 36 | { 37 | ret.push_back(q_.at(i)); 38 | } 39 | return ret; 40 | } 41 | 42 | std::vector last_formatted(size_t lim = 0) 43 | { 44 | std::lock_guard lock(base_sink::mutex_); 45 | auto items_available = q_.size(); 46 | auto n_items = lim > 0 ? (std::min)(lim, items_available) : items_available; 47 | std::vector ret; 48 | ret.reserve(n_items); 49 | for (size_t i = (items_available - n_items); i < items_available; i++) 50 | { 51 | memory_buf_t formatted; 52 | base_sink::formatter_->format(q_.at(i), formatted); 53 | ret.push_back(fmt::to_string(formatted)); 54 | } 55 | return ret; 56 | } 57 | 58 | protected: 59 | void sink_it_(const details::log_msg &msg) override 60 | { 61 | q_.push_back(details::log_msg_buffer{msg}); 62 | } 63 | void flush_() override {} 64 | 65 | private: 66 | details::circular_q q_; 67 | }; 68 | 69 | using ringbuffer_sink_mt = ringbuffer_sink; 70 | using ringbuffer_sink_st = ringbuffer_sink; 71 | 72 | } // namespace sinks 73 | 74 | } // namespace spdlog 75 | -------------------------------------------------------------------------------- /vendor/spdlog/include/spdlog/sinks/rotating_file_sink.h: -------------------------------------------------------------------------------- 1 | // Copyright(c) 2015-present, Gabi Melman & spdlog contributors. 2 | // Distributed under the MIT License (http://opensource.org/licenses/MIT) 3 | 4 | #pragma once 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | #include 12 | #include 13 | #include 14 | 15 | namespace spdlog { 16 | namespace sinks { 17 | 18 | // 19 | // Rotating file sink based on size 20 | // 21 | template 22 | class rotating_file_sink final : public base_sink 23 | { 24 | public: 25 | rotating_file_sink(filename_t base_filename, std::size_t max_size, std::size_t max_files, bool rotate_on_open = false); 26 | static filename_t calc_filename(const filename_t &filename, std::size_t index); 27 | filename_t filename(); 28 | 29 | protected: 30 | void sink_it_(const details::log_msg &msg) override; 31 | void flush_() override; 32 | 33 | private: 34 | // Rotate files: 35 | // log.txt -> log.1.txt 36 | // log.1.txt -> log.2.txt 37 | // log.2.txt -> log.3.txt 38 | // log.3.txt -> delete 39 | void rotate_(); 40 | 41 | // delete the target if exists, and rename the src file to target 42 | // return true on success, false otherwise. 43 | bool rename_file_(const filename_t &src_filename, const filename_t &target_filename); 44 | 45 | filename_t base_filename_; 46 | std::size_t max_size_; 47 | std::size_t max_files_; 48 | std::size_t current_size_; 49 | details::file_helper file_helper_; 50 | }; 51 | 52 | using rotating_file_sink_mt = rotating_file_sink; 53 | using rotating_file_sink_st = rotating_file_sink; 54 | 55 | } // namespace sinks 56 | 57 | // 58 | // factory functions 59 | // 60 | 61 | template 62 | inline std::shared_ptr rotating_logger_mt( 63 | const std::string &logger_name, const filename_t &filename, size_t max_file_size, size_t max_files, bool rotate_on_open = false) 64 | { 65 | return Factory::template create(logger_name, filename, max_file_size, max_files, rotate_on_open); 66 | } 67 | 68 | template 69 | inline std::shared_ptr rotating_logger_st( 70 | const std::string &logger_name, const filename_t &filename, size_t max_file_size, size_t max_files, bool rotate_on_open = false) 71 | { 72 | return Factory::template create(logger_name, filename, max_file_size, max_files, rotate_on_open); 73 | } 74 | } // namespace spdlog 75 | 76 | #ifdef SPDLOG_HEADER_ONLY 77 | #include "rotating_file_sink-inl.h" 78 | #endif 79 | -------------------------------------------------------------------------------- /vendor/spdlog/include/spdlog/sinks/sink-inl.h: -------------------------------------------------------------------------------- 1 | // Copyright(c) 2015-present, Gabi Melman & spdlog contributors. 2 | // Distributed under the MIT License (http://opensource.org/licenses/MIT) 3 | 4 | #pragma once 5 | 6 | #ifndef SPDLOG_HEADER_ONLY 7 | #include 8 | #endif 9 | 10 | #include 11 | 12 | SPDLOG_INLINE bool spdlog::sinks::sink::should_log(spdlog::level::level_enum msg_level) const 13 | { 14 | return msg_level >= level_.load(std::memory_order_relaxed); 15 | } 16 | 17 | SPDLOG_INLINE void spdlog::sinks::sink::set_level(level::level_enum log_level) 18 | { 19 | level_.store(log_level, std::memory_order_relaxed); 20 | } 21 | 22 | SPDLOG_INLINE spdlog::level::level_enum spdlog::sinks::sink::level() const 23 | { 24 | return static_cast(level_.load(std::memory_order_relaxed)); 25 | } 26 | -------------------------------------------------------------------------------- /vendor/spdlog/include/spdlog/sinks/sink.h: -------------------------------------------------------------------------------- 1 | // Copyright(c) 2015-present, Gabi Melman & spdlog contributors. 2 | // Distributed under the MIT License (http://opensource.org/licenses/MIT) 3 | 4 | #pragma once 5 | 6 | #include 7 | #include 8 | 9 | namespace spdlog { 10 | 11 | namespace sinks { 12 | class SPDLOG_API sink 13 | { 14 | public: 15 | virtual ~sink() = default; 16 | virtual void log(const details::log_msg &msg) = 0; 17 | virtual void flush() = 0; 18 | virtual void set_pattern(const std::string &pattern) = 0; 19 | virtual void set_formatter(std::unique_ptr sink_formatter) = 0; 20 | 21 | void set_level(level::level_enum log_level); 22 | level::level_enum level() const; 23 | bool should_log(level::level_enum msg_level) const; 24 | 25 | protected: 26 | // sink log level - default is all 27 | level_t level_{level::trace}; 28 | }; 29 | 30 | } // namespace sinks 31 | } // namespace spdlog 32 | 33 | #ifdef SPDLOG_HEADER_ONLY 34 | #include "sink-inl.h" 35 | #endif 36 | -------------------------------------------------------------------------------- /vendor/spdlog/include/spdlog/sinks/stdout_color_sinks-inl.h: -------------------------------------------------------------------------------- 1 | // Copyright(c) 2015-present, Gabi Melman & spdlog contributors. 2 | // Distributed under the MIT License (http://opensource.org/licenses/MIT) 3 | 4 | #pragma once 5 | 6 | #ifndef SPDLOG_HEADER_ONLY 7 | #include 8 | #endif 9 | 10 | #include 11 | #include 12 | 13 | namespace spdlog { 14 | 15 | template 16 | SPDLOG_INLINE std::shared_ptr stdout_color_mt(const std::string &logger_name, color_mode mode) 17 | { 18 | return Factory::template create(logger_name, mode); 19 | } 20 | 21 | template 22 | SPDLOG_INLINE std::shared_ptr stdout_color_st(const std::string &logger_name, color_mode mode) 23 | { 24 | return Factory::template create(logger_name, mode); 25 | } 26 | 27 | template 28 | SPDLOG_INLINE std::shared_ptr stderr_color_mt(const std::string &logger_name, color_mode mode) 29 | { 30 | return Factory::template create(logger_name, mode); 31 | } 32 | 33 | template 34 | SPDLOG_INLINE std::shared_ptr stderr_color_st(const std::string &logger_name, color_mode mode) 35 | { 36 | return Factory::template create(logger_name, mode); 37 | } 38 | } // namespace spdlog 39 | 40 | -------------------------------------------------------------------------------- /vendor/spdlog/include/spdlog/sinks/stdout_color_sinks.h: -------------------------------------------------------------------------------- 1 | // Copyright(c) 2015-present, Gabi Melman & spdlog contributors. 2 | // Distributed under the MIT License (http://opensource.org/licenses/MIT) 3 | 4 | #pragma once 5 | 6 | #ifdef _WIN32 7 | #include 8 | #else 9 | #include 10 | #endif 11 | 12 | #include 13 | 14 | namespace spdlog { 15 | namespace sinks { 16 | #ifdef _WIN32 17 | using stdout_color_sink_mt = wincolor_stdout_sink_mt; 18 | using stdout_color_sink_st = wincolor_stdout_sink_st; 19 | using stderr_color_sink_mt = wincolor_stderr_sink_mt; 20 | using stderr_color_sink_st = wincolor_stderr_sink_st; 21 | #else 22 | using stdout_color_sink_mt = ansicolor_stdout_sink_mt; 23 | using stdout_color_sink_st = ansicolor_stdout_sink_st; 24 | using stderr_color_sink_mt = ansicolor_stderr_sink_mt; 25 | using stderr_color_sink_st = ansicolor_stderr_sink_st; 26 | #endif 27 | } // namespace sinks 28 | 29 | template 30 | std::shared_ptr stdout_color_mt(const std::string &logger_name, color_mode mode = color_mode::automatic); 31 | 32 | template 33 | std::shared_ptr stdout_color_st(const std::string &logger_name, color_mode mode = color_mode::automatic); 34 | 35 | template 36 | std::shared_ptr stderr_color_mt(const std::string &logger_name, color_mode mode = color_mode::automatic); 37 | 38 | template 39 | std::shared_ptr stderr_color_st(const std::string &logger_name, color_mode mode = color_mode::automatic); 40 | 41 | } // namespace spdlog 42 | 43 | #ifdef SPDLOG_HEADER_ONLY 44 | #include "stdout_color_sinks-inl.h" 45 | #endif 46 | -------------------------------------------------------------------------------- /vendor/spdlog/include/spdlog/sinks/stdout_sinks.h: -------------------------------------------------------------------------------- 1 | // Copyright(c) 2015-present, Gabi Melman & spdlog contributors. 2 | // Distributed under the MIT License (http://opensource.org/licenses/MIT) 3 | 4 | #pragma once 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | #ifdef _WIN32 12 | #include 13 | #endif 14 | 15 | namespace spdlog { 16 | 17 | namespace sinks { 18 | 19 | template 20 | class stdout_sink_base : public sink 21 | { 22 | public: 23 | using mutex_t = typename ConsoleMutex::mutex_t; 24 | explicit stdout_sink_base(FILE *file); 25 | ~stdout_sink_base() override = default; 26 | 27 | stdout_sink_base(const stdout_sink_base &other) = delete; 28 | stdout_sink_base(stdout_sink_base &&other) = delete; 29 | 30 | stdout_sink_base &operator=(const stdout_sink_base &other) = delete; 31 | stdout_sink_base &operator=(stdout_sink_base &&other) = delete; 32 | 33 | void log(const details::log_msg &msg) override; 34 | void flush() override; 35 | void set_pattern(const std::string &pattern) override; 36 | 37 | void set_formatter(std::unique_ptr sink_formatter) override; 38 | 39 | protected: 40 | mutex_t &mutex_; 41 | FILE *file_; 42 | std::unique_ptr formatter_; 43 | #ifdef _WIN32 44 | HANDLE handle_; 45 | #endif // WIN32 46 | }; 47 | 48 | template 49 | class stdout_sink : public stdout_sink_base 50 | { 51 | public: 52 | stdout_sink(); 53 | }; 54 | 55 | template 56 | class stderr_sink : public stdout_sink_base 57 | { 58 | public: 59 | stderr_sink(); 60 | }; 61 | 62 | using stdout_sink_mt = stdout_sink; 63 | using stdout_sink_st = stdout_sink; 64 | 65 | using stderr_sink_mt = stderr_sink; 66 | using stderr_sink_st = stderr_sink; 67 | 68 | } // namespace sinks 69 | 70 | // factory methods 71 | template 72 | std::shared_ptr stdout_logger_mt(const std::string &logger_name); 73 | 74 | template 75 | std::shared_ptr stdout_logger_st(const std::string &logger_name); 76 | 77 | template 78 | std::shared_ptr stderr_logger_mt(const std::string &logger_name); 79 | 80 | template 81 | std::shared_ptr stderr_logger_st(const std::string &logger_name); 82 | 83 | } // namespace spdlog 84 | 85 | #ifdef SPDLOG_HEADER_ONLY 86 | #include "stdout_sinks-inl.h" 87 | #endif 88 | -------------------------------------------------------------------------------- /vendor/spdlog/include/spdlog/sinks/systemd_sink.h: -------------------------------------------------------------------------------- 1 | // Copyright(c) 2019 ZVYAGIN.Alexander@gmail.com 2 | // Distributed under the MIT License (http://opensource.org/licenses/MIT) 3 | 4 | #pragma once 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | #include 11 | #ifndef SD_JOURNAL_SUPPRESS_LOCATION 12 | #define SD_JOURNAL_SUPPRESS_LOCATION 13 | #endif 14 | #include 15 | 16 | namespace spdlog { 17 | namespace sinks { 18 | 19 | /** 20 | * Sink that write to systemd journal using the `sd_journal_send()` library call. 21 | * 22 | * Locking is not needed, as `sd_journal_send()` itself is thread-safe. 23 | */ 24 | template 25 | class systemd_sink : public base_sink 26 | { 27 | public: 28 | // 29 | systemd_sink() 30 | : syslog_levels_{{/* spdlog::level::trace */ LOG_DEBUG, 31 | /* spdlog::level::debug */ LOG_DEBUG, 32 | /* spdlog::level::info */ LOG_INFO, 33 | /* spdlog::level::warn */ LOG_WARNING, 34 | /* spdlog::level::err */ LOG_ERR, 35 | /* spdlog::level::critical */ LOG_CRIT, 36 | /* spdlog::level::off */ LOG_INFO}} 37 | {} 38 | 39 | ~systemd_sink() override {} 40 | 41 | systemd_sink(const systemd_sink &) = delete; 42 | systemd_sink &operator=(const systemd_sink &) = delete; 43 | 44 | protected: 45 | using levels_array = std::array; 46 | levels_array syslog_levels_; 47 | 48 | void sink_it_(const details::log_msg &msg) override 49 | { 50 | int err; 51 | 52 | size_t length = msg.payload.size(); 53 | // limit to max int 54 | if (length > static_cast(std::numeric_limits::max())) 55 | { 56 | length = static_cast(std::numeric_limits::max()); 57 | } 58 | 59 | // Do not send source location if not available 60 | if (msg.source.empty()) 61 | { 62 | // Note: function call inside '()' to avoid macro expansion 63 | err = (sd_journal_send)("MESSAGE=%.*s", static_cast(length), msg.payload.data(), "PRIORITY=%d", syslog_level(msg.level), 64 | "SYSLOG_IDENTIFIER=%.*s", static_cast(msg.logger_name.size()), msg.logger_name.data(), nullptr); 65 | } 66 | else 67 | { 68 | err = (sd_journal_send)("MESSAGE=%.*s", static_cast(length), msg.payload.data(), "PRIORITY=%d", syslog_level(msg.level), 69 | "SYSLOG_IDENTIFIER=%.*s", static_cast(msg.logger_name.size()), msg.logger_name.data(), "CODE_FILE=%s", 70 | msg.source.filename, "CODE_LINE=%d", msg.source.line, "CODE_FUNC=%s", msg.source.funcname, nullptr); 71 | } 72 | 73 | if (err) 74 | { 75 | throw_spdlog_ex("Failed writing to systemd", errno); 76 | } 77 | } 78 | 79 | int syslog_level(level::level_enum l) 80 | { 81 | return syslog_levels_.at(static_cast(l)); 82 | } 83 | 84 | void flush_() override {} 85 | }; 86 | 87 | using systemd_sink_mt = systemd_sink; 88 | using systemd_sink_st = systemd_sink; 89 | } // namespace sinks 90 | 91 | // Create and register a syslog logger 92 | template 93 | inline std::shared_ptr systemd_logger_mt(const std::string &logger_name) 94 | { 95 | return Factory::template create(logger_name); 96 | } 97 | 98 | template 99 | inline std::shared_ptr systemd_logger_st(const std::string &logger_name) 100 | { 101 | return Factory::template create(logger_name); 102 | } 103 | } // namespace spdlog 104 | -------------------------------------------------------------------------------- /vendor/spdlog/include/spdlog/sinks/tcp_sink.h: -------------------------------------------------------------------------------- 1 | // Copyright(c) 2015-present, Gabi Melman & spdlog contributors. 2 | // Distributed under the MIT License (http://opensource.org/licenses/MIT) 3 | 4 | #pragma once 5 | 6 | #include 7 | #include 8 | #include 9 | #ifdef _WIN32 10 | #include 11 | #else 12 | #include 13 | #endif 14 | 15 | #include 16 | #include 17 | #include 18 | #include 19 | 20 | #pragma once 21 | 22 | // Simple tcp client sink 23 | // Connects to remote address and send the formatted log. 24 | // Will attempt to reconnect if connection drops. 25 | // If more complicated behaviour is needed (i.e get responses), you can inherit it and override the sink_it_ method. 26 | 27 | namespace spdlog { 28 | namespace sinks { 29 | 30 | struct tcp_sink_config 31 | { 32 | std::string server_host; 33 | int server_port; 34 | bool lazy_connect = false; // if true connect on first log call instead of on construction 35 | 36 | tcp_sink_config(std::string host, int port) 37 | : server_host{std::move(host)} 38 | , server_port{port} 39 | {} 40 | }; 41 | 42 | template 43 | class tcp_sink : public spdlog::sinks::base_sink 44 | { 45 | public: 46 | // connect to tcp host/port or throw if failed 47 | // host can be hostname or ip address 48 | 49 | explicit tcp_sink(tcp_sink_config sink_config) 50 | : config_{std::move(sink_config)} 51 | { 52 | if (!config_.lazy_connect) 53 | { 54 | this->client_.connect(config_.server_host, config_.server_port); 55 | } 56 | } 57 | 58 | ~tcp_sink() override = default; 59 | 60 | protected: 61 | void sink_it_(const spdlog::details::log_msg &msg) override 62 | { 63 | spdlog::memory_buf_t formatted; 64 | spdlog::sinks::base_sink::formatter_->format(msg, formatted); 65 | if (!client_.is_connected()) 66 | { 67 | client_.connect(config_.server_host, config_.server_port); 68 | } 69 | client_.send(formatted.data(), formatted.size()); 70 | } 71 | 72 | void flush_() override {} 73 | tcp_sink_config config_; 74 | details::tcp_client client_; 75 | }; 76 | 77 | using tcp_sink_mt = tcp_sink; 78 | using tcp_sink_st = tcp_sink; 79 | 80 | } // namespace sinks 81 | } // namespace spdlog 82 | -------------------------------------------------------------------------------- /vendor/spdlog/include/spdlog/sinks/wincolor_sink.h: -------------------------------------------------------------------------------- 1 | // Copyright(c) 2015-present, Gabi Melman & spdlog contributors. 2 | // Distributed under the MIT License (http://opensource.org/licenses/MIT) 3 | 4 | #pragma once 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | 17 | namespace spdlog { 18 | namespace sinks { 19 | /* 20 | * Windows color console sink. Uses WriteConsoleA to write to the console with 21 | * colors 22 | */ 23 | template 24 | class wincolor_sink : public sink 25 | { 26 | public: 27 | wincolor_sink(void *out_handle, color_mode mode); 28 | ~wincolor_sink() override; 29 | 30 | wincolor_sink(const wincolor_sink &other) = delete; 31 | wincolor_sink &operator=(const wincolor_sink &other) = delete; 32 | 33 | // change the color for the given level 34 | void set_color(level::level_enum level, std::uint16_t color); 35 | void log(const details::log_msg &msg) final override; 36 | void flush() final override; 37 | void set_pattern(const std::string &pattern) override final; 38 | void set_formatter(std::unique_ptr sink_formatter) override final; 39 | void set_color_mode(color_mode mode); 40 | 41 | protected: 42 | using mutex_t = typename ConsoleMutex::mutex_t; 43 | void *out_handle_; 44 | mutex_t &mutex_; 45 | bool should_do_colors_; 46 | std::unique_ptr formatter_; 47 | std::array colors_; 48 | 49 | // set foreground color and return the orig console attributes (for resetting later) 50 | std::uint16_t set_foreground_color_(std::uint16_t attribs); 51 | 52 | // print a range of formatted message to console 53 | void print_range_(const memory_buf_t &formatted, size_t start, size_t end); 54 | 55 | // in case we are redirected to file (not in console mode) 56 | void write_to_file_(const memory_buf_t &formatted); 57 | 58 | void set_color_mode_impl(color_mode mode); 59 | }; 60 | 61 | template 62 | class wincolor_stdout_sink : public wincolor_sink 63 | { 64 | public: 65 | explicit wincolor_stdout_sink(color_mode mode = color_mode::automatic); 66 | }; 67 | 68 | template 69 | class wincolor_stderr_sink : public wincolor_sink 70 | { 71 | public: 72 | explicit wincolor_stderr_sink(color_mode mode = color_mode::automatic); 73 | }; 74 | 75 | using wincolor_stdout_sink_mt = wincolor_stdout_sink; 76 | using wincolor_stdout_sink_st = wincolor_stdout_sink; 77 | 78 | using wincolor_stderr_sink_mt = wincolor_stderr_sink; 79 | using wincolor_stderr_sink_st = wincolor_stderr_sink; 80 | } // namespace sinks 81 | } // namespace spdlog 82 | 83 | #ifdef SPDLOG_HEADER_ONLY 84 | #include "wincolor_sink-inl.h" 85 | #endif 86 | -------------------------------------------------------------------------------- /vendor/spdlog/include/spdlog/spdlog-inl.h: -------------------------------------------------------------------------------- 1 | // Copyright(c) 2015-present, Gabi Melman & spdlog contributors. 2 | // Distributed under the MIT License (http://opensource.org/licenses/MIT) 3 | 4 | #pragma once 5 | 6 | #ifndef SPDLOG_HEADER_ONLY 7 | #include 8 | #endif 9 | 10 | #include 11 | #include 12 | 13 | namespace spdlog { 14 | 15 | SPDLOG_INLINE void initialize_logger(std::shared_ptr logger) 16 | { 17 | details::registry::instance().initialize_logger(std::move(logger)); 18 | } 19 | 20 | SPDLOG_INLINE std::shared_ptr get(const std::string &name) 21 | { 22 | return details::registry::instance().get(name); 23 | } 24 | 25 | SPDLOG_INLINE void set_formatter(std::unique_ptr formatter) 26 | { 27 | details::registry::instance().set_formatter(std::move(formatter)); 28 | } 29 | 30 | SPDLOG_INLINE void set_pattern(std::string pattern, pattern_time_type time_type) 31 | { 32 | set_formatter(std::unique_ptr(new pattern_formatter(std::move(pattern), time_type))); 33 | } 34 | 35 | SPDLOG_INLINE void enable_backtrace(size_t n_messages) 36 | { 37 | details::registry::instance().enable_backtrace(n_messages); 38 | } 39 | 40 | SPDLOG_INLINE void disable_backtrace() 41 | { 42 | details::registry::instance().disable_backtrace(); 43 | } 44 | 45 | SPDLOG_INLINE void dump_backtrace() 46 | { 47 | default_logger_raw()->dump_backtrace(); 48 | } 49 | 50 | SPDLOG_INLINE level::level_enum get_level() 51 | { 52 | return default_logger_raw()->level(); 53 | } 54 | 55 | SPDLOG_INLINE bool should_log(level::level_enum log_level) 56 | { 57 | return default_logger_raw()->should_log(log_level); 58 | } 59 | 60 | SPDLOG_INLINE void set_level(level::level_enum log_level) 61 | { 62 | details::registry::instance().set_level(log_level); 63 | } 64 | 65 | SPDLOG_INLINE void flush_on(level::level_enum log_level) 66 | { 67 | details::registry::instance().flush_on(log_level); 68 | } 69 | 70 | SPDLOG_INLINE void flush_every(std::chrono::seconds interval) 71 | { 72 | details::registry::instance().flush_every(interval); 73 | } 74 | 75 | SPDLOG_INLINE void set_error_handler(void (*handler)(const std::string &msg)) 76 | { 77 | details::registry::instance().set_error_handler(handler); 78 | } 79 | 80 | SPDLOG_INLINE void register_logger(std::shared_ptr logger) 81 | { 82 | details::registry::instance().register_logger(std::move(logger)); 83 | } 84 | 85 | SPDLOG_INLINE void apply_all(const std::function)> &fun) 86 | { 87 | details::registry::instance().apply_all(fun); 88 | } 89 | 90 | SPDLOG_INLINE void drop(const std::string &name) 91 | { 92 | details::registry::instance().drop(name); 93 | } 94 | 95 | SPDLOG_INLINE void drop_all() 96 | { 97 | details::registry::instance().drop_all(); 98 | } 99 | 100 | SPDLOG_INLINE void shutdown() 101 | { 102 | details::registry::instance().shutdown(); 103 | } 104 | 105 | SPDLOG_INLINE void set_automatic_registration(bool automatic_registration) 106 | { 107 | details::registry::instance().set_automatic_registration(automatic_registration); 108 | } 109 | 110 | SPDLOG_INLINE std::shared_ptr default_logger() 111 | { 112 | return details::registry::instance().default_logger(); 113 | } 114 | 115 | SPDLOG_INLINE spdlog::logger *default_logger_raw() 116 | { 117 | return details::registry::instance().get_default_raw(); 118 | } 119 | 120 | SPDLOG_INLINE void set_default_logger(std::shared_ptr default_logger) 121 | { 122 | details::registry::instance().set_default_logger(std::move(default_logger)); 123 | } 124 | 125 | } // namespace spdlog 126 | -------------------------------------------------------------------------------- /vendor/spdlog/include/spdlog/stopwatch.h: -------------------------------------------------------------------------------- 1 | // Copyright(c) 2015-present, Gabi Melman & spdlog contributors. 2 | // Distributed under the MIT License (http://opensource.org/licenses/MIT) 3 | 4 | #pragma once 5 | 6 | #include 7 | 8 | // Stopwatch support for spdlog (using std::chrono::steady_clock). 9 | // Displays elapsed seconds since construction as double. 10 | // 11 | // Usage: 12 | // 13 | // spdlog::stopwatch sw; 14 | // ... 15 | // spdlog::debug("Elapsed: {} seconds", sw); => "Elapsed 0.005116733 seconds" 16 | // spdlog::info("Elapsed: {:.6} seconds", sw); => "Elapsed 0.005163 seconds" 17 | // 18 | // 19 | // If other units are needed (e.g. millis instead of double), include "fmt/chrono.h" and use "duration_cast<..>(sw.elapsed())": 20 | // 21 | // #include 22 | //.. 23 | // using std::chrono::duration_cast; 24 | // using std::chrono::milliseconds; 25 | // spdlog::info("Elapsed {}", duration_cast(sw.elapsed())); => "Elapsed 5ms" 26 | 27 | namespace spdlog { 28 | class stopwatch 29 | { 30 | using clock = std::chrono::steady_clock; 31 | std::chrono::time_point start_tp_; 32 | 33 | public: 34 | stopwatch() 35 | : start_tp_{clock::now()} 36 | {} 37 | 38 | std::chrono::duration elapsed() const 39 | { 40 | return std::chrono::duration(clock::now() - start_tp_); 41 | } 42 | 43 | void reset() 44 | { 45 | start_tp_ = clock ::now(); 46 | } 47 | }; 48 | } // namespace spdlog 49 | 50 | // Support for fmt formatting (e.g. "{:012.9}" or just "{}") 51 | namespace fmt { 52 | template<> 53 | struct formatter : formatter 54 | { 55 | template 56 | auto format(const spdlog::stopwatch &sw, FormatContext &ctx) -> decltype(ctx.out()) 57 | { 58 | return formatter::format(sw.elapsed().count(), ctx); 59 | } 60 | }; 61 | } // namespace fmt 62 | -------------------------------------------------------------------------------- /vendor/spdlog/include/spdlog/version.h: -------------------------------------------------------------------------------- 1 | // Copyright(c) 2015-present, Gabi Melman & spdlog contributors. 2 | // Distributed under the MIT License (http://opensource.org/licenses/MIT) 3 | 4 | #pragma once 5 | 6 | #define SPDLOG_VER_MAJOR 1 7 | #define SPDLOG_VER_MINOR 8 8 | #define SPDLOG_VER_PATCH 5 9 | 10 | #define SPDLOG_VERSION (SPDLOG_VER_MAJOR * 10000 + SPDLOG_VER_MINOR * 100 + SPDLOG_VER_PATCH) 11 | -------------------------------------------------------------------------------- /vendor/spdlog/src/async.cpp: -------------------------------------------------------------------------------- 1 | // Copyright(c) 2015-present, Gabi Melman & spdlog contributors. 2 | // Distributed under the MIT License (http://opensource.org/licenses/MIT) 3 | 4 | #ifndef SPDLOG_COMPILED_LIB 5 | #error Please define SPDLOG_COMPILED_LIB to compile this file. 6 | #endif 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | template class SPDLOG_API spdlog::details::mpmc_blocking_queue; 14 | 15 | -------------------------------------------------------------------------------- /vendor/spdlog/src/cfg.cpp: -------------------------------------------------------------------------------- 1 | // Copyright(c) 2015-present, Gabi Melman & spdlog contributors. 2 | // Distributed under the MIT License (http://opensource.org/licenses/MIT) 3 | 4 | #ifndef SPDLOG_COMPILED_LIB 5 | #error Please define SPDLOG_COMPILED_LIB to compile this file. 6 | #endif 7 | 8 | #include 9 | 10 | -------------------------------------------------------------------------------- /vendor/spdlog/src/color_sinks.cpp: -------------------------------------------------------------------------------- 1 | // Copyright(c) 2015-present, Gabi Melman & spdlog contributors. 2 | // Distributed under the MIT License (http://opensource.org/licenses/MIT) 3 | 4 | #ifndef SPDLOG_COMPILED_LIB 5 | #error Please define SPDLOG_COMPILED_LIB to compile this file. 6 | #endif 7 | 8 | #include 9 | 10 | #include 11 | #include 12 | // 13 | // color sinks 14 | // 15 | #ifdef _WIN32 16 | #include 17 | template class SPDLOG_API spdlog::sinks::wincolor_sink; 18 | template class SPDLOG_API spdlog::sinks::wincolor_sink; 19 | template class SPDLOG_API spdlog::sinks::wincolor_stdout_sink; 20 | template class SPDLOG_API spdlog::sinks::wincolor_stdout_sink; 21 | template class SPDLOG_API spdlog::sinks::wincolor_stderr_sink; 22 | template class SPDLOG_API spdlog::sinks::wincolor_stderr_sink; 23 | #else 24 | #include "spdlog/sinks/ansicolor_sink-inl.h" 25 | template class SPDLOG_API spdlog::sinks::ansicolor_sink; 26 | template class SPDLOG_API spdlog::sinks::ansicolor_sink; 27 | template class SPDLOG_API spdlog::sinks::ansicolor_stdout_sink; 28 | template class SPDLOG_API spdlog::sinks::ansicolor_stdout_sink; 29 | template class SPDLOG_API spdlog::sinks::ansicolor_stderr_sink; 30 | template class SPDLOG_API spdlog::sinks::ansicolor_stderr_sink; 31 | #endif 32 | 33 | // factory methods for color loggers 34 | #include "spdlog/sinks/stdout_color_sinks-inl.h" 35 | template SPDLOG_API std::shared_ptr spdlog::stdout_color_mt( 36 | const std::string &logger_name, color_mode mode); 37 | template SPDLOG_API std::shared_ptr spdlog::stdout_color_st( 38 | const std::string &logger_name, color_mode mode); 39 | template SPDLOG_API std::shared_ptr spdlog::stderr_color_mt( 40 | const std::string &logger_name, color_mode mode); 41 | template SPDLOG_API std::shared_ptr spdlog::stderr_color_st( 42 | const std::string &logger_name, color_mode mode); 43 | 44 | template SPDLOG_API std::shared_ptr spdlog::stdout_color_mt( 45 | const std::string &logger_name, color_mode mode); 46 | template SPDLOG_API std::shared_ptr spdlog::stdout_color_st( 47 | const std::string &logger_name, color_mode mode); 48 | template SPDLOG_API std::shared_ptr spdlog::stderr_color_mt( 49 | const std::string &logger_name, color_mode mode); 50 | template SPDLOG_API std::shared_ptr spdlog::stderr_color_st( 51 | const std::string &logger_name, color_mode mode); 52 | 53 | -------------------------------------------------------------------------------- /vendor/spdlog/src/file_sinks.cpp: -------------------------------------------------------------------------------- 1 | // Copyright(c) 2015-present, Gabi Melman & spdlog contributors. 2 | // Distributed under the MIT License (http://opensource.org/licenses/MIT) 3 | 4 | #ifndef SPDLOG_COMPILED_LIB 5 | #error Please define SPDLOG_COMPILED_LIB to compile this file. 6 | #endif 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | #include 14 | 15 | template class SPDLOG_API spdlog::sinks::basic_file_sink; 16 | template class SPDLOG_API spdlog::sinks::basic_file_sink; 17 | 18 | #include 19 | template class SPDLOG_API spdlog::sinks::rotating_file_sink; 20 | template class SPDLOG_API spdlog::sinks::rotating_file_sink; 21 | 22 | -------------------------------------------------------------------------------- /vendor/spdlog/src/fmt.cpp: -------------------------------------------------------------------------------- 1 | // Slightly modified version of fmt lib's format.cc source file. 2 | // Copyright (c) 2012 - 2016, Victor Zverovich 3 | // All rights reserved. 4 | 5 | #ifndef SPDLOG_COMPILED_LIB 6 | #error Please define SPDLOG_COMPILED_LIB to compile this file. 7 | #endif 8 | 9 | #if !defined(SPDLOG_FMT_EXTERNAL) 10 | #include 11 | 12 | 13 | 14 | FMT_BEGIN_NAMESPACE 15 | namespace detail { 16 | 17 | template 18 | int format_float(char *buf, std::size_t size, const char *format, int precision, T value) 19 | { 20 | # ifdef FMT_FUZZ 21 | if (precision > 100000) 22 | throw std::runtime_error("fuzz mode - avoid large allocation inside snprintf"); 23 | # endif 24 | // Suppress the warning about nonliteral format string. 25 | int (*snprintf_ptr)(char *, size_t, const char *, ...) = FMT_SNPRINTF; 26 | return precision < 0 ? snprintf_ptr(buf, size, format, value) : snprintf_ptr(buf, size, format, precision, value); 27 | } 28 | 29 | template FMT_API dragonbox::decimal_fp dragonbox::to_decimal(float x) FMT_NOEXCEPT; 30 | template FMT_API dragonbox::decimal_fp dragonbox::to_decimal(double x) FMT_NOEXCEPT; 31 | } // namespace detail 32 | 33 | // Workaround a bug in MSVC2013 that prevents instantiation of format_float. 34 | int (*instantiate_format_float)(double, int, detail::float_specs, detail::buffer &) = detail::format_float; 35 | 36 | # ifndef FMT_STATIC_THOUSANDS_SEPARATOR 37 | template FMT_API detail::locale_ref::locale_ref(const std::locale &loc); 38 | template FMT_API std::locale detail::locale_ref::get() const; 39 | # endif 40 | 41 | // Explicit instantiations for char. 42 | 43 | template FMT_API auto detail::thousands_sep_impl(locale_ref) -> thousands_sep_result; 44 | template FMT_API char detail::decimal_point_impl(locale_ref); 45 | 46 | template FMT_API void detail::buffer::append(const char *, const char *); 47 | 48 | template FMT_API void detail::vformat_to( 49 | detail::buffer &, string_view, basic_format_args, detail::locale_ref); 50 | 51 | template FMT_API int detail::snprintf_float(double, int, detail::float_specs, detail::buffer &); 52 | template FMT_API int detail::snprintf_float(long double, int, detail::float_specs, detail::buffer &); 53 | template FMT_API int detail::format_float(double, int, detail::float_specs, detail::buffer &); 54 | template FMT_API int detail::format_float(long double, int, detail::float_specs, detail::buffer &); 55 | 56 | // Explicit instantiations for wchar_t. 57 | 58 | template FMT_API auto detail::thousands_sep_impl(locale_ref) -> thousands_sep_result; 59 | template FMT_API wchar_t detail::decimal_point_impl(locale_ref); 60 | 61 | template FMT_API void detail::buffer::append(const wchar_t *, const wchar_t *); 62 | 63 | template struct detail::basic_data; 64 | 65 | FMT_END_NAMESPACE 66 | 67 | #endif // !SPDLOG_FMT_EXTERNAL 68 | -------------------------------------------------------------------------------- /vendor/spdlog/src/spdlog.cpp: -------------------------------------------------------------------------------- 1 | // Copyright(c) 2015-present, Gabi Melman & spdlog contributors. 2 | // Distributed under the MIT License (http://opensource.org/licenses/MIT) 3 | 4 | #ifndef SPDLOG_COMPILED_LIB 5 | #error Please define SPDLOG_COMPILED_LIB to compile this file. 6 | #endif 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | 21 | #include 22 | 23 | // template instantiate logger constructor with sinks init list 24 | template SPDLOG_API spdlog::logger::logger(std::string name, sinks_init_list::iterator begin, sinks_init_list::iterator end); 25 | template class SPDLOG_API spdlog::sinks::base_sink; 26 | template class SPDLOG_API spdlog::sinks::base_sink; 27 | 28 | -------------------------------------------------------------------------------- /vendor/spdlog/src/stdout_sinks.cpp: -------------------------------------------------------------------------------- 1 | // Copyright(c) 2015-present, Gabi Melman & spdlog contributors. 2 | // Distributed under the MIT License (http://opensource.org/licenses/MIT) 3 | 4 | #ifndef SPDLOG_COMPILED_LIB 5 | #error Please define SPDLOG_COMPILED_LIB to compile this file. 6 | #endif 7 | 8 | #include 9 | 10 | #include 11 | #include 12 | #include 13 | 14 | template class SPDLOG_API spdlog::sinks::stdout_sink_base; 15 | template class SPDLOG_API spdlog::sinks::stdout_sink_base; 16 | template class SPDLOG_API spdlog::sinks::stdout_sink; 17 | template class SPDLOG_API spdlog::sinks::stdout_sink; 18 | template class SPDLOG_API spdlog::sinks::stderr_sink; 19 | template class SPDLOG_API spdlog::sinks::stderr_sink; 20 | 21 | template SPDLOG_API std::shared_ptr spdlog::stdout_logger_mt(const std::string &logger_name); 22 | template SPDLOG_API std::shared_ptr spdlog::stdout_logger_st(const std::string &logger_name); 23 | template SPDLOG_API std::shared_ptr spdlog::stderr_logger_mt(const std::string &logger_name); 24 | template SPDLOG_API std::shared_ptr spdlog::stderr_logger_st(const std::string &logger_name); 25 | 26 | template SPDLOG_API std::shared_ptr spdlog::stdout_logger_mt(const std::string &logger_name); 27 | template SPDLOG_API std::shared_ptr spdlog::stdout_logger_st(const std::string &logger_name); 28 | template SPDLOG_API std::shared_ptr spdlog::stderr_logger_mt(const std::string &logger_name); 29 | template SPDLOG_API std::shared_ptr spdlog::stderr_logger_st(const std::string &logger_name); 30 | 31 | -------------------------------------------------------------------------------- /vendor/unicorn/include/list.h: -------------------------------------------------------------------------------- 1 | #ifndef UC_LLIST_H 2 | #define UC_LLIST_H 3 | 4 | #include "unicorn/platform.h" 5 | 6 | struct list_item { 7 | struct list_item *next; 8 | void *data; 9 | }; 10 | 11 | struct list { 12 | struct list_item *head, *tail; 13 | }; 14 | 15 | // create a new list 16 | struct list *list_new(void); 17 | 18 | // removed linked list nodes but does not free their content 19 | void list_clear(struct list *list); 20 | 21 | // insert a new item at the begin of the list. 22 | void *list_insert(struct list *list, void *data); 23 | 24 | // append a new item at the end of the list. 25 | void *list_append(struct list *list, void *data); 26 | 27 | // returns true if entry was removed, false otherwise 28 | bool list_remove(struct list *list, void *data); 29 | 30 | // returns true if the data exists in the list 31 | bool list_exists(struct list *list, void *data); 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /vendor/unicorn/include/qemu.h: -------------------------------------------------------------------------------- 1 | /* By Dang Hoang Vu , 2015 */ 2 | 3 | #ifndef UC_QEMU_H 4 | #define UC_QEMU_H 5 | 6 | struct uc_struct; 7 | 8 | #define OPC_BUF_SIZE 640 9 | 10 | #include "sysemu/sysemu.h" 11 | #include "sysemu/cpus.h" 12 | #include "exec/cpu-common.h" 13 | #include "exec/memory.h" 14 | 15 | #include "qemu/thread.h" 16 | #include "include/qom/cpu.h" 17 | 18 | #include "vl.h" 19 | 20 | // This two struct is originally from qemu/include/exec/cpu-all.h 21 | // Temporarily moved here since there is circular inclusion. 22 | typedef struct RAMBlock { 23 | struct MemoryRegion *mr; 24 | uint8_t *host; 25 | ram_addr_t offset; 26 | ram_addr_t length; 27 | uint32_t flags; 28 | char idstr[256]; 29 | /* Reads can take either the iothread or the ramlist lock. 30 | * Writes must take both locks. 31 | */ 32 | QTAILQ_ENTRY(RAMBlock) next; 33 | int fd; 34 | } RAMBlock; 35 | 36 | typedef struct { 37 | MemoryRegion *mr; 38 | void *buffer; 39 | hwaddr addr; 40 | hwaddr len; 41 | } BounceBuffer; 42 | 43 | typedef struct RAMList { 44 | /* Protected by the iothread lock. */ 45 | unsigned long *dirty_memory[DIRTY_MEMORY_NUM]; 46 | RAMBlock *mru_block; 47 | QTAILQ_HEAD(, RAMBlock) blocks; 48 | uint32_t version; 49 | } RAMList; 50 | 51 | #endif 52 | -------------------------------------------------------------------------------- /vendor/unicorn/include/unicorn/m68k.h: -------------------------------------------------------------------------------- 1 | /* Unicorn Emulator Engine */ 2 | /* By Nguyen Anh Quynh , 2014-2017 */ 3 | /* This file is released under LGPL2. 4 | See COPYING.LGPL2 in root directory for more details 5 | */ 6 | 7 | #ifndef UNICORN_M68K_H 8 | #define UNICORN_M68K_H 9 | 10 | #ifdef __cplusplus 11 | extern "C" { 12 | #endif 13 | 14 | #ifdef _MSC_VER 15 | #pragma warning(disable:4201) 16 | #endif 17 | 18 | //> M68K registers 19 | typedef enum uc_m68k_reg { 20 | UC_M68K_REG_INVALID = 0, 21 | 22 | UC_M68K_REG_A0, 23 | UC_M68K_REG_A1, 24 | UC_M68K_REG_A2, 25 | UC_M68K_REG_A3, 26 | UC_M68K_REG_A4, 27 | UC_M68K_REG_A5, 28 | UC_M68K_REG_A6, 29 | UC_M68K_REG_A7, 30 | 31 | UC_M68K_REG_D0, 32 | UC_M68K_REG_D1, 33 | UC_M68K_REG_D2, 34 | UC_M68K_REG_D3, 35 | UC_M68K_REG_D4, 36 | UC_M68K_REG_D5, 37 | UC_M68K_REG_D6, 38 | UC_M68K_REG_D7, 39 | 40 | UC_M68K_REG_SR, 41 | UC_M68K_REG_PC, 42 | 43 | UC_M68K_REG_ENDING, // <-- mark the end of the list of registers 44 | } uc_m68k_reg; 45 | 46 | #ifdef __cplusplus 47 | } 48 | #endif 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /vendor/unicorn/include/unicorn/sparc.h: -------------------------------------------------------------------------------- 1 | /* Unicorn Emulator Engine */ 2 | /* By Nguyen Anh Quynh , 2014-2017 */ 3 | /* This file is released under LGPL2. 4 | See COPYING.LGPL2 in root directory for more details 5 | */ 6 | 7 | #ifndef UNICORN_SPARC_H 8 | #define UNICORN_SPARC_H 9 | 10 | #ifdef __cplusplus 11 | extern "C" { 12 | #endif 13 | 14 | // GCC SPARC toolchain has a default macro called "sparc" which breaks 15 | // compilation 16 | #undef sparc 17 | 18 | #ifdef _MSC_VER 19 | #pragma warning(disable:4201) 20 | #endif 21 | 22 | //> SPARC registers 23 | typedef enum uc_sparc_reg { 24 | UC_SPARC_REG_INVALID = 0, 25 | 26 | UC_SPARC_REG_F0, 27 | UC_SPARC_REG_F1, 28 | UC_SPARC_REG_F2, 29 | UC_SPARC_REG_F3, 30 | UC_SPARC_REG_F4, 31 | UC_SPARC_REG_F5, 32 | UC_SPARC_REG_F6, 33 | UC_SPARC_REG_F7, 34 | UC_SPARC_REG_F8, 35 | UC_SPARC_REG_F9, 36 | UC_SPARC_REG_F10, 37 | UC_SPARC_REG_F11, 38 | UC_SPARC_REG_F12, 39 | UC_SPARC_REG_F13, 40 | UC_SPARC_REG_F14, 41 | UC_SPARC_REG_F15, 42 | UC_SPARC_REG_F16, 43 | UC_SPARC_REG_F17, 44 | UC_SPARC_REG_F18, 45 | UC_SPARC_REG_F19, 46 | UC_SPARC_REG_F20, 47 | UC_SPARC_REG_F21, 48 | UC_SPARC_REG_F22, 49 | UC_SPARC_REG_F23, 50 | UC_SPARC_REG_F24, 51 | UC_SPARC_REG_F25, 52 | UC_SPARC_REG_F26, 53 | UC_SPARC_REG_F27, 54 | UC_SPARC_REG_F28, 55 | UC_SPARC_REG_F29, 56 | UC_SPARC_REG_F30, 57 | UC_SPARC_REG_F31, 58 | UC_SPARC_REG_F32, 59 | UC_SPARC_REG_F34, 60 | UC_SPARC_REG_F36, 61 | UC_SPARC_REG_F38, 62 | UC_SPARC_REG_F40, 63 | UC_SPARC_REG_F42, 64 | UC_SPARC_REG_F44, 65 | UC_SPARC_REG_F46, 66 | UC_SPARC_REG_F48, 67 | UC_SPARC_REG_F50, 68 | UC_SPARC_REG_F52, 69 | UC_SPARC_REG_F54, 70 | UC_SPARC_REG_F56, 71 | UC_SPARC_REG_F58, 72 | UC_SPARC_REG_F60, 73 | UC_SPARC_REG_F62, 74 | UC_SPARC_REG_FCC0, // Floating condition codes 75 | UC_SPARC_REG_FCC1, 76 | UC_SPARC_REG_FCC2, 77 | UC_SPARC_REG_FCC3, 78 | UC_SPARC_REG_G0, 79 | UC_SPARC_REG_G1, 80 | UC_SPARC_REG_G2, 81 | UC_SPARC_REG_G3, 82 | UC_SPARC_REG_G4, 83 | UC_SPARC_REG_G5, 84 | UC_SPARC_REG_G6, 85 | UC_SPARC_REG_G7, 86 | UC_SPARC_REG_I0, 87 | UC_SPARC_REG_I1, 88 | UC_SPARC_REG_I2, 89 | UC_SPARC_REG_I3, 90 | UC_SPARC_REG_I4, 91 | UC_SPARC_REG_I5, 92 | UC_SPARC_REG_FP, 93 | UC_SPARC_REG_I7, 94 | UC_SPARC_REG_ICC, // Integer condition codes 95 | UC_SPARC_REG_L0, 96 | UC_SPARC_REG_L1, 97 | UC_SPARC_REG_L2, 98 | UC_SPARC_REG_L3, 99 | UC_SPARC_REG_L4, 100 | UC_SPARC_REG_L5, 101 | UC_SPARC_REG_L6, 102 | UC_SPARC_REG_L7, 103 | UC_SPARC_REG_O0, 104 | UC_SPARC_REG_O1, 105 | UC_SPARC_REG_O2, 106 | UC_SPARC_REG_O3, 107 | UC_SPARC_REG_O4, 108 | UC_SPARC_REG_O5, 109 | UC_SPARC_REG_SP, 110 | UC_SPARC_REG_O7, 111 | UC_SPARC_REG_Y, 112 | 113 | // special register 114 | UC_SPARC_REG_XCC, 115 | 116 | // pseudo register 117 | UC_SPARC_REG_PC, // program counter register 118 | 119 | UC_SPARC_REG_ENDING, // <-- mark the end of the list of registers 120 | 121 | // extras 122 | UC_SPARC_REG_O6 = UC_SPARC_REG_SP, 123 | UC_SPARC_REG_I6 = UC_SPARC_REG_FP, 124 | } uc_sparc_reg; 125 | 126 | #ifdef __cplusplus 127 | } 128 | #endif 129 | 130 | #endif 131 | -------------------------------------------------------------------------------- /vendor/unicorn/lib/x64/unicorn_static.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mike1k/VMPImportFixer/b6fef34b90669933425f24e8204ff2cb52128fb6/vendor/unicorn/lib/x64/unicorn_static.lib -------------------------------------------------------------------------------- /vendor/zycore/include/Zycore/API/Process.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************************************** 2 | 3 | Zyan Core Library (Zycore-C) 4 | 5 | Original Author : Florian Bernd 6 | 7 | * Permission is hereby granted, free of charge, to any person obtaining a copy 8 | * of this software and associated documentation files (the "Software"), to deal 9 | * in the Software without restriction, including without limitation the rights 10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | * copies of the Software, and to permit persons to whom the Software is 12 | * furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in all 15 | * copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | * SOFTWARE. 24 | 25 | ***************************************************************************************************/ 26 | 27 | /** 28 | * @file 29 | * @brief 30 | */ 31 | 32 | #ifndef ZYCORE_API_PROCESS_H 33 | #define ZYCORE_API_PROCESS_H 34 | 35 | #include 36 | #include 37 | #include 38 | 39 | /* ============================================================================================== */ 40 | /* Enums and types */ 41 | /* ============================================================================================== */ 42 | 43 | 44 | 45 | /* ============================================================================================== */ 46 | /* Exported functions */ 47 | /* ============================================================================================== */ 48 | 49 | /* ---------------------------------------------------------------------------------------------- */ 50 | /* General */ 51 | /* ---------------------------------------------------------------------------------------------- */ 52 | 53 | /** 54 | * @brief Flushes the process instruction cache. 55 | * 56 | * @param address The address. 57 | * @param size The size. 58 | * 59 | * @return A zyan status code. 60 | */ 61 | ZYCORE_EXPORT ZyanStatus ZyanProcessFlushInstructionCache(void* address, ZyanUSize size); 62 | 63 | /* ---------------------------------------------------------------------------------------------- */ 64 | 65 | /* ============================================================================================== */ 66 | 67 | #endif /* ZYCORE_API_PROCESS_H */ 68 | -------------------------------------------------------------------------------- /vendor/zycore/include/Zycore/Object.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************************************** 2 | 3 | Zyan Core Library (Zycore-C) 4 | 5 | Original Author : Florian Bernd 6 | 7 | * Permission is hereby granted, free of charge, to any person obtaining a copy 8 | * of this software and associated documentation files (the "Software"), to deal 9 | * in the Software without restriction, including without limitation the rights 10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | * copies of the Software, and to permit persons to whom the Software is 12 | * furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in all 15 | * copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | * SOFTWARE. 24 | 25 | ***************************************************************************************************/ 26 | 27 | /** 28 | * @file 29 | * Defines some generic object-related datatypes. 30 | */ 31 | 32 | #ifndef ZYCORE_OBJECT_H 33 | #define ZYCORE_OBJECT_H 34 | 35 | #include 36 | #include 37 | 38 | #ifdef __cplusplus 39 | extern "C" { 40 | #endif 41 | 42 | /* ============================================================================================== */ 43 | /* Enums and types */ 44 | /* ============================================================================================== */ 45 | 46 | /** 47 | * Defines the `ZyanMemberProcedure` function prototype. 48 | * 49 | * @param object A pointer to the object. 50 | */ 51 | typedef void (*ZyanMemberProcedure)(void* object); 52 | 53 | /** 54 | * Defines the `ZyanConstMemberProcedure` function prototype. 55 | * 56 | * @param object A pointer to the object. 57 | */ 58 | typedef void (*ZyanConstMemberProcedure)(const void* object); 59 | 60 | /** 61 | * Defines the `ZyanMemberFunction` function prototype. 62 | * 63 | * @param object A pointer to the object. 64 | * 65 | * @return A zyan status code. 66 | */ 67 | typedef ZyanStatus (*ZyanMemberFunction)(void* object); 68 | 69 | /** 70 | * Defines the `ZyanConstMemberFunction` function prototype. 71 | * 72 | * @param object A pointer to the object. 73 | * 74 | * @return A zyan status code. 75 | */ 76 | typedef ZyanStatus (*ZyanConstMemberFunction)(const void* object); 77 | 78 | /* ============================================================================================== */ 79 | 80 | #ifdef __cplusplus 81 | } 82 | #endif 83 | 84 | #endif /* ZYCORE_OBJECT_H */ 85 | -------------------------------------------------------------------------------- /vendor/zycore/include/Zycore/ZycoreExportConfig.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef ZYCORE_EXPORT_H 3 | #define ZYCORE_EXPORT_H 4 | 5 | #ifdef ZYCORE_STATIC_DEFINE 6 | # define ZYCORE_EXPORT 7 | # define ZYCORE_NO_EXPORT 8 | #else 9 | # ifndef ZYCORE_EXPORT 10 | # ifdef Zycore_EXPORTS 11 | /* We are building this library */ 12 | # define ZYCORE_EXPORT __declspec(dllexport) 13 | # else 14 | /* We are using this library */ 15 | # define ZYCORE_EXPORT __declspec(dllimport) 16 | # endif 17 | # endif 18 | 19 | # ifndef ZYCORE_NO_EXPORT 20 | # define ZYCORE_NO_EXPORT 21 | # endif 22 | #endif 23 | 24 | #ifndef ZYCORE_DEPRECATED 25 | # define ZYCORE_DEPRECATED __declspec(deprecated) 26 | #endif 27 | 28 | #ifndef ZYCORE_DEPRECATED_EXPORT 29 | # define ZYCORE_DEPRECATED_EXPORT ZYCORE_EXPORT ZYCORE_DEPRECATED 30 | #endif 31 | 32 | #ifndef ZYCORE_DEPRECATED_NO_EXPORT 33 | # define ZYCORE_DEPRECATED_NO_EXPORT ZYCORE_NO_EXPORT ZYCORE_DEPRECATED 34 | #endif 35 | 36 | #if 0 /* DEFINE_NO_DEPRECATED */ 37 | # ifndef ZYCORE_NO_DEPRECATED 38 | # define ZYCORE_NO_DEPRECATED 39 | # endif 40 | #endif 41 | 42 | #endif /* ZYCORE_EXPORT_H */ 43 | -------------------------------------------------------------------------------- /vendor/zycore/include/ZycoreExportConfig.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef ZYCORE_EXPORT_H 3 | #define ZYCORE_EXPORT_H 4 | 5 | #ifdef ZYCORE_STATIC_DEFINE 6 | # define ZYCORE_EXPORT 7 | # define ZYCORE_NO_EXPORT 8 | #else 9 | # ifndef ZYCORE_EXPORT 10 | # ifdef Zycore_EXPORTS 11 | /* We are building this library */ 12 | # define ZYCORE_EXPORT __declspec(dllexport) 13 | # else 14 | /* We are using this library */ 15 | # define ZYCORE_EXPORT __declspec(dllimport) 16 | # endif 17 | # endif 18 | 19 | # ifndef ZYCORE_NO_EXPORT 20 | # define ZYCORE_NO_EXPORT 21 | # endif 22 | #endif 23 | 24 | #ifndef ZYCORE_DEPRECATED 25 | # define ZYCORE_DEPRECATED __declspec(deprecated) 26 | #endif 27 | 28 | #ifndef ZYCORE_DEPRECATED_EXPORT 29 | # define ZYCORE_DEPRECATED_EXPORT ZYCORE_EXPORT ZYCORE_DEPRECATED 30 | #endif 31 | 32 | #ifndef ZYCORE_DEPRECATED_NO_EXPORT 33 | # define ZYCORE_DEPRECATED_NO_EXPORT ZYCORE_NO_EXPORT ZYCORE_DEPRECATED 34 | #endif 35 | 36 | #if 0 /* DEFINE_NO_DEPRECATED */ 37 | # ifndef ZYCORE_NO_DEPRECATED 38 | # define ZYCORE_NO_DEPRECATED 39 | # endif 40 | #endif 41 | 42 | #endif /* ZYCORE_EXPORT_H */ 43 | -------------------------------------------------------------------------------- /vendor/zycore/src/API/Process.c: -------------------------------------------------------------------------------- 1 | /*************************************************************************************************** 2 | 3 | Zyan Core Library (Zycore-C) 4 | 5 | Original Author : Florian Bernd 6 | 7 | * Permission is hereby granted, free of charge, to any person obtaining a copy 8 | * of this software and associated documentation files (the "Software"), to deal 9 | * in the Software without restriction, including without limitation the rights 10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | * copies of the Software, and to permit persons to whom the Software is 12 | * furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in all 15 | * copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | * SOFTWARE. 24 | 25 | ***************************************************************************************************/ 26 | 27 | #include 28 | #if defined(ZYAN_WINDOWS) 29 | # include 30 | #elif defined(ZYAN_POSIX) 31 | # include 32 | #else 33 | # error "Unsupported platform detected" 34 | #endif 35 | #include 36 | 37 | /* ============================================================================================== */ 38 | /* Exported functions */ 39 | /* ============================================================================================== */ 40 | 41 | /* ---------------------------------------------------------------------------------------------- */ 42 | /* General */ 43 | /* ---------------------------------------------------------------------------------------------- */ 44 | 45 | ZyanStatus ZyanProcessFlushInstructionCache(void* address, ZyanUSize size) 46 | { 47 | #if defined(ZYAN_WINDOWS) 48 | 49 | if (!FlushInstructionCache(GetCurrentProcess(), address, size)) 50 | { 51 | return ZYAN_STATUS_BAD_SYSTEMCALL; 52 | } 53 | 54 | #elif defined(ZYAN_POSIX) 55 | 56 | if (msync(address, size, MS_SYNC | MS_INVALIDATE)) 57 | { 58 | return ZYAN_STATUS_BAD_SYSTEMCALL; 59 | } 60 | 61 | #endif 62 | 63 | return ZYAN_STATUS_SUCCESS; 64 | } 65 | 66 | /* ---------------------------------------------------------------------------------------------- */ 67 | 68 | /* ============================================================================================== */ 69 | -------------------------------------------------------------------------------- /vendor/zycore/src/Zycore.c: -------------------------------------------------------------------------------- 1 | /*************************************************************************************************** 2 | 3 | Zyan Core Library (Zycore-C) 4 | 5 | Original Author : Florian Bernd 6 | 7 | * Permission is hereby granted, free of charge, to any person obtaining a copy 8 | * of this software and associated documentation files (the "Software"), to deal 9 | * in the Software without restriction, including without limitation the rights 10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | * copies of the Software, and to permit persons to whom the Software is 12 | * furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in all 15 | * copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | * SOFTWARE. 24 | 25 | ***************************************************************************************************/ 26 | 27 | #include 28 | 29 | /* ============================================================================================== */ 30 | /* Exported functions */ 31 | /* ============================================================================================== */ 32 | 33 | ZyanU64 ZycoreGetVersion(void) 34 | { 35 | return ZYCORE_VERSION; 36 | } 37 | 38 | /* ============================================================================================== */ 39 | -------------------------------------------------------------------------------- /vendor/zydis/include/Zydis/Generated/EnumISAExt.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Defines the `ZydisISAExt` enum. 3 | */ 4 | typedef enum ZydisISAExt_ 5 | { 6 | ZYDIS_ISA_EXT_INVALID, 7 | ZYDIS_ISA_EXT_ADOX_ADCX, 8 | ZYDIS_ISA_EXT_AES, 9 | ZYDIS_ISA_EXT_AMD3DNOW, 10 | ZYDIS_ISA_EXT_AMD3DNOW_PREFETCH, 11 | ZYDIS_ISA_EXT_AMD_INVLPGB, 12 | ZYDIS_ISA_EXT_AMX_BF16, 13 | ZYDIS_ISA_EXT_AMX_INT8, 14 | ZYDIS_ISA_EXT_AMX_TILE, 15 | ZYDIS_ISA_EXT_AVX, 16 | ZYDIS_ISA_EXT_AVX2, 17 | ZYDIS_ISA_EXT_AVX2GATHER, 18 | ZYDIS_ISA_EXT_AVX512EVEX, 19 | ZYDIS_ISA_EXT_AVX512VEX, 20 | ZYDIS_ISA_EXT_AVXAES, 21 | ZYDIS_ISA_EXT_BASE, 22 | ZYDIS_ISA_EXT_BMI1, 23 | ZYDIS_ISA_EXT_BMI2, 24 | ZYDIS_ISA_EXT_CET, 25 | ZYDIS_ISA_EXT_CLDEMOTE, 26 | ZYDIS_ISA_EXT_CLFLUSHOPT, 27 | ZYDIS_ISA_EXT_CLFSH, 28 | ZYDIS_ISA_EXT_CLWB, 29 | ZYDIS_ISA_EXT_CLZERO, 30 | ZYDIS_ISA_EXT_ENQCMD, 31 | ZYDIS_ISA_EXT_F16C, 32 | ZYDIS_ISA_EXT_FMA, 33 | ZYDIS_ISA_EXT_FMA4, 34 | ZYDIS_ISA_EXT_GFNI, 35 | ZYDIS_ISA_EXT_INVPCID, 36 | ZYDIS_ISA_EXT_KNC, 37 | ZYDIS_ISA_EXT_KNCE, 38 | ZYDIS_ISA_EXT_KNCV, 39 | ZYDIS_ISA_EXT_LONGMODE, 40 | ZYDIS_ISA_EXT_LZCNT, 41 | ZYDIS_ISA_EXT_MCOMMIT, 42 | ZYDIS_ISA_EXT_MMX, 43 | ZYDIS_ISA_EXT_MONITOR, 44 | ZYDIS_ISA_EXT_MONITORX, 45 | ZYDIS_ISA_EXT_MOVBE, 46 | ZYDIS_ISA_EXT_MOVDIR, 47 | ZYDIS_ISA_EXT_MPX, 48 | ZYDIS_ISA_EXT_PADLOCK, 49 | ZYDIS_ISA_EXT_PAUSE, 50 | ZYDIS_ISA_EXT_PCLMULQDQ, 51 | ZYDIS_ISA_EXT_PCONFIG, 52 | ZYDIS_ISA_EXT_PKU, 53 | ZYDIS_ISA_EXT_PREFETCHWT1, 54 | ZYDIS_ISA_EXT_PT, 55 | ZYDIS_ISA_EXT_RDPID, 56 | ZYDIS_ISA_EXT_RDPRU, 57 | ZYDIS_ISA_EXT_RDRAND, 58 | ZYDIS_ISA_EXT_RDSEED, 59 | ZYDIS_ISA_EXT_RDTSCP, 60 | ZYDIS_ISA_EXT_RDWRFSGS, 61 | ZYDIS_ISA_EXT_RTM, 62 | ZYDIS_ISA_EXT_SERIALIZE, 63 | ZYDIS_ISA_EXT_SGX, 64 | ZYDIS_ISA_EXT_SGX_ENCLV, 65 | ZYDIS_ISA_EXT_SHA, 66 | ZYDIS_ISA_EXT_SMAP, 67 | ZYDIS_ISA_EXT_SMX, 68 | ZYDIS_ISA_EXT_SNP, 69 | ZYDIS_ISA_EXT_SSE, 70 | ZYDIS_ISA_EXT_SSE2, 71 | ZYDIS_ISA_EXT_SSE3, 72 | ZYDIS_ISA_EXT_SSE4, 73 | ZYDIS_ISA_EXT_SSE4A, 74 | ZYDIS_ISA_EXT_SSSE3, 75 | ZYDIS_ISA_EXT_SVM, 76 | ZYDIS_ISA_EXT_TBM, 77 | ZYDIS_ISA_EXT_TSX_LDTRK, 78 | ZYDIS_ISA_EXT_VAES, 79 | ZYDIS_ISA_EXT_VMFUNC, 80 | ZYDIS_ISA_EXT_VPCLMULQDQ, 81 | ZYDIS_ISA_EXT_VTX, 82 | ZYDIS_ISA_EXT_WAITPKG, 83 | ZYDIS_ISA_EXT_X87, 84 | ZYDIS_ISA_EXT_XOP, 85 | ZYDIS_ISA_EXT_XSAVE, 86 | ZYDIS_ISA_EXT_XSAVEC, 87 | ZYDIS_ISA_EXT_XSAVEOPT, 88 | ZYDIS_ISA_EXT_XSAVES, 89 | 90 | /** 91 | * Maximum value of this enum. 92 | */ 93 | ZYDIS_ISA_EXT_MAX_VALUE = ZYDIS_ISA_EXT_XSAVES, 94 | /** 95 | * The minimum number of bits required to represent all values of this enum. 96 | */ 97 | ZYDIS_ISA_EXT_REQUIRED_BITS = ZYAN_BITS_TO_REPRESENT(ZYDIS_ISA_EXT_MAX_VALUE) 98 | } ZydisISAExt; 99 | -------------------------------------------------------------------------------- /vendor/zydis/include/Zydis/Generated/EnumInstructionCategory.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Defines the `ZydisInstructionCategory` enum. 3 | */ 4 | typedef enum ZydisInstructionCategory_ 5 | { 6 | ZYDIS_CATEGORY_INVALID, 7 | ZYDIS_CATEGORY_ADOX_ADCX, 8 | ZYDIS_CATEGORY_AES, 9 | ZYDIS_CATEGORY_AMD3DNOW, 10 | ZYDIS_CATEGORY_AMX_TILE, 11 | ZYDIS_CATEGORY_AVX, 12 | ZYDIS_CATEGORY_AVX2, 13 | ZYDIS_CATEGORY_AVX2GATHER, 14 | ZYDIS_CATEGORY_AVX512, 15 | ZYDIS_CATEGORY_AVX512_4FMAPS, 16 | ZYDIS_CATEGORY_AVX512_4VNNIW, 17 | ZYDIS_CATEGORY_AVX512_BITALG, 18 | ZYDIS_CATEGORY_AVX512_VBMI, 19 | ZYDIS_CATEGORY_AVX512_VP2INTERSECT, 20 | ZYDIS_CATEGORY_BINARY, 21 | ZYDIS_CATEGORY_BITBYTE, 22 | ZYDIS_CATEGORY_BLEND, 23 | ZYDIS_CATEGORY_BMI1, 24 | ZYDIS_CATEGORY_BMI2, 25 | ZYDIS_CATEGORY_BROADCAST, 26 | ZYDIS_CATEGORY_CALL, 27 | ZYDIS_CATEGORY_CET, 28 | ZYDIS_CATEGORY_CLDEMOTE, 29 | ZYDIS_CATEGORY_CLFLUSHOPT, 30 | ZYDIS_CATEGORY_CLWB, 31 | ZYDIS_CATEGORY_CLZERO, 32 | ZYDIS_CATEGORY_CMOV, 33 | ZYDIS_CATEGORY_COMPRESS, 34 | ZYDIS_CATEGORY_COND_BR, 35 | ZYDIS_CATEGORY_CONFLICT, 36 | ZYDIS_CATEGORY_CONVERT, 37 | ZYDIS_CATEGORY_DATAXFER, 38 | ZYDIS_CATEGORY_DECIMAL, 39 | ZYDIS_CATEGORY_ENQCMD, 40 | ZYDIS_CATEGORY_EXPAND, 41 | ZYDIS_CATEGORY_FCMOV, 42 | ZYDIS_CATEGORY_FLAGOP, 43 | ZYDIS_CATEGORY_FMA4, 44 | ZYDIS_CATEGORY_GATHER, 45 | ZYDIS_CATEGORY_GFNI, 46 | ZYDIS_CATEGORY_IFMA, 47 | ZYDIS_CATEGORY_INTERRUPT, 48 | ZYDIS_CATEGORY_IO, 49 | ZYDIS_CATEGORY_IOSTRINGOP, 50 | ZYDIS_CATEGORY_KMASK, 51 | ZYDIS_CATEGORY_KNC, 52 | ZYDIS_CATEGORY_KNCMASK, 53 | ZYDIS_CATEGORY_KNCSCALAR, 54 | ZYDIS_CATEGORY_LOGICAL, 55 | ZYDIS_CATEGORY_LOGICAL_FP, 56 | ZYDIS_CATEGORY_LZCNT, 57 | ZYDIS_CATEGORY_MISC, 58 | ZYDIS_CATEGORY_MMX, 59 | ZYDIS_CATEGORY_MOVDIR, 60 | ZYDIS_CATEGORY_MPX, 61 | ZYDIS_CATEGORY_NOP, 62 | ZYDIS_CATEGORY_PADLOCK, 63 | ZYDIS_CATEGORY_PCLMULQDQ, 64 | ZYDIS_CATEGORY_PCONFIG, 65 | ZYDIS_CATEGORY_PKU, 66 | ZYDIS_CATEGORY_POP, 67 | ZYDIS_CATEGORY_PREFETCH, 68 | ZYDIS_CATEGORY_PREFETCHWT1, 69 | ZYDIS_CATEGORY_PT, 70 | ZYDIS_CATEGORY_PUSH, 71 | ZYDIS_CATEGORY_RDPID, 72 | ZYDIS_CATEGORY_RDPRU, 73 | ZYDIS_CATEGORY_RDRAND, 74 | ZYDIS_CATEGORY_RDSEED, 75 | ZYDIS_CATEGORY_RDWRFSGS, 76 | ZYDIS_CATEGORY_RET, 77 | ZYDIS_CATEGORY_ROTATE, 78 | ZYDIS_CATEGORY_SCATTER, 79 | ZYDIS_CATEGORY_SEGOP, 80 | ZYDIS_CATEGORY_SEMAPHORE, 81 | ZYDIS_CATEGORY_SERIALIZE, 82 | ZYDIS_CATEGORY_SETCC, 83 | ZYDIS_CATEGORY_SGX, 84 | ZYDIS_CATEGORY_SHA, 85 | ZYDIS_CATEGORY_SHIFT, 86 | ZYDIS_CATEGORY_SMAP, 87 | ZYDIS_CATEGORY_SSE, 88 | ZYDIS_CATEGORY_STRINGOP, 89 | ZYDIS_CATEGORY_STTNI, 90 | ZYDIS_CATEGORY_SYSCALL, 91 | ZYDIS_CATEGORY_SYSRET, 92 | ZYDIS_CATEGORY_SYSTEM, 93 | ZYDIS_CATEGORY_TBM, 94 | ZYDIS_CATEGORY_TSX_LDTRK, 95 | ZYDIS_CATEGORY_UFMA, 96 | ZYDIS_CATEGORY_UNCOND_BR, 97 | ZYDIS_CATEGORY_VAES, 98 | ZYDIS_CATEGORY_VBMI2, 99 | ZYDIS_CATEGORY_VFMA, 100 | ZYDIS_CATEGORY_VPCLMULQDQ, 101 | ZYDIS_CATEGORY_VTX, 102 | ZYDIS_CATEGORY_WAITPKG, 103 | ZYDIS_CATEGORY_WIDENOP, 104 | ZYDIS_CATEGORY_X87_ALU, 105 | ZYDIS_CATEGORY_XOP, 106 | ZYDIS_CATEGORY_XSAVE, 107 | ZYDIS_CATEGORY_XSAVEOPT, 108 | 109 | /** 110 | * Maximum value of this enum. 111 | */ 112 | ZYDIS_CATEGORY_MAX_VALUE = ZYDIS_CATEGORY_XSAVEOPT, 113 | /** 114 | * The minimum number of bits required to represent all values of this enum. 115 | */ 116 | ZYDIS_CATEGORY_REQUIRED_BITS = ZYAN_BITS_TO_REPRESENT(ZYDIS_CATEGORY_MAX_VALUE) 117 | } ZydisInstructionCategory; 118 | -------------------------------------------------------------------------------- /vendor/zydis/include/Zydis/MetaInfo.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************************************** 2 | 3 | Zyan Disassembler Library (Zydis) 4 | 5 | Original Author : Florian Bernd 6 | 7 | * Permission is hereby granted, free of charge, to any person obtaining a copy 8 | * of this software and associated documentation files (the "Software"), to deal 9 | * in the Software without restriction, including without limitation the rights 10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | * copies of the Software, and to permit persons to whom the Software is 12 | * furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in all 15 | * copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | * SOFTWARE. 24 | 25 | ***************************************************************************************************/ 26 | 27 | /** 28 | * @file 29 | * @brief 30 | */ 31 | 32 | #ifndef ZYDIS_METAINFO_H 33 | #define ZYDIS_METAINFO_H 34 | 35 | #include 36 | #include 37 | #include 38 | 39 | #ifdef __cplusplus 40 | extern "C" { 41 | #endif 42 | 43 | /* ============================================================================================== */ 44 | /* Enums and types */ 45 | /* ============================================================================================== */ 46 | 47 | #include 48 | #include 49 | #include 50 | 51 | /* ============================================================================================== */ 52 | /* Exported functions */ 53 | /* ============================================================================================== */ 54 | 55 | /** 56 | * Returns the specified instruction category string. 57 | * 58 | * @param category The instruction category. 59 | * 60 | * @return The instruction category string or `ZYAN_NULL`, if an invalid category was passed. 61 | */ 62 | ZYDIS_EXPORT const char* ZydisCategoryGetString(ZydisInstructionCategory category); 63 | 64 | /** 65 | * Returns the specified isa-set string. 66 | * 67 | * @param isa_set The isa-set. 68 | * 69 | * @return The isa-set string or `ZYAN_NULL`, if an invalid isa-set was passed. 70 | */ 71 | ZYDIS_EXPORT const char* ZydisISASetGetString(ZydisISASet isa_set); 72 | 73 | /** 74 | * Returns the specified isa-extension string. 75 | * 76 | * @param isa_ext The isa-extension. 77 | * 78 | * @return The isa-extension string or `ZYAN_NULL`, if an invalid isa-extension was passed. 79 | */ 80 | ZYDIS_EXPORT const char* ZydisISAExtGetString(ZydisISAExt isa_ext); 81 | 82 | /* ============================================================================================== */ 83 | 84 | #ifdef __cplusplus 85 | } 86 | #endif 87 | 88 | #endif /* ZYDIS_METAINFO_H */ 89 | -------------------------------------------------------------------------------- /vendor/zydis/include/Zydis/Mnemonic.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************************************** 2 | 3 | Zyan Disassembler Library (Zydis) 4 | 5 | Original Author : Florian Bernd 6 | 7 | * Permission is hereby granted, free of charge, to any person obtaining a copy 8 | * of this software and associated documentation files (the "Software"), to deal 9 | * in the Software without restriction, including without limitation the rights 10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | * copies of the Software, and to permit persons to whom the Software is 12 | * furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in all 15 | * copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | * SOFTWARE. 24 | 25 | ***************************************************************************************************/ 26 | 27 | /** 28 | * @file 29 | * Mnemonic constant definitions and helper functions. 30 | */ 31 | 32 | #ifndef ZYDIS_MNEMONIC_H 33 | #define ZYDIS_MNEMONIC_H 34 | 35 | #include 36 | #include 37 | 38 | #ifdef __cplusplus 39 | extern "C" { 40 | #endif 41 | 42 | /* ============================================================================================== */ 43 | /* Enums and types */ 44 | /* ============================================================================================== */ 45 | 46 | #include 47 | 48 | /* ============================================================================================== */ 49 | /* Exported functions */ 50 | /* ============================================================================================== */ 51 | 52 | /** 53 | * @addtogroup mnemonic Mnemonic 54 | * Functions for retrieving mnemonic names. 55 | * @{ 56 | */ 57 | 58 | /** 59 | * Returns the specified instruction mnemonic string. 60 | * 61 | * @param mnemonic The mnemonic. 62 | * 63 | * @return The instruction mnemonic string or `ZYAN_NULL`, if an invalid mnemonic was passed. 64 | */ 65 | ZYDIS_EXPORT const char* ZydisMnemonicGetString(ZydisMnemonic mnemonic); 66 | 67 | /** 68 | * Returns the specified instruction mnemonic as `ZydisShortString`. 69 | * 70 | * @param mnemonic The mnemonic. 71 | * 72 | * @return The instruction mnemonic string or `ZYAN_NULL`, if an invalid mnemonic was passed. 73 | * 74 | * The `buffer` of the returned struct is guaranteed to be zero-terminated in this special case. 75 | */ 76 | ZYDIS_EXPORT const ZydisShortString* ZydisMnemonicGetStringWrapped(ZydisMnemonic mnemonic); 77 | 78 | /** 79 | * @} 80 | */ 81 | 82 | /* ============================================================================================== */ 83 | 84 | #ifdef __cplusplus 85 | } 86 | #endif 87 | 88 | #endif /* ZYDIS_MNEMONIC_H */ 89 | -------------------------------------------------------------------------------- /vendor/zydis/include/Zydis/ShortString.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************************************** 2 | 3 | Zyan Disassembler Library (Zydis) 4 | 5 | Original Author : Florian Bernd 6 | 7 | * Permission is hereby granted, free of charge, to any person obtaining a copy 8 | * of this software and associated documentation files (the "Software"), to deal 9 | * in the Software without restriction, including without limitation the rights 10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | * copies of the Software, and to permit persons to whom the Software is 12 | * furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in all 15 | * copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | * SOFTWARE. 24 | 25 | ***************************************************************************************************/ 26 | 27 | /** 28 | * @file 29 | * Defines the immutable and storage-efficient `ZydisShortString` struct, which 30 | * is used to store strings in the generated tables. 31 | */ 32 | 33 | #ifndef ZYDIS_SHORTSTRING_H 34 | #define ZYDIS_SHORTSTRING_H 35 | 36 | #include 37 | #include 38 | #include 39 | 40 | #ifdef __cplusplus 41 | extern "C" { 42 | #endif 43 | 44 | /* ============================================================================================== */ 45 | /* Enums and types */ 46 | /* ============================================================================================== */ 47 | 48 | #pragma pack(push, 1) 49 | 50 | /** 51 | * Defines the `ZydisShortString` struct. 52 | * 53 | * This compact struct is mainly used for internal string-tables to save up some bytes. 54 | * 55 | * All fields in this struct should be considered as "private". Any changes may lead to unexpected 56 | * behavior. 57 | */ 58 | typedef struct ZydisShortString_ 59 | { 60 | /** 61 | * The buffer that contains the actual (null-terminated) string. 62 | */ 63 | const char* data; 64 | /** 65 | * The length (number of characters) of the string (without 0-termination). 66 | */ 67 | ZyanU8 size; 68 | } ZydisShortString; 69 | 70 | #pragma pack(pop) 71 | 72 | /* ============================================================================================== */ 73 | /* Macros */ 74 | /* ============================================================================================== */ 75 | 76 | /** 77 | * Declares a `ZydisShortString` from a static C-style string. 78 | * 79 | * @param string The C-string constant. 80 | */ 81 | #define ZYDIS_MAKE_SHORTSTRING(string) \ 82 | { string, sizeof(string) - 1 } 83 | 84 | /* ============================================================================================== */ 85 | 86 | #ifdef __cplusplus 87 | } 88 | #endif 89 | 90 | #endif /* ZYDIS_SHORTSTRING_H */ 91 | -------------------------------------------------------------------------------- /vendor/zydis/include/ZydisExportConfig.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef ZYDIS_EXPORT_H 3 | #define ZYDIS_EXPORT_H 4 | 5 | #ifdef ZYDIS_STATIC_DEFINE 6 | # define ZYDIS_EXPORT 7 | # define ZYDIS_NO_EXPORT 8 | #else 9 | # ifndef ZYDIS_EXPORT 10 | # ifdef Zydis_EXPORTS 11 | /* We are building this library */ 12 | # define ZYDIS_EXPORT __declspec(dllexport) 13 | # else 14 | /* We are using this library */ 15 | # define ZYDIS_EXPORT __declspec(dllimport) 16 | # endif 17 | # endif 18 | 19 | # ifndef ZYDIS_NO_EXPORT 20 | # define ZYDIS_NO_EXPORT 21 | # endif 22 | #endif 23 | 24 | #ifndef ZYDIS_DEPRECATED 25 | # define ZYDIS_DEPRECATED __declspec(deprecated) 26 | #endif 27 | 28 | #ifndef ZYDIS_DEPRECATED_EXPORT 29 | # define ZYDIS_DEPRECATED_EXPORT ZYDIS_EXPORT ZYDIS_DEPRECATED 30 | #endif 31 | 32 | #ifndef ZYDIS_DEPRECATED_NO_EXPORT 33 | # define ZYDIS_DEPRECATED_NO_EXPORT ZYDIS_NO_EXPORT ZYDIS_DEPRECATED 34 | #endif 35 | 36 | #if 0 /* DEFINE_NO_DEPRECATED */ 37 | # ifndef ZYDIS_NO_DEPRECATED 38 | # define ZYDIS_NO_DEPRECATED 39 | # endif 40 | #endif 41 | 42 | #endif /* ZYDIS_EXPORT_H */ 43 | -------------------------------------------------------------------------------- /vendor/zydis/lib/ReleaseX64/Zycore.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mike1k/VMPImportFixer/b6fef34b90669933425f24e8204ff2cb52128fb6/vendor/zydis/lib/ReleaseX64/Zycore.lib -------------------------------------------------------------------------------- /vendor/zydis/lib/ReleaseX64/Zydis.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mike1k/VMPImportFixer/b6fef34b90669933425f24e8204ff2cb52128fb6/vendor/zydis/lib/ReleaseX64/Zydis.lib -------------------------------------------------------------------------------- /vendor/zydis/lib/ReleaseX86/Zycore.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mike1k/VMPImportFixer/b6fef34b90669933425f24e8204ff2cb52128fb6/vendor/zydis/lib/ReleaseX86/Zycore.lib -------------------------------------------------------------------------------- /vendor/zydis/lib/ReleaseX86/Zydis.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mike1k/VMPImportFixer/b6fef34b90669933425f24e8204ff2cb52128fb6/vendor/zydis/lib/ReleaseX86/Zydis.lib -------------------------------------------------------------------------------- /vendor/zydis/src/Generated/EnumISAExt.inc: -------------------------------------------------------------------------------- 1 | static const char* STR_ISAEXT[] = 2 | { 3 | "INVALID", 4 | "ADOX_ADCX", 5 | "AES", 6 | "AMD3DNOW", 7 | "AMD3DNOW_PREFETCH", 8 | "AMD_INVLPGB", 9 | "AMX_BF16", 10 | "AMX_INT8", 11 | "AMX_TILE", 12 | "AVX", 13 | "AVX2", 14 | "AVX2GATHER", 15 | "AVX512EVEX", 16 | "AVX512VEX", 17 | "AVXAES", 18 | "BASE", 19 | "BMI1", 20 | "BMI2", 21 | "CET", 22 | "CLDEMOTE", 23 | "CLFLUSHOPT", 24 | "CLFSH", 25 | "CLWB", 26 | "CLZERO", 27 | "ENQCMD", 28 | "F16C", 29 | "FMA", 30 | "FMA4", 31 | "GFNI", 32 | "INVPCID", 33 | "KNC", 34 | "KNCE", 35 | "KNCV", 36 | "LONGMODE", 37 | "LZCNT", 38 | "MCOMMIT", 39 | "MMX", 40 | "MONITOR", 41 | "MONITORX", 42 | "MOVBE", 43 | "MOVDIR", 44 | "MPX", 45 | "PADLOCK", 46 | "PAUSE", 47 | "PCLMULQDQ", 48 | "PCONFIG", 49 | "PKU", 50 | "PREFETCHWT1", 51 | "PT", 52 | "RDPID", 53 | "RDPRU", 54 | "RDRAND", 55 | "RDSEED", 56 | "RDTSCP", 57 | "RDWRFSGS", 58 | "RTM", 59 | "SERIALIZE", 60 | "SGX", 61 | "SGX_ENCLV", 62 | "SHA", 63 | "SMAP", 64 | "SMX", 65 | "SNP", 66 | "SSE", 67 | "SSE2", 68 | "SSE3", 69 | "SSE4", 70 | "SSE4A", 71 | "SSSE3", 72 | "SVM", 73 | "TBM", 74 | "TSX_LDTRK", 75 | "VAES", 76 | "VMFUNC", 77 | "VPCLMULQDQ", 78 | "VTX", 79 | "WAITPKG", 80 | "X87", 81 | "XOP", 82 | "XSAVE", 83 | "XSAVEC", 84 | "XSAVEOPT", 85 | "XSAVES" 86 | }; 87 | -------------------------------------------------------------------------------- /vendor/zydis/src/Generated/EnumISASet.inc: -------------------------------------------------------------------------------- 1 | static const char* STR_ISASET[] = 2 | { 3 | "INVALID", 4 | "ADOX_ADCX", 5 | "AES", 6 | "AMD", 7 | "AMD3DNOW", 8 | "AMX_BF16", 9 | "AMX_INT8", 10 | "AMX_TILE", 11 | "AVX", 12 | "AVX2", 13 | "AVX2GATHER", 14 | "AVX512BW_128", 15 | "AVX512BW_128N", 16 | "AVX512BW_256", 17 | "AVX512BW_512", 18 | "AVX512BW_KOP", 19 | "AVX512CD_128", 20 | "AVX512CD_256", 21 | "AVX512CD_512", 22 | "AVX512DQ_128", 23 | "AVX512DQ_128N", 24 | "AVX512DQ_256", 25 | "AVX512DQ_512", 26 | "AVX512DQ_KOP", 27 | "AVX512DQ_SCALAR", 28 | "AVX512ER_512", 29 | "AVX512ER_SCALAR", 30 | "AVX512F_128", 31 | "AVX512F_128N", 32 | "AVX512F_256", 33 | "AVX512F_512", 34 | "AVX512F_KOP", 35 | "AVX512F_SCALAR", 36 | "AVX512PF_512", 37 | "AVX512_4FMAPS_512", 38 | "AVX512_4FMAPS_SCALAR", 39 | "AVX512_4VNNIW_512", 40 | "AVX512_BF16_128", 41 | "AVX512_BF16_256", 42 | "AVX512_BF16_512", 43 | "AVX512_BITALG_128", 44 | "AVX512_BITALG_256", 45 | "AVX512_BITALG_512", 46 | "AVX512_GFNI_128", 47 | "AVX512_GFNI_256", 48 | "AVX512_GFNI_512", 49 | "AVX512_IFMA_128", 50 | "AVX512_IFMA_256", 51 | "AVX512_IFMA_512", 52 | "AVX512_VAES_128", 53 | "AVX512_VAES_256", 54 | "AVX512_VAES_512", 55 | "AVX512_VBMI2_128", 56 | "AVX512_VBMI2_256", 57 | "AVX512_VBMI2_512", 58 | "AVX512_VBMI_128", 59 | "AVX512_VBMI_256", 60 | "AVX512_VBMI_512", 61 | "AVX512_VNNI_128", 62 | "AVX512_VNNI_256", 63 | "AVX512_VNNI_512", 64 | "AVX512_VP2INTERSECT_128", 65 | "AVX512_VP2INTERSECT_256", 66 | "AVX512_VP2INTERSECT_512", 67 | "AVX512_VPCLMULQDQ_128", 68 | "AVX512_VPCLMULQDQ_256", 69 | "AVX512_VPCLMULQDQ_512", 70 | "AVX512_VPOPCNTDQ_128", 71 | "AVX512_VPOPCNTDQ_256", 72 | "AVX512_VPOPCNTDQ_512", 73 | "AVXAES", 74 | "AVX_GFNI", 75 | "BMI1", 76 | "BMI2", 77 | "CET", 78 | "CLDEMOTE", 79 | "CLFLUSHOPT", 80 | "CLFSH", 81 | "CLWB", 82 | "CLZERO", 83 | "CMOV", 84 | "CMPXCHG16B", 85 | "ENQCMD", 86 | "F16C", 87 | "FAT_NOP", 88 | "FCMOV", 89 | "FMA", 90 | "FMA4", 91 | "FXSAVE", 92 | "FXSAVE64", 93 | "GFNI", 94 | "I186", 95 | "I286PROTECTED", 96 | "I286REAL", 97 | "I386", 98 | "I486", 99 | "I486REAL", 100 | "I86", 101 | "INVPCID", 102 | "KNCE", 103 | "KNCJKBR", 104 | "KNCSTREAM", 105 | "KNCV", 106 | "KNC_MISC", 107 | "KNC_PF_HINT", 108 | "LAHF", 109 | "LONGMODE", 110 | "LZCNT", 111 | "MCOMMIT", 112 | "MONITOR", 113 | "MONITORX", 114 | "MOVBE", 115 | "MOVDIR", 116 | "MPX", 117 | "PADLOCK_ACE", 118 | "PADLOCK_PHE", 119 | "PADLOCK_PMM", 120 | "PADLOCK_RNG", 121 | "PAUSE", 122 | "PCLMULQDQ", 123 | "PCONFIG", 124 | "PENTIUMMMX", 125 | "PENTIUMREAL", 126 | "PKU", 127 | "POPCNT", 128 | "PPRO", 129 | "PREFETCHWT1", 130 | "PREFETCH_NOP", 131 | "PT", 132 | "RDPID", 133 | "RDPMC", 134 | "RDPRU", 135 | "RDRAND", 136 | "RDSEED", 137 | "RDTSCP", 138 | "RDWRFSGS", 139 | "RTM", 140 | "SERIALIZE", 141 | "SGX", 142 | "SGX_ENCLV", 143 | "SHA", 144 | "SMAP", 145 | "SMX", 146 | "SSE", 147 | "SSE2", 148 | "SSE2MMX", 149 | "SSE3", 150 | "SSE3X87", 151 | "SSE4", 152 | "SSE42", 153 | "SSE4A", 154 | "SSEMXCSR", 155 | "SSE_PREFETCH", 156 | "SSSE3", 157 | "SSSE3MMX", 158 | "SVM", 159 | "TBM", 160 | "TSX_LDTRK", 161 | "VAES", 162 | "VMFUNC", 163 | "VPCLMULQDQ", 164 | "VTX", 165 | "WAITPKG", 166 | "X87", 167 | "XOP", 168 | "XSAVE", 169 | "XSAVEC", 170 | "XSAVEOPT", 171 | "XSAVES" 172 | }; 173 | -------------------------------------------------------------------------------- /vendor/zydis/src/Generated/EnumInstructionCategory.inc: -------------------------------------------------------------------------------- 1 | static const char* STR_INSTRUCTIONCATEGORY[] = 2 | { 3 | "INVALID", 4 | "ADOX_ADCX", 5 | "AES", 6 | "AMD3DNOW", 7 | "AMX_TILE", 8 | "AVX", 9 | "AVX2", 10 | "AVX2GATHER", 11 | "AVX512", 12 | "AVX512_4FMAPS", 13 | "AVX512_4VNNIW", 14 | "AVX512_BITALG", 15 | "AVX512_VBMI", 16 | "AVX512_VP2INTERSECT", 17 | "BINARY", 18 | "BITBYTE", 19 | "BLEND", 20 | "BMI1", 21 | "BMI2", 22 | "BROADCAST", 23 | "CALL", 24 | "CET", 25 | "CLDEMOTE", 26 | "CLFLUSHOPT", 27 | "CLWB", 28 | "CLZERO", 29 | "CMOV", 30 | "COMPRESS", 31 | "COND_BR", 32 | "CONFLICT", 33 | "CONVERT", 34 | "DATAXFER", 35 | "DECIMAL", 36 | "ENQCMD", 37 | "EXPAND", 38 | "FCMOV", 39 | "FLAGOP", 40 | "FMA4", 41 | "GATHER", 42 | "GFNI", 43 | "IFMA", 44 | "INTERRUPT", 45 | "IO", 46 | "IOSTRINGOP", 47 | "KMASK", 48 | "KNC", 49 | "KNCMASK", 50 | "KNCSCALAR", 51 | "LOGICAL", 52 | "LOGICAL_FP", 53 | "LZCNT", 54 | "MISC", 55 | "MMX", 56 | "MOVDIR", 57 | "MPX", 58 | "NOP", 59 | "PADLOCK", 60 | "PCLMULQDQ", 61 | "PCONFIG", 62 | "PKU", 63 | "POP", 64 | "PREFETCH", 65 | "PREFETCHWT1", 66 | "PT", 67 | "PUSH", 68 | "RDPID", 69 | "RDPRU", 70 | "RDRAND", 71 | "RDSEED", 72 | "RDWRFSGS", 73 | "RET", 74 | "ROTATE", 75 | "SCATTER", 76 | "SEGOP", 77 | "SEMAPHORE", 78 | "SERIALIZE", 79 | "SETCC", 80 | "SGX", 81 | "SHA", 82 | "SHIFT", 83 | "SMAP", 84 | "SSE", 85 | "STRINGOP", 86 | "STTNI", 87 | "SYSCALL", 88 | "SYSRET", 89 | "SYSTEM", 90 | "TBM", 91 | "TSX_LDTRK", 92 | "UFMA", 93 | "UNCOND_BR", 94 | "VAES", 95 | "VBMI2", 96 | "VFMA", 97 | "VPCLMULQDQ", 98 | "VTX", 99 | "WAITPKG", 100 | "WIDENOP", 101 | "X87_ALU", 102 | "XOP", 103 | "XSAVE", 104 | "XSAVEOPT" 105 | }; 106 | -------------------------------------------------------------------------------- /vendor/zydis/src/Generated/InstructionEncodings.inc: -------------------------------------------------------------------------------- 1 | static const ZydisInstructionEncodingInfo INSTR_ENCODINGS[] = 2 | { 3 | { 0, { { 0, 0, 0 } }, { { { 0, 0, 0 }, ZYAN_FALSE, ZYAN_FALSE }, { { 0, 0, 0 }, ZYAN_FALSE, ZYAN_FALSE } } }, 4 | { ZYDIS_INSTR_ENC_FLAG_HAS_MODRM, { { 0, 0, 0 } }, { { { 0, 0, 0 }, ZYAN_FALSE, ZYAN_FALSE }, { { 0, 0, 0 }, ZYAN_FALSE, ZYAN_FALSE } } }, 5 | { ZYDIS_INSTR_ENC_FLAG_HAS_DISP, { { 16, 32, 64 } }, { { { 0, 0, 0 }, ZYAN_FALSE, ZYAN_FALSE }, { { 0, 0, 0 }, ZYAN_FALSE, ZYAN_FALSE } } }, 6 | { ZYDIS_INSTR_ENC_FLAG_HAS_IMM0, { { 0, 0, 0 } }, { { { 8, 8, 8 }, ZYAN_FALSE, ZYAN_FALSE }, { { 0, 0, 0 }, ZYAN_FALSE, ZYAN_FALSE } } }, 7 | { ZYDIS_INSTR_ENC_FLAG_HAS_IMM0, { { 0, 0, 0 } }, { { { 16, 16, 16 }, ZYAN_FALSE, ZYAN_FALSE }, { { 0, 0, 0 }, ZYAN_FALSE, ZYAN_FALSE } } }, 8 | { ZYDIS_INSTR_ENC_FLAG_HAS_IMM0, { { 0, 0, 0 } }, { { { 16, 32, 64 }, ZYAN_FALSE, ZYAN_FALSE }, { { 0, 0, 0 }, ZYAN_FALSE, ZYAN_FALSE } } }, 9 | { ZYDIS_INSTR_ENC_FLAG_HAS_IMM0, { { 0, 0, 0 } }, { { { 8, 8, 8 }, ZYAN_TRUE, ZYAN_FALSE }, { { 0, 0, 0 }, ZYAN_FALSE, ZYAN_FALSE } } }, 10 | { ZYDIS_INSTR_ENC_FLAG_HAS_IMM0, { { 0, 0, 0 } }, { { { 16, 32, 32 }, ZYAN_TRUE, ZYAN_FALSE }, { { 0, 0, 0 }, ZYAN_FALSE, ZYAN_FALSE } } }, 11 | { ZYDIS_INSTR_ENC_FLAG_HAS_IMM0, { { 0, 0, 0 } }, { { { 8, 8, 8 }, ZYAN_TRUE, ZYAN_TRUE }, { { 0, 0, 0 }, ZYAN_FALSE, ZYAN_FALSE } } }, 12 | { ZYDIS_INSTR_ENC_FLAG_HAS_IMM0, { { 0, 0, 0 } }, { { { 16, 32, 32 }, ZYAN_TRUE, ZYAN_TRUE }, { { 0, 0, 0 }, ZYAN_FALSE, ZYAN_FALSE } } }, 13 | { ZYDIS_INSTR_ENC_FLAG_HAS_IMM0, { { 0, 0, 0 } }, { { { 32, 32, 32 }, ZYAN_TRUE, ZYAN_TRUE }, { { 0, 0, 0 }, ZYAN_FALSE, ZYAN_FALSE } } }, 14 | { ZYDIS_INSTR_ENC_FLAG_HAS_MODRM | ZYDIS_INSTR_ENC_FLAG_HAS_IMM0, { { 0, 0, 0 } }, { { { 8, 8, 8 }, ZYAN_FALSE, ZYAN_FALSE }, { { 0, 0, 0 }, ZYAN_FALSE, ZYAN_FALSE } } }, 15 | { ZYDIS_INSTR_ENC_FLAG_HAS_MODRM | ZYDIS_INSTR_ENC_FLAG_HAS_IMM0, { { 0, 0, 0 } }, { { { 32, 32, 32 }, ZYAN_FALSE, ZYAN_FALSE }, { { 0, 0, 0 }, ZYAN_FALSE, ZYAN_FALSE } } }, 16 | { ZYDIS_INSTR_ENC_FLAG_HAS_MODRM | ZYDIS_INSTR_ENC_FLAG_HAS_IMM0, { { 0, 0, 0 } }, { { { 8, 8, 8 }, ZYAN_TRUE, ZYAN_FALSE }, { { 0, 0, 0 }, ZYAN_FALSE, ZYAN_FALSE } } }, 17 | { ZYDIS_INSTR_ENC_FLAG_HAS_MODRM | ZYDIS_INSTR_ENC_FLAG_HAS_IMM0, { { 0, 0, 0 } }, { { { 16, 32, 32 }, ZYAN_TRUE, ZYAN_FALSE }, { { 0, 0, 0 }, ZYAN_FALSE, ZYAN_FALSE } } }, 18 | { ZYDIS_INSTR_ENC_FLAG_HAS_MODRM | ZYDIS_INSTR_ENC_FLAG_HAS_IMM0, { { 0, 0, 0 } }, { { { 16, 32, 32 }, ZYAN_TRUE, ZYAN_TRUE }, { { 0, 0, 0 }, ZYAN_FALSE, ZYAN_FALSE } } }, 19 | { ZYDIS_INSTR_ENC_FLAG_HAS_MODRM | ZYDIS_INSTR_ENC_FLAG_FORCE_REG_FORM, { { 0, 0, 0 } }, { { { 0, 0, 0 }, ZYAN_FALSE, ZYAN_FALSE }, { { 0, 0, 0 }, ZYAN_FALSE, ZYAN_FALSE } } }, 20 | { ZYDIS_INSTR_ENC_FLAG_HAS_IMM0 | ZYDIS_INSTR_ENC_FLAG_HAS_IMM1, { { 0, 0, 0 } }, { { { 16, 16, 16 }, ZYAN_FALSE, ZYAN_FALSE }, { { 8, 8, 8 }, ZYAN_FALSE, ZYAN_FALSE } } }, 21 | { ZYDIS_INSTR_ENC_FLAG_HAS_IMM0 | ZYDIS_INSTR_ENC_FLAG_HAS_IMM1, { { 0, 0, 0 } }, { { { 16, 32, 32 }, ZYAN_TRUE, ZYAN_TRUE }, { { 16, 16, 16 }, ZYAN_FALSE, ZYAN_FALSE } } }, 22 | { ZYDIS_INSTR_ENC_FLAG_HAS_MODRM | ZYDIS_INSTR_ENC_FLAG_HAS_IMM0 | ZYDIS_INSTR_ENC_FLAG_HAS_IMM1, { { 0, 0, 0 } }, { { { 8, 8, 8 }, ZYAN_FALSE, ZYAN_FALSE }, { { 8, 8, 8 }, ZYAN_FALSE, ZYAN_FALSE } } } 23 | }; 24 | -------------------------------------------------------------------------------- /vendor/zydis/src/MetaInfo.c: -------------------------------------------------------------------------------- 1 | /*************************************************************************************************** 2 | 3 | Zyan Disassembler Library (Zydis) 4 | 5 | Original Author : Florian Bernd 6 | 7 | * Permission is hereby granted, free of charge, to any person obtaining a copy 8 | * of this software and associated documentation files (the "Software"), to deal 9 | * in the Software without restriction, including without limitation the rights 10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | * copies of the Software, and to permit persons to whom the Software is 12 | * furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in all 15 | * copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | * SOFTWARE. 24 | 25 | ***************************************************************************************************/ 26 | 27 | #include 28 | 29 | /* ============================================================================================== */ 30 | /* Enum strings */ 31 | /* ============================================================================================== */ 32 | 33 | #include 34 | #include 35 | #include 36 | 37 | /* ============================================================================================== */ 38 | /* Exported functions */ 39 | /* ============================================================================================== */ 40 | 41 | const char* ZydisCategoryGetString(ZydisInstructionCategory category) 42 | { 43 | if ((ZyanUSize)category >= ZYAN_ARRAY_LENGTH(STR_INSTRUCTIONCATEGORY)) 44 | { 45 | return ZYAN_NULL; 46 | } 47 | return STR_INSTRUCTIONCATEGORY[category]; 48 | } 49 | 50 | const char* ZydisISASetGetString(ZydisISASet isa_set) 51 | { 52 | if ((ZyanUSize)isa_set >= ZYAN_ARRAY_LENGTH(STR_ISASET)) 53 | { 54 | return ZYAN_NULL; 55 | } 56 | return STR_ISASET[isa_set]; 57 | } 58 | 59 | const char* ZydisISAExtGetString(ZydisISAExt isa_ext) 60 | { 61 | if ((ZyanUSize)isa_ext >= ZYAN_ARRAY_LENGTH(STR_ISAEXT)) 62 | { 63 | return ZYAN_NULL; 64 | } 65 | return STR_ISAEXT[isa_ext]; 66 | } 67 | 68 | /* ============================================================================================== */ 69 | -------------------------------------------------------------------------------- /vendor/zydis/src/Mnemonic.c: -------------------------------------------------------------------------------- 1 | /*************************************************************************************************** 2 | 3 | Zyan Disassembler Library (Zydis) 4 | 5 | Original Author : Florian Bernd 6 | 7 | * Permission is hereby granted, free of charge, to any person obtaining a copy 8 | * of this software and associated documentation files (the "Software"), to deal 9 | * in the Software without restriction, including without limitation the rights 10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | * copies of the Software, and to permit persons to whom the Software is 12 | * furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in all 15 | * copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | * SOFTWARE. 24 | 25 | ***************************************************************************************************/ 26 | 27 | #include 28 | #include 29 | 30 | /* ============================================================================================== */ 31 | /* Exported functions */ 32 | /* ============================================================================================== */ 33 | 34 | const char* ZydisMnemonicGetString(ZydisMnemonic mnemonic) 35 | { 36 | if ((ZyanUSize)mnemonic >= ZYAN_ARRAY_LENGTH(STR_MNEMONIC)) 37 | { 38 | return ZYAN_NULL; 39 | } 40 | return (const char*)STR_MNEMONIC[mnemonic].data; 41 | } 42 | 43 | const ZydisShortString* ZydisMnemonicGetStringWrapped(ZydisMnemonic mnemonic) 44 | { 45 | if ((ZyanUSize)mnemonic >= ZYAN_ARRAY_LENGTH(STR_MNEMONIC)) 46 | { 47 | return ZYAN_NULL; 48 | } 49 | return &STR_MNEMONIC[mnemonic]; 50 | } 51 | 52 | /* ============================================================================================== */ 53 | -------------------------------------------------------------------------------- /vendor/zydis/src/Zydis.c: -------------------------------------------------------------------------------- 1 | /*************************************************************************************************** 2 | 3 | Zyan Disassembler Library (Zydis) 4 | 5 | Original Author : Florian Bernd 6 | 7 | * Permission is hereby granted, free of charge, to any person obtaining a copy 8 | * of this software and associated documentation files (the "Software"), to deal 9 | * in the Software without restriction, including without limitation the rights 10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | * copies of the Software, and to permit persons to whom the Software is 12 | * furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in all 15 | * copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | * SOFTWARE. 24 | 25 | ***************************************************************************************************/ 26 | 27 | #include 28 | 29 | /* ============================================================================================== */ 30 | /* Exported functions */ 31 | /* ============================================================================================== */ 32 | 33 | ZyanU64 ZydisGetVersion(void) 34 | { 35 | return ZYDIS_VERSION; 36 | } 37 | 38 | ZyanStatus ZydisIsFeatureEnabled(ZydisFeature feature) 39 | { 40 | switch (feature) 41 | { 42 | case ZYDIS_FEATURE_DECODER: 43 | #ifndef ZYDIS_DISABLE_DECODER 44 | return ZYAN_STATUS_TRUE; 45 | #else 46 | return ZYAN_STATUS_FALSE; 47 | #endif 48 | case ZYDIS_FEATURE_FORMATTER: 49 | #ifndef ZYDIS_DISABLE_FORMATTER 50 | return ZYAN_STATUS_TRUE; 51 | #else 52 | return ZYAN_STATUS_FALSE; 53 | #endif 54 | case ZYDIS_FEATURE_AVX512: 55 | #ifndef ZYDIS_DISABLE_AVX512 56 | return ZYAN_STATUS_TRUE; 57 | #else 58 | return ZYAN_STATUS_FALSE; 59 | #endif 60 | 61 | case ZYDIS_FEATURE_KNC: 62 | #ifndef ZYDIS_DISABLE_KNC 63 | return ZYAN_STATUS_TRUE; 64 | #else 65 | return ZYAN_STATUS_FALSE; 66 | #endif 67 | 68 | default: 69 | return ZYAN_STATUS_INVALID_ARGUMENT; 70 | } 71 | } 72 | 73 | /* ============================================================================================== */ 74 | --------------------------------------------------------------------------------