Browse Source

initial commit; started earlier today

tags/v0.1
commit
d12972a0d1
Signed by: govanify <gauvain@govanify.com> GPG Key ID: DE62E1E2A6145556
13 changed files with 231 additions and 0 deletions
  1. +2
    -0
      .gitignore
  2. +21
    -0
      LICENSE
  3. +0
    -0
      Module.manifest
  4. +4
    -0
      build.sh
  5. +62
    -0
      data/kh2ai.cspec
  6. +2
    -0
      data/languages/.gdb_history
  7. BIN
      data/languages/.kh2ai.sinc.swp
  8. +62
    -0
      data/languages/kh2ai.cspec
  9. +15
    -0
      data/languages/kh2ai.ldefs
  10. +5
    -0
      data/languages/kh2ai.pspec
  11. +53
    -0
      data/languages/kh2ai.sinc
  12. +4
    -0
      data/languages/kh2ai.slaspec
  13. +1
    -0
      data/languages/peda-session-sleigh.txt

+ 2
- 0
.gitignore View File

@@ -0,0 +1,2 @@
*.sla
mep.zip

+ 21
- 0
LICENSE View File

@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2019 Gauvain "GovanifY" Roussel-Tarbouriech

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

+ 0
- 0
Module.manifest View File


+ 4
- 0
build.sh View File

@@ -0,0 +1,4 @@
cd data/languages
/home/govanify/Documents/projects/programming/hacking/tools/ghidra/Ghidra/Features/Decompiler/os/linux64/sleigh -c -u -a
cp -rf ../../ /home/govanify/Documents/projects/programming/hacking/tools/ghidra/Ghidra/Processors/kh2a
cd ../../

+ 62
- 0
data/kh2ai.cspec View File

@@ -0,0 +1,62 @@
<?xml version="1.0" encoding="UTF-8"?>

<compiler_spec>
<data_organization> <!-- These tags were generated with gcc 4.2.4 -->
<absolute_max_alignment value="0" />
<machine_alignment value="2" />
<default_alignment value="1" />
<default_pointer_alignment value="4" />
<pointer_size value="4" />
<wchar_size value="4" />
<short_size value="2" />
<integer_size value="4" />
<long_size value="4" />
<long_long_size value="8" />
<float_size value="4" />
<double_size value="8" />
<long_double_size value="8" />
<size_alignment_map>
<entry size="1" alignment="1" />
<entry size="2" alignment="2" />
<entry size="4" alignment="4" />
<entry size="8" alignment="8" />
</size_alignment_map>
</data_organization>
<global>
<range space="ram"/>
</global>
<stackpointer register="sp" space="ram"/>
<default_proto>
<prototype name="__stdcall" extrapop="0" stackshift="0">
<input>
<pentry minsize="1" maxsize="4" extension="inttype">
<register name="r1"/>
</pentry>
<pentry minsize="1" maxsize="4" extension="inttype">
<register name="r2"/>
</pentry>
<pentry minsize="1" maxsize="4" extension="inttype">
<register name="r3"/>
</pentry>
<pentry minsize="1" maxsize="4" extension="inttype">
<register name="r4"/>
</pentry>
<pentry minsize="1" maxsize="500" align="4">
<addr offset="0" space="stack"/>
</pentry>
</input>
<output>
<pentry minsize="1" maxsize="4" extension="inttype">
<register name="r0"/>
</pentry>
</output>
<unaffected>
<register name="r5"/>
<register name="r6"/>
<register name="r7"/>
<register name="r8"/>
<register name="sp"/>
</unaffected>
</prototype>
</default_proto>
</compiler_spec>

+ 2
- 0
data/languages/.gdb_history View File

@@ -0,0 +1,2 @@
run -c -u -a
q

BIN
data/languages/.kh2ai.sinc.swp View File


+ 62
- 0
data/languages/kh2ai.cspec View File

@@ -0,0 +1,62 @@
<?xml version="1.0" encoding="UTF-8"?>

