diff --git a/.gitignore b/.gitignore index 5ad4c9d..bae3f14 100644 --- a/.gitignore +++ b/.gitignore @@ -15,3 +15,5 @@ mods/ *.orig Debug Portable/ BuildPS4/ +ORBIS_Debug/ +Prospero_Debug/ diff --git a/Assets/Plugins/orbis/SceKernelShim.prx b/Assets/Plugins/orbis/SceKernelShim.prx new file mode 100644 index 0000000..08f0efd Binary files /dev/null and b/Assets/Plugins/orbis/SceKernelShim.prx differ diff --git a/Assets/Plugins/orbis/SceKernelShim.prx.meta b/Assets/Plugins/orbis/SceKernelShim.prx.meta new file mode 100644 index 0000000..e6b1b95 --- /dev/null +++ b/Assets/Plugins/orbis/SceKernelShim.prx.meta @@ -0,0 +1,77 @@ +fileFormatVersion: 2 +guid: 1979846846ce98c448853c7141a0171e +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + defineConstraints: [] + isPreloaded: 0 + isOverridable: 0 + isExplicitlyReferenced: 0 + validateReferences: 1 + platformData: + - first: + : Any + second: + enabled: 0 + settings: + Exclude Editor: 1 + Exclude GameCoreScarlett: 1 + Exclude GameCoreXboxOne: 1 + Exclude Linux64: 1 + Exclude OSXUniversal: 1 + Exclude PS4: 0 + Exclude PS5: 1 + Exclude Win: 1 + Exclude Win64: 1 + - first: + Any: + second: + enabled: 0 + settings: {} + - first: + Editor: Editor + second: + enabled: 0 + settings: + CPU: AnyCPU + DefaultValueInitialized: true + OS: AnyOS + - first: + PS4: PS4 + second: + enabled: 1 + settings: {} + - first: + PS5: PS5 + second: + enabled: 0 + settings: {} + - first: + Standalone: Linux64 + second: + enabled: 0 + settings: + CPU: None + - first: + Standalone: OSXUniversal + second: + enabled: 0 + settings: + CPU: None + - first: + Standalone: Win + second: + enabled: 0 + settings: + CPU: x86 + - first: + Standalone: Win64 + second: + enabled: 0 + settings: + CPU: x86_64 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/SystemLibrary.cs b/Assets/Scripts/SystemLibrary.cs index 6064e54..e1c93f3 100644 --- a/Assets/Scripts/SystemLibrary.cs +++ b/Assets/Scripts/SystemLibrary.cs @@ -26,23 +26,31 @@ public static class SystemLibrary [DllImport("kernel32")] public static extern IntPtr GetProcAddress(IntPtr hModule, string procedureName); -#else +#elif UNITY_PS4 || UNITY_PS5 + [DllImport("SceKernelShim.prx", EntryPoint = "LoadLibrary")] + private static extern Int32 LoadLibraryNative(string filename); + public static IntPtr LoadLibrary(string filename) { - // sceKernelLoadStartModule - return IntPtr.Zero; + Int32 moduleHandle = LoadLibraryNative(filename); + if (moduleHandle <= 0) + { + UnityEngine.Debug.LogError($"Error loading PRX module '{filename}', error code = 0x{moduleHandle:X}"); + return IntPtr.Zero; + } + + return new IntPtr(moduleHandle); } + [DllImport("SceKernelShim.prx", EntryPoint = "FreeLibrary")] + private static extern bool FreeLibraryNative(Int32 moduleHandle); + public static bool FreeLibrary(IntPtr hModule) { - // sceKernelStopUnloadModule - return false; + return FreeLibraryNative(hModule.ToInt32()); } - public static IntPtr GetProcAddress(IntPtr hModule, string procedureName) - { - // sceKernelDlsym - return IntPtr.Zero; - } + [DllImport("SceKernelShim.psx")] + public static extern IntPtr GetProcAddress(IntPtr hModule, string procedureName); #endif } diff --git a/engine/SceKernelShim/SceKernelShim.sln b/engine/SceKernelShim/SceKernelShim.sln new file mode 100644 index 0000000..0597ad1 --- /dev/null +++ b/engine/SceKernelShim/SceKernelShim.sln @@ -0,0 +1,31 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.28307.1433 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SceKernelShim", "SceKernelShim.vcxproj", "{4587A77D-1FD8-4A92-9D11-26545047C1D1}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|ORBIS = Debug|ORBIS + Debug|Prospero = Debug|Prospero + Release|ORBIS = Release|ORBIS + Release|Prospero = Release|Prospero + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {4587A77D-1FD8-4A92-9D11-26545047C1D1}.Debug|ORBIS.ActiveCfg = Debug|ORBIS + {4587A77D-1FD8-4A92-9D11-26545047C1D1}.Debug|ORBIS.Build.0 = Debug|ORBIS + {4587A77D-1FD8-4A92-9D11-26545047C1D1}.Debug|Prospero.ActiveCfg = Debug|Prospero + {4587A77D-1FD8-4A92-9D11-26545047C1D1}.Debug|Prospero.Build.0 = Debug|Prospero + {4587A77D-1FD8-4A92-9D11-26545047C1D1}.Release|ORBIS.ActiveCfg = Release|ORBIS + {4587A77D-1FD8-4A92-9D11-26545047C1D1}.Release|ORBIS.Build.0 = Release|ORBIS + {4587A77D-1FD8-4A92-9D11-26545047C1D1}.Release|Prospero.ActiveCfg = Release|Prospero + {4587A77D-1FD8-4A92-9D11-26545047C1D1}.Release|Prospero.Build.0 = Release|Prospero + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {5883AE2B-631A-4510-AF53-C0EB35922AA2} + EndGlobalSection +EndGlobal diff --git a/engine/SceKernelShim/SceKernelShim.vcxproj b/engine/SceKernelShim/SceKernelShim.vcxproj new file mode 100644 index 0000000..665bda6 --- /dev/null +++ b/engine/SceKernelShim/SceKernelShim.vcxproj @@ -0,0 +1,106 @@ + + + + + Debug + ORBIS + + + Debug + Prospero + + + Release + ORBIS + + + Release + Prospero + + + + {4587A77D-1FD8-4A92-9D11-26545047C1D1} + + + + DynamicLibrary + + + DynamicLibrary + + + DynamicLibrary + + + DynamicLibrary + + + v141 + + + v141 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + _DEBUG;%(PreprocessorDefinitions); + true + NotUsing + + + + + _DEBUG;%(PreprocessorDefinitions); + true + NotUsing + + + + + NDEBUG;%(PreprocessorDefinitions); + Level2 + NotUsing + + + + + NDEBUG;%(PreprocessorDefinitions); + Level2 + NotUsing + + + + + + + + + + + + \ No newline at end of file diff --git a/engine/SceKernelShim/SceKernelShim.vcxproj.filters b/engine/SceKernelShim/SceKernelShim.vcxproj.filters new file mode 100644 index 0000000..1b47693 --- /dev/null +++ b/engine/SceKernelShim/SceKernelShim.vcxproj.filters @@ -0,0 +1,18 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cxx;cc;s;asm + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hpp + + + + + Source Files + + + \ No newline at end of file diff --git a/engine/SceKernelShim/prx.cpp b/engine/SceKernelShim/prx.cpp new file mode 100644 index 0000000..13b26aa --- /dev/null +++ b/engine/SceKernelShim/prx.cpp @@ -0,0 +1,23 @@ +#include + +#define PRX_EXPORT extern "C" __declspec (dllexport) + +PRX_EXPORT SceKernelModule LoadLibrary(const char *filename) +{ + return sceKernelLoadStartModule(filename, 0, nullptr, 0, nullptr, nullptr); +} + +PRX_EXPORT bool FreeLibrary(SceKernelModule moduleHandle) +{ + return sceKernelStopUnloadModule(moduleHandle, 0, nullptr, 0, nullptr, nullptr) == 0; +} + +PRX_EXPORT void *GetProcAddress(SceKernelModule moduleHandle, const char *procedureName) +{ + void *result; + if (sceKernelDlsym(moduleHandle, procedureName, &result) != 0) + { + return nullptr; + } + return result; +}