Decompile memaFree

This commit is contained in:
Ryan Dwyer 2021-10-30 10:16:13 +10:00
parent 6ecd5fa063
commit 2143bef1df
9 changed files with 20 additions and 27 deletions

View File

@ -92,7 +92,7 @@ The decomp project wraps all decompiled piracy checks in `#if PIRACYCHECKS` stat
**What It Checks:** Checksums `lvInit` to make sure it hasn't been modified. **What It Checks:** Checksums `lvInit` to make sure it hasn't been modified.
**Payload:** Nops `func00012914` entirely. Unsure what effect this has. This means any time that function is called it'll flow into the following function, which just returns. **Payload:** Nops `_memaFree` entirely, so any time that function is called it'll flow into the following function, which just returns. The effect this has is that the system is unable to free individual mema allocations which makes it more likely to run out of memory.
--- ---

View File

@ -10806,13 +10806,13 @@ void func0f15e474(s32 roomnum)
if (g_Rooms[roomnum].unk44) { if (g_Rooms[roomnum].unk44) {
thing = ((g_Rooms[roomnum].unk40 << 5) + 0xf) & ~0xf; thing = ((g_Rooms[roomnum].unk40 << 5) + 0xf) & ~0xf;
func00012cb4(g_Rooms[roomnum].unk44, thing); memaFree(g_Rooms[roomnum].unk44, thing);
g_Rooms[roomnum].unk44 = NULL; g_Rooms[roomnum].unk44 = NULL;
} }
if (g_Rooms[roomnum].unk80 > 0) { if (g_Rooms[roomnum].unk80 > 0) {
thing = g_Rooms[roomnum].unk80; thing = g_Rooms[roomnum].unk80;
func00012cb4(g_Rooms[roomnum].unk14, thing); memaFree(g_Rooms[roomnum].unk14, thing);
g_Rooms[roomnum].unk14 = 0; g_Rooms[roomnum].unk14 = 0;
} }

View File

@ -340,7 +340,7 @@ void func0f149e58(u8 *arg0, u32 size)
for (i = 0; i < var800a45a0->unk37c; i++) { for (i = 0; i < var800a45a0->unk37c; i++) {
if (arg0 == NULL || arg0 == var800a45a0->unk380[i]) { if (arg0 == NULL || arg0 == var800a45a0->unk380[i]) {
func00012cb4(var800a45a0->unk380[i], var800a45a0->unk3f8[i]); memaFree(var800a45a0->unk380[i], var800a45a0->unk3f8[i]);
var800a45a0->unk380[i] = 0; var800a45a0->unk380[i] = 0;
} }
} }

View File

