mirror of
https://github.com/KytyPS5/KytyPS5.git
synced 2026-10-21 19:36:55 +02:00
kernel: retain modules until their final explicit unload
This commit is contained in:
@@ -1226,6 +1226,7 @@ static KYTY_SYSV_ABI KernelModule KernelLoadStartModule(const char* module_file_
|
||||
|
||||
auto* program = rt->FindProgramByFileName(module_path);
|
||||
if (program != nullptr) {
|
||||
++program->load_count;
|
||||
if (res != nullptr) {
|
||||
*res = OK;
|
||||
}
|
||||
@@ -1240,6 +1241,7 @@ static KYTY_SYSV_ABI KernelModule KernelLoadStartModule(const char* module_file_
|
||||
|
||||
rt->RelocateProgram(program);
|
||||
|
||||
program->load_count = 1;
|
||||
int result = rt->StartModule(program, args, argp, nullptr);
|
||||
|
||||
LOGF("\tmodule_start() result = %d\n", result);
|
||||
@@ -1269,6 +1271,11 @@ static int KYTY_SYSV_ABI KernelStopUnloadModule(KernelModule handle, size_t args
|
||||
|
||||
if (program == nullptr) {
|
||||
LOGF("\tinvalid module handle = %" PRId32 "\n", handle);
|
||||
return KERNEL_ERROR_ESRCH;
|
||||
}
|
||||
|
||||
if (program->load_count > 1) {
|
||||
--program->load_count;
|
||||
return OK;
|
||||
}
|
||||
|
||||
|
||||
@@ -115,6 +115,7 @@ struct Program {
|
||||
|
||||
int32_t unique_id = -1;
|
||||
RuntimeLinker* rt = nullptr;
|
||||
uint32_t load_count = 0; // Successful sceKernelLoadStartModule calls.
|
||||
std::filesystem::path file_name;
|
||||
std::unique_ptr<Elf64> elf;
|
||||
std::unique_ptr<DynamicInfo> dynamic_info;
|
||||
|
||||
Reference in New Issue
Block a user