I would like to call the DisassemblePPCRange() function via RPC. You can see the documentation by of it here. Disassembling so far requires platform dependent binaries to be possible in TCP Gecko clients so it is a pain to support Windows, Linux and Mac OS X. Getting DisassemblePPCRange() to work would make the powerpc-eabi binaries redundant since we can let the Wii U disassemble everything for us
So far I "almost" got DisassemblePPCRange() working but I'm not sure about how exactly to call it. I got the DisassemblePPCOpcode() function working already but it only does one instruction at a time which is way too slow to apply to an entire range:
Now the non-functional RPC implementation of DisassemblePPCRange():
Any help or tips on how to fix the above code would be appreciated. If you can do the same in PyGecko then let me know because that's good enough for me.
@QuarkTheAwesome
So far I "almost" got DisassemblePPCRange() working but I'm not sure about how exactly to call it. I got the DisassemblePPCOpcode() function working already but it only does one instruction at a time which is way too slow to apply to an entire range:
Code:
public static String disassembleValue(int value) throws IOException
{
try (AllocatedMemory allocatedMemory = new AllocatedMemory(4, 4))
{
int address = allocatedMemory.getAddress();
// Write the value into the allocated memory address
MemoryWriter memoryWriter = new MemoryWriter();
memoryWriter.writeInt(address, value);
// Disassemble and return the result
return disassembleAddress(address);
}
}
public static String disassembleAddress(int address) throws IOException
{
int instructionBufferLength = 0x40;
try (FindSymbol findSymbol = new FindSymbol();
AllocatedMemory instructionBuffer = new AllocatedMemory(instructionBufferLength, 0x20))
{
RemoteProcedureCall remoteProcedureCall = new RemoteProcedureCall();
ExportedSymbol exportedSymbol = remoteProcedureCall.getSymbol("coreinit.rpl", "DisassemblePPCOpcode");
remoteProcedureCall.call(exportedSymbol,
address,
instructionBuffer.getAddress(),
instructionBufferLength,
findSymbol.getAddress(),
0);
// Read the output buffer's contents
MemoryReader memoryReader = new MemoryReader();
byte[] disassembledBytes = memoryReader.readBytes(instructionBuffer.getAddress(), instructionBufferLength);
// Clean up the disassembled String
String disassembled = new String(disassembledBytes);
disassembled = disassembled.replaceAll("\\(null\\)", " ");
disassembled = disassembled.replaceAll("\\s+", " ");
disassembled = disassembled.trim();
return disassembled;
}
}
Code:
// TODO Non-functional yet
public static String disassembleRange(int start, int length) throws IOException
{
int end = start + length;
try (FindSymbol findSymbol = new FindSymbol();
RemoteString printingFunction = new RemoteString("%s"))
{
RemoteProcedureCall remoteProcedureCall = new RemoteProcedureCall();
ExportedSymbol exportedSymbol = remoteProcedureCall.getSymbol("coreinit.rpl", "DisassemblePPCRange");
remoteProcedureCall.call(exportedSymbol, start, end,
printingFunction.getAddress(), findSymbol.getAddress(), 0); // Crashes here
MemoryReader memoryReader = new MemoryReader();
byte[] disassembledBytes = memoryReader.readBytes(printingFunction.getAddress(), length);
String disassembled = new String(disassembledBytes);
disassembledBytes = memoryReader.readBytes(findSymbol.getAddress(), length);
String disassembled2 = new String(disassembledBytes);
return disassembled;
}
}
@QuarkTheAwesome