@ -39,7 +39,7 @@ void func0f110bf8(void)
for (i = 0; i < 4; i++) { for (i = 0; i < 4; i++) {
if (g_FileLists[i] != NULL) { if (g_FileLists[i] != NULL) {
func00012cb4(g_FileLists[i], align16(sizeof(struct filelist))); memaFree(g_FileLists[i], align16(sizeof(struct filelist)));
g_FileLists[i] = NULL; g_FileLists[i] = NULL;
} }
} }
@ -537,7 +537,7 @@ void pheadFreeTextures(s32 playernum)
{ {
if (g_Menus[playernum].fm.headtextures != NULL) { if (g_Menus[playernum].fm.headtextures != NULL) {
if (g_Menus[playernum].fm.unke40_01) { if (g_Menus[playernum].fm.unke40_01) {
func00012cb4(g_Menus[playernum].fm.headtextures, align16(sizeof(struct perfectheadtexturelist))); memaFree(g_Menus[playernum].fm.headtextures, align16(sizeof(struct perfectheadtexturelist)));
} }
g_Menus[playernum].fm.headtextures = NULL; g_Menus[playernum].fm.headtextures = NULL;

View File

@ -460,7 +460,7 @@ void func0f10898c(void)
case FILEOP_READ_GAME: case FILEOP_READ_GAME:
case FILEOP_READ_MPSETUP: case FILEOP_READ_MPSETUP:
case FILEOP_READ_MPPLAYER: case FILEOP_READ_MPPLAYER:
func00012cb4(g_Menus[g_MpPlayerNum].fm.unke44, align16(g_FileTypeSizes[g_Menus[g_MpPlayerNum].fm.filetypeplusone - 1])); memaFree(g_Menus[g_MpPlayerNum].fm.unke44, align16(g_FileTypeSizes[g_Menus[g_MpPlayerNum].fm.filetypeplusone - 1]));
break; break;
case FILEOP_LOAD_GAME: case FILEOP_LOAD_GAME:
case FILEOP_LOAD_MPPLAYER: case FILEOP_LOAD_MPPLAYER:
@ -484,7 +484,7 @@ void filemgrHandleSuccess(void)
case FILEOP_WRITE_GAME: case FILEOP_WRITE_GAME:
case FILEOP_WRITE_MPSETUP: case FILEOP_WRITE_MPSETUP:
case FILEOP_WRITE_MPPLAYER: case FILEOP_WRITE_MPPLAYER:
func00012cb4(g_Menus[g_MpPlayerNum].fm.unke44, memaFree(g_Menus[g_MpPlayerNum].fm.unke44,
align16(g_FileTypeSizes[g_Menus[g_MpPlayerNum].fm.filetypeplusone - 1])); align16(g_FileTypeSizes[g_Menus[g_MpPlayerNum].fm.filetypeplusone - 1]));
break; break;
case FILEOP_LOAD_GAME: case FILEOP_LOAD_GAME:

View File

@ -898,7 +898,7 @@ struct prop *propAllocateEyespy(struct pad *pad, s16 room)
} }
if (checksum != CHECKSUM_PLACEHOLDER) { if (checksum != CHECKSUM_PLACEHOLDER) {
s32 *ptr2 = (s32 *)func00012914; s32 *ptr2 = (s32 *)_memaFree;
s32 *end2 = (s32 *)memaInit; s32 *end2 = (s32 *)memaInit;
while (ptr2 < end2) { while (ptr2 < end2) {

View File

@ -111,7 +111,7 @@ void func0f12939c(void)
s32 size = ALIGN16(var8007e3d0[1].unk24[j].unk0c * 0x0c); s32 size = ALIGN16(var8007e3d0[1].unk24[j].unk0c * 0x0c);
func0f129210(var8007e3d0[1].unk24[j].unk00, var8007e3d0[1].unk24[i].unk00); func0f129210(var8007e3d0[1].unk24[j].unk00, var8007e3d0[1].unk24[i].unk00);
var8007e3d0[1].unk24[i].unk0e += var8007e3d0[1].unk24[j].unk0e; var8007e3d0[1].unk24[i].unk0e += var8007e3d0[1].unk24[j].unk0e;
func00012cb4(var8007e3d0[1].unk24[j].unk00, size); memaFree(var8007e3d0[1].unk24[j].unk00, size);
var8007e3d0[1].unk24[j].unk0e = 0; var8007e3d0[1].unk24[j].unk0e = 0;
var8007e3d0[1].val2 += var8007e3d0[1].unk24[j].unk0c; var8007e3d0[1].val2 += var8007e3d0[1].unk24[j].unk0c;
} }
@ -419,7 +419,7 @@ void func0f129818(s32 arg0, void *arg1)
return; return;
} }
func00012cb4(var8007e3d0[arg0].unk24[i].unk00, ALIGN16(var8007e3d0[arg0].unk24[i].unk0c * 0xc)); memaFree(var8007e3d0[arg0].unk24[i].unk00, ALIGN16(var8007e3d0[arg0].unk24[i].unk0c * 0xc));
var8007e3d0[arg0].val2 += var8007e3d0[arg0].unk24[i].unk0c; var8007e3d0[arg0].val2 += var8007e3d0[arg0].unk24[i].unk0c;
return; return;

View File

@ -6,13 +6,13 @@
void memaDefrag(void); void memaDefrag(void);
u32 func00012800(void); u32 func00012800(void);
u32 func00012914(void); void _memaFree(u32 addr, u32 size);
void memaInit(void); void memaInit(void);
void memaHeapInit(void *ptr, u32 arg1); void memaHeapInit(void *ptr, u32 size);
void memaPrint(void); void memaPrint(void);
void *memaAlloc(u32 size); void *memaAlloc(u32 size);
u32 func00012c3c(void); u32 func00012c3c(void);
void func00012cb4(void *arg0, s32 arg1); void memaFree(void *addr, s32 size);
s32 memaGetLongestFree(void); s32 memaGetLongestFree(void);
u32 func00012d48(void); u32 func00012d48(void);

View File

@ -157,7 +157,7 @@ glabel func00012800
); );
GLOBAL_ASM( GLOBAL_ASM(
glabel func00012914 glabel _memaFree
/* 12914: 3c0f800a */ lui $t7,%hi(var80099470) /* 12914: 3c0f800a */ lui $t7,%hi(var80099470)
/* 12918: 8def9470 */ lw $t7,%lo(var80099470)($t7) /* 12918: 8def9470 */ lw $t7,%lo(var80099470)($t7)
/* 1291c: 3c09800a */ lui $t1,%hi(var80099474) /* 1291c: 3c09800a */ lui $t1,%hi(var80099474)
@ -720,17 +720,10 @@ glabel func00012c3c
/* 12cb0: 00000000 */ nop /* 12cb0: 00000000 */ nop
); );
GLOBAL_ASM( void memaFree(void *addr, s32 size)
glabel func00012cb4 {
/* 12cb4: 27bdffe8 */ addiu $sp,$sp,-24 _memaFree((u32)addr, size);
/* 12cb8: afbf0014 */ sw $ra,0x14($sp) }
/* 12cbc: 0c004a45 */ jal func00012914
/* 12cc0: 00000000 */ nop
/* 12cc4: 8fbf0014 */ lw $ra,0x14($sp)
/* 12cc8: 27bd0018 */ addiu $sp,$sp,0x18
/* 12ccc: 03e00008 */ jr $ra
/* 12cd0: 00000000 */ nop
);
void mema00012cd4(void) void mema00012cd4(void)
{ {
@ -785,7 +778,7 @@ glabel func00012d48
/* 12d80: 10200004 */ beqz $at,.L00012d94 /* 12d80: 10200004 */ beqz $at,.L00012d94
/* 12d84: 8faf0018 */ lw $t7,0x18($sp) /* 12d84: 8faf0018 */ lw $t7,0x18($sp)
/* 12d88: 01e62021 */ addu $a0,$t7,$a2 /* 12d88: 01e62021 */ addu $a0,$t7,$a2
/* 12d8c: 0c004b2d */ jal func00012cb4 /* 12d8c: 0c004b2d */ jal memaFree
/* 12d90: 00e62823 */ subu $a1,$a3,$a2 /* 12d90: 00e62823 */ subu $a1,$a3,$a2
.L00012d94: .L00012d94:
/* 12d94: 24020001 */ addiu $v0,$zero,0x1 /* 12d94: 24020001 */ addiu $v0,$zero,0x1