-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlog.c
More file actions
132 lines (119 loc) · 3.56 KB
/
log.c
File metadata and controls
132 lines (119 loc) · 3.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
/*
* log.c is part of cxmb
* Copyright (C) 2008 Poison
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*
* Description:
* Author: Poison <hbpoison@gmail.com>
* Date Created: 2008-04-05
*/
//patpat mod for 3.71 - 6.37 <2011-02-19>
//neur0n mod for 6.39
//frostegater mod for 6.60
//LMAN mod for 6.61
//Yoti mod for INFINITY
#include <pspkernel.h>
#include <pspsysmem_kernel.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "log.h"
#include "utils.h"
#if _DEBUG >= 1
int log_running = 0;
char lstr[128];
int printlog(const char *str)
{
log_running = 1;
int fd = sceIoOpen("ms0:/log.txt", PSP_O_RDWR | PSP_O_CREAT | PSP_O_APPEND, 0777);
sceIoWrite(fd, str, strlen(str));
sceIoClose(fd);
fd = sceIoOpen("ef0:/log.txt", PSP_O_RDWR | PSP_O_CREAT | PSP_O_APPEND, 0777);
sceIoWrite(fd, str, strlen(str));
sceIoClose(fd);
log_running = 0;
return 0;
}
int printFileArg(PspIoDrvFileArg *arg)
{
log("unk1: %08x\nfs_num: %08x\ndrv: %08x\nunk2: %08x\narg: %08x\n",
(unsigned int)arg->unk1, (unsigned int)arg->fs_num, (unsigned int)arg->drv, (unsigned int)arg->unk2, (unsigned int)arg->arg);
if (!arg->arg)
return 0;
unsigned int *tmp = arg->arg;
log("arg0: %08x\narg1: %08x\narg2: %08x\narg3: %08x\n",
tmp[0], tmp[1], tmp[2], tmp[3]);
return 0;
}
void dumpRange(const char *name, void *start, int len)
{
sceIoMkdir("ms0:/Dump", 0777);
sprintf(lstr, "ms0:/Dump/%s.bin", name);
int fd = sceIoOpen(lstr, PSP_O_CREAT | PSP_O_TRUNC | PSP_O_RDWR, 0777);
sceIoWrite(fd, start, len);
sceIoClose(fd);
}
void dumpKmem()
{
dumpRange("kmem", (void *)0x88000000, 0x00400000);
}
void dumpUmem()
{
dumpRange("umem", (void *)0x08800000, 0x01800000);
}
void dumpThreadList()
{
int t_ids[100], t_count, i;
memset(t_ids, 0, 400);
sceKernelGetThreadmanIdList(SCE_KERNEL_TMID_Thread, t_ids, 400, &t_count);
log("%d thread found!\n", t_count);
for (i = 0; i < t_count; i++)
{
SceKernelThreadInfo info;
memset(&info, 0, sizeof(SceKernelThreadInfo));
info.size = sizeof(SceKernelThreadInfo);
if (sceKernelReferThreadStatus(t_ids[i], &info) == 0)
{
log("thread id %08x name %s\n", t_ids[i], info.name);
}
}
}
void dumpModuleList()
{
int m_ids[100], m_count, i;
memset(m_ids, 0, 400);
sceKernelGetModuleIdList(m_ids, 400, &m_count);
log("%d module found!\n", m_count);
for (i = 0; i < m_count; i++)
{
tSceModule *pMod = (tSceModule *)sceKernelFindModuleByUID(m_ids[i]);
if (pMod)
log("module id %08x name %s\n", m_ids[i], pMod->modname);
}
}
void dumpMemPartitionInfo()
{
int i;
for (i = 1; i < 6; i++)
{
PspSysmemPartitionInfo info;
memset(&info, 0, sizeof(PspSysmemPartitionInfo));
info.size = sizeof(PspSysmemPartitionInfo);
sceKernelQueryMemoryPartitionInfo(i, &info);
log("partition %d start %08x size %08x free %08x attr %x\n", i, info.startaddr, info.memsize, sceKernelPartitionTotalFreeMemSize(i), info.attr);
}
}
#endif