X64 base regs (#1166)

* x86: setup FS & GS base

* Fixed base register writes for x64, removed then for x16/x32 (the don't exist there?)

* FS reg comes before GS so the base regs do so, too

* added shebang to const_generator.py

* Added base regs to and added 'all' support to const_generator

Co-authored-by: naq <aquynh@gmail.com>
This commit is contained in:
Dominik Maier
2020-05-05 02:34:51 +02:00
committed by GitHub
parent b7e64f3c99
commit 625399774c
9 changed files with 59 additions and 10 deletions

View File

@@ -1,3 +1,4 @@
#!/usr/bin/env python3
# Unicorn Engine
# By Dang Hoang Vu, 2013
from __future__ import print_function
@@ -118,7 +119,8 @@ def gen(lang):
outfile.write((templ['header'] % (prefix)).encode("utf-8"))
if target == 'unicorn.h':
prefix = ''
lines = open(os.path.join(INCL_DIR, target)).readlines()
with open(os.path.join(INCL_DIR, target)) as f:
lines = f.readlines()
previous = {}
count = 0
@@ -185,12 +187,18 @@ def gen(lang):
def main():
lang = sys.argv[1]
if not lang in template:
raise RuntimeError("Unsupported binding %s" % lang)
gen(sys.argv[1])
if lang == "all":
for lang in template.keys():
print("Generating constants for {}".format(lang))
gen(lang)
else:
if not lang in template:
raise RuntimeError("Unsupported binding %s" % lang)
gen(lang)
if __name__ == "__main__":
if len(sys.argv) < 2:
print("Usage:", sys.argv[0], " <python>")
print("Supported: {}".format(["all"] + [x for x in template.keys()]))
sys.exit(1)
main()

View File

@@ -259,7 +259,9 @@ module X86 =
let UC_X86_REG_FPTAG = 247
let UC_X86_REG_MSR = 248
let UC_X86_REG_MXCSR = 249
let UC_X86_REG_ENDING = 250
let UC_X86_REG_FS_BASE = 250
let UC_X86_REG_GS_BASE = 251
let UC_X86_REG_ENDING = 252
// X86 instructions

View File

@@ -254,7 +254,9 @@ const (
X86_REG_FPTAG = 247
X86_REG_MSR = 248
X86_REG_MXCSR = 249
X86_REG_ENDING = 250
X86_REG_FS_BASE = 250
X86_REG_GS_BASE = 251
X86_REG_ENDING = 252
// X86 instructions

View File

@@ -256,7 +256,9 @@ public interface X86Const {
public static final int UC_X86_REG_FPTAG = 247;
public static final int UC_X86_REG_MSR = 248;
public static final int UC_X86_REG_MXCSR = 249;
public static final int UC_X86_REG_ENDING = 250;
public static final int UC_X86_REG_FS_BASE = 250;
public static final int UC_X86_REG_GS_BASE = 251;
public static final int UC_X86_REG_ENDING = 252;
// X86 instructions

View File

@@ -257,7 +257,9 @@ const
UC_X86_REG_FPTAG = 247;
UC_X86_REG_MSR = 248;
UC_X86_REG_MXCSR = 249;
UC_X86_REG_ENDING = 250;
UC_X86_REG_FS_BASE = 250;
UC_X86_REG_GS_BASE = 251;
UC_X86_REG_ENDING = 252;
// X86 instructions

View File

@@ -252,7 +252,9 @@ UC_X86_REG_FPCW = 246
UC_X86_REG_FPTAG = 247
UC_X86_REG_MSR = 248
UC_X86_REG_MXCSR = 249
UC_X86_REG_ENDING = 250
UC_X86_REG_FS_BASE = 250
UC_X86_REG_GS_BASE = 251
UC_X86_REG_ENDING = 252
# X86 instructions

View File

@@ -254,7 +254,9 @@ module UnicornEngine
UC_X86_REG_FPTAG = 247
UC_X86_REG_MSR = 248
UC_X86_REG_MXCSR = 249
UC_X86_REG_ENDING = 250
UC_X86_REG_FS_BASE = 250
UC_X86_REG_GS_BASE = 251
UC_X86_REG_ENDING = 252
# X86 instructions