diff --git a/src/main/java/ntrghidra/ARM9.java b/src/main/java/ntrghidra/ARM9.java index 1af86fd..99567fe 100644 --- a/src/main/java/ntrghidra/ARM9.java +++ b/src/main/java/ntrghidra/ARM9.java @@ -1,3 +1,14 @@ +/* +* ARM9.java +* This class contains code to locate in memory and +* work with the ARM9 part of a game's binary. +* +* Pedro Javier Fernández +* 12/06/2022 (DD/MM/YYYY) +* +* See project license file for license information. +*/ + package ntrghidra; import java.util.ArrayList; @@ -9,13 +20,10 @@ public class ARM9 { private int RamAddress; - private byte[] StaticData; - private int _start_ModuleParamsOffset; private CRT0.ModuleParams _start_ModuleParams; - - private List AutoLoadList; + private List AutoLoadList; // AutoLoad is a TODO feature still. public ARM9(byte[] Data, int RamAddress) { @@ -72,7 +80,6 @@ public ARM9(byte[] Data, int RamAddress, int _start_ModuleParamsOffset) } } - public void AddAutoLoadEntry(int Address, byte[] Data) { CRT0 a = new CRT0(); diff --git a/src/main/java/ntrghidra/CRT0.java b/src/main/java/ntrghidra/CRT0.java index 9a03d0e..bd86c0a 100644 --- a/src/main/java/ntrghidra/CRT0.java +++ b/src/main/java/ntrghidra/CRT0.java @@ -1,3 +1,16 @@ +/* +* CRT0.java +* CRT0 is one of the first initialization routines/code +* that is present in NDS games. This class contains method +* to work with game information that is compressed and +* decompress it. +* +* Pedro Javier Fernández +* 12/06/2022 (DD/MM/YYYY) +* +* See project license file for license information. +*/ + package ntrghidra; import java.io.DataOutputStream; diff --git a/src/main/java/ntrghidra/DSILabelList.java b/src/main/java/ntrghidra/DSILabelList.java index 166324d..166d192 100644 --- a/src/main/java/ntrghidra/DSILabelList.java +++ b/src/main/java/ntrghidra/DSILabelList.java @@ -1,3 +1,15 @@ +/* +* DSILabelList.java +* Definition of DSILabel class which represents registers +* and other important addresses in memory exclusive to the +* DSi console. Also includes a list of these memory regions. +* +* Pedro Javier Fernández +* 12/06/2022 (DD/MM/YYYY) +* +* See project license file for license information. +*/ + package ntrghidra; import java.util.ArrayList; @@ -5,7 +17,6 @@ public class DSILabelList { - //This internal class represents a location of interest (registers, i/o, etc) public class DSILabel { String name; @@ -117,7 +128,7 @@ private DSILabelList() - + /*ARM7*/ @@ -162,7 +173,6 @@ private DSILabelList() _ARM7labels.add(new DSILabel("REG_POWCNT2", 0x4000304)); _ARM7labels.add(new DSILabel("REG_BIOSPROT", 0x4000308)); - //ARM7 Sound Registers (NOTE: sound channle specific registers missing) _ARM7labels.add(new DSILabel("Sound_Channels_0_to_15", 0x4000400)); //... @@ -175,7 +185,6 @@ private DSILabelList() _ARM7labels.add(new DSILabel("REG_SNDCAP1DAD", 0x4000518)); _ARM7labels.add(new DSILabel("REG_SNDCAP1LEN", 0x400051C)); - //ARM7 DSi Extra Registers //not included @@ -190,7 +199,6 @@ private DSILabelList() _ARM7labels.add(new DSILabel("Wifi_WS0_Region", 0x4800000)); _ARM7labels.add(new DSILabel("Wifi_WS1_Region", 0x4808000)); - //ARM7 Hardcoded RAM Addresses for Exception Handling _ARM7labels.add(new DSILabel("DSi7_IRQ_IF2_Check_Bits_DSi_only)", 0x380FFC0)); _ARM7labels.add(new DSILabel("NDS7_Debug_Stacktop_Debug_Vector", 0x380FFDC)); @@ -199,6 +207,7 @@ private DSILabelList() } + // Singleton pattern public static DSILabelList getInstance() { if(_instance==null) diff --git a/src/main/java/ntrghidra/DSIMemRegionList.java b/src/main/java/ntrghidra/DSIMemRegionList.java index 4bc8c15..c179d7d 100644 --- a/src/main/java/ntrghidra/DSIMemRegionList.java +++ b/src/main/java/ntrghidra/DSIMemRegionList.java @@ -1,3 +1,15 @@ +/* +* NDSIMemRegionList.java +* Definition of DSIMemRegionList class and +* list of these memory regions. These are +* DSi only memory regions !!! +* +* Pedro Javier Fernández +* 12/06/2022 (DD/MM/YYYY) +* +* See project license file for license information. +*/ + package ntrghidra; import java.util.ArrayList; @@ -28,7 +40,6 @@ public DSIMemRegion(String name, int addr, int size, boolean read, boolean write public boolean write() {return write;} public boolean execute() {return execute;} } - //This class uses a singleton pattern private static DSIMemRegionList _instance = null; diff --git a/src/main/java/ntrghidra/IOUtil.java b/src/main/java/ntrghidra/IOUtil.java index 1705169..65e58fb 100644 --- a/src/main/java/ntrghidra/IOUtil.java +++ b/src/main/java/ntrghidra/IOUtil.java @@ -1,3 +1,13 @@ +/* +* IOUtil.java +* Helper methods to manipulate bytes +* +* Pedro Javier Fernández +* 12/06/2022 (DD/MM/YYYY) +* +* See project license file for license information. +*/ + package ntrghidra; import java.nio.ByteBuffer; diff --git a/src/main/java/ntrghidra/NDS.java b/src/main/java/ntrghidra/NDS.java index 109f853..d64cc21 100644 --- a/src/main/java/ntrghidra/NDS.java +++ b/src/main/java/ntrghidra/NDS.java @@ -1,3 +1,13 @@ +/* +* NDS.java +* Definition of the NDS binary format +* +* Pedro Javier Fernández +* 12/06/2022 (DD/MM/YYYY) +* +* See project license file for license information. +*/ + package ntrghidra; import java.io.IOException; diff --git a/src/main/java/ntrghidra/NDSLabelList.java b/src/main/java/ntrghidra/NDSLabelList.java index 41a1f7b..81b1c7e 100644 --- a/src/main/java/ntrghidra/NDSLabelList.java +++ b/src/main/java/ntrghidra/NDSLabelList.java @@ -1,3 +1,15 @@ +/* +* NDSLabelList.java +* Definition of NDSLabel class which represents registers +* and other important addresses in memory. Also includes +* a list of these memory regions. +* +* Pedro Javier Fernández +* 12/06/2022 (DD/MM/YYYY) +* +* See project license file for license information. +*/ + package ntrghidra; import java.util.ArrayList; diff --git a/src/main/java/ntrghidra/NDSMemRegionList.java b/src/main/java/ntrghidra/NDSMemRegionList.java index 77e3d46..81ae4ba 100644 --- a/src/main/java/ntrghidra/NDSMemRegionList.java +++ b/src/main/java/ntrghidra/NDSMemRegionList.java @@ -1,3 +1,14 @@ +/* +* NDSMemRegionList.java +* Definition of NDSMemRegionList class and +* list of these memory regions. +* +* Pedro Javier Fernández +* 12/06/2022 (DD/MM/YYYY) +* +* See project license file for license information. +*/ + package ntrghidra; import java.util.ArrayList; diff --git a/src/main/java/ntrghidra/NTRGhidraLoader.java b/src/main/java/ntrghidra/NTRGhidraLoader.java index 9d695ad..2d5b5e3 100644 --- a/src/main/java/ntrghidra/NTRGhidraLoader.java +++ b/src/main/java/ntrghidra/NTRGhidraLoader.java @@ -13,13 +13,26 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + +/* +* NTRGhidraLoader.java +* Main plugin file and entrypoint code. +* +* Pedro Javier Fernández +* 12/06/2022 (DD/MM/YYYY) +* +* See project license file for license information. +*/ + package ntrghidra; +// Java standard utilities import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; import java.util.*; +// Ghidra Imports: IMPORTANT, these may change with Ghidra updates import docking.widgets.OptionDialog; import ghidra.app.util.Option; import ghidra.app.util.bin.BinaryReader; @@ -43,7 +56,7 @@ import static ghidra.app.util.MemoryBlockUtils.createInitializedBlock; /** - * TODO: Provide class-level documentation that describes what this loader does. + * Main entrypoint class */ public class NTRGhidraLoader extends AbstractLibrarySupportLoader { @@ -53,9 +66,6 @@ public class NTRGhidraLoader extends AbstractLibrarySupportLoader { @Override public String getName() { - - // TODO: Name the loader. This name must match the name of the loader in the .opinion - // files. return "Nintendo DS (NTR) and DSi (TWL)"; } @@ -103,7 +113,8 @@ protected boolean promptToAskSDK() { @Override public Collection findSupportedLoadSpecs(ByteProvider provider) throws IOException { - // In this callback loader should decide whether it able to process the file and return instance of the class LoadSpec, telling user how file can be processed*/ + // In this callback loader should decide whether it able to process the file and return instance of the class LoadSpec, + // telling user how file can be processed BinaryReader reader = new BinaryReader(provider, true); @@ -162,7 +173,6 @@ void loadARM9Overlays(ByteProvider provider, Program program, NDS romparser, Mes } } - //ARM7 has support for overlays as well, even compressed, but they have never been used in comercial games. void loadARM7Overlays(ByteProvider provider, Program program, NDS romparser, MessageLog log, FlatProgramAPI fpa, TaskMonitor monitor) throws IOException, AddressOverflowException{ BinaryReader reader = new BinaryReader(provider, true); @@ -179,7 +189,6 @@ void loadARM7Overlays(ByteProvider provider, Program program, NDS romparser, Mes } } - @Override protected void load(ByteProvider provider, LoadSpec loadSpec, List