Repository navigation
Expand file tree
/
Copy pathModule.cpp
More file actions
83 lines (70 loc) · 2.36 KB
/
Copy pathModule.cpp
File metadata and controls
83 lines (70 loc) · 2.36 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
#include <cstdint>
#include <cstddef>
#include "SceTypes.hpp"
#include "prx/libc/include/General.hpp"
#include "prx/libkernel/DirectMemory/DirectMemory.hpp"
#include "prx/libkernel/KernelErrors.hpp"
extern "C" {
void* APS5_VABI dlopen_nid_postfix(const char* path, int flags);
void* APS5_VABI dlsym_nid_postfix(void* handle, const char* name);
int APS5_VABI dlclose_nid_postfix(void* handle);
}
namespace {
constexpr int kRtldNow = 2;
}
extern "C" {
int APS5_VABI sceKernelDlsym(KernelModule handle, const char* symbol, void** addr) {
if (!symbol || !addr) return SCE_KERNEL_ERROR_EFAULT;
void* found = dlsym_nid_postfix(reinterpret_cast<void*>(static_cast<intptr_t>(handle)), symbol);
if (!found) return SCE_KERNEL_ERROR_ESRCH;
*addr = found;
return 0;
}
int APS5_VABI sceKernelGetModuleInfoForUnwind(uint64_t addr, int flags, ModuleInfoForUnwind* info) {
(void)addr;
(void)flags;
(void)info;
NotImplemented_nid_no_patch(__func__);
return 0;
}
int APS5_VABI sceKernelGetModuleInfoFromAddr(uint64_t addr, int n, ModuleInfo* r) {
(void)addr;
(void)n;
(void)r;
NotImplemented_nid_no_patch(__func__);
return 0;
}
KernelModule APS5_VABI sceKernelLoadStartModule(const char* module_file_name, size_t args, const void* argp, uint32_t flags, const KernelLoadModuleOpt* opt, int* res) {
(void)args;
(void)argp;
(void)flags;
(void)opt;
if (res) *res = 0;
if (!module_file_name) return static_cast<KernelModule>(SCE_KERNEL_ERROR_EFAULT);
void* handle = dlopen_nid_postfix(module_file_name, kRtldNow);
if (!handle) return static_cast<KernelModule>(SCE_KERNEL_ERROR_ENOENT);
return static_cast<KernelModule>(reinterpret_cast<intptr_t>(handle));
}
int APS5_VABI sceKernelStopUnloadModule(KernelModule handle, size_t args, const void* argp, uint32_t flags, const KernelUnloadModuleOpt* opt, int* res) {
(void)args;
(void)argp;
(void)flags;
(void)opt;
if (res) *res = 0;
return dlclose_nid_postfix(reinterpret_cast<void*>(static_cast<intptr_t>(handle))) == 0 ? 0 : SCE_KERNEL_ERROR_ESRCH;
}
}
extern "C" {
int APS5_VABI __elf_phdr_match_addr_nid_postfix(ModuleInfo* module, std::uint64_t address) {
(void)module;
(void)address;
NotImplemented_nid_no_patch(__func__);
return 0;
}
// unknown signature
std::int32_t APS5_VABI sceKernelInternalMemoryGetModuleSegmentInfo_nid_postfix(void* result) {
(void)result;
NotImplemented_nid_no_patch(__func__);
return 0;
}
}