Revert constant generation + Quality of service change

This commit is contained in:
FuzzySecurity 2016-11-11 14:15:45 +01:00
parent 6d2fad58fc
commit f575f5e75e
4 changed files with 45 additions and 68 deletions

View File

@ -18,7 +18,6 @@ all:
cd python && $(MAKE) gen_const
cd java && $(MAKE) gen_const
cd ocaml && $(MAKE) gen_const
python const_generator.py powershell
tests: expected python java #oclma ruby

View File

@ -8,16 +8,6 @@ INCL_DIR = '../include/'
include = [ 'arm.h', 'arm64.h', 'mips.h', 'x86.h', 'ppc.h', 'sparc.h', 'systemz.h', 'xcore.h' ]
template = {
'powershell': {
'header': "# For Capstone Engine. AUTO-GENERATED FILE, DO NOT EDIT [%s_h.cs]\n",
'footer': "",
'line_format': '%s = %s\n',
'out_file': './powershell/Capstone/Const/%s_h.cs',
# only capstone.h required, but it is not included above on line 8?
'capstone.h': 'capstone',
'comment_open': '///',
'comment_close': '',
},
'java': {
'header': "// For Capstone Engine. AUTO-GENERATED FILE, DO NOT EDIT\npackage capstone;\n\npublic class %s_const {\n",
'footer': "}",

View File

@ -149,11 +149,6 @@ function Get-CapstoneDisassembly {
Return
}
# Load C# constants
$cs_err = Select-String "CS_ERR_" $($PSScriptRoot + '\Const\capstone_h.cs') |select -exp line
$cs_arch = Select-String "CS_ARCH_" $($PSScriptRoot + '\Const\capstone_h.cs') |select -exp line
$cs_mode = Select-String "CS_MODE_" $($PSScriptRoot + '\Const\capstone_h.cs') |select -exp line
# Inline C# to parse the unmanaged capstone DLL
Add-Type -TypeDefinition @"
using System;
@ -193,17 +188,52 @@ function Get-CapstoneDisassembly {
public enum cs_err : int
{
$cs_err
CS_ERR_OK = 0, /// No error: everything was fine
CS_ERR_MEM, /// Out-Of-Memory error: cs_open(), cs_disasm(), cs_disasm_iter()
CS_ERR_ARCH, /// Unsupported architecture: cs_open()
CS_ERR_HANDLE, /// Invalid handle: cs_op_count(), cs_op_index()
CS_ERR_CSH, /// Invalid csh argument: cs_close(), cs_errno(), cs_option()
CS_ERR_MODE, /// Invalid/unsupported mode: cs_open()
CS_ERR_OPTION, /// Invalid/unsupported option: cs_option()
CS_ERR_DETAIL, /// Information is unavailable because detail option is OFF
CS_ERR_MEMSETUP, /// Dynamic memory management uninitialized (see CS_OPT_MEM)
CS_ERR_VERSION, /// Unsupported version (bindings)
CS_ERR_DIET, /// Access irrelevant data in "diet" engine
CS_ERR_SKIPDATA, /// Access irrelevant data for "data" instruction in SKIPDATA mode
CS_ERR_X86_ATT, /// X86 AT&T syntax is unsupported (opt-out at compile time)
CS_ERR_X86_INTEL, /// X86 Intel syntax is unsupported (opt-out at compile time)
}
public enum cs_arch : int
{
$cs_arch
CS_ARCH_ARM = 0, /// ARM architecture (including Thumb, Thumb-2)
CS_ARCH_ARM64, /// ARM-64, also called AArch64
CS_ARCH_MIPS, /// Mips architecture
CS_ARCH_X86, /// X86 architecture (including x86 & x86-64)
CS_ARCH_PPC, /// PowerPC architecture
CS_ARCH_SPARC, /// Sparc architecture
CS_ARCH_SYSZ, /// SystemZ architecture
CS_ARCH_XCORE, /// XCore architecture
CS_ARCH_MAX,
CS_ARCH_ALL = 0xFFFF, /// All architectures - for cs_support()
}
public enum cs_mode : int
{
$cs_mode
CS_MODE_LITTLE_ENDIAN = 0, /// little-endian mode (default mode)
CS_MODE_ARM = 0, /// 32-bit ARM
CS_MODE_16 = 1 << 1, /// 16-bit mode (X86)
CS_MODE_32 = 1 << 2, /// 32-bit mode (X86)
CS_MODE_64 = 1 << 3, /// 64-bit mode (X86, PPC)
CS_MODE_THUMB = 1 << 4, /// ARM's Thumb mode, including Thumb-2
CS_MODE_MCLASS = 1 << 5, /// ARM's Cortex-M series
CS_MODE_V8 = 1 << 6, /// ARMv8 A32 encodings for ARM
CS_MODE_MICRO = 1 << 4, /// MicroMips mode (MIPS)
CS_MODE_MIPS3 = 1 << 5, /// Mips III ISA
CS_MODE_MIPS32R6 = 1 << 6, /// Mips32r6 ISA
CS_MODE_MIPSGP64 = 1 << 7, /// General Purpose Registers are 64-bit wide (MIPS)
CS_MODE_V9 = 1 << 4, /// SparcV9 mode (Sparc)
CS_MODE_BIG_ENDIAN = 1 << 31, /// big-endian mode
CS_MODE_MIPS32 = CS_MODE_32, /// Mips32 ISA (Mips)
CS_MODE_MIPS64 = CS_MODE_64, /// Mips64 ISA (Mips)
}
public static class Capstone
@ -361,14 +391,12 @@ function Get-CapstoneDisassembly {
$Cast = [system.runtime.interopservices.marshal]::PtrToStructure($InsnPointer,[type]$cs_insn)
if ($CS_OPT -eq 0) {
# Some dirty tricks for spacing, sorry mmkay!
if ($i -eq 0) {
$Disasm += echo "`n"
}
$Disasm += echo "$($Cast.mnemonic) $($Cast.operands)"
if ($i -eq $($count-1)){
$Disasm += echo "`n"
$HashTable = @{
Address = echo "0x$("{0:X}" -f $Cast.address)"
Instruction = echo "$($Cast.mnemonic) $($Cast.operands)"
}
$Object = New-Object PSObject -Property $HashTable
$Disasm += $Object |Select-Object Address,Instruction
} else {
$DetailCast = [system.runtime.interopservices.marshal]::PtrToStructure($Cast.detail,[type]$cs_detail)
if($DetailCast.regs_read_count -gt 0) {

View File

@ -1,40 +0,0 @@
CS_ERR_OK = 0,
CS_ERR_MEM,
CS_ERR_ARCH,
CS_ERR_HANDLE,
CS_ERR_CSH,
CS_ERR_MODE,
CS_ERR_OPTION,
CS_ERR_DETAIL,
CS_ERR_MEMSETUP,
CS_ERR_VERSION,
CS_ERR_DIET,
CS_ERR_SKIPDATA,
CS_ERR_X86_ATT,
CS_ERR_X86_INTEL,
CS_ARCH_ARM = 0,
CS_ARCH_ARM64,
CS_ARCH_MIPS,
CS_ARCH_X86,
CS_ARCH_PPC,
CS_ARCH_SPARC,
CS_ARCH_SYSZ,
CS_ARCH_XCORE,
CS_ARCH_MAX,
CS_ARCH_ALL = 0xFFFF,
CS_MODE_LITTLE_ENDIAN = 0,
CS_MODE_ARM = 0,
CS_MODE_16 = 1 << 1,
CS_MODE_32 = 1 << 2,
CS_MODE_64 = 1 << 3,
CS_MODE_THUMB = 1 << 4,
CS_MODE_MCLASS = 1 << 5,
CS_MODE_V8 = 1 << 6,
CS_MODE_MICRO = 1 << 4,
CS_MODE_MIPS3 = 1 << 5,
CS_MODE_MIPS32R6 = 1 << 6,
CS_MODE_MIPSGP64 = 1 << 7,
CS_MODE_V9 = 1 << 4,
CS_MODE_BIG_ENDIAN = 1 << 31,
CS_MODE_MIPS32 = CS_MODE_32,
CS_MODE_MIPS64 = CS_MODE_64,