From b691c43c44ff180d10e7d4a9afc83b98551ff586 Mon Sep 17 00:00:00 2001 From: daoge_cmd <3523206925@qq.com> Date: Sun, 1 Mar 2026 12:16:08 +0800 Subject: Initial commit --- .../HeapInspector/Samples/Hook/HookSample.cpp | 30 ++++ .../Samples/Hook/PS3/HookSample.vcproj | 183 +++++++++++++++++++++ .../Samples/Hook/PS3/HookSample.vcxproj | 72 ++++++++ .../HeapInspector/Samples/Hook/PS3/Main.cpp | 18 ++ .../HeapInspector/Samples/Hook/PS3/Wait.cpp | 6 + 5 files changed, 309 insertions(+) create mode 100644 Minecraft.Client/PS3/PS3Extras/HeapInspector/Samples/Hook/HookSample.cpp create mode 100644 Minecraft.Client/PS3/PS3Extras/HeapInspector/Samples/Hook/PS3/HookSample.vcproj create mode 100644 Minecraft.Client/PS3/PS3Extras/HeapInspector/Samples/Hook/PS3/HookSample.vcxproj create mode 100644 Minecraft.Client/PS3/PS3Extras/HeapInspector/Samples/Hook/PS3/Main.cpp create mode 100644 Minecraft.Client/PS3/PS3Extras/HeapInspector/Samples/Hook/PS3/Wait.cpp (limited to 'Minecraft.Client/PS3/PS3Extras/HeapInspector/Samples/Hook') diff --git a/Minecraft.Client/PS3/PS3Extras/HeapInspector/Samples/Hook/HookSample.cpp b/Minecraft.Client/PS3/PS3Extras/HeapInspector/Samples/Hook/HookSample.cpp new file mode 100644 index 00000000..07ad4e20 --- /dev/null +++ b/Minecraft.Client/PS3/PS3Extras/HeapInspector/Samples/Hook/HookSample.cpp @@ -0,0 +1,30 @@ +// ================================================================================================================================= +// This sample demonstrates how to use the auto-hooking functionality of HeapInspector. On PlayStation 3, this uses link-time +// malloc/realloc/free overloading. On PC it uses the mhook API, which will hook into the very low-level HeapAlloc, HeapRealloc +// and HeapFree functions. This will cause any allocations in your application to be caught. +// +// NOTE: the platform specific hooking calls can be found in the Main.cpp. +// ================================================================================================================================= + +#include + +void Wait(int a_MilliSeconds); + +void RunHeapInspectorServer() +{ + while (1) + { + void* mem1; + void* memB; + + mem1 = malloc(16); + memB = malloc(1024); + + Wait(100); + + free(mem1); + free(memB); + + Wait(100); + } +} diff --git a/Minecraft.Client/PS3/PS3Extras/HeapInspector/Samples/Hook/PS3/HookSample.vcproj b/Minecraft.Client/PS3/PS3Extras/HeapInspector/Samples/Hook/PS3/HookSample.vcproj new file mode 100644 index 00000000..a838f008 --- /dev/null +++ b/Minecraft.Client/PS3/PS3Extras/HeapInspector/Samples/Hook/PS3/HookSample.vcproj @@ -0,0 +1,183 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Minecraft.Client/PS3/PS3Extras/HeapInspector/Samples/Hook/PS3/HookSample.vcxproj b/Minecraft.Client/PS3/PS3Extras/HeapInspector/Samples/Hook/PS3/HookSample.vcxproj new file mode 100644 index 00000000..74c78a6a --- /dev/null +++ b/Minecraft.Client/PS3/PS3Extras/HeapInspector/Samples/Hook/PS3/HookSample.vcxproj @@ -0,0 +1,72 @@ + + + + + Debug + PS3 + + + Release + PS3 + + + + + + + + + {F749F5D0-B972-4E99-8B4B-2B865D4A8BC9} + + + + Application + GCC + + + Application + GCC + + + + + + + + + + + + + $(ProjectDir)$(Platform)_$(Configuration)_VS2010\ + $(Platform)_$(Configuration)_VS2010\ + + + $(ProjectDir)$(Platform)_$(Configuration)_VS2010\ + $(Platform)_$(Configuration)_VS2010\ + + + + _DEBUG;__CELL_ASSERT__;%(PreprocessorDefinitions);;HEAPINSPECTOR_PS3=1 + true + + + "$(SCE_PS3_ROOT)\target\ppu\lib\libm.a";"$(SCE_PS3_ROOT)\target\ppu\lib\libio_stub.a";"..\..\..\Server\PS3\Debug\libHeapInspectorServer.a";"$(SCE_PS3_ROOT)\target\ppu\lib\libpthread.a";"$(SCE_PS3_ROOT)\target\ppu\lib\libnet_stub.a";"$(SCE_PS3_ROOT)\target\ppu\lib\libsysmodule_stub.a";%(AdditionalDependencies) + -Wl,--wrap=malloc,--wrap=free,--wrap=calloc,--wrap=memalign,--wrap=realloc,--wrap=reallocalign,--wrap=_malloc_init %(AdditionalOptions) + + + + + NDEBUG;%(PreprocessorDefinitions);;HEAPINSPECTOR_PS3=1 + Level2 + + + "..\..\..\Server\PS3\Release\libHeapInspectorServer.a";"$(SCE_PS3_ROOT)\target\ppu\lib\libpthread.a";"$(SCE_PS3_ROOT)\target\ppu\lib\libnet_stub.a";"$(SCE_PS3_ROOT)\target\ppu\lib\libsysmodule_stub.a";%(AdditionalDependencies) + -Wl,--wrap=malloc,--wrap=free,--wrap=calloc,--wrap=memalign,--wrap=realloc,--wrap=reallocalign,--wrap=_malloc_init %(AdditionalOptions) + + + + + + + \ No newline at end of file diff --git a/Minecraft.Client/PS3/PS3Extras/HeapInspector/Samples/Hook/PS3/Main.cpp b/Minecraft.Client/PS3/PS3Extras/HeapInspector/Samples/Hook/PS3/Main.cpp new file mode 100644 index 00000000..e3417e42 --- /dev/null +++ b/Minecraft.Client/PS3/PS3Extras/HeapInspector/Samples/Hook/PS3/Main.cpp @@ -0,0 +1,18 @@ +#include "../../../Server/HeapInspectorServer.h" +#include "../../../Server/PS3/HeapHooks.hpp" + +void RunHeapInspectorServer(); + +extern "C" void* __real__malloc_init(); +extern "C" void* __wrap__malloc_init() +{ + void* result = __real__malloc_init(); + Initialise(HeapInspectorServer::GetDefaultHeapInfo(), 3000, HeapInspectorServer::WaitForConnection_Enabled); + return result; +} + +int main(int /*a_ArgC*/, const char* /*a_ArgV[]*/) +{ + RunHeapInspectorServer(); + HeapInspectorServer::Shutdown(); +} diff --git a/Minecraft.Client/PS3/PS3Extras/HeapInspector/Samples/Hook/PS3/Wait.cpp b/Minecraft.Client/PS3/PS3Extras/HeapInspector/Samples/Hook/PS3/Wait.cpp new file mode 100644 index 00000000..2c436c84 --- /dev/null +++ b/Minecraft.Client/PS3/PS3Extras/HeapInspector/Samples/Hook/PS3/Wait.cpp @@ -0,0 +1,6 @@ +#include + +void Wait(int a_Milliseconds) +{ + sys_timer_usleep(a_Milliseconds * 1000); +} \ No newline at end of file -- cgit v1.2.3