-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into easy-module-dump
- Loading branch information
Showing
15 changed files
with
244 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
IOP_OBJS = main.o ioplib.o imports.o | ||
|
||
include ../../Defs.make | ||
include ../Rules.bin.make | ||
include ../Rules.make |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
intrman_IMPORTS_start | ||
I_CpuSuspendIntr | ||
I_CpuResumeIntr | ||
intrman_IMPORTS_end | ||
|
||
loadcore_IMPORTS_start | ||
I_GetLoadcoreInternalData | ||
loadcore_IMPORTS_end | ||
|
||
#ifdef DEBUG | ||
stdio_IMPORTS_start | ||
I_printf | ||
stdio_IMPORTS_end | ||
#endif | ||
|
||
#ifdef DEBUG | ||
sysmem_IMPORTS_start | ||
I_QueryTotalFreeMemSize | ||
sysmem_IMPORTS_end | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
#include "ioplib.h" | ||
#include <intrman.h> | ||
#include <stdint.h> | ||
|
||
iop_library_t *ioplib_getByName(const char *name) | ||
{ | ||
iop_library_t *libptr; | ||
int i; | ||
|
||
// Get first loaded library | ||
libptr = GetLoadcoreInternalData()->let_next; | ||
// Loop through all loaded libraries | ||
while (libptr != NULL) { | ||
// Compare library name only | ||
for (i = 0; i < 8; i++) { | ||
if (libptr->name[i] != name[i]) | ||
break; | ||
} | ||
|
||
// Return if match | ||
if (i == 8) | ||
return libptr; | ||
|
||
// Next library | ||
libptr = libptr->prev; | ||
} | ||
|
||
return NULL; | ||
} | ||
|
||
unsigned int ioplib_getTableSize(iop_library_t *lib) | ||
{ | ||
void **exp; | ||
unsigned int size; | ||
|
||
exp = NULL; | ||
if (lib != NULL) { | ||
exp = lib->exports; | ||
} | ||
size = 0; | ||
|
||
if (exp != NULL) | ||
while (*exp++ != NULL) | ||
size++; | ||
|
||
return size; | ||
} | ||
|
||
void *ioplib_hookExportEntry(iop_library_t *lib, unsigned int entry, void *func) | ||
{ | ||
if (entry < ioplib_getTableSize(lib)) { | ||
int oldstate; | ||
void **exp, *temp; | ||
|
||
exp = &lib->exports[entry]; | ||
|
||
CpuSuspendIntr(&oldstate); | ||
temp = *exp; | ||
*exp = func; | ||
func = temp; | ||
CpuResumeIntr(oldstate); | ||
|
||
return func; | ||
} | ||
|
||
return NULL; | ||
} | ||
|
||
void ioplib_relinkExports(iop_library_t *lib) | ||
{ | ||
struct irx_import_table *table; | ||
struct irx_import_stub *stub; | ||
|
||
// go through each table that imports the library | ||
for (table = lib->caller; table != NULL; table = table->next) { | ||
// go through each import in the table | ||
for (stub = (struct irx_import_stub *)table->stubs; stub->jump != 0; stub++) { | ||
// patch the stub to jump to the address specified in the library export table for "fno" | ||
stub->jump = 0x08000000 | (((uint32_t)lib->exports[stub->fno] << 4) >> 6); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#ifndef IOPLIB_H | ||
#define IOPLIB_H | ||
|
||
|
||
#include <loadcore.h> | ||
|
||
|
||
iop_library_t *ioplib_getByName(const char *name); | ||
unsigned int ioplib_getTableSize(iop_library_t *lib); | ||
void *ioplib_hookExportEntry(iop_library_t *lib, unsigned int entry, void *func); | ||
void ioplib_relinkExports(iop_library_t *lib); | ||
|
||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#ifndef IOP_IRX_IMPORTS_H | ||
#define IOP_IRX_IMPORTS_H | ||
|
||
#include "irx.h" | ||
|
||
#include <intrman.h> | ||
#include <loadcore.h> | ||
#ifdef DEBUG | ||
#include <stdio.h> | ||
#include <sysmem.h> | ||
#endif | ||
|
||
#endif |
Oops, something went wrong.