From d9b1be5ec4c4d9152754fa16a49331fbd3d02c7a Mon Sep 17 00:00:00 2001 From: Greg Date: Tue, 21 Feb 2023 17:20:41 -0700 Subject: [PATCH] Update to use shared ptr --- Playstation/OrbisLibAPI/API.cpp | 25 +- Playstation/OrbisLibAPI/APIHelper.h | 9 +- Playstation/OrbisLibAPI/Apps.cpp | 2 +- Playstation/OrbisLibAPI/Apps.h | 2 +- Playstation/OrbisLibAPI/Common.h | 1 + Playstation/OrbisLibAPI/Debug.cpp | 2 +- Playstation/OrbisLibAPI/Debug.h | 2 +- Playstation/OrbisLibAPI/Proc.cpp | 2 +- Playstation/OrbisLibAPI/Proc.h | 2 +- Playstation/OrbisLibAPI/Target.cpp | 10 +- Playstation/OrbisLibAPI/Target.h | 2 +- Playstation/OrbisLibAPI/Version.h | 22 +- .../Installer/BootstrapperSetup/Version.wxi | 2 +- .../Generated/OrbisLibraryManager.wxs | 156 +- .../Generated/OrbisNeighborhood.wxs | 2202 ++++++++--------- .../Generated/OrbisPeeknPoke.wxs | 154 +- .../Generated/OrbisSuiteService.wxs | 376 +-- .../Resources/BuildNumber.txt | 2 +- .../Resources/BuildString.txt | 2 +- 19 files changed, 1484 insertions(+), 1491 deletions(-) diff --git a/Playstation/OrbisLibAPI/API.cpp b/Playstation/OrbisLibAPI/API.cpp index 564c562..d464c3d 100644 --- a/Playstation/OrbisLibAPI/API.cpp +++ b/Playstation/OrbisLibAPI/API.cpp @@ -12,20 +12,18 @@ bool API::Running = false; void API::ListenerCallback(void* tdParam, OrbisNetId s, OrbisNetInAddr sin_addr) { // Deserialize the packet. - auto Packet = RecievePacket(s); + auto packet = RecievePacket(s); // Did we recieve a packet? - if (Packet == nullptr) + if (packet == nullptr) { return; } // Validate Packet - if (strcmp(Packet->PacketMagic, "ORBIS_SUITE") || Packet->PacketVersion != PACKET_VERSION) + if (strcmp(packet->PacketMagic, "ORBIS_SUITE") || packet->PacketVersion != PACKET_VERSION) { - klog("Invalid Packet with Magic '%s' and Version %i\nExpected 'ORBIS_SUITE' and %i\n", Packet->PacketMagic, Packet->PacketVersion, PACKET_VERSION); - - free(Packet); + klog("Invalid Packet with Magic '%s' and Version %i\nExpected 'ORBIS_SUITE' and %i\n", packet->PacketMagic, packet->PacketVersion, PACKET_VERSION); return; } @@ -39,22 +37,22 @@ void API::ListenerCallback(void* tdParam, OrbisNetId s, OrbisNetInAddr sin_addr) Events::AddHost(sin_addr.s_addr); // Send out the command to the right places. - switch (Packet->Command) + switch (packet->Command) { default: - klog("API: Invalid Command %i...\n", Packet->Command); + klog("API: Invalid Command %i...\n", packet->Command); break; case APICommands::PROC_START ... APICommands::PROC_END: - Proc->HandleAPI(s, Packet); + Proc->HandleAPI(s, packet); break; case APICommands::APP_START ... APICommands::APP_END: - Apps->HandleAPI(s, Packet); + Apps->HandleAPI(s, packet); break; case APICommands::DBG_START ... APICommands::DBG_END: - Debug->HandleAPI(s, Packet); + Debug->HandleAPI(s, packet); break; case APICommands::KERN_START ... APICommands::KERN_END: @@ -63,13 +61,10 @@ void API::ListenerCallback(void* tdParam, OrbisNetId s, OrbisNetInAddr sin_addr) break; case APICommands::TARGET_START ... APICommands::TARGET_END: - Target->HandleAPI(s, Packet); + Target->HandleAPI(s, packet); break; } - - // Clean up. :) - free(Packet); } void API::Init() diff --git a/Playstation/OrbisLibAPI/APIHelper.h b/Playstation/OrbisLibAPI/APIHelper.h index ca8f8cf..141c839 100644 --- a/Playstation/OrbisLibAPI/APIHelper.h +++ b/Playstation/OrbisLibAPI/APIHelper.h @@ -4,18 +4,17 @@ void SendStatus(OrbisNetId Sock, int status); int RecieveInt(OrbisNetId Sock); -template T* RecievePacket(OrbisNetId Sock) +template std::shared_ptr RecievePacket(OrbisNetId Sock) { - auto Packet = (T*)malloc(sizeof(T)); + auto packet = std::make_shared(); - if (sceNetRecv(Sock, Packet, sizeof(T), 0) < 0) + if (sceNetRecv(Sock, packet.get(), sizeof(T), 0) < 0) { SendStatus(Sock, APIResults::API_ERROR_GENERAL); - free(Packet); return nullptr; } SendStatus(Sock, APIResults::API_OK); - return Packet; + return packet; } \ No newline at end of file diff --git a/Playstation/OrbisLibAPI/Apps.cpp b/Playstation/OrbisLibAPI/Apps.cpp index 9f8246d..ec45fdf 100644 --- a/Playstation/OrbisLibAPI/Apps.cpp +++ b/Playstation/OrbisLibAPI/Apps.cpp @@ -6,7 +6,7 @@ #include #include -void Apps::HandleAPI(OrbisNetId Sock, APIPacket* Packet) +void Apps::HandleAPI(OrbisNetId Sock, std::shared_ptr Packet) { char titleId[10]; memset(titleId, 0, sizeof(titleId)); diff --git a/Playstation/OrbisLibAPI/Apps.h b/Playstation/OrbisLibAPI/Apps.h index 6b53895..7aab03d 100644 --- a/Playstation/OrbisLibAPI/Apps.h +++ b/Playstation/OrbisLibAPI/Apps.h @@ -8,7 +8,7 @@ public: Apps(); ~Apps(); - void HandleAPI(OrbisNetId Sock, APIPacket* Packet); + void HandleAPI(OrbisNetId Sock, std::shared_ptr Packet); private: void CheckDBVersion(OrbisNetId Sock); diff --git a/Playstation/OrbisLibAPI/Common.h b/Playstation/OrbisLibAPI/Common.h index 37dc09b..1c53e6c 100644 --- a/Playstation/OrbisLibAPI/Common.h +++ b/Playstation/OrbisLibAPI/Common.h @@ -28,6 +28,7 @@ #include #include #include +#include #include "Config.h" #include "SocketListener.h" diff --git a/Playstation/OrbisLibAPI/Debug.cpp b/Playstation/OrbisLibAPI/Debug.cpp index bf7926b..4e78b3d 100644 --- a/Playstation/OrbisLibAPI/Debug.cpp +++ b/Playstation/OrbisLibAPI/Debug.cpp @@ -8,7 +8,7 @@ #define HelperPrxPath "/data/Orbis Suite/OrbisLibGeneralHelper.sprx" -void Debug::HandleAPI(OrbisNetId Sock, APIPacket* Packet) +void Debug::HandleAPI(OrbisNetId Sock, std::shared_ptr Packet) { if (Packet->Command > API_DBG_GET_CURRENT) { diff --git a/Playstation/OrbisLibAPI/Debug.h b/Playstation/OrbisLibAPI/Debug.h index 1c1b2ae..3d22857 100644 --- a/Playstation/OrbisLibAPI/Debug.h +++ b/Playstation/OrbisLibAPI/Debug.h @@ -10,7 +10,7 @@ public: Debug(); ~Debug(); - void HandleAPI(OrbisNetId Sock, APIPacket* Packet); + void HandleAPI(OrbisNetId Sock, std::shared_ptr Packet); private: bool TryDetach(int pid); diff --git a/Playstation/OrbisLibAPI/Proc.cpp b/Playstation/OrbisLibAPI/Proc.cpp index 541e197..8dd8306 100644 --- a/Playstation/OrbisLibAPI/Proc.cpp +++ b/Playstation/OrbisLibAPI/Proc.cpp @@ -2,7 +2,7 @@ #include "Proc.h" #include "APIHelper.h" -void Proc::HandleAPI(OrbisNetId Sock, APIPacket* Packet) +void Proc::HandleAPI(OrbisNetId Sock, std::shared_ptr Packet) { switch (Packet->Command) { diff --git a/Playstation/OrbisLibAPI/Proc.h b/Playstation/OrbisLibAPI/Proc.h index 9427b04..ac49d18 100644 --- a/Playstation/OrbisLibAPI/Proc.h +++ b/Playstation/OrbisLibAPI/Proc.h @@ -5,7 +5,7 @@ class Proc public: Proc(); ~Proc(); - void HandleAPI(OrbisNetId Sock, APIPacket* Packet); + void HandleAPI(OrbisNetId Sock, std::shared_ptr Packet); void SendProcessList(OrbisNetId Sock); diff --git a/Playstation/OrbisLibAPI/Target.cpp b/Playstation/OrbisLibAPI/Target.cpp index 218508b..3ad452a 100644 --- a/Playstation/OrbisLibAPI/Target.cpp +++ b/Playstation/OrbisLibAPI/Target.cpp @@ -3,8 +3,9 @@ #include "APIHelper.h" #include "Debug.h" #include +#include -void Target::HandleAPI(OrbisNetId Sock, APIPacket* Packet) +void Target::HandleAPI(OrbisNetId Sock, std::shared_ptr Packet) { switch (Packet->Command) { @@ -79,8 +80,7 @@ Target::~Target() void Target::SendTargetInfo(OrbisNetId Sock) { - auto Packet = (TargetInfoPacket*)malloc(sizeof(TargetInfoPacket)); - memset(Packet, 0, sizeof(TargetInfoPacket)); + auto Packet = std::make_unique(); Packet->SDKVersion = GetSDKVersion(); Packet->SoftwareVersion = GetUpdateVersion(); @@ -148,9 +148,7 @@ void Target::SendTargetInfo(OrbisNetId Sock) memcpy(&Packet->Ram, &SystemMonitor::RAM, sizeof(MemoryInfo)); memcpy(&Packet->VRam, &SystemMonitor::VRAM, sizeof(MemoryInfo));*/ - sceNetSend(Sock, Packet, sizeof(TargetInfoPacket), 0); - - free(Packet); + sceNetSend(Sock, Packet.get(), sizeof(TargetInfoPacket), 0); } void Target::DoNotify(OrbisNetId Sock) diff --git a/Playstation/OrbisLibAPI/Target.h b/Playstation/OrbisLibAPI/Target.h index b03f491..349d220 100644 --- a/Playstation/OrbisLibAPI/Target.h +++ b/Playstation/OrbisLibAPI/Target.h @@ -7,7 +7,7 @@ class Target public: Target(Debug* Debug); ~Target(); - void HandleAPI(OrbisNetId Sock, APIPacket* Packet); + void HandleAPI(OrbisNetId Sock, std::shared_ptr Packet); void SendTargetInfo(OrbisNetId Sock); void DoNotify(OrbisNetId Sock); diff --git a/Playstation/OrbisLibAPI/Version.h b/Playstation/OrbisLibAPI/Version.h index f745c51..abb779b 100644 --- a/Playstation/OrbisLibAPI/Version.h +++ b/Playstation/OrbisLibAPI/Version.h @@ -1,11 +1,11 @@ -#pragma once -#define ORBISLIB_MAJOR 3 -#define ORBISLIB_MINOR 0 -#define ORBISLIB_BUILDVERSION 1165 -#define stringify(a) stringify_(a) -#define stringify_(a) #a -#if defined(_DEBUG) -#define ORBISLIB_BUILDSTRING ("[OrbisLib Daemon " stringify(ORBISLIB_MAJOR) "." stringify(ORBISLIB_MINOR) "] Dev Build " stringify(ORBISLIB_BUILDVERSION) " " __DATE__ " " __TIME__) -#else -#define ORBISLIB_BUILDSTRING ("[OrbisLib Daemon " stringify(ORBISLIB_MAJOR) "." stringify(ORBISLIB_MINOR) "] Build " stringify(ORBISLIB_BUILDVERSION) " " __DATE__ " " __TIME__) -#endif +#pragma once +#define ORBISLIB_MAJOR 3 +#define ORBISLIB_MINOR 0 +#define ORBISLIB_BUILDVERSION 1169 +#define stringify(a) stringify_(a) +#define stringify_(a) #a +#if defined(_DEBUG) +#define ORBISLIB_BUILDSTRING ("[OrbisLib Daemon " stringify(ORBISLIB_MAJOR) "." stringify(ORBISLIB_MINOR) "] Dev Build " stringify(ORBISLIB_BUILDVERSION) " " __DATE__ " " __TIME__) +#else +#define ORBISLIB_BUILDSTRING ("[OrbisLib Daemon " stringify(ORBISLIB_MAJOR) "." stringify(ORBISLIB_MINOR) "] Build " stringify(ORBISLIB_BUILDVERSION) " " __DATE__ " " __TIME__) +#endif diff --git a/Windows/Installer/BootstrapperSetup/Version.wxi b/Windows/Installer/BootstrapperSetup/Version.wxi index 6810cc6..8cd37b3 100644 --- a/Windows/Installer/BootstrapperSetup/Version.wxi +++ b/Windows/Installer/BootstrapperSetup/Version.wxi @@ -2,5 +2,5 @@ - + diff --git a/Windows/Installer/DummyInstaller/Generated/OrbisLibraryManager.wxs b/Windows/Installer/DummyInstaller/Generated/OrbisLibraryManager.wxs index a63594f..f2594e4 100644 --- a/Windows/Installer/DummyInstaller/Generated/OrbisLibraryManager.wxs +++ b/Windows/Installer/DummyInstaller/Generated/OrbisLibraryManager.wxs @@ -7,25 +7,25 @@ - + - + - + - + - + - + - + @@ -52,85 +52,85 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -157,34 +157,34 @@ - + - + - + - + - + - + - + - + - + - + @@ -339,110 +339,110 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + diff --git a/Windows/Installer/DummyInstaller/Generated/OrbisNeighborhood.wxs b/Windows/Installer/DummyInstaller/Generated/OrbisNeighborhood.wxs index d7f9fee..c41dc4f 100644 --- a/Windows/Installer/DummyInstaller/Generated/OrbisNeighborhood.wxs +++ b/Windows/Installer/DummyInstaller/Generated/OrbisNeighborhood.wxs @@ -7,184 +7,184 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -211,211 +211,211 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -570,136 +570,136 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -1790,1424 +1790,1424 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -3362,136 +3362,136 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -4582,1244 +4582,1244 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + diff --git a/Windows/Installer/DummyInstaller/Generated/OrbisPeeknPoke.wxs b/Windows/Installer/DummyInstaller/Generated/OrbisPeeknPoke.wxs index ec57f5e..ddf1b2e 100644 --- a/Windows/Installer/DummyInstaller/Generated/OrbisPeeknPoke.wxs +++ b/Windows/Installer/DummyInstaller/Generated/OrbisPeeknPoke.wxs @@ -7,13 +7,13 @@ - + - + - + @@ -109,25 +109,25 @@ - + - + - + - + - + - + - + @@ -154,103 +154,103 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -405,110 +405,110 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + diff --git a/Windows/Installer/DummyInstaller/Generated/OrbisSuiteService.wxs b/Windows/Installer/DummyInstaller/Generated/OrbisSuiteService.wxs index 9bb8a16..718c600 100644 --- a/Windows/Installer/DummyInstaller/Generated/OrbisSuiteService.wxs +++ b/Windows/Installer/DummyInstaller/Generated/OrbisSuiteService.wxs @@ -7,31 +7,31 @@ - + - + - + - + - + - + - + - + - + @@ -58,97 +58,97 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -175,37 +175,37 @@ - + - + - + - + - + - + - + - + - + - + - + @@ -360,104 +360,104 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -484,43 +484,43 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -1091,280 +1091,280 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + diff --git a/Windows/OrbisNeighborHood/Resources/BuildNumber.txt b/Windows/OrbisNeighborHood/Resources/BuildNumber.txt index 8933964..6642ad1 100644 --- a/Windows/OrbisNeighborHood/Resources/BuildNumber.txt +++ b/Windows/OrbisNeighborHood/Resources/BuildNumber.txt @@ -1 +1 @@ -2694 +2696 diff --git a/Windows/OrbisNeighborHood/Resources/BuildString.txt b/Windows/OrbisNeighborHood/Resources/BuildString.txt index bbc076a..da916da 100644 --- a/Windows/OrbisNeighborHood/Resources/BuildString.txt +++ b/Windows/OrbisNeighborHood/Resources/BuildString.txt @@ -1 +1 @@ -Version 3.0.2694 Release Build Sunday February 19 2023 12:48 AM +Version 3.0.2696 Release Build Monday February 20 2023 9:18 PM