mirror of
https://github.com/wiiu-env/gdbstub_plugin.git
synced 2024-11-26 05:24:22 +01:00
clang-format
This commit is contained in:
parent
8e2a431827
commit
4993b321ce
@ -1,8 +1,8 @@
|
|||||||
|
|
||||||
#include "cafe/coreinit.h"
|
#include "cafe/coreinit.h"
|
||||||
#include "hbl.h"
|
#include "hbl.h"
|
||||||
#include <cstdint>
|
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
int (*OSDynLoad_Acquire)(const char *name, uint32_t *handle);
|
int (*OSDynLoad_Acquire)(const char *name, uint32_t *handle);
|
||||||
int (*OSDynLoad_FindExport)(uint32_t handle, bool isData, const char *name, void *ptr);
|
int (*OSDynLoad_FindExport)(uint32_t handle, bool isData, const char *name, void *ptr);
|
||||||
@ -124,8 +124,8 @@ OSDynLoad_RPLInfo **pFirstRPL;
|
|||||||
OSThread **pThreadList;
|
OSThread **pThreadList;
|
||||||
|
|
||||||
void coreinitInitialize() {
|
void coreinitInitialize() {
|
||||||
*(uint32_t *)&OSDynLoad_Acquire = OS_SPECIFICS->OSDynLoad_Acquire;
|
*(uint32_t *) &OSDynLoad_Acquire = OS_SPECIFICS->OSDynLoad_Acquire;
|
||||||
*(uint32_t *)&OSDynLoad_FindExport = OS_SPECIFICS->OSDynLoad_FindExport;
|
*(uint32_t *) &OSDynLoad_FindExport = OS_SPECIFICS->OSDynLoad_FindExport;
|
||||||
|
|
||||||
uint32_t handle;
|
uint32_t handle;
|
||||||
OSDynLoad_Acquire("coreinit.rpl", &handle);
|
OSDynLoad_Acquire("coreinit.rpl", &handle);
|
||||||
@ -242,7 +242,7 @@ void coreinitInitialize() {
|
|||||||
OSDynLoad_FindExport(handle, true, "MEMAllocFromDefaultHeapEx", &pMEMAllocFromDefaultHeapEx);
|
OSDynLoad_FindExport(handle, true, "MEMAllocFromDefaultHeapEx", &pMEMAllocFromDefaultHeapEx);
|
||||||
OSDynLoad_FindExport(handle, true, "MEMFreeToDefaultHeap", &pMEMFreeToDefaultHeap);
|
OSDynLoad_FindExport(handle, true, "MEMFreeToDefaultHeap", &pMEMFreeToDefaultHeap);
|
||||||
|
|
||||||
pMainRPL = (OSDynLoad_RPLInfo **)0x10081014;
|
pMainRPL = (OSDynLoad_RPLInfo **) 0x10081014;
|
||||||
pFirstRPL = (OSDynLoad_RPLInfo **)0x10081018;
|
pFirstRPL = (OSDynLoad_RPLInfo **) 0x10081018;
|
||||||
pThreadList = (OSThread **)0x100567F8;
|
pThreadList = (OSThread **) 0x100567F8;
|
||||||
}
|
}
|
||||||
|
@ -1,17 +1,17 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <cstdint>
|
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
// Timers
|
// Timers
|
||||||
#define OSTimerClockSpeed ((OSGetSystemInfo()->busClockSpeed) / 4)
|
#define OSTimerClockSpeed ((OSGetSystemInfo()->busClockSpeed) / 4)
|
||||||
|
|
||||||
#define OSSecondsToTicks(val) ((uint64_t)(val) * (uint64_t)OSTimerClockSpeed)
|
#define OSSecondsToTicks(val) ((uint64_t) (val) * (uint64_t) OSTimerClockSpeed)
|
||||||
#define OSMillisecondsToTicks(val) (((uint64_t)(val) * (uint64_t)OSTimerClockSpeed) / 1000ull)
|
#define OSMillisecondsToTicks(val) (((uint64_t) (val) * (uint64_t) OSTimerClockSpeed) / 1000ull)
|
||||||
|
|
||||||
#define OSTicksToSeconds(val) ((uint64_t)(val) / (uint64_t)OSTimerClockSpeed)
|
#define OSTicksToSeconds(val) ((uint64_t) (val) / (uint64_t) OSTimerClockSpeed)
|
||||||
#define OSTicksToMilliseconds(val) (((uint64_t)(val) * 1000ull) / (uint64_t)OSTimerClockSpeed)
|
#define OSTicksToMilliseconds(val) (((uint64_t) (val) *1000ull) / (uint64_t) OSTimerClockSpeed)
|
||||||
|
|
||||||
// Memory
|
// Memory
|
||||||
enum OSMemoryType {
|
enum OSMemoryType {
|
||||||
@ -226,7 +226,6 @@ struct OSThread {
|
|||||||
const char *name;
|
const char *name;
|
||||||
|
|
||||||
char _5C4[0x6A0 - 0x5C4];
|
char _5C4[0x6A0 - 0x5C4];
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Messages
|
// Messages
|
||||||
|
@ -7,7 +7,7 @@ namespace nn::act {
|
|||||||
uint8_t (*GetSlotNo)();
|
uint8_t (*GetSlotNo)();
|
||||||
uint32_t (*GetPersistentIdEx)(uint8_t slot);
|
uint32_t (*GetPersistentIdEx)(uint8_t slot);
|
||||||
uint32_t (*Finalize)();
|
uint32_t (*Finalize)();
|
||||||
}
|
} // namespace nn::act
|
||||||
|
|
||||||
void nnactInitialize() {
|
void nnactInitialize() {
|
||||||
uint32_t handle;
|
uint32_t handle;
|
||||||
|
@ -6,6 +6,6 @@ namespace nn::act {
|
|||||||
extern uint8_t (*GetSlotNo)();
|
extern uint8_t (*GetSlotNo)();
|
||||||
extern uint32_t (*GetPersistentIdEx)(uint8_t slot);
|
extern uint32_t (*GetPersistentIdEx)(uint8_t slot);
|
||||||
extern uint32_t (*Finalize)();
|
extern uint32_t (*Finalize)();
|
||||||
}
|
} // namespace nn::act
|
||||||
|
|
||||||
void nnactInitialize();
|
void nnactInitialize();
|
||||||
|
151
src/debugger.cpp
151
src/debugger.cpp
@ -6,8 +6,8 @@
|
|||||||
|
|
||||||
#include "debugger.h"
|
#include "debugger.h"
|
||||||
#include "exceptions.h"
|
#include "exceptions.h"
|
||||||
#include "screen.h"
|
|
||||||
#include "input.h"
|
#include "input.h"
|
||||||
|
#include "screen.h"
|
||||||
|
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
|
||||||
@ -66,8 +66,7 @@ bool BreakPointMgr::isSoftware(uint32_t addr) {
|
|||||||
uint32_t opcode = instr >> 26;
|
uint32_t opcode = instr >> 26;
|
||||||
if (opcode == 3) { //twi
|
if (opcode == 3) { //twi
|
||||||
return true;
|
return true;
|
||||||
}
|
} else if (opcode == 31) {
|
||||||
else if (opcode == 31) {
|
|
||||||
return (instr & 0x7FF) == 8; //tw
|
return (instr & 0x7FF) == 8; //tw
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@ -88,9 +87,8 @@ void BreakPointMgr::enable(BreakPoint *bp, uint32_t addr) {
|
|||||||
BreakPoint *other = find(addr, true);
|
BreakPoint *other = find(addr, true);
|
||||||
if (other) {
|
if (other) {
|
||||||
bp->instruction = other->instruction;
|
bp->instruction = other->instruction;
|
||||||
}
|
} else {
|
||||||
else {
|
bp->instruction = *(uint32_t *) addr;
|
||||||
bp->instruction = *(uint32_t *)addr;
|
|
||||||
KernelWriteU32(addr, TRAP);
|
KernelWriteU32(addr, TRAP);
|
||||||
}
|
}
|
||||||
bp->address = addr;
|
bp->address = addr;
|
||||||
@ -118,22 +116,21 @@ void BreakPointMgr::cleanup() {
|
|||||||
void BreakPointMgr::read(void *buffer, uint32_t addr, uint32_t length) {
|
void BreakPointMgr::read(void *buffer, uint32_t addr, uint32_t length) {
|
||||||
lock();
|
lock();
|
||||||
|
|
||||||
memcpy(buffer, (void *)addr, length);
|
memcpy(buffer, (void *) addr, length);
|
||||||
|
|
||||||
int index = 0;
|
int index = 0;
|
||||||
BreakPoint *bp = findRange(addr, length, &index, true);
|
BreakPoint *bp = findRange(addr, length, &index, true);
|
||||||
while (bp) {
|
while (bp) {
|
||||||
uint32_t offset = bp->address - addr;
|
uint32_t offset = bp->address - addr;
|
||||||
char *bufptr = (char *)buffer + offset;
|
char *bufptr = (char *) buffer + offset;
|
||||||
if (bp->address > addr + length - 4) {
|
if (bp->address > addr + length - 4) {
|
||||||
uint32_t value = bp->instruction;
|
uint32_t value = bp->instruction;
|
||||||
for (int i = 0; i < length - offset; i++) {
|
for (int i = 0; i < length - offset; i++) {
|
||||||
bufptr[i] = value >> 24;
|
bufptr[i] = value >> 24;
|
||||||
value <<= 8;
|
value <<= 8;
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
*(uint32_t *) bufptr = bp->instruction;
|
||||||
*(uint32_t *)bufptr = bp->instruction;
|
|
||||||
}
|
}
|
||||||
bp = findRange(addr, length, &index, true);
|
bp = findRange(addr, length, &index, true);
|
||||||
}
|
}
|
||||||
@ -148,17 +145,15 @@ void BreakPointMgr::write(const void *buffer, uint32_t addr, uint32_t length) {
|
|||||||
int index = 0;
|
int index = 0;
|
||||||
if (!findRange(addr, length, &index, true)) {
|
if (!findRange(addr, length, &index, true)) {
|
||||||
KernelWrite(addr, buffer, length);
|
KernelWrite(addr, buffer, length);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
for (uint32_t i = 0; i < length; i += 4) {
|
for (uint32_t i = 0; i < length; i += 4) {
|
||||||
uint32_t value = *(uint32_t *)((char *)buffer + i);
|
uint32_t value = *(uint32_t *) ((char *) buffer + i);
|
||||||
|
|
||||||
int index = 0;
|
int index = 0;
|
||||||
BreakPoint *bp = findRange(addr + i, 4, &index, true);
|
BreakPoint *bp = findRange(addr + i, 4, &index, true);
|
||||||
if (!bp) {
|
if (!bp) {
|
||||||
KernelWriteU32(addr + i, value);
|
KernelWriteU32(addr + i, value);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
while (bp) {
|
while (bp) {
|
||||||
bp->instruction = value;
|
bp->instruction = value;
|
||||||
bp = findRange(addr + i, 4, &index, true);
|
bp = findRange(addr + i, 4, &index, true);
|
||||||
@ -176,8 +171,7 @@ void BreakPointMgr::toggle(uint32_t addr) {
|
|||||||
BreakPoint *bp = find(addr, false);
|
BreakPoint *bp = find(addr, false);
|
||||||
if (bp) {
|
if (bp) {
|
||||||
disable(bp);
|
disable(bp);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
BreakPoint *bp = breakpoints.alloc();
|
BreakPoint *bp = breakpoints.alloc();
|
||||||
bp->isSpecial = false;
|
bp->isSpecial = false;
|
||||||
enable(bp, addr);
|
enable(bp, addr);
|
||||||
@ -192,9 +186,8 @@ uint32_t BreakPointMgr::getInstr(uint32_t addr) {
|
|||||||
BreakPoint *bp = find(addr, true);
|
BreakPoint *bp = find(addr, true);
|
||||||
if (bp) {
|
if (bp) {
|
||||||
instruction = bp->instruction;
|
instruction = bp->instruction;
|
||||||
}
|
} else {
|
||||||
else {
|
instruction = *(uint32_t *) addr;
|
||||||
instruction = *(uint32_t *)addr;
|
|
||||||
}
|
}
|
||||||
unlock();
|
unlock();
|
||||||
return instruction;
|
return instruction;
|
||||||
@ -257,7 +250,8 @@ void BreakPointMgr::predictStep(ExceptionState *state, bool stepOver) {
|
|||||||
|
|
||||||
if (!LK || !stepOver) {
|
if (!LK || !stepOver) {
|
||||||
if (XO == 16) target2 = state->context.lr;
|
if (XO == 16) target2 = state->context.lr;
|
||||||
else if (XO == 528) target2 = state->context.ctr;
|
else if (XO == 528)
|
||||||
|
target2 = state->context.ctr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -449,8 +443,7 @@ void StepMgr::singleStep(ExceptionState *state, uint32_t instruction) {
|
|||||||
if (XO == 16) {
|
if (XO == 16) {
|
||||||
branchConditional(state, instruction, state->context.lr, true);
|
branchConditional(state, instruction, state->context.lr, true);
|
||||||
return;
|
return;
|
||||||
}
|
} else if (XO == 528) {
|
||||||
else if (XO == 528) {
|
|
||||||
branchConditional(state, instruction, state->context.ctr, false);
|
branchConditional(state, instruction, state->context.ctr, false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -462,12 +455,12 @@ void StepMgr::singleStep(ExceptionState *state, uint32_t instruction) {
|
|||||||
ptr[2] = state->context.srr0;
|
ptr[2] = state->context.srr0;
|
||||||
DCFlushRange(ptr, 12);
|
DCFlushRange(ptr, 12);
|
||||||
ICInvalidateRange(ptr, 12);
|
ICInvalidateRange(ptr, 12);
|
||||||
state->context.srr0 = (uint32_t)ptr;
|
state->context.srr0 = (uint32_t) ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void StepMgr::handleBreakPoint(ExceptionState *state) {
|
void StepMgr::handleBreakPoint(ExceptionState *state) {
|
||||||
uint32_t start = (uint32_t)buffer;
|
uint32_t start = (uint32_t) buffer;
|
||||||
uint32_t end = (uint32_t)buffer + sizeof(buffer);
|
uint32_t end = (uint32_t) buffer + sizeof(buffer);
|
||||||
|
|
||||||
uint32_t addr = state->context.srr0;
|
uint32_t addr = state->context.srr0;
|
||||||
if (addr >= start && addr < end) {
|
if (addr >= start && addr < end) {
|
||||||
@ -487,8 +480,8 @@ void StepMgr::handleBreakPoint(ExceptionState *state) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void StepMgr::adjustAddress(ExceptionState *state) {
|
void StepMgr::adjustAddress(ExceptionState *state) {
|
||||||
uint32_t start = (uint32_t)buffer;
|
uint32_t start = (uint32_t) buffer;
|
||||||
uint32_t end = (uint32_t)buffer + sizeof(buffer);
|
uint32_t end = (uint32_t) buffer + sizeof(buffer);
|
||||||
|
|
||||||
uint32_t addr = state->context.srr0;
|
uint32_t addr = state->context.srr0;
|
||||||
if (addr >= start && addr < end) {
|
if (addr >= start && addr < end) {
|
||||||
@ -510,15 +503,15 @@ bool Debugger::checkDataRead(uint32_t addr, uint32_t length) {
|
|||||||
Debugger::StepCommand Debugger::notifyBreak(ExceptionState *state) {
|
Debugger::StepCommand Debugger::notifyBreak(ExceptionState *state) {
|
||||||
OSMessage message;
|
OSMessage message;
|
||||||
message.message = ExceptionState::PROGRAM;
|
message.message = ExceptionState::PROGRAM;
|
||||||
message.args[0] = (uint32_t)&state->context;
|
message.args[0] = (uint32_t) &state->context;
|
||||||
message.args[1] = sizeof(OSContext);
|
message.args[1] = sizeof(OSContext);
|
||||||
message.args[2] = (uint32_t)state->thread;
|
message.args[2] = (uint32_t) state->thread;
|
||||||
OSSendMessage(&eventQueue, &message, OS_MESSAGE_FLAGS_BLOCKING);
|
OSSendMessage(&eventQueue, &message, OS_MESSAGE_FLAGS_BLOCKING);
|
||||||
|
|
||||||
state->isPaused = true;
|
state->isPaused = true;
|
||||||
OSReceiveMessage(&state->queue, &message, OS_MESSAGE_FLAGS_BLOCKING);
|
OSReceiveMessage(&state->queue, &message, OS_MESSAGE_FLAGS_BLOCKING);
|
||||||
state->isPaused = false;
|
state->isPaused = false;
|
||||||
return (StepCommand)message.message;
|
return (StepCommand) message.message;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Debugger::resumeBreakPoint(ExceptionState *state) {
|
void Debugger::resumeBreakPoint(ExceptionState *state) {
|
||||||
@ -549,8 +542,7 @@ void Debugger::handleBreakPoint(ExceptionState *state) {
|
|||||||
screen.drawText(
|
screen.drawText(
|
||||||
0, 0, "Waiting for debugger connection.\n"
|
0, 0, "Waiting for debugger connection.\n"
|
||||||
"Press the home button to continue without debugger.\n"
|
"Press the home button to continue without debugger.\n"
|
||||||
"You can still connect while the game is running."
|
"You can still connect while the game is running.");
|
||||||
);
|
|
||||||
screen.flip();
|
screen.flip();
|
||||||
|
|
||||||
while (!connected) {
|
while (!connected) {
|
||||||
@ -588,16 +580,15 @@ void Debugger::handleCrash(ExceptionState *state) {
|
|||||||
if (connected) {
|
if (connected) {
|
||||||
OSMessage message;
|
OSMessage message;
|
||||||
message.message = state->type;
|
message.message = state->type;
|
||||||
message.args[0] = (uint32_t)&state->context;
|
message.args[0] = (uint32_t) &state->context;
|
||||||
message.args[1] = sizeof(OSContext);
|
message.args[1] = sizeof(OSContext);
|
||||||
message.args[2] = (uint32_t)state->thread;
|
message.args[2] = (uint32_t) state->thread;
|
||||||
OSSendMessage(&eventQueue, &message, OS_MESSAGE_FLAGS_BLOCKING);
|
OSSendMessage(&eventQueue, &message, OS_MESSAGE_FLAGS_BLOCKING);
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
OSReceiveMessage(&state->queue, &message, OS_MESSAGE_FLAGS_BLOCKING);
|
OSReceiveMessage(&state->queue, &message, OS_MESSAGE_FLAGS_BLOCKING);
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
handleFatalCrash(&state->context, state->type);
|
handleFatalCrash(&state->context, state->type);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -605,7 +596,8 @@ void Debugger::handleCrash(ExceptionState *state) {
|
|||||||
void Debugger::handleFatalCrash(OSContext *context, ExceptionState::Type type) {
|
void Debugger::handleFatalCrash(OSContext *context, ExceptionState::Type type) {
|
||||||
const char *name;
|
const char *name;
|
||||||
if (type == ExceptionState::DSI) name = "A DSI";
|
if (type == ExceptionState::DSI) name = "A DSI";
|
||||||
else if (type == ExceptionState::ISI) name = "An ISI";
|
else if (type == ExceptionState::ISI)
|
||||||
|
name = "An ISI";
|
||||||
else {
|
else {
|
||||||
name = "A program";
|
name = "A program";
|
||||||
}
|
}
|
||||||
@ -627,8 +619,7 @@ void Debugger::handleException(OSContext *context, ExceptionState::Type type) {
|
|||||||
|
|
||||||
if (state->isBreakpoint()) {
|
if (state->isBreakpoint()) {
|
||||||
handleBreakPoint(state);
|
handleBreakPoint(state);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
handleCrash(state);
|
handleCrash(state);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -640,8 +631,8 @@ void Debugger::exceptionHandler(OSContext *context, ExceptionState::Type type) {
|
|||||||
bool Debugger::dsiHandler(OSContext *context) {
|
bool Debugger::dsiHandler(OSContext *context) {
|
||||||
OSContext *info = new OSContext();
|
OSContext *info = new OSContext();
|
||||||
memcpy(info, context, sizeof(OSContext));
|
memcpy(info, context, sizeof(OSContext));
|
||||||
context->srr0 = (uint32_t)exceptionHandler;
|
context->srr0 = (uint32_t) exceptionHandler;
|
||||||
context->gpr[3] = (uint32_t)info;
|
context->gpr[3] = (uint32_t) info;
|
||||||
context->gpr[4] = ExceptionState::DSI;
|
context->gpr[4] = ExceptionState::DSI;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -649,8 +640,8 @@ bool Debugger::dsiHandler(OSContext *context) {
|
|||||||
bool Debugger::isiHandler(OSContext *context) {
|
bool Debugger::isiHandler(OSContext *context) {
|
||||||
OSContext *info = new OSContext();
|
OSContext *info = new OSContext();
|
||||||
memcpy(info, context, sizeof(OSContext));
|
memcpy(info, context, sizeof(OSContext));
|
||||||
context->srr0 = (uint32_t)exceptionHandler;
|
context->srr0 = (uint32_t) exceptionHandler;
|
||||||
context->gpr[3] = (uint32_t)info;
|
context->gpr[3] = (uint32_t) info;
|
||||||
context->gpr[4] = ExceptionState::ISI;
|
context->gpr[4] = ExceptionState::ISI;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -658,8 +649,8 @@ bool Debugger::isiHandler(OSContext *context) {
|
|||||||
bool Debugger::programHandler(OSContext *context) {
|
bool Debugger::programHandler(OSContext *context) {
|
||||||
OSContext *info = new OSContext();
|
OSContext *info = new OSContext();
|
||||||
memcpy(info, context, sizeof(OSContext));
|
memcpy(info, context, sizeof(OSContext));
|
||||||
context->srr0 = (uint32_t)exceptionHandler;
|
context->srr0 = (uint32_t) exceptionHandler;
|
||||||
context->gpr[3] = (uint32_t)info;
|
context->gpr[3] = (uint32_t) info;
|
||||||
context->gpr[4] = ExceptionState::PROGRAM;
|
context->gpr[4] = ExceptionState::PROGRAM;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -669,7 +660,8 @@ void Debugger::cleanup() {
|
|||||||
exceptions.cleanup();
|
exceptions.cleanup();
|
||||||
|
|
||||||
OSMessage message;
|
OSMessage message;
|
||||||
while (OSReceiveMessage(&eventQueue, &message, OS_MESSAGE_FLAGS_NONE));
|
while (OSReceiveMessage(&eventQueue, &message, OS_MESSAGE_FLAGS_NONE))
|
||||||
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Debugger::mainLoop(Client *client) {
|
void Debugger::mainLoop(Client *client) {
|
||||||
@ -690,14 +682,12 @@ void Debugger::mainLoop(Client *client) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
delete buffer;
|
delete buffer;
|
||||||
}
|
} else if (cmd == COMMAND_WRITE) {
|
||||||
else if (cmd == COMMAND_WRITE) {
|
|
||||||
uint32_t addr, length;
|
uint32_t addr, length;
|
||||||
if (!client->recvall(&addr, 4)) return;
|
if (!client->recvall(&addr, 4)) return;
|
||||||
if (!client->recvall(&length, 4)) return;
|
if (!client->recvall(&length, 4)) return;
|
||||||
if (!client->recvall((void *)addr, length)) return;
|
if (!client->recvall((void *) addr, length)) return;
|
||||||
}
|
} else if (cmd == COMMAND_WRITE_CODE) {
|
||||||
else if (cmd == COMMAND_WRITE_CODE) {
|
|
||||||
uint32_t addr, length;
|
uint32_t addr, length;
|
||||||
if (!client->recvall(&addr, 4)) return;
|
if (!client->recvall(&addr, 4)) return;
|
||||||
if (!client->recvall(&length, 4)) return;
|
if (!client->recvall(&length, 4)) return;
|
||||||
@ -709,8 +699,7 @@ void Debugger::mainLoop(Client *client) {
|
|||||||
}
|
}
|
||||||
breakpoints.write(buffer, addr, length);
|
breakpoints.write(buffer, addr, length);
|
||||||
delete buffer;
|
delete buffer;
|
||||||
}
|
} else if (cmd == COMMAND_GET_MODULE_NAME) {
|
||||||
else if (cmd == COMMAND_GET_MODULE_NAME) {
|
|
||||||
char name[0x40];
|
char name[0x40];
|
||||||
int length = 0x40;
|
int length = 0x40;
|
||||||
OSDynLoad_GetModuleName(-1, name, &length);
|
OSDynLoad_GetModuleName(-1, name, &length);
|
||||||
@ -718,8 +707,7 @@ void Debugger::mainLoop(Client *client) {
|
|||||||
length = strlen(name);
|
length = strlen(name);
|
||||||
if (!client->sendall(&length, 4)) return;
|
if (!client->sendall(&length, 4)) return;
|
||||||
if (!client->sendall(name, length)) return;
|
if (!client->sendall(name, length)) return;
|
||||||
}
|
} else if (cmd == COMMAND_GET_MODULE_LIST) {
|
||||||
else if (cmd == COMMAND_GET_MODULE_LIST) {
|
|
||||||
OSLockMutex(OSDynLoad_gLoaderLock);
|
OSLockMutex(OSDynLoad_gLoaderLock);
|
||||||
|
|
||||||
char buffer[0x1000]; //This should be enough
|
char buffer[0x1000]; //This should be enough
|
||||||
@ -733,12 +721,12 @@ void Debugger::mainLoop(Client *client) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t *infobuf = (uint32_t *)(buffer + offset);
|
uint32_t *infobuf = (uint32_t *) (buffer + offset);
|
||||||
infobuf[0] = info->textAddr;
|
infobuf[0] = info->textAddr;
|
||||||
infobuf[1] = info->textSize;
|
infobuf[1] = info->textSize;
|
||||||
infobuf[2] = info->dataAddr;
|
infobuf[2] = info->dataAddr;
|
||||||
infobuf[3] = info->dataSize;
|
infobuf[3] = info->dataSize;
|
||||||
infobuf[4] = (uint32_t)current->entryPoint;
|
infobuf[4] = (uint32_t) current->entryPoint;
|
||||||
infobuf[5] = namelen;
|
infobuf[5] = namelen;
|
||||||
memcpy(&infobuf[6], current->name, namelen);
|
memcpy(&infobuf[6], current->name, namelen);
|
||||||
offset += 0x18 + namelen;
|
offset += 0x18 + namelen;
|
||||||
@ -750,8 +738,7 @@ void Debugger::mainLoop(Client *client) {
|
|||||||
|
|
||||||
if (!client->sendall(&offset, 4)) return;
|
if (!client->sendall(&offset, 4)) return;
|
||||||
if (!client->sendall(buffer, offset)) return;
|
if (!client->sendall(buffer, offset)) return;
|
||||||
}
|
} else if (cmd == COMMAND_GET_THREAD_LIST) {
|
||||||
else if (cmd == COMMAND_GET_THREAD_LIST) {
|
|
||||||
int state = OSDisableInterrupts();
|
int state = OSDisableInterrupts();
|
||||||
__OSLockScheduler(this);
|
__OSLockScheduler(this);
|
||||||
|
|
||||||
@ -773,18 +760,17 @@ void Debugger::mainLoop(Client *client) {
|
|||||||
int priority = current->basePriority;
|
int priority = current->basePriority;
|
||||||
if (current->type == 1) {
|
if (current->type == 1) {
|
||||||
priority -= 0x20;
|
priority -= 0x20;
|
||||||
}
|
} else if (current->type == 2) {
|
||||||
else if (current->type == 2) {
|
|
||||||
priority -= 0x40;
|
priority -= 0x40;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t *infobuf = (uint32_t *)(buffer + offset);
|
uint32_t *infobuf = (uint32_t *) (buffer + offset);
|
||||||
infobuf[0] = (uint32_t)current;
|
infobuf[0] = (uint32_t) current;
|
||||||
infobuf[1] = current->attr & 7;
|
infobuf[1] = current->attr & 7;
|
||||||
infobuf[2] = priority;
|
infobuf[2] = priority;
|
||||||
infobuf[3] = (uint32_t)current->stackBase;
|
infobuf[3] = (uint32_t) current->stackBase;
|
||||||
infobuf[4] = (uint32_t)current->stackEnd;
|
infobuf[4] = (uint32_t) current->stackEnd;
|
||||||
infobuf[5] = (uint32_t)current->entryPoint;
|
infobuf[5] = (uint32_t) current->entryPoint;
|
||||||
infobuf[6] = namelen;
|
infobuf[6] = namelen;
|
||||||
memcpy(&infobuf[7], name, namelen);
|
memcpy(&infobuf[7], name, namelen);
|
||||||
offset += 0x1C + namelen;
|
offset += 0x1C + namelen;
|
||||||
@ -797,8 +783,7 @@ void Debugger::mainLoop(Client *client) {
|
|||||||
|
|
||||||
if (!client->sendall(&offset, 4)) return;
|
if (!client->sendall(&offset, 4)) return;
|
||||||
if (!client->sendall(buffer, offset)) return;
|
if (!client->sendall(buffer, offset)) return;
|
||||||
}
|
} else if (cmd == COMMAND_GET_STACK_TRACE) {
|
||||||
else if (cmd == COMMAND_GET_STACK_TRACE) {
|
|
||||||
OSThread *thread;
|
OSThread *thread;
|
||||||
if (!client->recvall(&thread, 4)) return;
|
if (!client->recvall(&thread, 4)) return;
|
||||||
|
|
||||||
@ -808,28 +793,25 @@ void Debugger::mainLoop(Client *client) {
|
|||||||
uint32_t trace[100];
|
uint32_t trace[100];
|
||||||
int index = 0;
|
int index = 0;
|
||||||
while (checkDataRead(sp, 4) && index < 100) {
|
while (checkDataRead(sp, 4) && index < 100) {
|
||||||
sp = *(uint32_t *)sp;
|
sp = *(uint32_t *) sp;
|
||||||
if (!checkDataRead(sp, 4)) break;
|
if (!checkDataRead(sp, 4)) break;
|
||||||
|
|
||||||
trace[index] = *(uint32_t *)(sp + 4);
|
trace[index] = *(uint32_t *) (sp + 4);
|
||||||
index++;
|
index++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!client->sendall(&index, 4)) return;
|
if (!client->sendall(&index, 4)) return;
|
||||||
if (!client->sendall(trace, index * 4)) return;
|
if (!client->sendall(trace, index * 4)) return;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
int index = 0;
|
int index = 0;
|
||||||
if (!client->sendall(&index, 4)) return;
|
if (!client->sendall(&index, 4)) return;
|
||||||
}
|
}
|
||||||
}
|
} else if (cmd == COMMAND_TOGGLE_BREAKPOINT) {
|
||||||
else if (cmd == COMMAND_TOGGLE_BREAKPOINT) {
|
|
||||||
uint32_t address;
|
uint32_t address;
|
||||||
if (!client->recvall(&address, 4)) return;
|
if (!client->recvall(&address, 4)) return;
|
||||||
|
|
||||||
breakpoints.toggle(address);
|
breakpoints.toggle(address);
|
||||||
}
|
} else if (cmd == COMMAND_POKE_REGISTERS) {
|
||||||
else if (cmd == COMMAND_POKE_REGISTERS) {
|
|
||||||
OSThread *thread;
|
OSThread *thread;
|
||||||
if (!client->recvall(&thread, 4)) return;
|
if (!client->recvall(&thread, 4)) return;
|
||||||
|
|
||||||
@ -845,8 +827,7 @@ void Debugger::mainLoop(Client *client) {
|
|||||||
memcpy(state->context.fpr, fpr, 8 * 32);
|
memcpy(state->context.fpr, fpr, 8 * 32);
|
||||||
}
|
}
|
||||||
exceptions.unlock();
|
exceptions.unlock();
|
||||||
}
|
} else if (cmd == COMMAND_RECEIVE_MESSAGES) {
|
||||||
else if (cmd == COMMAND_RECEIVE_MESSAGES) {
|
|
||||||
OSMessage messages[10];
|
OSMessage messages[10];
|
||||||
|
|
||||||
int count = 0;
|
int count = 0;
|
||||||
@ -861,17 +842,16 @@ void Debugger::mainLoop(Client *client) {
|
|||||||
for (int i = 0; i < count; i++) {
|
for (int i = 0; i < count; i++) {
|
||||||
if (!client->sendall(&messages[i], sizeof(OSMessage))) return;
|
if (!client->sendall(&messages[i], sizeof(OSMessage))) return;
|
||||||
if (messages[i].args[0]) {
|
if (messages[i].args[0]) {
|
||||||
void *data = (void *)messages[i].args[0];
|
void *data = (void *) messages[i].args[0];
|
||||||
size_t length = messages[i].args[1];
|
size_t length = messages[i].args[1];
|
||||||
if (!client->sendall(data, length)) return;
|
if (!client->sendall(data, length)) return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} else if (cmd == COMMAND_SEND_MESSAGE) {
|
||||||
else if (cmd == COMMAND_SEND_MESSAGE) {
|
|
||||||
OSMessage message;
|
OSMessage message;
|
||||||
if (!client->recvall(&message, sizeof(OSMessage))) return;
|
if (!client->recvall(&message, sizeof(OSMessage))) return;
|
||||||
|
|
||||||
OSThread *thread = (OSThread *)message.args[0];
|
OSThread *thread = (OSThread *) message.args[0];
|
||||||
|
|
||||||
exceptions.lock();
|
exceptions.lock();
|
||||||
ExceptionState *state = exceptions.find(thread);
|
ExceptionState *state = exceptions.find(thread);
|
||||||
@ -932,8 +912,7 @@ void Debugger::start() {
|
|||||||
OSCreateThread(
|
OSCreateThread(
|
||||||
serverThread, threadEntry, 0, 0,
|
serverThread, threadEntry, 0, 0,
|
||||||
stack + STACK_SIZE, STACK_SIZE,
|
stack + STACK_SIZE, STACK_SIZE,
|
||||||
0, 12
|
0, 12);
|
||||||
);
|
|
||||||
OSSetThreadName(serverThread, "Debug Server");
|
OSSetThreadName(serverThread, "Debug Server");
|
||||||
OSResumeThread(serverThread);
|
OSResumeThread(serverThread);
|
||||||
|
|
||||||
|
@ -14,14 +14,14 @@
|
|||||||
#define TRAP 0x7FE00008
|
#define TRAP 0x7FE00008
|
||||||
|
|
||||||
|
|
||||||
template <int N>
|
template<int N>
|
||||||
class Bits {
|
class Bits {
|
||||||
public:
|
public:
|
||||||
Bits(uint32_t value) {
|
Bits(uint32_t value) {
|
||||||
this->value = value;
|
this->value = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool operator [](int index) {
|
bool operator[](int index) {
|
||||||
return (value >> (N - index - 1)) & 1;
|
return (value >> (N - index - 1)) & 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -83,7 +83,7 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
template <class T>
|
template<class T>
|
||||||
class BreakPointList {
|
class BreakPointList {
|
||||||
public:
|
public:
|
||||||
size_t size() {
|
size_t size() {
|
||||||
@ -129,7 +129,7 @@ public:
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
T *operator [](int index) {
|
T *operator[](int index) {
|
||||||
return &list[index];
|
return &list[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,8 +24,7 @@ void DumpContext(OSContext *context, const char *excType) {
|
|||||||
context->gpr[24], context->gpr[25], context->gpr[26], context->gpr[27],
|
context->gpr[24], context->gpr[25], context->gpr[26], context->gpr[27],
|
||||||
context->gpr[28], context->gpr[29], context->gpr[30], context->gpr[31],
|
context->gpr[28], context->gpr[29], context->gpr[30], context->gpr[31],
|
||||||
context->lr, context->ctr, context->xer, context->srr0, context->srr1,
|
context->lr, context->ctr, context->xer, context->srr0, context->srr1,
|
||||||
context->dsisr, context->dar
|
context->dsisr, context->dar);
|
||||||
);
|
|
||||||
OSFatal(buffer);
|
OSFatal(buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@ struct OsSpecifics {
|
|||||||
uint32_t OSDynLoad_Acquire;
|
uint32_t OSDynLoad_Acquire;
|
||||||
uint32_t OSDynLoad_FindExport;
|
uint32_t OSDynLoad_FindExport;
|
||||||
};
|
};
|
||||||
#define OS_SPECIFICS ((OsSpecifics *)(MEM_BASE + 0x1500))
|
#define OS_SPECIFICS ((OsSpecifics *) (MEM_BASE + 0x1500))
|
||||||
|
|
||||||
#define EXIT_SUCCESS 0
|
#define EXIT_SUCCESS 0
|
||||||
#define EXIT_RELAUNCH_ON_LOAD -3
|
#define EXIT_RELAUNCH_ON_LOAD -3
|
||||||
|
@ -14,24 +14,23 @@ extern "C" void KernelCopyData(uint32_t dst, uint32_t src, uint32_t len);
|
|||||||
|
|
||||||
void KernelWrite(uint32_t addr, const void *data, uint32_t length) {
|
void KernelWrite(uint32_t addr, const void *data, uint32_t length) {
|
||||||
uint32_t dst = OSEffectiveToPhysical(addr);
|
uint32_t dst = OSEffectiveToPhysical(addr);
|
||||||
uint32_t src = OSEffectiveToPhysical((uint32_t)data);
|
uint32_t src = OSEffectiveToPhysical((uint32_t) data);
|
||||||
KernelCopyData(dst, src, length);
|
KernelCopyData(dst, src, length);
|
||||||
DCFlushRange((void *)addr, length);
|
DCFlushRange((void *) addr, length);
|
||||||
ICInvalidateRange((void *)addr, length);
|
ICInvalidateRange((void *) addr, length);
|
||||||
}
|
}
|
||||||
|
|
||||||
void KernelWriteU32(uint32_t addr, uint32_t value) {
|
void KernelWriteU32(uint32_t addr, uint32_t value) {
|
||||||
uint32_t dst = OSEffectiveToPhysical(addr);
|
uint32_t dst = OSEffectiveToPhysical(addr);
|
||||||
uint32_t src = OSEffectiveToPhysical((uint32_t)&value);
|
uint32_t src = OSEffectiveToPhysical((uint32_t) &value);
|
||||||
KernelCopyData(dst, src, 4);
|
KernelCopyData(dst, src, 4);
|
||||||
DCFlushRange((void *)addr, 4);
|
DCFlushRange((void *) addr, 4);
|
||||||
ICInvalidateRange((void *)addr, 4);
|
ICInvalidateRange((void *) addr, 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Write a 32-bit word with kernel permissions */
|
/* Write a 32-bit word with kernel permissions */
|
||||||
void __attribute__ ((noinline)) kern_write(uint32_t addr, uint32_t value)
|
void __attribute__((noinline)) kern_write(uint32_t addr, uint32_t value) {
|
||||||
{
|
asm volatile(
|
||||||
asm volatile (
|
|
||||||
"li 3,1\n"
|
"li 3,1\n"
|
||||||
"li 4,0\n"
|
"li 4,0\n"
|
||||||
"mr 5,%1\n"
|
"mr 5,%1\n"
|
||||||
@ -47,8 +46,7 @@ void __attribute__ ((noinline)) kern_write(uint32_t addr, uint32_t value)
|
|||||||
:
|
:
|
||||||
: "r"(addr), "r"(value)
|
: "r"(addr), "r"(value)
|
||||||
: "memory", "ctr", "lr", "0", "3", "4", "5", "6", "7", "8", "9", "10",
|
: "memory", "ctr", "lr", "0", "3", "4", "5", "6", "7", "8", "9", "10",
|
||||||
"11", "12"
|
"11", "12");
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PatchSyscall(int index, uint32_t addr) {
|
void PatchSyscall(int index, uint32_t addr) {
|
||||||
@ -60,5 +58,5 @@ void PatchSyscall(int index, uint32_t addr) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void kernelInitialize() {
|
void kernelInitialize() {
|
||||||
PatchSyscall(0x25, (uint32_t)SCKernelCopyData);
|
PatchSyscall(0x25, (uint32_t) SCKernelCopyData);
|
||||||
}
|
}
|
||||||
|
23
src/main.cpp
23
src/main.cpp
@ -1,18 +1,18 @@
|
|||||||
|
|
||||||
#include "cafe/coreinit.h"
|
#include "cafe/coreinit.h"
|
||||||
#include "cafe/sysapp.h"
|
|
||||||
#include "cafe/nsysnet.h"
|
|
||||||
#include "cafe/vpad.h"
|
|
||||||
#include "cafe/nn_save.h"
|
|
||||||
#include "cafe/nn_act.h"
|
#include "cafe/nn_act.h"
|
||||||
#include "kernel.h"
|
#include "cafe/nn_save.h"
|
||||||
|
#include "cafe/nsysnet.h"
|
||||||
|
#include "cafe/sysapp.h"
|
||||||
|
#include "cafe/vpad.h"
|
||||||
#include "hbl.h"
|
#include "hbl.h"
|
||||||
|
#include "kernel.h"
|
||||||
|
|
||||||
#include "patches.h"
|
|
||||||
#include "debugger.h"
|
#include "debugger.h"
|
||||||
#include "exceptions.h"
|
#include "exceptions.h"
|
||||||
#include "screen.h"
|
|
||||||
#include "menu.h"
|
#include "menu.h"
|
||||||
|
#include "patches.h"
|
||||||
|
#include "screen.h"
|
||||||
|
|
||||||
|
|
||||||
bool GetTitleIdOnDisk(uint64_t *titleId) {
|
bool GetTitleIdOnDisk(uint64_t *titleId) {
|
||||||
@ -42,12 +42,10 @@ int MenuMain() {
|
|||||||
uint64_t titleId;
|
uint64_t titleId;
|
||||||
if (GetTitleIdOnDisk(&titleId)) {
|
if (GetTitleIdOnDisk(&titleId)) {
|
||||||
SYSLaunchTitle(titleId);
|
SYSLaunchTitle(titleId);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
menu.setMessage("Please insert a valid disk");
|
menu.setMessage("Please insert a valid disk");
|
||||||
}
|
}
|
||||||
}
|
} else if (result == Menu::ReturnToMenu) {
|
||||||
else if (result == Menu::ReturnToMenu) {
|
|
||||||
SYSLaunchMenu();
|
SYSLaunchMenu();
|
||||||
}
|
}
|
||||||
return EXIT_RELAUNCH_ON_LOAD;
|
return EXIT_RELAUNCH_ON_LOAD;
|
||||||
@ -76,8 +74,7 @@ int start() {
|
|||||||
int result;
|
int result;
|
||||||
if (firstRun) {
|
if (firstRun) {
|
||||||
result = MenuMain();
|
result = MenuMain();
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
result = DebuggerMain();
|
result = DebuggerMain();
|
||||||
}
|
}
|
||||||
firstRun = false;
|
firstRun = false;
|
||||||
|
@ -3,19 +3,19 @@
|
|||||||
|
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
|
|
||||||
void * operator new(size_t size) {
|
void *operator new(size_t size) {
|
||||||
return MEMAllocFromDefaultHeap(size);
|
return MEMAllocFromDefaultHeap(size);
|
||||||
}
|
}
|
||||||
|
|
||||||
void * operator new[](size_t size) {
|
void *operator new[](size_t size) {
|
||||||
return MEMAllocFromDefaultHeap(size);
|
return MEMAllocFromDefaultHeap(size);
|
||||||
}
|
}
|
||||||
|
|
||||||
void * operator new(size_t size, int alignment) {
|
void *operator new(size_t size, int alignment) {
|
||||||
return MEMAllocFromDefaultHeapEx(size, alignment);
|
return MEMAllocFromDefaultHeapEx(size, alignment);
|
||||||
}
|
}
|
||||||
|
|
||||||
void * operator new[](size_t size, int alignment) {
|
void *operator new[](size_t size, int alignment) {
|
||||||
return MEMAllocFromDefaultHeapEx(size, alignment);
|
return MEMAllocFromDefaultHeapEx(size, alignment);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
11
src/menu.cpp
11
src/menu.cpp
@ -1,9 +1,9 @@
|
|||||||
|
|
||||||
#include "cafe/vpad.h"
|
|
||||||
#include "menu.h"
|
#include "menu.h"
|
||||||
#include "screen.h"
|
#include "cafe/vpad.h"
|
||||||
#include "input.h"
|
|
||||||
#include "color.h"
|
#include "color.h"
|
||||||
|
#include "input.h"
|
||||||
|
#include "screen.h"
|
||||||
|
|
||||||
Menu::Menu(Screen *screen) : screen(screen) {
|
Menu::Menu(Screen *screen) : screen(screen) {
|
||||||
currentOption = LaunchDisk;
|
currentOption = LaunchDisk;
|
||||||
@ -14,11 +14,10 @@ Menu::Option Menu::show() {
|
|||||||
while (true) {
|
while (true) {
|
||||||
redraw();
|
redraw();
|
||||||
uint32_t buttons = WaitInput(VPAD_BUTTON_A | VPAD_BUTTON_DOWN | VPAD_BUTTON_UP);
|
uint32_t buttons = WaitInput(VPAD_BUTTON_A | VPAD_BUTTON_DOWN | VPAD_BUTTON_UP);
|
||||||
if (buttons & VPAD_BUTTON_A) return (Option)currentOption;
|
if (buttons & VPAD_BUTTON_A) return (Option) currentOption;
|
||||||
else if (buttons & VPAD_BUTTON_DOWN) {
|
else if (buttons & VPAD_BUTTON_DOWN) {
|
||||||
if (currentOption < 2) currentOption++;
|
if (currentOption < 2) currentOption++;
|
||||||
}
|
} else if (buttons & VPAD_BUTTON_UP) {
|
||||||
else if (buttons & VPAD_BUTTON_UP) {
|
|
||||||
if (currentOption > 0) currentOption--;
|
if (currentOption > 0) currentOption--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
#include "screen.h"
|
#include "screen.h"
|
||||||
|
|
||||||
class Menu {
|
class Menu {
|
||||||
public:
|
public:
|
||||||
enum Option {
|
enum Option {
|
||||||
LaunchDisk,
|
LaunchDisk,
|
||||||
ReturnToMenu,
|
ReturnToMenu,
|
||||||
@ -16,7 +16,7 @@ class Menu {
|
|||||||
void setMessage(const char *message);
|
void setMessage(const char *message);
|
||||||
void redraw();
|
void redraw();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Screen *screen;
|
Screen *screen;
|
||||||
int currentOption;
|
int currentOption;
|
||||||
|
|
||||||
|
@ -19,11 +19,11 @@ bool OSIsDebuggerInitialized_Patch() {
|
|||||||
void Patch(void *funcPtr, void *patchPtr) {
|
void Patch(void *funcPtr, void *patchPtr) {
|
||||||
OSDynLoad_NotifyData *sectionInfo = MainRPL->notifyData;
|
OSDynLoad_NotifyData *sectionInfo = MainRPL->notifyData;
|
||||||
|
|
||||||
uint32_t func = (uint32_t)funcPtr;
|
uint32_t func = (uint32_t) funcPtr;
|
||||||
uint32_t patch = (uint32_t)patchPtr;
|
uint32_t patch = (uint32_t) patchPtr;
|
||||||
if (func < 0x01800000) { //OS function (with trampoline)
|
if (func < 0x01800000) { //OS function (with trampoline)
|
||||||
for (uint32_t addr = sectionInfo->textAddr; addr < 0x10000000; addr += 4) {
|
for (uint32_t addr = sectionInfo->textAddr; addr < 0x10000000; addr += 4) {
|
||||||
uint32_t *instrs = (uint32_t *)addr;
|
uint32_t *instrs = (uint32_t *) addr;
|
||||||
if (instrs[0] == (0x3D600000 | (func >> 16)) && //lis r11, func@h
|
if (instrs[0] == (0x3D600000 | (func >> 16)) && //lis r11, func@h
|
||||||
instrs[1] == (0x616B0000 | (func & 0xFFFF)) && //ori r11, r11, func@l
|
instrs[1] == (0x616B0000 | (func & 0xFFFF)) && //ori r11, r11, func@l
|
||||||
instrs[2] == 0x7D6903A6 && //mtctr r11
|
instrs[2] == 0x7D6903A6 && //mtctr r11
|
||||||
@ -33,10 +33,9 @@ void Patch(void *funcPtr, void *patchPtr) {
|
|||||||
KernelWriteU32(addr + 4, 0x616B0000 | (patch & 0xFFFF)); //ori r11, r11, patch@l
|
KernelWriteU32(addr + 4, 0x616B0000 | (patch & 0xFFFF)); //ori r11, r11, patch@l
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} else { //Dynamic function
|
||||||
else { //Dynamic function
|
|
||||||
for (uint32_t addr = sectionInfo->textAddr; addr < 0x10000000; addr += 4) {
|
for (uint32_t addr = sectionInfo->textAddr; addr < 0x10000000; addr += 4) {
|
||||||
uint32_t instr = *(uint32_t *)addr;
|
uint32_t instr = *(uint32_t *) addr;
|
||||||
if ((instr & 0xFC000002) == 0x48000000) { //b or bl
|
if ((instr & 0xFC000002) == 0x48000000) { //b or bl
|
||||||
if ((instr & 0x03FFFFFC) == func - addr) {
|
if ((instr & 0x03FFFFFC) == func - addr) {
|
||||||
instr = instr & ~0x03FFFFFC;
|
instr = instr & ~0x03FFFFFC;
|
||||||
@ -50,8 +49,8 @@ void Patch(void *funcPtr, void *patchPtr) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ApplyPatches() {
|
void ApplyPatches() {
|
||||||
Patch((void *)OSSetExceptionCallback, (void *)OSSetExceptionCallback_Patch);
|
Patch((void *) OSSetExceptionCallback, (void *) OSSetExceptionCallback_Patch);
|
||||||
Patch((void *)OSSetExceptionCallbackEx, (void *)OSSetExceptionCallbackEx_Patch);
|
Patch((void *) OSSetExceptionCallbackEx, (void *) OSSetExceptionCallbackEx_Patch);
|
||||||
|
|
||||||
Patch((void *)OSIsDebuggerInitialized, (void *)OSIsDebuggerInitialized_Patch);
|
Patch((void *) OSIsDebuggerInitialized, (void *) OSIsDebuggerInitialized_Patch);
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
|
|
||||||
#include "cafe/coreinit.h"
|
|
||||||
#include "screen.h"
|
#include "screen.h"
|
||||||
|
#include "cafe/coreinit.h"
|
||||||
#include "memory.h"
|
#include "memory.h"
|
||||||
|
|
||||||
Screen::Screen() : screenBuffer(0) {}
|
Screen::Screen() : screenBuffer(0) {}
|
||||||
@ -17,7 +17,7 @@ void Screen::init() {
|
|||||||
uint32_t bufferSize1 = OSScreenGetBufferSizeEx(1);
|
uint32_t bufferSize1 = OSScreenGetBufferSizeEx(1);
|
||||||
screenBuffer = operator new(bufferSize0 + bufferSize1, 0x40);
|
screenBuffer = operator new(bufferSize0 + bufferSize1, 0x40);
|
||||||
OSScreenSetBufferEx(0, screenBuffer);
|
OSScreenSetBufferEx(0, screenBuffer);
|
||||||
OSScreenSetBufferEx(1, (char *)screenBuffer + bufferSize0);
|
OSScreenSetBufferEx(1, (char *) screenBuffer + bufferSize0);
|
||||||
|
|
||||||
OSScreenEnableEx(0, 1);
|
OSScreenEnableEx(0, 1);
|
||||||
OSScreenEnableEx(1, 1);
|
OSScreenEnableEx(1, 1);
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
|
||||||
class Screen {
|
class Screen {
|
||||||
public:
|
public:
|
||||||
enum Display {
|
enum Display {
|
||||||
TV,
|
TV,
|
||||||
DRC
|
DRC
|
||||||
@ -26,7 +26,7 @@ class Screen {
|
|||||||
void drawText(Display screen, int x, int y, const char *text);
|
void drawText(Display screen, int x, int y, const char *text);
|
||||||
void flip(Display screen);
|
void flip(Display screen);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void *screenBuffer;
|
void *screenBuffer;
|
||||||
|
|
||||||
int convx(int x);
|
int convx(int x);
|
||||||
|
@ -14,8 +14,7 @@ Socket::~Socket() {
|
|||||||
bool Socket::init(Type type) {
|
bool Socket::init(Type type) {
|
||||||
if (type == TCP) {
|
if (type == TCP) {
|
||||||
sock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
|
sock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
sock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
|
sock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
|
||||||
}
|
}
|
||||||
return sock >= 0;
|
return sock >= 0;
|
||||||
@ -41,7 +40,7 @@ bool Client::sendall(const void *data, size_t length) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
sent += num;
|
sent += num;
|
||||||
data = (const char *)data + num;
|
data = (const char *) data + num;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -56,7 +55,7 @@ bool Client::recvall(void *data, size_t length) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
received += num;
|
received += num;
|
||||||
data = (char *)data + num;
|
data = (char *) data + num;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user