├── .clang-format
├── .gitignore
├── LICENSE
├── README.md
├── ScreenShot
└── demo.jpg
├── ShellcodeSample
├── ShellcodeSample.vcxproj
├── ShellcodeSample.vcxproj.filters
└── main.cpp
├── ThirdParty
├── xbyak
│ ├── xbyak.h
│ ├── xbyak_bin2hex.h
│ ├── xbyak_mnemonic.h
│ └── xbyak_util.h
└── zydis
│ ├── .gitattributes
│ ├── .gitignore
│ ├── .gitmodules
│ ├── CMakeLists.txt
│ ├── Doxyfile
│ ├── Doxyfile-mcss
│ ├── LICENSE
│ ├── README.md
│ ├── SECURITY.md
│ ├── assets
│ ├── amalgamate.py
│ ├── porting-guide-v3-v4.md
│ ├── screenshots
│ │ └── ZydisInfo.png
│ └── version-bump-checklist.txt
│ ├── cmake
│ └── zydis-config.cmake.in
│ ├── dependencies
│ └── zycore
│ │ ├── .gitignore
│ │ ├── CMakeLists.txt
│ │ ├── CMakeLists.txt.in
│ │ ├── LICENSE
│ │ ├── README.md
│ │ ├── cmake
│ │ ├── zyan-functions.cmake
│ │ └── zycore-config.cmake.in
│ │ ├── examples
│ │ ├── String.c
│ │ └── Vector.c
│ │ ├── 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
│ │ ├── resources
│ │ └── VersionInfo.rc
│ │ ├── 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
│ │ └── tests
│ │ ├── ArgParse.cpp
│ │ ├── String.cpp
│ │ └── Vector.cpp
│ ├── examples
│ ├── EncodeFromScratch.c
│ ├── Formatter01.c
│ ├── Formatter02.c
│ ├── Formatter03.c
│ ├── README.md
│ ├── RewriteCode.c
│ ├── ZydisPerfTest.c
│ └── ZydisWinKernel.c
│ ├── files.dox
│ ├── include
│ └── Zydis
│ │ ├── Decoder.h
│ │ ├── DecoderTypes.h
│ │ ├── Defines.h
│ │ ├── Encoder.h
│ │ ├── Formatter.h
│ │ ├── FormatterBuffer.h
│ │ ├── Generated
│ │ ├── EnumISAExt.h
│ │ ├── EnumISASet.h
│ │ ├── EnumInstructionCategory.h
│ │ ├── EnumMnemonic.h
│ │ └── EnumRegister.h
│ │ ├── Internal
│ │ ├── DecoderData.h
│ │ ├── EncoderData.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
│ ├── man
│ ├── ZydisDisasm.1.ronn
│ └── ZydisInfo.1.ronn
│ ├── msvc
│ ├── README.md
│ ├── Zydis.sln
│ ├── dependencies
│ │ └── zycore
│ │ │ ├── Zycore.vcxproj
│ │ │ └── Zycore.vcxproj.filters
│ ├── examples
│ │ ├── EncodeFromScratch.vcxproj
│ │ ├── EncodeFromScratch.vcxproj.filters
│ │ ├── Formatter01.vcxproj
│ │ ├── Formatter01.vcxproj.filters
│ │ ├── Formatter02.vcxproj
│ │ ├── Formatter02.vcxproj.filters
│ │ ├── Formatter03.vcxproj
│ │ ├── Formatter03.vcxproj.filters
│ │ ├── RewriteCode.vcxproj
│ │ ├── RewriteCode.vcxproj.filters
│ │ ├── ZydisPerfTest.vcxproj
│ │ ├── ZydisPerfTest.vcxproj.filters
│ │ ├── ZydisWinKernel.vcxproj
│ │ └── ZydisWinKernel.vcxproj.filters
│ ├── tools
│ │ ├── ZydisDisasm.vcxproj
│ │ ├── ZydisDisasm.vcxproj.filters
│ │ ├── ZydisFuzzDecoder.vcxproj
│ │ ├── ZydisFuzzDecoder.vcxproj.filters
│ │ ├── ZydisFuzzEncoder.vcxproj
│ │ ├── ZydisFuzzEncoder.vcxproj.filters
│ │ ├── ZydisFuzzReEncoding.vcxproj
│ │ ├── ZydisFuzzReEncoding.vcxproj.filters
│ │ ├── ZydisInfo.vcxproj
│ │ └── ZydisInfo.vcxproj.filters
│ └── zydis
│ │ ├── Zydis.vcxproj
│ │ └── Zydis.vcxproj.filters
│ ├── resources
│ └── VersionInfo.rc
│ ├── src
│ ├── Decoder.c
│ ├── DecoderData.c
│ ├── Encoder.c
│ ├── EncoderData.c
│ ├── Formatter.c
│ ├── FormatterATT.c
│ ├── FormatterBase.c
│ ├── FormatterBuffer.c
│ ├── FormatterIntel.c
│ ├── Generated
│ │ ├── AccessedFlags.inc
│ │ ├── DecoderTables.inc
│ │ ├── EncoderTables.inc
│ │ ├── EnumISAExt.inc
│ │ ├── EnumISASet.inc
│ │ ├── EnumInstructionCategory.inc
│ │ ├── EnumMnemonic.inc
│ │ ├── EnumRegister.inc
│ │ ├── FormatterStrings.inc
│ │ ├── InstructionDefinitions.inc
│ │ ├── InstructionEncodings.inc
│ │ ├── OperandDefinitions.inc
│ │ ├── RegisterClassLookup.inc
│ │ └── RegisterLookup.inc
│ ├── MetaInfo.c
│ ├── Mnemonic.c
│ ├── Register.c
│ ├── SharedData.c
│ ├── String.c
│ ├── Utils.c
│ └── Zydis.c
│ └── tools
│ ├── ZydisDisasm.c
│ ├── ZydisFuzzDecoder.c
│ ├── ZydisFuzzEncoder.c
│ ├── ZydisFuzzReEncoding.c
│ ├── ZydisFuzzShared.c
│ ├── ZydisFuzzShared.h
│ └── ZydisInfo.c
├── TinyDBR.sln
├── TinyDBR
├── TinyDBR.vcxproj
├── TinyDBR.vcxproj.filters
├── arch
│ └── x86
│ │ ├── reg.h
│ │ ├── x86_assembler.cpp
│ │ ├── x86_assembler.h
│ │ ├── x86_helpers.cpp
│ │ ├── x86_helpers.h
│ │ ├── x86_memory_monitor.cpp
│ │ └── x86_memory_monitor.h
├── assembler.h
├── common.cpp
├── common.h
├── instruction.h
├── memory_monitor.cpp
├── memory_monitor.h
├── tinydbr.cpp
├── tinydbr.h
├── unwind.h
└── windows
│ ├── api_helper.cpp
│ ├── api_helper.h
│ ├── dllnotify.cpp
│ ├── dllnotify.h
│ ├── executor.cpp
│ ├── executor.h
│ ├── winunwind.cpp
│ └── winunwind.h
├── Translator
├── Translator.vcxproj
├── Translator.vcxproj.filters
└── main.cpp
└── note.txt
/.clang-format:
--------------------------------------------------------------------------------
1 | BasedOnStyle: LLVM
2 |
3 | AccessModifierOffset: -4
4 | AlignConsecutiveAssignments: true
5 | AlignConsecutiveMacros: true
6 | AllowAllArgumentsOnNextLine: false
7 | AllowShortFunctionsOnASingleLine: None
8 |
9 | AlignConsecutiveDeclarations: true
10 | BinPackParameters: false
11 |
12 | AlwaysBreakTemplateDeclarations: Yes
13 | BreakBeforeBraces: Allman
14 | BreakConstructorInitializers: AfterColon
15 | BreakInheritanceList: AfterColon
16 | Cpp11BracedListStyle: false
17 | PointerAlignment: Left
18 | SpacesBeforeTrailingComments: 2
19 |
20 | UseTab: ForContinuationAndIndentation
21 | IndentWidth: 4
22 | TabWidth: 4
23 |
24 | ColumnLimit: 0
25 | SortIncludes: true
26 | IncludeBlocks: Regroup
27 | IncludeCategories:
28 | - Regex: '^"(\.\.|Platform|Emulator|Graphic|Loader|Algorithm|Util)/'
29 | Priority: 2
30 | - Regex: '^(<|"(gtest|gmock|isl|json)/)'
31 | Priority: 3
32 | - Regex: '.*'
33 | Priority: 1
34 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # TinyDBR
2 |
3 | 
4 |
5 | ## What is TinyDBR?
6 |
7 | TinyDBR is meant for tiny dynamic binary rewriter fox x86 instruction set.
8 |
9 | This is a port to the [TinyInst](https://github.com/googleprojectzero/TinyInst) by Google Project Zero team to fit my own needs.
10 |
11 | The original TinyInst works as a debuuger and the target process runs seperately as a debuggee.
12 |
13 | While TinyDBR runs inter the target process and translate instructions right there.
14 |
15 | ## How TinyDBR works?
16 |
17 | Currently, TinyDBR only support Windows and X64.
18 |
19 | Both TinyInst and TinyDBR will protect the target's code to non-executable property, then an attempt to execute the target code will raise an execute exception.
20 |
21 | But compared to TinyInst, which catch the exception and translate instructions in debug event loop of the debugger process, TinyDBR registers a VEH handler at the target process, and does all tranlation steps within the VEH handler.
22 |
23 | Other parts are almost the same as the original TinyInst.
24 |
25 | ## Memory Monitor
26 | TinyDBR ships with a memory access monitor which can monitor memory read/write with some limitations(see below).
27 |
28 | Support all SSE and AVX/AVX512 instructions including gather and scatter.
29 |
30 | Users can inherite the `MemoryCallback` class to get notified when memory access happens.
31 |
32 | See [here](https://github.com/Inori/TinyDBR/blob/master/Translator/main.cpp) for an example.
33 |
34 | ### Limitations
35 | There are some limitations due to my own usage.
36 |
37 | Basically, what I want is just to monitor heap access, code and stack access is not useful for me,
38 |
39 | besides, monitor all of that is too expensive.
40 |
41 | 1. Code memory is not supported. (e.g. call [mem])
42 | 2. Stack memory is not supported (e.g. mov rax, [rsp - 8])
43 | 3. FS and GS segment access is not supported. (e.g. mov rax, gs:[58])
44 | 4. Conditional read and write are not implemented accurately. (e.g. cmpxchg, vpgatherqd)
45 |
46 | I removed the condition, which means the callback will always be called no matter the memory referenced is really read/written or not.
47 | This reduced the complexity of the implementation.
48 |
49 | But even with this limitation, it also ensures that, before the memory read
50 | we have chance to feed the memory the target may read and, after the memory write, we always get the correct content of the target memory.
51 |
52 | ## TODO List:
53 | 1. ~~Refactory the public interface for easy usage.~~ Done.
54 | 2. Remove remote memory backup as we now have only one process.
55 | 3. ~~Support rewrite shellcode without modules.~~ Done.
56 | 4. Support rewrite multiple modules.
57 | 5. Support other platform.
58 |
59 |
60 |
--------------------------------------------------------------------------------
/ScreenShot/demo.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Inori/TinyDBR/6be0a1317c6a03d888289424a65197800299fec8/ScreenShot/demo.jpg
--------------------------------------------------------------------------------
/ShellcodeSample/ShellcodeSample.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
15 |
16 |
17 |
18 |
19 | Source Files
20 |
21 |
22 |
--------------------------------------------------------------------------------
/ShellcodeSample/main.cpp:
--------------------------------------------------------------------------------
1 | #include "tinydbr.h"
2 | #include
3 |
4 | void QuickSort(int number[25], int first, int last)
5 | {
6 | int i, j, pivot, temp;
7 |
8 | if (first < last)
9 | {
10 | pivot = first;
11 | i = first;
12 | j = last;
13 |
14 | while (i < j)
15 | {
16 | while (number[i] <= number[pivot] && i < last)
17 | i++;
18 | while (number[j] > number[pivot])
19 | j--;
20 | if (i < j)
21 | {
22 | temp = number[i];
23 | number[i] = number[j];
24 | number[j] = temp;
25 | }
26 | }
27 |
28 | temp = number[pivot];
29 | number[pivot] = number[j];
30 | number[j] = temp;
31 | QuickSort(number, first, j - 1);
32 | QuickSort(number, j + 1, last);
33 | }
34 | }
35 |
36 |
37 |
38 | void TestShellcode()
39 | {
40 | void* code = nullptr;
41 | const size_t code_size = 0x1000;
42 |
43 | do
44 | {
45 | code = VirtualAlloc(NULL, code_size, MEM_RESERVE | MEM_COMMIT, PAGE_EXECUTE_READWRITE);
46 | if (!code)
47 | {
48 | break;
49 | }
50 |
51 | int i = 0, count = 25, number[25];
52 |
53 | for (i = 0; i < count; i++)
54 | {
55 | number[i] = rand();
56 | }
57 |
58 | printf("Order before Sort: ");
59 | for (i = 0; i < count; i++)
60 | {
61 | printf(" %d", number[i]);
62 | }
63 |
64 | //QuickSort(number, 0, count - 1);
65 |
66 | // Copy function code.
67 | memcpy(code, &QuickSort, 0x256);
68 | typedef void (*FnQuickSort)(int number[25], int first, int last);
69 | FnQuickSort pfnQuickSort = (FnQuickSort)code;
70 |
71 | // Initialize TinyDBR
72 |
73 | // Give it a dummy module name.
74 | char shellcode_name[64] = { 0 };
75 | sprintf_s(shellcode_name, "shellcode_0x%X", code);
76 |
77 | // Init module info.
78 | TargetModule virtual_module = {};
79 | virtual_module.name = shellcode_name;
80 | virtual_module.is_main = true;
81 | virtual_module.is_shellcode = true;
82 | virtual_module.code_sections.push_back({ code, code_size });
83 |
84 | // Set shellcode mode to true.
85 | Options options = {};
86 | options.shellcode_mode = true;
87 |
88 | auto tinydbr = TinyDBR::GetInstance();
89 | tinydbr->Init({ virtual_module }, options);
90 |
91 | // After TinyDBR initialization, this call should
92 | // be rewrite once it get called.
93 | pfnQuickSort(number, 0, count - 1);
94 |
95 | printf("\n\n");
96 | printf("Order after Sorted: ");
97 | for (i = 0; i < count; i++)
98 | {
99 | printf(" %d", number[i]);
100 | }
101 |
102 |
103 | } while (false);
104 |
105 | if (code)
106 | {
107 | VirtualFree(code, code_size, MEM_RELEASE);
108 | }
109 | }
110 |
111 | int main(int argc, char* argv[])
112 | {
113 | TestShellcode();
114 | return 0;
115 | }
--------------------------------------------------------------------------------
/ThirdParty/zydis/.gitattributes:
--------------------------------------------------------------------------------
1 | *.inc linguist-language=C
2 |
--------------------------------------------------------------------------------
/ThirdParty/zydis/.gitignore:
--------------------------------------------------------------------------------
1 | # Created by https://www.gitignore.io/api/c,c++,cmake
2 |
3 | ### C ###
4 | # Object files
5 | *.o
6 | *.ko
7 | *.obj
8 | *.elf
9 |
10 | # Precompiled Headers
11 | *.gch
12 | *.pch
13 |
14 | # Libraries
15 | *.lib
16 | *.a
17 | *.la
18 | *.lo
19 |
20 | # Shared objects (inc. Windows DLLs)
21 | *.dll
22 | *.so
23 | *.so.*
24 | *.dylib
25 |
26 | # Executables
27 | *.exe
28 | *.out
29 | *.app
30 | *.i*86
31 | *.x86_64
32 | *.hex
33 |
34 | # Debug files
35 | *.dSYM/
36 | *.su
37 |
38 |
39 | ### C++ ###
40 | # Compiled Object files
41 | *.slo
42 | *.lo
43 | *.o
44 | *.obj
45 |
46 | # Precompiled Headers
47 | *.gch
48 | *.pch
49 |
50 | # Compiled Dynamic libraries
51 | *.so
52 | *.dylib
53 | *.dll
54 |
55 | # Fortran module files
56 | *.mod
57 |
58 | # Compiled Static libraries
59 | *.lai
60 | *.la
61 | *.a
62 | *.lib
63 |
64 | # Executables
65 | *.exe
66 | *.out
67 | *.app
68 |
69 |
70 | ### CMake ###
71 | CMakeCache.txt
72 | CMakeFiles
73 | CMakeScripts
74 | Makefile
75 | cmake_install.cmake
76 | install_manifest.txt
77 | CTestTestfile.cmake
78 |
79 |
80 | # MacOS
81 | .DS_Store
82 |
83 | build*
84 |
85 | # MSVC
86 | .vs
87 | *.vcxproj.user
88 | *.suo
89 | *.sdf
90 | *.opensdf
91 | *.VC.db
92 | *.VC.opendb
93 | msvc/**/*.user
94 | msvc/**/obj/
95 | msvc/**/bin/
96 |
97 | doc/html
98 |
99 | .vscode
100 | .idea
101 | cmake-build-debug
102 | !tests/cases/*.out
103 | *.pyc
104 | /amalgamated-dist
--------------------------------------------------------------------------------
/ThirdParty/zydis/.gitmodules:
--------------------------------------------------------------------------------
1 | [submodule "dependencies/zycore"]
2 | path = dependencies/zycore
3 | url = https://github.com/zyantific/zycore-c
4 |
--------------------------------------------------------------------------------
/ThirdParty/zydis/Doxyfile-mcss:
--------------------------------------------------------------------------------
1 | @INCLUDE = Doxyfile
2 | GENERATE_HTML = NO
3 | GENERATE_XML = YES
4 | XML_PROGRAMLISTING = NO
5 | ##!M_LINKS_NAVBAR1 = modules files
6 | ##!M_LINKS_NAVBAR2 =
7 | ##!M_FILE_TREE_EXPAND_LEVELS = 2
8 |
--------------------------------------------------------------------------------
/ThirdParty/zydis/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2014-2021 Florian Bernd
4 | Copyright (c) 2014-2021 Joel Höner
5 |
6 | Permission is hereby granted, free of charge, to any person obtaining a copy
7 | of this software and associated documentation files (the "Software"), to deal
8 | in the Software without restriction, including without limitation the rights
9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | copies of the Software, and to permit persons to whom the Software is
11 | furnished to do so, subject to the following conditions:
12 |
13 | The above copyright notice and this permission notice shall be included in all
14 | copies or substantial portions of the Software.
15 |
16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | SOFTWARE.
23 |
24 |
--------------------------------------------------------------------------------
/ThirdParty/zydis/SECURITY.md:
--------------------------------------------------------------------------------
1 | # Security Policy
2 |
3 | ## Reporting a Vulnerability
4 |
5 | Please report security issues to `joel@zyantific.com`
--------------------------------------------------------------------------------
/ThirdParty/zydis/assets/porting-guide-v3-v4.md:
--------------------------------------------------------------------------------
1 | # Porting Guide v3 -> v4
2 |
3 | ## API changes
4 |
5 | ### ZydisDecodedInstruction
6 |
7 | 1. Removed field `operands`
8 | - The `operands` array is passed to the desired decoder function as a separate argument instead
9 | 2. Added field `operand_count_visible`
10 | - Contains the number of visible (explicit and implicit) operands
11 |
12 | ### ZydisDecoder
13 |
14 | #### 1
15 |
16 | Removed:
17 |
18 | ```c
19 | ZYDIS_EXPORT ZyanStatus ZydisDecoderDecodeBuffer(const ZydisDecoder* decoder,
20 | const void* buffer, ZyanUSize length, ZydisDecodedInstruction* instruction);
21 | ```
22 |
23 | Replaced by:
24 |
25 | ```c
26 | ZYDIS_EXPORT ZyanStatus ZydisDecoderDecodeFull(const ZydisDecoder* decoder,
27 | const void* buffer, ZyanUSize length, ZydisDecodedInstruction* instruction,
28 | ZydisDecodedOperand* operands, ZyanU8 operand_count, ZydisDecodingFlags flags);
29 | ```
30 |
31 | #### 2
32 |
33 | Added:
34 |
35 | ```c
36 | ZYDIS_EXPORT ZyanStatus ZydisDecoderDecodeInstruction(const ZydisDecoder* decoder,
37 | ZydisDecoderContext* context, const void* buffer, ZyanUSize length,
38 | ZydisDecodedInstruction* instruction);
39 | ```
40 |
41 | Added:
42 |
43 | ```c
44 | ZYDIS_EXPORT ZyanStatus ZydisDecoderDecodeOperands(const ZydisDecoder* decoder,
45 | const ZydisDecoderContext* context, const ZydisDecodedInstruction* instruction,
46 | ZydisDecodedOperand* operands, ZyanU8 operand_count);
47 | ```
48 |
49 | ### General
50 |
51 | - Type renamed: `ZydisAddressWidth` -> `ZydisStackWidth`
52 | - Constants renamed: `ZYDIS_ADDRESS_WIDTH_XXX` -> `ZYDIS_STACK_WIDTH_XXX`
53 | - Enum changed: `ZydisMemoryOperandType`
54 | - Constants added: `ZYDIS_MEMOP_TYPE_VSIB`
55 | - Decoding behavior changed:
56 | - In case of vector SIB addressing memory operands, `ZYDIS_MEMOP_TYPE_VSIB` will be reported by the decoder instead of `ZYDIS_MEMOP_TYPE_MEM` (in `ZydisDecodedOperand.mem.type`)
57 | - Constants renamed:
58 | - `ZYDIS_STATIC_DEFINE` -> `ZYDIS_STATIC_BUILD`
59 | - `Zydis_EXPORTS` -> `ZYDIS_SHOULD_EXPORT`
60 |
61 | ## Changes relevant for language bindings
62 |
63 | - The `ZYDIS_ATTRIB_` defines were rebased (underlying bits were changed)
64 | - New type: `ZydisDecodingFlags`
65 | - New type: `ZydisDecoderContext`
66 |
--------------------------------------------------------------------------------
/ThirdParty/zydis/assets/screenshots/ZydisInfo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Inori/TinyDBR/6be0a1317c6a03d888289424a65197800299fec8/ThirdParty/zydis/assets/screenshots/ZydisInfo.png
--------------------------------------------------------------------------------
/ThirdParty/zydis/assets/version-bump-checklist.txt:
--------------------------------------------------------------------------------
1 | - CMakeLists (VERSION)
2 | - Doxyfile
3 | - resources/VersionInfo.rc (4 locations)
4 | - include/Zydis/Zydis.h (ZYDIS_VERSION macro)
5 | - create a tagged release of zycore
6 | - create a tagged release of zydis
7 |
--------------------------------------------------------------------------------
/ThirdParty/zydis/cmake/zydis-config.cmake.in:
--------------------------------------------------------------------------------
1 | set(zydis_VERSION @PROJECT_VERSION@)
2 |
3 | @PACKAGE_INIT@
4 |
5 | include(CMakeFindDependencyMacro)
6 | find_dependency(Zycore)
7 |
8 | include("${CMAKE_CURRENT_LIST_DIR}/zydis-targets.cmake")
9 |
10 | set_and_check(zydis_INCLUDE_DIR "${PACKAGE_PREFIX_DIR}/@CMAKE_INSTALL_INCLUDEDIR@")
11 | set_and_check(zydis_LIB_DIR "${PACKAGE_PREFIX_DIR}/@CMAKE_INSTALL_LIBDIR@")
12 |
13 | check_required_components(zydis)
14 |
--------------------------------------------------------------------------------
/ThirdParty/zydis/dependencies/zycore/.gitignore:
--------------------------------------------------------------------------------
1 | # Created by https://www.gitignore.io/api/c,c++,cmake
2 |
3 | ### C ###
4 | # Object files
5 | *.o
6 | *.ko
7 | *.obj
8 | *.elf
9 |
10 | # Precompiled Headers
11 | *.gch
12 | *.pch
13 |
14 | # Libraries
15 | *.lib
16 | *.a
17 | *.la
18 | *.lo
19 |
20 | # Shared objects (inc. Windows DLLs)
21 | *.dll
22 | *.so
23 | *.so.*
24 | *.dylib
25 |
26 | # Executables
27 | *.exe
28 | *.out
29 | *.app
30 | *.i*86
31 | *.x86_64
32 | *.hex
33 |
34 | # Debug files
35 | *.dSYM/
36 | *.su
37 |
38 |
39 | ### C++ ###
40 | # Compiled Object files
41 | *.slo
42 | *.lo
43 | *.o
44 | *.obj
45 |
46 | # Precompiled Headers
47 | *.gch
48 | *.pch
49 |
50 | # Compiled Dynamic libraries
51 | *.so
52 | *.dylib
53 | *.dll
54 |
55 | # Fortran module files
56 | *.mod
57 |
58 | # Compiled Static libraries
59 | *.lai
60 | *.la
61 | *.a
62 | *.lib
63 |
64 | # Executables
65 | *.exe
66 | *.out
67 | *.app
68 |
69 |
70 | ### CMake ###
71 | CMakeCache.txt
72 | CMakeFiles
73 | CMakeScripts
74 | Makefile
75 | cmake_install.cmake
76 | install_manifest.txt
77 | CTestTestfile.cmake
78 |
79 |
80 | # MacOS
81 | .DS_Store
82 |
83 | build*
84 |
85 | # MSVC
86 | .vs
87 | *.vcxproj.user
88 | *.suo
89 | *.sdf
90 | *.opensdf
91 | *.VC.db
92 | *.VC.opendb
93 | msvc/**/obj/
94 | msvc/**/bin/
95 |
96 | doc/html
97 |
98 | /.vscode
99 | /.idea
100 | /cmake-build-*
101 |
--------------------------------------------------------------------------------
/ThirdParty/zydis/dependencies/zycore/CMakeLists.txt.in:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 2.8.2)
2 |
3 | project(googletest-download NONE)
4 |
5 | include(ExternalProject)
6 | ExternalProject_Add(googletest
7 | GIT_REPOSITORY https://github.com/google/googletest.git
8 | GIT_TAG ee3aa831172090fd5442820f215cb04ab6062756
9 | SOURCE_DIR "${CMAKE_BINARY_DIR}/gtest/src"
10 | BINARY_DIR "${CMAKE_BINARY_DIR}/gtest/build"
11 | CONFIGURE_COMMAND ""
12 | BUILD_COMMAND ""
13 | INSTALL_COMMAND ""
14 | TEST_COMMAND ""
15 | )
16 |
--------------------------------------------------------------------------------
/ThirdParty/zydis/dependencies/zycore/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2018-2020 Florian Bernd
4 | Copyright (c) 2018-2020 Joel Höner
5 |
6 | Permission is hereby granted, free of charge, to any person obtaining a copy
7 | of this software and associated documentation files (the "Software"), to deal
8 | in the Software without restriction, including without limitation the rights
9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | copies of the Software, and to permit persons to whom the Software is
11 | furnished to do so, subject to the following conditions:
12 |
13 | The above copyright notice and this permission notice shall be included in all
14 | copies or substantial portions of the Software.
15 |
16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | SOFTWARE.
23 |
24 |
--------------------------------------------------------------------------------
/ThirdParty/zydis/dependencies/zycore/README.md:
--------------------------------------------------------------------------------
1 | # Zyan Core Library for C
2 |
3 | Internal library providing platform independent types, macros and a fallback for environments without LibC.
4 |
5 | ## Features
6 |
7 | - Platform independent types
8 | - Integer types (`ZyanU8`, `ZyanI32`, `ZyanUSize`, ...)
9 | - `ZyanBool` (+ `ZYAN_FALSE`, `ZYAN_TRUE`)
10 | - `ZYAN_NULL`
11 | - Macros
12 | - Compiler/Platform/Architecture detection
13 | - Asserts and static asserts
14 | - Utils (`ARRAY_LENGTH`, `FALLTHROUGH`, `UNUSED`, ...)
15 | - Common types
16 | - `ZyanBitset`
17 | - `ZyanString`/`ZyanStringView`
18 | - Container types
19 | - `ZyanVector`
20 | - `ZyanList`
21 | - LibC abstraction (WiP)
22 |
23 | ## License
24 |
25 | Zycore is licensed under the MIT license.
26 |
--------------------------------------------------------------------------------
/ThirdParty/zydis/dependencies/zycore/cmake/zyan-functions.cmake:
--------------------------------------------------------------------------------
1 | # =============================================================================================== #
2 | # Exported functions #
3 | # =============================================================================================== #
4 |
5 | function (zyan_set_common_flags target)
6 | if (NOT MSVC)
7 | target_compile_options("${target}" PRIVATE "-std=c99")
8 | endif ()
9 |
10 | if (ZYAN_DEV_MODE)
11 | # If in developer mode, be pedantic.
12 | if (MSVC)
13 | target_compile_options("${target}" PUBLIC "/WX" "/W4")
14 | else ()
15 | target_compile_options("${target}" PUBLIC "-Wall" "-pedantic" "-Wextra" "-Werror")
16 | endif ()
17 | endif ()
18 | endfunction ()
19 |
20 | function (zyan_set_source_group target)
21 | if (ZYAN_DEV_MODE)
22 | if (((CMAKE_MAJOR_VERSION GREATER 3) OR (CMAKE_MAJOR_VERSION EQUAL 3)) AND
23 | ((CMAKE_MINOR_VERSION GREATER 8) OR (CMAKE_MINOR_VERSION EQUAL 8)))
24 | # Mirror directory structure in project files
25 | get_property("TARGET_SOURCE_FILES" TARGET "${target}" PROPERTY SOURCES)
26 | source_group(TREE "${CMAKE_CURRENT_LIST_DIR}" FILES ${TARGET_SOURCE_FILES})
27 | endif ()
28 | endif ()
29 | endfunction ()
30 |
31 | function (zyan_maybe_enable_wpo target)
32 | if (ZYAN_WHOLE_PROGRAM_OPTIMIZATION AND MSVC)
33 | set_target_properties("${target}" PROPERTIES COMPILE_FLAGS "/GL")
34 | set_target_properties("${target}" PROPERTIES LINK_FLAGS_RELEASE "/LTCG")
35 | endif ()
36 | endfunction ()
37 |
38 | function (zyan_maybe_enable_wpo_for_lib target)
39 | if (ZYAN_WHOLE_PROGRAM_OPTIMIZATION AND MSVC)
40 | set_target_properties("${target}" PROPERTIES COMPILE_FLAGS "/GL")
41 | set_target_properties("${target}" PROPERTIES LINK_FLAGS_RELEASE "/LTCG")
42 | set_target_properties("${target}" PROPERTIES STATIC_LIBRARY_FLAGS_RELEASE "/LTCG")
43 | endif ()
44 | endfunction ()
45 |
--------------------------------------------------------------------------------
/ThirdParty/zydis/dependencies/zycore/cmake/zycore-config.cmake.in:
--------------------------------------------------------------------------------
1 | set(zycore_VERSION @PROJECT_VERSION@)
2 |
3 | @PACKAGE_INIT@
4 |
5 | include(CMakeFindDependencyMacro)
6 | if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux" AND NOT @ZYAN_NO_LIBC@)
7 | find_dependency(Threads)
8 | endif()
9 |
10 | include("${CMAKE_CURRENT_LIST_DIR}/zyan-functions.cmake")
11 |
12 | include("${CMAKE_CURRENT_LIST_DIR}/zycore-targets.cmake")
13 |
14 | set_and_check(zycore_INCLUDE_DIR "${PACKAGE_PREFIX_DIR}/@CMAKE_INSTALL_INCLUDEDIR@")
15 | set_and_check(zycore_LIB_DIR "${PACKAGE_PREFIX_DIR}/@CMAKE_INSTALL_LIBDIR@")
16 |
17 | check_required_components(zycore)
18 |
--------------------------------------------------------------------------------
/ThirdParty/zydis/dependencies/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 |
38 | #ifndef ZYAN_NO_LIBC
39 |
40 | /* ============================================================================================== */
41 | /* Enums and types */
42 | /* ============================================================================================== */
43 |
44 |
45 |
46 | /* ============================================================================================== */
47 | /* Exported functions */
48 | /* ============================================================================================== */
49 |
50 | /* ---------------------------------------------------------------------------------------------- */
51 | /* General */
52 | /* ---------------------------------------------------------------------------------------------- */
53 |
54 | /**
55 | * @brief Flushes the process instruction cache.
56 | *
57 | * @param address The address.
58 | * @param size The size.
59 | *
60 | * @return A zyan status code.
61 | */
62 | ZYCORE_EXPORT ZyanStatus ZyanProcessFlushInstructionCache(void* address, ZyanUSize size);
63 |
64 | /* ---------------------------------------------------------------------------------------------- */
65 |
66 | /* ============================================================================================== */
67 |
68 | #endif /* ZYAN_NO_LIBC */
69 |
70 | #endif /* ZYCORE_API_PROCESS_H */
71 |
--------------------------------------------------------------------------------
/ThirdParty/zydis/dependencies/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 |
--------------------------------------------------------------------------------
/ThirdParty/zydis/dependencies/zycore/include/Zycore/Zycore.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 | * Master include file, including everything else.
30 | */
31 |
32 | #ifndef ZYCORE_H
33 | #define ZYCORE_H
34 |
35 | #include
36 |
37 | // TODO:
38 |
39 | #ifdef __cplusplus
40 | extern "C" {
41 | #endif
42 |
43 | /* ============================================================================================== */
44 | /* Macros */
45 | /* ============================================================================================== */
46 |
47 | /* ---------------------------------------------------------------------------------------------- */
48 | /* Constants */
49 | /* ---------------------------------------------------------------------------------------------- */
50 |
51 | /**
52 | * A macro that defines the zycore version.
53 | */
54 | #define ZYCORE_VERSION (ZyanU64)0x0001000100000000
55 |
56 | /* ---------------------------------------------------------------------------------------------- */
57 | /* Helper macros */
58 | /* ---------------------------------------------------------------------------------------------- */
59 |
60 | /**
61 | * Extracts the major-part of the zycore version.
62 | *
63 | * @param version The zycore version value
64 | */
65 | #define ZYCORE_VERSION_MAJOR(version) (ZyanU16)((version & 0xFFFF000000000000) >> 48)
66 |
67 | /**
68 | * Extracts the minor-part of the zycore version.
69 | *
70 | * @param version The zycore version value
71 | */
72 | #define ZYCORE_VERSION_MINOR(version) (ZyanU16)((version & 0x0000FFFF00000000) >> 32)
73 |
74 | /**
75 | * Extracts the patch-part of the zycore version.
76 | *
77 | * @param version The zycore version value
78 | */
79 | #define ZYCORE_VERSION_PATCH(version) (ZyanU16)((version & 0x00000000FFFF0000) >> 16)
80 |
81 | /**
82 | * Extracts the build-part of the zycore version.
83 | *
84 | * @param version The zycore version value
85 | */
86 | #define ZYCORE_VERSION_BUILD(version) (ZyanU16)(version & 0x000000000000FFFF)
87 |
88 | /* ---------------------------------------------------------------------------------------------- */
89 |
90 | /* ============================================================================================== */
91 | /* Exported functions */
92 | /* ============================================================================================== */
93 |
94 | /**
95 | * Returns the zycore version.
96 | *
97 | * @return The zycore version.
98 | *
99 | * Use the macros provided in this file to extract the major, minor, patch and build part from the
100 | * returned version value.
101 | */
102 | ZYCORE_EXPORT ZyanU64 ZycoreGetVersion(void);
103 |
104 | /* ============================================================================================== */
105 |
106 | #ifdef __cplusplus
107 | }
108 | #endif
109 |
110 | #endif /* ZYCORE_H */
111 |
--------------------------------------------------------------------------------
/ThirdParty/zydis/dependencies/zycore/resources/VersionInfo.rc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Inori/TinyDBR/6be0a1317c6a03d888289424a65197800299fec8/ThirdParty/zydis/dependencies/zycore/resources/VersionInfo.rc
--------------------------------------------------------------------------------
/ThirdParty/zydis/dependencies/zycore/src/API/Memory.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 | #ifndef ZYAN_NO_LIBC
30 |
31 | #if defined(ZYAN_WINDOWS)
32 |
33 | #elif defined(ZYAN_POSIX)
34 | # include
35 | #else
36 | # error "Unsupported platform detected"
37 | #endif
38 |
39 | /* ============================================================================================== */
40 | /* Exported functions */
41 | /* ============================================================================================== */
42 |
43 | /* ---------------------------------------------------------------------------------------------- */
44 | /* General */
45 | /* ---------------------------------------------------------------------------------------------- */
46 |
47 | ZyanU32 ZyanMemoryGetSystemPageSize()
48 | {
49 | #if defined(ZYAN_WINDOWS)
50 |
51 | SYSTEM_INFO system_info;
52 | GetSystemInfo(&system_info);
53 |
54 | return system_info.dwPageSize;
55 |
56 | #elif defined(ZYAN_POSIX)
57 |
58 | return sysconf(_SC_PAGE_SIZE);
59 |
60 | #endif
61 | }
62 |
63 | ZyanU32 ZyanMemoryGetSystemAllocationGranularity()
64 | {
65 | #if defined(ZYAN_WINDOWS)
66 |
67 | SYSTEM_INFO system_info;
68 | GetSystemInfo(&system_info);
69 |
70 | return system_info.dwAllocationGranularity;
71 |
72 | #elif defined(ZYAN_POSIX)
73 |
74 | return sysconf(_SC_PAGE_SIZE);
75 |
76 | #endif
77 | }
78 |
79 | /* ---------------------------------------------------------------------------------------------- */
80 | /* Memory management */
81 | /* ---------------------------------------------------------------------------------------------- */
82 |
83 | ZyanStatus ZyanMemoryVirtualProtect(void* address, ZyanUSize size,
84 | ZyanMemoryPageProtection protection)
85 | {
86 | #if defined(ZYAN_WINDOWS)
87 |
88 | DWORD old;
89 | if (!VirtualProtect(address, size, protection, &old))
90 | {
91 | return ZYAN_STATUS_BAD_SYSTEMCALL;
92 | }
93 |
94 | #elif defined(ZYAN_POSIX)
95 |
96 | if (mprotect(address, size, protection))
97 | {
98 | return ZYAN_STATUS_BAD_SYSTEMCALL;
99 | }
100 |
101 | #endif
102 |
103 | return ZYAN_STATUS_SUCCESS;
104 | }
105 |
106 | ZyanStatus ZyanMemoryVirtualFree(void* address, ZyanUSize size)
107 | {
108 | #if defined(ZYAN_WINDOWS)
109 |
110 | ZYAN_UNUSED(size);
111 | if (!VirtualFree(address, 0, MEM_RELEASE))
112 | {
113 | return ZYAN_STATUS_BAD_SYSTEMCALL;
114 | }
115 |
116 | #elif defined(ZYAN_POSIX)
117 |
118 | if (munmap(address, size))
119 | {
120 | return ZYAN_STATUS_BAD_SYSTEMCALL;
121 | }
122 |
123 | #endif
124 |
125 | return ZYAN_STATUS_SUCCESS;
126 | }
127 |
128 | /* ---------------------------------------------------------------------------------------------- */
129 |
130 | /* ============================================================================================== */
131 |
132 | #endif /* ZYAN_NO_LIBC */
133 |
--------------------------------------------------------------------------------
/ThirdParty/zydis/dependencies/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 | #if defined(ZYAN_KERNEL)
30 | # include
31 | #else
32 | # include
33 | #endif
34 | #elif defined(ZYAN_POSIX)
35 | # include
36 | #else
37 | # error "Unsupported platform detected"
38 | #endif
39 | #include
40 |
41 | #ifndef ZYAN_NO_LIBC
42 |
43 | /* ============================================================================================== */
44 | /* Exported functions */
45 | /* ============================================================================================== */
46 |
47 | /* ---------------------------------------------------------------------------------------------- */
48 | /* General */
49 | /* ---------------------------------------------------------------------------------------------- */
50 |
51 | ZyanStatus ZyanProcessFlushInstructionCache(void* address, ZyanUSize size)
52 | {
53 | #if defined(ZYAN_WINDOWS)
54 |
55 | if (!FlushInstructionCache(GetCurrentProcess(), address, size))
56 | {
57 | return ZYAN_STATUS_BAD_SYSTEMCALL;
58 | }
59 |
60 | #elif defined(ZYAN_POSIX)
61 |
62 | if (msync(address, size, MS_SYNC | MS_INVALIDATE))
63 | {
64 | return ZYAN_STATUS_BAD_SYSTEMCALL;
65 | }
66 |
67 | #endif
68 |
69 | return ZYAN_STATUS_SUCCESS;
70 | }
71 |
72 | /* ---------------------------------------------------------------------------------------------- */
73 |
74 | /* ============================================================================================== */
75 |
76 | #endif /* ZYAN_NO_LIBC */
77 |
--------------------------------------------------------------------------------
/ThirdParty/zydis/dependencies/zycore/src/API/Terminal.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 | #ifndef ZYAN_NO_LIBC
30 |
31 | #if defined(ZYAN_POSIX)
32 | # include
33 | #elif defined(ZYAN_WINDOWS)
34 | # include
35 | # include
36 | #else
37 | # error "Unsupported platform detected"
38 | #endif
39 |
40 | // Provide fallback for old SDK versions
41 | #ifdef ZYAN_WINDOWS
42 | # ifndef ENABLE_VIRTUAL_TERMINAL_PROCESSING
43 | # define ENABLE_VIRTUAL_TERMINAL_PROCESSING 0x0004
44 | # endif
45 | #endif
46 |
47 | /* ============================================================================================== */
48 | /* Exported functions */
49 | /* ============================================================================================== */
50 |
51 | ZyanStatus ZyanTerminalEnableVT100(ZyanStandardStream stream)
52 | {
53 | if ((stream != ZYAN_STDSTREAM_OUT) && (stream != ZYAN_STDSTREAM_ERR))
54 | {
55 | return ZYAN_STATUS_INVALID_ARGUMENT;
56 | }
57 |
58 | #ifdef ZYAN_WINDOWS
59 | // Get file descriptor
60 | int file;
61 | switch (stream)
62 | {
63 | case ZYAN_STDSTREAM_OUT:
64 | file = _fileno(ZYAN_STDOUT);
65 | break;
66 | case ZYAN_STDSTREAM_ERR:
67 | file = _fileno(ZYAN_STDERR);
68 | break;
69 | default:
70 | ZYAN_UNREACHABLE;
71 | }
72 | if (file < 0)
73 | {
74 | return ZYAN_STATUS_INVALID_ARGUMENT;
75 | }
76 |
77 | HANDLE const handle = (HANDLE)_get_osfhandle(file);
78 | if (handle == INVALID_HANDLE_VALUE)
79 | {
80 | return ZYAN_STATUS_INVALID_ARGUMENT;
81 | }
82 |
83 | DWORD mode;
84 | if (!GetConsoleMode(handle, &mode))
85 | {
86 | // The given standard stream is not bound to a terminal
87 | return ZYAN_STATUS_INVALID_ARGUMENT;
88 | }
89 |
90 | mode |= ENABLE_VIRTUAL_TERMINAL_PROCESSING;
91 | if (!SetConsoleMode(handle, mode))
92 | {
93 | return ZYAN_STATUS_BAD_SYSTEMCALL;
94 | }
95 | #endif
96 |
97 | return ZYAN_STATUS_SUCCESS;
98 | }
99 |
100 | ZyanStatus ZyanTerminalIsTTY(ZyanStandardStream stream)
101 | {
102 | // Get file descriptor
103 | int file;
104 | #ifdef ZYAN_WINDOWS
105 | switch (stream)
106 | {
107 | case ZYAN_STDSTREAM_IN:
108 | file = _fileno(ZYAN_STDIN);
109 | break;
110 | case ZYAN_STDSTREAM_OUT:
111 | file = _fileno(ZYAN_STDOUT);
112 | break;
113 | case ZYAN_STDSTREAM_ERR:
114 | file = _fileno(ZYAN_STDERR);
115 | break;
116 | default:
117 | ZYAN_UNREACHABLE;
118 | }
119 | if (file < 0)
120 | {
121 | return ZYAN_STATUS_INVALID_ARGUMENT;
122 | }
123 | #else
124 | switch (stream)
125 | {
126 | case ZYAN_STDSTREAM_IN:
127 | file = STDIN_FILENO;
128 | break;
129 | case ZYAN_STDSTREAM_OUT:
130 | file = STDOUT_FILENO;
131 | break;
132 | case ZYAN_STDSTREAM_ERR:
133 | file = STDERR_FILENO;
134 | break;
135 | default:
136 | ZYAN_UNREACHABLE;
137 | }
138 | #endif
139 |
140 | #ifdef ZYAN_WINDOWS
141 | if (_isatty(file))
142 | #else
143 | if ( isatty(file))
144 | #endif
145 | {
146 | return ZYAN_STATUS_TRUE;
147 | }
148 | if (ZYAN_ERRNO == EBADF)
149 | {
150 | // Invalid file descriptor
151 | return ZYAN_STATUS_INVALID_ARGUMENT;
152 | }
153 | //ZYAN_ASSERT((errno == EINVAL) || (errno == ENOTTY));
154 |
155 | return ZYAN_STATUS_FALSE;
156 | }
157 |
158 | /* ============================================================================================== */
159 |
160 | #endif /* ZYAN_NO_LIBC */
161 |
--------------------------------------------------------------------------------
/ThirdParty/zydis/dependencies/zycore/src/Allocator.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 | #include
29 |
30 | /* ============================================================================================== */
31 | /* Internal functions */
32 | /* ============================================================================================== */
33 |
34 | /* ---------------------------------------------------------------------------------------------- */
35 | /* Default allocator */
36 | /* ---------------------------------------------------------------------------------------------- */
37 |
38 | #ifndef ZYAN_NO_LIBC
39 |
40 | static ZyanStatus ZyanAllocatorDefaultAllocate(ZyanAllocator* allocator, void** p,
41 | ZyanUSize element_size, ZyanUSize n)
42 | {
43 | ZYAN_ASSERT(allocator);
44 | ZYAN_ASSERT(p);
45 | ZYAN_ASSERT(element_size);
46 | ZYAN_ASSERT(n);
47 |
48 | ZYAN_UNUSED(allocator);
49 |
50 | *p = ZYAN_MALLOC(element_size * n);
51 | if (!*p)
52 | {
53 | return ZYAN_STATUS_NOT_ENOUGH_MEMORY;
54 | }
55 |
56 | return ZYAN_STATUS_SUCCESS;
57 | }
58 |
59 | static ZyanStatus ZyanAllocatorDefaultReallocate(ZyanAllocator* allocator, void** p,
60 | ZyanUSize element_size, ZyanUSize n)
61 | {
62 | ZYAN_ASSERT(allocator);
63 | ZYAN_ASSERT(p);
64 | ZYAN_ASSERT(element_size);
65 | ZYAN_ASSERT(n);
66 |
67 | ZYAN_UNUSED(allocator);
68 |
69 | void* const x = ZYAN_REALLOC(*p, element_size * n);
70 | if (!x)
71 | {
72 | return ZYAN_STATUS_NOT_ENOUGH_MEMORY;
73 | }
74 | *p = x;
75 |
76 | return ZYAN_STATUS_SUCCESS;
77 | }
78 |
79 | static ZyanStatus ZyanAllocatorDefaultDeallocate(ZyanAllocator* allocator, void* p,
80 | ZyanUSize element_size, ZyanUSize n)
81 | {
82 | ZYAN_ASSERT(allocator);
83 | ZYAN_ASSERT(p);
84 | ZYAN_ASSERT(element_size);
85 | ZYAN_ASSERT(n);
86 |
87 | ZYAN_UNUSED(allocator);
88 | ZYAN_UNUSED(element_size);
89 | ZYAN_UNUSED(n);
90 |
91 | ZYAN_FREE(p);
92 |
93 | return ZYAN_STATUS_SUCCESS;
94 | }
95 |
96 | #endif // ZYAN_NO_LIBC
97 |
98 | /* ---------------------------------------------------------------------------------------------- */
99 |
100 | /* ============================================================================================== */
101 | /* Exported functions */
102 | /* ============================================================================================== */
103 |
104 | ZyanStatus ZyanAllocatorInit(ZyanAllocator* allocator, ZyanAllocatorAllocate allocate,
105 | ZyanAllocatorAllocate reallocate, ZyanAllocatorDeallocate deallocate)
106 | {
107 | if (!allocator || !allocate || !reallocate || !deallocate)
108 | {
109 | return ZYAN_STATUS_INVALID_ARGUMENT;
110 | }
111 |
112 | allocator->allocate = allocate;
113 | allocator->reallocate = reallocate;
114 | allocator->deallocate = deallocate;
115 |
116 | return ZYAN_STATUS_SUCCESS;
117 | }
118 |
119 | #ifndef ZYAN_NO_LIBC
120 |
121 | ZyanAllocator* ZyanAllocatorDefault(void)
122 | {
123 | static ZyanAllocator allocator =
124 | {
125 | &ZyanAllocatorDefaultAllocate,
126 | &ZyanAllocatorDefaultReallocate,
127 | &ZyanAllocatorDefaultDeallocate
128 | };
129 | return &allocator;
130 | }
131 |
132 | #endif
133 |
134 | /* ============================================================================================== */
135 |
--------------------------------------------------------------------------------
/ThirdParty/zydis/dependencies/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 |
--------------------------------------------------------------------------------
/ThirdParty/zydis/dependencies/zycore/tests/String.cpp:
--------------------------------------------------------------------------------
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 Tests the `ZyanString` implementation.
30 | */
31 |
32 | #include
33 | #include
34 |
35 | /* ============================================================================================== */
36 | /* Enums and types */
37 | /* ============================================================================================== */
38 |
39 |
40 |
41 | /* ============================================================================================== */
42 | /* Helper functions */
43 | /* ============================================================================================== */
44 |
45 |
46 |
47 | /* ============================================================================================== */
48 | /* Tests */
49 | /* ============================================================================================== */
50 |
51 | /* ---------------------------------------------------------------------------------------------- */
52 | /* */
53 | /* ---------------------------------------------------------------------------------------------- */
54 |
55 |
56 |
57 | /* ---------------------------------------------------------------------------------------------- */
58 |
59 | /* ============================================================================================== */
60 | /* Entry point */
61 | /* ============================================================================================== */
62 |
63 | int main(int argc, char **argv)
64 | {
65 | ::testing::InitGoogleTest(&argc, argv);
66 | return RUN_ALL_TESTS();
67 | }
68 |
69 | /* ============================================================================================== */
70 |
--------------------------------------------------------------------------------
/ThirdParty/zydis/examples/EncodeFromScratch.c:
--------------------------------------------------------------------------------
1 | /***************************************************************************************************
2 |
3 | Zyan Disassembler Library (Zydis)
4 |
5 | Original Author : Joel Hoener
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 | *
30 | * Example on assembling a basic function returning `0x1337` in `rax`.
31 | */
32 |
33 | #include
34 | #include
35 | #include
36 |
37 | #include
38 |
39 | /* ============================================================================================== */
40 | /* Entry point */
41 | /* ============================================================================================== */
42 |
43 | static void ExpectSuccess(ZyanStatus status)
44 | {
45 | if (ZYAN_FAILED(status))
46 | {
47 | fprintf(stderr, "Something failed: 0x%08X\n", status);
48 | exit(EXIT_FAILURE);
49 | }
50 | }
51 |
52 | static void AppendInstruction(const ZydisEncoderRequest* req, ZyanU8** buffer,
53 | ZyanUSize* buffer_length)
54 | {
55 | assert(req);
56 | assert(buffer);
57 | assert(buffer_length);
58 |
59 | ZyanUSize instr_length = *buffer_length;
60 | ExpectSuccess(ZydisEncoderEncodeInstruction(req, *buffer, &instr_length));
61 | *buffer += instr_length;
62 | *buffer_length -= instr_length;
63 | }
64 |
65 | static ZyanUSize AssembleCode(ZyanU8* buffer, ZyanUSize buffer_length)
66 | {
67 | assert(buffer);
68 | assert(buffer_length);
69 |
70 | ZyanU8* write_ptr = buffer;
71 | ZyanUSize remaining_length = buffer_length;
72 |
73 | // Assemble `mov rax, 0x1337`.
74 | ZydisEncoderRequest req;
75 | memset(&req, 0, sizeof(req));
76 | req.mnemonic = ZYDIS_MNEMONIC_MOV;
77 | req.machine_mode = ZYDIS_MACHINE_MODE_LONG_64;
78 | req.operand_count = 2;
79 | req.operands[0].type = ZYDIS_OPERAND_TYPE_REGISTER;
80 | req.operands[0].reg.value = ZYDIS_REGISTER_RAX;
81 | req.operands[1].type = ZYDIS_OPERAND_TYPE_IMMEDIATE;
82 | req.operands[1].imm.u = 0x1337;
83 | AppendInstruction(&req, &write_ptr, &remaining_length);
84 |
85 | // Assemble `ret`.
86 | memset(&req, 0, sizeof(req));
87 | req.mnemonic = ZYDIS_MNEMONIC_RET;
88 | req.machine_mode = ZYDIS_MACHINE_MODE_LONG_64;
89 | AppendInstruction(&req, &write_ptr, &remaining_length);
90 |
91 | return buffer_length - remaining_length;
92 | }
93 |
94 | int main(void)
95 | {
96 | // Allocate 2 pages of memory. We won't need nearly as much, but it simplifies
97 | // re-protecting the memory to RWX later.
98 | const ZyanUSize page_size = 0x1000;
99 | const ZyanUSize alloc_size = page_size * 2;
100 | ZyanU8* buffer = malloc(alloc_size);
101 |
102 | // Assemble our function.
103 | const ZyanUSize length = AssembleCode(buffer, alloc_size);
104 |
105 | // Print a hex-dump of the assembled code.
106 | puts("Created byte-code:");
107 | for (ZyanUSize i = 0; i < length; ++i)
108 | {
109 | printf("%02X ", buffer[i]);
110 | }
111 | puts("");
112 |
113 | #ifdef ZYAN_X64
114 |
115 | // Align pointer to typical page size.
116 | void* aligned = (void*)((ZyanUPointer)buffer & ~(page_size-1));
117 |
118 | // Re-protect the heap region as RWX. Don't do this at home, kids!
119 | ExpectSuccess(ZyanMemoryVirtualProtect(aligned, alloc_size, ZYAN_PAGE_EXECUTE_READWRITE));
120 |
121 | // Create a function pointer for our buffer.
122 | typedef ZyanU64(*FnPtr)();
123 | const FnPtr func_ptr = (FnPtr)(uintptr_t)buffer;
124 |
125 | // Call the function!
126 | const ZyanU64 result = func_ptr();
127 | printf("Return value of JITed code: 0x%016" PRIx64 "\n", result);
128 |
129 | #endif
130 | }
131 |
132 | /* ============================================================================================== */
133 |
--------------------------------------------------------------------------------
/ThirdParty/zydis/examples/README.md:
--------------------------------------------------------------------------------
1 | # Zydis Examples
2 |
3 | ## Decoder
4 |
5 | We currently don't have any examples that specifically only demonstrate using the decoder, but all formatter examples also demonstrate decoding instructions. Additionally, the [`ZydisInfo.c`](../tools/ZydisInfo.c) and [`ZydisDisasm.c`](../tools/ZydisDisasm.c) examples in the [tools](../tools) directory serve as additional examples for both decoding and formatting.
6 |
7 | ## Formatter
8 |
9 | ### [Formatter01](./Formatter01.c)
10 | Demonstrates basic hooking functionality of the `ZydisFormatter` class by implementing a custom symbol-resolver.
11 |
12 | ### [Formatter02](./Formatter02.c)
13 | Demonstrates basic hooking functionality of the `ZydisFormatter` class and the ability to completely omit specific operands.
14 |
15 | The example demonstrates the hooking functionality of the `ZydisFormatter` class by rewriting the mnemonics of `(V)CMPPS` and `(V)CMPPD` to their corresponding alias-forms (based on the condition encoded in the immediate operand).
16 |
17 | ### [Formatter03](./Formatter03.c)
18 | Demonstrates the tokenizing feature of the `ZydisFormatter` class.
19 |
20 | ## Encoder
21 |
22 | ### [EncodeFromScratch](./EncodeFromScratch.c)
23 | Example assembling a basic function returning `0x1337` in `rax` from scratch.
24 |
25 | ### [RewriteCode](./RewriteCode.c)
26 | Demonstrates how to rewrite ("reassemble") instructions.
27 |
28 | ## Misc
29 |
30 | ### [ZydisWinKernel](./ZydisWinKernel.c)
31 | Implements an example Windows kernel-mode driver.
--------------------------------------------------------------------------------
/ThirdParty/zydis/files.dox:
--------------------------------------------------------------------------------
1 | /** @dir include
2 | * @brief Top-level include dir
3 | */
4 | /** @dir include/Zydis
5 | * @brief Zydis include dir
6 | */
7 | /** @dir include/Zydis/Generated
8 | * @brief Generated files
9 | */
10 | /** @dir include/Zydis/Internal
11 | * @brief Internal APIs
12 | */
13 |
--------------------------------------------------------------------------------
/ThirdParty/zydis/include/Zydis/Defines.h:
--------------------------------------------------------------------------------
1 | /***************************************************************************************************
2 |
3 | Zyan Disassembler Library (Zydis)
4 |
5 | Original Author : Joel Hoener
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 | * Import/export defines for MSVC builds.
30 | */
31 |
32 | #ifndef ZYDIS_DEFINES_H
33 | #define ZYDIS_DEFINES_H
34 |
35 | #include
36 |
37 | // This is a cut-down version of what CMake's `GenerateExportHeader` would usually generate. To
38 | // simplify builds without CMake, we define these things manually instead of relying on CMake
39 | // to generate the header.
40 | //
41 | // For static builds, our CMakeList will define `ZYDIS_STATIC_BUILD`. For shared library builds,
42 | // our CMake will define `ZYDIS_SHOULD_EXPORT` depending on whether the target is being imported or
43 | // exported. If CMake isn't used, users can manually define these to fit their use-case.
44 |
45 | // Backward compatibility: CMake would previously generate these variables names. However, because
46 | // they have pretty cryptic names, we renamed them when we got rid of `GenerateExportHeader`. For
47 | // backward compatibility for users that don't use CMake and previously manually defined these, we
48 | // translate the old defines here and print a warning.
49 | #if defined(ZYDIS_STATIC_DEFINE)
50 | # pragma message("ZYDIS_STATIC_DEFINE was renamed to ZYDIS_STATIC_BUILD.")
51 | # define ZYDIS_STATIC_BUILD
52 | #endif
53 | #if defined(Zydis_EXPORTS)
54 | # pragma message("Zydis_EXPORTS was renamed to ZYDIS_SHOULD_EXPORT.")
55 | # define ZYDIS_SHOULD_EXPORT
56 | #endif
57 |
58 | /**
59 | * Symbol is exported in shared library builds.
60 | */
61 | #if defined(ZYDIS_STATIC_BUILD)
62 | # define ZYDIS_EXPORT
63 | #else
64 | # if defined(ZYDIS_SHOULD_EXPORT)
65 | # define ZYDIS_EXPORT ZYAN_DLLEXPORT
66 | # else
67 | # define ZYDIS_EXPORT ZYAN_DLLIMPORT
68 | # endif
69 | #endif
70 |
71 | /**
72 | * Symbol is not exported and for internal use only.
73 | */
74 | #define ZYDIS_NO_EXPORT
75 |
76 | #endif // ZYDIS_DEFINES_H
77 |
--------------------------------------------------------------------------------
/ThirdParty/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_AVX_VNNI,
22 | ZYDIS_ISA_EXT_BASE,
23 | ZYDIS_ISA_EXT_BMI1,
24 | ZYDIS_ISA_EXT_BMI2,
25 | ZYDIS_ISA_EXT_CET,
26 | ZYDIS_ISA_EXT_CLDEMOTE,
27 | ZYDIS_ISA_EXT_CLFLUSHOPT,
28 | ZYDIS_ISA_EXT_CLFSH,
29 | ZYDIS_ISA_EXT_CLWB,
30 | ZYDIS_ISA_EXT_CLZERO,
31 | ZYDIS_ISA_EXT_ENQCMD,
32 | ZYDIS_ISA_EXT_F16C,
33 | ZYDIS_ISA_EXT_FMA,
34 | ZYDIS_ISA_EXT_FMA4,
35 | ZYDIS_ISA_EXT_GFNI,
36 | ZYDIS_ISA_EXT_HRESET,
37 | ZYDIS_ISA_EXT_INVPCID,
38 | ZYDIS_ISA_EXT_KEYLOCKER,
39 | ZYDIS_ISA_EXT_KEYLOCKER_WIDE,
40 | ZYDIS_ISA_EXT_KNC,
41 | ZYDIS_ISA_EXT_KNCE,
42 | ZYDIS_ISA_EXT_KNCV,
43 | ZYDIS_ISA_EXT_LONGMODE,
44 | ZYDIS_ISA_EXT_LZCNT,
45 | ZYDIS_ISA_EXT_MCOMMIT,
46 | ZYDIS_ISA_EXT_MMX,
47 | ZYDIS_ISA_EXT_MONITOR,
48 | ZYDIS_ISA_EXT_MONITORX,
49 | ZYDIS_ISA_EXT_MOVBE,
50 | ZYDIS_ISA_EXT_MOVDIR,
51 | ZYDIS_ISA_EXT_MPX,
52 | ZYDIS_ISA_EXT_PADLOCK,
53 | ZYDIS_ISA_EXT_PAUSE,
54 | ZYDIS_ISA_EXT_PCLMULQDQ,
55 | ZYDIS_ISA_EXT_PCONFIG,
56 | ZYDIS_ISA_EXT_PKU,
57 | ZYDIS_ISA_EXT_PREFETCHWT1,
58 | ZYDIS_ISA_EXT_PT,
59 | ZYDIS_ISA_EXT_RDPID,
60 | ZYDIS_ISA_EXT_RDPRU,
61 | ZYDIS_ISA_EXT_RDRAND,
62 | ZYDIS_ISA_EXT_RDSEED,
63 | ZYDIS_ISA_EXT_RDTSCP,
64 | ZYDIS_ISA_EXT_RDWRFSGS,
65 | ZYDIS_ISA_EXT_RTM,
66 | ZYDIS_ISA_EXT_SERIALIZE,
67 | ZYDIS_ISA_EXT_SGX,
68 | ZYDIS_ISA_EXT_SGX_ENCLV,
69 | ZYDIS_ISA_EXT_SHA,
70 | ZYDIS_ISA_EXT_SMAP,
71 | ZYDIS_ISA_EXT_SMX,
72 | ZYDIS_ISA_EXT_SNP,
73 | ZYDIS_ISA_EXT_SSE,
74 | ZYDIS_ISA_EXT_SSE2,
75 | ZYDIS_ISA_EXT_SSE3,
76 | ZYDIS_ISA_EXT_SSE4,
77 | ZYDIS_ISA_EXT_SSE4A,
78 | ZYDIS_ISA_EXT_SSSE3,
79 | ZYDIS_ISA_EXT_SVM,
80 | ZYDIS_ISA_EXT_TBM,
81 | ZYDIS_ISA_EXT_TDX,
82 | ZYDIS_ISA_EXT_TSX_LDTRK,
83 | ZYDIS_ISA_EXT_UINTR,
84 | ZYDIS_ISA_EXT_VAES,
85 | ZYDIS_ISA_EXT_VMFUNC,
86 | ZYDIS_ISA_EXT_VPCLMULQDQ,
87 | ZYDIS_ISA_EXT_VTX,
88 | ZYDIS_ISA_EXT_WAITPKG,
89 | ZYDIS_ISA_EXT_X87,
90 | ZYDIS_ISA_EXT_XOP,
91 | ZYDIS_ISA_EXT_XSAVE,
92 | ZYDIS_ISA_EXT_XSAVEC,
93 | ZYDIS_ISA_EXT_XSAVEOPT,
94 | ZYDIS_ISA_EXT_XSAVES,
95 |
96 | /**
97 | * Maximum value of this enum.
98 | */
99 | ZYDIS_ISA_EXT_MAX_VALUE = ZYDIS_ISA_EXT_XSAVES,
100 | /**
101 | * The minimum number of bits required to represent all values of this enum.
102 | */
103 | ZYDIS_ISA_EXT_REQUIRED_BITS = ZYAN_BITS_TO_REPRESENT(ZYDIS_ISA_EXT_MAX_VALUE)
104 | } ZydisISAExt;
105 |
--------------------------------------------------------------------------------
/ThirdParty/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_FP16,
45 | ZYDIS_CATEGORY_GATHER,
46 | ZYDIS_CATEGORY_GFNI,
47 | ZYDIS_CATEGORY_HRESET,
48 | ZYDIS_CATEGORY_IFMA,
49 | ZYDIS_CATEGORY_INTERRUPT,
50 | ZYDIS_CATEGORY_IO,
51 | ZYDIS_CATEGORY_IOSTRINGOP,
52 | ZYDIS_CATEGORY_KEYLOCKER,
53 | ZYDIS_CATEGORY_KEYLOCKER_WIDE,
54 | ZYDIS_CATEGORY_KMASK,
55 | ZYDIS_CATEGORY_KNC,
56 | ZYDIS_CATEGORY_KNCMASK,
57 | ZYDIS_CATEGORY_KNCSCALAR,
58 | ZYDIS_CATEGORY_LEGACY,
59 | ZYDIS_CATEGORY_LOGICAL,
60 | ZYDIS_CATEGORY_LOGICAL_FP,
61 | ZYDIS_CATEGORY_LZCNT,
62 | ZYDIS_CATEGORY_MISC,
63 | ZYDIS_CATEGORY_MMX,
64 | ZYDIS_CATEGORY_MOVDIR,
65 | ZYDIS_CATEGORY_MPX,
66 | ZYDIS_CATEGORY_NOP,
67 | ZYDIS_CATEGORY_PADLOCK,
68 | ZYDIS_CATEGORY_PCLMULQDQ,
69 | ZYDIS_CATEGORY_PCONFIG,
70 | ZYDIS_CATEGORY_PKU,
71 | ZYDIS_CATEGORY_POP,
72 | ZYDIS_CATEGORY_PREFETCH,
73 | ZYDIS_CATEGORY_PREFETCHWT1,
74 | ZYDIS_CATEGORY_PT,
75 | ZYDIS_CATEGORY_PUSH,
76 | ZYDIS_CATEGORY_RDPID,
77 | ZYDIS_CATEGORY_RDPRU,
78 | ZYDIS_CATEGORY_RDRAND,
79 | ZYDIS_CATEGORY_RDSEED,
80 | ZYDIS_CATEGORY_RDWRFSGS,
81 | ZYDIS_CATEGORY_RET,
82 | ZYDIS_CATEGORY_ROTATE,
83 | ZYDIS_CATEGORY_SCATTER,
84 | ZYDIS_CATEGORY_SEGOP,
85 | ZYDIS_CATEGORY_SEMAPHORE,
86 | ZYDIS_CATEGORY_SERIALIZE,
87 | ZYDIS_CATEGORY_SETCC,
88 | ZYDIS_CATEGORY_SGX,
89 | ZYDIS_CATEGORY_SHA,
90 | ZYDIS_CATEGORY_SHIFT,
91 | ZYDIS_CATEGORY_SMAP,
92 | ZYDIS_CATEGORY_SSE,
93 | ZYDIS_CATEGORY_STRINGOP,
94 | ZYDIS_CATEGORY_STTNI,
95 | ZYDIS_CATEGORY_SYSCALL,
96 | ZYDIS_CATEGORY_SYSRET,
97 | ZYDIS_CATEGORY_SYSTEM,
98 | ZYDIS_CATEGORY_TBM,
99 | ZYDIS_CATEGORY_TSX_LDTRK,
100 | ZYDIS_CATEGORY_UFMA,
101 | ZYDIS_CATEGORY_UINTR,
102 | ZYDIS_CATEGORY_UNCOND_BR,
103 | ZYDIS_CATEGORY_VAES,
104 | ZYDIS_CATEGORY_VBMI2,
105 | ZYDIS_CATEGORY_VEX,
106 | ZYDIS_CATEGORY_VFMA,
107 | ZYDIS_CATEGORY_VPCLMULQDQ,
108 | ZYDIS_CATEGORY_VTX,
109 | ZYDIS_CATEGORY_WAITPKG,
110 | ZYDIS_CATEGORY_WIDENOP,
111 | ZYDIS_CATEGORY_X87_ALU,
112 | ZYDIS_CATEGORY_XOP,
113 | ZYDIS_CATEGORY_XSAVE,
114 | ZYDIS_CATEGORY_XSAVEOPT,
115 |
116 | /**
117 | * Maximum value of this enum.
118 | */
119 | ZYDIS_CATEGORY_MAX_VALUE = ZYDIS_CATEGORY_XSAVEOPT,
120 | /**
121 | * The minimum number of bits required to represent all values of this enum.
122 | */
123 | ZYDIS_CATEGORY_REQUIRED_BITS = ZYAN_BITS_TO_REPRESENT(ZYDIS_CATEGORY_MAX_VALUE)
124 | } ZydisInstructionCategory;
125 |
--------------------------------------------------------------------------------
/ThirdParty/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 |
38 | #ifdef __cplusplus
39 | extern "C" {
40 | #endif
41 |
42 | /* ============================================================================================== */
43 | /* Enums and types */
44 | /* ============================================================================================== */
45 |
46 | #include
47 | #include
48 | #include
49 |
50 | /* ============================================================================================== */
51 | /* Exported functions */
52 | /* ============================================================================================== */
53 |
54 | /**
55 | * Returns the specified instruction category string.
56 | *
57 | * @param category The instruction category.
58 | *
59 | * @return The instruction category string or `ZYAN_NULL`, if an invalid category was passed.
60 | */
61 | ZYDIS_EXPORT const char* ZydisCategoryGetString(ZydisInstructionCategory category);
62 |
63 | /**
64 | * Returns the specified isa-set string.
65 | *
66 | * @param isa_set The isa-set.
67 | *
68 | * @return The isa-set string or `ZYAN_NULL`, if an invalid isa-set was passed.
69 | */
70 | ZYDIS_EXPORT const char* ZydisISASetGetString(ZydisISASet isa_set);
71 |
72 | /**
73 | * Returns the specified isa-extension string.
74 | *
75 | * @param isa_ext The isa-extension.
76 | *
77 | * @return The isa-extension string or `ZYAN_NULL`, if an invalid isa-extension was passed.
78 | */
79 | ZYDIS_EXPORT const char* ZydisISAExtGetString(ZydisISAExt isa_ext);
80 |
81 | /* ============================================================================================== */
82 |
83 | #ifdef __cplusplus
84 | }
85 | #endif
86 |
87 | #endif /* ZYDIS_METAINFO_H */
88 |
--------------------------------------------------------------------------------
/ThirdParty/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 | #include
38 |
39 | #ifdef __cplusplus
40 | extern "C" {
41 | #endif
42 |
43 | /* ============================================================================================== */
44 | /* Enums and types */
45 | /* ============================================================================================== */
46 |
47 | #include
48 |
49 | /* ============================================================================================== */
50 | /* Exported functions */
51 | /* ============================================================================================== */
52 |
53 | /**
54 | * @addtogroup mnemonic Mnemonic
55 | * Functions for retrieving mnemonic names.
56 | * @{
57 | */
58 |
59 | /**
60 | * Returns the specified instruction mnemonic string.
61 | *
62 | * @param mnemonic The mnemonic.
63 | *
64 | * @return The instruction mnemonic string or `ZYAN_NULL`, if an invalid mnemonic was passed.
65 | */
66 | ZYDIS_EXPORT const char* ZydisMnemonicGetString(ZydisMnemonic mnemonic);
67 |
68 | /**
69 | * Returns the specified instruction mnemonic as `ZydisShortString`.
70 | *
71 | * @param mnemonic The mnemonic.
72 | *
73 | * @return The instruction mnemonic string or `ZYAN_NULL`, if an invalid mnemonic was passed.
74 | *
75 | * The `buffer` of the returned struct is guaranteed to be zero-terminated in this special case.
76 | */
77 | ZYDIS_EXPORT const ZydisShortString* ZydisMnemonicGetStringWrapped(ZydisMnemonic mnemonic);
78 |
79 | /**
80 | * @}
81 | */
82 |
83 | /* ============================================================================================== */
84 |
85 | #ifdef __cplusplus
86 | }
87 | #endif
88 |
89 | #endif /* ZYDIS_MNEMONIC_H */
90 |
--------------------------------------------------------------------------------
/ThirdParty/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 |
39 | #ifdef __cplusplus
40 | extern "C" {
41 | #endif
42 |
43 | /* ============================================================================================== */
44 | /* Enums and types */
45 | /* ============================================================================================== */
46 |
47 | #if !(defined(ZYAN_AARCH64) && defined(ZYAN_APPLE))
48 | # pragma pack(push, 1)
49 | #endif
50 |
51 | /**
52 | * Defines the `ZydisShortString` struct.
53 | *
54 | * This compact struct is mainly used for internal string-tables to save up some bytes.
55 | *
56 | * All fields in this struct should be considered as "private". Any changes may lead to unexpected
57 | * behavior.
58 | */
59 | typedef struct ZydisShortString_
60 | {
61 | /**
62 | * The buffer that contains the actual (null-terminated) string.
63 | */
64 | const char* data;
65 | /**
66 | * The length (number of characters) of the string (without 0-termination).
67 | */
68 | ZyanU8 size;
69 | } ZydisShortString;
70 |
71 | #if !(defined(ZYAN_AARCH64) && defined(ZYAN_APPLE))
72 | # pragma pack(pop)
73 | #endif
74 |
75 | /* ============================================================================================== */
76 | /* Macros */
77 | /* ============================================================================================== */
78 |
79 | /**
80 | * Declares a `ZydisShortString` from a static C-style string.
81 | *
82 | * @param string The C-string constant.
83 | */
84 | #define ZYDIS_MAKE_SHORTSTRING(string) \
85 | { string, sizeof(string) - 1 }
86 |
87 | /* ============================================================================================== */
88 |
89 | #ifdef __cplusplus
90 | }
91 | #endif
92 |
93 | #endif /* ZYDIS_SHORTSTRING_H */
94 |
--------------------------------------------------------------------------------
/ThirdParty/zydis/man/ZydisDisasm.1.ronn:
--------------------------------------------------------------------------------
1 | ZydisDisasm(1) -- disassemble files
2 | ===================================
3 |
4 | ## SYNOPSIS
5 |
6 | `ZydisDisasm` []
7 |
8 | ## DESCRIPTION
9 |
10 | `ZydisDisasm` allows you to decode X86 & X86-64 assembly files, dumping the disassembled instructions to stdout. With no argument, `ZydisDisasm` will read input from stdin.
11 |
12 | ## OPTIONS
13 |
14 | `ZydisDisasm` supports four different machine modes
15 |
16 | * `-real`:
17 | real machine mode
18 |
19 | * `-16`:
20 | 16 bits machine mode
21 |
22 | * `-32`:
23 | 32 bits machine mode
24 |
25 | * `-64`:
26 | 64 bits machine mode
27 |
28 | ## EXAMPLES
29 |
30 | $ ZydisDisasm -64 input.hex
31 | and byte ptr ds:[rbx], dh
32 | and byte ptr ds:[r14], r14b
33 | xor eax, 0x20453220
34 | xor byte ptr ds:[rax], r12b
35 | xor r12b, byte ptr ds:[rax]
36 | xor r12d, dword ptr ds:[rax]
37 | xor al, 0x38
38 | and byte ptr ds:[rax], dh
39 | xor dword ptr ds:[rax], esp
40 | xor al, 0x20
41 | cmp dword ptr ds:[rax], edi
42 | and byte ptr ds:[rdx], dh
43 | and byte ptr ds:[r8], sil
44 | xor dword ptr ds:[rax], esp
45 | xor byte ptr ds:[rax], dh
46 | and byte ptr ds:[rax], dh
47 | xor byte ptr ds:[rdx], cl
48 |
49 | ## SEE ALSO
50 |
51 | ZydisInfo(1)
52 |
--------------------------------------------------------------------------------
/ThirdParty/zydis/man/ZydisInfo.1.ronn:
--------------------------------------------------------------------------------
1 | ZydisInfo(1) -- detailed instruction information
2 | ================================================
3 |
4 | ## SYNOPSIS
5 |
6 | `ZydisInfo` []
7 |
8 | ## DESCRIPTION
9 |
10 | `ZydisInfo` allows you to decode X86 & X86-64 assembly displaying lots of information about it.
11 |
12 | ## OPTIONS
13 |
14 | `ZydisInfo` supports four different machine modes
15 |
16 | * `-real`:
17 | real machine mode
18 |
19 | * `-16`:
20 | 16 bits machine mode
21 |
22 | * `-32`:
23 | 32 bits machine mode
24 |
25 | * `-64`:
26 | 64 bits machine mode
27 |
28 | You can also specify the stack width one of the following options
29 |
30 | * `-16`:
31 | 16 bits
32 |
33 | * `-32`:
34 | 32 bits
35 |
36 | * `-64`:
37 | 64 bits
38 |
39 | ## EXAMPLES
40 |
41 | $ ZydisInfo -64 66 3E 65 2E F0 F2 F3 48 01 A4 98 2C 01 00 00
42 | == [ BASIC ] ==================================================
43 | MNEMONIC: add [ENC: DEFAULT, MAP: DEFAULT, OPC: 0x01]
44 | LENGTH: 15
45 | SSZ: 64
46 | EOSZ: 64
47 | EASZ: 64
48 | CATEGORY: BINARY
49 | ISA-SET: I86
50 | ISA-EXT: BASE
51 | EXCEPTIONS: NONE
52 | ATTRIBUTES: HAS_MODRM HAS_SIB HAS_REX CPUFLAG_ACCESS ACCEPTS_LOCK
53 | [...more info...]
54 |
55 | ## SEE ALSO
56 |
57 | ZydisDisasm(1)
58 |
--------------------------------------------------------------------------------
/ThirdParty/zydis/msvc/README.md:
--------------------------------------------------------------------------------
1 | ## Readme
2 |
3 | This directory contains MSVC project files to build Zydis and the included tools and examples.
4 |
5 | There are five build configurations, each with 32/64 bit and debug/release versions:
6 | - Static with dynamic run-time library (MD)
7 | - Static with static run-time library (MT)
8 | - Dynamic (DLL) with dynamic run-time library (MD)
9 | - Dynamic (DLL) with static run-time library (MT)
10 | - Kernel mode
11 |
12 | In order to build the kernel mode configuration you must have the Microsoft WDK installed, available at https://developer.microsoft.com/en-us/windows/hardware/windows-driver-kit.
13 | The kernel mode configuration only builds `Zydis` and the `ZydisWinKernel` driver sample. The other configurations build all projects except for `ZydisWinKernel`.
14 |
15 | NOTE: If you already have the WDK installed, make sure it is updated to at least the Windows 10 1709 version (10.0.16299.0) in order to prevent issues opening the solution file. This is due to a bug in older WDK toolsets.
16 |
17 | All Zydis features are enabled by default. In order to disable specific features you can define preprocessor directives such as `ZYDIS_DISABLE_FORMATTER`. Refer to `CMakeLists.txt` for the full list of feature switches.
18 |
--------------------------------------------------------------------------------
/ThirdParty/zydis/msvc/Zydis.sln:
--------------------------------------------------------------------------------
1 | Microsoft Visual Studio Solution File, Format Version 12.00
2 | # Visual Studio Version 16
3 | VisualStudioVersion = 16.0.31624.102
4 | MinimumVisualStudioVersion = 10.0.40219.1
5 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tools", "Tools", "{292A9E1E-C557-4570-ABE1-8EEC0E1B79C4}"
6 | EndProject
7 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ZydisInfo", "tools\ZydisInfo.vcxproj", "{BC04B6A7-D80C-3FED-97AC-BCC8370D6A7E}"
8 | ProjectSection(ProjectDependencies) = postProject
9 | {88A23124-5640-35A0-B890-311D7A67A7D2} = {88A23124-5640-35A0-B890-311D7A67A7D2}
10 | {E06E2E87-82B9-4DC2-A1E9-FE371CDBAAC2} = {E06E2E87-82B9-4DC2-A1E9-FE371CDBAAC2}
11 | EndProjectSection
12 | EndProject
13 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Zydis", "zydis\Zydis.vcxproj", "{88A23124-5640-35A0-B890-311D7A67A7D2}"
14 | EndProject
15 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Zycore", "dependencies\zycore\Zycore.vcxproj", "{E06E2E87-82B9-4DC2-A1E9-FE371CDBAAC2}"
16 | EndProject
17 | Global
18 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
19 | Debug|X64 = Debug|X64
20 | Debug|X86 = Debug|X86
21 | Release|X64 = Release|X64
22 | Release|X86 = Release|X86
23 | EndGlobalSection
24 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
25 | {BC04B6A7-D80C-3FED-97AC-BCC8370D6A7E}.Debug|X64.ActiveCfg = Debug|x64
26 | {BC04B6A7-D80C-3FED-97AC-BCC8370D6A7E}.Debug|X64.Build.0 = Debug|x64
27 | {BC04B6A7-D80C-3FED-97AC-BCC8370D6A7E}.Debug|X86.ActiveCfg = Debug|Win32
28 | {BC04B6A7-D80C-3FED-97AC-BCC8370D6A7E}.Debug|X86.Build.0 = Debug|Win32
29 | {BC04B6A7-D80C-3FED-97AC-BCC8370D6A7E}.Release|X64.ActiveCfg = Release|x64
30 | {BC04B6A7-D80C-3FED-97AC-BCC8370D6A7E}.Release|X64.Build.0 = Release|x64
31 | {BC04B6A7-D80C-3FED-97AC-BCC8370D6A7E}.Release|X86.ActiveCfg = Release|Win32
32 | {BC04B6A7-D80C-3FED-97AC-BCC8370D6A7E}.Release|X86.Build.0 = Release|Win32
33 | {88A23124-5640-35A0-B890-311D7A67A7D2}.Debug|X64.ActiveCfg = Debug|x64
34 | {88A23124-5640-35A0-B890-311D7A67A7D2}.Debug|X64.Build.0 = Debug|x64
35 | {88A23124-5640-35A0-B890-311D7A67A7D2}.Debug|X86.ActiveCfg = Debug|Win32
36 | {88A23124-5640-35A0-B890-311D7A67A7D2}.Debug|X86.Build.0 = Debug|Win32
37 | {88A23124-5640-35A0-B890-311D7A67A7D2}.Release|X64.ActiveCfg = Release|x64
38 | {88A23124-5640-35A0-B890-311D7A67A7D2}.Release|X64.Build.0 = Release|x64
39 | {88A23124-5640-35A0-B890-311D7A67A7D2}.Release|X86.ActiveCfg = Release|Win32
40 | {88A23124-5640-35A0-B890-311D7A67A7D2}.Release|X86.Build.0 = Release|Win32
41 | {E06E2E87-82B9-4DC2-A1E9-FE371CDBAAC2}.Debug|X64.ActiveCfg = Debug|x64
42 | {E06E2E87-82B9-4DC2-A1E9-FE371CDBAAC2}.Debug|X64.Build.0 = Debug|x64
43 | {E06E2E87-82B9-4DC2-A1E9-FE371CDBAAC2}.Debug|X86.ActiveCfg = Debug|Win32
44 | {E06E2E87-82B9-4DC2-A1E9-FE371CDBAAC2}.Debug|X86.Build.0 = Debug|Win32
45 | {E06E2E87-82B9-4DC2-A1E9-FE371CDBAAC2}.Release|X64.ActiveCfg = Release|x64
46 | {E06E2E87-82B9-4DC2-A1E9-FE371CDBAAC2}.Release|X64.Build.0 = Release|x64
47 | {E06E2E87-82B9-4DC2-A1E9-FE371CDBAAC2}.Release|X86.ActiveCfg = Release|Win32
48 | {E06E2E87-82B9-4DC2-A1E9-FE371CDBAAC2}.Release|X86.Build.0 = Release|Win32
49 | EndGlobalSection
50 | GlobalSection(SolutionProperties) = preSolution
51 | HideSolutionNode = FALSE
52 | EndGlobalSection
53 | GlobalSection(NestedProjects) = preSolution
54 | {BC04B6A7-D80C-3FED-97AC-BCC8370D6A7E} = {292A9E1E-C557-4570-ABE1-8EEC0E1B79C4}
55 | EndGlobalSection
56 | GlobalSection(ExtensibilityGlobals) = postSolution
57 | SolutionGuid = {F578E55A-EB10-4D4A-9F4E-C74DCB58DE73}
58 | EndGlobalSection
59 | EndGlobal
60 |
--------------------------------------------------------------------------------
/ThirdParty/zydis/msvc/examples/EncodeFromScratch.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {1E428BB6-354B-440D-9F6C-501808E19B2E}
6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {4D41ED45-7EA3-4C1B-AD5D-25E17BE47901}
10 | h;hh;hpp;hxx;hm;inl;inc;xsd
11 |
12 |
13 | {7BADE0F7-E82D-4D21-896B-50E56085AC85}
14 |
15 |
16 | {7F3EEF39-FFB3-4D06-A971-72D16E95597F}
17 |
18 |
19 |
20 |
21 | Source Files
22 |
23 |
24 |
25 |
26 | Header Files\Zycore
27 |
28 |
29 | Header Files\Zycore
30 |
31 |
32 | Header Files\Zycore
33 |
34 |
35 | Header Files\Zycore
36 |
37 |
38 | Header Files\Zycore
39 |
40 |
41 | Header Files\Zycore
42 |
43 |
44 | Header Files\Zycore
45 |
46 |
47 | Header Files\Zycore
48 |
49 |
50 | Header Files\Zycore
51 |
52 |
53 | Header Files\Zycore
54 |
55 |
56 | Header Files\Zycore
57 |
58 |
59 | Header Files\Zycore
60 |
61 |
62 | Header Files\Zydis
63 |
64 |
65 | Header Files\Zydis
66 |
67 |
68 | Header Files\Zydis
69 |
70 |
71 | Header Files\Zydis
72 |
73 |
74 | Header Files\Zydis
75 |
76 |
77 | Header Files\Zydis
78 |
79 |
80 | Header Files\Zydis
81 |
82 |
83 | Header Files\Zydis
84 |
85 |
86 | Header Files\Zydis
87 |
88 |
89 | Header Files\Zydis
90 |
91 |
92 | Header Files\Zydis
93 |
94 |
95 |
--------------------------------------------------------------------------------
/ThirdParty/zydis/msvc/examples/Formatter01.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {696C4839-0CFE-4685-8A7E-17D6CEA8A9E1}
6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {B33CB479-1C96-4E23-AABF-6F6AFE4EC48F}
10 | h;hh;hpp;hxx;hm;inl;inc;xsd
11 |
12 |
13 | {F16C31FA-178D-4018-B19B-AC17921D4BBA}
14 |
15 |
16 | {7E5DB78A-D59D-4537-B5FE-D5BFB35D8684}
17 |
18 |
19 |
20 |
21 | Source Files
22 |
23 |
24 |
25 |
26 | Header Files\Zycore
27 |
28 |
29 | Header Files\Zycore
30 |
31 |
32 | Header Files\Zycore
33 |
34 |
35 | Header Files\Zycore
36 |
37 |
38 | Header Files\Zycore
39 |
40 |
41 | Header Files\Zycore
42 |
43 |
44 | Header Files\Zycore
45 |
46 |
47 | Header Files\Zycore
48 |
49 |
50 | Header Files\Zycore
51 |
52 |
53 | Header Files\Zycore
54 |
55 |
56 | Header Files\Zycore
57 |
58 |
59 | Header Files\Zycore
60 |
61 |
62 | Header Files\Zydis
63 |
64 |
65 | Header Files\Zydis
66 |
67 |
68 | Header Files\Zydis
69 |
70 |
71 | Header Files\Zydis
72 |
73 |
74 | Header Files\Zydis
75 |
76 |
77 | Header Files\Zydis
78 |
79 |
80 | Header Files\Zydis
81 |
82 |
83 | Header Files\Zydis
84 |
85 |
86 | Header Files\Zydis
87 |
88 |
89 | Header Files\Zydis
90 |
91 |
92 | Header Files\Zydis
93 |
94 |
95 |
--------------------------------------------------------------------------------
/ThirdParty/zydis/msvc/examples/Formatter02.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {EEA2894A-5270-4A30-A19A-6E197DF8F321}
6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {D13CAF58-E8F9-44C6-BB28-12E3A9124A6B}
10 | h;hh;hpp;hxx;hm;inl;inc;xsd
11 |
12 |
13 | {2DA0252F-A511-42D7-87CF-B4CAC2AF15F1}
14 |
15 |
16 | {3F259D2B-7A0D-4147-B076-203B5EC4AF31}
17 |
18 |
19 |
20 |
21 | Source Files
22 |
23 |
24 |
25 |
26 | Header Files\Zycore
27 |
28 |
29 | Header Files\Zycore
30 |
31 |
32 | Header Files\Zycore
33 |
34 |
35 | Header Files\Zycore
36 |
37 |
38 | Header Files\Zycore
39 |
40 |
41 | Header Files\Zycore
42 |
43 |
44 | Header Files\Zycore
45 |
46 |
47 | Header Files\Zycore
48 |
49 |
50 | Header Files\Zycore
51 |
52 |
53 | Header Files\Zycore
54 |
55 |
56 | Header Files\Zycore
57 |
58 |
59 | Header Files\Zycore
60 |
61 |
62 | Header Files\Zydis
63 |
64 |
65 | Header Files\Zydis
66 |
67 |
68 | Header Files\Zydis
69 |
70 |
71 | Header Files\Zydis
72 |
73 |
74 | Header Files\Zydis
75 |
76 |
77 | Header Files\Zydis
78 |
79 |
80 | Header Files\Zydis
81 |
82 |
83 | Header Files\Zydis
84 |
85 |
86 | Header Files\Zydis
87 |
88 |
89 | Header Files\Zydis
90 |
91 |
92 | Header Files\Zydis
93 |
94 |
95 |
--------------------------------------------------------------------------------
/ThirdParty/zydis/msvc/examples/Formatter03.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {F4C79A89-1963-4A14-84DB-EF4DF9F46217}
6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {3E5632E3-79C0-48D1-B2F0-A7CC3B08344B}
10 | h;hh;hpp;hxx;hm;inl;inc;xsd
11 |
12 |
13 | {AE8ED7E6-E8D2-466E-B5D7-51B0B5D3B3AF}
14 |
15 |
16 | {E6AAE699-279A-49D1-BF5F-B4A08678A442}
17 |
18 |
19 |
20 |
21 | Source Files
22 |
23 |
24 |
25 |
26 | Header Files\Zycore
27 |
28 |
29 | Header Files\Zycore
30 |
31 |
32 | Header Files\Zycore
33 |
34 |
35 | Header Files\Zycore
36 |
37 |
38 | Header Files\Zycore
39 |
40 |
41 | Header Files\Zycore
42 |
43 |
44 | Header Files\Zycore
45 |
46 |
47 | Header Files\Zycore
48 |
49 |
50 | Header Files\Zycore
51 |
52 |
53 | Header Files\Zycore
54 |
55 |
56 | Header Files\Zycore
57 |
58 |
59 | Header Files\Zycore
60 |
61 |
62 | Header Files\Zydis
63 |
64 |
65 | Header Files\Zydis
66 |
67 |
68 | Header Files\Zydis
69 |
70 |
71 | Header Files\Zydis
72 |
73 |
74 | Header Files\Zydis
75 |
76 |
77 | Header Files\Zydis
78 |
79 |
80 | Header Files\Zydis
81 |
82 |
83 | Header Files\Zydis
84 |
85 |
86 | Header Files\Zydis
87 |
88 |
89 | Header Files\Zydis
90 |
91 |
92 | Header Files\Zydis
93 |
94 |
95 |
--------------------------------------------------------------------------------
/ThirdParty/zydis/msvc/examples/RewriteCode.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {B2B9E8A4-CF65-47E2-9F61-A511E4F63256}
6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {56095DA9-623B-4998-B8EE-7711F10EEA08}
10 | h;hh;hpp;hxx;hm;inl;inc;xsd
11 |
12 |
13 | {7EDE8B6E-ACF9-4F08-B8BC-7FEB10190D97}
14 |
15 |
16 | {4E8956D8-706F-40FA-83F1-EC69B3575144}
17 |
18 |
19 |
20 |
21 | Source Files
22 |
23 |
24 |
25 |
26 | Header Files\Zycore
27 |
28 |
29 | Header Files\Zycore
30 |
31 |
32 | Header Files\Zycore
33 |
34 |
35 | Header Files\Zycore
36 |
37 |
38 | Header Files\Zycore
39 |
40 |
41 | Header Files\Zycore
42 |
43 |
44 | Header Files\Zycore
45 |
46 |
47 | Header Files\Zycore
48 |
49 |
50 | Header Files\Zycore
51 |
52 |
53 | Header Files\Zycore
54 |
55 |
56 | Header Files\Zycore
57 |
58 |
59 | Header Files\Zycore
60 |
61 |
62 | Header Files\Zydis
63 |
64 |
65 | Header Files\Zydis
66 |
67 |
68 | Header Files\Zydis
69 |
70 |
71 | Header Files\Zydis
72 |
73 |
74 | Header Files\Zydis
75 |
76 |
77 | Header Files\Zydis
78 |
79 |
80 | Header Files\Zydis
81 |
82 |
83 | Header Files\Zydis
84 |
85 |
86 | Header Files\Zydis
87 |
88 |
89 | Header Files\Zydis
90 |
91 |
92 | Header Files\Zydis
93 |
94 |
95 |
--------------------------------------------------------------------------------
/ThirdParty/zydis/msvc/examples/ZydisPerfTest.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {664BBE0B-918F-3B41-8D06-1875B10A7BE5}
6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {54CFF9CE-5525-3FCE-8ECE-9A26FB686F56}
10 | h;hh;hpp;hxx;hm;inl;inc;xsd
11 |
12 |
13 | {8CD89CBF-4A23-408A-AED4-3CDFB9296284}
14 |
15 |
16 | {A98CBC54-AA7E-4AEE-80CE-19DD4304363F}
17 |
18 |
19 |
20 |
21 | Source Files
22 |
23 |
24 |
25 |
26 | Header Files\Zycore
27 |
28 |
29 | Header Files\Zycore
30 |
31 |
32 | Header Files\Zycore
33 |
34 |
35 | Header Files\Zycore
36 |
37 |
38 | Header Files\Zycore
39 |
40 |
41 | Header Files\Zycore
42 |
43 |
44 | Header Files\Zycore
45 |
46 |
47 | Header Files\Zycore
48 |
49 |
50 | Header Files\Zycore
51 |
52 |
53 | Header Files\Zycore
54 |
55 |
56 | Header Files\Zycore
57 |
58 |
59 | Header Files\Zycore
60 |
61 |
62 | Header Files\Zydis
63 |
64 |
65 | Header Files\Zydis
66 |
67 |
68 | Header Files\Zydis
69 |
70 |
71 | Header Files\Zydis
72 |
73 |
74 | Header Files\Zydis
75 |
76 |
77 | Header Files\Zydis
78 |
79 |
80 | Header Files\Zydis
81 |
82 |
83 | Header Files\Zydis
84 |
85 |
86 | Header Files\Zydis
87 |
88 |
89 | Header Files\Zydis
90 |
91 |
92 | Header Files\Zydis
93 |
94 |
95 |
--------------------------------------------------------------------------------
/ThirdParty/zydis/msvc/examples/ZydisWinKernel.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {664BBE0B-918F-3B41-8D06-1875B10A7BE5}
6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {54CFF9CE-5525-3FCE-8ECE-9A26FB686F56}
10 | h;hh;hpp;hxx;hm;inl;inc;xsd
11 |
12 |
13 | {53777263-749B-4134-9A9E-42DB87A66F18}
14 |
15 |
16 | {9A331546-C5D3-48F8-ACCF-992D48C1F6EE}
17 |
18 |
19 |
20 |
21 | Header Files\Zycore
22 |
23 |
24 | Header Files\Zycore
25 |
26 |
27 | Header Files\Zycore
28 |
29 |
30 | Header Files\Zycore
31 |
32 |
33 | Header Files\Zycore
34 |
35 |
36 | Header Files\Zycore
37 |
38 |
39 | Header Files\Zycore
40 |
41 |
42 | Header Files\Zycore
43 |
44 |
45 | Header Files\Zycore
46 |
47 |
48 | Header Files\Zycore
49 |
50 |
51 | Header Files\Zycore
52 |
53 |
54 | Header Files\Zycore
55 |
56 |
57 | Header Files\Zydis
58 |
59 |
60 | Header Files\Zydis
61 |
62 |
63 | Header Files\Zydis
64 |
65 |
66 | Header Files\Zydis
67 |
68 |
69 | Header Files\Zydis
70 |
71 |
72 | Header Files\Zydis
73 |
74 |
75 | Header Files\Zydis
76 |
77 |
78 | Header Files\Zydis
79 |
80 |
81 | Header Files\Zydis
82 |
83 |
84 | Header Files\Zydis
85 |
86 |
87 | Header Files\Zydis
88 |
89 |
90 |
91 |
92 | Source Files
93 |
94 |
95 |
--------------------------------------------------------------------------------
/ThirdParty/zydis/msvc/tools/ZydisDisasm.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {664BBE0B-918F-3B41-8D06-1875B10A7BE5}
6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {54CFF9CE-5525-3FCE-8ECE-9A26FB686F56}
10 | h;hh;hpp;hxx;hm;inl;inc;xsd
11 |
12 |
13 | {349C208E-6013-4B2A-86D4-F5CBD4C9B359}
14 |
15 |
16 | {599A7DB6-1F45-4378-90DD-94C11D46EC4D}
17 |
18 |
19 |
20 |
21 | Source Files
22 |
23 |
24 |
25 |
26 | Header Files\Zycore
27 |
28 |
29 | Header Files\Zycore
30 |
31 |
32 | Header Files\Zycore
33 |
34 |
35 | Header Files\Zycore
36 |
37 |
38 | Header Files\Zycore
39 |
40 |
41 | Header Files\Zycore
42 |
43 |
44 | Header Files\Zycore
45 |
46 |
47 | Header Files\Zycore
48 |
49 |
50 | Header Files\Zycore
51 |
52 |
53 | Header Files\Zycore
54 |
55 |
56 | Header Files\Zycore
57 |
58 |
59 | Header Files\Zycore
60 |
61 |
62 | Header Files\Zydis
63 |
64 |
65 | Header Files\Zydis
66 |
67 |
68 | Header Files\Zydis
69 |
70 |
71 | Header Files\Zydis
72 |
73 |
74 | Header Files\Zydis
75 |
76 |
77 | Header Files\Zydis
78 |
79 |
80 | Header Files\Zydis
81 |
82 |
83 | Header Files\Zydis
84 |
85 |
86 | Header Files\Zydis
87 |
88 |
89 | Header Files\Zydis
90 |
91 |
92 | Header Files\Zydis
93 |
94 |
95 |
--------------------------------------------------------------------------------
/ThirdParty/zydis/msvc/tools/ZydisFuzzDecoder.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {664BBE0B-918F-3B41-8D06-1875B10A7BE5}
6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {54CFF9CE-5525-3FCE-8ECE-9A26FB686F56}
10 | h;hh;hpp;hxx;hm;inl;inc;xsd
11 |
12 |
13 | {48794B8D-2E4F-4E2F-901F-77F8CB177A92}
14 |
15 |
16 | {B4E29716-3340-4942-8633-40107E569597}
17 |
18 |
19 |
20 |
21 | Source Files
22 |
23 |
24 | Source Files
25 |
26 |
27 |
28 |
29 | Header Files\Zycore
30 |
31 |
32 | Header Files\Zycore
33 |
34 |
35 | Header Files\Zycore
36 |
37 |
38 | Header Files\Zycore
39 |
40 |
41 | Header Files\Zycore
42 |
43 |
44 | Header Files\Zycore
45 |
46 |
47 | Header Files\Zycore
48 |
49 |
50 | Header Files\Zycore
51 |
52 |
53 | Header Files\Zycore
54 |
55 |
56 | Header Files\Zycore
57 |
58 |
59 | Header Files\Zycore
60 |
61 |
62 | Header Files\Zycore
63 |
64 |
65 | Header Files\Zydis
66 |
67 |
68 | Header Files\Zydis
69 |
70 |
71 | Header Files\Zydis
72 |
73 |
74 | Header Files\Zydis
75 |
76 |
77 | Header Files\Zydis
78 |
79 |
80 | Header Files\Zydis
81 |
82 |
83 | Header Files\Zydis
84 |
85 |
86 | Header Files\Zydis
87 |
88 |
89 | Header Files\Zydis
90 |
91 |
92 | Header Files\Zydis
93 |
94 |
95 | Header Files\Zydis
96 |
97 |
98 | Header Files
99 |
100 |
101 |
--------------------------------------------------------------------------------
/ThirdParty/zydis/msvc/tools/ZydisFuzzEncoder.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {D3B81AAA-C6A9-4CE0-A5EB-E1FD6758EE93}
6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {396D88C6-04D9-48FF-866A-F85639EEED75}
10 | h;hh;hpp;hxx;hm;inl;inc;xsd
11 |
12 |
13 | {0BC19CB7-62BB-4806-BBE9-1A194DF875CF}
14 |
15 |
16 | {CE45509B-FA47-4A58-95DD-20485A689F1C}
17 |
18 |
19 |
20 |
21 | Source Files
22 |
23 |
24 | Source Files
25 |
26 |
27 |
28 |
29 | Header Files\Zycore
30 |
31 |
32 | Header Files\Zycore
33 |
34 |
35 | Header Files\Zycore
36 |
37 |
38 | Header Files\Zycore
39 |
40 |
41 | Header Files\Zycore
42 |
43 |
44 | Header Files\Zycore
45 |
46 |
47 | Header Files\Zycore
48 |
49 |
50 | Header Files\Zycore
51 |
52 |
53 | Header Files\Zycore
54 |
55 |
56 | Header Files\Zycore
57 |
58 |
59 | Header Files\Zycore
60 |
61 |
62 | Header Files\Zycore
63 |
64 |
65 | Header Files\Zydis
66 |
67 |
68 | Header Files\Zydis
69 |
70 |
71 | Header Files\Zydis
72 |
73 |
74 | Header Files\Zydis
75 |
76 |
77 | Header Files\Zydis
78 |
79 |
80 | Header Files\Zydis
81 |
82 |
83 | Header Files\Zydis
84 |
85 |
86 | Header Files\Zydis
87 |
88 |
89 | Header Files\Zydis
90 |
91 |
92 | Header Files\Zydis
93 |
94 |
95 | Header Files\Zydis
96 |
97 |
98 | Header Files
99 |
100 |
101 |
--------------------------------------------------------------------------------
/ThirdParty/zydis/msvc/tools/ZydisFuzzReEncoding.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {A0F8EAF9-228A-4DC6-AE0F-5388ED752F93}
6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {3F150437-2A8C-4E05-BDE1-9A7DA665343C}
10 | h;hh;hpp;hxx;hm;inl;inc;xsd
11 |
12 |
13 | {3649A1F6-474A-472D-9799-83D46C13C12E}
14 |
15 |
16 | {CAF313CF-5C34-4BD9-82B7-86713B3B9B74}
17 |
18 |
19 |
20 |
21 | Source Files
22 |
23 |
24 | Source Files
25 |
26 |
27 |
28 |
29 | Header Files\Zycore
30 |
31 |
32 | Header Files\Zycore
33 |
34 |
35 | Header Files\Zycore
36 |
37 |
38 | Header Files\Zycore
39 |
40 |
41 | Header Files\Zycore
42 |
43 |
44 | Header Files\Zycore
45 |
46 |
47 | Header Files\Zycore
48 |
49 |
50 | Header Files\Zycore
51 |
52 |
53 | Header Files\Zycore
54 |
55 |
56 | Header Files\Zycore
57 |
58 |
59 | Header Files\Zycore
60 |
61 |
62 | Header Files\Zycore
63 |
64 |
65 | Header Files\Zydis
66 |
67 |
68 | Header Files\Zydis
69 |
70 |
71 | Header Files\Zydis
72 |
73 |
74 | Header Files\Zydis
75 |
76 |
77 | Header Files\Zydis
78 |
79 |
80 | Header Files\Zydis
81 |
82 |
83 | Header Files\Zydis
84 |
85 |
86 | Header Files\Zydis
87 |
88 |
89 | Header Files\Zydis
90 |
91 |
92 | Header Files\Zydis
93 |
94 |
95 | Header Files\Zydis
96 |
97 |
98 | Header Files
99 |
100 |
101 |
--------------------------------------------------------------------------------
/ThirdParty/zydis/msvc/tools/ZydisInfo.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {664BBE0B-918F-3B41-8D06-1875B10A7BE5}
6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {54CFF9CE-5525-3FCE-8ECE-9A26FB686F56}
10 | h;hh;hpp;hxx;hm;inl;inc;xsd
11 |
12 |
13 | {2C8FA06C-89F9-4D92-8182-B42C1D5E459D}
14 |
15 |
16 | {1314C403-E579-49B8-9A96-4C9483FBB054}
17 |
18 |
19 |
20 |
21 | Source Files
22 |
23 |
24 |
25 |
26 | Header Files\Zycore
27 |
28 |
29 | Header Files\Zycore
30 |
31 |
32 | Header Files\Zycore
33 |
34 |
35 | Header Files\Zycore
36 |
37 |
38 | Header Files\Zycore
39 |
40 |
41 | Header Files\Zycore
42 |
43 |
44 | Header Files\Zycore
45 |
46 |
47 | Header Files\Zycore
48 |
49 |
50 | Header Files\Zycore
51 |
52 |
53 | Header Files\Zycore
54 |
55 |
56 | Header Files\Zycore
57 |
58 |
59 | Header Files\Zycore
60 |
61 |
62 | Header Files\Zydis
63 |
64 |
65 | Header Files\Zydis
66 |
67 |
68 | Header Files\Zydis
69 |
70 |
71 | Header Files\Zydis
72 |
73 |
74 | Header Files\Zydis
75 |
76 |
77 | Header Files\Zydis
78 |
79 |
80 | Header Files\Zydis
81 |
82 |
83 | Header Files\Zydis
84 |
85 |
86 | Header Files\Zydis
87 |
88 |
89 | Header Files\Zydis
90 |
91 |
92 | Header Files\Zydis
93 |
94 |
95 |
--------------------------------------------------------------------------------
/ThirdParty/zydis/resources/VersionInfo.rc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Inori/TinyDBR/6be0a1317c6a03d888289424a65197800299fec8/ThirdParty/zydis/resources/VersionInfo.rc
--------------------------------------------------------------------------------
/ThirdParty/zydis/src/EncoderData.c:
--------------------------------------------------------------------------------
1 | /***************************************************************************************************
2 |
3 | Zyan Disassembler Library (Zydis)
4 |
5 | Original Author : Mappa
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 | #include
30 |
31 | ZyanU8 ZydisGetEncodableInstructions(ZydisMnemonic mnemonic,
32 | const ZydisEncodableInstruction **instruction)
33 | {
34 | if (mnemonic <= ZYDIS_MNEMONIC_INVALID || mnemonic > ZYDIS_MNEMONIC_MAX_VALUE)
35 | {
36 | *instruction = ZYAN_NULL;
37 | return 0;
38 | }
39 | ZydisEncoderLookupEntry lookup_entry = encoder_instruction_lookup[mnemonic];
40 | *instruction = &encoder_instructions[lookup_entry.encoder_reference];
41 | return lookup_entry.instruction_count;
42 | }
43 |
--------------------------------------------------------------------------------
/ThirdParty/zydis/src/Generated/AccessedFlags.inc:
--------------------------------------------------------------------------------
1 | #ifndef ZYDIS_MINIMAL_MODE
2 | static const ZydisDefinitionAccessedFlags ACCESSED_FLAGS[] =
3 | {
4 | { { 0x0, 0x0, 0x0, 0x0, 0x0 }, { 0x0, 0x0, 0x0, 0x0, 0x0 } },
5 | { { 0x0, 0x0, 0x0, 0x0, 0x0 }, { 0x0, 0xF, 0x0, 0x0, 0x0 } },
6 | { { 0x0, 0x0, 0x0, 0x0, 0x0 }, { 0x0, 0x6, 0x0, 0x0, 0x9 } },
7 | { { 0x0, 0x0, 0x0, 0x0, 0x0 }, { 0x0, 0x2, 0x0, 0x0, 0xD } },
8 | { { 0x0, 0x0, 0x0, 0x0, 0x0 }, { 0x0, 0x0, 0x0, 0x0, 0xF } },
9 | { { 0x0, 0x0, 0x40000, 0x0, 0x0 }, { 0x0, 0x0, 0x0, 0x0, 0x0 } },
10 | { { 0x0, 0x0, 0x0, 0x40000, 0x0 }, { 0x0, 0x0, 0x0, 0x0, 0x0 } },
11 | { { 0x1000, 0x0, 0x0, 0x0, 0x0 }, { 0x0, 0x0, 0x0, 0x0, 0x0 } },
12 | { { 0x800, 0x0, 0x0, 0x0, 0x0 }, { 0x0, 0x0, 0x0, 0x0, 0x0 } },
13 | { { 0x800, 0x800, 0x0, 0x0, 0x0 }, { 0x0, 0x0, 0x0, 0x0, 0x0 } },
14 | { { 0x400, 0x0, 0x0, 0x0, 0x0 }, { 0x0, 0x0, 0x0, 0x0, 0x0 } },
15 | { { 0x1400, 0x0, 0x0, 0x0, 0x0 }, { 0x0, 0x0, 0x0, 0x0, 0x0 } },
16 | { { 0x0, 0x0, 0x400, 0x0, 0x0 }, { 0x0, 0x0, 0x0, 0x0, 0x0 } },
17 | { { 0x0, 0x0, 0x0, 0x400, 0x0 }, { 0x0, 0x0, 0x0, 0x0, 0x0 } },
18 | { { 0x1000, 0x80200, 0x0, 0x0, 0x0 }, { 0x0, 0x0, 0x0, 0x0, 0x0 } },
19 | { { 0x0, 0x0, 0x30200, 0x0, 0x0 }, { 0x0, 0x0, 0x0, 0x0, 0x0 } },
20 | { { 0x21800, 0x64300, 0x10000, 0x0, 0x0 }, { 0x0, 0x0, 0x0, 0x0, 0x0 } },
21 | { { 0x21000, 0xE4200, 0x10100, 0x0, 0x0 }, { 0x0, 0x0, 0x0, 0x0, 0x0 } },
22 | { { 0x80, 0x0, 0x0, 0x0, 0x0 }, { 0x0, 0x0, 0x0, 0x0, 0x0 } },
23 | { { 0x880, 0x0, 0x0, 0x0, 0x0 }, { 0x0, 0x0, 0x0, 0x0, 0x0 } },
24 | { { 0x40, 0x0, 0x0, 0x0, 0x0 }, { 0x0, 0x0, 0x0, 0x0, 0x0 } },
25 | { { 0x40, 0x0, 0x0, 0x0, 0x0 }, { 0x0, 0x2, 0x0, 0x0, 0xD } },
26 | { { 0x8C0, 0x0, 0x0, 0x0, 0x0 }, { 0x0, 0x0, 0x0, 0x0, 0x0 } },
27 | { { 0x0, 0x40, 0x0, 0x0, 0x0 }, { 0x0, 0x0, 0x0, 0x0, 0x0 } },
28 | { { 0x4, 0x0, 0x0, 0x0, 0x0 }, { 0x0, 0x0, 0x0, 0x0, 0x0 } },
29 | { { 0x4, 0x0, 0x0, 0x0, 0x0 }, { 0x0, 0x2, 0x0, 0x0, 0xD } },
30 | { { 0x0, 0x8D4, 0x0, 0x0, 0x0 }, { 0x0, 0x0, 0x0, 0x0, 0x0 } },
31 | { { 0x1, 0x0, 0x0, 0x0, 0x0 }, { 0x0, 0x0, 0x0, 0x0, 0x0 } },
32 | { { 0x1, 0x0, 0x0, 0x0, 0x0 }, { 0x0, 0x2, 0x0, 0x0, 0xD } },
33 | { { 0x41, 0x0, 0x0, 0x0, 0x0 }, { 0x0, 0x0, 0x0, 0x0, 0x0 } },
34 | { { 0x41, 0x0, 0x0, 0x0, 0x0 }, { 0x0, 0x2, 0x0, 0x0, 0xD } },
35 | { { 0xD5, 0x0, 0x0, 0x0, 0x0 }, { 0x0, 0x0, 0x0, 0x0, 0x0 } },
36 | { { 0x3F5FD5, 0x0, 0x0, 0x0, 0x0 }, { 0x0, 0x0, 0x0, 0x0, 0x0 } },
37 | { { 0x1, 0x1, 0x0, 0x0, 0x0 }, { 0x0, 0x0, 0x0, 0x0, 0x0 } },
38 | { { 0x1, 0x1, 0x0, 0x0, 0x800 }, { 0x0, 0x0, 0x0, 0x0, 0x0 } },
39 | { { 0x11, 0xD5, 0x0, 0x0, 0x800 }, { 0x0, 0x0, 0x0, 0x0, 0x0 } },
40 | { { 0x1, 0x8D5, 0x0, 0x0, 0x0 }, { 0x0, 0x0, 0x0, 0x0, 0x0 } },
41 | { { 0x1, 0x8C5, 0x0, 0x0, 0x10 }, { 0x0, 0x0, 0x0, 0x0, 0x0 } },
42 | { { 0x0, 0x1, 0x0, 0x0, 0x0 }, { 0x0, 0x0, 0x0, 0x0, 0x0 } },
43 | { { 0x0, 0x1, 0x0, 0x0, 0x800 }, { 0x0, 0x0, 0x0, 0x0, 0x0 } },
44 | { { 0x0, 0x41, 0x0, 0x0, 0x0 }, { 0x0, 0x0, 0x0, 0x0, 0x0 } },
45 | { { 0x440, 0x8D5, 0x0, 0x0, 0x0 }, { 0x0, 0x0, 0x0, 0x0, 0x0 } },
46 | { { 0x0, 0xD5, 0x0, 0x0, 0x0 }, { 0x0, 0x0, 0x0, 0x0, 0x0 } },
47 | { { 0x0, 0x8D5, 0x0, 0x0, 0x0 }, { 0x0, 0x0, 0x0, 0x0, 0x0 } },
48 | { { 0x400, 0x8D5, 0x0, 0x0, 0x0 }, { 0x0, 0x0, 0x0, 0x0, 0x0 } },
49 | { { 0x25000, 0x3F5FD5, 0x0, 0x0, 0x0 }, { 0x0, 0x0, 0x0, 0x0, 0x0 } },
50 | { { 0x21000, 0x3D5FD5, 0x0, 0x0, 0x0 }, { 0x0, 0x0, 0x0, 0x0, 0x0 } },
51 | { { 0x121000, 0x2C5FD5, 0x10000, 0x0, 0x0 }, { 0x0, 0x0, 0x0, 0x0, 0x0 } },
52 | { { 0x0, 0x3F5FD5, 0x0, 0x0, 0x0 }, { 0x0, 0x0, 0x0, 0x0, 0x0 } },
53 | { { 0x0, 0x3C5FD5, 0x10000, 0x0, 0x0 }, { 0x0, 0x0, 0x0, 0x0, 0x0 } },
54 | { { 0x0, 0x3C5FD5, 0x30000, 0x0, 0x0 }, { 0x0, 0x0, 0x0, 0x0, 0x0 } },
55 | { { 0x0, 0x45, 0x890, 0x0, 0x0 }, { 0x0, 0x0, 0x0, 0x0, 0x0 } },
56 | { { 0x0, 0x45, 0x890, 0x0, 0x0 }, { 0x0, 0x2, 0x0, 0x0, 0x0 } },
57 | { { 0x0, 0xC5, 0x0, 0x0, 0x810 }, { 0x0, 0x0, 0x0, 0x0, 0x0 } },
58 | { { 0x0, 0x8C1, 0x14, 0x0, 0x0 }, { 0x0, 0x0, 0x0, 0x0, 0x0 } },
59 | { { 0x0, 0x41, 0x894, 0x0, 0x0 }, { 0x0, 0x0, 0x0, 0x0, 0x0 } },
60 | { { 0x0, 0x1, 0x8D4, 0x0, 0x0 }, { 0x0, 0x0, 0x0, 0x0, 0x0 } },
61 | { { 0x10, 0x11, 0x0, 0x0, 0x8C4 }, { 0x0, 0x0, 0x0, 0x0, 0x0 } },
62 | { { 0x0, 0x1, 0x0, 0x0, 0x894 }, { 0x0, 0x0, 0x0, 0x0, 0x0 } },
63 | { { 0x0, 0xC1, 0x800, 0x0, 0x14 }, { 0x0, 0x0, 0x0, 0x0, 0x0 } },
64 | { { 0x0, 0x41, 0x0, 0x0, 0x894 }, { 0x0, 0x0, 0x0, 0x0, 0x0 } },
65 | { { 0x0, 0x81, 0x840, 0x0, 0x14 }, { 0x0, 0x0, 0x0, 0x0, 0x0 } },
66 | { { 0x0, 0x801, 0x0, 0x0, 0xD4 }, { 0x0, 0x0, 0x0, 0x0, 0x0 } },
67 | { { 0x0, 0x0, 0x1, 0x0, 0x0 }, { 0x0, 0x0, 0x0, 0x0, 0x0 } },
68 | { { 0x0, 0xC4, 0x801, 0x0, 0x10 }, { 0x0, 0x0, 0x0, 0x0, 0x0 } },
69 | { { 0x0, 0x40, 0x895, 0x0, 0x0 }, { 0x0, 0x0, 0x0, 0x0, 0x0 } },
70 | { { 0x0, 0x0, 0x8D5, 0x0, 0x0 }, { 0x0, 0x0, 0x0, 0x0, 0x0 } },
71 | { { 0x0, 0xC0, 0x801, 0x0, 0x14 }, { 0x0, 0x0, 0x0, 0x0, 0x0 } },
72 | { { 0x0, 0x40, 0x801, 0x0, 0x94 }, { 0x0, 0x0, 0x0, 0x0, 0x0 } },
73 | { { 0x0, 0x0, 0x0, 0x1, 0x0 }, { 0x0, 0x0, 0x0, 0x0, 0x0 } },
74 | { { 0x0, 0xC4, 0x0, 0x0, 0x811 }, { 0x0, 0x0, 0x0, 0x0, 0x0 } },
75 | { { 0x0, 0x40, 0x0, 0x0, 0x895 }, { 0x0, 0x0, 0x0, 0x0, 0x0 } },
76 | { { 0x0, 0x0, 0x0, 0x0, 0x8D5 }, { 0x0, 0x0, 0x0, 0x0, 0x0 } }
77 | };
78 | #endif
79 |
--------------------------------------------------------------------------------
/ThirdParty/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 | "AVX_VNNI",
19 | "BASE",
20 | "BMI1",
21 | "BMI2",
22 | "CET",
23 | "CLDEMOTE",
24 | "CLFLUSHOPT",
25 | "CLFSH",
26 | "CLWB",
27 | "CLZERO",
28 | "ENQCMD",
29 | "F16C",
30 | "FMA",
31 | "FMA4",
32 | "GFNI",
33 | "HRESET",
34 | "INVPCID",
35 | "KEYLOCKER",
36 | "KEYLOCKER_WIDE",
37 | "KNC",
38 | "KNCE",
39 | "KNCV",
40 | "LONGMODE",
41 | "LZCNT",
42 | "MCOMMIT",
43 | "MMX",
44 | "MONITOR",
45 | "MONITORX",
46 | "MOVBE",
47 | "MOVDIR",
48 | "MPX",
49 | "PADLOCK",
50 | "PAUSE",
51 | "PCLMULQDQ",
52 | "PCONFIG",
53 | "PKU",
54 | "PREFETCHWT1",
55 | "PT",
56 | "RDPID",
57 | "RDPRU",
58 | "RDRAND",
59 | "RDSEED",
60 | "RDTSCP",
61 | "RDWRFSGS",
62 | "RTM",
63 | "SERIALIZE",
64 | "SGX",
65 | "SGX_ENCLV",
66 | "SHA",
67 | "SMAP",
68 | "SMX",
69 | "SNP",
70 | "SSE",
71 | "SSE2",
72 | "SSE3",
73 | "SSE4",
74 | "SSE4A",
75 | "SSSE3",
76 | "SVM",
77 | "TBM",
78 | "TDX",
79 | "TSX_LDTRK",
80 | "UINTR",
81 | "VAES",
82 | "VMFUNC",
83 | "VPCLMULQDQ",
84 | "VTX",
85 | "WAITPKG",
86 | "X87",
87 | "XOP",
88 | "XSAVE",
89 | "XSAVEC",
90 | "XSAVEOPT",
91 | "XSAVES"
92 | };
93 |
--------------------------------------------------------------------------------
/ThirdParty/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_FP16_128",
47 | "AVX512_FP16_128N",
48 | "AVX512_FP16_256",
49 | "AVX512_FP16_512",
50 | "AVX512_FP16_SCALAR",
51 | "AVX512_GFNI_128",
52 | "AVX512_GFNI_256",
53 | "AVX512_GFNI_512",
54 | "AVX512_IFMA_128",
55 | "AVX512_IFMA_256",
56 | "AVX512_IFMA_512",
57 | "AVX512_VAES_128",
58 | "AVX512_VAES_256",
59 | "AVX512_VAES_512",
60 | "AVX512_VBMI2_128",
61 | "AVX512_VBMI2_256",
62 | "AVX512_VBMI2_512",
63 | "AVX512_VBMI_128",
64 | "AVX512_VBMI_256",
65 | "AVX512_VBMI_512",
66 | "AVX512_VNNI_128",
67 | "AVX512_VNNI_256",
68 | "AVX512_VNNI_512",
69 | "AVX512_VP2INTERSECT_128",
70 | "AVX512_VP2INTERSECT_256",
71 | "AVX512_VP2INTERSECT_512",
72 | "AVX512_VPCLMULQDQ_128",
73 | "AVX512_VPCLMULQDQ_256",
74 | "AVX512_VPCLMULQDQ_512",
75 | "AVX512_VPOPCNTDQ_128",
76 | "AVX512_VPOPCNTDQ_256",
77 | "AVX512_VPOPCNTDQ_512",
78 | "AVXAES",
79 | "AVX_GFNI",
80 | "AVX_VNNI",
81 | "BMI1",
82 | "BMI2",
83 | "CET",
84 | "CLDEMOTE",
85 | "CLFLUSHOPT",
86 | "CLFSH",
87 | "CLWB",
88 | "CLZERO",
89 | "CMOV",
90 | "CMPXCHG16B",
91 | "ENQCMD",
92 | "F16C",
93 | "FAT_NOP",
94 | "FCMOV",
95 | "FMA",
96 | "FMA4",
97 | "FXSAVE",
98 | "FXSAVE64",
99 | "GFNI",
100 | "HRESET",
101 | "I186",
102 | "I286PROTECTED",
103 | "I286REAL",
104 | "I386",
105 | "I486",
106 | "I486REAL",
107 | "I86",
108 | "INVPCID",
109 | "KEYLOCKER",
110 | "KEYLOCKER_WIDE",
111 | "KNCE",
112 | "KNCJKBR",
113 | "KNCSTREAM",
114 | "KNCV",
115 | "KNC_MISC",
116 | "KNC_PF_HINT",
117 | "LAHF",
118 | "LONGMODE",
119 | "LWP",
120 | "LZCNT",
121 | "MCOMMIT",
122 | "MONITOR",
123 | "MONITORX",
124 | "MOVBE",
125 | "MOVDIR",
126 | "MPX",
127 | "PADLOCK_ACE",
128 | "PADLOCK_PHE",
129 | "PADLOCK_PMM",
130 | "PADLOCK_RNG",
131 | "PAUSE",
132 | "PCLMULQDQ",
133 | "PCONFIG",
134 | "PENTIUMMMX",
135 | "PENTIUMREAL",
136 | "PKU",
137 | "POPCNT",
138 | "PPRO",
139 | "PREFETCHWT1",
140 | "PREFETCH_NOP",
141 | "PT",
142 | "RDPID",
143 | "RDPMC",
144 | "RDPRU",
145 | "RDRAND",
146 | "RDSEED",
147 | "RDTSCP",
148 | "RDWRFSGS",
149 | "RTM",
150 | "SERIALIZE",
151 | "SGX",
152 | "SGX_ENCLV",
153 | "SHA",
154 | "SMAP",
155 | "SMX",
156 | "SSE",
157 | "SSE2",
158 | "SSE2MMX",
159 | "SSE3",
160 | "SSE3X87",
161 | "SSE4",
162 | "SSE42",
163 | "SSE4A",
164 | "SSEMXCSR",
165 | "SSE_PREFETCH",
166 | "SSSE3",
167 | "SSSE3MMX",
168 | "SVM",
169 | "TBM",
170 | "TDX",
171 | "TSX_LDTRK",
172 | "UINTR",
173 | "VAES",
174 | "VMFUNC",
175 | "VPCLMULQDQ",
176 | "VTX",
177 | "WAITPKG",
178 | "X87",
179 | "XOP",
180 | "XSAVE",
181 | "XSAVEC",
182 | "XSAVEOPT",
183 | "XSAVES"
184 | };
185 |
--------------------------------------------------------------------------------
/ThirdParty/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 | "FP16",
42 | "GATHER",
43 | "GFNI",
44 | "HRESET",
45 | "IFMA",
46 | "INTERRUPT",
47 | "IO",
48 | "IOSTRINGOP",
49 | "KEYLOCKER",
50 | "KEYLOCKER_WIDE",
51 | "KMASK",
52 | "KNC",
53 | "KNCMASK",
54 | "KNCSCALAR",
55 | "LEGACY",
56 | "LOGICAL",
57 | "LOGICAL_FP",
58 | "LZCNT",
59 | "MISC",
60 | "MMX",
61 | "MOVDIR",
62 | "MPX",
63 | "NOP",
64 | "PADLOCK",
65 | "PCLMULQDQ",
66 | "PCONFIG",
67 | "PKU",
68 | "POP",
69 | "PREFETCH",
70 | "PREFETCHWT1",
71 | "PT",
72 | "PUSH",
73 | "RDPID",
74 | "RDPRU",
75 | "RDRAND",
76 | "RDSEED",
77 | "RDWRFSGS",
78 | "RET",
79 | "ROTATE",
80 | "SCATTER",
81 | "SEGOP",
82 | "SEMAPHORE",
83 | "SERIALIZE",
84 | "SETCC",
85 | "SGX",
86 | "SHA",
87 | "SHIFT",
88 | "SMAP",
89 | "SSE",
90 | "STRINGOP",
91 | "STTNI",
92 | "SYSCALL",
93 | "SYSRET",
94 | "SYSTEM",
95 | "TBM",
96 | "TSX_LDTRK",
97 | "UFMA",
98 | "UINTR",
99 | "UNCOND_BR",
100 | "VAES",
101 | "VBMI2",
102 | "VEX",
103 | "VFMA",
104 | "VPCLMULQDQ",
105 | "VTX",
106 | "WAITPKG",
107 | "WIDENOP",
108 | "X87_ALU",
109 | "XOP",
110 | "XSAVE",
111 | "XSAVEOPT"
112 | };
113 |
--------------------------------------------------------------------------------
/ThirdParty/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_FALSE, ZYAN_FALSE }, { { 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 |
--------------------------------------------------------------------------------
/ThirdParty/zydis/src/Generated/RegisterClassLookup.inc:
--------------------------------------------------------------------------------
1 | static const ZydisRegisterClassLookupItem REG_CLASS_LOOKUP[] =
2 | {
3 | /* INVALID */ { ZYDIS_REGISTER_NONE, ZYDIS_REGISTER_NONE, 0, 0 },
4 | /* GPR8 */ { ZYDIS_REGISTER_AL, ZYDIS_REGISTER_R15B, 8, 8 },
5 | /* GPR16 */ { ZYDIS_REGISTER_AX, ZYDIS_REGISTER_R15W, 16, 16 },
6 | /* GPR32 */ { ZYDIS_REGISTER_EAX, ZYDIS_REGISTER_R15D, 32, 32 },
7 | /* GPR64 */ { ZYDIS_REGISTER_RAX, ZYDIS_REGISTER_R15, 0, 64 },
8 | /* X87 */ { ZYDIS_REGISTER_ST0, ZYDIS_REGISTER_ST7, 80, 80 },
9 | /* MMX */ { ZYDIS_REGISTER_MM0, ZYDIS_REGISTER_MM7, 64, 64 },
10 | /* XMM */ { ZYDIS_REGISTER_XMM0, ZYDIS_REGISTER_XMM31, 128, 128 },
11 | /* YMM */ { ZYDIS_REGISTER_YMM0, ZYDIS_REGISTER_YMM31, 256, 256 },
12 | /* ZMM */ { ZYDIS_REGISTER_ZMM0, ZYDIS_REGISTER_ZMM31, 512, 512 },
13 | /* TMM */ { ZYDIS_REGISTER_TMM0, ZYDIS_REGISTER_TMM7, 8192, 8192 },
14 | /* FLAGS */ { ZYDIS_REGISTER_NONE, ZYDIS_REGISTER_NONE, 0, 0 },
15 | /* IP */ { ZYDIS_REGISTER_NONE, ZYDIS_REGISTER_NONE, 0, 0 },
16 | /* SEGMENT */ { ZYDIS_REGISTER_ES, ZYDIS_REGISTER_GS, 16, 16 },
17 | /* TABLE */ { ZYDIS_REGISTER_NONE, ZYDIS_REGISTER_NONE, 0, 0 },
18 | /* TEST */ { ZYDIS_REGISTER_TR0, ZYDIS_REGISTER_TR7, 32, 32 },
19 | /* CONTROL */ { ZYDIS_REGISTER_CR0, ZYDIS_REGISTER_CR15, 32, 64 },
20 | /* DEBUG */ { ZYDIS_REGISTER_DR0, ZYDIS_REGISTER_DR15, 32, 64 },
21 | /* MASK */ { ZYDIS_REGISTER_K0, ZYDIS_REGISTER_K7, 64, 64 },
22 | /* BOUND */ { ZYDIS_REGISTER_BND0, ZYDIS_REGISTER_BND3, 128, 128 }
23 | };
24 |
--------------------------------------------------------------------------------
/ThirdParty/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 |
--------------------------------------------------------------------------------
/ThirdParty/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 |
--------------------------------------------------------------------------------
/ThirdParty/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_ENCODER:
49 | #ifndef ZYDIS_DISABLE_ENCODER
50 | return ZYAN_STATUS_TRUE;
51 | #else
52 | return ZYAN_STATUS_FALSE;
53 | #endif
54 | case ZYDIS_FEATURE_FORMATTER:
55 | #ifndef ZYDIS_DISABLE_FORMATTER
56 | return ZYAN_STATUS_TRUE;
57 | #else
58 | return ZYAN_STATUS_FALSE;
59 | #endif
60 | case ZYDIS_FEATURE_AVX512:
61 | #ifndef ZYDIS_DISABLE_AVX512
62 | return ZYAN_STATUS_TRUE;
63 | #else
64 | return ZYAN_STATUS_FALSE;
65 | #endif
66 |
67 | case ZYDIS_FEATURE_KNC:
68 | #ifndef ZYDIS_DISABLE_KNC
69 | return ZYAN_STATUS_TRUE;
70 | #else
71 | return ZYAN_STATUS_FALSE;
72 | #endif
73 |
74 | default:
75 | return ZYAN_STATUS_INVALID_ARGUMENT;
76 | }
77 | }
78 |
79 | /* ============================================================================================== */
80 |
--------------------------------------------------------------------------------
/ThirdParty/zydis/tools/ZydisFuzzReEncoding.c:
--------------------------------------------------------------------------------
1 | /***************************************************************************************************
2 |
3 | Zyan Disassembler Library (Zydis)
4 |
5 | Original Author : Mappa
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 | *
30 | * This file implements fuzz target for re-encoding. Fuzzer input is passed to decoder first and if
31 | * it decodes as a valid instruction `ZydisEncoderDecodedInstructionToEncoderRequest` is used to
32 | * create encoder request which gets passed to the encoder.
33 | */
34 |
35 | #include "ZydisFuzzShared.h"
36 |
37 | /* ============================================================================================== */
38 | /* Enums and types */
39 | /* ============================================================================================== */
40 |
41 | /**
42 | * Structure for fuzzing decoder inputs.
43 | */
44 | typedef struct ZydisFuzzControlBlock_
45 | {
46 | ZydisMachineMode machine_mode;
47 | ZydisStackWidth stack_width;
48 | } ZydisFuzzControlBlock;
49 |
50 | /* ============================================================================================== */
51 | /* Fuzz target */
52 | /* ============================================================================================== */
53 |
54 | ZYAN_NO_SANITIZE("enum")
55 | int ZydisFuzzTarget(ZydisStreamRead read_fn, void *stream_ctx)
56 | {
57 | ZydisFuzzControlBlock control_block;
58 | if (read_fn(
59 | stream_ctx, (ZyanU8 *)&control_block, sizeof(control_block)) != sizeof(control_block))
60 | {
61 | ZYDIS_MAYBE_FPUTS("Not enough bytes to fuzz\n", ZYAN_STDERR);
62 | return EXIT_SUCCESS;
63 | }
64 |
65 | ZydisDecoder decoder;
66 | if (!ZYAN_SUCCESS(ZydisDecoderInit(&decoder, control_block.machine_mode,
67 | control_block.stack_width)))
68 | {
69 | ZYDIS_MAYBE_FPUTS("Failed to initialize decoder\n", ZYAN_STDERR);
70 | return EXIT_FAILURE;
71 | }
72 |
73 | ZyanU8 buffer[32];
74 | ZyanUSize input_len = read_fn(stream_ctx, buffer, sizeof(buffer));
75 |
76 | ZydisDecodedInstruction insn1;
77 | ZydisDecodedOperand operands1[ZYDIS_MAX_OPERAND_COUNT];
78 | ZyanStatus status = ZydisDecoderDecodeFull(&decoder, buffer, input_len, &insn1, operands1,
79 | ZYDIS_MAX_OPERAND_COUNT, 0);
80 | if (!ZYAN_SUCCESS(status))
81 | {
82 | return EXIT_FAILURE;
83 | }
84 |
85 | ZydisReEncodeInstruction(&decoder, &insn1, operands1, insn1.operand_count_visible, buffer);
86 |
87 | return EXIT_SUCCESS;
88 | }
89 |
90 | /* ============================================================================================== */
91 |
--------------------------------------------------------------------------------
/ThirdParty/zydis/tools/ZydisFuzzShared.h:
--------------------------------------------------------------------------------
1 | /***************************************************************************************************
2 |
3 | Zyan Disassembler Library (Zydis)
4 |
5 | Original Author : Mappa
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 | #ifndef ZYDIS_FUZZSHARED_H
28 | #define ZYDIS_FUZZSHARED_H
29 |
30 | #include
31 | #include
32 | #include
33 | #include
34 | #include
35 |
36 | /* ============================================================================================== */
37 | /* Enums and types */
38 | /* ============================================================================================== */
39 |
40 | typedef ZyanUSize(*ZydisStreamRead)(void *ctx, ZyanU8 *buf, ZyanUSize max_len);
41 |
42 | /* ============================================================================================== */
43 | /* Macros */
44 | /* ============================================================================================== */
45 |
46 | #if defined(ZYDIS_FUZZ_AFL_FAST) || defined(ZYDIS_LIBFUZZER)
47 | # define ZYDIS_MAYBE_FPUTS(x, y)
48 | #else
49 | # define ZYDIS_MAYBE_FPUTS(x, y) fputs(x, y)
50 | #endif
51 |
52 | // Existing tools and seed corpora depend on this heavily
53 | enum ZyanEnumSizeCheck_ { ZYAN_ENUM_SIZE_CHECK = 1 };
54 | ZYAN_STATIC_ASSERT(sizeof(enum ZyanEnumSizeCheck_) == 4);
55 |
56 | #define ZYDIS_SANITIZE_MASK(var, type, type_size, mask) \
57 | var = (type)((ZyanU##type_size)(var) & (mask))
58 | #define ZYDIS_SANITIZE_MASK32(var, type, mask) ZYDIS_SANITIZE_MASK(var, type, 32, mask)
59 | #define ZYDIS_SANITIZE_MASK64(var, type, mask) ZYDIS_SANITIZE_MASK(var, type, 64, mask)
60 | #define ZYDIS_SANITIZE_ENUM(var, type, max_value) var = (type)((ZyanUSize)(ZyanU32)(var) % \
61 | (max_value + 1))
62 |
63 | /* ============================================================================================== */
64 | /* Function declarations */
65 | /* ============================================================================================== */
66 |
67 | #if defined(ZYDIS_FUZZ_AFL_FAST) || defined(ZYDIS_LIBFUZZER)
68 |
69 | #define ZydisPrintInstruction(...)
70 |
71 | #else
72 |
73 | void ZydisPrintInstruction(const ZydisDecodedInstruction *instruction,
74 | const ZydisDecodedOperand* operands, ZyanU8 operand_count, const ZyanU8 *instruction_bytes);
75 |
76 | #endif
77 |
78 | void ZydisValidateEnumRanges(const ZydisDecodedInstruction* insn,
79 | const ZydisDecodedOperand* operands, ZyanU8 operand_count);
80 | void ZydisValidateInstructionIdentity(const ZydisDecodedInstruction* insn1,
81 | const ZydisDecodedOperand* operands1, const ZydisDecodedInstruction* insn2,
82 | const ZydisDecodedOperand* operands2);
83 | void ZydisReEncodeInstruction(const ZydisDecoder* decoder, const ZydisDecodedInstruction* insn1,
84 | const ZydisDecodedOperand* operands1, ZyanU8 operand_count, const ZyanU8 *insn1_bytes);
85 |
86 | // One `ZydisFuzzTarget` must be defined for every fuzz target project
87 | extern int ZydisFuzzTarget(ZydisStreamRead read_fn, void *stream_ctx);
88 |
89 | /* ============================================================================================== */
90 |
91 | #endif /* ZYDIS_FUZZSHARED_H */
92 |
--------------------------------------------------------------------------------
/TinyDBR.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 16
4 | VisualStudioVersion = 16.0.32002.261
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TinyDBR", "TinyDBR\TinyDBR.vcxproj", "{2C3AD807-FE99-4595-941C-9F45B22D8C21}"
7 | EndProject
8 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ThirdParty", "ThirdParty", "{E0F5F7A3-7655-4AD8-A252-CB49B646E7F4}"
9 | EndProject
10 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ShellcodeSample", "ShellcodeSample\ShellcodeSample.vcxproj", "{07997D2A-7B10-4C8D-AAD6-849569F6DA8F}"
11 | EndProject
12 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Translator", "Translator\Translator.vcxproj", "{282E10E2-9C33-401E-8254-90D6127E1EA6}"
13 | ProjectSection(ProjectDependencies) = postProject
14 | {2C3AD807-FE99-4595-941C-9F45B22D8C21} = {2C3AD807-FE99-4595-941C-9F45B22D8C21}
15 | EndProjectSection
16 | EndProject
17 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Zycore", "ThirdParty\zydis\msvc\dependencies\zycore\Zycore.vcxproj", "{E06E2E87-82B9-4DC2-A1E9-FE371CDBAAC2}"
18 | EndProject
19 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Zydis", "ThirdParty\zydis\msvc\zydis\Zydis.vcxproj", "{88A23124-5640-35A0-B890-311D7A67A7D2}"
20 | EndProject
21 | Global
22 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
23 | Debug|x64 = Debug|x64
24 | Debug|x86 = Debug|x86
25 | Release|x64 = Release|x64
26 | Release|x86 = Release|x86
27 | EndGlobalSection
28 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
29 | {2C3AD807-FE99-4595-941C-9F45B22D8C21}.Debug|x64.ActiveCfg = Debug|x64
30 | {2C3AD807-FE99-4595-941C-9F45B22D8C21}.Debug|x64.Build.0 = Debug|x64
31 | {2C3AD807-FE99-4595-941C-9F45B22D8C21}.Debug|x86.ActiveCfg = Debug|Win32
32 | {2C3AD807-FE99-4595-941C-9F45B22D8C21}.Debug|x86.Build.0 = Debug|Win32
33 | {2C3AD807-FE99-4595-941C-9F45B22D8C21}.Release|x64.ActiveCfg = Release|x64
34 | {2C3AD807-FE99-4595-941C-9F45B22D8C21}.Release|x64.Build.0 = Release|x64
35 | {2C3AD807-FE99-4595-941C-9F45B22D8C21}.Release|x86.ActiveCfg = Release|Win32
36 | {2C3AD807-FE99-4595-941C-9F45B22D8C21}.Release|x86.Build.0 = Release|Win32
37 | {07997D2A-7B10-4C8D-AAD6-849569F6DA8F}.Debug|x64.ActiveCfg = Debug|x64
38 | {07997D2A-7B10-4C8D-AAD6-849569F6DA8F}.Debug|x64.Build.0 = Debug|x64
39 | {07997D2A-7B10-4C8D-AAD6-849569F6DA8F}.Debug|x86.ActiveCfg = Debug|Win32
40 | {07997D2A-7B10-4C8D-AAD6-849569F6DA8F}.Debug|x86.Build.0 = Debug|Win32
41 | {07997D2A-7B10-4C8D-AAD6-849569F6DA8F}.Release|x64.ActiveCfg = Release|x64
42 | {07997D2A-7B10-4C8D-AAD6-849569F6DA8F}.Release|x64.Build.0 = Release|x64
43 | {07997D2A-7B10-4C8D-AAD6-849569F6DA8F}.Release|x86.ActiveCfg = Release|Win32
44 | {07997D2A-7B10-4C8D-AAD6-849569F6DA8F}.Release|x86.Build.0 = Release|Win32
45 | {282E10E2-9C33-401E-8254-90D6127E1EA6}.Debug|x64.ActiveCfg = Debug|x64
46 | {282E10E2-9C33-401E-8254-90D6127E1EA6}.Debug|x64.Build.0 = Debug|x64
47 | {282E10E2-9C33-401E-8254-90D6127E1EA6}.Debug|x86.ActiveCfg = Debug|Win32
48 | {282E10E2-9C33-401E-8254-90D6127E1EA6}.Debug|x86.Build.0 = Debug|Win32
49 | {282E10E2-9C33-401E-8254-90D6127E1EA6}.Release|x64.ActiveCfg = Release|x64
50 | {282E10E2-9C33-401E-8254-90D6127E1EA6}.Release|x64.Build.0 = Release|x64
51 | {282E10E2-9C33-401E-8254-90D6127E1EA6}.Release|x86.ActiveCfg = Release|Win32
52 | {282E10E2-9C33-401E-8254-90D6127E1EA6}.Release|x86.Build.0 = Release|Win32
53 | {E06E2E87-82B9-4DC2-A1E9-FE371CDBAAC2}.Debug|x64.ActiveCfg = Debug|x64
54 | {E06E2E87-82B9-4DC2-A1E9-FE371CDBAAC2}.Debug|x64.Build.0 = Debug|x64
55 | {E06E2E87-82B9-4DC2-A1E9-FE371CDBAAC2}.Debug|x86.ActiveCfg = Debug|Win32
56 | {E06E2E87-82B9-4DC2-A1E9-FE371CDBAAC2}.Debug|x86.Build.0 = Debug|Win32
57 | {E06E2E87-82B9-4DC2-A1E9-FE371CDBAAC2}.Release|x64.ActiveCfg = Release|x64
58 | {E06E2E87-82B9-4DC2-A1E9-FE371CDBAAC2}.Release|x64.Build.0 = Release|x64
59 | {E06E2E87-82B9-4DC2-A1E9-FE371CDBAAC2}.Release|x86.ActiveCfg = Release|Win32
60 | {E06E2E87-82B9-4DC2-A1E9-FE371CDBAAC2}.Release|x86.Build.0 = Release|Win32
61 | {88A23124-5640-35A0-B890-311D7A67A7D2}.Debug|x64.ActiveCfg = Debug|x64
62 | {88A23124-5640-35A0-B890-311D7A67A7D2}.Debug|x64.Build.0 = Debug|x64
63 | {88A23124-5640-35A0-B890-311D7A67A7D2}.Debug|x86.ActiveCfg = Debug|Win32
64 | {88A23124-5640-35A0-B890-311D7A67A7D2}.Debug|x86.Build.0 = Debug|Win32
65 | {88A23124-5640-35A0-B890-311D7A67A7D2}.Release|x64.ActiveCfg = Release|x64
66 | {88A23124-5640-35A0-B890-311D7A67A7D2}.Release|x64.Build.0 = Release|x64
67 | {88A23124-5640-35A0-B890-311D7A67A7D2}.Release|x86.ActiveCfg = Release|Win32
68 | {88A23124-5640-35A0-B890-311D7A67A7D2}.Release|x86.Build.0 = Release|Win32
69 | EndGlobalSection
70 | GlobalSection(SolutionProperties) = preSolution
71 | HideSolutionNode = FALSE
72 | EndGlobalSection
73 | GlobalSection(NestedProjects) = preSolution
74 | {E06E2E87-82B9-4DC2-A1E9-FE371CDBAAC2} = {E0F5F7A3-7655-4AD8-A252-CB49B646E7F4}
75 | {88A23124-5640-35A0-B890-311D7A67A7D2} = {E0F5F7A3-7655-4AD8-A252-CB49B646E7F4}
76 | EndGlobalSection
77 | GlobalSection(ExtensibilityGlobals) = postSolution
78 | SolutionGuid = {F3F0C001-05F8-45CB-B495-931311907306}
79 | EndGlobalSection
80 | EndGlobal
81 |
--------------------------------------------------------------------------------
/TinyDBR/TinyDBR.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {8f9832fc-1414-4d81-b003-33dff4b2f7cd}
6 |
7 |
8 | {32411f08-95d7-4b93-8968-82481ea2eb30}
9 |
10 |
11 | {54174657-5e77-46aa-96ad-6e73fc4b89fd}
12 |
13 |
14 | {07f12266-7b6f-43c0-ad66-279c9d4b8331}
15 |
16 |
17 |
18 |
19 | Source Files\windows
20 |
21 |
22 | Source Files\windows
23 |
24 |
25 | Source Files
26 |
27 |
28 | Source Files
29 |
30 |
31 | Source Files\arch\x86
32 |
33 |
34 | Source Files\arch\x86
35 |
36 |
37 | Source Files\windows
38 |
39 |
40 | Source Files\windows
41 |
42 |
43 | Source Files\arch\x86
44 |
45 |
46 | Source Files
47 |
48 |
49 |
50 |
51 | Source Files\windows
52 |
53 |
54 | Source Files\windows
55 |
56 |
57 | Source Files
58 |
59 |
60 | Source Files
61 |
62 |
63 | Source Files
64 |
65 |
66 | Source Files
67 |
68 |
69 | Source Files
70 |
71 |
72 | Source Files\arch\x86
73 |
74 |
75 | Source Files\arch\x86
76 |
77 |
78 | Source Files\arch\x86
79 |
80 |
81 | Source Files\windows
82 |
83 |
84 | Source Files\windows
85 |
86 |
87 | Source Files
88 |
89 |
90 | Source Files\arch\x86
91 |
92 |
93 |
--------------------------------------------------------------------------------
/TinyDBR/arch/x86/reg.h:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2021 Google LLC
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | https ://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 |
17 | #ifndef ARCH_X86_REG_H
18 | #define ARCH_X86_REG_H
19 |
20 | #define ARCH_SP RSP
21 | #define ARCH_PC RIP
22 | #define ARCH_RETURN_VALUE_REGISTER RAX
23 | #define ARCH_PC RIP
24 | #define ORIG_ADDR_REG RAX
25 |
26 | enum Register {
27 | RAX,
28 | RCX,
29 | RDX,
30 | RBX,
31 | RSP,
32 | RBP,
33 | RSI,
34 | RDI,
35 | R8,
36 | R9,
37 | R10,
38 | R11,
39 | R12,
40 | R13,
41 | R14,
42 | R15,
43 | RIP
44 | };
45 |
46 | #endif // ARCH_X86_REG_H
47 |
--------------------------------------------------------------------------------
/TinyDBR/arch/x86/x86_assembler.h:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2021 Google LLC
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | https ://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 |
17 | #ifndef ARCH_X86_X86_ASSEMBLER_H
18 | #define ARCH_X86_X86_ASSEMBLER_H
19 |
20 | #include "assembler.h"
21 | #include "tinydbr.h"
22 |
23 | class X86Assembler : public Assembler
24 | {
25 | public:
26 | using Assembler::Assembler;
27 | virtual ~X86Assembler();
28 |
29 | void Init() override;
30 |
31 | bool DecodeInstruction(Instruction& inst,
32 | const unsigned char* buffer,
33 | unsigned int buffer_size) override;
34 | void FixInstructionAndOutput(ModuleInfo* module,
35 | Instruction& inst,
36 | const unsigned char* input,
37 | const unsigned char* input_address_remote,
38 | bool convert_call_to_jmp = false) override;
39 | void HandleBasicBlockEnd(
40 | const char* address,
41 | ModuleInfo* module,
42 | std::set* queue,
43 | std::list>* offset_fixes,
44 | Instruction& inst,
45 | const char* code_ptr,
46 | size_t offset,
47 | size_t last_offset) override;
48 |
49 | void JmpAddress(ModuleInfo* module, size_t address) override;
50 | void Nop(ModuleInfo* module) override;
51 | void Breakpoint(ModuleInfo* module) override;
52 | void Crash(ModuleInfo* module) override;
53 |
54 | void OffsetStack(ModuleInfo* module, int32_t offset) override;
55 | bool IsRipRelative(ModuleInfo* module,
56 | Instruction& inst,
57 | size_t instruction_address,
58 | size_t* mem_address = nullptr) override;
59 | bool IsRspRelative(Instruction& inst,
60 | size_t* displacement = nullptr) override;
61 | void TranslateJmp(ModuleInfo* module,
62 | ModuleInfo* target_module,
63 | size_t original_target,
64 | IndirectBreakpoinInfo& breakpoint_info,
65 | bool global_indirect,
66 | size_t previous_offset) override;
67 | void InstrumentLocalIndirect(ModuleInfo* module,
68 | Instruction& inst,
69 | size_t instruction_address,
70 | size_t bb_address) override;
71 | void InstrumentGlobalIndirect(ModuleInfo* module,
72 | Instruction& inst,
73 | size_t instruction_address) override;
74 | void FixOffset(ModuleInfo* module,
75 | uint32_t jmp_offset,
76 | uint32_t target_offset) override;
77 |
78 |
79 | void PrintInstruction(const Instruction& inst) override;
80 |
81 | private:
82 | inline void FixDisp4(ModuleInfo* module, int32_t disp);
83 | void ReadStack(ModuleInfo* module, int32_t offset);
84 | void WriteStack(ModuleInfo* module, int32_t offset);
85 | void MovIndirectTarget(ModuleInfo* module,
86 | Instruction& inst,
87 | size_t original_address,
88 | int32_t stack_offset);
89 |
90 | void InstrumentRet(ModuleInfo* module,
91 | Instruction& inst,
92 | size_t instruction_address,
93 | TinyDBR::IndirectInstrumentation mode,
94 | size_t bb_address);
95 | void PushReturnAddress(ModuleInfo* module, uint64_t return_address);
96 |
97 | const ZydisDecodedOperand* FindExplicitMemoryOperand(
98 | const Instruction& inst,
99 | size_t* index = nullptr);
100 | bool IsIndirectBranch(Instruction& inst);
101 |
102 | private:
103 | ZydisDecoder decoder;
104 | #ifdef _DEBUG
105 | ZydisFormatter formatter;
106 | #endif // _DEBUG
107 | };
108 |
109 | #endif // ARCH_X86_X86_ASSEMBLER_H
110 |
--------------------------------------------------------------------------------
/TinyDBR/assembler.h:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2021 Google LLC
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | https ://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 |
17 | #ifndef ASSEMBLER_H
18 | #define ASSEMBLER_H
19 |
20 | #include
21 | #include
22 | #include
23 |
24 | #include "instruction.h"
25 |
26 | struct IndirectBreakpoinInfo;
27 | class TinyDBR;
28 | class ModuleInfo;
29 |
30 | class Assembler {
31 | public:
32 | Assembler(TinyDBR &tinyinst) : tinyinst_(tinyinst) {}
33 | virtual ~Assembler() = default;
34 |
35 | virtual void Init() = 0;
36 |
37 | virtual bool DecodeInstruction(Instruction &inst,
38 | const unsigned char *address,
39 | unsigned int max_size) = 0;
40 | virtual void FixInstructionAndOutput(
41 | ModuleInfo *module,
42 | Instruction &inst,
43 | const unsigned char *input,
44 | const unsigned char *input_address_remote,
45 | bool convert_call_to_jmp = false) = 0;
46 | virtual void HandleBasicBlockEnd(
47 | const char *address, ModuleInfo *module,
48 | std::set *queue,
49 | std::list> *offset_fixes,
50 | Instruction &inst,
51 | const char *code_ptr,
52 | size_t offset,
53 | size_t last_offset) = 0;
54 |
55 | virtual void JmpAddress(ModuleInfo *module, size_t address) = 0;
56 | virtual void Nop(ModuleInfo *module) = 0;
57 | virtual void Breakpoint(ModuleInfo *module) = 0;
58 | virtual void Crash(ModuleInfo *module) = 0;
59 |
60 | virtual void OffsetStack(ModuleInfo *module, int32_t offset) = 0;
61 |
62 | virtual bool IsRipRelative(ModuleInfo* module,
63 | Instruction& inst,
64 | size_t instruction_address,
65 | size_t* mem_address = nullptr) = 0;
66 | virtual bool IsRspRelative(Instruction& inst,
67 | size_t* displacement = nullptr) = 0;
68 |
69 | virtual void TranslateJmp(ModuleInfo *module,
70 | ModuleInfo *target_module,
71 | size_t original_target,
72 | IndirectBreakpoinInfo& breakpoint_info,
73 | bool global_indirect,
74 | size_t previous_offset) = 0;
75 | virtual void InstrumentLocalIndirect(ModuleInfo *module,
76 | Instruction &inst,
77 | size_t instruction_address,
78 | size_t bb_address) = 0;
79 | virtual void InstrumentGlobalIndirect(ModuleInfo *module,
80 | Instruction &inst,
81 | size_t instruction_address) = 0;
82 | virtual void FixOffset(ModuleInfo *module,
83 | uint32_t jmp_offset,
84 | uint32_t target_offset) = 0;
85 |
86 | virtual void PrintInstruction(const Instruction& inst) = 0;
87 |
88 | protected:
89 | TinyDBR &tinyinst_;
90 | };
91 |
92 | #endif // ASSEMBLER_H
93 |
--------------------------------------------------------------------------------
/TinyDBR/common.h:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2020 Google LLC
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | https ://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 |
17 | #ifndef COMMON_H
18 | #define COMMON_H
19 |
20 | #include
21 | #include
22 | #include
23 | #include
24 | #include
25 | #include
26 |
27 |
28 |
29 | enum {
30 | /* 00 */ FAULT_NONE,
31 | /* 01 */ FAULT_TMOUT,
32 | /* 02 */ FAULT_CRASH,
33 | /* 03 */ FAULT_ERROR,
34 | /* 04 */ FAULT_NOINST,
35 | /* 05 */ FAULT_NOBITS
36 | };
37 |
38 | #ifdef _DEBUG
39 | #define DBG_BREAK __debugbreak()
40 | #else
41 | #define DBG_BREAK
42 | #endif
43 |
44 | #define SAY(...) printf(__VA_ARGS__)
45 |
46 | #define WARN(...) do { \
47 | SAY("[!] WARNING: " __VA_ARGS__); \
48 | SAY("\n"); \
49 | } while (0)
50 |
51 | #define FATAL(...) do { \
52 | SAY("[-] PROGRAM ABORT : " __VA_ARGS__); \
53 | SAY(" Location : %s(), %s:%u\n\n", \
54 | __FUNCTION__, __FILE__, __LINE__); \
55 | DBG_BREAK; \
56 | exit(1); \
57 | } while (0)
58 |
59 | #define USAGE_CHECK(condition, message) if(!(condition)) FATAL("%s\n", message);
60 |
61 | struct AddressRange
62 | {
63 | size_t from = 0;
64 | size_t to = 0;
65 | char* data = nullptr;
66 | };
67 |
68 | struct CodeSection
69 | {
70 | void* code;
71 | size_t size;
72 | };
73 |
74 | struct Options
75 | {
76 | bool shellcode_mode = false;
77 | bool trace_debug_events = false;
78 | bool instrument_modules_on_load = false;
79 | bool patch_return_addresses = false;
80 | bool instrument_cross_module_calls = true;
81 | bool persist_instrumentation_data = true;
82 | bool trace_basic_blocks = false;
83 | bool trace_module_entries = false;
84 | int32_t sp_offset = 0;
85 | bool generate_unwind = true;
86 | };
87 |
88 |
89 | struct TargetModule
90 | {
91 | // module name
92 | std::string name;
93 | // is main executable module.
94 | bool is_main = false;
95 | // is shellcode without module.
96 | bool is_shellcode = false;
97 | // only valid if is_shellcode is true.
98 | std::vector code_sections;
99 | };
100 |
101 | // gets time in milliseconds
102 | uint64_t GetCurTime(void);
103 |
104 | uint32_t GetCurTid(void);
105 |
106 | bool PauseResumeThreadList(uint32_t dwOwnerPID, bool bResumeThread);
107 |
108 | void* GetModuleEntrypoint(void* base_address);
109 |
110 | std::string UnicodeToAnsi(const std::wstring& wstr, unsigned int code_page);
111 |
112 |
113 | #endif
114 |
--------------------------------------------------------------------------------
/TinyDBR/instruction.h:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2021 Google LLC
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | https ://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 |
17 | #ifndef INSTRUCTION_H
18 | #define INSTRUCTION_H
19 |
20 | #ifdef ARM64
21 | #include "third_party/reil/reil/aarch64/decoder.h"
22 | #else
23 |
24 | #include
25 |
26 | struct ZydisInstruction
27 | {
28 | ZydisDecodedInstruction instruction;
29 | ZydisDecodedOperand operands[ZYDIS_MAX_OPERAND_COUNT];
30 | };
31 |
32 | #endif
33 |
34 | enum InstructionClass {
35 | INVALID = 0,
36 | RET,
37 | IJUMP,
38 | ICALL,
39 | OTHER,
40 | };
41 |
42 | struct Instruction
43 | {
44 | size_t address;
45 | size_t length;
46 | bool bbend;
47 | InstructionClass iclass;
48 |
49 | #ifdef ARM64
50 | reil::aarch64::decoder::Instruction instr;
51 | #else
52 | ZydisInstruction zinst;
53 | #endif
54 | Instruction() :
55 | address(0),
56 | length(0),
57 | bbend(false),
58 | iclass(InstructionClass::INVALID),
59 | #ifdef ARM64
60 | instr({})
61 | #else
62 | zinst({})
63 | #endif
64 | {
65 | }
66 | };
67 |
68 | #endif // INSTRUCTION_H
69 |
--------------------------------------------------------------------------------
/TinyDBR/memory_monitor.cpp:
--------------------------------------------------------------------------------
1 | #include "memory_monitor.h"
2 |
3 | MemoryCallback::~MemoryCallback()
4 | {
5 | }
6 |
7 |
8 | MemoryMonitor::MemoryMonitor(MonitorFlags flags, MemoryCallback* callback) :
9 | m_flags(flags),
10 | m_callback(callback)
11 | {
12 | }
13 |
14 | MemoryMonitor::~MemoryMonitor()
15 | {
16 | }
17 |
18 | void MemoryMonitor::OnMemoryRead(void* address, size_t size)
19 | {
20 | m_callback->OnMemoryRead(address, size);
21 | }
22 |
23 | void MemoryMonitor::OnMemoryWrite(void* address, size_t size)
24 | {
25 | m_callback->OnMemoryWrite(address, size);
26 | }
27 |
28 |
--------------------------------------------------------------------------------
/TinyDBR/memory_monitor.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include "tinydbr.h"
4 | #include
5 |
6 | enum MonitorFlag : uint64_t
7 | {
8 | IgnoreCode = 1 << 0, // e.g. call [0x1234], jmp [0x1234]
9 | IgnoreStack = 1 << 1, // e.g. mov rax, [rsp + 0x8]
10 | IgnoreRipRelative = 1 << 2, // e.g. mov rax, [rip + 0x8]
11 |
12 | // save processor extended states, e.g. xmm, ymm, fpu, mxcsr
13 | // before call into user callback.
14 | SaveExtendedState = 1 << 3, // this is a very costive operation which will slow down the program severely
15 | };
16 |
17 | typedef uint64_t MonitorFlags;
18 |
19 |
20 | // Library users should inherit this interface
21 | class MemoryCallback
22 | {
23 | public:
24 | virtual ~MemoryCallback();
25 |
26 | // memory read callback
27 | // this will be called before the read instruction,
28 | // so you can prepare the memory for the target program to read
29 | virtual void OnMemoryRead(void* address, size_t size) = 0;
30 |
31 | // memory write callback
32 | // this will be called after the write instruction
33 | // so you can get the memory content been written by the target program
34 | virtual void OnMemoryWrite(void* address, size_t size) = 0;
35 | };
36 |
37 |
38 |
39 | class MemoryMonitor : public TinyDBR
40 | {
41 |
42 | public:
43 | MemoryMonitor(MonitorFlags flags, MemoryCallback* callback);
44 | virtual ~MemoryMonitor();
45 |
46 | protected:
47 | // These functions will be called from generated assemble code.
48 |
49 | // memory read
50 | // this will be called before the read instruction
51 | void OnMemoryRead(void* address, size_t size);
52 |
53 | // memory write
54 | // this will be called after the write instruction
55 | void OnMemoryWrite(void* address, size_t size);
56 |
57 | protected:
58 | MonitorFlags m_flags = 0;
59 | MemoryCallback* m_callback;
60 | };
61 |
62 |
63 |
--------------------------------------------------------------------------------
/TinyDBR/unwind.h:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2021 Google LLC
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | https ://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 |
17 | #ifndef UNWIND_H
18 | #define UNWIND_H
19 |
20 |
21 | class TinyDBR;
22 | class ModuleInfo;
23 |
24 | class UnwindData {
25 | public:
26 | virtual ~UnwindData() = default;
27 | };
28 |
29 | class UnwindGenerator {
30 | public:
31 | UnwindGenerator(TinyDBR& tinyinst) : tinydbr_(tinyinst) {}
32 | virtual ~UnwindGenerator() = default;
33 |
34 | virtual void Init() {}
35 |
36 | virtual void OnModuleInstrumented(ModuleInfo* module) { }
37 | virtual void OnModuleUninstrumented(ModuleInfo* module) { }
38 |
39 | virtual size_t MaybeRedirectExecution(ModuleInfo* module, size_t IP, void* context) {
40 | return IP;
41 | }
42 |
43 | virtual void OnBasicBlockStart(ModuleInfo* module,
44 | size_t original_address,
45 | size_t translated_address)
46 | { }
47 |
48 | virtual void OnInstruction(ModuleInfo* module,
49 | size_t original_address,
50 | size_t translated_address)
51 | { }
52 |
53 | virtual void OnBasicBlockEnd(ModuleInfo* module,
54 | size_t original_address,
55 | size_t translated_address)
56 | { }
57 |
58 | virtual void OnModuleLoaded(void *module, char *module_name) { }
59 |
60 | virtual void OnReturnAddress(ModuleInfo *module, size_t original_address, size_t translated_address) { }
61 |
62 | virtual bool HandleBreakpoint(ModuleInfo* module, void* address, void* context)
63 | {
64 | return false;
65 | }
66 |
67 | virtual bool Is64BitOnly() { return false; }
68 |
69 | protected:
70 | TinyDBR& tinydbr_;
71 | };
72 |
73 | #endif // UNWIND_H
74 |
--------------------------------------------------------------------------------
/TinyDBR/windows/api_helper.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include "common.h"
4 | #include
5 | #include
6 |
7 | class Executor;
8 |
9 | class ApiHelper
10 | {
11 | public:
12 | ApiHelper(Executor& executor);
13 |
14 | virtual ~ApiHelper();
15 |
16 | virtual void ExtractAndProtectCodeRanges(
17 | void* module_base,
18 | size_t min_address,
19 | size_t max_address,
20 | std::list* executable_ranges,
21 | size_t* code_size);
22 |
23 | virtual void ProtectCodeRanges(
24 | std::list* executable_ranges);
25 |
26 | virtual uint32_t GetImageSize(void* base_address) = 0;
27 |
28 | virtual uint32_t GetProcOffset(void* module, const char* name) = 0;
29 |
30 | virtual void GetExceptionHandlers(
31 | size_t module_header, std::unordered_set& handlers) = 0;
32 |
33 | protected:
34 | Executor& m_executor;
35 | };
36 |
37 | ///////////////////////////////////////////////////////////////////
38 |
39 | class ModuleHelper : public ApiHelper
40 | {
41 | public:
42 | ModuleHelper(Executor& executor);
43 | virtual ~ModuleHelper();
44 |
45 | virtual uint32_t GetImageSize(void* base_address) override;
46 |
47 | virtual uint32_t GetProcOffset(void* module, const char* name) override;
48 |
49 | virtual void GetExceptionHandlers(
50 | size_t module_header, std::unordered_set& handlers) override;
51 |
52 | private:
53 | };
54 |
55 | ///////////////////////////////////////////////////////////////////
56 |
57 | class ShellcodeHelper : public ApiHelper
58 | {
59 | public:
60 | ShellcodeHelper(Executor& executor);
61 | virtual ~ShellcodeHelper();
62 |
63 | virtual uint32_t GetImageSize(void* base_address) override;
64 |
65 | virtual uint32_t GetProcOffset(void* module, const char* name) override;
66 |
67 | virtual void GetExceptionHandlers(
68 | size_t module_header, std::unordered_set& handlers) override;
69 |
70 | private:
71 | const TargetModule* GetModule(void* base_address);
72 | };
73 |
74 |
--------------------------------------------------------------------------------
/TinyDBR/windows/dllnotify.cpp:
--------------------------------------------------------------------------------
1 | #include "dllnotify.h"
2 |
3 | #ifndef STATUS_SUCCESS
4 | #define STATUS_SUCCESS 0
5 | #endif
6 |
7 | typedef NTSTATUS (NTAPI *PfuncLdrRegisterDllNotification)(
8 | ULONG Flags,
9 | PLDR_DLL_NOTIFICATION_FUNCTION NotificationFunction,
10 | PVOID Context,
11 | PVOID* Cookie);
12 |
13 | typedef NTSTATUS (NTAPI *PfuncLdrUnregisterDllNotification)(
14 | PVOID Cookie);
15 |
16 | PfuncLdrRegisterDllNotification LdrRegisterDllNotification = nullptr;
17 | PfuncLdrUnregisterDllNotification LdrUnregisterDllNotification = nullptr;
18 |
19 | void* InstallDllNotification(PLDR_DLL_NOTIFICATION_FUNCTION NotificationFunction, PVOID Context)
20 | {
21 | void* pCookie = nullptr;
22 | do
23 | {
24 | if (!LdrRegisterDllNotification)
25 | {
26 | HMODULE hNtdll = GetModuleHandleA("ntdll.dll");
27 | if (!hNtdll)
28 | {
29 | break;
30 | }
31 |
32 | LdrRegisterDllNotification = (PfuncLdrRegisterDllNotification)GetProcAddress(hNtdll, "LdrRegisterDllNotification");
33 | if (!LdrRegisterDllNotification)
34 | {
35 | break;
36 | }
37 | }
38 |
39 | NTSTATUS status = LdrRegisterDllNotification(0, NotificationFunction, Context, &pCookie);
40 | if (status != STATUS_SUCCESS)
41 | {
42 | break;
43 | }
44 |
45 | } while (false);
46 | return pCookie;
47 | }
48 |
49 | void UninstallDllNotification(void* Cookie)
50 | {
51 | do
52 | {
53 | if (!LdrUnregisterDllNotification)
54 | {
55 | HMODULE hNtdll = GetModuleHandleA("ntdll.dll");
56 | if (!hNtdll)
57 | {
58 | break;
59 | }
60 |
61 | LdrUnregisterDllNotification = (PfuncLdrUnregisterDllNotification)GetProcAddress(hNtdll, "LdrUnregisterDllNotification");
62 | if (!LdrUnregisterDllNotification)
63 | {
64 | break;
65 | }
66 | }
67 |
68 | LdrUnregisterDllNotification(Cookie);
69 | } while (false);
70 | }
71 |
--------------------------------------------------------------------------------
/TinyDBR/windows/dllnotify.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include
4 |
5 | typedef struct _UNICODE_STRING
6 | {
7 | USHORT Length;
8 | USHORT MaximumLength;
9 | PWSTR Buffer;
10 | } UNICODE_STRING, *PUNICODE_STRING;
11 | typedef const UNICODE_STRING* PCUNICODE_STRING;
12 |
13 | typedef struct _LDR_DLL_LOADED_NOTIFICATION_DATA
14 | {
15 | ULONG Flags; //Reserved.
16 | PCUNICODE_STRING FullDllName; //The full path name of the DLL module.
17 | PCUNICODE_STRING BaseDllName; //The base file name of the DLL module.
18 | PVOID DllBase; //A pointer to the base address for the DLL in memory.
19 | ULONG SizeOfImage; //The size of the DLL image, in bytes.
20 | } LDR_DLL_LOADED_NOTIFICATION_DATA, *PLDR_DLL_LOADED_NOTIFICATION_DATA;
21 |
22 | typedef struct _LDR_DLL_UNLOADED_NOTIFICATION_DATA
23 | {
24 | ULONG Flags; //Reserved.
25 | PCUNICODE_STRING FullDllName; //The full path name of the DLL module.
26 | PCUNICODE_STRING BaseDllName; //The base file name of the DLL module.
27 | PVOID DllBase; //A pointer to the base address for the DLL in memory.
28 | ULONG SizeOfImage; //The size of the DLL image, in bytes.
29 | } LDR_DLL_UNLOADED_NOTIFICATION_DATA, *PLDR_DLL_UNLOADED_NOTIFICATION_DATA;
30 |
31 | typedef union _LDR_DLL_NOTIFICATION_DATA
32 | {
33 | LDR_DLL_LOADED_NOTIFICATION_DATA Loaded;
34 | LDR_DLL_UNLOADED_NOTIFICATION_DATA Unloaded;
35 | } LDR_DLL_NOTIFICATION_DATA, *PLDR_DLL_NOTIFICATION_DATA;
36 | typedef const LDR_DLL_NOTIFICATION_DATA* PCLDR_DLL_NOTIFICATION_DATA;
37 |
38 | #define LDR_DLL_NOTIFICATION_REASON_LOADED 1
39 | #define LDR_DLL_NOTIFICATION_REASON_UNLOADED 2
40 |
41 | typedef VOID(CALLBACK* PLDR_DLL_NOTIFICATION_FUNCTION)(
42 | ULONG NotificationReason,
43 | PCLDR_DLL_NOTIFICATION_DATA NotificationData,
44 | PVOID Context);
45 |
46 |
47 | void* InstallDllNotification(PLDR_DLL_NOTIFICATION_FUNCTION NotificationFunction,
48 | PVOID Context);
49 |
50 | void UninstallDllNotification(void* Cookie);
--------------------------------------------------------------------------------
/Translator/Translator.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
15 |
16 |
17 |
18 |
19 | Source Files
20 |
21 |
22 |
--------------------------------------------------------------------------------
/Translator/main.cpp:
--------------------------------------------------------------------------------
1 | #include "tinydbr.h"
2 | #include "arch/x86/x86_memory_monitor.h"
3 |
4 | #include
5 | #include
6 | #include
7 | #include
8 | #include