├── Module.manifest
├── ghidra_scripts
└── README.txt
├── .gitignore
├── src
├── main
│ ├── resources
│ │ └── images
│ │ │ └── README.txt
│ ├── help
│ │ └── help
│ │ │ ├── topics
│ │ │ └── mclfloader
│ │ │ │ └── help.html
│ │ │ ├── TOC_Source.xml
│ │ │ └── shared
│ │ │ └── Frontpage.css
│ └── java
│ │ └── mclfloader
│ │ ├── MCLFHeader.java
│ │ └── MCLFLoader.java
└── test
│ └── java
│ └── README.test.txt
├── dist
├── ghidra_9.0_PUBLIC_20190321_MCLFLoader.zip
├── ghidra_9.0.1_PUBLIC_20190607_mclf-ghidra-loader.zip
├── ghidra_9.0.2_PUBLIC_20190607_mclf-ghidra-loader.zip
├── ghidra_9.0.4_PUBLIC_20190607_mclf-ghidra-loader.zip
└── ghidra_9.1_PUBLIC_20191102_mclf-ghidra-loader.zip
├── extension.properties
├── lib
└── README.txt
├── os
├── linux64
│ └── README.txt
├── osx64
│ └── README.txt
└── win64
│ └── README.txt
├── README.md
└── data
├── languages
├── skel.opinion
├── skel.ldefs
├── skel.pspec
├── skel.slaspec
├── skel.cspec
└── skel.sinc
├── README.txt
└── build.xml
/Module.manifest:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/ghidra_scripts/README.txt:
--------------------------------------------------------------------------------
1 | Java source directory to hold module-specific Ghidra scripts.
2 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | .*
2 | *.zip
3 | *.jar
4 | *.log
5 | *.class
6 | bin/*
7 | build/*
8 | !/.gitignore
9 |
--------------------------------------------------------------------------------
/src/main/resources/images/README.txt:
--------------------------------------------------------------------------------
1 | The "src/resources/images" directory is intended to hold all image/icon files used by
2 | this module.
3 |
--------------------------------------------------------------------------------
/dist/ghidra_9.0_PUBLIC_20190321_MCLFLoader.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NeatMonster/mclf-ghidra-loader/HEAD/dist/ghidra_9.0_PUBLIC_20190321_MCLFLoader.zip
--------------------------------------------------------------------------------
/dist/ghidra_9.0.1_PUBLIC_20190607_mclf-ghidra-loader.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NeatMonster/mclf-ghidra-loader/HEAD/dist/ghidra_9.0.1_PUBLIC_20190607_mclf-ghidra-loader.zip
--------------------------------------------------------------------------------
/dist/ghidra_9.0.2_PUBLIC_20190607_mclf-ghidra-loader.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NeatMonster/mclf-ghidra-loader/HEAD/dist/ghidra_9.0.2_PUBLIC_20190607_mclf-ghidra-loader.zip
--------------------------------------------------------------------------------
/dist/ghidra_9.0.4_PUBLIC_20190607_mclf-ghidra-loader.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NeatMonster/mclf-ghidra-loader/HEAD/dist/ghidra_9.0.4_PUBLIC_20190607_mclf-ghidra-loader.zip
--------------------------------------------------------------------------------
/dist/ghidra_9.1_PUBLIC_20191102_mclf-ghidra-loader.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NeatMonster/mclf-ghidra-loader/HEAD/dist/ghidra_9.1_PUBLIC_20191102_mclf-ghidra-loader.zip
--------------------------------------------------------------------------------
/extension.properties:
--------------------------------------------------------------------------------
1 | name=@extname@
2 | description=The extension description can be customized by editing the extension.properties file.
3 | author=
4 | createdOn=
5 | version=@extversion@
6 |
--------------------------------------------------------------------------------
/src/test/java/README.test.txt:
--------------------------------------------------------------------------------
1 | The "test" directory is intended to hold unit test cases. The package structure within
2 | this folder should correspond to that found in the "src" folder.
3 |
--------------------------------------------------------------------------------
/lib/README.txt:
--------------------------------------------------------------------------------
1 | The "lib" directory is intended to hold Jar files which this module
2 | is dependent upon. This directory may be eliminated from a specific
3 | module if no other Jar files are needed.
4 |
--------------------------------------------------------------------------------
/os/linux64/README.txt:
--------------------------------------------------------------------------------
1 | The "os/linux64" directory is intended to hold Linux native binaries
2 | which this module is dependent upon. This directory may be eliminated for a specific
3 | module if native binaries are not provided for the corresponding platform.
4 |
--------------------------------------------------------------------------------
/os/osx64/README.txt:
--------------------------------------------------------------------------------
1 | The "os/osx64" directory is intended to hold macOS (OS X) native binaries
2 | which this module is dependent upon. This directory may be eliminated for a specific
3 | module if native binaries are not provided for the corresponding platform.
4 |
--------------------------------------------------------------------------------
/os/win64/README.txt:
--------------------------------------------------------------------------------
1 | The "os/win64" directory is intended to hold MS Windows native binaries (.exe)
2 | which this module is dependent upon. This directory may be eliminated for a specific
3 | module if native binaries are not provided for the corresponding platform.
4 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # MCLFLoader
2 |
3 | A Ghidra loader module for the MobiCore Loadable Format (MCLF) used by trustlet and driver binaries.
4 |
5 | ## Installation
6 |
7 | Copy the ZIP file from the `dist/` to the `GHIDRA_INSTALL_DIR/Extensions/Ghidra` directory and install the module from the `File > Install extensions...` menu on the main screen.
8 |
9 | ## Compilation
10 |
11 | Set the `GHIDRA_INSTALL_DIR` environment variable and run `gradle`.
12 |
--------------------------------------------------------------------------------
/data/languages/skel.opinion:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
12 |
13 |
--------------------------------------------------------------------------------
/data/languages/skel.ldefs:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
20 |
21 |
--------------------------------------------------------------------------------
/data/README.txt:
--------------------------------------------------------------------------------
1 | The "data" directory is intended to hold data files that will be used by this module and will
2 | not end up in the .jar file, but will be present in the zip or tar file. Typically, data
3 | files are placed here rather than in the resources directory if the user may need to edit them.
4 |
5 | An optional data/languages directory can exist for the purpose of containing various Sleigh language
6 | specification files and importer opinion files.
7 |
8 | The data/build.xml is used for building the contents of the data/languages directory.
9 |
10 | The skel language definition has been commented-out within the skel.ldefs file so that the
11 | skeleton language does not show-up within Ghidra.
12 |
13 | See the Sleigh language documentation (docs/languages/sleigh.htm or sleigh.pdf) for details
14 | on Sleigh language specification syntax.
15 |
16 |
--------------------------------------------------------------------------------
/data/languages/skel.pspec:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/src/main/help/help/topics/mclfloader/help.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
7 |
8 |
9 |
10 |
11 |
12 | Skeleton Help File for a Module
13 |
14 |
15 |
16 |
17 |
Skeleton Help File for a Module
18 |
19 |
This is a simple skeleton help topic. For a better description of what should and should not
20 | go in here, see the "sample" Ghidra extension in the Extensions/Ghidra directory, or see your
21 | favorite help topic. In general, language modules do not have their own help topics.
22 |
23 |
24 |
--------------------------------------------------------------------------------
/data/languages/skel.slaspec:
--------------------------------------------------------------------------------
1 | # sleigh specification file for Skeleton Processor
2 | # >> see docs/languages/sleigh.htm or sleigh.pdf for Sleigh syntax
3 | # Other language modules (see Ghidra/Processors) may provide better examples
4 | # when creating a new language module.
5 |
6 | define endian=little;
7 | define alignment=1;
8 |
9 | define space ram type=ram_space size=2 default;
10 |
11 | define space io type=ram_space size=2;
12 | define space register type=register_space size=1;
13 |
14 | define register offset=0x00 size=1 [ F A C B E D L H I R ];
15 | define register offset=0x00 size=2 [ AF BC DE HL ];
16 | define register offset=0x20 size=1 [ A_ F_ B_ C_ D_ E_ H_ L_ ]; # Alternate registers
17 | define register offset=0x20 size=2 [ AF_ BC_ DE_ HL_ ]; # Alternate registers
18 |
19 | define register offset=0x40 size=2 [ _ PC SP IX IY ];
20 |
21 | define register offset=0x50 size=1 [ rCBAR rCBR rBBR ];
22 |
23 | # Define context bits (if defined, size must be multiple of 4-bytes)
24 | define register offset=0xf0 size=4 contextreg;
25 |
26 | define context contextreg
27 | assume8bitIOSpace = (0,0)
28 | ;
29 |
30 | # Flag bits (?? manual is very confusing - could be typos!)
31 | @define C_flag "F[0,1]" # C: Carry
32 | @define N_flag "F[1,1]" # N: Add/Subtract
33 | @define PV_flag "F[2,1]" # PV: Parity/Overflow
34 | @define H_flag "F[4,1]" # H: Half Carry
35 | @define Z_flag "F[6,1]" # Z: Zero
36 | @define S_flag "F[7,1]" # S: Sign
37 |
38 | # Include contents of skel.sinc file
39 | @include "skel.sinc"
40 |
--------------------------------------------------------------------------------
/src/main/java/mclfloader/MCLFHeader.java:
--------------------------------------------------------------------------------
1 | package mclfloader;
2 |
3 | import java.io.IOException;
4 |
5 | import ghidra.app.util.bin.BinaryReader;
6 | import ghidra.app.util.bin.StructConverter;
7 | import ghidra.program.flatapi.FlatProgramAPI;
8 | import ghidra.program.model.address.Address;
9 | import ghidra.program.model.data.ArrayDataType;
10 | import ghidra.program.model.data.DataType;
11 | import ghidra.program.model.data.Structure;
12 | import ghidra.program.model.data.StructureDataType;
13 |
14 | public class MCLFHeader implements StructConverter {
15 | public String intro;
16 | public long version;
17 | public long flags;
18 | public long memType;
19 | public long serviceType;
20 | public long numInstances;
21 | public byte[] uuid;
22 | public long driverId;
23 | public long numThreads;
24 | public Address textVa;
25 | public long textLen;
26 | public Address dataVa;
27 | public long dataLen;
28 | public long bssLen;
29 | public Address entry;
30 | public long serviceVersion;
31 |
32 | public MCLFHeader(FlatProgramAPI api, BinaryReader reader) throws IOException {
33 | reader.setPointerIndex(0);
34 | intro = reader.readNextAsciiString(4);
35 | version = reader.readNextUnsignedInt();
36 | flags = reader.readNextUnsignedInt();
37 | memType = reader.readNextUnsignedInt();
38 | serviceType = reader.readNextUnsignedInt();
39 | numInstances = reader.readNextUnsignedInt();
40 | uuid = reader.readNextByteArray(16);
41 | driverId = reader.readNextUnsignedInt();
42 | numThreads = reader.readNextUnsignedInt();
43 | textVa = api.toAddr(reader.readNextUnsignedInt());
44 | textLen = reader.readNextUnsignedInt();
45 | dataVa = api.toAddr(reader.readNextUnsignedInt());
46 | dataLen = reader.readNextUnsignedInt();
47 | bssLen = reader.readNextUnsignedInt();
48 | entry = api.toAddr(reader.readNextUnsignedInt());
49 | serviceVersion = reader.readNextUnsignedInt();
50 | }
51 |
52 | @Override
53 | public DataType toDataType() {
54 | Structure struct = new StructureDataType("mclfHeader_t", 0);
55 | struct.add(ASCII, 4, "intro", null);
56 | struct.add(DWORD, 4, "version", null);
57 | struct.add(DWORD, 4, "flags", null);
58 | struct.add(DWORD, 4, "memType", null);
59 | struct.add(DWORD, 4, "serviceType", null);
60 | struct.add(DWORD, 4, "numInstances", null);
61 | struct.add(new ArrayDataType(BYTE, 16, 1), "uuid", null);
62 | struct.add(DWORD, 4, "driverId", null);
63 | struct.add(DWORD, 4, "numThreads", null);
64 | struct.add(POINTER, 4, "textVa", null);
65 | struct.add(DWORD, 4, "textLen", null);
66 | struct.add(POINTER, 4, "dataVa", null);
67 | struct.add(DWORD, 4, "dataLen", null);
68 | struct.add(DWORD, 4, "bssLen", null);
69 | struct.add(POINTER, 4, "entry", null);
70 | struct.add(DWORD, 4, "serviceVersion", null);
71 | return struct;
72 | }
73 | }
74 |
--------------------------------------------------------------------------------
/src/main/help/help/TOC_Source.xml:
--------------------------------------------------------------------------------
1 |
2 |
49 |
50 |
51 |
52 |
57 |
58 |
--------------------------------------------------------------------------------
/data/build.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
--------------------------------------------------------------------------------
/src/main/help/help/shared/Frontpage.css:
--------------------------------------------------------------------------------
1 | /* ###
2 | * IP: GHIDRA
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | /*
17 | WARNING!
18 | This file is copied to all help directories. If you change this file, you must copy it
19 | to each src/main/help/help/shared directory.
20 |
21 |
22 | Java Help Note: JavaHelp does not accept sizes (like in 'margin-top') in anything but
23 | px (pixel) or with no type marking.
24 |
25 | */
26 |
27 | body { margin-bottom: 50px; margin-left: 10px; margin-right: 10px; margin-top: 10px; } /* some padding to improve readability */
28 | li { font-family:times new roman; font-size:14pt; }
29 | h1 { color:#000080; font-family:times new roman; font-size:36pt; font-style:italic; font-weight:bold; text-align:center; }
30 | h2 { margin: 10px; margin-top: 20px; color:#984c4c; font-family:times new roman; font-size:18pt; font-weight:bold; }
31 | h3 { margin-left: 10px; margin-top: 20px; color:#0000ff; font-family:times new roman; font-size:14pt; font-weight:bold; }
32 | h4 { margin-left: 10px; margin-top: 20px; font-family:times new roman; font-size:14pt; font-style:italic; }
33 |
34 | /*
35 | P tag code. Most of the help files nest P tags inside of blockquote tags (the was the
36 | way it had been done in the beginning). The net effect is that the text is indented. In
37 | modern HTML we would use CSS to do this. We need to support the Ghidra P tags, nested in
38 | blockquote tags, as well as naked P tags. The following two lines accomplish this. Note
39 | that the 'blockquote p' definition will inherit from the first 'p' definition.
40 | */
41 | p { margin-left: 40px; font-family:times new roman; font-size:14pt; }
42 | blockquote p { margin-left: 10px; }
43 |
44 | p.providedbyplugin { color:#7f7f7f; margin-left: 10px; font-size:14pt; margin-top:100px }
45 | p.ProvidedByPlugin { color:#7f7f7f; margin-left: 10px; font-size:14pt; margin-top:100px }
46 | p.relatedtopic { color:#800080; margin-left: 10px; font-size:14pt; }
47 | p.RelatedTopic { color:#800080; margin-left: 10px; font-size:14pt; }
48 |
49 | /*
50 | We wish for a tables to have space between it and the preceding element, so that text
51 | is not too close to the top of the table. Also, nest the table a bit so that it is clear
52 | the table relates to the preceding text.
53 | */
54 | table { margin-left: 20px; margin-top: 10px; width: 80%;}
55 | td { font-family:times new roman; font-size:14pt; vertical-align: top; }
56 | th { font-family:times new roman; font-size:14pt; font-weight:bold; background-color: #EDF3FE; }
57 |
58 | code { color: black; font-family: courier new; font-size: 14pt; }
59 |
--------------------------------------------------------------------------------
/src/main/java/mclfloader/MCLFLoader.java:
--------------------------------------------------------------------------------
1 | package mclfloader;
2 |
3 | import java.io.IOException;
4 | import java.io.InputStream;
5 | import java.util.ArrayList;
6 | import java.util.Collection;
7 | import java.util.List;
8 |
9 | import ghidra.app.util.Option;
10 | import ghidra.app.util.bin.BinaryReader;
11 | import ghidra.app.util.bin.ByteProvider;
12 | import ghidra.app.util.importer.MessageLog;
13 | import ghidra.app.util.opinion.AbstractLibrarySupportLoader;
14 | import ghidra.app.util.opinion.LoadSpec;
15 | import ghidra.program.flatapi.FlatProgramAPI;
16 | import ghidra.program.model.address.Address;
17 | import ghidra.program.model.data.DataUtilities;
18 | import ghidra.program.model.data.DataUtilities.ClearDataMode;
19 | import ghidra.program.model.lang.LanguageCompilerSpecPair;
20 | import ghidra.program.model.listing.Program;
21 | import ghidra.program.model.mem.MemoryBlock;
22 | import ghidra.program.model.util.CodeUnitInsertionException;
23 | import ghidra.util.Msg;
24 | import ghidra.util.exception.CancelledException;
25 | import ghidra.util.task.TaskMonitor;
26 |
27 |
28 | public class MCLFLoader extends AbstractLibrarySupportLoader {
29 | public MCLFHeader header;
30 |
31 | @Override
32 | public String getName() {
33 | return "MobiCore Loadable Format (MCLF)";
34 | }
35 |
36 | @Override
37 | public Collection findSupportedLoadSpecs(ByteProvider provider) throws IOException {
38 | BinaryReader reader = new BinaryReader(provider, true);
39 | if (reader.readNextAsciiString(4).equals("MCLF"))
40 | return List.of(new LoadSpec(this, 0, new LanguageCompilerSpecPair("ARM:LE:32:v7", "default"), true));
41 | return new ArrayList<>();
42 | }
43 |
44 | @Override
45 | protected void load(ByteProvider provider, LoadSpec loadSpec, List