diff --git a/src/core/libraries/kernel/file_system.cpp b/src/core/libraries/kernel/file_system.cpp index 78088d6f..2be96466 100644 --- a/src/core/libraries/kernel/file_system.cpp +++ b/src/core/libraries/kernel/file_system.cpp @@ -13,6 +13,10 @@ namespace Libraries::Kernel { int PS4_SYSV_ABI sceKernelOpen(const char* path, int flags, u16 mode) { LOG_INFO(Kernel_Fs, "path = {} flags = {:#x} mode = {}", path, flags, mode); + if (strcmp(path, "/dev/urandom") == 0 || strcmp(path, "/dev/random") == 0) { + std::srand(std::time(nullptr)); + return 2222; // random hackish descriptor + } auto* h = Common::Singleton::Instance(); auto* mnt = Common::Singleton::Instance(); @@ -75,6 +79,9 @@ int PS4_SYSV_ABI sceKernelClose(int d) { if (d < 3) { // d probably hold an error code return ORBIS_KERNEL_ERROR_EPERM; } + if (d == 2222) { // random / urandom + return SCE_OK; + } auto* h = Common::Singleton::Instance(); auto* file = h->GetFile(d); if (file == nullptr) { @@ -144,6 +151,14 @@ s64 PS4_SYSV_ABI lseek(int d, s64 offset, int whence) { } s64 PS4_SYSV_ABI sceKernelRead(int d, void* buf, size_t nbytes) { + if (d == 2222) { // random / urandom + auto charbuff = static_cast(buf); + + for (size_t i = 0; i < nbytes; i++) + charbuff[i] = std::rand() & 0xFF; + + return nbytes; + } if (buf == nullptr) { return SCE_KERNEL_ERROR_EFAULT; }