contrast-agent 3.8.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.clang-format +5 -0
- data/.dockerignore +10 -0
- data/.gitignore +58 -0
- data/.gitmodules +6 -0
- data/.rspec +6 -0
- data/.simplecov +4 -0
- data/Gemfile +7 -0
- data/LICENSE.txt +12 -0
- data/Rakefile +15 -0
- data/exe/contrast_service +29 -0
- data/ext/build_funchook.rb +48 -0
- data/ext/cs__assess_active_record_named/cs__active_record_named.c +47 -0
- data/ext/cs__assess_active_record_named/cs__active_record_named.h +10 -0
- data/ext/cs__assess_active_record_named/extconf.rb +2 -0
- data/ext/cs__assess_array/cs__assess_array.c +38 -0
- data/ext/cs__assess_array/cs__assess_array.h +9 -0
- data/ext/cs__assess_array/extconf.rb +2 -0
- data/ext/cs__assess_basic_object/cs__assess_basic_object.c +50 -0
- data/ext/cs__assess_basic_object/cs__assess_basic_object.h +17 -0
- data/ext/cs__assess_basic_object/extconf.rb +2 -0
- data/ext/cs__assess_fiber_track/cs__assess_fiber_track.c +86 -0
- data/ext/cs__assess_fiber_track/cs__assess_fiber_track.h +34 -0
- data/ext/cs__assess_fiber_track/extconf.rb +2 -0
- data/ext/cs__assess_hash/cs__assess_hash.c +64 -0
- data/ext/cs__assess_hash/cs__assess_hash.h +24 -0
- data/ext/cs__assess_hash/extconf.rb +2 -0
- data/ext/cs__assess_kernel/cs__assess_kernel.c +36 -0
- data/ext/cs__assess_kernel/cs__assess_kernel.h +10 -0
- data/ext/cs__assess_kernel/extconf.rb +2 -0
- data/ext/cs__assess_marshal_module/cs__assess_marshal_module.c +47 -0
- data/ext/cs__assess_marshal_module/cs__assess_marshal_module.h +18 -0
- data/ext/cs__assess_marshal_module/extconf.rb +2 -0
- data/ext/cs__assess_module/cs__assess_module.c +78 -0
- data/ext/cs__assess_module/cs__assess_module.h +25 -0
- data/ext/cs__assess_module/extconf.rb +2 -0
- data/ext/cs__assess_regexp/cs__assess_regexp.c +48 -0
- data/ext/cs__assess_regexp/cs__assess_regexp.h +22 -0
- data/ext/cs__assess_regexp/extconf.rb +2 -0
- data/ext/cs__assess_regexp_track/cs__assess_regexp_track.c +63 -0
- data/ext/cs__assess_regexp_track/cs__assess_regexp_track.h +29 -0
- data/ext/cs__assess_regexp_track/extconf.rb +2 -0
- data/ext/cs__assess_string/cs__assess_string.c +38 -0
- data/ext/cs__assess_string/cs__assess_string.h +19 -0
- data/ext/cs__assess_string/extconf.rb +2 -0
- data/ext/cs__assess_string_interpolation26/cs__assess_string_interpolation26.c +31 -0
- data/ext/cs__assess_string_interpolation26/cs__assess_string_interpolation26.h +13 -0
- data/ext/cs__assess_string_interpolation26/extconf.rb +2 -0
- data/ext/cs__common/cs__common.c +60 -0
- data/ext/cs__common/cs__common.h +28 -0
- data/ext/cs__common/extconf.rb +20 -0
- data/ext/cs__contrast_patch/cs__contrast_patch.c +445 -0
- data/ext/cs__contrast_patch/cs__contrast_patch.h +196 -0
- data/ext/cs__contrast_patch/extconf.rb +2 -0
- data/ext/cs__protect_kernel/cs__protect_kernel.c +37 -0
- data/ext/cs__protect_kernel/cs__protect_kernel.h +11 -0
- data/ext/cs__protect_kernel/extconf.rb +2 -0
- data/ext/cs__scope/cs__scope.c +96 -0
- data/ext/cs__scope/cs__scope.h +33 -0
- data/ext/cs__scope/extconf.rb +2 -0
- data/ext/extconf_common.rb +49 -0
- data/funchook/LICENSE +360 -0
- data/funchook/Makefile +29 -0
- data/funchook/Makefile.in +29 -0
- data/funchook/README.md +121 -0
- data/funchook/appveyor.yml +42 -0
- data/funchook/autogen.sh +3 -0
- data/funchook/autom4te.cache/output.0 +4976 -0
- data/funchook/autom4te.cache/requests +78 -0
- data/funchook/autom4te.cache/traces.0 +364 -0
- data/funchook/config.guess +1530 -0
- data/funchook/config.log +490 -0
- data/funchook/config.status +1016 -0
- data/funchook/config.sub +1773 -0
- data/funchook/configure +4976 -0
- data/funchook/configure.ac +59 -0
- data/funchook/distorm/COPYING +26 -0
- data/funchook/distorm/MANIFEST +25 -0
- data/funchook/distorm/MANIFEST.in +4 -0
- data/funchook/distorm/README.md +12 -0
- data/funchook/distorm/disOps/disOps.py +795 -0
- data/funchook/distorm/disOps/x86db.py +404 -0
- data/funchook/distorm/disOps/x86header.py +247 -0
- data/funchook/distorm/disOps/x86sets.py +1664 -0
- data/funchook/distorm/examples/cs/TestdiStorm/Program.cs +79 -0
- data/funchook/distorm/examples/cs/TestdiStorm/Properties/AssemblyInfo.cs +36 -0
- data/funchook/distorm/examples/cs/TestdiStorm/TestdiStorm.csproj +69 -0
- data/funchook/distorm/examples/cs/distorm-net.sln +26 -0
- data/funchook/distorm/examples/cs/distorm-net/CodeInfo.cs +23 -0
- data/funchook/distorm/examples/cs/distorm-net/DecodedInst.cs +15 -0
- data/funchook/distorm/examples/cs/distorm-net/DecodedResult.cs +14 -0
- data/funchook/distorm/examples/cs/distorm-net/DecomposedInst.cs +36 -0
- data/funchook/distorm/examples/cs/distorm-net/DecomposedResult.cs +14 -0
- data/funchook/distorm/examples/cs/distorm-net/Opcodes.cs +1268 -0
- data/funchook/distorm/examples/cs/distorm-net/Opcodes.tt +37 -0
- data/funchook/distorm/examples/cs/distorm-net/Operand.cs +25 -0
- data/funchook/distorm/examples/cs/distorm-net/Properties/AssemblyInfo.cs +36 -0
- data/funchook/distorm/examples/cs/distorm-net/diStorm3.cs +411 -0
- data/funchook/distorm/examples/cs/distorm-net/distorm-net.csproj +80 -0
- data/funchook/distorm/examples/cs/readme +3 -0
- data/funchook/distorm/examples/ddk/README +48 -0
- data/funchook/distorm/examples/ddk/distorm.ini +11 -0
- data/funchook/distorm/examples/ddk/dummy.c +15 -0
- data/funchook/distorm/examples/ddk/main.c +91 -0
- data/funchook/distorm/examples/ddk/makefile +1 -0
- data/funchook/distorm/examples/ddk/sources +10 -0
- data/funchook/distorm/examples/java/Makefile +23 -0
- data/funchook/distorm/examples/java/distorm/src/Main.java +43 -0
- data/funchook/distorm/examples/java/distorm/src/diStorm3/CodeInfo.java +27 -0
- data/funchook/distorm/examples/java/distorm/src/diStorm3/DecodedInst.java +32 -0
- data/funchook/distorm/examples/java/distorm/src/diStorm3/DecodedResult.java +11 -0
- data/funchook/distorm/examples/java/distorm/src/diStorm3/DecomposedInst.java +89 -0
- data/funchook/distorm/examples/java/distorm/src/diStorm3/DecomposedResult.java +11 -0
- data/funchook/distorm/examples/java/distorm/src/diStorm3/OpcodeEnum.java +131 -0
- data/funchook/distorm/examples/java/distorm/src/diStorm3/Opcodes.java +1123 -0
- data/funchook/distorm/examples/java/distorm/src/diStorm3/Operand.java +24 -0
- data/funchook/distorm/examples/java/distorm/src/diStorm3/distorm3.java +41 -0
- data/funchook/distorm/examples/java/jdistorm.c +405 -0
- data/funchook/distorm/examples/java/jdistorm.h +40 -0
- data/funchook/distorm/examples/java/jdistorm.sln +20 -0
- data/funchook/distorm/examples/java/jdistorm.vcproj +208 -0
- data/funchook/distorm/examples/linux/Makefile +15 -0
- data/funchook/distorm/examples/linux/main.c +181 -0
- data/funchook/distorm/examples/tests/Makefile +15 -0
- data/funchook/distorm/examples/tests/main.cpp +42 -0
- data/funchook/distorm/examples/tests/main.py +66 -0
- data/funchook/distorm/examples/tests/test_distorm3.py +1672 -0
- data/funchook/distorm/examples/tests/tests.sln +20 -0
- data/funchook/distorm/examples/tests/tests.vcxproj +82 -0
- data/funchook/distorm/examples/tests/tests.vcxproj.filters +22 -0
- data/funchook/distorm/examples/win32/disasm.sln +25 -0
- data/funchook/distorm/examples/win32/disasm.vcxproj +201 -0
- data/funchook/distorm/examples/win32/disasm.vcxproj.filters +14 -0
- data/funchook/distorm/examples/win32/main.cpp +163 -0
- data/funchook/distorm/include/distorm.h +482 -0
- data/funchook/distorm/include/mnemonics.h +301 -0
- data/funchook/distorm/make/linux/Makefile +28 -0
- data/funchook/distorm/make/mac/Makefile +24 -0
- data/funchook/distorm/make/win32/cdistorm.vcxproj +239 -0
- data/funchook/distorm/make/win32/cdistorm.vcxproj.filters +80 -0
- data/funchook/distorm/make/win32/distorm.sln +25 -0
- data/funchook/distorm/make/win32/resource.h +14 -0
- data/funchook/distorm/make/win32/resource.rc +99 -0
- data/funchook/distorm/python/distorm3/__init__.py +957 -0
- data/funchook/distorm/python/distorm3/sample.py +51 -0
- data/funchook/distorm/setup.cfg +10 -0
- data/funchook/distorm/setup.py +266 -0
- data/funchook/distorm/src/config.h +169 -0
- data/funchook/distorm/src/decoder.c +641 -0
- data/funchook/distorm/src/decoder.h +33 -0
- data/funchook/distorm/src/distorm.c +413 -0
- data/funchook/distorm/src/instructions.c +597 -0
- data/funchook/distorm/src/instructions.h +463 -0
- data/funchook/distorm/src/insts.c +7939 -0
- data/funchook/distorm/src/insts.h +64 -0
- data/funchook/distorm/src/mnemonics.c +284 -0
- data/funchook/distorm/src/operands.c +1290 -0
- data/funchook/distorm/src/operands.h +28 -0
- data/funchook/distorm/src/prefix.c +368 -0
- data/funchook/distorm/src/prefix.h +64 -0
- data/funchook/distorm/src/textdefs.c +172 -0
- data/funchook/distorm/src/textdefs.h +57 -0
- data/funchook/distorm/src/wstring.c +47 -0
- data/funchook/distorm/src/wstring.h +35 -0
- data/funchook/distorm/src/x86defs.h +82 -0
- data/funchook/include/funchook.h +123 -0
- data/funchook/install-sh +527 -0
- data/funchook/src/Makefile +70 -0
- data/funchook/src/Makefile.in +70 -0
- data/funchook/src/__strerror.h +109 -0
- data/funchook/src/config.h +101 -0
- data/funchook/src/config.h.in +100 -0
- data/funchook/src/decoder.o +0 -0
- data/funchook/src/distorm.o +0 -0
- data/funchook/src/funchook.c +440 -0
- data/funchook/src/funchook.o +0 -0
- data/funchook/src/funchook_internal.h +155 -0
- data/funchook/src/funchook_io.c +182 -0
- data/funchook/src/funchook_io.h +64 -0
- data/funchook/src/funchook_io.o +0 -0
- data/funchook/src/funchook_syscall.S +134 -0
- data/funchook/src/funchook_syscall.o +0 -0
- data/funchook/src/funchook_unix.c +480 -0
- data/funchook/src/funchook_unix.o +0 -0
- data/funchook/src/funchook_windows.c +397 -0
- data/funchook/src/funchook_x86.c +622 -0
- data/funchook/src/funchook_x86.o +0 -0
- data/funchook/src/instructions.o +0 -0
- data/funchook/src/insts.o +0 -0
- data/funchook/src/libfunchook.so +0 -0
- data/funchook/src/mnemonics.o +0 -0
- data/funchook/src/operands.o +0 -0
- data/funchook/src/os_func.c +115 -0
- data/funchook/src/os_func.h +75 -0
- data/funchook/src/os_func.o +0 -0
- data/funchook/src/os_func_unix.c +94 -0
- data/funchook/src/os_func_unix.o +0 -0
- data/funchook/src/os_func_windows.c +32 -0
- data/funchook/src/prefix.o +0 -0
- data/funchook/src/printf_base.c +1688 -0
- data/funchook/src/printf_base.h +46 -0
- data/funchook/src/printf_base.o +0 -0
- data/funchook/src/textdefs.o +0 -0
- data/funchook/src/wstring.o +0 -0
- data/funchook/test/Makefile +43 -0
- data/funchook/test/Makefile.in +43 -0
- data/funchook/test/funchook_test +0 -0
- data/funchook/test/libfunchook_test.c +25 -0
- data/funchook/test/libfunchook_test.so +0 -0
- data/funchook/test/libfunchook_test2.c +18 -0
- data/funchook/test/suffix.list +600 -0
- data/funchook/test/test_main.c +430 -0
- data/funchook/test/test_main.o +0 -0
- data/funchook/test/x86_64_test.S +10 -0
- data/funchook/test/x86_64_test.o +0 -0
- data/funchook/test/x86_test.S +339 -0
- data/funchook/win32/config.h +1 -0
- data/funchook/win32/funchook.sln +52 -0
- data/funchook/win32/funchook.vcxproj +188 -0
- data/funchook/win32/funchook.vcxproj.filters +84 -0
- data/funchook/win32/funchook_test.vcxproj +170 -0
- data/funchook/win32/funchook_test.vcxproj.filters +22 -0
- data/funchook/win32/funchook_test_dll.vcxproj +184 -0
- data/funchook/win32/funchook_test_dll.vcxproj.filters +30 -0
- data/funchook/win32/funchook_test_exe.def +3 -0
- data/lib/contrast-agent.rb +8 -0
- data/lib/contrast.rb +57 -0
- data/lib/contrast/agent.rb +80 -0
- data/lib/contrast/agent/assess.rb +45 -0
- data/lib/contrast/agent/assess/adjusted_span.rb +25 -0
- data/lib/contrast/agent/assess/class_reverter.rb +82 -0
- data/lib/contrast/agent/assess/contrast_event.rb +398 -0
- data/lib/contrast/agent/assess/frozen_properties.rb +41 -0
- data/lib/contrast/agent/assess/insulator.rb +53 -0
- data/lib/contrast/agent/assess/policy/dynamic_source_factory.rb +78 -0
- data/lib/contrast/agent/assess/policy/patcher.rb +85 -0
- data/lib/contrast/agent/assess/policy/policy.rb +116 -0
- data/lib/contrast/agent/assess/policy/policy_node.rb +289 -0
- data/lib/contrast/agent/assess/policy/policy_scanner.rb +44 -0
- data/lib/contrast/agent/assess/policy/preshift.rb +94 -0
- data/lib/contrast/agent/assess/policy/propagation_method.rb +260 -0
- data/lib/contrast/agent/assess/policy/propagation_node.rb +127 -0
- data/lib/contrast/agent/assess/policy/propagator.rb +35 -0
- data/lib/contrast/agent/assess/policy/propagator/append.rb +54 -0
- data/lib/contrast/agent/assess/policy/propagator/base.rb +37 -0
- data/lib/contrast/agent/assess/policy/propagator/center.rb +73 -0
- data/lib/contrast/agent/assess/policy/propagator/custom.rb +36 -0
- data/lib/contrast/agent/assess/policy/propagator/database_write.rb +62 -0
- data/lib/contrast/agent/assess/policy/propagator/insert.rb +55 -0
- data/lib/contrast/agent/assess/policy/propagator/keep.rb +26 -0
- data/lib/contrast/agent/assess/policy/propagator/next.rb +42 -0
- data/lib/contrast/agent/assess/policy/propagator/prepend.rb +50 -0
- data/lib/contrast/agent/assess/policy/propagator/remove.rb +76 -0
- data/lib/contrast/agent/assess/policy/propagator/replace.rb +27 -0
- data/lib/contrast/agent/assess/policy/propagator/reverse.rb +38 -0
- data/lib/contrast/agent/assess/policy/propagator/select.rb +86 -0
- data/lib/contrast/agent/assess/policy/propagator/splat.rb +60 -0
- data/lib/contrast/agent/assess/policy/propagator/split.rb +49 -0
- data/lib/contrast/agent/assess/policy/propagator/substitution.rb +169 -0
- data/lib/contrast/agent/assess/policy/propagator/trim.rb +81 -0
- data/lib/contrast/agent/assess/policy/rewriter_patch.rb +79 -0
- data/lib/contrast/agent/assess/policy/source_method.rb +209 -0
- data/lib/contrast/agent/assess/policy/source_node.rb +62 -0
- data/lib/contrast/agent/assess/policy/trigger_method.rb +209 -0
- data/lib/contrast/agent/assess/policy/trigger_node.rb +198 -0
- data/lib/contrast/agent/assess/policy/trigger_validation/ssrf_validator.rb +77 -0
- data/lib/contrast/agent/assess/policy/trigger_validation/trigger_validation.rb +31 -0
- data/lib/contrast/agent/assess/policy/trigger_validation/xss_validator.rb +40 -0
- data/lib/contrast/agent/assess/properties.rb +392 -0
- data/lib/contrast/agent/assess/rule.rb +18 -0
- data/lib/contrast/agent/assess/rule/base.rb +72 -0
- data/lib/contrast/agent/assess/rule/csrf.rb +66 -0
- data/lib/contrast/agent/assess/rule/csrf/csrf_action.rb +28 -0
- data/lib/contrast/agent/assess/rule/csrf/csrf_applicator.rb +69 -0
- data/lib/contrast/agent/assess/rule/csrf/csrf_watcher.rb +132 -0
- data/lib/contrast/agent/assess/rule/provider.rb +21 -0
- data/lib/contrast/agent/assess/rule/provider/hardcoded_key.rb +62 -0
- data/lib/contrast/agent/assess/rule/provider/hardcoded_password.rb +73 -0
- data/lib/contrast/agent/assess/rule/provider/hardcoded_value_rule.rb +121 -0
- data/lib/contrast/agent/assess/rule/redos.rb +68 -0
- data/lib/contrast/agent/assess/rule/response_scanning_rule.rb +47 -0
- data/lib/contrast/agent/assess/rule/response_watcher.rb +36 -0
- data/lib/contrast/agent/assess/rule/watcher.rb +36 -0
- data/lib/contrast/agent/assess/tag.rb +151 -0
- data/lib/contrast/agent/at_exit_hook.rb +33 -0
- data/lib/contrast/agent/class_reopener.rb +195 -0
- data/lib/contrast/agent/deadzone/policy/deadzone_node.rb +26 -0
- data/lib/contrast/agent/deadzone/policy/policy.rb +57 -0
- data/lib/contrast/agent/disable_reaction.rb +24 -0
- data/lib/contrast/agent/exclusion_matcher.rb +190 -0
- data/lib/contrast/agent/feature_state.rb +379 -0
- data/lib/contrast/agent/inventory/policy/policy.rb +32 -0
- data/lib/contrast/agent/inventory/policy/trigger_node.rb +22 -0
- data/lib/contrast/agent/logger_manager.rb +116 -0
- data/lib/contrast/agent/middleware.rb +352 -0
- data/lib/contrast/agent/module_data.rb +16 -0
- data/lib/contrast/agent/patching/policy/after_load_patch.rb +37 -0
- data/lib/contrast/agent/patching/policy/after_load_patcher.rb +58 -0
- data/lib/contrast/agent/patching/policy/method_policy.rb +94 -0
- data/lib/contrast/agent/patching/policy/module_policy.rb +116 -0
- data/lib/contrast/agent/patching/policy/patch.rb +312 -0
- data/lib/contrast/agent/patching/policy/patch_status.rb +192 -0
- data/lib/contrast/agent/patching/policy/patcher.rb +310 -0
- data/lib/contrast/agent/patching/policy/policy.rb +138 -0
- data/lib/contrast/agent/patching/policy/policy_node.rb +80 -0
- data/lib/contrast/agent/patching/policy/policy_unpatcher.rb +28 -0
- data/lib/contrast/agent/patching/policy/trigger_node.rb +81 -0
- data/lib/contrast/agent/protect/policy/policy.rb +37 -0
- data/lib/contrast/agent/protect/policy/trigger_node.rb +23 -0
- data/lib/contrast/agent/protect/rule.rb +58 -0
- data/lib/contrast/agent/protect/rule/base.rb +300 -0
- data/lib/contrast/agent/protect/rule/base_service.rb +88 -0
- data/lib/contrast/agent/protect/rule/cmd_injection.rb +156 -0
- data/lib/contrast/agent/protect/rule/csrf.rb +118 -0
- data/lib/contrast/agent/protect/rule/csrf/csrf_evaluator.rb +103 -0
- data/lib/contrast/agent/protect/rule/csrf/csrf_token_injector.rb +85 -0
- data/lib/contrast/agent/protect/rule/default_scanner.rb +300 -0
- data/lib/contrast/agent/protect/rule/deserialization.rb +193 -0
- data/lib/contrast/agent/protect/rule/http_method_tampering.rb +80 -0
- data/lib/contrast/agent/protect/rule/no_sqli.rb +101 -0
- data/lib/contrast/agent/protect/rule/no_sqli/mongo_no_sql_scanner.rb +40 -0
- data/lib/contrast/agent/protect/rule/path_traversal.rb +143 -0
- data/lib/contrast/agent/protect/rule/sqli.rb +101 -0
- data/lib/contrast/agent/protect/rule/sqli/default_sql_scanner.rb +16 -0
- data/lib/contrast/agent/protect/rule/sqli/mysql_sql_scanner.rb +38 -0
- data/lib/contrast/agent/protect/rule/sqli/postgres_sql_scanner.rb +22 -0
- data/lib/contrast/agent/protect/rule/sqli/sqlite_sql_scanner.rb +19 -0
- data/lib/contrast/agent/protect/rule/unsafe_file_upload.rb +20 -0
- data/lib/contrast/agent/protect/rule/xss.rb +24 -0
- data/lib/contrast/agent/protect/rule/xxe.rb +120 -0
- data/lib/contrast/agent/protect/rule/xxe/entity_wrapper.rb +82 -0
- data/lib/contrast/agent/railtie.rb +30 -0
- data/lib/contrast/agent/reaction_processor.rb +47 -0
- data/lib/contrast/agent/request.rb +493 -0
- data/lib/contrast/agent/request_context.rb +225 -0
- data/lib/contrast/agent/require_state.rb +61 -0
- data/lib/contrast/agent/response.rb +215 -0
- data/lib/contrast/agent/rewriter.rb +244 -0
- data/lib/contrast/agent/scope.rb +28 -0
- data/lib/contrast/agent/service_heartbeat.rb +37 -0
- data/lib/contrast/agent/settings_state.rb +148 -0
- data/lib/contrast/agent/socket_client.rb +125 -0
- data/lib/contrast/agent/thread.rb +26 -0
- data/lib/contrast/agent/tracepoint_hook.rb +51 -0
- data/lib/contrast/agent/version.rb +8 -0
- data/lib/contrast/api.rb +17 -0
- data/lib/contrast/api/.gitkeep +0 -0
- data/lib/contrast/api/connection_status.rb +49 -0
- data/lib/contrast/api/socket.rb +43 -0
- data/lib/contrast/api/speedracer.rb +206 -0
- data/lib/contrast/api/tcp_socket.rb +31 -0
- data/lib/contrast/api/unix_socket.rb +25 -0
- data/lib/contrast/common_agent_configuration.rb +86 -0
- data/lib/contrast/components/agent.rb +85 -0
- data/lib/contrast/components/app_context.rb +188 -0
- data/lib/contrast/components/assess.rb +67 -0
- data/lib/contrast/components/config.rb +135 -0
- data/lib/contrast/components/contrast_service.rb +113 -0
- data/lib/contrast/components/heap_dump.rb +34 -0
- data/lib/contrast/components/interface.rb +178 -0
- data/lib/contrast/components/inventory.rb +23 -0
- data/lib/contrast/components/logger.rb +92 -0
- data/lib/contrast/components/protect.rb +38 -0
- data/lib/contrast/components/sampling.rb +41 -0
- data/lib/contrast/components/scope.rb +106 -0
- data/lib/contrast/components/settings.rb +140 -0
- data/lib/contrast/config.rb +33 -0
- data/lib/contrast/config/agent_configuration.rb +24 -0
- data/lib/contrast/config/application_configuration.rb +27 -0
- data/lib/contrast/config/assess_configuration.rb +22 -0
- data/lib/contrast/config/assess_rules_configuration.rb +18 -0
- data/lib/contrast/config/base_configuration.rb +105 -0
- data/lib/contrast/config/default_value.rb +16 -0
- data/lib/contrast/config/exception_configuration.rb +21 -0
- data/lib/contrast/config/heap_dump_configuration.rb +23 -0
- data/lib/contrast/config/inventory_configuration.rb +20 -0
- data/lib/contrast/config/logger_configuration.rb +20 -0
- data/lib/contrast/config/protect_configuration.rb +20 -0
- data/lib/contrast/config/protect_rule_configuration.rb +37 -0
- data/lib/contrast/config/protect_rules_configuration.rb +30 -0
- data/lib/contrast/config/root_configuration.rb +26 -0
- data/lib/contrast/config/ruby_configuration.rb +39 -0
- data/lib/contrast/config/sampling_configuration.rb +22 -0
- data/lib/contrast/config/server_configuration.rb +23 -0
- data/lib/contrast/config/service_configuration.rb +22 -0
- data/lib/contrast/configuration.rb +214 -0
- data/lib/contrast/core_extensions/assess.rb +51 -0
- data/lib/contrast/core_extensions/assess/array.rb +58 -0
- data/lib/contrast/core_extensions/assess/assess_extension.rb +145 -0
- data/lib/contrast/core_extensions/assess/basic_object.rb +15 -0
- data/lib/contrast/core_extensions/assess/erb.rb +42 -0
- data/lib/contrast/core_extensions/assess/exec_trigger.rb +48 -0
- data/lib/contrast/core_extensions/assess/fiber.rb +125 -0
- data/lib/contrast/core_extensions/assess/hash.rb +22 -0
- data/lib/contrast/core_extensions/assess/kernel.rb +95 -0
- data/lib/contrast/core_extensions/assess/module.rb +14 -0
- data/lib/contrast/core_extensions/assess/regexp.rb +206 -0
- data/lib/contrast/core_extensions/assess/string.rb +75 -0
- data/lib/contrast/core_extensions/assess/tilt_template_trigger.rb +73 -0
- data/lib/contrast/core_extensions/delegator.rb +14 -0
- data/lib/contrast/core_extensions/eval_trigger.rb +52 -0
- data/lib/contrast/core_extensions/inventory.rb +22 -0
- data/lib/contrast/core_extensions/inventory/datastores.rb +37 -0
- data/lib/contrast/core_extensions/module.rb +42 -0
- data/lib/contrast/core_extensions/object.rb +27 -0
- data/lib/contrast/core_extensions/protect.rb +20 -0
- data/lib/contrast/core_extensions/protect/applies_command_injection_rule.rb +70 -0
- data/lib/contrast/core_extensions/protect/applies_deserialization_rule.rb +58 -0
- data/lib/contrast/core_extensions/protect/applies_no_sqli_rule.rb +81 -0
- data/lib/contrast/core_extensions/protect/applies_path_traversal_rule.rb +119 -0
- data/lib/contrast/core_extensions/protect/applies_sqli_rule.rb +63 -0
- data/lib/contrast/core_extensions/protect/applies_xxe_rule.rb +141 -0
- data/lib/contrast/core_extensions/protect/kernel.rb +30 -0
- data/lib/contrast/core_extensions/protect/psych.rb +7 -0
- data/lib/contrast/core_extensions/thread.rb +31 -0
- data/lib/contrast/internal_exception.rb +8 -0
- data/lib/contrast/rails_extensions/assess/action_controller_inheritance.rb +48 -0
- data/lib/contrast/rails_extensions/assess/active_record.rb +32 -0
- data/lib/contrast/rails_extensions/assess/active_record_named.rb +61 -0
- data/lib/contrast/rails_extensions/assess/configuration.rb +26 -0
- data/lib/contrast/rails_extensions/buffer.rb +30 -0
- data/lib/contrast/rails_extensions/rack.rb +45 -0
- data/lib/contrast/security_exception.rb +14 -0
- data/lib/contrast/sinatra_extensions/assess/cookie.rb +26 -0
- data/lib/contrast/sinatra_extensions/inventory/sinatra_base.rb +59 -0
- data/lib/contrast/tasks/service.rb +95 -0
- data/lib/contrast/utils/assess/sampling_util.rb +96 -0
- data/lib/contrast/utils/assess/tracking_util.rb +39 -0
- data/lib/contrast/utils/boolean_util.rb +33 -0
- data/lib/contrast/utils/cache.rb +69 -0
- data/lib/contrast/utils/class_util.rb +58 -0
- data/lib/contrast/utils/comment_range.rb +19 -0
- data/lib/contrast/utils/data_store_util.rb +23 -0
- data/lib/contrast/utils/duck_utils.rb +58 -0
- data/lib/contrast/utils/env_configuration_item.rb +52 -0
- data/lib/contrast/utils/environment_util.rb +152 -0
- data/lib/contrast/utils/freeze_util.rb +36 -0
- data/lib/contrast/utils/gemfile_reader.rb +191 -0
- data/lib/contrast/utils/hash_digest.rb +148 -0
- data/lib/contrast/utils/heap_dump_util.rb +113 -0
- data/lib/contrast/utils/invalid_configuration_util.rb +88 -0
- data/lib/contrast/utils/inventory_util.rb +126 -0
- data/lib/contrast/utils/io_util.rb +61 -0
- data/lib/contrast/utils/object_share.rb +117 -0
- data/lib/contrast/utils/operating_environment.rb +38 -0
- data/lib/contrast/utils/os.rb +49 -0
- data/lib/contrast/utils/path_util.rb +151 -0
- data/lib/contrast/utils/performs_logging.rb +152 -0
- data/lib/contrast/utils/preflight_util.rb +13 -0
- data/lib/contrast/utils/prevent_serialization.rb +52 -0
- data/lib/contrast/utils/rack_assess_session_cookie.rb +104 -0
- data/lib/contrast/utils/rails_assess_configuration.rb +95 -0
- data/lib/contrast/utils/random_util.rb +22 -0
- data/lib/contrast/utils/resource_loader.rb +23 -0
- data/lib/contrast/utils/ruby_ast_rewriter.rb +74 -0
- data/lib/contrast/utils/scope_util.rb +99 -0
- data/lib/contrast/utils/service_response_util.rb +116 -0
- data/lib/contrast/utils/service_sender_util.rb +98 -0
- data/lib/contrast/utils/sha256_builder.rb +69 -0
- data/lib/contrast/utils/sinatra_helper.rb +49 -0
- data/lib/contrast/utils/stack_trace_utils.rb +209 -0
- data/lib/contrast/utils/string_utils.rb +72 -0
- data/lib/contrast/utils/tag_util.rb +139 -0
- data/lib/contrast/utils/thread_tracker.rb +54 -0
- data/lib/contrast/utils/timer.rb +78 -0
- data/resources/assess/policy.json +1673 -0
- data/resources/csrf/inject.js +44 -0
- data/resources/deadzone/policy.json +55 -0
- data/resources/factory-bot-spec/spec_helper.rb +30 -0
- data/resources/inventory/policy.json +110 -0
- data/resources/protect/policy.json +417 -0
- data/resources/rubocops/kernel/catch_cop.rb +37 -0
- data/resources/rubocops/kernel/require_cop.rb +37 -0
- data/resources/rubocops/kernel/require_relative_cop.rb +33 -0
- data/resources/rubocops/module/autoload_cop.rb +37 -0
- data/resources/rubocops/module/const_defined_cop.rb +37 -0
- data/resources/rubocops/module/const_get_cop.rb +37 -0
- data/resources/rubocops/module/const_set_cop.rb +37 -0
- data/resources/rubocops/module/constants_cop.rb +37 -0
- data/resources/rubocops/module/name_cop.rb +37 -0
- data/resources/rubocops/object/class_cop.rb +37 -0
- data/resources/rubocops/object/freeze_cop.rb +37 -0
- data/resources/rubocops/object/frozen_cop.rb +37 -0
- data/resources/rubocops/object/is_a_cop.rb +37 -0
- data/resources/rubocops/object/method_cop.rb +37 -0
- data/resources/rubocops/object/respond_to_cop.rb +37 -0
- data/resources/rubocops/object/singleton_class_cop.rb +37 -0
- data/resources/rubocops/regexp/spelling_cop.rb +44 -0
- data/resources/rubocops/thread/new_cop.rb +39 -0
- data/resources/ruby-spec/ancestors_spec.rb +70 -0
- data/resources/ruby-spec/modulo_spec.rb +831 -0
- data/resources/ruby-spec/parameters_spec.rb +261 -0
- data/resources/ruby-spec/ruby_spec_spec_helper.rb +35 -0
- data/resources/test_marker.txt +1 -0
- data/ruby-agent.gemspec +129 -0
- data/service_executables/.gitkeep +0 -0
- data/service_executables/VERSION +1 -0
- data/service_executables/linux/contrast-service +0 -0
- data/service_executables/mac/contrast-service +0 -0
- metadata +945 -0
@@ -0,0 +1,64 @@
|
|
1
|
+
/*
|
2
|
+
insts.h
|
3
|
+
|
4
|
+
diStorm3 - Powerful disassembler for X86/AMD64
|
5
|
+
http://ragestorm.net/distorm/
|
6
|
+
distorm at gmail dot com
|
7
|
+
Copyright (C) 2003-2016 Gil Dabah
|
8
|
+
This library is licensed under the BSD license. See the file COPYING.
|
9
|
+
*/
|
10
|
+
|
11
|
+
|
12
|
+
#ifndef INSTS_H
|
13
|
+
#define INSTS_H
|
14
|
+
|
15
|
+
#include "instructions.h"
|
16
|
+
|
17
|
+
|
18
|
+
/* Flags Table */
|
19
|
+
extern _iflags FlagsTable[];
|
20
|
+
|
21
|
+
/* Root Trie DB */
|
22
|
+
extern _InstSharedInfo InstSharedInfoTable[];
|
23
|
+
extern _InstInfo InstInfos[];
|
24
|
+
extern _InstInfoEx InstInfosEx[];
|
25
|
+
extern _InstNode InstructionsTree[];
|
26
|
+
|
27
|
+
/* 3DNow! Trie DB */
|
28
|
+
extern _InstNode Table_0F_0F;
|
29
|
+
/* AVX related: */
|
30
|
+
extern _InstNode Table_0F, Table_0F_38, Table_0F_3A;
|
31
|
+
|
32
|
+
/*
|
33
|
+
* The inst_lookup will return on of these two instructions according to the specified decoding mode.
|
34
|
+
* ARPL or MOVSXD on 64 bits is one byte instruction at index 0x63.
|
35
|
+
*/
|
36
|
+
extern _InstInfo II_MOVSXD;
|
37
|
+
|
38
|
+
/*
|
39
|
+
* The NOP instruction can be prefixed by REX in 64bits, therefore we have to decide in runtime whether it's an XCHG or NOP instruction.
|
40
|
+
* If 0x90 is prefixed by a usable REX it will become XCHG, otherwise it will become a NOP.
|
41
|
+
* Also note that if it's prefixed by 0xf3, it becomes a Pause.
|
42
|
+
*/
|
43
|
+
extern _InstInfo II_NOP;
|
44
|
+
extern _InstInfo II_PAUSE;
|
45
|
+
|
46
|
+
/*
|
47
|
+
* RDRAND and VMPTRLD share same 2.3 bytes opcode, and then alternates on the MOD bits,
|
48
|
+
* RDRAND is OT_FULL_REG while VMPTRLD is OT_MEM, and there's no such mixed type.
|
49
|
+
* So a hack into the inst_lookup was added for this decision, the DB isn't flexible enough. :(
|
50
|
+
*/
|
51
|
+
extern _InstInfo II_RDRAND;
|
52
|
+
|
53
|
+
/*
|
54
|
+
* Used for letting the extract operand know the type of operands without knowing the
|
55
|
+
* instruction itself yet, because of the way those instructions work.
|
56
|
+
* See function instructions.c!inst_lookup_3dnow.
|
57
|
+
*/
|
58
|
+
extern _InstInfo II_3DNOW;
|
59
|
+
|
60
|
+
/* Helper tables for pseudo compare mnemonics. */
|
61
|
+
extern uint16_t CmpMnemonicOffsets[8]; /* SSE */
|
62
|
+
extern uint16_t VCmpMnemonicOffsets[32]; /* AVX */
|
63
|
+
|
64
|
+
#endif /* INSTS_H */
|
@@ -0,0 +1,284 @@
|
|
1
|
+
/*
|
2
|
+
mnemonics.c
|
3
|
+
|
4
|
+
diStorm3 - Powerful disassembler for X86/AMD64
|
5
|
+
http://ragestorm.net/distorm/
|
6
|
+
distorm at gmail dot com
|
7
|
+
Copyright (C) 2003-2016 Gil Dabah
|
8
|
+
This library is licensed under the BSD license. See the file COPYING.
|
9
|
+
*/
|
10
|
+
|
11
|
+
|
12
|
+
#include "../include/mnemonics.h"
|
13
|
+
|
14
|
+
#ifndef DISTORM_LIGHT
|
15
|
+
|
16
|
+
const unsigned char _MNEMONICS[] =
|
17
|
+
"\x09" "UNDEFINED\0" "\x03" "ADD\0" "\x04" "PUSH\0" "\x03" "POP\0" "\x02" "OR\0" \
|
18
|
+
"\x03" "ADC\0" "\x03" "SBB\0" "\x03" "AND\0" "\x03" "DAA\0" "\x03" "SUB\0" \
|
19
|
+
"\x03" "DAS\0" "\x03" "XOR\0" "\x03" "AAA\0" "\x03" "CMP\0" "\x03" "AAS\0" \
|
20
|
+
"\x03" "INC\0" "\x03" "DEC\0" "\x05" "PUSHA\0" "\x04" "POPA\0" "\x05" "BOUND\0" \
|
21
|
+
"\x04" "ARPL\0" "\x04" "IMUL\0" "\x03" "INS\0" "\x04" "OUTS\0" "\x02" "JO\0" \
|
22
|
+
"\x03" "JNO\0" "\x02" "JB\0" "\x03" "JAE\0" "\x02" "JZ\0" "\x03" "JNZ\0" "\x03" "JBE\0" \
|
23
|
+
"\x02" "JA\0" "\x02" "JS\0" "\x03" "JNS\0" "\x02" "JP\0" "\x03" "JNP\0" "\x02" "JL\0" \
|
24
|
+
"\x03" "JGE\0" "\x03" "JLE\0" "\x02" "JG\0" "\x04" "TEST\0" "\x04" "XCHG\0" \
|
25
|
+
"\x03" "MOV\0" "\x03" "LEA\0" "\x03" "CBW\0" "\x04" "CWDE\0" "\x04" "CDQE\0" \
|
26
|
+
"\x03" "CWD\0" "\x03" "CDQ\0" "\x03" "CQO\0" "\x08" "CALL FAR\0" "\x05" "PUSHF\0" \
|
27
|
+
"\x04" "POPF\0" "\x04" "SAHF\0" "\x04" "LAHF\0" "\x04" "MOVS\0" "\x04" "CMPS\0" \
|
28
|
+
"\x04" "STOS\0" "\x04" "LODS\0" "\x04" "SCAS\0" "\x03" "RET\0" "\x03" "LES\0" \
|
29
|
+
"\x03" "LDS\0" "\x05" "ENTER\0" "\x05" "LEAVE\0" "\x04" "RETF\0" "\x05" "INT 3\0" \
|
30
|
+
"\x03" "INT\0" "\x04" "INTO\0" "\x04" "IRET\0" "\x03" "AAM\0" "\x03" "AAD\0" \
|
31
|
+
"\x04" "SALC\0" "\x04" "XLAT\0" "\x06" "LOOPNZ\0" "\x05" "LOOPZ\0" "\x04" "LOOP\0" \
|
32
|
+
"\x04" "JCXZ\0" "\x05" "JECXZ\0" "\x05" "JRCXZ\0" "\x02" "IN\0" "\x03" "OUT\0" \
|
33
|
+
"\x04" "CALL\0" "\x03" "JMP\0" "\x07" "JMP FAR\0" "\x04" "INT1\0" "\x03" "HLT\0" \
|
34
|
+
"\x03" "CMC\0" "\x03" "CLC\0" "\x03" "STC\0" "\x03" "CLI\0" "\x03" "STI\0" \
|
35
|
+
"\x03" "CLD\0" "\x03" "STD\0" "\x03" "LAR\0" "\x03" "LSL\0" "\x07" "SYSCALL\0" \
|
36
|
+
"\x04" "CLTS\0" "\x06" "SYSRET\0" "\x04" "INVD\0" "\x06" "WBINVD\0" "\x03" "UD2\0" \
|
37
|
+
"\x05" "FEMMS\0" "\x03" "NOP\0" "\x05" "WRMSR\0" "\x05" "RDTSC\0" "\x05" "RDMSR\0" \
|
38
|
+
"\x05" "RDPMC\0" "\x08" "SYSENTER\0" "\x07" "SYSEXIT\0" "\x06" "GETSEC\0" "\x05" "CMOVO\0" \
|
39
|
+
"\x06" "CMOVNO\0" "\x05" "CMOVB\0" "\x06" "CMOVAE\0" "\x05" "CMOVZ\0" "\x06" "CMOVNZ\0" \
|
40
|
+
"\x06" "CMOVBE\0" "\x05" "CMOVA\0" "\x05" "CMOVS\0" "\x06" "CMOVNS\0" "\x05" "CMOVP\0" \
|
41
|
+
"\x06" "CMOVNP\0" "\x05" "CMOVL\0" "\x06" "CMOVGE\0" "\x06" "CMOVLE\0" "\x05" "CMOVG\0" \
|
42
|
+
"\x04" "SETO\0" "\x05" "SETNO\0" "\x04" "SETB\0" "\x05" "SETAE\0" "\x04" "SETZ\0" \
|
43
|
+
"\x05" "SETNZ\0" "\x05" "SETBE\0" "\x04" "SETA\0" "\x04" "SETS\0" "\x05" "SETNS\0" \
|
44
|
+
"\x04" "SETP\0" "\x05" "SETNP\0" "\x04" "SETL\0" "\x05" "SETGE\0" "\x05" "SETLE\0" \
|
45
|
+
"\x04" "SETG\0" "\x05" "CPUID\0" "\x02" "BT\0" "\x04" "SHLD\0" "\x03" "RSM\0" \
|
46
|
+
"\x03" "BTS\0" "\x04" "SHRD\0" "\x07" "CMPXCHG\0" "\x03" "LSS\0" "\x03" "BTR\0" \
|
47
|
+
"\x03" "LFS\0" "\x03" "LGS\0" "\x05" "MOVZX\0" "\x03" "BTC\0" "\x05" "MOVSX\0" \
|
48
|
+
"\x04" "XADD\0" "\x06" "MOVNTI\0" "\x05" "BSWAP\0" "\x03" "ROL\0" "\x03" "ROR\0" \
|
49
|
+
"\x03" "RCL\0" "\x03" "RCR\0" "\x03" "SHL\0" "\x03" "SHR\0" "\x03" "SAL\0" \
|
50
|
+
"\x03" "SAR\0" "\x06" "XABORT\0" "\x06" "XBEGIN\0" "\x04" "FADD\0" "\x04" "FMUL\0" \
|
51
|
+
"\x04" "FCOM\0" "\x05" "FCOMP\0" "\x04" "FSUB\0" "\x05" "FSUBR\0" "\x04" "FDIV\0" \
|
52
|
+
"\x05" "FDIVR\0" "\x03" "FLD\0" "\x03" "FST\0" "\x04" "FSTP\0" "\x06" "FLDENV\0" \
|
53
|
+
"\x05" "FLDCW\0" "\x04" "FXCH\0" "\x04" "FNOP\0" "\x04" "FCHS\0" "\x04" "FABS\0" \
|
54
|
+
"\x04" "FTST\0" "\x04" "FXAM\0" "\x04" "FLD1\0" "\x06" "FLDL2T\0" "\x06" "FLDL2E\0" \
|
55
|
+
"\x05" "FLDPI\0" "\x06" "FLDLG2\0" "\x06" "FLDLN2\0" "\x04" "FLDZ\0" "\x05" "F2XM1\0" \
|
56
|
+
"\x05" "FYL2X\0" "\x05" "FPTAN\0" "\x06" "FPATAN\0" "\x07" "FXTRACT\0" "\x06" "FPREM1\0" \
|
57
|
+
"\x07" "FDECSTP\0" "\x07" "FINCSTP\0" "\x05" "FPREM\0" "\x07" "FYL2XP1\0" "\x05" "FSQRT\0" \
|
58
|
+
"\x07" "FSINCOS\0" "\x07" "FRNDINT\0" "\x06" "FSCALE\0" "\x04" "FSIN\0" "\x04" "FCOS\0" \
|
59
|
+
"\x05" "FIADD\0" "\x05" "FIMUL\0" "\x05" "FICOM\0" "\x06" "FICOMP\0" "\x05" "FISUB\0" \
|
60
|
+
"\x06" "FISUBR\0" "\x05" "FIDIV\0" "\x06" "FIDIVR\0" "\x06" "FCMOVB\0" "\x06" "FCMOVE\0" \
|
61
|
+
"\x07" "FCMOVBE\0" "\x06" "FCMOVU\0" "\x07" "FUCOMPP\0" "\x04" "FILD\0" "\x06" "FISTTP\0" \
|
62
|
+
"\x04" "FIST\0" "\x05" "FISTP\0" "\x07" "FCMOVNB\0" "\x07" "FCMOVNE\0" "\x08" "FCMOVNBE\0" \
|
63
|
+
"\x07" "FCMOVNU\0" "\x04" "FENI\0" "\x06" "FEDISI\0" "\x06" "FSETPM\0" "\x06" "FUCOMI\0" \
|
64
|
+
"\x05" "FCOMI\0" "\x06" "FRSTOR\0" "\x05" "FFREE\0" "\x05" "FUCOM\0" "\x06" "FUCOMP\0" \
|
65
|
+
"\x05" "FADDP\0" "\x05" "FMULP\0" "\x06" "FCOMPP\0" "\x06" "FSUBRP\0" "\x05" "FSUBP\0" \
|
66
|
+
"\x06" "FDIVRP\0" "\x05" "FDIVP\0" "\x04" "FBLD\0" "\x05" "FBSTP\0" "\x07" "FUCOMIP\0" \
|
67
|
+
"\x06" "FCOMIP\0" "\x03" "NOT\0" "\x03" "NEG\0" "\x03" "MUL\0" "\x03" "DIV\0" \
|
68
|
+
"\x04" "IDIV\0" "\x04" "SLDT\0" "\x03" "STR\0" "\x04" "LLDT\0" "\x03" "LTR\0" \
|
69
|
+
"\x04" "VERR\0" "\x04" "VERW\0" "\x04" "SGDT\0" "\x04" "SIDT\0" "\x04" "LGDT\0" \
|
70
|
+
"\x04" "LIDT\0" "\x04" "SMSW\0" "\x04" "LMSW\0" "\x06" "INVLPG\0" "\x06" "VMCALL\0" \
|
71
|
+
"\x08" "VMLAUNCH\0" "\x08" "VMRESUME\0" "\x06" "VMXOFF\0" "\x07" "MONITOR\0" \
|
72
|
+
"\x05" "MWAIT\0" "\x06" "XGETBV\0" "\x06" "XSETBV\0" "\x06" "VMFUNC\0" "\x04" "XEND\0" \
|
73
|
+
"\x05" "VMRUN\0" "\x07" "VMMCALL\0" "\x06" "VMLOAD\0" "\x06" "VMSAVE\0" "\x04" "STGI\0" \
|
74
|
+
"\x04" "CLGI\0" "\x06" "SKINIT\0" "\x07" "INVLPGA\0" "\x06" "SWAPGS\0" "\x06" "RDTSCP\0" \
|
75
|
+
"\x08" "PREFETCH\0" "\x09" "PREFETCHW\0" "\x05" "PI2FW\0" "\x05" "PI2FD\0" \
|
76
|
+
"\x05" "PF2IW\0" "\x05" "PF2ID\0" "\x06" "PFNACC\0" "\x07" "PFPNACC\0" "\x07" "PFCMPGE\0" \
|
77
|
+
"\x05" "PFMIN\0" "\x05" "PFRCP\0" "\x07" "PFRSQRT\0" "\x05" "PFSUB\0" "\x05" "PFADD\0" \
|
78
|
+
"\x07" "PFCMPGT\0" "\x05" "PFMAX\0" "\x08" "PFRCPIT1\0" "\x08" "PFRSQIT1\0" \
|
79
|
+
"\x06" "PFSUBR\0" "\x05" "PFACC\0" "\x07" "PFCMPEQ\0" "\x05" "PFMUL\0" "\x08" "PFRCPIT2\0" \
|
80
|
+
"\x07" "PMULHRW\0" "\x06" "PSWAPD\0" "\x07" "PAVGUSB\0" "\x06" "MOVUPS\0" "\x06" "MOVUPD\0" \
|
81
|
+
"\x05" "MOVSS\0" "\x05" "MOVSD\0" "\x07" "VMOVUPS\0" "\x07" "VMOVUPD\0" "\x06" "VMOVSS\0" \
|
82
|
+
"\x06" "VMOVSD\0" "\x07" "MOVHLPS\0" "\x06" "MOVLPS\0" "\x06" "MOVLPD\0" "\x08" "MOVSLDUP\0" \
|
83
|
+
"\x07" "MOVDDUP\0" "\x08" "VMOVHLPS\0" "\x07" "VMOVLPS\0" "\x07" "VMOVLPD\0" \
|
84
|
+
"\x09" "VMOVSLDUP\0" "\x08" "VMOVDDUP\0" "\x08" "UNPCKLPS\0" "\x08" "UNPCKLPD\0" \
|
85
|
+
"\x09" "VUNPCKLPS\0" "\x09" "VUNPCKLPD\0" "\x08" "UNPCKHPS\0" "\x08" "UNPCKHPD\0" \
|
86
|
+
"\x09" "VUNPCKHPS\0" "\x09" "VUNPCKHPD\0" "\x07" "MOVLHPS\0" "\x06" "MOVHPS\0" \
|
87
|
+
"\x06" "MOVHPD\0" "\x08" "MOVSHDUP\0" "\x08" "VMOVLHPS\0" "\x07" "VMOVHPS\0" \
|
88
|
+
"\x07" "VMOVHPD\0" "\x09" "VMOVSHDUP\0" "\x0b" "PREFETCHNTA\0" "\x0a" "PREFETCHT0\0" \
|
89
|
+
"\x0a" "PREFETCHT1\0" "\x0a" "PREFETCHT2\0" "\x06" "MOVAPS\0" "\x06" "MOVAPD\0" \
|
90
|
+
"\x07" "VMOVAPS\0" "\x07" "VMOVAPD\0" "\x08" "CVTPI2PS\0" "\x08" "CVTPI2PD\0" \
|
91
|
+
"\x08" "CVTSI2SS\0" "\x08" "CVTSI2SD\0" "\x09" "VCVTSI2SS\0" "\x09" "VCVTSI2SD\0" \
|
92
|
+
"\x07" "MOVNTPS\0" "\x07" "MOVNTPD\0" "\x07" "MOVNTSS\0" "\x07" "MOVNTSD\0" \
|
93
|
+
"\x08" "VMOVNTPS\0" "\x08" "VMOVNTPD\0" "\x09" "CVTTPS2PI\0" "\x09" "CVTTPD2PI\0" \
|
94
|
+
"\x09" "CVTTSS2SI\0" "\x09" "CVTTSD2SI\0" "\x0a" "VCVTTSS2SI\0" "\x0a" "VCVTTSD2SI\0" \
|
95
|
+
"\x08" "CVTPS2PI\0" "\x08" "CVTPD2PI\0" "\x08" "CVTSS2SI\0" "\x08" "CVTSD2SI\0" \
|
96
|
+
"\x09" "VCVTSS2SI\0" "\x09" "VCVTSD2SI\0" "\x07" "UCOMISS\0" "\x07" "UCOMISD\0" \
|
97
|
+
"\x08" "VUCOMISS\0" "\x08" "VUCOMISD\0" "\x06" "COMISS\0" "\x06" "COMISD\0" \
|
98
|
+
"\x07" "VCOMISS\0" "\x07" "VCOMISD\0" "\x08" "MOVMSKPS\0" "\x08" "MOVMSKPD\0" \
|
99
|
+
"\x09" "VMOVMSKPS\0" "\x09" "VMOVMSKPD\0" "\x06" "SQRTPS\0" "\x06" "SQRTPD\0" \
|
100
|
+
"\x06" "SQRTSS\0" "\x06" "SQRTSD\0" "\x07" "VSQRTPS\0" "\x07" "VSQRTPD\0" "\x07" "VSQRTSS\0" \
|
101
|
+
"\x07" "VSQRTSD\0" "\x07" "RSQRTPS\0" "\x07" "RSQRTSS\0" "\x08" "VRSQRTPS\0" \
|
102
|
+
"\x08" "VRSQRTSS\0" "\x05" "RCPPS\0" "\x05" "RCPSS\0" "\x06" "VRCPPS\0" "\x06" "VRCPSS\0" \
|
103
|
+
"\x05" "ANDPS\0" "\x05" "ANDPD\0" "\x06" "VANDPS\0" "\x06" "VANDPD\0" "\x06" "ANDNPS\0" \
|
104
|
+
"\x06" "ANDNPD\0" "\x07" "VANDNPS\0" "\x07" "VANDNPD\0" "\x04" "ORPS\0" "\x04" "ORPD\0" \
|
105
|
+
"\x05" "VORPS\0" "\x05" "VORPD\0" "\x05" "XORPS\0" "\x05" "XORPD\0" "\x06" "VXORPS\0" \
|
106
|
+
"\x06" "VXORPD\0" "\x05" "ADDPS\0" "\x05" "ADDPD\0" "\x05" "ADDSS\0" "\x05" "ADDSD\0" \
|
107
|
+
"\x06" "VADDPS\0" "\x06" "VADDPD\0" "\x06" "VADDSS\0" "\x06" "VADDSD\0" "\x05" "MULPS\0" \
|
108
|
+
"\x05" "MULPD\0" "\x05" "MULSS\0" "\x05" "MULSD\0" "\x06" "VMULPS\0" "\x06" "VMULPD\0" \
|
109
|
+
"\x06" "VMULSS\0" "\x06" "VMULSD\0" "\x08" "CVTPS2PD\0" "\x08" "CVTPD2PS\0" \
|
110
|
+
"\x08" "CVTSS2SD\0" "\x08" "CVTSD2SS\0" "\x09" "VCVTPS2PD\0" "\x09" "VCVTPD2PS\0" \
|
111
|
+
"\x09" "VCVTSS2SD\0" "\x09" "VCVTSD2SS\0" "\x08" "CVTDQ2PS\0" "\x08" "CVTPS2DQ\0" \
|
112
|
+
"\x09" "CVTTPS2DQ\0" "\x09" "VCVTDQ2PS\0" "\x09" "VCVTPS2DQ\0" "\x0a" "VCVTTPS2DQ\0" \
|
113
|
+
"\x05" "SUBPS\0" "\x05" "SUBPD\0" "\x05" "SUBSS\0" "\x05" "SUBSD\0" "\x06" "VSUBPS\0" \
|
114
|
+
"\x06" "VSUBPD\0" "\x06" "VSUBSS\0" "\x06" "VSUBSD\0" "\x05" "MINPS\0" "\x05" "MINPD\0" \
|
115
|
+
"\x05" "MINSS\0" "\x05" "MINSD\0" "\x06" "VMINPS\0" "\x06" "VMINPD\0" "\x06" "VMINSS\0" \
|
116
|
+
"\x06" "VMINSD\0" "\x05" "DIVPS\0" "\x05" "DIVPD\0" "\x05" "DIVSS\0" "\x05" "DIVSD\0" \
|
117
|
+
"\x06" "VDIVPS\0" "\x06" "VDIVPD\0" "\x06" "VDIVSS\0" "\x06" "VDIVSD\0" "\x05" "MAXPS\0" \
|
118
|
+
"\x05" "MAXPD\0" "\x05" "MAXSS\0" "\x05" "MAXSD\0" "\x06" "VMAXPS\0" "\x06" "VMAXPD\0" \
|
119
|
+
"\x06" "VMAXSS\0" "\x06" "VMAXSD\0" "\x09" "PUNPCKLBW\0" "\x0a" "VPUNPCKLBW\0" \
|
120
|
+
"\x09" "PUNPCKLWD\0" "\x0a" "VPUNPCKLWD\0" "\x09" "PUNPCKLDQ\0" "\x0a" "VPUNPCKLDQ\0" \
|
121
|
+
"\x08" "PACKSSWB\0" "\x09" "VPACKSSWB\0" "\x07" "PCMPGTB\0" "\x08" "VPCMPGTB\0" \
|
122
|
+
"\x07" "PCMPGTW\0" "\x08" "VPCMPGTW\0" "\x07" "PCMPGTD\0" "\x08" "VPCMPGTD\0" \
|
123
|
+
"\x08" "PACKUSWB\0" "\x09" "VPACKUSWB\0" "\x09" "PUNPCKHBW\0" "\x0a" "VPUNPCKHBW\0" \
|
124
|
+
"\x09" "PUNPCKHWD\0" "\x0a" "VPUNPCKHWD\0" "\x09" "PUNPCKHDQ\0" "\x0a" "VPUNPCKHDQ\0" \
|
125
|
+
"\x08" "PACKSSDW\0" "\x09" "VPACKSSDW\0" "\x0a" "PUNPCKLQDQ\0" "\x0b" "VPUNPCKLQDQ\0" \
|
126
|
+
"\x0a" "PUNPCKHQDQ\0" "\x0b" "VPUNPCKHQDQ\0" "\x04" "MOVD\0" "\x04" "MOVQ\0" \
|
127
|
+
"\x05" "VMOVD\0" "\x05" "VMOVQ\0" "\x06" "MOVDQA\0" "\x06" "MOVDQU\0" "\x07" "VMOVDQA\0" \
|
128
|
+
"\x07" "VMOVDQU\0" "\x06" "PSHUFW\0" "\x06" "PSHUFD\0" "\x07" "PSHUFHW\0" "\x07" "PSHUFLW\0" \
|
129
|
+
"\x07" "VPSHUFD\0" "\x08" "VPSHUFHW\0" "\x08" "VPSHUFLW\0" "\x07" "PCMPEQB\0" \
|
130
|
+
"\x08" "VPCMPEQB\0" "\x07" "PCMPEQW\0" "\x08" "VPCMPEQW\0" "\x07" "PCMPEQD\0" \
|
131
|
+
"\x08" "VPCMPEQD\0" "\x04" "EMMS\0" "\x0a" "VZEROUPPER\0" "\x08" "VZEROALL\0" \
|
132
|
+
"\x06" "VMREAD\0" "\x05" "EXTRQ\0" "\x07" "INSERTQ\0" "\x07" "VMWRITE\0" "\x08" "CVTPH2PS\0" \
|
133
|
+
"\x08" "CVTPS2PH\0" "\x06" "HADDPD\0" "\x06" "HADDPS\0" "\x07" "VHADDPD\0" \
|
134
|
+
"\x07" "VHADDPS\0" "\x06" "HSUBPD\0" "\x06" "HSUBPS\0" "\x07" "VHSUBPD\0" "\x07" "VHSUBPS\0" \
|
135
|
+
"\x05" "XSAVE\0" "\x07" "XSAVE64\0" "\x06" "LFENCE\0" "\x06" "XRSTOR\0" "\x08" "XRSTOR64\0" \
|
136
|
+
"\x06" "MFENCE\0" "\x08" "XSAVEOPT\0" "\x0a" "XSAVEOPT64\0" "\x06" "SFENCE\0" \
|
137
|
+
"\x07" "CLFLUSH\0" "\x06" "POPCNT\0" "\x03" "BSF\0" "\x05" "TZCNT\0" "\x03" "BSR\0" \
|
138
|
+
"\x05" "LZCNT\0" "\x07" "CMPEQPS\0" "\x07" "CMPLTPS\0" "\x07" "CMPLEPS\0" "\x0a" "CMPUNORDPS\0" \
|
139
|
+
"\x08" "CMPNEQPS\0" "\x08" "CMPNLTPS\0" "\x08" "CMPNLEPS\0" "\x08" "CMPORDPS\0" \
|
140
|
+
"\x07" "CMPEQPD\0" "\x07" "CMPLTPD\0" "\x07" "CMPLEPD\0" "\x0a" "CMPUNORDPD\0" \
|
141
|
+
"\x08" "CMPNEQPD\0" "\x08" "CMPNLTPD\0" "\x08" "CMPNLEPD\0" "\x08" "CMPORDPD\0" \
|
142
|
+
"\x07" "CMPEQSS\0" "\x07" "CMPLTSS\0" "\x07" "CMPLESS\0" "\x0a" "CMPUNORDSS\0" \
|
143
|
+
"\x08" "CMPNEQSS\0" "\x08" "CMPNLTSS\0" "\x08" "CMPNLESS\0" "\x08" "CMPORDSS\0" \
|
144
|
+
"\x07" "CMPEQSD\0" "\x07" "CMPLTSD\0" "\x07" "CMPLESD\0" "\x0a" "CMPUNORDSD\0" \
|
145
|
+
"\x08" "CMPNEQSD\0" "\x08" "CMPNLTSD\0" "\x08" "CMPNLESD\0" "\x08" "CMPORDSD\0" \
|
146
|
+
"\x08" "VCMPEQPS\0" "\x08" "VCMPLTPS\0" "\x08" "VCMPLEPS\0" "\x0b" "VCMPUNORDPS\0" \
|
147
|
+
"\x09" "VCMPNEQPS\0" "\x09" "VCMPNLTPS\0" "\x09" "VCMPNLEPS\0" "\x09" "VCMPORDPS\0" \
|
148
|
+
"\x0b" "VCMPEQ_UQPS\0" "\x09" "VCMPNGEPS\0" "\x09" "VCMPNGTPS\0" "\x0b" "VCMPFALSEPS\0" \
|
149
|
+
"\x0c" "VCMPNEQ_OQPS\0" "\x08" "VCMPGEPS\0" "\x08" "VCMPGTPS\0" "\x0a" "VCMPTRUEPS\0" \
|
150
|
+
"\x0b" "VCMPEQ_OSPS\0" "\x0b" "VCMPLT_OQPS\0" "\x0b" "VCMPLE_OQPS\0" "\x0d" "VCMPUNORD_SPS\0" \
|
151
|
+
"\x0c" "VCMPNEQ_USPS\0" "\x0c" "VCMPNLT_UQPS\0" "\x0c" "VCMPNLE_UQPS\0" "\x0b" "VCMPORD_SPS\0" \
|
152
|
+
"\x0b" "VCMPEQ_USPS\0" "\x0c" "VCMPNGE_UQPS\0" "\x0c" "VCMPNGT_UQPS\0" "\x0e" "VCMPFALSE_OSPS\0" \
|
153
|
+
"\x0c" "VCMPNEQ_OSPS\0" "\x0b" "VCMPGE_OQPS\0" "\x0b" "VCMPGT_OQPS\0" "\x0d" "VCMPTRUE_USPS\0" \
|
154
|
+
"\x08" "VCMPEQPD\0" "\x08" "VCMPLTPD\0" "\x08" "VCMPLEPD\0" "\x0b" "VCMPUNORDPD\0" \
|
155
|
+
"\x09" "VCMPNEQPD\0" "\x09" "VCMPNLTPD\0" "\x09" "VCMPNLEPD\0" "\x09" "VCMPORDPD\0" \
|
156
|
+
"\x0b" "VCMPEQ_UQPD\0" "\x09" "VCMPNGEPD\0" "\x09" "VCMPNGTPD\0" "\x0b" "VCMPFALSEPD\0" \
|
157
|
+
"\x0c" "VCMPNEQ_OQPD\0" "\x08" "VCMPGEPD\0" "\x08" "VCMPGTPD\0" "\x0a" "VCMPTRUEPD\0" \
|
158
|
+
"\x0b" "VCMPEQ_OSPD\0" "\x0b" "VCMPLT_OQPD\0" "\x0b" "VCMPLE_OQPD\0" "\x0d" "VCMPUNORD_SPD\0" \
|
159
|
+
"\x0c" "VCMPNEQ_USPD\0" "\x0c" "VCMPNLT_UQPD\0" "\x0c" "VCMPNLE_UQPD\0" "\x0b" "VCMPORD_SPD\0" \
|
160
|
+
"\x0b" "VCMPEQ_USPD\0" "\x0c" "VCMPNGE_UQPD\0" "\x0c" "VCMPNGT_UQPD\0" "\x0e" "VCMPFALSE_OSPD\0" \
|
161
|
+
"\x0c" "VCMPNEQ_OSPD\0" "\x0b" "VCMPGE_OQPD\0" "\x0b" "VCMPGT_OQPD\0" "\x0d" "VCMPTRUE_USPD\0" \
|
162
|
+
"\x08" "VCMPEQSS\0" "\x08" "VCMPLTSS\0" "\x08" "VCMPLESS\0" "\x0b" "VCMPUNORDSS\0" \
|
163
|
+
"\x09" "VCMPNEQSS\0" "\x09" "VCMPNLTSS\0" "\x09" "VCMPNLESS\0" "\x09" "VCMPORDSS\0" \
|
164
|
+
"\x0b" "VCMPEQ_UQSS\0" "\x09" "VCMPNGESS\0" "\x09" "VCMPNGTSS\0" "\x0b" "VCMPFALSESS\0" \
|
165
|
+
"\x0c" "VCMPNEQ_OQSS\0" "\x08" "VCMPGESS\0" "\x08" "VCMPGTSS\0" "\x0a" "VCMPTRUESS\0" \
|
166
|
+
"\x0b" "VCMPEQ_OSSS\0" "\x0b" "VCMPLT_OQSS\0" "\x0b" "VCMPLE_OQSS\0" "\x0d" "VCMPUNORD_SSS\0" \
|
167
|
+
"\x0c" "VCMPNEQ_USSS\0" "\x0c" "VCMPNLT_UQSS\0" "\x0c" "VCMPNLE_UQSS\0" "\x0b" "VCMPORD_SSS\0" \
|
168
|
+
"\x0b" "VCMPEQ_USSS\0" "\x0c" "VCMPNGE_UQSS\0" "\x0c" "VCMPNGT_UQSS\0" "\x0e" "VCMPFALSE_OSSS\0" \
|
169
|
+
"\x0c" "VCMPNEQ_OSSS\0" "\x0b" "VCMPGE_OQSS\0" "\x0b" "VCMPGT_OQSS\0" "\x0d" "VCMPTRUE_USSS\0" \
|
170
|
+
"\x08" "VCMPEQSD\0" "\x08" "VCMPLTSD\0" "\x08" "VCMPLESD\0" "\x0b" "VCMPUNORDSD\0" \
|
171
|
+
"\x09" "VCMPNEQSD\0" "\x09" "VCMPNLTSD\0" "\x09" "VCMPNLESD\0" "\x09" "VCMPORDSD\0" \
|
172
|
+
"\x0b" "VCMPEQ_UQSD\0" "\x09" "VCMPNGESD\0" "\x09" "VCMPNGTSD\0" "\x0b" "VCMPFALSESD\0" \
|
173
|
+
"\x0c" "VCMPNEQ_OQSD\0" "\x08" "VCMPGESD\0" "\x08" "VCMPGTSD\0" "\x0a" "VCMPTRUESD\0" \
|
174
|
+
"\x0b" "VCMPEQ_OSSD\0" "\x0b" "VCMPLT_OQSD\0" "\x0b" "VCMPLE_OQSD\0" "\x0d" "VCMPUNORD_SSD\0" \
|
175
|
+
"\x0c" "VCMPNEQ_USSD\0" "\x0c" "VCMPNLT_UQSD\0" "\x0c" "VCMPNLE_UQSD\0" "\x0b" "VCMPORD_SSD\0" \
|
176
|
+
"\x0b" "VCMPEQ_USSD\0" "\x0c" "VCMPNGE_UQSD\0" "\x0c" "VCMPNGT_UQSD\0" "\x0e" "VCMPFALSE_OSSD\0" \
|
177
|
+
"\x0c" "VCMPNEQ_OSSD\0" "\x0b" "VCMPGE_OQSD\0" "\x0b" "VCMPGT_OQSD\0" "\x0d" "VCMPTRUE_USSD\0" \
|
178
|
+
"\x06" "PINSRW\0" "\x07" "VPINSRW\0" "\x06" "PEXTRW\0" "\x07" "VPEXTRW\0" "\x06" "SHUFPS\0" \
|
179
|
+
"\x06" "SHUFPD\0" "\x07" "VSHUFPS\0" "\x07" "VSHUFPD\0" "\x09" "CMPXCHG8B\0" \
|
180
|
+
"\x0a" "CMPXCHG16B\0" "\x07" "VMPTRST\0" "\x08" "ADDSUBPD\0" "\x08" "ADDSUBPS\0" \
|
181
|
+
"\x09" "VADDSUBPD\0" "\x09" "VADDSUBPS\0" "\x05" "PSRLW\0" "\x06" "VPSRLW\0" \
|
182
|
+
"\x05" "PSRLD\0" "\x06" "VPSRLD\0" "\x05" "PSRLQ\0" "\x06" "VPSRLQ\0" "\x05" "PADDQ\0" \
|
183
|
+
"\x06" "VPADDQ\0" "\x06" "PMULLW\0" "\x07" "VPMULLW\0" "\x07" "MOVQ2DQ\0" "\x07" "MOVDQ2Q\0" \
|
184
|
+
"\x08" "PMOVMSKB\0" "\x09" "VPMOVMSKB\0" "\x07" "PSUBUSB\0" "\x08" "VPSUBUSB\0" \
|
185
|
+
"\x07" "PSUBUSW\0" "\x08" "VPSUBUSW\0" "\x06" "PMINUB\0" "\x07" "VPMINUB\0" \
|
186
|
+
"\x04" "PAND\0" "\x05" "VPAND\0" "\x07" "PADDUSB\0" "\x08" "VPADDUSW\0" "\x07" "PADDUSW\0" \
|
187
|
+
"\x06" "PMAXUB\0" "\x07" "VPMAXUB\0" "\x05" "PANDN\0" "\x06" "VPANDN\0" "\x05" "PAVGB\0" \
|
188
|
+
"\x06" "VPAVGB\0" "\x05" "PSRAW\0" "\x06" "VPSRAW\0" "\x05" "PSRAD\0" "\x06" "VPSRAD\0" \
|
189
|
+
"\x05" "PAVGW\0" "\x06" "VPAVGW\0" "\x07" "PMULHUW\0" "\x08" "VPMULHUW\0" "\x06" "PMULHW\0" \
|
190
|
+
"\x07" "VPMULHW\0" "\x09" "CVTTPD2DQ\0" "\x08" "CVTDQ2PD\0" "\x08" "CVTPD2DQ\0" \
|
191
|
+
"\x0a" "VCVTTPD2DQ\0" "\x09" "VCVTDQ2PD\0" "\x09" "VCVTPD2DQ\0" "\x06" "MOVNTQ\0" \
|
192
|
+
"\x07" "MOVNTDQ\0" "\x08" "VMOVNTDQ\0" "\x06" "PSUBSB\0" "\x07" "VPSUBSB\0" \
|
193
|
+
"\x06" "PSUBSW\0" "\x07" "VPSUBSW\0" "\x06" "PMINSW\0" "\x07" "VPMINSW\0" "\x03" "POR\0" \
|
194
|
+
"\x04" "VPOR\0" "\x06" "PADDSB\0" "\x07" "VPADDSB\0" "\x06" "PADDSW\0" "\x07" "VPADDSW\0" \
|
195
|
+
"\x06" "PMAXSW\0" "\x07" "VPMAXSW\0" "\x04" "PXOR\0" "\x05" "VPXOR\0" "\x05" "LDDQU\0" \
|
196
|
+
"\x06" "VLDDQU\0" "\x05" "PSLLW\0" "\x06" "VPSLLW\0" "\x05" "PSLLD\0" "\x06" "VPSLLD\0" \
|
197
|
+
"\x05" "PSLLQ\0" "\x06" "VPSLLQ\0" "\x07" "PMULUDQ\0" "\x08" "VPMULUDQ\0" "\x07" "PMADDWD\0" \
|
198
|
+
"\x08" "VPMADDWD\0" "\x06" "PSADBW\0" "\x07" "VPSADBW\0" "\x08" "MASKMOVQ\0" \
|
199
|
+
"\x0a" "MASKMOVDQU\0" "\x0b" "VMASKMOVDQU\0" "\x05" "PSUBB\0" "\x06" "VPSUBB\0" \
|
200
|
+
"\x05" "PSUBW\0" "\x06" "VPSUBW\0" "\x05" "PSUBD\0" "\x06" "VPSUBD\0" "\x05" "PSUBQ\0" \
|
201
|
+
"\x06" "VPSUBQ\0" "\x05" "PADDB\0" "\x06" "VPADDB\0" "\x05" "PADDW\0" "\x06" "VPADDW\0" \
|
202
|
+
"\x05" "PADDD\0" "\x06" "VPADDD\0" "\x07" "FNSTENV\0" "\x06" "FSTENV\0" "\x06" "FNSTCW\0" \
|
203
|
+
"\x05" "FSTCW\0" "\x06" "FNCLEX\0" "\x05" "FCLEX\0" "\x06" "FNINIT\0" "\x05" "FINIT\0" \
|
204
|
+
"\x06" "FNSAVE\0" "\x05" "FSAVE\0" "\x06" "FNSTSW\0" "\x05" "FSTSW\0" "\x06" "PSHUFB\0" \
|
205
|
+
"\x07" "VPSHUFB\0" "\x06" "PHADDW\0" "\x07" "VPHADDW\0" "\x06" "PHADDD\0" "\x07" "VPHADDD\0" \
|
206
|
+
"\x07" "PHADDSW\0" "\x08" "VPHADDSW\0" "\x09" "PMADDUBSW\0" "\x0a" "VPMADDUBSW\0" \
|
207
|
+
"\x06" "PHSUBW\0" "\x07" "VPHSUBW\0" "\x06" "PHSUBD\0" "\x07" "VPHSUBD\0" "\x07" "PHSUBSW\0" \
|
208
|
+
"\x08" "VPHSUBSW\0" "\x06" "PSIGNB\0" "\x07" "VPSIGNB\0" "\x06" "PSIGNW\0" \
|
209
|
+
"\x07" "VPSIGNW\0" "\x06" "PSIGND\0" "\x07" "VPSIGND\0" "\x08" "PMULHRSW\0" \
|
210
|
+
"\x09" "VPMULHRSW\0" "\x09" "VPERMILPS\0" "\x09" "VPERMILPD\0" "\x07" "VTESTPS\0" \
|
211
|
+
"\x07" "VTESTPD\0" "\x08" "PBLENDVB\0" "\x08" "BLENDVPS\0" "\x08" "BLENDVPD\0" \
|
212
|
+
"\x05" "PTEST\0" "\x06" "VPTEST\0" "\x0c" "VBROADCASTSS\0" "\x0c" "VBROADCASTSD\0" \
|
213
|
+
"\x0e" "VBROADCASTF128\0" "\x05" "PABSB\0" "\x06" "VPABSB\0" "\x05" "PABSW\0" \
|
214
|
+
"\x06" "VPABSW\0" "\x05" "PABSD\0" "\x06" "VPABSD\0" "\x08" "PMOVSXBW\0" "\x09" "VPMOVSXBW\0" \
|
215
|
+
"\x08" "PMOVSXBD\0" "\x09" "VPMOVSXBD\0" "\x08" "PMOVSXBQ\0" "\x09" "VPMOVSXBQ\0" \
|
216
|
+
"\x08" "PMOVSXWD\0" "\x09" "VPMOVSXWD\0" "\x08" "PMOVSXWQ\0" "\x09" "VPMOVSXWQ\0" \
|
217
|
+
"\x08" "PMOVSXDQ\0" "\x09" "VPMOVSXDQ\0" "\x06" "PMULDQ\0" "\x07" "VPMULDQ\0" \
|
218
|
+
"\x07" "PCMPEQQ\0" "\x08" "VPCMPEQQ\0" "\x08" "MOVNTDQA\0" "\x09" "VMOVNTDQA\0" \
|
219
|
+
"\x08" "PACKUSDW\0" "\x09" "VPACKUSDW\0" "\x0a" "VMASKMOVPS\0" "\x0a" "VMASKMOVPD\0" \
|
220
|
+
"\x08" "PMOVZXBW\0" "\x09" "VPMOVZXBW\0" "\x08" "PMOVZXBD\0" "\x09" "VPMOVZXBD\0" \
|
221
|
+
"\x08" "PMOVZXBQ\0" "\x09" "VPMOVZXBQ\0" "\x08" "PMOVZXWD\0" "\x09" "VPMOVZXWD\0" \
|
222
|
+
"\x08" "PMOVZXWQ\0" "\x09" "VPMOVZXWQ\0" "\x08" "PMOVZXDQ\0" "\x09" "VPMOVZXDQ\0" \
|
223
|
+
"\x07" "PCMPGTQ\0" "\x08" "VPCMPGTQ\0" "\x06" "PMINSB\0" "\x07" "VPMINSB\0" \
|
224
|
+
"\x06" "PMINSD\0" "\x07" "VPMINSD\0" "\x06" "PMINUW\0" "\x07" "VPMINUW\0" "\x06" "PMINUD\0" \
|
225
|
+
"\x07" "VPMINUD\0" "\x06" "PMAXSB\0" "\x07" "VPMAXSB\0" "\x06" "PMAXSD\0" "\x07" "VPMAXSD\0" \
|
226
|
+
"\x06" "PMAXUW\0" "\x07" "VPMAXUW\0" "\x06" "PMAXUD\0" "\x07" "VPMAXUD\0" "\x06" "PMULLD\0" \
|
227
|
+
"\x07" "VPMULLD\0" "\x0a" "PHMINPOSUW\0" "\x0b" "VPHMINPOSUW\0" "\x06" "INVEPT\0" \
|
228
|
+
"\x07" "INVVPID\0" "\x07" "INVPCID\0" "\x0e" "VFMADDSUB132PS\0" "\x0e" "VFMADDSUB132PD\0" \
|
229
|
+
"\x0e" "VFMSUBADD132PS\0" "\x0e" "VFMSUBADD132PD\0" "\x0b" "VFMADD132PS\0" \
|
230
|
+
"\x0b" "VFMADD132PD\0" "\x0b" "VFMADD132SS\0" "\x0b" "VFMADD132SD\0" "\x0b" "VFMSUB132PS\0" \
|
231
|
+
"\x0b" "VFMSUB132PD\0" "\x0b" "VFMSUB132SS\0" "\x0b" "VFMSUB132SD\0" "\x0c" "VFNMADD132PS\0" \
|
232
|
+
"\x0c" "VFNMADD132PD\0" "\x0c" "VFNMADD132SS\0" "\x0c" "VFNMADD132SD\0" "\x0c" "VFNMSUB132PS\0" \
|
233
|
+
"\x0c" "VFNMSUB132PD\0" "\x0c" "VFNMSUB132SS\0" "\x0c" "VFNMSUB132SD\0" "\x0e" "VFMADDSUB213PS\0" \
|
234
|
+
"\x0e" "VFMADDSUB213PD\0" "\x0e" "VFMSUBADD213PS\0" "\x0e" "VFMSUBADD213PD\0" \
|
235
|
+
"\x0b" "VFMADD213PS\0" "\x0b" "VFMADD213PD\0" "\x0b" "VFMADD213SS\0" "\x0b" "VFMADD213SD\0" \
|
236
|
+
"\x0b" "VFMSUB213PS\0" "\x0b" "VFMSUB213PD\0" "\x0b" "VFMSUB213SS\0" "\x0b" "VFMSUB213SD\0" \
|
237
|
+
"\x0c" "VFNMADD213PS\0" "\x0c" "VFNMADD213PD\0" "\x0c" "VFNMADD213SS\0" "\x0c" "VFNMADD213SD\0" \
|
238
|
+
"\x0c" "VFNMSUB213PS\0" "\x0c" "VFNMSUB213PD\0" "\x0c" "VFNMSUB213SS\0" "\x0c" "VFNMSUB213SD\0" \
|
239
|
+
"\x0e" "VFMADDSUB231PS\0" "\x0e" "VFMADDSUB231PD\0" "\x0e" "VFMSUBADD231PS\0" \
|
240
|
+
"\x0e" "VFMSUBADD231PD\0" "\x0b" "VFMADD231PS\0" "\x0b" "VFMADD231PD\0" "\x0b" "VFMADD231SS\0" \
|
241
|
+
"\x0b" "VFMADD231SD\0" "\x0b" "VFMSUB231PS\0" "\x0b" "VFMSUB231PD\0" "\x0b" "VFMSUB231SS\0" \
|
242
|
+
"\x0b" "VFMSUB231SD\0" "\x0c" "VFNMADD231PS\0" "\x0c" "VFNMADD231PD\0" "\x0c" "VFNMADD231SS\0" \
|
243
|
+
"\x0c" "VFNMADD231SD\0" "\x0c" "VFNMSUB231PS\0" "\x0c" "VFNMSUB231PD\0" "\x0c" "VFNMSUB231SS\0" \
|
244
|
+
"\x0c" "VFNMSUB231SD\0" "\x06" "AESIMC\0" "\x07" "VAESIMC\0" "\x06" "AESENC\0" \
|
245
|
+
"\x07" "VAESENC\0" "\x0a" "AESENCLAST\0" "\x0b" "VAESENCLAST\0" "\x06" "AESDEC\0" \
|
246
|
+
"\x07" "VAESDEC\0" "\x0a" "AESDECLAST\0" "\x0b" "VAESDECLAST\0" "\x05" "MOVBE\0" \
|
247
|
+
"\x05" "CRC32\0" "\x0a" "VPERM2F128\0" "\x07" "ROUNDPS\0" "\x08" "VROUNDPS\0" \
|
248
|
+
"\x07" "ROUNDPD\0" "\x08" "VROUNDPD\0" "\x07" "ROUNDSS\0" "\x08" "VROUNDSS\0" \
|
249
|
+
"\x07" "ROUNDSD\0" "\x08" "VROUNDSD\0" "\x07" "BLENDPS\0" "\x08" "VBLENDPS\0" \
|
250
|
+
"\x07" "BLENDPD\0" "\x08" "VBLENDPD\0" "\x07" "PBLENDW\0" "\x08" "VPBLENDW\0" \
|
251
|
+
"\x07" "PALIGNR\0" "\x08" "VPALIGNR\0" "\x06" "PEXTRB\0" "\x07" "VPEXTRB\0" \
|
252
|
+
"\x06" "PEXTRD\0" "\x06" "PEXTRQ\0" "\x07" "VPEXTRD\0" "\x07" "VPEXTRQ\0" "\x09" "EXTRACTPS\0" \
|
253
|
+
"\x0a" "VEXTRACTPS\0" "\x0b" "VINSERTF128\0" "\x0c" "VEXTRACTF128\0" "\x06" "PINSRB\0" \
|
254
|
+
"\x07" "VPINSRB\0" "\x08" "INSERTPS\0" "\x09" "VINSERTPS\0" "\x06" "PINSRD\0" \
|
255
|
+
"\x06" "PINSRQ\0" "\x07" "VPINSRD\0" "\x07" "VPINSRQ\0" "\x04" "DPPS\0" "\x05" "VDPPS\0" \
|
256
|
+
"\x04" "DPPD\0" "\x05" "VDPPD\0" "\x07" "MPSADBW\0" "\x08" "VMPSADBW\0" "\x09" "PCLMULQDQ\0" \
|
257
|
+
"\x0a" "VPCLMULQDQ\0" "\x09" "VBLENDVPS\0" "\x09" "VBLENDVPD\0" "\x09" "VPBLENDVB\0" \
|
258
|
+
"\x09" "PCMPESTRM\0" "\x0a" "VPCMPESTRM\0" "\x09" "PCMPESTRI\0" "\x0a" "VPCMPESTRI\0" \
|
259
|
+
"\x09" "PCMPISTRM\0" "\x0a" "VPCMPISTRM\0" "\x09" "PCMPISTRI\0" "\x0a" "VPCMPISTRI\0" \
|
260
|
+
"\x0f" "AESKEYGENASSIST\0" "\x10" "VAESKEYGENASSIST\0" "\x06" "PSRLDQ\0" "\x07" "VPSRLDQ\0" \
|
261
|
+
"\x06" "PSLLDQ\0" "\x07" "VPSLLDQ\0" "\x06" "FXSAVE\0" "\x08" "FXSAVE64\0" \
|
262
|
+
"\x08" "RDFSBASE\0" "\x07" "FXRSTOR\0" "\x09" "FXRSTOR64\0" "\x08" "RDGSBASE\0" \
|
263
|
+
"\x07" "LDMXCSR\0" "\x08" "WRFSBASE\0" "\x08" "VLDMXCSR\0" "\x07" "STMXCSR\0" \
|
264
|
+
"\x08" "WRGSBASE\0" "\x08" "VSTMXCSR\0" "\x07" "VMPTRLD\0" "\x07" "VMCLEAR\0" \
|
265
|
+
"\x05" "VMXON\0" "\x06" "MOVSXD\0" "\x05" "PAUSE\0" "\x04" "WAIT\0" "\x06" "RDRAND\0" \
|
266
|
+
"\x06" "_3DNOW\0";
|
267
|
+
|
268
|
+
const _WRegister _REGISTERS[] = {
|
269
|
+
{ 3, "RAX" }, { 3, "RCX" }, { 3, "RDX" }, { 3, "RBX" }, { 3, "RSP" }, { 3, "RBP" }, { 3, "RSI" }, { 3, "RDI" }, { 2, "R8" }, { 2, "R9" }, { 3, "R10" }, { 3, "R11" }, { 3, "R12" }, { 3, "R13" }, { 3, "R14" }, { 3, "R15" },
|
270
|
+
{ 3, "EAX" }, { 3, "ECX" }, { 3, "EDX" }, { 3, "EBX" }, { 3, "ESP" }, { 3, "EBP" }, { 3, "ESI" }, { 3, "EDI" }, { 3, "R8D" }, { 3, "R9D" }, { 4, "R10D" }, { 4, "R11D" }, { 4, "R12D" }, { 4, "R13D" }, { 4, "R14D" }, { 4, "R15D" },
|
271
|
+
{ 2, "AX" }, { 2, "CX" }, { 2, "DX" }, { 2, "BX" }, { 2, "SP" }, { 2, "BP" }, { 2, "SI" }, { 2, "DI" }, { 3, "R8W" }, { 3, "R9W" }, { 4, "R10W" }, { 4, "R11W" }, { 4, "R12W" }, { 4, "R13W" }, { 4, "R14W" }, { 4, "R15W" },
|
272
|
+
{ 2, "AL" }, { 2, "CL" }, { 2, "DL" }, { 2, "BL" }, { 2, "AH" }, { 2, "CH" }, { 2, "DH" }, { 2, "BH" }, { 3, "R8B" }, { 3, "R9B" }, { 4, "R10B" }, { 4, "R11B" }, { 4, "R12B" }, { 4, "R13B" }, { 4, "R14B" }, { 4, "R15B" },
|
273
|
+
{ 3, "SPL" }, { 3, "BPL" }, { 3, "SIL" }, { 3, "DIL" },
|
274
|
+
{ 2, "ES" }, { 2, "CS" }, { 2, "SS" }, { 2, "DS" }, { 2, "FS" }, { 2, "GS" },
|
275
|
+
{ 3, "RIP" },
|
276
|
+
{ 3, "ST0" }, { 3, "ST1" }, { 3, "ST2" }, { 3, "ST3" }, { 3, "ST4" }, { 3, "ST5" }, { 3, "ST6" }, { 3, "ST7" },
|
277
|
+
{ 3, "MM0" }, { 3, "MM1" }, { 3, "MM2" }, { 3, "MM3" }, { 3, "MM4" }, { 3, "MM5" }, { 3, "MM6" }, { 3, "MM7" },
|
278
|
+
{ 4, "XMM0" }, { 4, "XMM1" }, { 4, "XMM2" }, { 4, "XMM3" }, { 4, "XMM4" }, { 4, "XMM5" }, { 4, "XMM6" }, { 4, "XMM7" }, { 4, "XMM8" }, { 4, "XMM9" }, { 5, "XMM10" }, { 5, "XMM11" }, { 5, "XMM12" }, { 5, "XMM13" }, { 5, "XMM14" }, { 5, "XMM15" },
|
279
|
+
{ 4, "YMM0" }, { 4, "YMM1" }, { 4, "YMM2" }, { 4, "YMM3" }, { 4, "YMM4" }, { 4, "YMM5" }, { 4, "YMM6" }, { 4, "YMM7" }, { 4, "YMM8" }, { 4, "YMM9" }, { 5, "YMM10" }, { 5, "YMM11" }, { 5, "YMM12" }, { 5, "YMM13" }, { 5, "YMM14" }, { 5, "YMM15" },
|
280
|
+
{ 3, "CR0" }, { 0, "" }, { 3, "CR2" }, { 3, "CR3" }, { 3, "CR4" }, { 0, "" }, { 0, "" }, { 0, "" }, { 3, "CR8" },
|
281
|
+
{ 3, "DR0" }, { 3, "DR1" }, { 3, "DR2" }, { 3, "DR3" }, { 0, "" }, { 0, "" }, { 3, "DR6" }, { 3, "DR7" }
|
282
|
+
};
|
283
|
+
|
284
|
+
#endif /* DISTORM_LIGHT */
|
@@ -0,0 +1,1290 @@
|
|
1
|
+
/*
|
2
|
+
operands.c
|
3
|
+
|
4
|
+
diStorm3 - Powerful disassembler for X86/AMD64
|
5
|
+
http://ragestorm.net/distorm/
|
6
|
+
distorm at gmail dot com
|
7
|
+
Copyright (C) 2003-2016 Gil Dabah
|
8
|
+
This library is licensed under the BSD license. See the file COPYING.
|
9
|
+
*/
|
10
|
+
|
11
|
+
|
12
|
+
#include "config.h"
|
13
|
+
#include "operands.h"
|
14
|
+
#include "x86defs.h"
|
15
|
+
#include "insts.h"
|
16
|
+
#include "../include/mnemonics.h"
|
17
|
+
|
18
|
+
|
19
|
+
/* Maps a register to its register-class mask. */
|
20
|
+
uint32_t _REGISTERTORCLASS[] = /* Based on _RegisterType enumeration! */
|
21
|
+
{RM_AX, RM_CX, RM_DX, RM_BX, RM_SP, RM_BP, RM_SI, RM_DI, RM_R8, RM_R9, RM_R10, RM_R11, RM_R12, RM_R13, RM_R14, RM_R15,
|
22
|
+
RM_AX, RM_CX, RM_DX, RM_BX, RM_SP, RM_BP, RM_SI, RM_DI, RM_R8, RM_R9, RM_R10, RM_R11, RM_R12, RM_R13, RM_R14, RM_R15,
|
23
|
+
RM_AX, RM_CX, RM_DX, RM_BX, RM_SP, RM_BP, RM_SI, RM_DI, RM_R8, RM_R9, RM_R10, RM_R11, RM_R12, RM_R13, RM_R14, RM_R15,
|
24
|
+
RM_AX, RM_CX, RM_DX, RM_BX, RM_AX, RM_CX, RM_DX, RM_BX, RM_R8, RM_R9, RM_R10, RM_R11, RM_R12, RM_R13, RM_R14, RM_R15,
|
25
|
+
RM_SP, RM_BP, RM_SI, RM_DI,
|
26
|
+
0, 0, 0, 0, 0, 0,
|
27
|
+
0,
|
28
|
+
RM_FPU, RM_FPU, RM_FPU, RM_FPU, RM_FPU, RM_FPU, RM_FPU, RM_FPU,
|
29
|
+
RM_MMX, RM_MMX, RM_MMX, RM_MMX, RM_MMX, RM_MMX, RM_MMX, RM_MMX,
|
30
|
+
RM_SSE, RM_SSE, RM_SSE, RM_SSE, RM_SSE, RM_SSE, RM_SSE, RM_SSE, RM_SSE, RM_SSE, RM_SSE, RM_SSE, RM_SSE, RM_SSE, RM_SSE, RM_SSE,
|
31
|
+
RM_AVX, RM_AVX, RM_AVX, RM_AVX, RM_AVX, RM_AVX, RM_AVX, RM_AVX, RM_AVX, RM_AVX, RM_AVX, RM_AVX, RM_AVX, RM_AVX, RM_AVX, RM_AVX,
|
32
|
+
RM_CR, 0, RM_CR, RM_CR, RM_CR, 0, 0, 0, RM_CR,
|
33
|
+
RM_DR, RM_DR, RM_DR, RM_DR, 0, 0, RM_DR, RM_DR
|
34
|
+
};
|
35
|
+
|
36
|
+
typedef enum {OPERAND_SIZE_NONE = 0, OPERAND_SIZE8, OPERAND_SIZE16, OPERAND_SIZE32, OPERAND_SIZE64, OPERAND_SIZE80, OPERAND_SIZE128, OPERAND_SIZE256} _OperandSizeType;
|
37
|
+
static uint16_t _OPSIZETOINT[] = {0, 8, 16, 32, 64, 80, 128, 256};
|
38
|
+
|
39
|
+
/* A helper function to fix the 8 bits register if REX is used (to support SIL, DIL, etc). */
|
40
|
+
static unsigned int _FASTCALL_ operands_fix_8bit_rex_base(unsigned int reg)
|
41
|
+
{
|
42
|
+
if ((reg >= 4) && (reg < 8)) return reg + REGS8_REX_BASE - 4;
|
43
|
+
return reg + REGS8_BASE;
|
44
|
+
}
|
45
|
+
|
46
|
+
/* A helper function to set operand's type and size. */
|
47
|
+
static void _FASTCALL_ operands_set_ts(_Operand* op, _OperandType type, uint16_t size)
|
48
|
+
{
|
49
|
+
op->type = type;
|
50
|
+
op->size = size;
|
51
|
+
}
|
52
|
+
|
53
|
+
/* A helper function to set operand's type, size and index. */
|
54
|
+
static void _FASTCALL_ operands_set_tsi(_Operand* op, _OperandType type, uint16_t size, unsigned int index)
|
55
|
+
{
|
56
|
+
op->type = type;
|
57
|
+
op->index = (uint8_t)index;
|
58
|
+
op->size = size;
|
59
|
+
}
|
60
|
+
|
61
|
+
/* A helper function to read an unsigned integer from the stream safely. */
|
62
|
+
static int _FASTCALL_ read_stream_safe_uint(_CodeInfo* ci, void* result, unsigned int size)
|
63
|
+
{
|
64
|
+
ci->codeLen -= size;
|
65
|
+
if (ci->codeLen < 0) return FALSE;
|
66
|
+
switch (size)
|
67
|
+
{
|
68
|
+
case 1: *(uint8_t*)result = *(uint8_t*)ci->code; break;
|
69
|
+
case 2: *(uint16_t*)result = RUSHORT(ci->code); break;
|
70
|
+
case 4: *(uint32_t*)result = RULONG(ci->code); break;
|
71
|
+
case 8: *(uint64_t*)result = RULLONG(ci->code); break;
|
72
|
+
}
|
73
|
+
ci->code += size;
|
74
|
+
return TRUE;
|
75
|
+
}
|
76
|
+
|
77
|
+
/* A helper function to read a signed integer from the stream safely. */
|
78
|
+
static int _FASTCALL_ read_stream_safe_sint(_CodeInfo* ci, int64_t* result, unsigned int size)
|
79
|
+
{
|
80
|
+
ci->codeLen -= size;
|
81
|
+
if (ci->codeLen < 0) return FALSE;
|
82
|
+
switch (size)
|
83
|
+
{
|
84
|
+
case 1: *result = *(int8_t*)ci->code; break;
|
85
|
+
case 2: *result = RSHORT(ci->code); break;
|
86
|
+
case 4: *result = RLONG(ci->code); break;
|
87
|
+
case 8: *result = RLLONG(ci->code); break;
|
88
|
+
}
|
89
|
+
ci->code += size;
|
90
|
+
return TRUE;
|
91
|
+
}
|
92
|
+
|
93
|
+
/*
|
94
|
+
* SIB decoding is the most confusing part when decoding IA-32 instructions.
|
95
|
+
* This explanation should clear up some stuff.
|
96
|
+
*
|
97
|
+
* ! When base == 5, use EBP as the base register !
|
98
|
+
* if (rm == 4) {
|
99
|
+
* if mod == 01, decode SIB byte and ALSO read a 8 bits displacement.
|
100
|
+
* if mod == 10, decode SIB byte and ALSO read a 32 bits displacement.
|
101
|
+
* if mod == 11 <-- EXCEPTION, this is a general-purpose register and mustn't lead to SIB decoding!
|
102
|
+
* ; So far so good, now the confusing part comes in with mod == 0 and base=5, but no worry.
|
103
|
+
* if (mod == 00) {
|
104
|
+
* decode SIB byte WITHOUT any displacement.
|
105
|
+
* EXCEPTION!!! when base == 5, read a 32 bits displacement, but this time DO NOT use (EBP) BASE at all!
|
106
|
+
* }
|
107
|
+
*
|
108
|
+
* NOTE: base could specify None (no base register) if base==5 and mod==0, but then you also need DISP32.
|
109
|
+
* }
|
110
|
+
*/
|
111
|
+
static void operands_extract_sib(_DInst* di, _OperandNumberType opNum,
|
112
|
+
_PrefixState* ps, _DecodeType effAdrSz,
|
113
|
+
unsigned int sib, unsigned int mod)
|
114
|
+
{
|
115
|
+
unsigned int scale = 0, index = 0, base = 0;
|
116
|
+
unsigned int vrex = ps->vrex;
|
117
|
+
uint8_t* pIndex = NULL;
|
118
|
+
|
119
|
+
_Operand* op = &di->ops[opNum];
|
120
|
+
|
121
|
+
/*
|
122
|
+
* SIB bits:
|
123
|
+
* |7---6-5----3-2---0|
|
124
|
+
* |SCALE| INDEX| BASE|
|
125
|
+
* |------------------|
|
126
|
+
*/
|
127
|
+
scale = (sib >> 6) & 3;
|
128
|
+
index = (sib >> 3) & 7;
|
129
|
+
base = sib & 7;
|
130
|
+
|
131
|
+
/*
|
132
|
+
* The following fields: base/index/scale/disp8/32 are ALL optional by specific rules!
|
133
|
+
* The idea here is to keep the indirection as a simple-memory type.
|
134
|
+
* Because the base is optional, and we might be left with only one index.
|
135
|
+
* So even if there's a base but no index, or vice versa, we end up with one index register.
|
136
|
+
*/
|
137
|
+
|
138
|
+
/* In 64 bits the REX prefix might affect the index of the SIB byte. */
|
139
|
+
if (vrex & PREFIX_EX_X) {
|
140
|
+
ps->usedPrefixes |= INST_PRE_REX;
|
141
|
+
index += EX_GPR_BASE;
|
142
|
+
}
|
143
|
+
|
144
|
+
if (index == 4) { /* No index is used. Use SMEM. */
|
145
|
+
op->type = O_SMEM;
|
146
|
+
pIndex = &op->index;
|
147
|
+
} else {
|
148
|
+
op->type = O_MEM;
|
149
|
+
pIndex = &di->base;
|
150
|
+
/* No base, unless it is updated below. E.G: [EAX*4] has no base reg. */
|
151
|
+
}
|
152
|
+
|
153
|
+
if (base != 5) {
|
154
|
+
if (vrex & PREFIX_EX_B) ps->usedPrefixes |= INST_PRE_REX;
|
155
|
+
*pIndex = effAdrSz == Decode64Bits ? REGS64_BASE : REGS32_BASE;
|
156
|
+
*pIndex += (uint8_t)(base + ((vrex & PREFIX_EX_B) ? EX_GPR_BASE : 0));
|
157
|
+
} else if (mod != 0) {
|
158
|
+
/*
|
159
|
+
* if base == 5 then you have to decode according to MOD.
|
160
|
+
* mod(00) - disp32.
|
161
|
+
* mod(01) - disp8 + rBP
|
162
|
+
* mod(10) - disp32 + rBP
|
163
|
+
* mod(11) - not possible, it's a general-purpose register.
|
164
|
+
*/
|
165
|
+
|
166
|
+
if (vrex & PREFIX_EX_B) ps->usedPrefixes |= INST_PRE_REX;
|
167
|
+
if (effAdrSz == Decode64Bits) *pIndex = REGS64_BASE + 5 + ((vrex & PREFIX_EX_B) ? EX_GPR_BASE : 0);
|
168
|
+
else *pIndex = REGS32_BASE + 5 + ((vrex & PREFIX_EX_B) ? EX_GPR_BASE : 0);
|
169
|
+
} else if (index == 4) {
|
170
|
+
/* 32bits displacement only. */
|
171
|
+
op->type = O_DISP;
|
172
|
+
return;
|
173
|
+
}
|
174
|
+
|
175
|
+
if (index != 4) { /* In 64 bits decoding mode, if index == R12, it's valid! */
|
176
|
+
if (effAdrSz == Decode64Bits) op->index = (uint8_t)(REGS64_BASE + index);
|
177
|
+
else op->index = (uint8_t)(REGS32_BASE + index);
|
178
|
+
di->scale = scale != 0 ? (1 << scale) : 0;
|
179
|
+
}
|
180
|
+
}
|
181
|
+
|
182
|
+
/*
|
183
|
+
* This seems to be the hardest part in decoding the operands.
|
184
|
+
* If you take a look carefully at Table 2-2. 32-Bit Addressing Forms with the ModR/M Byte,
|
185
|
+
* you will understand it's easy to decode the operands.
|
186
|
+
|
187
|
+
* First we check the DT, so we can decide according to which Table in the documentation we are supposed to decode.
|
188
|
+
* Then we follow the specific table whether it's 16 bits or 32/64 bits.
|
189
|
+
|
190
|
+
* Don't forget that Operand Size AND Address Size prefixes may change the decoding!
|
191
|
+
|
192
|
+
* Some instructions force the use of RM16 or other specific types, so take it into account.
|
193
|
+
*/
|
194
|
+
static int operands_extract_modrm(_CodeInfo* ci,
|
195
|
+
_DInst* di, _OpType type,
|
196
|
+
_OperandNumberType opNum, _PrefixState* ps,
|
197
|
+
_DecodeType effOpSz, _DecodeType effAdrSz,
|
198
|
+
int* lockableInstruction, unsigned int mod, unsigned int rm,
|
199
|
+
_iflags instFlags)
|
200
|
+
{
|
201
|
+
unsigned int vrex = ps->vrex, sib = 0, base = 0;
|
202
|
+
_Operand* op = &di->ops[opNum];
|
203
|
+
uint16_t size = 0;
|
204
|
+
|
205
|
+
if (mod == 3) {
|
206
|
+
/*
|
207
|
+
* General-purpose register is handled the same way in 16/32/64 bits decoding modes.
|
208
|
+
* NOTE!! that we have to override the size of the register, since it was set earlier as Memory and not Register!
|
209
|
+
*/
|
210
|
+
op->type = O_REG;
|
211
|
+
/* Start with original size which was set earlier, some registers have same size of memory and depend on it. */
|
212
|
+
size = op->size;
|
213
|
+
switch(type)
|
214
|
+
{
|
215
|
+
case OT_RFULL_M16:
|
216
|
+
case OT_RM_FULL:
|
217
|
+
switch (effOpSz)
|
218
|
+
{
|
219
|
+
case Decode16Bits:
|
220
|
+
ps->usedPrefixes |= INST_PRE_OP_SIZE;
|
221
|
+
if (vrex & PREFIX_EX_B) {
|
222
|
+
ps->usedPrefixes |= INST_PRE_REX;
|
223
|
+
rm += EX_GPR_BASE;
|
224
|
+
}
|
225
|
+
size = 16;
|
226
|
+
rm += REGS16_BASE;
|
227
|
+
break;
|
228
|
+
case Decode32Bits:
|
229
|
+
ps->usedPrefixes |= INST_PRE_OP_SIZE;
|
230
|
+
if (vrex & PREFIX_EX_B) {
|
231
|
+
ps->usedPrefixes |= INST_PRE_REX;
|
232
|
+
rm += EX_GPR_BASE;
|
233
|
+
}
|
234
|
+
size = 32;
|
235
|
+
rm += REGS32_BASE;
|
236
|
+
break;
|
237
|
+
case Decode64Bits:
|
238
|
+
/* A fix for SMSW RAX which use the REX prefix. */
|
239
|
+
if (type == OT_RFULL_M16) ps->usedPrefixes |= INST_PRE_REX;
|
240
|
+
/* CALL NEAR/PUSH/POP defaults to 64 bits. --> INST_64BITS, REX isn't required, thus ignored anyways. */
|
241
|
+
if (instFlags & INST_PRE_REX) ps->usedPrefixes |= INST_PRE_REX;
|
242
|
+
/* Include REX if used for REX.B. */
|
243
|
+
if (vrex & PREFIX_EX_B) {
|
244
|
+
ps->usedPrefixes |= INST_PRE_REX;
|
245
|
+
rm += EX_GPR_BASE;
|
246
|
+
}
|
247
|
+
size = 64;
|
248
|
+
rm += REGS64_BASE;
|
249
|
+
break;
|
250
|
+
}
|
251
|
+
break;
|
252
|
+
case OT_R32_64_M8:
|
253
|
+
/* FALL THROUGH, decode 32 or 64 bits register. */
|
254
|
+
case OT_R32_64_M16:
|
255
|
+
/* FALL THROUGH, decode 32 or 64 bits register. */
|
256
|
+
case OT_RM32_64: /* Take care specifically in MOVNTI/MOVD/CVT's instructions, making it _REG64 with REX or if they are promoted. */
|
257
|
+
if (vrex & PREFIX_EX_B) {
|
258
|
+
ps->usedPrefixes |= INST_PRE_REX;
|
259
|
+
rm += EX_GPR_BASE;
|
260
|
+
}
|
261
|
+
/* Is it a promoted instruction? (only INST_64BITS is set and REX isn't required.) */
|
262
|
+
if ((ci->dt == Decode64Bits) && ((instFlags & (INST_64BITS | INST_PRE_REX)) == INST_64BITS)) {
|
263
|
+
size = 64;
|
264
|
+
rm += REGS64_BASE;
|
265
|
+
break;
|
266
|
+
}
|
267
|
+
/* Give a chance to REX.W. Because if it was a promoted instruction we don't care about REX.W anyways. */
|
268
|
+
if (vrex & PREFIX_EX_W) {
|
269
|
+
ps->usedPrefixes |= INST_PRE_REX;
|
270
|
+
size = 64;
|
271
|
+
rm += REGS64_BASE;
|
272
|
+
} else {
|
273
|
+
size = 32;
|
274
|
+
rm += REGS32_BASE;
|
275
|
+
}
|
276
|
+
break;
|
277
|
+
case OT_RM16_32: /* Used only with MOVZXD instruction to support 16 bits operand. */
|
278
|
+
if (vrex & PREFIX_EX_B) {
|
279
|
+
ps->usedPrefixes |= INST_PRE_REX;
|
280
|
+
rm += EX_GPR_BASE;
|
281
|
+
}
|
282
|
+
/* Is it 16 bits operand size? */
|
283
|
+
if (ps->decodedPrefixes & INST_PRE_OP_SIZE) {
|
284
|
+
ps->usedPrefixes |= INST_PRE_OP_SIZE;
|
285
|
+
size = 16;
|
286
|
+
rm += REGS16_BASE;
|
287
|
+
} else {
|
288
|
+
size = 32;
|
289
|
+
rm += REGS32_BASE;
|
290
|
+
}
|
291
|
+
break;
|
292
|
+
case OT_RM16:
|
293
|
+
if (vrex & PREFIX_EX_B) {
|
294
|
+
ps->usedPrefixes |= INST_PRE_REX;
|
295
|
+
rm += EX_GPR_BASE;
|
296
|
+
}
|
297
|
+
rm += REGS16_BASE;
|
298
|
+
break;
|
299
|
+
case OT_RM8:
|
300
|
+
if (ps->prefixExtType == PET_REX) {
|
301
|
+
ps->usedPrefixes |= INST_PRE_REX;
|
302
|
+
rm = operands_fix_8bit_rex_base(rm + ((vrex & PREFIX_EX_B) ? EX_GPR_BASE : 0));
|
303
|
+
} else rm += REGS8_BASE;
|
304
|
+
break;
|
305
|
+
case OT_MM32:
|
306
|
+
case OT_MM64:
|
307
|
+
/* MMX doesn't support extended registers. */
|
308
|
+
size = 64;
|
309
|
+
rm += MMXREGS_BASE;
|
310
|
+
break;
|
311
|
+
|
312
|
+
case OT_XMM16:
|
313
|
+
case OT_XMM32:
|
314
|
+
case OT_XMM64:
|
315
|
+
case OT_XMM128:
|
316
|
+
if (vrex & PREFIX_EX_B) {
|
317
|
+
ps->usedPrefixes |= INST_PRE_REX;
|
318
|
+
rm += EX_GPR_BASE;
|
319
|
+
}
|
320
|
+
size = 128;
|
321
|
+
rm += SSEREGS_BASE;
|
322
|
+
break;
|
323
|
+
|
324
|
+
case OT_RM32:
|
325
|
+
case OT_R32_M8:
|
326
|
+
case OT_R32_M16:
|
327
|
+
if (vrex & PREFIX_EX_B) {
|
328
|
+
ps->usedPrefixes |= INST_PRE_REX;
|
329
|
+
rm += EX_GPR_BASE;
|
330
|
+
}
|
331
|
+
size = 32;
|
332
|
+
rm += REGS32_BASE;
|
333
|
+
break;
|
334
|
+
|
335
|
+
case OT_YMM256:
|
336
|
+
if (vrex & PREFIX_EX_B) rm += EX_GPR_BASE;
|
337
|
+
rm += AVXREGS_BASE;
|
338
|
+
break;
|
339
|
+
case OT_YXMM64_256:
|
340
|
+
case OT_YXMM128_256:
|
341
|
+
if (vrex & PREFIX_EX_B) rm += EX_GPR_BASE;
|
342
|
+
if (vrex & PREFIX_EX_L) {
|
343
|
+
size = 256;
|
344
|
+
rm += AVXREGS_BASE;
|
345
|
+
} else {
|
346
|
+
size = 128;
|
347
|
+
rm += SSEREGS_BASE;
|
348
|
+
}
|
349
|
+
break;
|
350
|
+
case OT_WXMM32_64:
|
351
|
+
case OT_LXMM64_128:
|
352
|
+
if (vrex & PREFIX_EX_B) rm += EX_GPR_BASE;
|
353
|
+
size = 128;
|
354
|
+
rm += SSEREGS_BASE;
|
355
|
+
break;
|
356
|
+
|
357
|
+
case OT_WRM32_64:
|
358
|
+
case OT_REG32_64_M8:
|
359
|
+
case OT_REG32_64_M16:
|
360
|
+
if (vrex & PREFIX_EX_B) rm += EX_GPR_BASE;
|
361
|
+
if (vrex & PREFIX_EX_W) {
|
362
|
+
size = 64;
|
363
|
+
rm += REGS64_BASE;
|
364
|
+
} else {
|
365
|
+
size = 32;
|
366
|
+
rm += REGS32_BASE;
|
367
|
+
}
|
368
|
+
break;
|
369
|
+
|
370
|
+
default: return FALSE;
|
371
|
+
}
|
372
|
+
op->size = size;
|
373
|
+
op->index = (uint8_t)rm;
|
374
|
+
return TRUE;
|
375
|
+
}
|
376
|
+
|
377
|
+
/* Memory indirection decoding ahead:) */
|
378
|
+
|
379
|
+
ps->usedPrefixes |= INST_PRE_ADDR_SIZE;
|
380
|
+
if (lockableInstruction && (ps->decodedPrefixes & INST_PRE_LOCK)) *lockableInstruction = TRUE;
|
381
|
+
|
382
|
+
if (effAdrSz == Decode16Bits) {
|
383
|
+
/* Decoding according to Table 2-1. (16 bits) */
|
384
|
+
if ((mod == 0) && (rm == 6)) {
|
385
|
+
/* 6 is a special case - only 16 bits displacement. */
|
386
|
+
op->type = O_DISP;
|
387
|
+
di->dispSize = 16;
|
388
|
+
if (!read_stream_safe_sint(ci, (int64_t*)&di->disp, sizeof(int16_t))) return FALSE;
|
389
|
+
} else {
|
390
|
+
/*
|
391
|
+
* Create the O_MEM for 16 bits indirection that requires 2 registers, E.G: [BS+SI].
|
392
|
+
* or create O_SMEM for a single register indirection, E.G: [BP].
|
393
|
+
*/
|
394
|
+
static uint8_t MODS[] = {R_BX, R_BX, R_BP, R_BP, R_SI, R_DI, R_BP, R_BX};
|
395
|
+
static uint8_t MODS2[] = {R_SI, R_DI, R_SI, R_DI};
|
396
|
+
if (rm < 4) {
|
397
|
+
op->type = O_MEM;
|
398
|
+
di->base = MODS[rm];
|
399
|
+
op->index = MODS2[rm];
|
400
|
+
} else {
|
401
|
+
op->type = O_SMEM;
|
402
|
+
op->index = MODS[rm];
|
403
|
+
}
|
404
|
+
|
405
|
+
if (mod == 1) { /* 8 bits displacement + indirection */
|
406
|
+
di->dispSize = 8;
|
407
|
+
if (!read_stream_safe_sint(ci, (int64_t*)&di->disp, sizeof(int8_t))) return FALSE;
|
408
|
+
} else if (mod == 2) { /* 16 bits displacement + indirection */
|
409
|
+
di->dispSize = 16;
|
410
|
+
if (!read_stream_safe_sint(ci, (int64_t*)&di->disp, sizeof(int16_t))) return FALSE;
|
411
|
+
}
|
412
|
+
}
|
413
|
+
|
414
|
+
if ((rm == 2) || (rm == 3) || ((rm == 6) && (mod != 0))) {
|
415
|
+
/* BP's default segment is SS, so ignore it. */
|
416
|
+
prefixes_use_segment(INST_PRE_SS, ps, ci->dt, di);
|
417
|
+
} else {
|
418
|
+
/* Ignore default DS segment. */
|
419
|
+
prefixes_use_segment(INST_PRE_DS, ps, ci->dt, di);
|
420
|
+
}
|
421
|
+
} else { /* Decode32Bits or Decode64Bits! */
|
422
|
+
/* Remember that from a 32/64 bits ModR/M byte a SIB byte could follow! */
|
423
|
+
if ((mod == 0) && (rm == 5)) {
|
424
|
+
|
425
|
+
/* 5 is a special case - only 32 bits displacement, or RIP relative. */
|
426
|
+
di->dispSize = 32;
|
427
|
+
if (!read_stream_safe_sint(ci, (int64_t*)&di->disp, sizeof(int32_t))) return FALSE;
|
428
|
+
|
429
|
+
if (ci->dt == Decode64Bits) {
|
430
|
+
/* In 64 bits decoding mode depsite of the address size, a RIP-relative address it is. */
|
431
|
+
op->type = O_SMEM;
|
432
|
+
op->index = R_RIP;
|
433
|
+
di->flags |= FLAG_RIP_RELATIVE;
|
434
|
+
} else {
|
435
|
+
/* Absolute address: */
|
436
|
+
op->type = O_DISP;
|
437
|
+
}
|
438
|
+
} else {
|
439
|
+
if (rm == 4) {
|
440
|
+
/* 4 is a special case - SIB byte + disp8/32 follows! */
|
441
|
+
/* Read SIB byte. */
|
442
|
+
if (!read_stream_safe_uint(ci, &sib, sizeof(int8_t))) return FALSE;
|
443
|
+
operands_extract_sib(di, opNum, ps, effAdrSz, sib, mod);
|
444
|
+
} else {
|
445
|
+
op->type = O_SMEM;
|
446
|
+
if (vrex & PREFIX_EX_B) {
|
447
|
+
ps->usedPrefixes |= INST_PRE_REX;
|
448
|
+
rm += EX_GPR_BASE;
|
449
|
+
}
|
450
|
+
|
451
|
+
if (effAdrSz == Decode64Bits) op->index = (uint8_t)(REGS64_BASE + rm);
|
452
|
+
else op->index = (uint8_t)(REGS32_BASE + rm);
|
453
|
+
}
|
454
|
+
|
455
|
+
if (mod == 1) {
|
456
|
+
di->dispSize = 8;
|
457
|
+
if (!read_stream_safe_sint(ci, (int64_t*)&di->disp, sizeof(int8_t))) return FALSE;
|
458
|
+
} else if ((mod == 2) || ((sib & 7) == 5)) { /* If there is no BASE, read DISP32! */
|
459
|
+
di->dispSize = 32;
|
460
|
+
if (!read_stream_safe_sint(ci, (int64_t*)&di->disp, sizeof(int32_t))) return FALSE;
|
461
|
+
}
|
462
|
+
}
|
463
|
+
|
464
|
+
/* Get the base register. */
|
465
|
+
base = op->index;
|
466
|
+
if (di->base != R_NONE) base = di->base;
|
467
|
+
else if (di->scale >= 2) base = 0; /* If it's only an index but got scale, it's still DS. */
|
468
|
+
/* Default for EBP/ESP is SS segment. 64 bits mode ignores DS anyway. */
|
469
|
+
if ((base == R_EBP) || (base == R_ESP)) prefixes_use_segment(INST_PRE_SS, ps, ci->dt, di);
|
470
|
+
else prefixes_use_segment(INST_PRE_DS, ps, ci->dt, di);
|
471
|
+
}
|
472
|
+
|
473
|
+
return TRUE;
|
474
|
+
}
|
475
|
+
|
476
|
+
|
477
|
+
/*
|
478
|
+
* This function is reponsible to textually format a required operand according to its type.
|
479
|
+
* It is vital to understand that there are other operands than what the ModR/M byte specifies.
|
480
|
+
|
481
|
+
* Only by decoding the operands of an instruction which got a LOCK prefix, we could tell whether it may use the LOCK prefix.
|
482
|
+
* According to Intel, LOCK prefix must precede some specific instructions AND in their memory destination operand form (which means first operand).
|
483
|
+
* LOCK INC EAX, would generate an exception, but LOCK INC [EAX] is alright.
|
484
|
+
* Also LOCK ADD BX, [BP] would generate an exception.
|
485
|
+
|
486
|
+
* Return code:
|
487
|
+
* TRUE - continue parsing the instruction and its operands, everything went right 'till now.
|
488
|
+
* FALSE - not enough bytes, or invalid operands.
|
489
|
+
*/
|
490
|
+
|
491
|
+
int operands_extract(_CodeInfo* ci, _DInst* di, _InstInfo* ii,
|
492
|
+
_iflags instFlags, _OpType type, _OperandNumberType opNum,
|
493
|
+
unsigned int modrm, _PrefixState* ps, _DecodeType effOpSz,
|
494
|
+
_DecodeType effAdrSz, int* lockableInstruction)
|
495
|
+
{
|
496
|
+
int ret = 0;
|
497
|
+
unsigned int mod = 0, reg = 0, rm = 0, vexV = ps->vexV;
|
498
|
+
unsigned int vrex = ps->vrex, typeHandled = TRUE;
|
499
|
+
_Operand* op = &di->ops[opNum];
|
500
|
+
|
501
|
+
/* Used to indicate the size of the MEMORY INDIRECTION only. */
|
502
|
+
_OperandSizeType opSize = OPERAND_SIZE_NONE;
|
503
|
+
|
504
|
+
/*
|
505
|
+
* ModRM bits:
|
506
|
+
* |7-6-5--------3-2-0|
|
507
|
+
* |MOD|REG/OPCODE|RM |
|
508
|
+
* |------------------|
|
509
|
+
*/
|
510
|
+
mod = (modrm >> 6) & 3; /* Mode(register-indirection, disp8+reg+indirection, disp16+reg+indirection, general-purpose register) */
|
511
|
+
reg = (modrm >> 3) & 7; /* Register(could be part of the opcode itself or general-purpose register) */
|
512
|
+
rm = modrm & 7; /* Specifies which general-purpose register or disp+reg to use. */
|
513
|
+
|
514
|
+
/* -- Memory Indirection Operands (that cannot be a general purpose register) -- */
|
515
|
+
switch (type)
|
516
|
+
{
|
517
|
+
case OT_MEM64_128: /* Used only by CMPXCHG8/16B. */
|
518
|
+
/* Make a specific check when the type is OT_MEM64_128 since the lockable CMPXCHG8B uses this one... */
|
519
|
+
if (lockableInstruction && (ps->decodedPrefixes & INST_PRE_LOCK)) *lockableInstruction = TRUE;
|
520
|
+
if (effOpSz == Decode64Bits) {
|
521
|
+
ps->usedPrefixes |= INST_PRE_REX;
|
522
|
+
opSize = OPERAND_SIZE128;
|
523
|
+
} else opSize = OPERAND_SIZE64;
|
524
|
+
break;
|
525
|
+
case OT_MEM32: opSize = OPERAND_SIZE32; break;
|
526
|
+
case OT_MEM32_64:
|
527
|
+
/* Used by MOVNTI. Default size is 32bits, 64bits with REX. */
|
528
|
+
if (effOpSz == Decode64Bits) {
|
529
|
+
ps->usedPrefixes |= INST_PRE_REX;
|
530
|
+
opSize = OPERAND_SIZE64;
|
531
|
+
} else opSize = OPERAND_SIZE32;
|
532
|
+
break;
|
533
|
+
case OT_MEM64: opSize = OPERAND_SIZE64; break;
|
534
|
+
case OT_MEM128: opSize = OPERAND_SIZE128; break;
|
535
|
+
case OT_MEM16_FULL: /* The size indicates about the second item of the pair. */
|
536
|
+
switch (effOpSz)
|
537
|
+
{
|
538
|
+
case Decode16Bits:
|
539
|
+
ps->usedPrefixes |= INST_PRE_OP_SIZE;
|
540
|
+
opSize = OPERAND_SIZE16;
|
541
|
+
break;
|
542
|
+
case Decode32Bits:
|
543
|
+
ps->usedPrefixes |= INST_PRE_OP_SIZE;
|
544
|
+
opSize = OPERAND_SIZE32;
|
545
|
+
break;
|
546
|
+
case Decode64Bits:
|
547
|
+
/* Mark usage of REX only if it was required. */
|
548
|
+
if ((instFlags & (INST_64BITS | INST_PRE_REX)) == (INST_64BITS | INST_PRE_REX)) ps->usedPrefixes |= INST_PRE_REX;
|
549
|
+
opSize = OPERAND_SIZE64;
|
550
|
+
break;
|
551
|
+
}
|
552
|
+
break;
|
553
|
+
case OT_MEM16_3264: /* The size indicates about the second item of the pair. */
|
554
|
+
if (ci->dt == Decode64Bits) opSize = OPERAND_SIZE64;
|
555
|
+
else opSize = OPERAND_SIZE32;
|
556
|
+
break;
|
557
|
+
case OT_MEM_OPT:
|
558
|
+
/* Since the MEM is optional, only when mod != 3, then return true as if the operand was alright. */
|
559
|
+
if (mod == 0x3) return TRUE;
|
560
|
+
break;
|
561
|
+
case OT_FPUM16: opSize = OPERAND_SIZE16; break;
|
562
|
+
case OT_FPUM32: opSize = OPERAND_SIZE32; break;
|
563
|
+
case OT_FPUM64: opSize = OPERAND_SIZE64; break;
|
564
|
+
case OT_FPUM80: opSize = OPERAND_SIZE80; break;
|
565
|
+
case OT_LMEM128_256:
|
566
|
+
if (vrex & PREFIX_EX_L) opSize = OPERAND_SIZE256;
|
567
|
+
else opSize = OPERAND_SIZE128;
|
568
|
+
break;
|
569
|
+
case OT_MEM: /* Size is unknown, but still handled. */ break;
|
570
|
+
default: typeHandled = FALSE; break;
|
571
|
+
}
|
572
|
+
if (typeHandled) {
|
573
|
+
/* All of the above types can't use a general-purpose register (a MOD of 3)!. */
|
574
|
+
if (mod == 0x3) {
|
575
|
+
if (lockableInstruction) *lockableInstruction = FALSE;
|
576
|
+
return FALSE;
|
577
|
+
}
|
578
|
+
op->size = _OPSIZETOINT[opSize];
|
579
|
+
ret = operands_extract_modrm(ci, di, type, opNum, ps, effOpSz, effAdrSz, lockableInstruction, mod, rm, instFlags);
|
580
|
+
if ((op->type == O_REG) || (op->type == O_SMEM) || (op->type == O_MEM)) {
|
581
|
+
di->usedRegistersMask |= _REGISTERTORCLASS[op->index];
|
582
|
+
}
|
583
|
+
return ret;
|
584
|
+
}
|
585
|
+
|
586
|
+
/* -- Memory Indirection Operands (that can be a register) -- */
|
587
|
+
typeHandled = TRUE;
|
588
|
+
switch (type)
|
589
|
+
{
|
590
|
+
case OT_RM_FULL:
|
591
|
+
ps->usedPrefixes |= INST_PRE_OP_SIZE;
|
592
|
+
/* PUSH/JMP/CALL are automatically promoted to 64 bits! */
|
593
|
+
if (effOpSz == Decode32Bits) {
|
594
|
+
opSize = OPERAND_SIZE32;
|
595
|
+
break;
|
596
|
+
} else if (effOpSz == Decode64Bits) {
|
597
|
+
/* Mark usage of REX only if it was required. */
|
598
|
+
if ((instFlags & INST_64BITS) == 0) ps->usedPrefixes |= INST_PRE_REX;
|
599
|
+
opSize = OPERAND_SIZE64;
|
600
|
+
break;
|
601
|
+
}
|
602
|
+
/* FALL THROUGH BECAUSE dt==Decoded16Bits @-<----*/
|
603
|
+
case OT_RM16:
|
604
|
+
/* If we got here not from OT_RM16, then the prefix was used. */
|
605
|
+
if (type != OT_RM16) ps->usedPrefixes |= INST_PRE_OP_SIZE;
|
606
|
+
opSize = OPERAND_SIZE16;
|
607
|
+
break;
|
608
|
+
case OT_RM32_64:
|
609
|
+
/* The default size is 32, which can be 64 with a REX only. */
|
610
|
+
if (effOpSz == Decode64Bits) {
|
611
|
+
opSize = OPERAND_SIZE64;
|
612
|
+
/* Mark REX prefix as used if non-promoted instruction. */
|
613
|
+
if ((instFlags & (INST_64BITS | INST_PRE_REX)) == (INST_64BITS | INST_PRE_REX)) {
|
614
|
+
ps->usedPrefixes |= INST_PRE_REX;
|
615
|
+
}
|
616
|
+
} else opSize = OPERAND_SIZE32;
|
617
|
+
break;
|
618
|
+
case OT_RM16_32:
|
619
|
+
/* Ignore REX, it's either 32 or 16 bits RM. */
|
620
|
+
if (ps->decodedPrefixes & INST_PRE_OP_SIZE) {
|
621
|
+
ps->usedPrefixes |= INST_PRE_OP_SIZE;
|
622
|
+
/* Assume: We are in 64bits when we have this operand used. */
|
623
|
+
opSize = OPERAND_SIZE16;
|
624
|
+
} else opSize = OPERAND_SIZE32;
|
625
|
+
break;
|
626
|
+
case OT_WXMM32_64:
|
627
|
+
case OT_WRM32_64:
|
628
|
+
if (vrex & PREFIX_EX_W) opSize = OPERAND_SIZE64;
|
629
|
+
else opSize = OPERAND_SIZE32;
|
630
|
+
break;
|
631
|
+
case OT_YXMM64_256:
|
632
|
+
if (vrex & PREFIX_EX_L) opSize = OPERAND_SIZE256;
|
633
|
+
else opSize = OPERAND_SIZE64;
|
634
|
+
break;
|
635
|
+
case OT_YXMM128_256:
|
636
|
+
if (vrex & PREFIX_EX_L) opSize = OPERAND_SIZE256;
|
637
|
+
else opSize = OPERAND_SIZE128;
|
638
|
+
break;
|
639
|
+
case OT_LXMM64_128:
|
640
|
+
if (vrex & PREFIX_EX_L) opSize = OPERAND_SIZE128;
|
641
|
+
else opSize = OPERAND_SIZE64;
|
642
|
+
break;
|
643
|
+
case OT_RFULL_M16:
|
644
|
+
ps->usedPrefixes |= INST_PRE_OP_SIZE;
|
645
|
+
opSize = OPERAND_SIZE16;
|
646
|
+
break;
|
647
|
+
|
648
|
+
case OT_RM8:
|
649
|
+
case OT_R32_M8:
|
650
|
+
case OT_R32_64_M8:
|
651
|
+
case OT_REG32_64_M8:
|
652
|
+
opSize = OPERAND_SIZE8;
|
653
|
+
break;
|
654
|
+
|
655
|
+
case OT_XMM16:
|
656
|
+
case OT_R32_M16:
|
657
|
+
case OT_R32_64_M16:
|
658
|
+
case OT_REG32_64_M16:
|
659
|
+
opSize = OPERAND_SIZE16;
|
660
|
+
break;
|
661
|
+
|
662
|
+
case OT_RM32:
|
663
|
+
case OT_MM32:
|
664
|
+
case OT_XMM32:
|
665
|
+
opSize = OPERAND_SIZE32;
|
666
|
+
break;
|
667
|
+
|
668
|
+
case OT_MM64:
|
669
|
+
case OT_XMM64:
|
670
|
+
opSize = OPERAND_SIZE64;
|
671
|
+
break;
|
672
|
+
|
673
|
+
case OT_XMM128: opSize = OPERAND_SIZE128; break;
|
674
|
+
case OT_YMM256: opSize = OPERAND_SIZE256; break;
|
675
|
+
default: typeHandled = FALSE; break;
|
676
|
+
}
|
677
|
+
if (typeHandled) {
|
678
|
+
/* Fill size of memory dereference for operand. */
|
679
|
+
op->size = _OPSIZETOINT[opSize];
|
680
|
+
ret = operands_extract_modrm(ci, di, type, opNum, ps, effOpSz, effAdrSz, lockableInstruction, mod, rm, instFlags);
|
681
|
+
if ((op->type == O_REG) || (op->type == O_SMEM) || (op->type == O_MEM)) {
|
682
|
+
di->usedRegistersMask |= _REGISTERTORCLASS[op->index];
|
683
|
+
}
|
684
|
+
return ret;
|
685
|
+
}
|
686
|
+
|
687
|
+
/* Simple operand type (no ModRM byte). */
|
688
|
+
switch (type)
|
689
|
+
{
|
690
|
+
case OT_IMM8:
|
691
|
+
operands_set_ts(op, O_IMM, 8);
|
692
|
+
if (!read_stream_safe_uint(ci, &di->imm.byte, sizeof(int8_t))) return FALSE;
|
693
|
+
break;
|
694
|
+
case OT_IMM_FULL: /* 16, 32 or 64, depends on prefixes. */
|
695
|
+
if (effOpSz == Decode16Bits) {
|
696
|
+
ps->usedPrefixes |= INST_PRE_OP_SIZE;
|
697
|
+
/* FALL THROUGH */
|
698
|
+
case OT_IMM16: /* Force 16 bits imm. */
|
699
|
+
operands_set_ts(op, O_IMM, 16);
|
700
|
+
if (!read_stream_safe_uint(ci, &di->imm.word, sizeof(int16_t))) return FALSE;
|
701
|
+
break;
|
702
|
+
/*
|
703
|
+
* Extension: MOV imm64, requires REX.
|
704
|
+
* Make sure it needs the REX.
|
705
|
+
* REX must be present because op size function takes it into consideration.
|
706
|
+
*/
|
707
|
+
} else if ((effOpSz == Decode64Bits) &&
|
708
|
+
((instFlags & (INST_64BITS | INST_PRE_REX)) == (INST_64BITS | INST_PRE_REX))) {
|
709
|
+
ps->usedPrefixes |= INST_PRE_REX;
|
710
|
+
|
711
|
+
operands_set_ts(op, O_IMM, 64);
|
712
|
+
if (!read_stream_safe_uint(ci, &di->imm.qword, sizeof(int64_t))) return FALSE;
|
713
|
+
break;
|
714
|
+
} else ps->usedPrefixes |= INST_PRE_OP_SIZE;
|
715
|
+
/* FALL THROUGH BECAUSE dt==Decoded32Bits @-<----*/
|
716
|
+
case OT_IMM32:
|
717
|
+
op->type = O_IMM;
|
718
|
+
if (ci->dt == Decode64Bits) {
|
719
|
+
/*
|
720
|
+
* Imm32 is sign extended to 64 bits!
|
721
|
+
* Originally the op size was 64, but later was changed to reflect real size of imm.
|
722
|
+
*/
|
723
|
+
op->size = 32;
|
724
|
+
/* Use this as an indicator that it should be signed extended. */
|
725
|
+
di->flags |= FLAG_IMM_SIGNED;
|
726
|
+
if (!read_stream_safe_sint(ci, &di->imm.sqword, sizeof(int32_t))) return FALSE;
|
727
|
+
} else {
|
728
|
+
op->size = 32;
|
729
|
+
if (!read_stream_safe_uint(ci, &di->imm.dword, sizeof(int32_t))) return FALSE;
|
730
|
+
}
|
731
|
+
break;
|
732
|
+
case OT_SEIMM8: /* Sign extended immediate. */
|
733
|
+
/*
|
734
|
+
* PUSH SEIMM8 can be prefixed by operand size:
|
735
|
+
* Input stream: 66, 6a, 55
|
736
|
+
* 64bits DT: push small 55
|
737
|
+
* 32bits DT: push small 55
|
738
|
+
* 16bits DT: push large 55
|
739
|
+
* small/large indicates the size of the eSP pointer advancement.
|
740
|
+
* Check the instFlags (ii->flags) if it can be operand-size-prefixed and if the prefix exists.
|
741
|
+
*/
|
742
|
+
op->type = O_IMM;
|
743
|
+
if ((instFlags & INST_PRE_OP_SIZE) && (ps->decodedPrefixes & INST_PRE_OP_SIZE)) {
|
744
|
+
ps->usedPrefixes |= INST_PRE_OP_SIZE;
|
745
|
+
switch (ci->dt)
|
746
|
+
{
|
747
|
+
case Decode16Bits: op->size = 32; break;
|
748
|
+
case Decode32Bits:
|
749
|
+
case Decode64Bits:
|
750
|
+
op->size = 16;
|
751
|
+
break;
|
752
|
+
}
|
753
|
+
} else op->size = 8;
|
754
|
+
di->flags |= FLAG_IMM_SIGNED;
|
755
|
+
if (!read_stream_safe_sint(ci, &di->imm.sqword, sizeof(int8_t))) return FALSE;
|
756
|
+
break;
|
757
|
+
case OT_IMM16_1:
|
758
|
+
operands_set_ts(op, O_IMM1, 16);
|
759
|
+
if (!read_stream_safe_uint(ci, &di->imm.ex.i1, sizeof(int16_t))) return FALSE;
|
760
|
+
break;
|
761
|
+
case OT_IMM8_1:
|
762
|
+
operands_set_ts(op, O_IMM1, 8);
|
763
|
+
if (!read_stream_safe_uint(ci, &di->imm.ex.i1, sizeof(int8_t))) return FALSE;
|
764
|
+
break;
|
765
|
+
case OT_IMM8_2:
|
766
|
+
operands_set_ts(op, O_IMM2, 8);
|
767
|
+
if (!read_stream_safe_uint(ci, &di->imm.ex.i2, sizeof(int8_t))) return FALSE;
|
768
|
+
break;
|
769
|
+
case OT_REG8:
|
770
|
+
operands_set_ts(op, O_REG, 8);
|
771
|
+
if (ps->prefixExtType) {
|
772
|
+
/*
|
773
|
+
* If REX prefix is valid then we will have to use low bytes.
|
774
|
+
* This is a PASSIVE behavior changer of REX prefix, it affects operands even if its value is 0x40 !
|
775
|
+
*/
|
776
|
+
ps->usedPrefixes |= INST_PRE_REX;
|
777
|
+
op->index = (uint8_t)operands_fix_8bit_rex_base(reg + ((vrex & PREFIX_EX_R) ? EX_GPR_BASE : 0));
|
778
|
+
} else op->index = (uint8_t)(REGS8_BASE + reg);
|
779
|
+
break;
|
780
|
+
case OT_REG16:
|
781
|
+
operands_set_tsi(op, O_REG, 16, REGS16_BASE + reg);
|
782
|
+
break;
|
783
|
+
case OT_REG_FULL:
|
784
|
+
switch (effOpSz)
|
785
|
+
{
|
786
|
+
case Decode16Bits:
|
787
|
+
ps->usedPrefixes |= INST_PRE_OP_SIZE;
|
788
|
+
if (vrex & PREFIX_EX_R) {
|
789
|
+
ps->usedPrefixes |= INST_PRE_REX;
|
790
|
+
reg += EX_GPR_BASE;
|
791
|
+
}
|
792
|
+
operands_set_tsi(op, O_REG, 16, REGS16_BASE + reg);
|
793
|
+
break;
|
794
|
+
case Decode32Bits:
|
795
|
+
if (vrex & PREFIX_EX_R) {
|
796
|
+
ps->usedPrefixes |= INST_PRE_REX;
|
797
|
+
reg += EX_GPR_BASE;
|
798
|
+
} else ps->usedPrefixes |= INST_PRE_OP_SIZE;
|
799
|
+
operands_set_tsi(op, O_REG, 32, REGS32_BASE + reg);
|
800
|
+
break;
|
801
|
+
case Decode64Bits: /* rex must be presented. */
|
802
|
+
ps->usedPrefixes |= INST_PRE_REX;
|
803
|
+
operands_set_tsi(op, O_REG, 64, REGS64_BASE + reg + ((vrex & PREFIX_EX_R) ? EX_GPR_BASE : 0));
|
804
|
+
break;
|
805
|
+
}
|
806
|
+
break;
|
807
|
+
case OT_REG32:
|
808
|
+
if (vrex & PREFIX_EX_R) {
|
809
|
+
ps->usedPrefixes |= INST_PRE_REX;
|
810
|
+
reg += EX_GPR_BASE;
|
811
|
+
}
|
812
|
+
operands_set_tsi(op, O_REG, 32, REGS32_BASE + reg);
|
813
|
+
break;
|
814
|
+
case OT_REG32_64: /* Handle CVT's, MOVxX and MOVNTI instructions which could be extended to 64 bits registers with REX. */
|
815
|
+
if (vrex & PREFIX_EX_R) {
|
816
|
+
ps->usedPrefixes |= INST_PRE_REX;
|
817
|
+
reg += EX_GPR_BASE;
|
818
|
+
}
|
819
|
+
|
820
|
+
/* Is it a promoted instruction? (only INST_64BITS is set and REX isn't required.) */
|
821
|
+
if ((ci->dt == Decode64Bits) && ((instFlags & (INST_64BITS | INST_PRE_REX)) == INST_64BITS)) {
|
822
|
+
operands_set_tsi(op, O_REG, 64, REGS64_BASE + reg);
|
823
|
+
break;
|
824
|
+
}
|
825
|
+
/* Give a chance to REX.W. Because if it was a promoted instruction we don't care about REX.W anyways. */
|
826
|
+
if (vrex & PREFIX_EX_W) {
|
827
|
+
ps->usedPrefixes |= INST_PRE_REX;
|
828
|
+
operands_set_tsi(op, O_REG, 64, REGS64_BASE + reg);
|
829
|
+
} else operands_set_tsi(op, O_REG, 32, REGS32_BASE + reg);
|
830
|
+
break;
|
831
|
+
case OT_FREG32_64_RM: /* Force decoding mode. Used for MOV CR(n)/DR(n) which defaults to 64 bits operand size in 64 bits. */
|
832
|
+
if (vrex & PREFIX_EX_B) {
|
833
|
+
ps->usedPrefixes |= INST_PRE_REX;
|
834
|
+
rm += EX_GPR_BASE;
|
835
|
+
}
|
836
|
+
|
837
|
+
if (ci->dt == Decode64Bits) operands_set_tsi(op, O_REG, 64, REGS64_BASE + rm);
|
838
|
+
else operands_set_tsi(op, O_REG, 32, REGS32_BASE + rm);
|
839
|
+
break;
|
840
|
+
case OT_MM: /* MMX register */
|
841
|
+
operands_set_tsi(op, O_REG, 64, MMXREGS_BASE + reg);
|
842
|
+
break;
|
843
|
+
case OT_MM_RM: /* MMX register, this time from the RM field */
|
844
|
+
operands_set_tsi(op, O_REG, 64, MMXREGS_BASE + rm);
|
845
|
+
break;
|
846
|
+
case OT_REGXMM0: /* Implicit XMM0 operand. */
|
847
|
+
reg = 0;
|
848
|
+
vrex = 0;
|
849
|
+
/* FALL THROUGH */
|
850
|
+
case OT_XMM: /* SSE register */
|
851
|
+
if (vrex & PREFIX_EX_R) {
|
852
|
+
ps->usedPrefixes |= INST_PRE_REX;
|
853
|
+
reg += EX_GPR_BASE;
|
854
|
+
}
|
855
|
+
operands_set_tsi(op, O_REG, 128, SSEREGS_BASE + reg);
|
856
|
+
break;
|
857
|
+
case OT_XMM_RM: /* SSE register, this time from the RM field */
|
858
|
+
if (vrex & PREFIX_EX_B) {
|
859
|
+
ps->usedPrefixes |= INST_PRE_REX;
|
860
|
+
rm += EX_GPR_BASE;
|
861
|
+
}
|
862
|
+
operands_set_tsi(op, O_REG, 128, SSEREGS_BASE + rm);
|
863
|
+
break;
|
864
|
+
case OT_CREG:
|
865
|
+
/*
|
866
|
+
* Don't parse if the reg exceeds the bounds of the array.
|
867
|
+
* Most of the CR's are not implemented, so if there's no matching string, the operand is invalid.
|
868
|
+
*/
|
869
|
+
if (vrex & PREFIX_EX_R) {
|
870
|
+
ps->usedPrefixes |= INST_PRE_REX;
|
871
|
+
reg += EX_GPR_BASE;
|
872
|
+
} else if ((ci->dt == Decode32Bits) && (ps->decodedPrefixes & INST_PRE_LOCK)) {
|
873
|
+
/*
|
874
|
+
* NOTE: In 32 bits decoding mode,
|
875
|
+
* if the lock prefix is set before MOV CR(n) it will become the 4th bit of the REG field like REX.R in 64 bits.
|
876
|
+
*/
|
877
|
+
reg += EX_GPR_BASE;
|
878
|
+
ps->usedPrefixes |= INST_PRE_LOCK;
|
879
|
+
}
|
880
|
+
/* Ignore some registers which do not exist. */
|
881
|
+
if ((reg >= CREGS_MAX) || (reg == 1) || ((reg >= 5) && (reg <= 7))) return FALSE;
|
882
|
+
|
883
|
+
op->type = O_REG;
|
884
|
+
if (ci->dt == Decode64Bits) op->size = 64;
|
885
|
+
else op->size = 32;
|
886
|
+
op->index = (uint8_t)(CREGS_BASE + reg);
|
887
|
+
break;
|
888
|
+
case OT_DREG:
|
889
|
+
/*
|
890
|
+
* In 64 bits there are 16 debug registers.
|
891
|
+
* but accessing any of dr8-15 which aren't implemented will cause an #ud.
|
892
|
+
*/
|
893
|
+
if ((reg == 4) || (reg == 5) || (vrex & PREFIX_EX_R)) return FALSE;
|
894
|
+
|
895
|
+
op->type = O_REG;
|
896
|
+
if (ci->dt == Decode64Bits) op->size = 64;
|
897
|
+
else op->size = 32;
|
898
|
+
op->index = (uint8_t)(DREGS_BASE + reg);
|
899
|
+
break;
|
900
|
+
case OT_SREG: /* Works with REG16 only! */
|
901
|
+
/* If lockableInstruction pointer is non-null we know it's the first operand. */
|
902
|
+
if (lockableInstruction && (reg == 1)) return FALSE; /* Can't MOV CS, <REG>. */
|
903
|
+
/*Don't parse if the reg exceeds the bounds of the array. */
|
904
|
+
if (reg <= SEG_REGS_MAX - 1) operands_set_tsi(op, O_REG, 16, SREGS_BASE + reg);
|
905
|
+
else return FALSE;
|
906
|
+
break;
|
907
|
+
case OT_SEG:
|
908
|
+
op->type = O_REG;
|
909
|
+
/* Size of reg is always 16, it's up to caller to zero extend it to operand size. */
|
910
|
+
op->size = 16;
|
911
|
+
ps->usedPrefixes |= INST_PRE_OP_SIZE;
|
912
|
+
/*
|
913
|
+
* Extract the SEG from ii->flags this time!!!
|
914
|
+
* Check whether an operand size prefix is used.
|
915
|
+
*/
|
916
|
+
switch (instFlags & INST_PRE_SEGOVRD_MASK)
|
917
|
+
{
|
918
|
+
case INST_PRE_ES: op->index = R_ES; break;
|
919
|
+
case INST_PRE_CS: op->index = R_CS; break;
|
920
|
+
case INST_PRE_SS: op->index = R_SS; break;
|
921
|
+
case INST_PRE_DS: op->index = R_DS; break;
|
922
|
+
case INST_PRE_FS: op->index = R_FS; break;
|
923
|
+
case INST_PRE_GS: op->index = R_GS; break;
|
924
|
+
}
|
925
|
+
break;
|
926
|
+
case OT_ACC8:
|
927
|
+
operands_set_tsi(op, O_REG, 8, R_AL);
|
928
|
+
break;
|
929
|
+
case OT_ACC16:
|
930
|
+
operands_set_tsi(op, O_REG, 16, R_AX);
|
931
|
+
break;
|
932
|
+
case OT_ACC_FULL_NOT64: /* No REX.W support for IN/OUT. */
|
933
|
+
vrex &= ~PREFIX_EX_W;
|
934
|
+
case OT_ACC_FULL:
|
935
|
+
if (effOpSz == Decode16Bits) {
|
936
|
+
ps->usedPrefixes |= INST_PRE_OP_SIZE;
|
937
|
+
operands_set_tsi(op, O_REG, 16, R_AX);
|
938
|
+
} else if (effOpSz == Decode32Bits) {
|
939
|
+
ps->usedPrefixes |= INST_PRE_OP_SIZE;
|
940
|
+
operands_set_tsi(op, O_REG, 32, R_EAX);
|
941
|
+
} else { /* Decode64Bits */
|
942
|
+
/* Only non-promoted instructions need REX in order to decode in 64 bits. */
|
943
|
+
/* MEM-OFFSET MOV's are NOT automatically promoted to 64 bits. */
|
944
|
+
if (~instFlags & INST_64BITS) {
|
945
|
+
ps->usedPrefixes |= INST_PRE_REX;
|
946
|
+
}
|
947
|
+
operands_set_tsi(op, O_REG, 64, R_RAX);
|
948
|
+
}
|
949
|
+
break;
|
950
|
+
case OT_PTR16_FULL:
|
951
|
+
/* ptr16:full - full is size of operand size to read, therefore Operand Size Prefix affects this. So we need to handle it. */
|
952
|
+
if (effOpSz == Decode16Bits) {
|
953
|
+
ps->usedPrefixes |= INST_PRE_OP_SIZE;
|
954
|
+
ci->codeLen -= sizeof(int16_t)*2;
|
955
|
+
if (ci->codeLen < 0) return FALSE;
|
956
|
+
|
957
|
+
operands_set_ts(op, O_PTR, 16);
|
958
|
+
di->imm.ptr.off = RUSHORT(ci->code); /* Read offset first. */
|
959
|
+
di->imm.ptr.seg = RUSHORT((ci->code + sizeof(int16_t))); /* And read segment. */
|
960
|
+
|
961
|
+
ci->code += sizeof(int16_t)*2;
|
962
|
+
} else { /* Decode32Bits, for Decode64Bits this instruction is invalid. */
|
963
|
+
ps->usedPrefixes |= INST_PRE_OP_SIZE;
|
964
|
+
ci->codeLen -= sizeof(int32_t) + sizeof(int16_t);
|
965
|
+
if (ci->codeLen < 0) return FALSE;
|
966
|
+
|
967
|
+
operands_set_ts(op, O_PTR, 32);
|
968
|
+
di->imm.ptr.off = RULONG(ci->code); /* Read 32bits offset this time. */
|
969
|
+
di->imm.ptr.seg = RUSHORT((ci->code + sizeof(int32_t))); /* And read segment, 16 bits. */
|
970
|
+
|
971
|
+
ci->code += sizeof(int32_t) + sizeof(int16_t);
|
972
|
+
}
|
973
|
+
break;
|
974
|
+
case OT_RELCB:
|
975
|
+
case OT_RELC_FULL:
|
976
|
+
|
977
|
+
if (type == OT_RELCB) {
|
978
|
+
operands_set_ts(op, O_PC, 8);
|
979
|
+
if (!read_stream_safe_sint(ci, &di->imm.sqword, sizeof(int8_t))) return FALSE;
|
980
|
+
} else { /* OT_RELC_FULL */
|
981
|
+
|
982
|
+
/* Yep, operand size prefix affects relc also. */
|
983
|
+
ps->usedPrefixes |= INST_PRE_OP_SIZE;
|
984
|
+
if (effOpSz == Decode16Bits) {
|
985
|
+
operands_set_ts(op, O_PC, 16);
|
986
|
+
if (!read_stream_safe_sint(ci, &di->imm.sqword, sizeof(int16_t))) return FALSE;
|
987
|
+
} else { /* Decode32Bits or Decode64Bits = for now they are the same */
|
988
|
+
operands_set_ts(op, O_PC, 32);
|
989
|
+
if (!read_stream_safe_sint(ci, &di->imm.sqword, sizeof(int32_t))) return FALSE;
|
990
|
+
}
|
991
|
+
}
|
992
|
+
|
993
|
+
/* Support for hint, see if there's a segment override. */
|
994
|
+
if ((ii->opcodeId >= I_JO) && (ii->opcodeId <= I_JG)) {
|
995
|
+
if (ps->decodedPrefixes & INST_PRE_CS) {
|
996
|
+
ps->usedPrefixes |= INST_PRE_CS;
|
997
|
+
di->flags |= FLAG_HINT_NOT_TAKEN;
|
998
|
+
} else if (ps->decodedPrefixes & INST_PRE_DS) {
|
999
|
+
ps->usedPrefixes |= INST_PRE_DS;
|
1000
|
+
di->flags |= FLAG_HINT_TAKEN;
|
1001
|
+
}
|
1002
|
+
}
|
1003
|
+
break;
|
1004
|
+
case OT_MOFFS8:
|
1005
|
+
op->size = 8;
|
1006
|
+
/* FALL THROUGH, size won't be changed. */
|
1007
|
+
case OT_MOFFS_FULL:
|
1008
|
+
op->type = O_DISP;
|
1009
|
+
if (op->size == 0) {
|
1010
|
+
/* Calculate size of operand (same as ACC size). */
|
1011
|
+
switch (effOpSz)
|
1012
|
+
{
|
1013
|
+
case Decode16Bits: op->size = 16; break;
|
1014
|
+
case Decode32Bits: op->size = 32; break;
|
1015
|
+
case Decode64Bits: op->size = 64; break;
|
1016
|
+
}
|
1017
|
+
}
|
1018
|
+
|
1019
|
+
prefixes_use_segment(INST_PRE_DS, ps, ci->dt, di);
|
1020
|
+
|
1021
|
+
/*
|
1022
|
+
* Just a pointer to a BYTE, WORD, DWORD, QWORD. Works only with ACC8/16/32/64 respectively.
|
1023
|
+
* MOV [0x1234], AL ; MOV AX, [0x1234] ; MOV EAX, [0x1234], note that R/E/AX will be chosen by OT_ACC_FULL.
|
1024
|
+
*/
|
1025
|
+
if (effAdrSz == Decode16Bits) {
|
1026
|
+
ps->usedPrefixes |= INST_PRE_ADDR_SIZE;
|
1027
|
+
|
1028
|
+
di->dispSize = 16;
|
1029
|
+
if (!read_stream_safe_uint(ci, &di->disp, sizeof(int16_t))) return FALSE;
|
1030
|
+
} else if (effAdrSz == Decode32Bits) {
|
1031
|
+
ps->usedPrefixes |= INST_PRE_ADDR_SIZE;
|
1032
|
+
|
1033
|
+
di->dispSize = 32;
|
1034
|
+
if (!read_stream_safe_uint(ci, &di->disp, sizeof(int32_t))) return FALSE;
|
1035
|
+
} else { /* Decode64Bits */
|
1036
|
+
di->dispSize = 64;
|
1037
|
+
if (!read_stream_safe_uint(ci, &di->disp, sizeof(int64_t))) return FALSE;
|
1038
|
+
}
|
1039
|
+
break;
|
1040
|
+
case OT_CONST1:
|
1041
|
+
operands_set_ts(op, O_IMM, 8);
|
1042
|
+
di->imm.byte = 1;
|
1043
|
+
break;
|
1044
|
+
case OT_REGCL:
|
1045
|
+
operands_set_tsi(op, O_REG, 8, R_CL);
|
1046
|
+
break;
|
1047
|
+
|
1048
|
+
case OT_FPU_SI:
|
1049
|
+
/* Low 3 bits specify the REG, similar to the MODR/M byte reg. */
|
1050
|
+
operands_set_tsi(op, O_REG, 32, FPUREGS_BASE + (*(ci->code-1) & 7));
|
1051
|
+
break;
|
1052
|
+
case OT_FPU_SSI:
|
1053
|
+
operands_set_tsi(op, O_REG, 32, R_ST0);
|
1054
|
+
operands_set_tsi(op + 1, O_REG, 32, FPUREGS_BASE + (*(ci->code-1) & 7));
|
1055
|
+
break;
|
1056
|
+
case OT_FPU_SIS:
|
1057
|
+
operands_set_tsi(op, O_REG, 32, FPUREGS_BASE + (*(ci->code-1) & 7));
|
1058
|
+
operands_set_tsi(op + 1, O_REG, 32, R_ST0);
|
1059
|
+
break;
|
1060
|
+
|
1061
|
+
/*
|
1062
|
+
* Special treatment for Instructions-Block:
|
1063
|
+
* INC/DEC (only 16/32 bits) /PUSH/POP/XCHG instructions, which get their REG from their own binary code.
|
1064
|
+
|
1065
|
+
* Notice these instructions are 1 or 2 byte long,
|
1066
|
+
* code points after the byte which represents the instruction itself,
|
1067
|
+
* thus, even if the instructions are 2 bytes long it will read its last byte which contains the REG info.
|
1068
|
+
*/
|
1069
|
+
case OT_IB_RB:
|
1070
|
+
/* Low 3 bits specify the REG, similar to the MODR/M byte reg. */
|
1071
|
+
operands_set_ts(op, O_REG, 8);
|
1072
|
+
reg = *(ci->code-1) & 7;
|
1073
|
+
if (vrex & PREFIX_EX_B) {
|
1074
|
+
ps->usedPrefixes |= INST_PRE_REX;
|
1075
|
+
op->index = (uint8_t)operands_fix_8bit_rex_base(reg + EX_GPR_BASE);
|
1076
|
+
} else if (ps->prefixExtType == PET_REX) {
|
1077
|
+
ps->usedPrefixes |= INST_PRE_REX;
|
1078
|
+
op->index = (uint8_t)operands_fix_8bit_rex_base(reg);
|
1079
|
+
} else op->index = (uint8_t)(REGS8_BASE + reg);
|
1080
|
+
break;
|
1081
|
+
case OT_IB_R_FULL:
|
1082
|
+
reg = *(ci->code-1) & 7;
|
1083
|
+
switch (effOpSz)
|
1084
|
+
{
|
1085
|
+
case Decode16Bits:
|
1086
|
+
ps->usedPrefixes |= INST_PRE_OP_SIZE;
|
1087
|
+
if (vrex & PREFIX_EX_B) {
|
1088
|
+
ps->usedPrefixes |= INST_PRE_REX;
|
1089
|
+
reg += EX_GPR_BASE;
|
1090
|
+
}
|
1091
|
+
operands_set_tsi(op, O_REG, 16, REGS16_BASE + reg);
|
1092
|
+
break;
|
1093
|
+
case Decode32Bits:
|
1094
|
+
if (vrex & PREFIX_EX_B) {
|
1095
|
+
ps->usedPrefixes |= INST_PRE_REX;
|
1096
|
+
reg += EX_GPR_BASE;
|
1097
|
+
} else ps->usedPrefixes |= INST_PRE_OP_SIZE;
|
1098
|
+
operands_set_tsi(op, O_REG, 32, REGS32_BASE + reg);
|
1099
|
+
break;
|
1100
|
+
case Decode64Bits:
|
1101
|
+
/*
|
1102
|
+
* Automatically promoted instruction can drop REX prefix if not required.
|
1103
|
+
* PUSH/POP defaults to 64 bits. --> INST_64BITS
|
1104
|
+
* MOV imm64 / BSWAP requires REX.W to be 64 bits --> INST_64BITS | INST_PRE_REX
|
1105
|
+
*/
|
1106
|
+
if ((instFlags & INST_64BITS) && ((instFlags & INST_PRE_REX) == 0)) {
|
1107
|
+
if (vrex & PREFIX_EX_B) {
|
1108
|
+
ps->usedPrefixes |= INST_PRE_REX;
|
1109
|
+
reg += EX_GPR_BASE;
|
1110
|
+
}
|
1111
|
+
} else {
|
1112
|
+
ps->usedPrefixes |= INST_PRE_REX;
|
1113
|
+
reg += (vrex & PREFIX_EX_B) ? EX_GPR_BASE : 0;
|
1114
|
+
}
|
1115
|
+
operands_set_tsi(op, O_REG, 64, REGS64_BASE + reg);
|
1116
|
+
break;
|
1117
|
+
}
|
1118
|
+
break;
|
1119
|
+
|
1120
|
+
/*
|
1121
|
+
* Special treatment for repeatable instructions.
|
1122
|
+
|
1123
|
+
* We want the following output:
|
1124
|
+
* If there's only the REP/NZ prefix, we won't output anything (All operands are implicit).
|
1125
|
+
* If there's an operand size prefix, we will change the suffix letter of the mnemonic, which specifies the size of operand to the required one.
|
1126
|
+
* If there's a segment override prefix, we will output the segment and the used index register (EDI/ESI).
|
1127
|
+
* If there's an address size prefix, we will output the (segment if needed and) the used and inverted index register (DI/SI).
|
1128
|
+
|
1129
|
+
* Example:
|
1130
|
+
* :: Decoding in 16 bits mode! ::
|
1131
|
+
* AD ~ LODSW
|
1132
|
+
* 66 AD ~ LODSD
|
1133
|
+
* F3 AC ~ REP LODSB
|
1134
|
+
* F3 66 AD ~ REP LODSD
|
1135
|
+
* F3 3E AC ~ REP LODS BYTE DS:[SI]
|
1136
|
+
* F3 67 AD ~ REP LODS WORD [ESI]
|
1137
|
+
|
1138
|
+
* The basic form of a repeatable instruction has its operands hidden and has a suffix letter
|
1139
|
+
* which implies on the size of operation being done.
|
1140
|
+
* Therefore, we cannot change the mnemonic here when we encounter another prefix and its not the decoder's responsibility to do so.
|
1141
|
+
* That's why the caller is responsible to add the suffix letter if no other prefixes are used.
|
1142
|
+
* And all we are doing here is formatting the operand correctly.
|
1143
|
+
*/
|
1144
|
+
case OT_REGI_ESI:
|
1145
|
+
ps->usedPrefixes |= INST_PRE_ADDR_SIZE;
|
1146
|
+
|
1147
|
+
op->type = O_SMEM;
|
1148
|
+
|
1149
|
+
/* This might be a 16, 32 or 64 bits instruction, depends on the decoding mode. */
|
1150
|
+
if (instFlags & INST_16BITS) {
|
1151
|
+
ps->usedPrefixes |= INST_PRE_OP_SIZE;
|
1152
|
+
|
1153
|
+
if (effOpSz == Decode16Bits) op->size = 16;
|
1154
|
+
else if ((effOpSz == Decode64Bits) && (instFlags & INST_64BITS)) {
|
1155
|
+
ps->usedPrefixes |= INST_PRE_REX;
|
1156
|
+
op->size = 64;
|
1157
|
+
} else op->size = 32;
|
1158
|
+
} else op->size = 8;
|
1159
|
+
|
1160
|
+
/*
|
1161
|
+
* Clear segment in case OT_REGI_EDI was parsed earlier,
|
1162
|
+
* DS can be overridden and therefore has precedence.
|
1163
|
+
*/
|
1164
|
+
di->segment = 0;
|
1165
|
+
prefixes_use_segment(INST_PRE_DS, ps, ci->dt, di);
|
1166
|
+
|
1167
|
+
if (effAdrSz == Decode16Bits) op->index = R_SI;
|
1168
|
+
else if (effAdrSz == Decode32Bits) op->index = R_ESI;
|
1169
|
+
else op->index = R_RSI;
|
1170
|
+
break;
|
1171
|
+
case OT_REGI_EDI:
|
1172
|
+
ps->usedPrefixes |= INST_PRE_ADDR_SIZE;
|
1173
|
+
|
1174
|
+
op->type = O_SMEM;
|
1175
|
+
|
1176
|
+
/* This might be a 16 or 32 bits instruction, depends on the decoding mode. */
|
1177
|
+
if (instFlags & INST_16BITS) {
|
1178
|
+
ps->usedPrefixes |= INST_PRE_OP_SIZE;
|
1179
|
+
|
1180
|
+
if (effOpSz == Decode16Bits) op->size = 16;
|
1181
|
+
else if ((effOpSz == Decode64Bits) && (instFlags & INST_64BITS)) {
|
1182
|
+
ps->usedPrefixes |= INST_PRE_REX;
|
1183
|
+
op->size = 64;
|
1184
|
+
} else op->size = 32;
|
1185
|
+
} else op->size = 8;
|
1186
|
+
|
1187
|
+
/* Note: The [rDI] operand can't be prefixed by a segment override, therefore we don't set usedPrefixes. */
|
1188
|
+
if ((opNum == ONT_1) && (ci->dt != Decode64Bits)) di->segment = R_ES | SEGMENT_DEFAULT; /* No ES in 64 bits mode. */
|
1189
|
+
|
1190
|
+
if (effAdrSz == Decode16Bits) op->index = R_DI;
|
1191
|
+
else if (effAdrSz == Decode32Bits) op->index = R_EDI;
|
1192
|
+
else op->index = R_RDI;
|
1193
|
+
break;
|
1194
|
+
|
1195
|
+
/* Used for In/Out instructions varying forms. */
|
1196
|
+
case OT_REGDX:
|
1197
|
+
/* Simple single IN/OUT instruction. */
|
1198
|
+
operands_set_tsi(op, O_REG, 16, R_DX);
|
1199
|
+
break;
|
1200
|
+
|
1201
|
+
/* Used for INVLPGA instruction. */
|
1202
|
+
case OT_REGECX:
|
1203
|
+
operands_set_tsi(op, O_REG, 32, R_ECX);
|
1204
|
+
break;
|
1205
|
+
case OT_REGI_EBXAL:
|
1206
|
+
/* XLAT BYTE [rBX + AL] */
|
1207
|
+
ps->usedPrefixes |= INST_PRE_ADDR_SIZE;
|
1208
|
+
|
1209
|
+
prefixes_use_segment(INST_PRE_DS, ps, ci->dt, di);
|
1210
|
+
|
1211
|
+
/* Size of deref is always 8 for xlat. */
|
1212
|
+
operands_set_tsi(op, O_MEM, 8, R_AL);
|
1213
|
+
|
1214
|
+
if (effAdrSz == Decode16Bits) di->base = R_BX;
|
1215
|
+
else if (effAdrSz == Decode32Bits) di->base = R_EBX;
|
1216
|
+
else {
|
1217
|
+
ps->usedPrefixes |= INST_PRE_REX;
|
1218
|
+
di->base = R_RBX;
|
1219
|
+
}
|
1220
|
+
break;
|
1221
|
+
case OT_REGI_EAX:
|
1222
|
+
/*
|
1223
|
+
* Implicit rAX as memory indirection operand. Used by AMD's SVM instructions.
|
1224
|
+
* Since this is a memory indirection, the default address size in 64bits decoding mode is 64.
|
1225
|
+
*/
|
1226
|
+
|
1227
|
+
if (effAdrSz == Decode64Bits) operands_set_tsi(op, O_SMEM, 64, R_RAX);
|
1228
|
+
else if (effAdrSz == Decode32Bits) {
|
1229
|
+
ps->usedPrefixes |= INST_PRE_ADDR_SIZE;
|
1230
|
+
operands_set_tsi(op, O_SMEM, 32, R_EAX);
|
1231
|
+
} else {
|
1232
|
+
ps->usedPrefixes |= INST_PRE_ADDR_SIZE;
|
1233
|
+
operands_set_tsi(op, O_SMEM, 16, R_AX);
|
1234
|
+
}
|
1235
|
+
break;
|
1236
|
+
case OT_VXMM:
|
1237
|
+
operands_set_tsi(op, O_REG, 128, SSEREGS_BASE + vexV);
|
1238
|
+
break;
|
1239
|
+
case OT_XMM_IMM:
|
1240
|
+
ci->codeLen -= sizeof(int8_t);
|
1241
|
+
if (ci->codeLen < 0) return FALSE;
|
1242
|
+
|
1243
|
+
if (ci->dt == Decode32Bits) reg = (*ci->code >> 4) & 0x7;
|
1244
|
+
else reg = (*ci->code >> 4) & 0xf;
|
1245
|
+
operands_set_tsi(op, O_REG, 128, SSEREGS_BASE + reg);
|
1246
|
+
|
1247
|
+
ci->code += sizeof(int8_t);
|
1248
|
+
break;
|
1249
|
+
case OT_YXMM:
|
1250
|
+
if (vrex & PREFIX_EX_R) reg += EX_GPR_BASE;
|
1251
|
+
if (ps->vrex & PREFIX_EX_L) operands_set_tsi(op, O_REG, 256, AVXREGS_BASE + reg);
|
1252
|
+
else operands_set_tsi(op, O_REG, 128, SSEREGS_BASE + reg);
|
1253
|
+
break;
|
1254
|
+
case OT_YXMM_IMM:
|
1255
|
+
ci->codeLen -= sizeof(int8_t);
|
1256
|
+
if (ci->codeLen < 0) return FALSE;
|
1257
|
+
|
1258
|
+
if (ci->dt == Decode32Bits) reg = (*ci->code >> 4) & 0x7;
|
1259
|
+
else reg = (*ci->code >> 4) & 0xf;
|
1260
|
+
|
1261
|
+
if (ps->vrex & PREFIX_EX_L) operands_set_tsi(op, O_REG, 256, AVXREGS_BASE + reg);
|
1262
|
+
else operands_set_tsi(op, O_REG, 128, SSEREGS_BASE + reg);
|
1263
|
+
|
1264
|
+
ci->code += sizeof(int8_t);
|
1265
|
+
break;
|
1266
|
+
case OT_YMM:
|
1267
|
+
if (vrex & PREFIX_EX_R) reg += EX_GPR_BASE;
|
1268
|
+
operands_set_tsi(op, O_REG, 256, AVXREGS_BASE + reg);
|
1269
|
+
break;
|
1270
|
+
case OT_VYMM:
|
1271
|
+
operands_set_tsi(op, O_REG, 256, AVXREGS_BASE + vexV);
|
1272
|
+
break;
|
1273
|
+
case OT_VYXMM:
|
1274
|
+
if (ps->vrex & PREFIX_EX_L) operands_set_tsi(op, O_REG, 256, AVXREGS_BASE + vexV);
|
1275
|
+
else operands_set_tsi(op, O_REG, 128, SSEREGS_BASE + vexV);
|
1276
|
+
break;
|
1277
|
+
case OT_WREG32_64:
|
1278
|
+
if (vrex & PREFIX_EX_R) reg += EX_GPR_BASE;
|
1279
|
+
if (ps->vrex & PREFIX_EX_W) operands_set_tsi(op, O_REG, 64, REGS64_BASE + reg);
|
1280
|
+
else operands_set_tsi(op, O_REG, 32, REGS32_BASE + reg);
|
1281
|
+
break;
|
1282
|
+
default: return FALSE;
|
1283
|
+
}
|
1284
|
+
|
1285
|
+
if ((op->type == O_REG) || (op->type == O_SMEM) || (op->type == O_MEM)) {
|
1286
|
+
di->usedRegistersMask |= _REGISTERTORCLASS[op->index];
|
1287
|
+
}
|
1288
|
+
|
1289
|
+
return TRUE;
|
1290
|
+
}
|