diff --git a/Core/HLE/sceKernelModule.cpp b/Core/HLE/sceKernelModule.cpp index 918c4727af..d783fa7f50 100644 --- a/Core/HLE/sceKernelModule.cpp +++ b/Core/HLE/sceKernelModule.cpp @@ -837,6 +837,10 @@ void sceKernelStartModule(u32 moduleId, u32 argsize, u32 argAddr, u32 returnValu entryAddr = module->nm.module_start_func; // attr = module->nm } + + SceUID threadID = __KernelCreateThread(module->nm.name, moduleId, entryAddr, priority, stacksize, attr, 0); + sceKernelStartThread(threadID, argsize, argAddr); + sceKernelWaitThreadEnd(threadID, 0); } //SceUID threadId; diff --git a/Core/HLE/sceKernelThread.cpp b/Core/HLE/sceKernelThread.cpp index 378ff87dbc..a67a81d99e 100644 --- a/Core/HLE/sceKernelThread.cpp +++ b/Core/HLE/sceKernelThread.cpp @@ -1357,8 +1357,7 @@ void __KernelSetupRootThread(SceUID moduleID, int args, const char *argp, int pr Memory::Write_U8(argp[i], location + i); } - -int sceKernelCreateThread(const char *threadName, u32 entry, u32 prio, int stacksize, u32 attr, u32 optionAddr) +int __KernelCreateThread(const char *threadName, SceUID moduleID, u32 entry, u32 prio, int stacksize, u32 attr, u32 optionAddr) { if (threadName == NULL) { @@ -1382,13 +1381,21 @@ int sceKernelCreateThread(const char *threadName, u32 entry, u32 prio, int stack attr |= PSP_THREAD_ATTR_USER; SceUID id; - __KernelCreateThread(id, curModule, threadName, entry, prio, stacksize, attr); + __KernelCreateThread(id, moduleID, threadName, entry, prio, stacksize, attr); INFO_LOG(HLE, "%i = sceKernelCreateThread(name=\"%s\", entry=%08x, prio=%x, stacksize=%i)", id, threadName, entry, prio, stacksize); if (optionAddr != 0) WARN_LOG(HLE, "sceKernelCreateThread(name=\"%s\"): unsupported options parameter %08x", threadName, optionAddr); return id; } +int sceKernelCreateThread(const char *threadName, u32 entry, u32 prio, int stacksize, u32 attr, u32 optionAddr) +{ + SceUID moduleId = curModule; + if (__GetCurrentThread()) + moduleId = __GetCurrentThread()->moduleId; + return __KernelCreateThread(threadName, moduleId, entry, prio, stacksize, attr, optionAddr); +} + // int sceKernelStartThread(SceUID threadToStartID, SceSize argSize, void *argBlock) int sceKernelStartThread(SceUID threadToStartID, u32 argSize, u32 argBlockPtr) diff --git a/Core/HLE/sceKernelThread.h b/Core/HLE/sceKernelThread.h index c1af7d70d6..9f30374132 100644 --- a/Core/HLE/sceKernelThread.h +++ b/Core/HLE/sceKernelThread.h @@ -26,6 +26,7 @@ void sceKernelChangeThreadPriority(); +int __KernelCreateThread(const char *threadName, SceUID moduleID, u32 entry, u32 prio, int stacksize, u32 attr, u32 optionAddr); int sceKernelCreateThread(const char *threadName, u32 entry, u32 prio, int stacksize, u32 attr, u32 optionAddr); void sceKernelDelayThread(); void sceKernelDelayThreadCB();