Target Consoles now have events to fire, mutex protection for debugger, Revamp events so they dont need to be re registered & Impliment all events on host side.
This commit is contained in:
+4
-2
@@ -22,6 +22,8 @@ enum GeneralIPCResult
|
||||
|
||||
struct LibPacket
|
||||
{
|
||||
char Path[100];
|
||||
int Handle;
|
||||
uint32_t Handle;
|
||||
char Path[256];
|
||||
int SegmentCount;
|
||||
OrbisKernelModuleSegmentInfo Segments[4];
|
||||
};
|
||||
|
||||
+1
-1
@@ -7,7 +7,7 @@ extern "C"
|
||||
struct LibraryInfo
|
||||
{
|
||||
char Path[256];
|
||||
uint64_t ModuleHandle;
|
||||
uint64_t Handle;
|
||||
uint64_t map_base;
|
||||
size_t map_size;
|
||||
size_t text_size;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include "Common.h"
|
||||
#include "API.h"
|
||||
#include "Events.h"
|
||||
|
||||
Proc* API::Proc;
|
||||
Apps* API::Apps;
|
||||
@@ -8,10 +9,14 @@ Target* API::Target;
|
||||
SocketListener* API::Listener;
|
||||
bool API::Running = false;
|
||||
|
||||
void API::ListenerCallback(void* tdParam, OrbisNetId s)
|
||||
void API::ListenerCallback(void* tdParam, OrbisNetId s, OrbisNetInAddr sin_addr)
|
||||
{
|
||||
// Deserialize the packet.
|
||||
auto Packet = RecievePacket<APIPacket>(s);
|
||||
|
||||
// Add host to the host list.
|
||||
Events::AddHost(sin_addr.s_addr);
|
||||
|
||||
if (Packet != nullptr)
|
||||
{
|
||||
// Make sure were getting the proper packet version.
|
||||
@@ -68,7 +73,7 @@ void API::Init()
|
||||
Apps = new class Apps();
|
||||
Debug = new class Debug();
|
||||
Target = new class Target(Debug);
|
||||
Listener = new SocketListener(ListenerCallback, NULL, 6900);
|
||||
Listener = new SocketListener(ListenerCallback, NULL, API_PORT);
|
||||
Running = true;
|
||||
}
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ private:
|
||||
static Target* Target;
|
||||
static SocketListener* Listener;
|
||||
|
||||
static void ListenerCallback(void* tdParam, OrbisNetId s);
|
||||
static void ListenerCallback(void* tdParam, OrbisNetId s, OrbisNetInAddr sin_addr);
|
||||
|
||||
public:
|
||||
static bool Running;
|
||||
|
||||
@@ -191,9 +191,9 @@ struct AppListPacket
|
||||
|
||||
struct LibraryPacket
|
||||
{
|
||||
int64_t Handle;
|
||||
uint32_t Handle;
|
||||
char Path[256];
|
||||
int32_t SegmentCount;
|
||||
int SegmentCount;
|
||||
OrbisKernelModuleSegmentInfo Segments[4];
|
||||
};
|
||||
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
#include <orbis/ShellCoreUtil.h>
|
||||
#include <orbis/SystemStateMgr.h>
|
||||
|
||||
#include "Config.h"
|
||||
#include "SocketListener.h"
|
||||
#include "Utilities.h"
|
||||
#include "GoldHEN.h"
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
#define API_PORT 6900
|
||||
|
||||
#define EVENT_PORT 6901
|
||||
@@ -2,6 +2,7 @@
|
||||
#include "Debug.h"
|
||||
#include "APIHelper.h"
|
||||
#include "GeneralIPC.h"
|
||||
#include "Events.h"
|
||||
|
||||
#include <sys/ptrace.h>
|
||||
|
||||
@@ -109,11 +110,17 @@ void Debug::Attach(OrbisNetId Sock)
|
||||
char processName[32];
|
||||
sceKernelGetProcessName(pid, processName);
|
||||
|
||||
// Aquire lock.
|
||||
scePthreadMutexLock(&DebugMutex);
|
||||
|
||||
klog("Attempting to attach to %s (%d)\n", processName, pid);
|
||||
|
||||
// If we are currently debugging another process lets detach from it.
|
||||
if (!TryDetach(pid))
|
||||
{
|
||||
// release the lock.
|
||||
scePthreadMutexUnlock(&DebugMutex);
|
||||
|
||||
klog("Attach(): TryDetach Failed. :(\n");
|
||||
SendStatus(Sock, 0);
|
||||
return;
|
||||
@@ -123,6 +130,9 @@ void Debug::Attach(OrbisNetId Sock)
|
||||
int res = ptrace(PT_ATTACH, pid, nullptr, 0);
|
||||
if (res != 0)
|
||||
{
|
||||
// release the lock.
|
||||
scePthreadMutexUnlock(&DebugMutex);
|
||||
|
||||
klog("Attach(): ptrace(PT_ATTACH) failed with error %llX\n", res);
|
||||
SendStatus(Sock, 0);
|
||||
return;
|
||||
@@ -134,14 +144,24 @@ void Debug::Attach(OrbisNetId Sock)
|
||||
res = ptrace(PT_CONTINUE, pid, (void*)1, 0);
|
||||
if (res != 0)
|
||||
{
|
||||
// release the lock.
|
||||
scePthreadMutexUnlock(&DebugMutex);
|
||||
|
||||
klog("Attach(): ptrace(PT_CONTINUE) failed with error %llX\n", res);
|
||||
SendStatus(Sock, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
// Set current debugging state.
|
||||
IsDebugging = true;
|
||||
CurrentPID = pid;
|
||||
|
||||
// release the lock.
|
||||
scePthreadMutexUnlock(&DebugMutex);
|
||||
|
||||
// Send attach event to host.
|
||||
Events::SendEvent(Events::EVENT_ATTACH, pid);
|
||||
|
||||
klog("Attached to %s(%d)\n", processName, pid);
|
||||
|
||||
SendStatus(Sock, 1);
|
||||
@@ -167,10 +187,30 @@ void Debug::Attach(OrbisNetId Sock)
|
||||
|
||||
void Debug::Detach(OrbisNetId Sock)
|
||||
{
|
||||
bool result = false;
|
||||
if (IsDebugging)
|
||||
result = TryDetach(CurrentPID);
|
||||
SendStatus(Sock, result ? 1 : 0);
|
||||
if(!IsDebugging)
|
||||
SendStatus(Sock, 0);
|
||||
|
||||
// Aquire lock.
|
||||
scePthreadMutexLock(&DebugMutex);
|
||||
|
||||
if (TryDetach(CurrentPID))
|
||||
{
|
||||
// release the lock.
|
||||
scePthreadMutexUnlock(&DebugMutex);
|
||||
|
||||
Events::SendEvent(Events::EVENT_DETACH);
|
||||
|
||||
SendStatus(Sock, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
// release the lock.
|
||||
scePthreadMutexUnlock(&DebugMutex);
|
||||
|
||||
klog("Failed to detach from %d\n", CurrentPID);
|
||||
|
||||
SendStatus(Sock, 0);
|
||||
}
|
||||
}
|
||||
|
||||
void Debug::LoadLibrary(OrbisNetId Sock)
|
||||
@@ -259,25 +299,8 @@ void Debug::GetLibraryList(OrbisNetId Sock)
|
||||
}
|
||||
|
||||
// Get the library list with path.
|
||||
std::vector<LibraryInfo> klibraryList;
|
||||
GeneralIPC::GetLibraryList(CurrentPID, klibraryList);
|
||||
|
||||
// Parse the library list.
|
||||
std::vector<LibraryPacket> libraryList;
|
||||
for (const auto& i : klibraryList)
|
||||
{
|
||||
OrbisKernelModuleInfo moduleInfo;
|
||||
moduleInfo.size = sizeof(OrbisKernelModuleInfo);
|
||||
sceKernelGetModuleInfo(i.ModuleHandle, &moduleInfo);
|
||||
|
||||
LibraryPacket temp;
|
||||
temp.Handle = i.ModuleHandle;
|
||||
strcpy(temp.Path, i.Path);
|
||||
temp.SegmentCount = moduleInfo.segmentCount;
|
||||
memcpy(&temp.Segments, &moduleInfo.segmentInfo, sizeof(OrbisKernelModuleSegmentInfo) * 4);
|
||||
|
||||
libraryList.push_back(temp);
|
||||
}
|
||||
GeneralIPC::GetLibraryList(CurrentPID, libraryList);
|
||||
|
||||
// Send the data size.
|
||||
Sockets::SendInt(Sock, libraryList.size());
|
||||
@@ -290,9 +313,17 @@ Debug::Debug()
|
||||
{
|
||||
IsDebugging = false;
|
||||
CurrentPID = -1;
|
||||
|
||||
// Create the mutex to protect our host list.
|
||||
auto res = scePthreadMutexInit(&DebugMutex, nullptr, "DebugMutex");
|
||||
if (res != 0)
|
||||
{
|
||||
klog("Error: Failed to create mutex for Debug class!! Err 0x%llX\n", res);
|
||||
}
|
||||
}
|
||||
|
||||
Debug::~Debug()
|
||||
{
|
||||
|
||||
// Destroy for clean up.
|
||||
scePthreadMutexDestroy(&DebugMutex);
|
||||
}
|
||||
@@ -3,6 +3,7 @@
|
||||
class Debug
|
||||
{
|
||||
public:
|
||||
OrbisPthreadMutex DebugMutex;
|
||||
bool IsDebugging;
|
||||
int CurrentPID;
|
||||
|
||||
|
||||
@@ -0,0 +1,119 @@
|
||||
#include "Common.h"
|
||||
#include "Events.h"
|
||||
|
||||
std::vector< OrbisNetInAddr_t> Events::HostList;
|
||||
OrbisPthreadMutex Events::HostListMutex;
|
||||
|
||||
bool Events::Init()
|
||||
{
|
||||
// Create the mutex to protect our host list.
|
||||
auto res = scePthreadMutexInit(&HostListMutex, nullptr, "EventsHostListMutex");
|
||||
|
||||
if (res != 0)
|
||||
{
|
||||
klog("Failed to create mutex for Events Host list. Err: 0x%llX\n", res);
|
||||
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
void Events::Term()
|
||||
{
|
||||
// Destroy for clean up.
|
||||
scePthreadMutexDestroy(&HostListMutex);
|
||||
}
|
||||
|
||||
void Events::AddHost(OrbisNetInAddr_t HostAddress)
|
||||
{
|
||||
// Aquire a lock for the list.
|
||||
scePthreadMutexLock(&HostListMutex);
|
||||
|
||||
// Add the host to the list if it does not exist already.
|
||||
if (std::find(HostList.begin(), HostList.end(), HostAddress) == HostList.end())
|
||||
{
|
||||
klog("New host (%i.%i.%i.%i)!\n", HostAddress & 0xFF, (HostAddress >> 8) & 0xFF, (HostAddress >> 16) & 0xFF, (HostAddress >> 24) & 0xFF);
|
||||
HostList.push_back(HostAddress);
|
||||
}
|
||||
|
||||
// Revoke the lock on the list.
|
||||
scePthreadMutexUnlock(&HostListMutex);
|
||||
}
|
||||
|
||||
void Events::RemoveHost(OrbisNetInAddr_t HostAddress)
|
||||
{
|
||||
// Aquire a lock for the list.
|
||||
scePthreadMutexLock(&HostListMutex);
|
||||
|
||||
// Remove this host if it exists in the list.
|
||||
if (std::find(HostList.begin(), HostList.end(), HostAddress) != HostList.end())
|
||||
{
|
||||
klog("Lost host (%i.%i.%i.%i)!\n", HostAddress & 0xFF, (HostAddress >> 8) & 0xFF, (HostAddress >> 16) & 0xFF, (HostAddress >> 24) & 0xFF);
|
||||
std::remove(HostList.begin(), HostList.end(), HostAddress);
|
||||
}
|
||||
|
||||
// Revoke the lock on the list.
|
||||
scePthreadMutexUnlock(&HostListMutex);
|
||||
}
|
||||
|
||||
OrbisNetId Events::Connect(OrbisNetInAddr_t HostAddress)
|
||||
{
|
||||
// Set up socket params.
|
||||
OrbisNetSockaddrIn addr = { 0 };
|
||||
addr.sin_family = ORBIS_NET_AF_INET;
|
||||
addr.sin_addr.s_addr = HostAddress;
|
||||
addr.sin_port = sceNetHtons(EVENT_PORT);
|
||||
|
||||
// Create socket.
|
||||
auto sock = sceNetSocket("SendEventSock", ORBIS_NET_AF_INET, ORBIS_NET_SOCK_STREAM, ORBIS_NET_IPPROTO_TCP);
|
||||
|
||||
// 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));
|
||||
|
||||
auto res = sceNetConnect(sock, (OrbisNetSockaddr*)&addr, sizeof(addr));
|
||||
if (!res)
|
||||
return sock;
|
||||
else
|
||||
{
|
||||
klog("Events::Connect() Error: %llX\n", res);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void Events::SendEvent(int EventId, int pid)
|
||||
{
|
||||
if (HostList.empty())
|
||||
return;
|
||||
|
||||
for (const auto& host : HostList)
|
||||
{
|
||||
// Aquire a lock for the list.
|
||||
scePthreadMutexLock(&HostListMutex);
|
||||
|
||||
auto sock = Connect(host);
|
||||
if (sock)
|
||||
{
|
||||
// Send EventId
|
||||
Sockets::SendInt(sock, EventId);
|
||||
|
||||
if (EventId == EVENT_ATTACH && pid != -1)
|
||||
{
|
||||
Sockets::SendInt(sock, pid);
|
||||
}
|
||||
|
||||
// Revoke the lock on the list.
|
||||
scePthreadMutexUnlock(&HostListMutex);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Revoke the lock on the list.
|
||||
scePthreadMutexUnlock(&HostListMutex);
|
||||
|
||||
RemoveHost(host);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
#pragma once
|
||||
|
||||
class Events
|
||||
{
|
||||
public:
|
||||
enum EventId
|
||||
{
|
||||
EVENT_EXCEPTION,
|
||||
EVENT_CONTINUE,
|
||||
EVENT_DIE,
|
||||
EVENT_ATTACH,
|
||||
EVENT_DETACH,
|
||||
EVENT_SUSPEND,
|
||||
EVENT_RESUME,
|
||||
EVENT_SHUTDOWN,
|
||||
};
|
||||
|
||||
static bool Init();
|
||||
static void Term();
|
||||
|
||||
static void AddHost(OrbisNetInAddr_t HostAddress);
|
||||
static void RemoveHost(OrbisNetInAddr_t HostAddress);
|
||||
static void SendEvent(int EventId, int pid = -1);
|
||||
|
||||
private:
|
||||
static std::vector< OrbisNetInAddr_t> HostList;
|
||||
static OrbisPthreadMutex HostListMutex;
|
||||
|
||||
static OrbisNetId Connect(OrbisNetInAddr_t HostAddress);
|
||||
};
|
||||
|
||||
@@ -42,7 +42,7 @@ bool GeneralIPC::SendCommand(OrbisNetId Sock, int Command)
|
||||
return Status == GIPC_OK;
|
||||
}
|
||||
|
||||
bool GeneralIPC::GetLibraryList(int pid, std::vector<LibraryInfo>& Libraries)
|
||||
bool GeneralIPC::GetLibraryList(int pid, std::vector<LibraryPacket>& Libraries)
|
||||
{
|
||||
// Open a new local socket connection for the process.
|
||||
auto sock = Connect(pid);
|
||||
@@ -70,7 +70,7 @@ bool GeneralIPC::GetLibraryList(int pid, std::vector<LibraryInfo>& Libraries)
|
||||
// Resize the vector to accept the data.
|
||||
Libraries.resize(LibraryCount);
|
||||
|
||||
if (!Sockets::RecvLargeData(sock, (unsigned char*)Libraries.data(), LibraryCount * sizeof(LibraryInfo)))
|
||||
if (!Sockets::RecvLargeData(sock, (unsigned char*)Libraries.data(), LibraryCount * sizeof(LibPacket)))
|
||||
{
|
||||
klog("[GeneralIPC] Failed to recv library data.\n");
|
||||
return false;
|
||||
|
||||
@@ -8,7 +8,7 @@ private:
|
||||
static bool SendCommand(OrbisNetId Sock, int Command);
|
||||
|
||||
public:
|
||||
static bool GetLibraryList(int pid, std::vector<LibraryInfo>& Libraries);
|
||||
static bool GetLibraryList(int pid, std::vector<LibraryPacket>& Libraries);
|
||||
static bool LoadLibrary(int pid, const char* Path, int* HandleOut);
|
||||
static bool UnLoadLibrary(int pid, int Handle);
|
||||
static bool Jailbreak(int pid);
|
||||
|
||||
@@ -67,6 +67,7 @@ del /s /q /f $(IntDir)\*.oelf</NMakeCleanCommandLine>
|
||||
<ClCompile Include="Apps.cpp" />
|
||||
<ClCompile Include="Breakpoint.cpp" />
|
||||
<ClCompile Include="Debug.cpp" />
|
||||
<ClCompile Include="Events.cpp" />
|
||||
<ClCompile Include="Flash.cpp" />
|
||||
<ClCompile Include="GeneralIPC.cpp" />
|
||||
<ClCompile Include="main.cpp" />
|
||||
@@ -90,7 +91,9 @@ del /s /q /f $(IntDir)\*.oelf</NMakeCleanCommandLine>
|
||||
<ClInclude Include="Apps.h" />
|
||||
<ClInclude Include="Breakpoint.h" />
|
||||
<ClInclude Include="Common.h" />
|
||||
<ClInclude Include="Config.h" />
|
||||
<ClInclude Include="Debug.h" />
|
||||
<ClInclude Include="Events.h" />
|
||||
<ClInclude Include="Flash.h" />
|
||||
<ClInclude Include="GeneralIPC.h" />
|
||||
<ClInclude Include="Proc.h" />
|
||||
|
||||
@@ -99,6 +99,9 @@
|
||||
<ClCompile Include="Sockets.cpp">
|
||||
<Filter>Source Files\Utilities</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Events.cpp">
|
||||
<Filter>Source Files\API</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="Common.h">
|
||||
@@ -164,5 +167,11 @@
|
||||
<ClInclude Include="Sockets.h">
|
||||
<Filter>Header Files\Utilities</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Config.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Events.h">
|
||||
<Filter>Header Files\API</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -1,19 +1,14 @@
|
||||
#include "Common.h"
|
||||
#include "SocketListener.h"
|
||||
|
||||
struct ClientThreadParams
|
||||
{
|
||||
SocketListener* socketListener;
|
||||
OrbisNetId Sock;
|
||||
};
|
||||
|
||||
void* SocketListener::ClientThread(void* tdParam)
|
||||
{
|
||||
ClientThreadParams* Params = (ClientThreadParams*)tdParam;
|
||||
SocketListener* socketListener = Params->socketListener;
|
||||
OrbisNetId Sock = Params->Sock;
|
||||
OrbisNetInAddr sin_addr = Params->sin_addr;
|
||||
|
||||
socketListener->ClientCallBack(socketListener->tdParam, Sock);
|
||||
socketListener->ClientCallBack(socketListener->tdParam, Sock, sin_addr);
|
||||
|
||||
sceNetSocketClose(Sock);
|
||||
free(Params);
|
||||
@@ -100,6 +95,7 @@ void* SocketListener::DoWork()
|
||||
ClientThreadParams* Params = new ClientThreadParams();
|
||||
Params->socketListener = this;
|
||||
Params->Sock = ClientSocket;
|
||||
Params->sin_addr = ClientAddr.sin_addr;
|
||||
|
||||
// Create Thread to handle connection.
|
||||
OrbisPthread* Thread;
|
||||
@@ -132,7 +128,7 @@ void* SocketListener::ListenThread(void* tdParam)
|
||||
}
|
||||
|
||||
|
||||
SocketListener::SocketListener(void(*ClientCallBack)(void* tdParam, OrbisNetId Sock), void* tdParam, unsigned short Port)
|
||||
SocketListener::SocketListener(void(*ClientCallBack)(void* tdParam, OrbisNetId Sock, OrbisNetInAddr sin_addr), void* tdParam, unsigned short Port)
|
||||
{
|
||||
klog("Socket Listener.\n");
|
||||
this->ClientCallBack = ClientCallBack;
|
||||
|
||||
@@ -15,10 +15,17 @@ private:
|
||||
void* DoWork();
|
||||
static void* ClientThread(void* tdParam);
|
||||
void* tdParam;
|
||||
void(*ClientCallBack)(void* tdParam, OrbisNetId Sock);
|
||||
void(*ClientCallBack)(void* tdParam, OrbisNetId Sock, OrbisNetInAddr sin_addr);
|
||||
static void* ListenThread(void* tdParam);
|
||||
|
||||
public:
|
||||
SocketListener(void(*ClientCallBack)(void* tdParam, OrbisNetId Sock), void* tdParam, unsigned short Port);
|
||||
struct ClientThreadParams
|
||||
{
|
||||
SocketListener* socketListener;
|
||||
OrbisNetId Sock;
|
||||
OrbisNetInAddr sin_addr;
|
||||
};
|
||||
|
||||
SocketListener(void(*ClientCallBack)(void* tdParam, OrbisNetId Sock, OrbisNetInAddr sin_addr), void* tdParam, unsigned short Port);
|
||||
~SocketListener();
|
||||
};
|
||||
@@ -1,11 +1,11 @@
|
||||
#pragma once
|
||||
#define ORBISLIB_MAJOR 3
|
||||
#define ORBISLIB_MINOR 0
|
||||
#define ORBISLIB_BUILDVERSION 933
|
||||
#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 951
|
||||
#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
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#include "Version.h"
|
||||
#include "API.h"
|
||||
#include "GoldHEN.h"
|
||||
#include "Events.h"
|
||||
|
||||
void exiting()
|
||||
{
|
||||
@@ -10,6 +11,9 @@ void exiting()
|
||||
// Terminate System Monitor
|
||||
SystemMonitor::Term();
|
||||
|
||||
// Terminate the Events class.
|
||||
Events::Term();
|
||||
|
||||
// Terminate API
|
||||
API::Term();
|
||||
|
||||
@@ -47,6 +51,13 @@ int main()
|
||||
// Init a thread to monitor the system usage stats.
|
||||
// SystemMonitor::Init();
|
||||
|
||||
if (!Events::Init())
|
||||
{
|
||||
Notify("Failed to init Events...");
|
||||
sceSystemServiceLoadExec("exit", 0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// start up the API. NOTE: this is blocking.
|
||||
API::Init();
|
||||
|
||||
|
||||
@@ -5,18 +5,35 @@ LocalSocketListener* LocalListener = nullptr;
|
||||
|
||||
void SendLibraryList(OrbisNetId Sock)
|
||||
{
|
||||
std::vector<LibPacket> libraryList;
|
||||
|
||||
// Get the libraries.
|
||||
LibraryInfo* LibraryList = (LibraryInfo*)malloc(200 * sizeof(LibraryInfo));
|
||||
int RealLibCount = jbc_get_proc_libraries(LibraryList, 200);
|
||||
LibraryInfo* klibraryList = (LibraryInfo*)malloc(200 * sizeof(LibraryInfo));
|
||||
int realLibCount = jbc_get_proc_libraries(klibraryList, 200);
|
||||
|
||||
// Send the Count
|
||||
Sockets::SendInt(Sock, RealLibCount);
|
||||
Sockets::SendInt(Sock, realLibCount);
|
||||
|
||||
for (int i = 0; i < realLibCount; i++)
|
||||
{
|
||||
OrbisKernelModuleInfo moduleInfo;
|
||||
moduleInfo.size = sizeof(OrbisKernelModuleInfo);
|
||||
int res = sceKernelGetModuleInfo(klibraryList[i].Handle, &moduleInfo);
|
||||
|
||||
LibPacket temp;
|
||||
temp.Handle = klibraryList[i].Handle;
|
||||
strcpy(temp.Path, klibraryList[i].Path);
|
||||
temp.SegmentCount = moduleInfo.segmentCount;
|
||||
memcpy(&temp.Segments[0], &moduleInfo.segmentInfo[0], sizeof(OrbisKernelModuleSegmentInfo) * 4);
|
||||
|
||||
libraryList.push_back(temp);
|
||||
}
|
||||
|
||||
// Ship it.
|
||||
Sockets::SendLargeData(Sock, (unsigned char*)LibraryList, RealLibCount * sizeof(LibraryInfo));
|
||||
Sockets::SendLargeData(Sock, (unsigned char*)libraryList.data(), realLibCount * sizeof(LibPacket));
|
||||
|
||||
// Clean up!
|
||||
free(LibraryList);
|
||||
free(klibraryList);
|
||||
}
|
||||
|
||||
void LoadUnloadLib(int Command, OrbisNetId Sock)
|
||||
|
||||
@@ -201,7 +201,7 @@ namespace OrbisLib2.Common.API
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 8, CharSet = CharSet.Ansi)]
|
||||
public struct LibraryPacket
|
||||
{
|
||||
public long Handle;
|
||||
public int Handle;
|
||||
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)]
|
||||
public string Path;
|
||||
public int SegmentCount;
|
||||
|
||||
@@ -34,51 +34,42 @@ namespace OrbisLib2.Common.Dispatcher
|
||||
Console.WriteLine("Invalid Packet...");
|
||||
break;
|
||||
|
||||
// Debugging
|
||||
case ForwardPacket.PacketType.Print:
|
||||
TargetManager.SelectedTarget.Events.RaiseProcPrintEvent(Packet.SenderIPAddress, Packet.Print.Sender, Packet.Print.Data);
|
||||
break;
|
||||
|
||||
case ForwardPacket.PacketType.SerialCom:
|
||||
// TODO:
|
||||
break;
|
||||
|
||||
case ForwardPacket.PacketType.Intercept:
|
||||
TargetManager.SelectedTarget.Events.RaiseProcInterceptEvent(Packet.SenderIPAddress);
|
||||
Events.RaiseProcInterceptEvent(Packet.SenderIPAddress);
|
||||
break;
|
||||
|
||||
case ForwardPacket.PacketType.Continue:
|
||||
TargetManager.SelectedTarget.Events.RaiseProcContinueEvent(Packet.SenderIPAddress);
|
||||
Events.RaiseProcContinueEvent(Packet.SenderIPAddress);
|
||||
break;
|
||||
|
||||
// Process States
|
||||
case ForwardPacket.PacketType.ProcessDie:
|
||||
TargetManager.SelectedTarget.Events.RaiseProcDieEvent(Packet.SenderIPAddress);
|
||||
Events.RaiseProcDieEvent(Packet.SenderIPAddress);
|
||||
break;
|
||||
|
||||
case ForwardPacket.PacketType.ProcessAttach:
|
||||
TargetManager.SelectedTarget.Events.RaiseProcAttachEvent(Packet.SenderIPAddress, Packet.ProcessName);
|
||||
Events.RaiseProcAttachEvent(Packet.SenderIPAddress, Packet.ProcessId);
|
||||
break;
|
||||
|
||||
case ForwardPacket.PacketType.ProcessDetach:
|
||||
TargetManager.SelectedTarget.Events.RaiseProcDetachEvent(Packet.SenderIPAddress);
|
||||
Events.RaiseProcDetachEvent(Packet.SenderIPAddress);
|
||||
break;
|
||||
|
||||
// Target State
|
||||
case ForwardPacket.PacketType.TargetSuspend:
|
||||
TargetManager.SelectedTarget.Events.RaiseTargetSuspendEvent(Packet.SenderIPAddress);
|
||||
Events.RaiseTargetSuspendEvent(Packet.SenderIPAddress);
|
||||
break;
|
||||
|
||||
case ForwardPacket.PacketType.TargetResume:
|
||||
TargetManager.SelectedTarget.Events.RaiseTargetResumeEvent(Packet.SenderIPAddress);
|
||||
Events.RaiseTargetResumeEvent(Packet.SenderIPAddress);
|
||||
break;
|
||||
|
||||
case ForwardPacket.PacketType.TargetShutdown:
|
||||
TargetManager.SelectedTarget.Events.RaiseTargetShutdownEvent(Packet.SenderIPAddress);
|
||||
break;
|
||||
|
||||
case ForwardPacket.PacketType.TargetNewTitle:
|
||||
TargetManager.SelectedTarget.Events.RaiseTargetNewTitleEvent(Packet.SenderIPAddress, Packet.TitleChange.TitleID);
|
||||
Events.RaiseTargetShutdownEvent(Packet.SenderIPAddress);
|
||||
break;
|
||||
|
||||
case ForwardPacket.PacketType.TargetAvailability:
|
||||
|
||||
@@ -82,7 +82,6 @@
|
||||
TargetSuspend,
|
||||
TargetResume,
|
||||
TargetShutdown,
|
||||
TargetNewTitle,
|
||||
TargetAvailability,
|
||||
TargetAPIAvailability,
|
||||
|
||||
@@ -101,9 +100,9 @@
|
||||
public string? SenderIPAddress { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Name of the process that the event was triggered for.
|
||||
/// The process id for the event triggered.
|
||||
/// </summary>
|
||||
public string? ProcessName { get; set; }
|
||||
public int ProcessId { get; set; }
|
||||
|
||||
public TitleChange? TitleChange { get; set; }
|
||||
|
||||
|
||||
@@ -1,5 +1,90 @@
|
||||
namespace OrbisLib2.General
|
||||
using OrbisLib2.Targets;
|
||||
|
||||
namespace OrbisLib2.General
|
||||
{
|
||||
public class ProcInterceptEvent : EventArgs
|
||||
{
|
||||
public Target SendingTarget { get; private set; }
|
||||
|
||||
public ProcInterceptEvent(Target SendingTarget)
|
||||
{
|
||||
this.SendingTarget = SendingTarget;
|
||||
}
|
||||
}
|
||||
|
||||
public class ProcContinueEvent : EventArgs
|
||||
{
|
||||
public Target SendingTarget { get; private set; }
|
||||
|
||||
public ProcContinueEvent(Target SendingTarget)
|
||||
{
|
||||
this.SendingTarget = SendingTarget;
|
||||
}
|
||||
}
|
||||
|
||||
public class ProcDieEvent : EventArgs
|
||||
{
|
||||
public Target SendingTarget { get; private set; }
|
||||
|
||||
public ProcDieEvent(Target SendingTarget)
|
||||
{
|
||||
this.SendingTarget = SendingTarget;
|
||||
}
|
||||
}
|
||||
|
||||
public class ProcAttachEvent : EventArgs
|
||||
{
|
||||
public Target SendingTarget { get; private set; }
|
||||
|
||||
public int NewProcessId { get; private set; }
|
||||
|
||||
public ProcAttachEvent(Target SendingTarget, int NewProcessId)
|
||||
{
|
||||
this.SendingTarget = SendingTarget;
|
||||
this.NewProcessId = NewProcessId;
|
||||
}
|
||||
}
|
||||
|
||||
public class ProcDetachEvent : EventArgs
|
||||
{
|
||||
public Target SendingTarget { get; private set; }
|
||||
|
||||
public ProcDetachEvent(Target SendingTarget)
|
||||
{
|
||||
this.SendingTarget = SendingTarget;
|
||||
}
|
||||
}
|
||||
|
||||
public class TargetSuspendEvent : EventArgs
|
||||
{
|
||||
public Target SendingTarget { get; private set; }
|
||||
|
||||
public TargetSuspendEvent(Target SendingTarget)
|
||||
{
|
||||
this.SendingTarget = SendingTarget;
|
||||
}
|
||||
}
|
||||
|
||||
public class TargetResumeEvent : EventArgs
|
||||
{
|
||||
public Target SendingTarget { get; private set; }
|
||||
|
||||
public TargetResumeEvent(Target SendingTarget)
|
||||
{
|
||||
this.SendingTarget = SendingTarget;
|
||||
}
|
||||
}
|
||||
|
||||
public class TargetShutdownEvent : EventArgs
|
||||
{
|
||||
public Target SendingTarget { get; private set; }
|
||||
|
||||
public TargetShutdownEvent(Target SendingTarget)
|
||||
{
|
||||
this.SendingTarget = SendingTarget;
|
||||
}
|
||||
}
|
||||
|
||||
public class DBTouchedEvent : EventArgs
|
||||
{
|
||||
public DBTouchedEvent() { }
|
||||
@@ -39,21 +124,166 @@
|
||||
|
||||
public class Events
|
||||
{
|
||||
/// <summary>
|
||||
/// Event fired when the current proccess the debugger is attached to thows an exception.
|
||||
/// </summary>
|
||||
public static event EventHandler<ProcInterceptEvent> ProcIntercept;
|
||||
|
||||
/// <summary>
|
||||
/// Event fired when the current proccess the debugger is attached to continues.
|
||||
/// </summary>
|
||||
public static event EventHandler<ProcContinueEvent> ProcContinue;
|
||||
|
||||
/// <summary>
|
||||
/// Event fired when the current proccess the debugger is attached to is dying.
|
||||
/// </summary>
|
||||
public static event EventHandler<ProcDieEvent> ProcDie;
|
||||
|
||||
/// <summary>
|
||||
/// Event fired when the current proccess the debugger is attached to has changed.
|
||||
/// </summary>
|
||||
public static event EventHandler<ProcAttachEvent> ProcAttach;
|
||||
|
||||
/// <summary>
|
||||
/// Event fired when debugging of the last attached process has stopped.
|
||||
/// </summary>
|
||||
public static event EventHandler<ProcDetachEvent> ProcDetach;
|
||||
|
||||
/// <summary>
|
||||
/// Event fired when the corisponding target has changed states to suspend.
|
||||
/// </summary>
|
||||
public static event EventHandler<TargetSuspendEvent> TargetSuspend;
|
||||
|
||||
/// <summary>
|
||||
/// Event fired when the corisponding target has changed states to resume.
|
||||
/// </summary>
|
||||
public static event EventHandler<TargetResumeEvent> TargetResume;
|
||||
|
||||
/// <summary>
|
||||
/// Event fired when the corisponding target has changed states to shutdown.
|
||||
/// </summary>
|
||||
public static event EventHandler<TargetShutdownEvent> TargetShutdown;
|
||||
|
||||
/// <summary>
|
||||
/// The DBTouched Event gets invoked when the Database used to store target specific info is changed.
|
||||
/// </summary>
|
||||
public static event EventHandler<DBTouchedEvent>? DBTouched;
|
||||
|
||||
/// <summary>
|
||||
/// Even is fired when ever the state of the target changes.
|
||||
/// Event is fired when ever the state of the target changes.
|
||||
/// </summary>
|
||||
public static event EventHandler<TargetStateChangedEvent>? TargetStateChanged;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// Event thrown when ever the currently selected target has changed.
|
||||
/// </summary>
|
||||
public static event EventHandler<SelectedTargetChangedEvent>? SelectedTargetChanged;
|
||||
|
||||
/// <summary>
|
||||
/// Fires an event for when the Target's proccess were attached to has reached an intercepted state.
|
||||
/// </summary>
|
||||
/// <param name="IPAddr">The sending Target Address.</param>
|
||||
internal static void RaiseProcInterceptEvent(string IPAddr)
|
||||
{
|
||||
var sendingTarget = TargetManager.GetTarget(x => x.IPAddress == IPAddr);
|
||||
if(sendingTarget != null)
|
||||
{
|
||||
ProcIntercept?.Invoke(null, new ProcInterceptEvent(sendingTarget));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Fires an event when a procees on the Target has gotten the signal to continue execution.
|
||||
/// </summary>
|
||||
/// <param name="IPAddr">The sending Target Address.</param>
|
||||
internal static void RaiseProcContinueEvent(string IPAddr)
|
||||
{
|
||||
var sendingTarget = TargetManager.GetTarget(x => x.IPAddress == IPAddr);
|
||||
if (sendingTarget != null)
|
||||
{
|
||||
ProcContinue?.Invoke(null, new ProcContinueEvent(sendingTarget));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Fires an event for when a proccess is going to be shutting down on the Target.
|
||||
/// </summary>
|
||||
/// <param name="IPAddr">The sending Target Address.</param>
|
||||
internal static void RaiseProcDieEvent(string IPAddr)
|
||||
{
|
||||
var sendingTarget = TargetManager.GetTarget(x => x.IPAddress == IPAddr);
|
||||
if (sendingTarget != null)
|
||||
{
|
||||
ProcDie?.Invoke(null, new ProcDieEvent(sendingTarget));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Fires an event for when the OrbisLib API attaches to a process.
|
||||
/// </summary>
|
||||
/// <param name="IPAddr">The sending Target Address.</param>
|
||||
/// <param name="NewProcName">The name of the process were attaching to.</param>
|
||||
internal static void RaiseProcAttachEvent(string IPAddr, int NewProcessId)
|
||||
{
|
||||
var sendingTarget = TargetManager.GetTarget(x => x.IPAddress == IPAddr);
|
||||
if (sendingTarget != null)
|
||||
{
|
||||
ProcAttach?.Invoke(null, new ProcAttachEvent(sendingTarget, NewProcessId));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Fires an event for when the OrbisLib API detaches to a process.
|
||||
/// </summary>
|
||||
/// <param name="IPAddr">The sending Target Address.</param>
|
||||
internal static void RaiseProcDetachEvent(string IPAddr)
|
||||
{
|
||||
var sendingTarget = TargetManager.GetTarget(x => x.IPAddress == IPAddr);
|
||||
if (sendingTarget != null)
|
||||
{
|
||||
ProcDetach?.Invoke(null, new ProcDetachEvent(sendingTarget));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Fires event for when Target is entering the suspended state.
|
||||
/// </summary>
|
||||
/// <param name="IPAddr">The sending Target Address.</param>
|
||||
internal static void RaiseTargetSuspendEvent(string IPAddr)
|
||||
{
|
||||
var sendingTarget = TargetManager.GetTarget(x => x.IPAddress == IPAddr);
|
||||
if (sendingTarget != null)
|
||||
{
|
||||
TargetSuspend?.Invoke(null, new TargetSuspendEvent(sendingTarget));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Fires event for when the Target is resuming from a suspended state.
|
||||
/// </summary>
|
||||
/// <param name="IPAddr">The sending Target Address.</param>
|
||||
internal static void RaiseTargetResumeEvent(string IPAddr)
|
||||
{
|
||||
var sendingTarget = TargetManager.GetTarget(x => x.IPAddress == IPAddr);
|
||||
if (sendingTarget != null)
|
||||
{
|
||||
TargetResume?.Invoke(null, new TargetResumeEvent(sendingTarget));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Fires an event for when the Target is shutting down.
|
||||
/// </summary>
|
||||
/// <param name="IPAddr">The sending Target Address.</param>
|
||||
internal static void RaiseTargetShutdownEvent(string IPAddr)
|
||||
{
|
||||
var sendingTarget = TargetManager.GetTarget(x => x.IPAddress == IPAddr);
|
||||
if (sendingTarget != null)
|
||||
{
|
||||
TargetShutdown?.Invoke(null, new TargetShutdownEvent(sendingTarget));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Will Fire the event for when the Database has been updated.
|
||||
/// </summary>
|
||||
|
||||
@@ -80,7 +80,6 @@ namespace OrbisLib2.Targets
|
||||
}
|
||||
}
|
||||
|
||||
public TargetEvents Events;
|
||||
public Debug Debug;
|
||||
public Payload Payload;
|
||||
public Process Process;
|
||||
@@ -91,7 +90,6 @@ namespace OrbisLib2.Targets
|
||||
{
|
||||
_SavedTargetId = SavedTarget.Id;
|
||||
|
||||
Events = new TargetEvents(this);
|
||||
Debug = new Debug(this);
|
||||
Payload = new Payload(this);
|
||||
Process = new Process(this);
|
||||
|
||||
@@ -1,205 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace OrbisLib2.Targets
|
||||
{
|
||||
public class PrintEvent : EventArgs
|
||||
{
|
||||
public string Sender { get; private set; }
|
||||
public string Data { get; private set; }
|
||||
|
||||
public PrintEvent(string Sender, string Data)
|
||||
{
|
||||
this.Sender = Sender;
|
||||
this.Data = Data;
|
||||
}
|
||||
}
|
||||
|
||||
public class ProcInterceptEvent : EventArgs
|
||||
{
|
||||
public ProcInterceptEvent()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public class ProcContinueEvent : EventArgs
|
||||
{
|
||||
public ProcContinueEvent() { }
|
||||
}
|
||||
|
||||
public class ProcDieEvent : EventArgs
|
||||
{
|
||||
public ProcDieEvent() { }
|
||||
}
|
||||
|
||||
public class ProcAttachEvent : EventArgs
|
||||
{
|
||||
public string NewProcName { get; private set; }
|
||||
|
||||
public ProcAttachEvent(string NewProcName)
|
||||
{
|
||||
this.NewProcName = NewProcName;
|
||||
}
|
||||
}
|
||||
|
||||
public class ProcDetachEvent : EventArgs
|
||||
{
|
||||
public ProcDetachEvent() { }
|
||||
}
|
||||
|
||||
public class TargetSuspendEvent : EventArgs
|
||||
{
|
||||
public TargetSuspendEvent() { }
|
||||
}
|
||||
|
||||
public class TargetResumeEvent : EventArgs
|
||||
{
|
||||
public TargetResumeEvent() { }
|
||||
}
|
||||
|
||||
public class TargetShutdownEvent : EventArgs
|
||||
{
|
||||
public TargetShutdownEvent() { }
|
||||
}
|
||||
|
||||
public class TargetNewTitleEvent : EventArgs
|
||||
{
|
||||
public string TitleID { get; private set; }
|
||||
|
||||
public TargetNewTitleEvent(string TitleID)
|
||||
{
|
||||
this.TitleID = TitleID;
|
||||
}
|
||||
}
|
||||
|
||||
public class TargetEvents
|
||||
{
|
||||
private Target Target;
|
||||
|
||||
public event EventHandler<PrintEvent> Print;
|
||||
public event EventHandler<ProcInterceptEvent> ProcIntercept;
|
||||
public event EventHandler<ProcContinueEvent> ProcContinue;
|
||||
public event EventHandler<ProcDieEvent> ProcDie;
|
||||
public event EventHandler<ProcAttachEvent> ProcAttach;
|
||||
public event EventHandler<ProcDetachEvent> ProcDetach;
|
||||
public event EventHandler<TargetSuspendEvent> TargetSuspend;
|
||||
public event EventHandler<TargetResumeEvent> TargetResume;
|
||||
public event EventHandler<TargetShutdownEvent> TargetShutdown;
|
||||
public event EventHandler<TargetNewTitleEvent> TargetNewTitle;
|
||||
|
||||
public TargetEvents(Target Target)
|
||||
{
|
||||
this.Target = Target;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Event that should be fired when we recieve a print from the remote target.
|
||||
/// </summary>
|
||||
/// <param name="SenderIPAddress">The sending Target Address.</param>
|
||||
/// <param name="Sender"></param>
|
||||
/// <param name="Data"></param>
|
||||
internal void RaiseProcPrintEvent(string SenderIPAddress, string Sender, string Data)
|
||||
{
|
||||
if (SenderIPAddress.Equals(Target.IPAddress))
|
||||
Print?.Invoke(null, new PrintEvent(Sender, Data));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Fires an event for when the Target's proccess were attached to has reached an intercepted state.
|
||||
/// </summary>
|
||||
/// <param name="IPAddr">The sending Target Address.</param>
|
||||
internal void RaiseProcInterceptEvent(string IPAddr)
|
||||
{
|
||||
if (IPAddr.Equals(Target.IPAddress))
|
||||
{
|
||||
ProcIntercept?.Invoke(null, new ProcInterceptEvent());
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Fires an event when a procees on the Target has gotten the signal to continue execution.
|
||||
/// </summary>
|
||||
/// <param name="IPAddr">The sending Target Address.</param>
|
||||
internal void RaiseProcContinueEvent(string IPAddr)
|
||||
{
|
||||
if (IPAddr.Equals(Target.IPAddress))
|
||||
ProcContinue?.Invoke(null, new ProcContinueEvent());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Fires an event for when a proccess is going to be shutting down on the Target.
|
||||
/// </summary>
|
||||
/// <param name="IPAddr">The sending Target Address.</param>
|
||||
internal void RaiseProcDieEvent(string IPAddr)
|
||||
{
|
||||
if (IPAddr.Equals(Target.IPAddress))
|
||||
ProcDie?.Invoke(null, new ProcDieEvent());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Fires an event for when the OrbisLib API attaches to a process.
|
||||
/// </summary>
|
||||
/// <param name="IPAddr">The sending Target Address.</param>
|
||||
/// <param name="NewProcName">The name of the process were attaching to.</param>
|
||||
internal void RaiseProcAttachEvent(string IPAddr, string NewProcName)
|
||||
{
|
||||
if (IPAddr.Equals(Target.IPAddress))
|
||||
ProcAttach?.Invoke(null, new ProcAttachEvent(NewProcName));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Fires an event for when the OrbisLib API detaches to a process.
|
||||
/// </summary>
|
||||
/// <param name="IPAddr">The sending Target Address.</param>
|
||||
internal void RaiseProcDetachEvent(string IPAddr)
|
||||
{
|
||||
if (IPAddr.Equals(Target.IPAddress))
|
||||
ProcDetach?.Invoke(null, new ProcDetachEvent());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Fires event for when Target is entering the suspended state.
|
||||
/// </summary>
|
||||
/// <param name="IPAddr">The sending Target Address.</param>
|
||||
internal void RaiseTargetSuspendEvent(string IPAddr)
|
||||
{
|
||||
if (IPAddr.Equals(Target.IPAddress))
|
||||
TargetSuspend?.Invoke(null, new TargetSuspendEvent());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Fires event for when the Target is resuming from a suspended state.
|
||||
/// </summary>
|
||||
/// <param name="IPAddr">The sending Target Address.</param>
|
||||
internal void RaiseTargetResumeEvent(string IPAddr)
|
||||
{
|
||||
if (IPAddr.Equals(Target.IPAddress))
|
||||
TargetResume?.Invoke(null, new TargetResumeEvent());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Fires an event for when the Target is shutting down.
|
||||
/// </summary>
|
||||
/// <param name="IPAddr">The sending Target Address.</param>
|
||||
internal void RaiseTargetShutdownEvent(string IPAddr)
|
||||
{
|
||||
if (IPAddr.Equals(Target.IPAddress))
|
||||
TargetShutdown?.Invoke(null, new TargetShutdownEvent());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Fires an event for when we change the current game on the Target.
|
||||
/// </summary>
|
||||
/// <param name="IPAddr">The sending Target Address.</param>
|
||||
/// <param name="TitleID">The next title index our Target will be running.</param>
|
||||
internal void RaiseTargetNewTitleEvent(string IPAddr, string TitleID)
|
||||
{
|
||||
if (IPAddr.Equals(Target.IPAddress))
|
||||
TargetNewTitle?.Invoke(null, new TargetNewTitleEvent(TitleID));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@ using OrbisLib2.Common.Database;
|
||||
using OrbisLib2.Common.Database.Types;
|
||||
using OrbisLib2.Common.Helpers;
|
||||
using OrbisLib2.General;
|
||||
using System.Linq.Expressions;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace OrbisLib2.Targets
|
||||
@@ -65,7 +66,6 @@ namespace OrbisLib2.Targets
|
||||
/// Gets the specified target by name.
|
||||
/// </summary>
|
||||
/// <param name="TargetName">The specified target name.</param>
|
||||
/// <param name="Out">Target output.</param>
|
||||
/// <returns>Returns true if target is found.</returns>
|
||||
public static Target? GetTarget(string TargetName)
|
||||
{
|
||||
@@ -79,6 +79,23 @@ namespace OrbisLib2.Targets
|
||||
return new Target(saveedTarget);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the specified target by predicate.
|
||||
/// </summary>
|
||||
/// <param name="predicate">The predicate to be used to find the target.</param>
|
||||
/// <returns></returns>
|
||||
public static Target? GetTarget(Expression<Func<SavedTarget, bool>> predicate)
|
||||
{
|
||||
var saveedTarget = SavedTarget.FindTarget(predicate);
|
||||
|
||||
if (saveedTarget == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return new Target(saveedTarget);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Deletes the specified target.
|
||||
/// </summary>
|
||||
|
||||
@@ -180,7 +180,7 @@
|
||||
<ListView.View>
|
||||
<GridView>
|
||||
<GridViewColumn Header="Handle" Width="60" DisplayMemberBinding="{Binding Path=Handle}"/>
|
||||
<GridViewColumn Header="Name" Width="180" DisplayMemberBinding="{Binding Path=Path, Converter={StaticResource PathNameConverter}}"/>
|
||||
<GridViewColumn Header="Name" Width="250" DisplayMemberBinding="{Binding Path=Path, Converter={StaticResource PathNameConverter}}"/>
|
||||
<GridViewColumn Header="Segments" Width="Auto" DisplayMemberBinding="{Binding Path=Segments, Converter={StaticResource SegmentConverter}}"/>
|
||||
</GridView>
|
||||
</ListView.View>
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
using OrbisLib2.Common.Dispatcher;
|
||||
using OrbisLib2.General;
|
||||
using OrbisLib2.Targets;
|
||||
using SimpleUI.Controls;
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
|
||||
@@ -15,6 +17,25 @@ namespace OrbisLibraryManager
|
||||
{
|
||||
InitializeComponent();
|
||||
DispatcherClient.Subscribe();
|
||||
|
||||
Events.ProcAttach += Events_ProcAttach;
|
||||
Events.ProcDetach += Events_ProcDetach;
|
||||
}
|
||||
|
||||
private void Events_ProcDetach(object? sender, ProcDetachEvent e)
|
||||
{
|
||||
if(e.SendingTarget.IPAddress == TargetManager.SelectedTarget.IPAddress)
|
||||
{
|
||||
Console.WriteLine("ProcDetach");
|
||||
}
|
||||
}
|
||||
|
||||
private void Events_ProcAttach(object? sender, ProcAttachEvent e)
|
||||
{
|
||||
if (e.SendingTarget.IPAddress == TargetManager.SelectedTarget.IPAddress)
|
||||
{
|
||||
Console.WriteLine($"ProcAttach {e.NewProcessId}");
|
||||
}
|
||||
}
|
||||
|
||||
private void RefreshLibraryList()
|
||||
|
||||
@@ -1 +1 @@
|
||||
2313
|
||||
2336
|
||||
|
||||
@@ -1 +1 @@
|
||||
Version 3.0.2313 Debug Build Wednesday January 04 2023 8:32 PM
|
||||
Version 3.0.2336 Debug Build Friday January 06 2023 10:36 PM
|
||||
|
||||
@@ -13,7 +13,8 @@ namespace OrbisSuiteService.Service
|
||||
private Settings _Settings = Settings.CreateInstance();
|
||||
//private SerialComHelper _SerialMonitor = new SerialComHelper();
|
||||
private TargetWatcher _TargetWatcher;
|
||||
|
||||
private TargetEventListener _TargetEventListener;
|
||||
|
||||
|
||||
public Dispatcher()
|
||||
{
|
||||
@@ -25,6 +26,7 @@ namespace OrbisSuiteService.Service
|
||||
_SerialMonitor.Settings.PortName = "";
|
||||
_SerialMonitor.StartListening();*/
|
||||
_TargetWatcher = new TargetWatcher(this);
|
||||
_TargetEventListener = new TargetEventListener(this);
|
||||
}
|
||||
|
||||
private byte[] _SerialDataBuffer = new byte[0];
|
||||
|
||||
@@ -0,0 +1,83 @@
|
||||
using OrbisLib2.Common;
|
||||
using OrbisLib2.Common.Helpers;
|
||||
using System.Net.Sockets;
|
||||
using OrbisLib2.Common.Dispatcher;
|
||||
using System.Windows.Threading;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
|
||||
namespace OrbisSuiteService.Service
|
||||
{
|
||||
public enum EventId
|
||||
{
|
||||
EVENT_EXCEPTION,
|
||||
EVENT_CONTINUE,
|
||||
EVENT_DIE,
|
||||
EVENT_ATTACH,
|
||||
EVENT_DETACH,
|
||||
EVENT_SUSPEND,
|
||||
EVENT_RESUME,
|
||||
EVENT_SHUTDOWN,
|
||||
};
|
||||
|
||||
public class TargetEventListener
|
||||
{
|
||||
private Listener _TargetListener;
|
||||
private Dispatcher _Dispatcher;
|
||||
|
||||
public TargetEventListener(Dispatcher Dispatcher)
|
||||
{
|
||||
_Dispatcher = Dispatcher;
|
||||
|
||||
_TargetListener = new Listener(Config.EventPort);
|
||||
_TargetListener.SocketAccepted += _TargetListener_SocketAccepted;
|
||||
_TargetListener.Start();
|
||||
}
|
||||
|
||||
private void _TargetListener_SocketAccepted(Socket s)
|
||||
{
|
||||
var eventId = s.RecvInt32();
|
||||
var ipAddress = ((IPEndPoint)s.RemoteEndPoint).Address.ToString();
|
||||
switch (eventId)
|
||||
{
|
||||
default:
|
||||
Console.WriteLine($"Unknown Event {eventId}\n");
|
||||
break;
|
||||
|
||||
case (int)EventId.EVENT_EXCEPTION:
|
||||
_Dispatcher.PublishEvent(new ForwardPacket(ForwardPacket.PacketType.Intercept, ipAddress));
|
||||
break;
|
||||
|
||||
case (int)EventId.EVENT_CONTINUE:
|
||||
_Dispatcher.PublishEvent(new ForwardPacket(ForwardPacket.PacketType.Continue, ipAddress));
|
||||
break;
|
||||
|
||||
case (int)EventId.EVENT_DIE:
|
||||
_Dispatcher.PublishEvent(new ForwardPacket(ForwardPacket.PacketType.ProcessDie, ipAddress));
|
||||
break;
|
||||
|
||||
case (int)EventId.EVENT_ATTACH:
|
||||
var packet = new ForwardPacket(ForwardPacket.PacketType.ProcessAttach, ipAddress);
|
||||
packet.ProcessId = s.RecvInt32();
|
||||
_Dispatcher.PublishEvent(packet);
|
||||
break;
|
||||
|
||||
case (int)EventId.EVENT_DETACH:
|
||||
_Dispatcher.PublishEvent(new ForwardPacket(ForwardPacket.PacketType.ProcessDetach, ipAddress));
|
||||
break;
|
||||
|
||||
case (int)EventId.EVENT_SUSPEND:
|
||||
_Dispatcher.PublishEvent(new ForwardPacket(ForwardPacket.PacketType.TargetSuspend, ipAddress));
|
||||
break;
|
||||
|
||||
case (int)EventId.EVENT_RESUME:
|
||||
_Dispatcher.PublishEvent(new ForwardPacket(ForwardPacket.PacketType.TargetResume, ipAddress));
|
||||
break;
|
||||
|
||||
case (int)EventId.EVENT_SHUTDOWN:
|
||||
_Dispatcher.PublishEvent(new ForwardPacket(ForwardPacket.PacketType.TargetShutdown, ipAddress));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user