<compiler_spec>
<data_organization> <!-- These tags were generated with gcc 4.2.4 -->
<absolute_max_alignment value="0" />
<machine_alignment value="2" />
<default_alignment value="1" />
<default_pointer_alignment value="4" />
<pointer_size value="4" />
<wchar_size value="4" />
<short_size value="2" />
<integer_size value="4" />
<long_size value="4" />
<long_long_size value="8" />
<float_size value="4" />
<double_size value="8" />
<long_double_size value="8" />
<size_alignment_map>
<entry size="1" alignment="1" />
<entry size="2" alignment="2" />
<entry size="4" alignment="4" />
<entry size="8" alignment="8" />
</size_alignment_map>
</data_organization>
<global>
<range space="ram"/>
</global>
<stackpointer register="sp" space="ram"/>
<default_proto>
<prototype name="__stdcall" extrapop="0" stackshift="0">
<input>
<pentry minsize="1" maxsize="4" extension="inttype">
<register name="r1"/>
</pentry>
<pentry minsize="1" maxsize="4" extension="inttype">
<register name="r2"/>
</pentry>
<pentry minsize="1" maxsize="4" extension="inttype">
<register name="r3"/>
</pentry>
<pentry minsize="1" maxsize="4" extension="inttype">
<register name="r4"/>
</pentry>
<pentry minsize="1" maxsize="500" align="4">
<addr offset="0" space="stack"/>
</pentry>
</input>
<output>
<pentry minsize="1" maxsize="4" extension="inttype">
<register name="r0"/>
</pentry>
</output>
<unaffected>
<register name="r5"/>
<register name="r6"/>
<register name="r7"/>
<register name="r8"/>
<register name="sp"/>
</unaffected>
</prototype>
</default_proto>
</compiler_spec>

+ 15
- 0
data/languages/kh2ai.ldefs View File

@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>

<language_definitions>
<language processor="kh2ai"
endian="little"
size="32"
variant="default"
version="1.0"
slafile="kh2ai.sla"
processorspec="kh2ai.pspec"
id="KH2_AI:LE:32:default">
<description>Kingdom Hearts 2 pseudo-processor 32-bit little-endian</description>
<compiler name="default" spec="kh2ai.cspec" id="default"/>
</language>
</language_definitions>

+ 5
- 0
data/languages/kh2ai.pspec View File

@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>

<processor_spec>
<programcounter register="pc"/>
</processor_spec>

+ 53
- 0
data/languages/kh2ai.sinc View File

@@ -0,0 +1,53 @@
# Main slaspec must define endianess and alignment

define space ram type=ram_space size=4 wordsize=1 default;

define space register type=register_space size=4;

# the rx are used simply to store arguments of instr
define register offset=0 size=4 [
r0 r1 r2 r3 r4 r5 r6
r7 r8 pc sp test
];

define token instr(8)
op1 = (0, 3)
op2 = (4, 7)
op3 = (6, 7)
rn = (6, 7);

define token extsmall(24)
ib = (8, 23);

define token ext(40)
il = (8, 39);

define pcodeop system_call;

# only 2 and 3 are ever used but we need a full 2-bit mapping
attach variables [ rn ] [ r0 r0 r1 r1 ];



#
#
# Instructions
#
#

#push
:push il is op1=0 & op3=3 ; il {
*[ram]:4 sp = il:4;
sp=sp+4;
}

#push and add
:pusha rn,ib is op1=0 & ( op3=1 | op3=2) & rn ; ib {
*[ram]:4 sp = rn:4+ib:4;
sp=sp+4;
}

#syscall
:syscall op3,ib is op1=0xA & op3 ; ib {
r0=system_call();
}

+ 4
- 0
data/languages/kh2ai.slaspec View File

@@ -0,0 +1,4 @@
define endian=little;
#define alignment=2;

@include "kh2ai.sinc"

+ 1
- 0
data/languages/peda-session-sleigh.txt View File

@@ -0,0 +1 @@


Loading…
Cancel
Save