├── .gitattributes ├── .github ├── FUNDING.yml └── workflows │ ├── doc.yml │ └── main.yml ├── .gitignore ├── .gitmodules ├── CMakeLists.txt ├── Doxyfile ├── Doxyfile.meson.in ├── LICENSE ├── Makefile ├── README.md ├── SECURITY.md ├── assets ├── amalgamate.py ├── img │ ├── logo-dark.svg │ └── logo-light.svg ├── porting-guide-v3-v4.md ├── porting-guide-v4-v5.md ├── screenshots │ ├── ZydisDisasm.png │ └── ZydisInfo.png └── version-bump-checklist.txt ├── cmake └── zydis-config.cmake.in ├── dependencies └── zycore.wrap ├── examples ├── Disassemble.c ├── DisassembleSimple.c ├── EncodeFromScratch.c ├── EncodeMov.c ├── Formatter01.c ├── Formatter02.c ├── Formatter03.c ├── README.md ├── RewriteCode.c ├── ZydisPerfTest.c ├── ZydisWinKernel.c └── meson.build ├── files.dox ├── include └── Zydis │ ├── Decoder.h │ ├── DecoderTypes.h │ ├── Defines.h │ ├── Disassembler.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 │ ├── Segment.h │ ├── SharedTypes.h │ ├── ShortString.h │ ├── Status.h │ ├── Utils.h │ └── Zydis.h ├── man ├── ZydisDisasm.1.ronn ├── ZydisInfo.1.ronn └── meson.build ├── meson.build ├── meson_options.txt ├── msvc ├── README.md ├── Zydis.sln ├── dependencies │ └── zycore │ │ ├── Zycore.vcxproj │ │ └── Zycore.vcxproj.filters ├── examples │ ├── Disassemble.vcxproj │ ├── Disassemble.vcxproj.filters │ ├── DisassembleSimple.vcxproj │ ├── DisassembleSimple.vcxproj.filters │ ├── EncodeFromScratch.vcxproj │ ├── EncodeFromScratch.vcxproj.filters │ ├── EncodeMov.vcxproj │ ├── EncodeMov.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 │ ├── ZydisTestEncoderAbsolute.vcxproj │ └── ZydisTestEncoderAbsolute.vcxproj.filters └── zydis │ ├── Zydis.vcxproj │ └── Zydis.vcxproj.filters ├── resources └── VersionInfo.rc ├── src ├── Decoder.c ├── DecoderData.c ├── Disassembler.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 │ ├── GetRelInfo.inc │ ├── InstructionDefinitions.inc │ ├── InstructionEncodings.inc │ ├── OperandDefinitions.inc │ ├── RegisterClassLookup.inc │ └── RegisterLookup.inc ├── MetaInfo.c ├── Mnemonic.c ├── Register.c ├── Segment.c ├── SharedData.c ├── String.c ├── Utils.c └── Zydis.c ├── subprojects ├── tests ├── binary_reader.py ├── binary_writer.py ├── cases │ ├── 3dnow_000.in │ ├── 3dnow_000.out │ ├── 3dnow_001.in │ ├── 3dnow_001.out │ ├── 3dnow_002.in │ ├── 3dnow_002.out │ ├── 3dnow_003.in │ ├── 3dnow_003.out │ ├── 3dnow_004.in │ ├── 3dnow_004.out │ ├── 3dnow_005.in │ ├── 3dnow_005.out │ ├── 3dnow_006.in │ ├── 3dnow_006.out │ ├── 3dnow_007.in │ ├── 3dnow_007.out │ ├── 3dnow_008.in │ ├── 3dnow_008.out │ ├── 3dnow_009.in │ ├── 3dnow_009.out │ ├── 3dnow_010.in │ ├── 3dnow_010.out │ ├── 3dnow_011.in │ ├── 3dnow_011.out │ ├── 3dnow_012.in │ ├── 3dnow_012.out │ ├── 3dnow_013.in │ ├── 3dnow_013.out │ ├── 3dnow_014.in │ ├── 3dnow_014.out │ ├── 3dnow_015.in │ ├── 3dnow_015.out │ ├── 3dnow_016.in │ ├── 3dnow_016.out │ ├── 3dnow_017.in │ ├── 3dnow_017.out │ ├── 3dnow_018.in │ ├── 3dnow_018.out │ ├── 3dnow_019.in │ ├── 3dnow_019.out │ ├── 3dnow_020.in │ ├── 3dnow_020.out │ ├── 3dnow_021.in │ ├── 3dnow_021.out │ ├── 3dnow_022.in │ ├── 3dnow_022.out │ ├── 3dnow_023.in │ ├── 3dnow_023.out │ ├── 3dnow_024.in │ ├── 3dnow_024.out │ ├── default_000.in │ ├── default_000.out │ ├── default_001.in │ ├── default_001.out │ ├── default_002.in │ ├── default_002.out │ ├── default_003.in │ ├── default_003.out │ ├── default_004.in │ ├── default_004.out │ ├── default_005.in │ ├── default_005.out │ ├── default_006.in │ ├── default_006.out │ ├── default_007.in │ ├── default_007.out │ ├── default_008.in │ ├── default_008.out │ ├── default_009.in │ ├── default_009.out │ ├── default_010.in │ ├── default_010.out │ ├── default_011.in │ ├── default_011.out │ ├── default_012.in │ ├── default_012.out │ ├── default_013.in │ ├── default_013.out │ ├── default_014.in │ ├── default_014.out │ ├── default_015.in │ ├── default_015.out │ ├── default_016.in │ ├── default_016.out │ ├── default_017.in │ ├── default_017.out │ ├── default_018.in │ ├── default_018.out │ ├── default_019.in │ ├── default_019.out │ ├── default_020.in │ ├── default_020.out │ ├── default_021.in │ ├── default_021.out │ ├── default_022.in │ ├── default_022.out │ ├── default_023.in │ ├── default_023.out │ ├── default_024.in │ ├── default_024.out │ ├── default_025.in │ ├── default_025.out │ ├── default_026.in │ ├── default_026.out │ ├── default_027.in │ ├── default_027.out │ ├── default_028.in │ ├── default_028.out │ ├── default_029.in │ ├── default_029.out │ ├── default_030.in │ ├── default_030.out │ ├── default_031.in │ ├── default_031.out │ ├── default_032.in │ ├── default_032.out │ ├── default_033.in │ ├── default_033.out │ ├── default_034.in │ ├── default_034.out │ ├── default_035.in │ ├── default_035.out │ ├── default_036.in │ ├── default_036.out │ ├── default_037.in │ ├── default_037.out │ ├── default_038.in │ ├── default_038.out │ ├── default_039.in │ ├── default_039.out │ ├── default_040.in │ ├── default_040.out │ ├── default_041.in │ ├── default_041.out │ ├── default_042.in │ ├── default_042.out │ ├── default_043.in │ ├── default_043.out │ ├── default_044.in │ ├── default_044.out │ ├── default_045.in │ ├── default_045.out │ ├── default_046.in │ ├── default_046.out │ ├── default_047.in │ ├── default_047.out │ ├── default_048.in │ ├── default_048.out │ ├── evex_000.in │ ├── evex_000.out │ ├── evex_001.in │ ├── evex_001.out │ ├── evex_002.in │ ├── evex_002.out │ ├── evex_003.in │ ├── evex_003.out │ ├── evex_004.in │ ├── evex_004.out │ ├── evex_005.in │ ├── evex_005.out │ ├── evex_006.in │ ├── evex_006.out │ ├── evex_007.in │ ├── evex_007.out │ ├── evex_008.in │ ├── evex_008.out │ ├── evex_009.in │ ├── evex_009.out │ ├── evex_010.in │ ├── evex_010.out │ ├── evex_011.in │ ├── evex_011.out │ ├── evex_012.in │ ├── evex_012.out │ ├── evex_013.in │ ├── evex_013.out │ ├── evex_014.in │ ├── evex_014.out │ ├── evex_015.in │ ├── evex_015.out │ ├── evex_016.in │ ├── evex_016.out │ ├── evex_017.in │ ├── evex_017.out │ ├── evex_018.in │ ├── evex_018.out │ ├── evex_019.in │ ├── evex_019.out │ ├── evex_020.in │ ├── evex_020.out │ ├── evex_021.in │ ├── evex_021.out │ ├── evex_022.in │ ├── evex_022.out │ ├── evex_023.in │ ├── evex_023.out │ ├── evex_024.in │ ├── evex_024.out │ ├── evex_025.in │ ├── evex_025.out │ ├── evex_026.in │ ├── evex_026.out │ ├── evex_027.in │ ├── evex_027.out │ ├── evex_028.in │ ├── evex_028.out │ ├── jmp_far_16.in │ ├── jmp_far_16.out │ ├── jmp_far_32.in │ ├── jmp_far_32.out │ ├── mvex_000.in │ ├── mvex_000.out │ ├── mvex_001.in │ ├── mvex_001.out │ ├── mvex_002.in │ ├── mvex_002.out │ ├── mvex_003.in │ ├── mvex_003.out │ ├── mvex_004.in │ ├── mvex_004.out │ ├── mvex_005.in │ ├── mvex_005.out │ ├── mvex_006.in │ ├── mvex_006.out │ ├── mvex_007.in │ ├── mvex_007.out │ ├── mvex_008.in │ ├── mvex_008.out │ ├── mvex_009.in │ ├── mvex_009.out │ ├── mvex_010.in │ ├── mvex_010.out │ ├── mvex_011.in │ ├── mvex_011.out │ ├── mvex_012.in │ ├── mvex_012.out │ ├── mvex_013.in │ ├── mvex_013.out │ ├── mvex_014.in │ ├── mvex_014.out │ ├── mvex_015.in │ ├── mvex_015.out │ ├── mvex_016.in │ ├── mvex_016.out │ ├── mvex_017.in │ ├── mvex_017.out │ ├── mvex_018.in │ ├── mvex_018.out │ ├── mvex_019.in │ ├── mvex_019.out │ ├── mvex_020.in │ ├── mvex_020.out │ ├── mvex_021.in │ ├── mvex_021.out │ ├── mvex_022.in │ ├── mvex_022.out │ ├── mvex_023.in │ ├── mvex_023.out │ ├── mvex_024.in │ ├── mvex_024.out │ ├── mvex_025.in │ ├── mvex_025.out │ ├── mvex_026.in │ ├── mvex_026.out │ ├── vexc4_000.in │ ├── vexc4_000.out │ ├── vexc4_001.in │ ├── vexc4_001.out │ ├── vexc4_002.in │ ├── vexc4_002.out │ ├── vexc4_003.in │ ├── vexc4_003.out │ ├── vexc4_004.in │ ├── vexc4_004.out │ ├── vexc4_005.in │ ├── vexc4_005.out │ ├── vexc4_006.in │ ├── vexc4_006.out │ ├── vexc4_007.in │ ├── vexc4_007.out │ ├── vexc4_008.in │ ├── vexc4_008.out │ ├── vexc4_009.in │ ├── vexc4_009.out │ ├── vexc4_010.in │ ├── vexc4_010.out │ ├── vexc4_011.in │ ├── vexc4_011.out │ ├── vexc4_012.in │ ├── vexc4_012.out │ ├── vexc4_013.in │ ├── vexc4_013.out │ ├── vexc4_014.in │ ├── vexc4_014.out │ ├── vexc4_015.in │ ├── vexc4_015.out │ ├── vexc4_016.in │ ├── vexc4_016.out │ ├── vexc4_017.in │ ├── vexc4_017.out │ ├── vexc4_018.in │ ├── vexc4_018.out │ ├── vexc4_019.in │ ├── vexc4_019.out │ ├── vexc4_020.in │ ├── vexc4_020.out │ ├── vexc4_021.in │ ├── vexc4_021.out │ ├── vexc4_022.in │ ├── vexc4_022.out │ ├── vexc4_023.in │ ├── vexc4_023.out │ ├── vexc4_024.in │ ├── vexc4_024.out │ ├── vexc4_025.in │ ├── vexc4_025.out │ ├── vexc4_026.in │ ├── vexc4_026.out │ ├── vexc4_027.in │ ├── vexc4_027.out │ ├── vexc5_000.in │ ├── vexc5_000.out │ ├── vexc5_001.in │ ├── vexc5_001.out │ ├── vexc5_002.in │ ├── vexc5_002.out │ ├── vexc5_003.in │ ├── vexc5_003.out │ ├── vexc5_004.in │ ├── vexc5_004.out │ ├── vexc5_005.in │ ├── vexc5_005.out │ ├── vexc5_006.in │ ├── vexc5_006.out │ ├── vexc5_007.in │ ├── vexc5_007.out │ ├── vexc5_008.in │ ├── vexc5_008.out │ ├── vexc5_009.in │ ├── vexc5_009.out │ ├── vexc5_010.in │ ├── vexc5_010.out │ ├── vexc5_011.in │ ├── vexc5_011.out │ ├── vexc5_012.in │ ├── vexc5_012.out │ ├── vexc5_013.in │ ├── vexc5_013.out │ ├── vexc5_014.in │ ├── vexc5_014.out │ ├── vexc5_015.in │ ├── vexc5_015.out │ ├── vexc5_016.in │ ├── vexc5_016.out │ ├── vexc5_017.in │ ├── vexc5_017.out │ ├── vexc5_018.in │ ├── vexc5_018.out │ ├── vexc5_019.in │ ├── vexc5_019.out │ ├── vexc5_020.in │ ├── vexc5_020.out │ ├── vexc5_021.in │ ├── vexc5_021.out │ ├── vexc5_022.in │ ├── vexc5_022.out │ ├── vexc5_023.in │ ├── vexc5_023.out │ ├── vexc5_024.in │ ├── vexc5_024.out │ ├── xop_000.in │ ├── xop_000.out │ ├── xop_001.in │ ├── xop_001.out │ ├── xop_002.in │ ├── xop_002.out │ ├── xop_003.in │ ├── xop_003.out │ ├── xop_004.in │ ├── xop_004.out │ ├── xop_005.in │ ├── xop_005.out │ ├── xop_006.in │ ├── xop_006.out │ ├── xop_007.in │ ├── xop_007.out │ ├── xop_008.in │ ├── xop_008.out │ ├── xop_009.in │ ├── xop_009.out │ ├── xop_010.in │ ├── xop_010.out │ ├── xop_011.in │ ├── xop_011.out │ ├── xop_012.in │ ├── xop_012.out │ ├── xop_013.in │ ├── xop_013.out │ ├── xop_014.in │ ├── xop_014.out │ ├── xop_015.in │ ├── xop_015.out │ ├── xop_016.in │ ├── xop_016.out │ ├── xop_017.in │ ├── xop_017.out │ ├── xop_018.in │ ├── xop_018.out │ ├── xop_019.in │ ├── xop_019.out │ ├── xop_020.in │ ├── xop_020.out │ ├── xop_021.in │ ├── xop_021.out │ ├── xop_022.in │ ├── xop_022.out │ ├── xop_023.in │ ├── xop_023.out │ ├── xop_024.in │ └── xop_024.out ├── crash_tool.py ├── enc_test_cases.json ├── meson.build ├── re_enc_test_cases.json ├── regression.py ├── regression_encoder.py └── zydis_encoder_types.py └── tools ├── ZydisDisasm.c ├── ZydisFuzzDecoder.c ├── ZydisFuzzEncoder.c ├── ZydisFuzzReEncoding.c ├── ZydisFuzzShared.c ├── ZydisFuzzShared.h ├── ZydisInfo.c ├── ZydisTestEncoderAbsolute.c ├── ZydisToolsShared.c ├── ZydisToolsShared.h └── meson.build /.gitattributes: -------------------------------------------------------------------------------- 1 | *.inc eol=lf encoding=utf-8 linguist-language=C 2 | *.h eof=lf encoding=utf-8 3 | *.c eof=lf encoding=utf-8 4 | *.py eof=lf encoding=utf-8 5 | *.md eof=lf encoding=utf-8 6 | 7 | -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | github: flobernd -------------------------------------------------------------------------------- /.github/workflows/doc.yml: -------------------------------------------------------------------------------- 1 | name: Doc 2 | 3 | on: 4 | push: 5 | branches: 6 | - master 7 | release: 8 | types: [published] 9 | 10 | jobs: 11 | build-and-publish-doc: 12 | name: Build and publish documentation 13 | runs-on: ubuntu-22.04 14 | 15 | steps: 16 | - name: Checkout 17 | uses: actions/checkout@v3 18 | with: 19 | submodules: recursive 20 | fetch-depth: 0 # fetch all branches and tags 21 | - name: Install doxygen 22 | run: | 23 | sudo apt-get install -y doxygen 24 | - name: Download & install zydoc 25 | run: | 26 | wget -O zydoc.tar.gz https://github.com/zyantific/zydoc/releases/download/v0.3.2/zydoc_v0.3.2_x86_64-unknown-linux-musl.tar.gz 27 | tar xfv zydoc.tar.gz 28 | mv zydoc /usr/local/bin 29 | - name: Clone Doxygen theme 30 | run: >- 31 | git clone 32 | --depth=1 --branch=v2.3.1 33 | https://github.com/jothepro/doxygen-awesome-css.git 34 | /tmp/doxy-theme 35 | - name: Generate documentation 36 | run: >- 37 | zydoc 38 | --repo . 39 | --output-dir doc.zydis.re 40 | --config-ref master 41 | --doxyfile ./Doxyfile 42 | --refs 'refs/heads/master' 43 | --refs 'refs/tags/.*' 44 | --exclude-refs 'refs/tags/v1.*' 45 | --extra-css /tmp/doxy-theme/doxygen-awesome.css 46 | --extra-css /tmp/doxy-theme/doxygen-awesome-sidebar-only.css 47 | - name: Publish documentation 48 | uses: cpina/github-action-push-to-another-repository@v1.5 49 | env: 50 | SSH_DEPLOY_KEY: ${{ secrets.DOCS_ZYDIS_RE_SSH_DEPLOY_KEY }} 51 | with: 52 | source-directory: 'doc.zydis.re' 53 | destination-github-username: 'zyantific' 54 | destination-repository-name: 'doc.zydis.re' 55 | user-name: zydis-doc-bot 56 | user-email: doc-bot@zydis.re 57 | target-branch: main 58 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | .vscode 3 | .idea 4 | .vs 5 | __pycache__ 6 | 7 | /build* 8 | /msvc/**/*.user 9 | /msvc/**/obj/ 10 | /msvc/**/bin/ 11 | /doc 12 | /cmake-build-debug 13 | /amalgamated-dist 14 | 15 | .cache 16 | compile_commands.json 17 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "dependencies/zycore"] 2 | path = dependencies/zycore 3 | url = https://github.com/zyantific/zycore-c 4 | -------------------------------------------------------------------------------- /Doxyfile: -------------------------------------------------------------------------------- 1 | # This file is also parsed by CMakelists.txt, please only add one option value 2 | # per line (i.e. do not split long lines with '\'), and only use '=' to set values 3 | 4 | PROJECT_NAME = Zydis 5 | PROJECT_NUMBER = v4.0.0 6 | OUTPUT_DIRECTORY = ./doc 7 | INPUT = ./include ./README.md ./files.dox 8 | JAVADOC_AUTOBRIEF = YES 9 | QT_AUTOBRIEF = YES 10 | OPTIMIZE_OUTPUT_FOR_C = YES 11 | TOC_INCLUDE_HEADINGS = 0 12 | EXTRACT_LOCAL_CLASSES = NO 13 | HIDE_SCOPE_NAMES = YES 14 | RECURSIVE = YES 15 | USE_MDFILE_AS_MAINPAGE = README.md 16 | GENERATE_LATEX = NO 17 | GENERATE_TREEVIEW = YES 18 | DISABLE_INDEX = NO 19 | FULL_SIDEBAR = NO 20 | EXTRACT_ALL = YES 21 | -------------------------------------------------------------------------------- /Doxyfile.meson.in: -------------------------------------------------------------------------------- 1 | @INCLUDE = "@TOP_SRCDIR@/Doxyfile" 2 | PROJECT_NUMBER = @VERSION@ 3 | PROJECT_BRIEF = "Zyan Disassembler Library" 4 | OUTPUT_DIRECTORY = "@TOP_BUILDDIR@/doc" 5 | STRIP_FROM_PATH = "@TOP_SRCDIR@" 6 | STRIP_FROM_INC_PATH = "@ZYCORE_INCLUDE_PATH@" 7 | INPUT = "@TOP_SRCDIR@/include" \ 8 | "@TOP_SRCDIR@/README.md" \ 9 | "@TOP_SRCDIR@/files.dox" 10 | EXAMPLE_PATH = "@TOP_SRCDIR@/examples" 11 | USE_MDFILE_AS_MAINPAGE = "@TOP_SRCDIR@/README.md" 12 | MACRO_EXPANSION = YES 13 | EXPAND_ONLY_PREDEF = YES 14 | INCLUDE_PATH = "@ZYCORE_INCLUDE_PATH@" 15 | PREDEFINED = @PREDEFINED@ 16 | EXPAND_AS_DEFINED = ZYAN_BITFIELD 17 | DOT_COMMON_ATTR = "fontname=\"sans-serif\",fontsize=10" 18 | DOT_EDGE_ATTR = "labelfontname=\"sans-serif\",labelfontsize=10" 19 | DOT_IMAGE_FORMAT = svg 20 | INTERACTIVE_SVG = YES 21 | HAVE_DOT = @HAVE_DOT@ 22 | DOT_MULTI_TARGETS = @HAVE_DOT_1_8_10@ 23 | DOT_PATH = "@DOT_PATH@" 24 | HTML_FORMULA_FORMAT = @HTML_FORMULA_FORMAT@ 25 | 26 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014-2024 Florian Bernd 4 | Copyright (c) 2014-2024 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 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: build configure install amalgamate clean test doc doc-plain doc-themed clangd 2 | 3 | BUILD_DIR ?= build 4 | CSS_DIR ?= ../doxygen-awesome-css 5 | 6 | build: configure 7 | cmake --build $(BUILD_DIR) -j$(nproc) 8 | 9 | configure: dependencies/zycore/CMakeLists.txt 10 | @if ! command -v cmake > /dev/null; then \ 11 | echo >&2 "ERROR: cmake is not installed. Please install it first."; \ 12 | fi 13 | cmake -B $(BUILD_DIR) -DZYDIS_BUILD_TESTS=ON 14 | 15 | install: build 16 | cmake --install $(BUILD_DIR) 17 | 18 | amalgamate: 19 | assets/amalgamate.py 20 | 21 | clean: 22 | rm -rf $(BUILD_DIR) 23 | rm -rf doc 24 | rm -rf amalgamated-dist 25 | 26 | test: build 27 | cd $(BUILD_DIR) && ctest 28 | 29 | doc: configure 30 | cmake --build $(BUILD_DIR) --target ZydisDoc 31 | 32 | clangd: 33 | CC=clang cmake -B $(BUILD_DIR)-clangd -DCMAKE_EXPORT_COMPILE_COMMANDS=1; \ 34 | cmake --build $(BUILD_DIR)-clangd -j && \ 35 | mv $(BUILD_DIR)-clangd/compile_commands.json . 36 | 37 | dependencies/zycore/CMakeLists.txt: 38 | @if ! command -v git > /dev/null; then \ 39 | echo >&2 -n "ERROR: git is not installed. Please either manually place all"; \ 40 | echo >&2 "dependencies in their respective paths or install git first."; \ 41 | exit 1; \ 42 | fi 43 | git submodule update --init --recursive 44 | -------------------------------------------------------------------------------- /SECURITY.md: -------------------------------------------------------------------------------- 1 | # Security Policy 2 | 3 | ## Reporting a Vulnerability 4 | 5 | Please report security issues to `joel@zyantific.com` -------------------------------------------------------------------------------- /assets/porting-guide-v4-v5.md: -------------------------------------------------------------------------------- 1 | # Porting Guide v4 -> v5 2 | 3 | ### Encoder 4 | 5 | - `ZydisRegisterGetLargestEnclosing` will now return the given register itself for registers that don't have 6 | an enclosing register. Previously it would return `ZYDIS_REGISTER_NONE` in these cases. 7 | - `ZydisEncoderDecodedInstructionToEncoderRequest` now expects exactly `instruction->operand_count_visible` to be 8 | passed, not `operand_count_visible` at maximum. Passing a lower value was previously allowed but didn't really 9 | make much sense at all. 10 | 11 | ### Decoder 12 | 13 | - `ZydisDecodedOperandImm` struct was changed 14 | - Added field `offset` 15 | - Contains the offset of the immediate data, relative to the beginning of the instruction, in bytes. 16 | - Added field `size` 17 | - Contains the physical immediate size, in bits. 18 | - `ZydisDecodedOperandMemDisp_` struct was changed 19 | - Added field `offset` 20 | - Contains the offset of the immediate data, relative to the beginning of the instruction, in bytes. 21 | - Added field `size` 22 | - Contains the physical displacement size, in bits. 23 | - Removed field `has_displacement` 24 | - A `size` of 0 indicates that there is no displacement, effectively replacing the need for `has_displacement`. -------------------------------------------------------------------------------- /assets/screenshots/ZydisDisasm.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zyantific/zydis/6372690e30389a94db65ece2d8a1f0a2310475ed/assets/screenshots/ZydisDisasm.png -------------------------------------------------------------------------------- /assets/screenshots/ZydisInfo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zyantific/zydis/6372690e30389a94db65ece2d8a1f0a2310475ed/assets/screenshots/ZydisInfo.png -------------------------------------------------------------------------------- /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 | - sync revision in dependencies/zycore.wrap 7 | - create a tagged release of zydis 8 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /dependencies/zycore.wrap: -------------------------------------------------------------------------------- 1 | [wrap-git] 2 | # This is a fallback for plain clone (no submodules available). 3 | url = https://github.com/zyantific/zycore-c.git 4 | # Sync revision to `git submodule status zycore`. 5 | # If doing a release for Zydis, sync both to a tagged commit. 6 | revision = 38d4f0285e6157ee840ea82a9b90aba71c8a705d 7 | depth = 1 8 | 9 | [provide] 10 | dependency_names = zycore 11 | -------------------------------------------------------------------------------- /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. -------------------------------------------------------------------------------- /examples/meson.build: -------------------------------------------------------------------------------- 1 | examples_req = examples.enabled() 2 | 3 | if examples_req 4 | if decoder.enabled() and formatter.enabled() 5 | executable('DisassembleSimple', 'DisassembleSimple.c', dependencies: [zydis_dep]) 6 | executable('Disassemble', 'Disassemble.c', dependencies: [zydis_dep]) 7 | executable('Formatter01', 'Formatter01.c', dependencies: [zydis_dep]) 8 | executable('Formatter02', 'Formatter02.c', dependencies: [zydis_dep]) 9 | executable('Formatter03', 'Formatter03.c', dependencies: [zydis_dep]) 10 | executable( 11 | 'ZydisPerfTest', 12 | 'ZydisPerfTest.c', 13 | c_args: host_machine.system() in ['linux', 'freebsd'] ? ['-D_GNU_SOURCE'] : [], 14 | dependencies: [zydis_dep], 15 | ) 16 | endif 17 | 18 | if encoder.enabled() 19 | executable('EncodeMov', 'EncodeMov.c', dependencies: [zydis_dep]) 20 | executable('EncodeFromScratch', 'EncodeFromScratch.c', dependencies: [zydis_dep]) 21 | executable('RewriteCode', 'RewriteCode.c', dependencies: [zydis_dep]) 22 | endif 23 | endif 24 | 25 | summary( 26 | {'examples': examples_req}, 27 | section: 'Features', 28 | ) 29 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /man/meson.build: -------------------------------------------------------------------------------- 1 | ronn_exe = find_program('ronn', required: man) 2 | man_req = ronn_exe.found() 3 | 4 | if man_req 5 | man_names = [ 6 | 'ZydisDisasm.1', 7 | 'ZydisInfo.1', 8 | ] 9 | 10 | foreach page : man_names 11 | custom_target( 12 | page, 13 | input: files(f'@page@.ronn'), 14 | command: [ronn_exe, '--roff', '--output-dir', '@OUTDIR@', '@INPUT@'], 15 | output: page, 16 | install: true, 17 | install_dir: datadir / 'man' / 'man1', 18 | ) 19 | endforeach 20 | endif 21 | 22 | summary( 23 | {'man': man_req}, 24 | section: 'Features', 25 | ) 26 | -------------------------------------------------------------------------------- /meson_options.txt: -------------------------------------------------------------------------------- 1 | option( 2 | 'minimal', 3 | type: 'feature', 4 | value: 'disabled', 5 | description: 'Enable minimal mode (forces ZYDIS_DECODER_MODE_MINIMAL runtime option)', 6 | ) 7 | option( 8 | 'decoder', 9 | type: 'feature', 10 | value: 'auto', 11 | description: 'Enable instruction decoding functionality', 12 | ) 13 | option( 14 | 'encoder', 15 | type: 'feature', 16 | value: 'auto', 17 | description: 'Enable instruction encoding functionality', 18 | ) 19 | option( 20 | 'formatter', 21 | type: 'feature', 22 | value: 'auto', 23 | description: 'Enable instruction formatting functionality', 24 | ) 25 | option( 26 | 'avx512', 27 | type: 'feature', 28 | value: 'auto', 29 | description: 'Enable support for AVX-512 instructions', 30 | ) 31 | option( 32 | 'knc', 33 | type: 'feature', 34 | value: 'auto', 35 | description: 'Enable support for KNC instructions', 36 | ) 37 | option( 38 | 'segment', 39 | type: 'feature', 40 | value: 'auto', 41 | description: 'Enable instruction segment API', 42 | ) 43 | 44 | option( 45 | 'examples', 46 | type: 'feature', 47 | value: 'auto', 48 | description: 'Build examples', 49 | ) 50 | option( 51 | 'tools', 52 | type: 'feature', 53 | value: 'auto', 54 | description: 'Build tools', 55 | ) 56 | option( 57 | 'man', 58 | type: 'feature', 59 | value: 'auto', 60 | description: 'Build manpages for the tools (requires Ronn-NG)', 61 | ) 62 | option( 63 | 'doc', 64 | type: 'feature', 65 | value: 'auto', 66 | description: 'Build doxygen documentation (requires Doxygen)', 67 | ) 68 | option( 69 | 'tests', 70 | type: 'feature', 71 | value: 'auto', 72 | description: 'Build tests', 73 | ) 74 | 75 | option( 76 | 'nolibc', 77 | type: 'boolean', 78 | value: false, 79 | description: 'Do not use any C standard library functions (for exotic build-envs like kernel drivers)', 80 | ) 81 | 82 | option( 83 | 'llvm-fuzz', 84 | type: 'boolean', 85 | value: false, 86 | description: 'Enables LLVM libfuzzer mode and reduces prints in ZydisFuzzIn', 87 | ) 88 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | #include 31 | 32 | ZyanU8 ZydisGetEncodableInstructions(ZydisMnemonic mnemonic, 33 | const ZydisEncodableInstruction **instruction) 34 | { 35 | if (mnemonic <= ZYDIS_MNEMONIC_INVALID || mnemonic > ZYDIS_MNEMONIC_MAX_VALUE) 36 | { 37 | *instruction = ZYAN_NULL; 38 | return 0; 39 | } 40 | ZydisEncoderLookupEntry lookup_entry = encoder_instruction_lookup[mnemonic]; 41 | *instruction = &encoder_instructions[lookup_entry.encoder_reference]; 42 | return lookup_entry.instruction_count; 43 | } 44 | -------------------------------------------------------------------------------- /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_FP16", 11 | "AMX_INT8", 12 | "AMX_TILE", 13 | "AVX", 14 | "AVX2", 15 | "AVX2GATHER", 16 | "AVX512EVEX", 17 | "AVX512VEX", 18 | "AVXAES", 19 | "AVX_IFMA", 20 | "AVX_NE_CONVERT", 21 | "AVX_VNNI", 22 | "AVX_VNNI_INT16", 23 | "AVX_VNNI_INT8", 24 | "BASE", 25 | "BMI1", 26 | "BMI2", 27 | "CET", 28 | "CLDEMOTE", 29 | "CLFLUSHOPT", 30 | "CLFSH", 31 | "CLWB", 32 | "CLZERO", 33 | "ENQCMD", 34 | "F16C", 35 | "FMA", 36 | "FMA4", 37 | "FRED", 38 | "GFNI", 39 | "HRESET", 40 | "ICACHE_PREFETCH", 41 | "INVPCID", 42 | "KEYLOCKER", 43 | "KEYLOCKER_WIDE", 44 | "KNC", 45 | "KNCE", 46 | "KNCV", 47 | "LKGS", 48 | "LONGMODE", 49 | "LZCNT", 50 | "MCOMMIT", 51 | "MMX", 52 | "MONITOR", 53 | "MONITORX", 54 | "MOVBE", 55 | "MOVDIR", 56 | "MPX", 57 | "MSRLIST", 58 | "PADLOCK", 59 | "PAUSE", 60 | "PBNDKB", 61 | "PCLMULQDQ", 62 | "PCOMMIT", 63 | "PCONFIG", 64 | "PKU", 65 | "PREFETCHWT1", 66 | "PT", 67 | "RAO_INT", 68 | "RDPID", 69 | "RDPRU", 70 | "RDRAND", 71 | "RDSEED", 72 | "RDTSCP", 73 | "RDWRFSGS", 74 | "RTM", 75 | "SERIALIZE", 76 | "SGX", 77 | "SGX_ENCLV", 78 | "SHA", 79 | "SHA512", 80 | "SM3", 81 | "SM4", 82 | "SMAP", 83 | "SMX", 84 | "SNP", 85 | "SSE", 86 | "SSE2", 87 | "SSE3", 88 | "SSE4", 89 | "SSE4A", 90 | "SSSE3", 91 | "SVM", 92 | "TBM", 93 | "TDX", 94 | "TSX_LDTRK", 95 | "UINTR", 96 | "VAES", 97 | "VMFUNC", 98 | "VPCLMULQDQ", 99 | "VTX", 100 | "WAITPKG", 101 | "WRMSRNS", 102 | "X87", 103 | "XOP", 104 | "XSAVE", 105 | "XSAVEC", 106 | "XSAVEOPT", 107 | "XSAVES" 108 | }; 109 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /subprojects: -------------------------------------------------------------------------------- 1 | dependencies/ -------------------------------------------------------------------------------- /tests/binary_reader.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | from struct import unpack 3 | 4 | 5 | class BinaryReader(object): 6 | 7 | def __init__(self, data): 8 | self.data = data 9 | self.cursor = 0 10 | 11 | def _check_eof(self, size): 12 | if self.cursor + size > len(self.data): 13 | raise EOFError('Attempted to read past the end of internal data buffer') 14 | 15 | def _read_internal(self, fmt, size): 16 | self._check_eof(size) 17 | data_to_unpack = self.data[self.cursor:self.cursor + size] 18 | self.cursor += size 19 | return unpack(fmt, data_to_unpack)[0] 20 | 21 | def read_uint8(self): 22 | return self._read_internal('