diff --git a/Playstation/Build/pkg/sce_sys/param.sfo b/Playstation/Build/pkg/sce_sys/param.sfo index d1b8ac1..057445e 100644 Binary files a/Playstation/Build/pkg/sce_sys/param.sfo and b/Playstation/Build/pkg/sce_sys/param.sfo differ diff --git a/Playstation/OrbisLibAPI/Events.cpp b/Playstation/OrbisLibAPI/Events.cpp index 87231be..4bd9690 100644 --- a/Playstation/OrbisLibAPI/Events.cpp +++ b/Playstation/OrbisLibAPI/Events.cpp @@ -69,34 +69,53 @@ OrbisNetId Events::Connect(OrbisNetInAddr_t HostAddress) // Create socket. auto sock = sceNetSocket("SendEventSock", ORBIS_NET_AF_INET, ORBIS_NET_SOCK_STREAM, ORBIS_NET_IPPROTO_TCP); + if (sock < 0) + { + klog("Events::Connect() Failed to allocate sock: %llX %llX\n", sock, *sceNetErrnoLoc()); + return NULL; + } + + int nopipe = 1; + sceNetSetsockopt(sock, ORBIS_NET_SOL_SOCKET, ORBIS_NET_SO_NOSIGPIPE, &nopipe, sizeof(nopipe)); // Set connection time out to 4s. int sock_timeout = 4000000; sceNetSetsockopt(sock, ORBIS_NET_SOL_SOCKET, ORBIS_NET_SO_CONNECTTIMEO, &sock_timeout, sizeof(sock_timeout)); + sceNetSetsockopt(sock, ORBIS_NET_SOL_SOCKET, ORBIS_NET_SO_SNDTIMEO, &sock_timeout, sizeof(sock_timeout)); + sceNetSetsockopt(sock, ORBIS_NET_SOL_SOCKET, ORBIS_NET_SO_RCVTIMEO, &sock_timeout, sizeof(sock_timeout)); auto res = sceNetConnect(sock, (OrbisNetSockaddr*)&addr, sizeof(addr)); if (!res) return sock; else { - klog("Events::Connect() Error: %llX\n", res); + klog("Events::Connect() sceNetConnect(): %llX %llX\n", res, *sceNetErrnoLoc()); return NULL; } } void Events::SendEvent(int EventId, int pid) { + klog("SendEvent()\n"); + if (HostList.empty()) + { + klog("SendEvent(): Host List Empty :(\n"); return; + } for (const auto& host : HostList) { + klog("SendEvent(): Sending for host %i.%i.%i.%i\n", host & 0xFF, (host >> 8) & 0xFF, (host >> 16) & 0xFF, (host >> 24) & 0xFF); + // Aquire a lock for the list. scePthreadMutexLock(&HostListMutex); auto sock = Connect(host); if (sock) { + klog("Sending Event: %i\n", EventId); + // Send EventId Sockets::SendInt(sock, EventId); @@ -105,11 +124,16 @@ void Events::SendEvent(int EventId, int pid) Sockets::SendInt(sock, pid); } + // Close the socket. + sceNetSocketClose(sock); + // Revoke the lock on the list. scePthreadMutexUnlock(&HostListMutex); } else { + klog("SendEvent(): Failed to connect to host %i.%i.%i.%i\n", host & 0xFF, (host >> 8) & 0xFF, (host >> 16) & 0xFF, (host >> 24) & 0xFF); + // Revoke the lock on the list. scePthreadMutexUnlock(&HostListMutex); diff --git a/Playstation/OrbisLibAPI/Version.h b/Playstation/OrbisLibAPI/Version.h index 3035a77..cce5f40 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 1089 -#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 1117 +#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/Playstation/OrbisLibAPI/main.cpp b/Playstation/OrbisLibAPI/main.cpp index 5a3812b..9afdf21 100644 --- a/Playstation/OrbisLibAPI/main.cpp +++ b/Playstation/OrbisLibAPI/main.cpp @@ -6,6 +6,18 @@ #include #include "ThreadPool.h" +typedef unsigned char vm_prot_t; /* protection codes */ + +#define VM_PROT_NONE ((vm_prot_t) 0x00) +#define VM_PROT_READ ((vm_prot_t) 0x01) +#define VM_PROT_WRITE ((vm_prot_t) 0x02) +#define VM_PROT_EXECUTE ((vm_prot_t) 0x04) +#define VM_PROT_COPY ((vm_prot_t) 0x08) /* copy-on-read */ + +#define VM_PROT_ALL (VM_PROT_READ|VM_PROT_WRITE|VM_PROT_EXECUTE) +#define VM_PROT_RW (VM_PROT_READ|VM_PROT_WRITE) +#define VM_PROT_DEFAULT VM_PROT_ALL + void exiting() { klog("Good bye friends! :)\n"); @@ -41,21 +53,24 @@ int main() return 0; } + // Call cleanup on exit. + // TODO: Find working way to handle this. + // Copy back up of sflash so we can read it and not break things :) CopySflash(); - + // Set the Name of this process so it shows up as something other than eboot.bin. sceKernelSetProcessName("OrbisLibAPI"); - + // Log the loaded version string. klog("\n%s\n\n", ORBISLIB_BUILDSTRING); - + // Start up the thread pool. - ThreadPool::Init(100); - + ThreadPool::Init(50); + // Init a thread to monitor the system usage stats. // SystemMonitor::Init(); - + // Set up the events. if (!Events::Init()) { diff --git a/Windows/Installer/BootstrapperSetup/Version.wxi b/Windows/Installer/BootstrapperSetup/Version.wxi index de76ea6..e5ce901 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 a670298..6765905 100644 --- a/Windows/Installer/DummyInstaller/Generated/OrbisLibraryManager.wxs +++ b/Windows/Installer/DummyInstaller/Generated/OrbisLibraryManager.wxs @@ -7,25 +7,25 @@ - + - + - + - + - + - + - + @@ -52,82 +52,82 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -154,34 +154,34 @@ - + - + - + - + - + - + - + - + - + - + @@ -336,110 +336,110 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + diff --git a/Windows/Installer/DummyInstaller/Generated/OrbisNeighborhood.wxs b/Windows/Installer/DummyInstaller/Generated/OrbisNeighborhood.wxs index 79fb1b4..b56bb0a 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 286603d..4d9faec 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 4e609c6..d2aa086 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/Libraries/OrbisLib2/Common/Helpers/Listener.cs b/Windows/Libraries/OrbisLib2/Common/Helpers/Listener.cs index 9d611de..8f0ed0f 100644 --- a/Windows/Libraries/OrbisLib2/Common/Helpers/Listener.cs +++ b/Windows/Libraries/OrbisLib2/Common/Helpers/Listener.cs @@ -35,10 +35,9 @@ namespace OrbisLib2.Common.Helpers //Bind Socket to Port and Listen with a backlog of 100. s_Listener.Bind(new IPEndPoint(0, Port)); - s_Listener.Listen(1000); + s_Listener.Listen(100); //Call BeginAccept with our call back so on every accept of a new socket connection the call back is called. - s_Listener.BeginAccept(CallBack, null); Listening = true; } diff --git a/Windows/OrbisNeighborHood/Resources/BuildNumber.txt b/Windows/OrbisNeighborHood/Resources/BuildNumber.txt index 1c4c2de..799fc49 100644 --- a/Windows/OrbisNeighborHood/Resources/BuildNumber.txt +++ b/Windows/OrbisNeighborHood/Resources/BuildNumber.txt @@ -1 +1 @@ -2634 +2636 diff --git a/Windows/OrbisNeighborHood/Resources/BuildString.txt b/Windows/OrbisNeighborHood/Resources/BuildString.txt index e68d4c8..ec7efa8 100644 --- a/Windows/OrbisNeighborHood/Resources/BuildString.txt +++ b/Windows/OrbisNeighborHood/Resources/BuildString.txt @@ -1 +1 @@ -Version 3.0.2634 Release Build Thursday February 16 2023 9:30 PM +Version 3.0.2636 Release Build Friday February 17 2023 7:35 PM diff --git a/Windows/OrbisSuiteService/OrbisSuiteService.csproj b/Windows/OrbisSuiteService/OrbisSuiteService.csproj index 6c7f95f..f02b554 100644 --- a/Windows/OrbisSuiteService/OrbisSuiteService.csproj +++ b/Windows/OrbisSuiteService/OrbisSuiteService.csproj @@ -8,6 +8,18 @@ OrbisTaskbarApp.ico + + + 0 + 1 + 58fbcf7c-e7a9-467c-80b3-fc65e8fcca08 + 0 + tlbimp + false + true + + + diff --git a/Windows/OrbisSuiteService/Program.cs b/Windows/OrbisSuiteService/Program.cs index 41d8c39..bd1cdbc 100644 --- a/Windows/OrbisSuiteService/Program.cs +++ b/Windows/OrbisSuiteService/Program.cs @@ -2,6 +2,8 @@ using System.ServiceProcess; using Microsoft.Extensions.Logging; using Microsoft.Extensions.DependencyInjection; +using NetFwTypeLib; +using OrbisLib2.Common; #if DEBUG var service = new Service(); @@ -36,9 +38,30 @@ class Service : ServiceBase public void OnStartPublic(string[] args) { + // setup up rule in firewall for event listener. + INetFwPolicy2 firewallPolicy = (INetFwPolicy2)Activator.CreateInstance(Type.GetTypeFromProgID("HNetCfg.FwPolicy2")); + List firewallRules = firewallPolicy.Rules.OfType().Where(x => x.Name.Contains("OrbisSuiteEvents")).ToList(); + + // Only add the rule when it does not exist. + if(firewallRules.Count <= 0) + { + INetFwRule firewallRule = (INetFwRule)Activator.CreateInstance(Type.GetTypeFromProgID("HNetCfg.FWRule")); + firewallRule.Action = NET_FW_ACTION_.NET_FW_ACTION_ALLOW; + firewallRule.Description = "Allow for events to be sent from target PS4 to windows service."; + firewallRule.Direction = NET_FW_RULE_DIRECTION_.NET_FW_RULE_DIR_IN; + firewallRule.Enabled = true; + firewallRule.InterfaceTypes = "All"; + firewallRule.Name = "OrbisSuiteEvents"; + firewallRule.Protocol = (int)NET_FW_IP_PROTOCOL_.NET_FW_IP_PROTOCOL_TCP; + firewallRule.LocalPorts = Config.EventPort.ToString(); + firewallPolicy.Rules.Add(firewallRule); + } + + // Create logger instance. var logger = _serviceProvider.GetService() .AddFile(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) + @"\Orbis Suite\Logging\OrbisServiceLog.txt") .CreateLogger(); + var dp = new Dispatcher(logger); #if DEBUG while (RunService) { Thread.Sleep(10); }