Add peek n poke.

This commit is contained in:
Greg
2023-01-19 23:01:34 -07:00
parent 539aa8d0c6
commit f71f721061
45 changed files with 1296 additions and 236 deletions
+3
View File
@@ -15,3 +15,6 @@
[submodule "External/HexView"]
path = External/HexView
url = https://github.com/OSM-Made/HexView.Wpf
[submodule "External/Be.HexEditor"]
path = External/Be.HexEditor
url = https://github.com/OSM-Made/Be.HexEditor
Vendored Submodule
+1
Submodule External/Be.HexEditor added at 3f0ec50cb7
+8 -1
View File
@@ -1,6 +1,6 @@
#pragma once
// Genreall IPC ADDRS should follow the GeneralIPC#<ProcessName> pattern.
// Genreall IPC ADDRS should follow the GeneralIPC-<ProcessName> pattern.
#define GENERAL_IPC_ADDR "/system_tmp/GeneralIPC-%d"
enum GeneralIPCCommands
@@ -21,6 +21,13 @@ enum GeneralIPCResult
GIPC_OK,
};
struct RWPacket
{
bool Write;
uint64_t Address;
uint64_t Length;
};
struct LibPacket
{
uint32_t Handle;
+20 -1
View File
@@ -49,7 +49,9 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "OrbisLibGeneralHelper", "Pl
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OrbisLib2", "Windows\Libraries\OrbisLib2\OrbisLib2.csproj", "{75BA171D-708A-40AA-A27D-57150E5DFB7B}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OrbisPeeknPoke", "Windows\OrbisPeeknPoke\OrbisPeeknPoke.csproj", "{90180080-9585-499C-99A8-6F4D1725CAF4}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OrbisPeeknPoke", "Windows\OrbisPeeknPoke\OrbisPeeknPoke.csproj", "{90180080-9585-499C-99A8-6F4D1725CAF4}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "OrbisMonitor", "Playstation\OrbisMonitor\OrbisMonitor.vcxproj", "{95716BEC-FF5A-4666-B8FE-547512CA38E0}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -255,6 +257,22 @@ Global
{90180080-9585-499C-99A8-6F4D1725CAF4}.Release|x64.Build.0 = Release|Any CPU
{90180080-9585-499C-99A8-6F4D1725CAF4}.Release|x86.ActiveCfg = Release|Any CPU
{90180080-9585-499C-99A8-6F4D1725CAF4}.Release|x86.Build.0 = Release|Any CPU
{95716BEC-FF5A-4666-B8FE-547512CA38E0}.Debug|Any CPU.ActiveCfg = Debug|x64
{95716BEC-FF5A-4666-B8FE-547512CA38E0}.Debug|Any CPU.Build.0 = Debug|x64
{95716BEC-FF5A-4666-B8FE-547512CA38E0}.Debug|Win32.ActiveCfg = Debug|x64
{95716BEC-FF5A-4666-B8FE-547512CA38E0}.Debug|Win32.Build.0 = Debug|x64
{95716BEC-FF5A-4666-B8FE-547512CA38E0}.Debug|x64.ActiveCfg = Debug|x64
{95716BEC-FF5A-4666-B8FE-547512CA38E0}.Debug|x64.Build.0 = Debug|x64
{95716BEC-FF5A-4666-B8FE-547512CA38E0}.Debug|x86.ActiveCfg = Debug|x64
{95716BEC-FF5A-4666-B8FE-547512CA38E0}.Debug|x86.Build.0 = Debug|x64
{95716BEC-FF5A-4666-B8FE-547512CA38E0}.Release|Any CPU.ActiveCfg = Release|x64
{95716BEC-FF5A-4666-B8FE-547512CA38E0}.Release|Any CPU.Build.0 = Release|x64
{95716BEC-FF5A-4666-B8FE-547512CA38E0}.Release|Win32.ActiveCfg = Release|x64
{95716BEC-FF5A-4666-B8FE-547512CA38E0}.Release|Win32.Build.0 = Release|x64
{95716BEC-FF5A-4666-B8FE-547512CA38E0}.Release|x64.ActiveCfg = Release|x64
{95716BEC-FF5A-4666-B8FE-547512CA38E0}.Release|x64.Build.0 = Release|x64
{95716BEC-FF5A-4666-B8FE-547512CA38E0}.Release|x86.ActiveCfg = Release|x64
{95716BEC-FF5A-4666-B8FE-547512CA38E0}.Release|x86.Build.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@@ -274,6 +292,7 @@ Global
{F0E3446E-D9D7-4F44-AC98-797C5124BE91} = {8E8E4C8D-E3E1-4CB9-BD78-7ADAB2F2CF45}
{75BA171D-708A-40AA-A27D-57150E5DFB7B} = {72E29C1E-8723-4885-A5ED-BD3A929D81B6}
{90180080-9585-499C-99A8-6F4D1725CAF4} = {8F0E1457-FB1E-47A4-9DA8-74A6B757CAA4}
{95716BEC-FF5A-4666-B8FE-547512CA38E0} = {8E8E4C8D-E3E1-4CB9-BD78-7ADAB2F2CF45}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {4B6EE1D0-5ADF-44A2-B6EE-E5C8E110EE47}
+41 -33
View File
@@ -14,50 +14,58 @@ void API::ListenerCallback(void* tdParam, OrbisNetId s, OrbisNetInAddr sin_addr)
// Deserialize the packet.
auto Packet = RecievePacket<APIPacket>(s);
// Did we recieve a packet?
if (Packet == nullptr)
{
return;
}
// Validate Packet
if (strcmp(Packet->PacketMagic, "ORBIS_SUITE") && Packet->PacketVersion != PACKET_VERSION)
{
klog("Invalid Packet with Magic %s and Version %i\n", Packet->PacketMagic, Packet->PacketVersion);
free(Packet);
return;
}
//if (Packet->Command > 0 && Packet->Command <= ARRAY_COUNT(CommandList))
//{
// klog("Recieved the Command %i(%s)\n", Packet->Command, CommandList[Packet->Command]);
//}
// Add host to the host list.
Events::AddHost(sin_addr.s_addr);
if (Packet != nullptr)
// Send out the command to the right places.
switch (Packet->Command)
{
// Make sure were getting the proper packet version.
if (Packet->PacketVersion != PACKET_VERSION)
{
//klog("Packet version %i does not match our expected %i version!\n", Packet->PacketVersion, PACKET_VERSION);
default:
klog("API: Invalid Command %i...\n", Packet->Command);
break;
free(Packet);
case APICommands::PROC_START ... APICommands::PROC_END:
Proc->HandleAPI(s, Packet);
break;
return;
}
case APICommands::APP_START ... APICommands::APP_END:
Apps->HandleAPI(s, Packet);
break;
// Send out the command to the right places.
switch (Packet->Command)
{
default:
klog("API: Invalid Command %i...\n", Packet->Command);
break;
case APICommands::DBG_START ... APICommands::DBG_END:
Debug->HandleAPI(s, Packet);
break;
case APICommands::PROC_START ... APICommands::PROC_END:
Proc->HandleAPI(s, Packet);
break;
case APICommands::KERN_START ... APICommands::KERN_END:
klog("Kernel API Call\n");
case APICommands::APP_START ... APICommands::APP_END:
Apps->HandleAPI(s, Packet);
break;
break;
case APICommands::DBG_START ... APICommands::DBG_END:
Debug->HandleAPI(s, Packet);
break;
case APICommands::TARGET_START ... APICommands::TARGET_END:
Target->HandleAPI(s, Packet);
break;
case APICommands::KERN_START ... APICommands::KERN_END:
klog("Kernel API Call\n");
break;
case APICommands::TARGET_START ... APICommands::TARGET_END:
Target->HandleAPI(s, Packet);
break;
}
}
// Clean up. :)
+113 -1
View File
@@ -1,7 +1,7 @@
#pragma once
#include "Common.h"
#define PACKET_VERSION 2
#define PACKET_VERSION 3
#pragma region Commands
@@ -114,6 +114,117 @@ enum APICommands
/* ############################## */
};
constexpr const char* CommandList[] = {
"Invalid Command",
/* ####### Proc functions ####### */
"PROC_START",
"API_PROC_GET_LIST",
"API_PROC_LOAD_ELF",
"API_PROC_CALL", /* RPC Call. */
"PROC_END",
/* ############################## */
/* ####### Apps functions ####### */
"APP_START",
"API_APPS_GET_LIST",
"API_APPS_GET_INFO_STR",
"API_APPS_STATUS",
"API_APPS_START",
"API_APPS_STOP",
"API_APPS_SUSPEND",
"API_APPS_RESUME",
"API_APPS_DELETE",
"API_APPS_SET_VISIBILITY",
"API_APPS_GET_VISIBILITY",
"APP_END",
/* ############################## */
/* ##### Debugger functions ##### */
"DBG_START",
"API_DBG_ATTACH", /* Debugger attach to target */
"API_DBG_DETACH", /* Debugger detach from target */
"API_DBG_GET_CURRENT",
"API_DBG_READ",
"API_DBG_WRITE",
"API_DBG_KILL",
"API_DBG_BREAK",
"API_DBG_RESUME",
"API_DBG_SIGNAL",
"API_DBG_STEP",
"API_DBG_STEP_OVER",
"API_DBG_STEP_OUT",
"API_DBG_GET_CALLSTACK",
"API_DBG_GET_REG",
"API_DBG_SET_REG",
"API_DBG_GET_FREG",
"API_DBG_SET_FREG",
"API_DBG_GET_DBGREG",
"API_DBG_SET_DBGREG",
/* Remote Library functions */
"API_DBG_LOAD_LIBRARY",
"API_DBG_UNLOAD_LIBRARY",
"API_DBG_RELOAD_LIBRARY",
"API_DBG_LIBRARY_LIST",
/* Thread Management */
"API_DBG_THREAD_LIST",
"API_DBG_THREAD_STOP",
"API_DBG_THREAD_RESUME",
/* Breakpoint functions */
"API_DBG_BREAKPOINT_GETFREE",
"API_DBG_BREAKPOINT_SET",
"API_DBG_BREAKPOINT_UPDATE",
"API_DBG_BREAKPOINT_REMOVE",
"API_DBG_BREAKPOINT_GETINFO",
"API_DBG_BREAKPOINT_LIST",
/* Watchpoint functions */
"API_DBG_WATCHPOINT_SET",
"API_DBG_WATCHPOINT_UPDATE",
"API_DBG_WATCHPOINT_REMOVE",
"API_DBG_WATCHPOINT_GETINFO",
"API_DBG_WATCHPOINT_LIST",
"DBG_END",
/* ############################## */
/* ###### Kernel functions ###### */
"KERN_START",
"API_KERN_BASE",
"API_KERN_READ",
"API_KERN_WRITE",
"KERN_END",
/* ############################## */
/* ###### Target functions ###### */
"TARGET_START",
"API_TARGET_INFO",
"API_TARGET_RESTMODE",
"API_TARGET_SHUTDOWN",
"API_TARGET_REBOOT",
"API_TARGET_NOTIFY",
"API_TARGET_BUZZER",
"API_TARGET_SET_LED",
"API_TARGET_DUMP_PROC",
"API_TARGET_SET_SETTINGS",
"API_TARGET_GETFILE",
"TARGET_END",
/* ############################## */
};
#pragma endregion
#pragma region Generic
@@ -136,6 +247,7 @@ enum APIResults
struct APIPacket
{
char PacketMagic[10];
int PacketVersion;
int Command;
};
+73
View File
@@ -40,10 +40,14 @@ void Debug::HandleAPI(OrbisNetId Sock, APIPacket* Packet)
case API_DBG_READ:
ReadWriteMemory(Sock, false);
break;
case API_DBG_WRITE:
ReadWriteMemory(Sock, true);
break;
case API_DBG_KILL:
@@ -387,6 +391,75 @@ void Debug::GetLibraryList(OrbisNetId Sock)
Sockets::SendLargeData(Sock, (unsigned char*)libraryList.data(), libraryList.size() * sizeof(LibraryPacket));
}
void Debug::ReadWriteMemory(OrbisNetId Sock, bool write)
{
if (!IsDebugging || CurrentPID == -1)
{
return;
}
// Get next packet.
auto Packet = (DbgRWPacket*)malloc(sizeof(DbgRWPacket));
sceNetRecv(Sock, Packet, sizeof(DbgRWPacket), 0);
if (write)
{
auto buffer = (unsigned char*)malloc(Packet->Length);
if (!Sockets::RecvLargeData(Sock, buffer, Packet->Length))
{
free(buffer);
klog("Failed to recieve memory to write\n");
return;
}
if (!GeneralIPC::ReadWriteMemory(CurrentPID, Packet->Address, buffer, Packet->Length, true))
{
free(buffer);
klog("Failed to write memory to process %i at %llX\n", CurrentPID, Packet->Address);
Sockets::SendInt(Sock, 0);
return;
}
free(buffer);
Sockets::SendInt(Sock, 1);
}
else
{
auto buffer = (unsigned char*)malloc(Packet->Length);
if (!GeneralIPC::ReadWriteMemory(CurrentPID, Packet->Address, buffer, Packet->Length, false))
{
free(buffer);
klog("Failed to write memory to process %i at %llX\n", CurrentPID, Packet->Address);
Sockets::SendInt(Sock, 0);
return;
}
Sockets::SendInt(Sock, 1);
if (!Sockets::SendLargeData(Sock, buffer, Packet->Length))
{
free(buffer);
klog("Failed to send memory\n");
return;
}
free(buffer);
}
}
Debug::Debug()
{
IsDebugging = false;
+2
View File
@@ -23,4 +23,6 @@ private:
void UnloadLibrary(OrbisNetId Sock);
void ReloadLibrary(OrbisNetId Sock);
void GetLibraryList(OrbisNetId Sock);
void ReadWriteMemory(OrbisNetId Sock, bool write);
};
+105
View File
@@ -13,6 +13,11 @@ OrbisNetId GeneralIPC::Connect(int pid)
// Make new local Socket
auto Socket = sceNetSocket("GeneralIPC Socket", ORBIS_NET_AF_LOCAL, ORBIS_NET_SOCK_STREAM, 0);
if (Socket < 0)
{
klog("Failed to get socket: %llX\n", Socket);
return NULL;
}
auto res = sceNetConnect(Socket, (OrbisNetSockaddr*)&addr, SUN_LEN(&addr));
if (!res)
@@ -351,5 +356,105 @@ bool GeneralIPC::Jail(int pid)
// Close the socket.
sceNetSocketClose(sock);
return result == GIPC_OK;
}
bool GeneralIPC::ReadWriteMemory(int pid, uint64_t address, unsigned char* data, size_t length, bool write)
{
// Open a new local socket connection for the process.
auto sock = Connect(pid);
if (!sock)
{
klog("[GeneralIPC] ReadWriteMemory(): Failed to connect to socket.\n");
return false;
}
// Send the command.
if (!SendCommand(sock, GIPC_RW))
{
// Close the socket.
sceNetSocketClose(sock);
klog("[GeneralIPC] ReadWriteMemory(): Failed to send command.\n");
return false;
}
// Create next packet.
auto Packet = (RWPacket*)malloc(sizeof(RWPacket));
Packet->Address = address;
Packet->Length = length;
Packet->Write = write;
// Send the packet.
if (sceNetSend(sock, Packet, sizeof(RWPacket), 0) < 0)
{
// Close the socket.
sceNetSocketClose(sock);
// Cleanup
free(Packet);
klog("[GeneralIPC] ReadWriteMemory(): Failed to send RWPacket.\n");
return false;
}
// Cleanup
free(Packet);
// Make sure the address was valid.
int result = 0;
if (!Sockets::RecvInt(sock, &result))
{
// Close the socket.
sceNetSocketClose(sock);
klog("[GeneralIPC] Failed to recv result.\n");
return false;
}
if (result == 0)
{
// Close the socket.
sceNetSocketClose(sock);
klog("[GeneralIPC] ReadWriteMemory():Invalid Address %llX\n", address);
return false;
}
// Recieve/Send Data
if (write)
{
if (!Sockets::SendLargeData(sock, data, length))
{
klog("[GeneralIPC] ReadWriteMemory(): Failed to send the data.");
return false;
}
}
else
{
if (!Sockets::RecvLargeData(sock, data, length))
{
klog("[GeneralIPC] ReadWriteMemory(): Failed to recv the data.");
return false;
}
}
// Recieve the result.
result = 0;
if (!Sockets::RecvInt(sock, &result))
{
// Close the socket.
sceNetSocketClose(sock);
klog("[GeneralIPC] Failed to recv result.\n");
return false;
}
// Close the socket.
sceNetSocketClose(sock);
return result == GIPC_OK;
}
+1
View File
@@ -14,4 +14,5 @@ public:
static bool UnLoadLibrary(int pid, int Handle);
static bool Jailbreak(int pid);
static bool Jail(int pid);
static bool ReadWriteMemory(int pid, uint64_t address, unsigned char* data, size_t length, bool write);
};
+5
View File
@@ -10,6 +10,11 @@ OrbisNetId ShellUIIPC::Connect()
// Make new local Socket
auto Socket = sceNetSocket("GeneralIPC Socket", ORBIS_NET_AF_LOCAL, ORBIS_NET_SOCK_STREAM, 0);
if (Socket < 0)
{
klog("Failed to get socket: %llX\n", Socket);
return NULL;
}
auto res = sceNetConnect(Socket, (OrbisNetSockaddr*)&addr, SUN_LEN(&addr));
if (!res)
+2 -2
View File
@@ -11,7 +11,7 @@ void* SocketListener::ClientThread(void* tdParam)
socketListener->ClientCallBack(socketListener->tdParam, Sock, sin_addr);
sceNetSocketClose(Sock);
free(Params);
delete Params;
// Kill our thread and exit.
scePthreadDetach(scePthreadSelf());
@@ -86,7 +86,7 @@ void* SocketListener::DoWork()
if (ClientSocket != -1)
{
// klog("New Connection from %i.%i.%i.%i!\n", ClientAddr.sin_addr.s_addr & 0xFF, (ClientAddr.sin_addr.s_addr >> 8) & 0xFF, (ClientAddr.sin_addr.s_addr >> 16) & 0xFF, (ClientAddr.sin_addr.s_addr >> 24) & 0xFF);
//klog("New Connection from %i.%i.%i.%i!\n", ClientAddr.sin_addr.s_addr & 0xFF, (ClientAddr.sin_addr.s_addr >> 8) & 0xFF, (ClientAddr.sin_addr.s_addr >> 16) & 0xFF, (ClientAddr.sin_addr.s_addr >> 24) & 0xFF);
int optval = 1;
sceNetSetsockopt(ClientSocket, ORBIS_NET_SOL_SOCKET, ORBIS_NET_SO_NOSIGPIPE, &optval, sizeof(optval));
+1 -1
View File
@@ -19,7 +19,7 @@ bool Sockets::RecvInt(OrbisNetId Sock, int* val)
auto res = sceNetRecv(Sock, val, sizeof(int), 0);
if (res <= 0)
{
klog("RecvInt(): Failed to send %llX\n", res);
klog("RecvInt(): Failed to recv %llX\n", res);
return false;
}
+2 -1
View File
@@ -1,6 +1,6 @@
#pragma once
#define ARRAY_COUNT(arry) sizeof(arry) / sizeof(arry[0])
// Misc
bool LoadModules();
@@ -32,6 +32,7 @@ struct kinfo_proc {
#define KERN_PROC 14
#define KERN_PROC_ALL 0
#define KERN_PROC_PROC 8
#define KERN_PROC_PID 1
void hexdump(void* ptr, int buflen);
int GetProcessList(std::vector<kinfo_proc>& ProcessList);
+11 -11
View File
@@ -1,11 +1,11 @@
#pragma once
#define ORBISLIB_MAJOR 3
#define ORBISLIB_MINOR 0
#define ORBISLIB_BUILDVERSION 995
#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 1021
#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,16 +2,6 @@
#include "Detour.h"
#include "hde64.h"
#define VM_PROT_NONE ((int) 0x00)
#define VM_PROT_READ ((int) 0x01)
#define VM_PROT_WRITE ((int) 0x02)
#define VM_PROT_EXECUTE ((int) 0x04)
#define VM_PROT_COPY ((int) 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 Detour::WriteJump(void* Address, void* Destination)
{
uint8_t JumpInstructions[] = {
@@ -11,9 +11,10 @@ void* LocalSocketListener::ClientThread(void* tdParam)
localSocketListener->ClientCallBack(localSocketListener->tdParam, Sock);
sceNetSocketClose(Sock);
free(Params);
delete Params;
// Kill our thread and exit.
scePthreadDetach(scePthreadSelf());
scePthreadExit(NULL);
return nullptr;
}
@@ -59,6 +59,107 @@ void LoadUnloadLib(int Command, OrbisNetId Sock)
free(Packet);
}
void ReadWriteMemory(OrbisNetId Sock)
{
int res = 0;
// Get the packet for the info.
auto Packet = (RWPacket*)malloc(sizeof(RWPacket));
if (sceNetRecv(Sock, Packet, sizeof(RWPacket), 0) < 0)
{
klog("ReadWriteMemory(): Failed to recieve packet\n");
free(Packet);
return;
}
// Make sure the address is valid.
OrbisKernelModuleInfo info;
if (Packet->Address == 0 || !GetModuleFromAddress(Packet->Address, &info) && !IsMemoryMapped(Packet->Address))
{
Sockets::SendInt(Sock, 0);
klog("ReadWriteMemory(): Failed to validate address.\n");
free(Packet);
return;
}
// Get the current protection of the memory.
int prot;
res = sceKernelQueryMemoryProtection((void*)Packet->Address, nullptr, nullptr, &prot);
if (res != 0)
{
Sockets::SendInt(Sock, 0);
klog("ReadWriteMemory(): Failed to get memory prot: %llX\n", res);
free(Packet);
return;
}
// Set the protection level so we can RW.
res = sceKernelMprotect((void* )Packet->Address, Packet->Length, VM_PROT_ALL);
if (res != 0)
{
Sockets::SendInt(Sock, 0);
klog("ReadWriteMemory(): Failed to set memory prot: %llX\n", res);
free(Packet);
return;
}
Sockets::SendInt(Sock, 1);
// Read / Write the memory.
if (Packet->Write)
{
auto buffer = (unsigned char*)malloc(Packet->Length);
if (!Sockets::RecvLargeData(Sock, buffer, Packet->Length))
{
klog("ReadWriteMemory(): Failed to recieve the data.\n");
free(buffer);
goto Exit;
}
memcpy((void*)Packet->Address, buffer, Packet->Length);
free(buffer);
}
else
{
auto buffer = (unsigned char*)malloc(Packet->Length);
memcpy(buffer, (void*)Packet->Address, Packet->Length);
if (!Sockets::SendLargeData(Sock, buffer, Packet->Length))
{
klog("ReadWriteMemory(): Failed to send memory.\n");
}
free(buffer);
}
Exit:
// Reset the protection back.
res = sceKernelMprotect((void*)Packet->Address, Packet->Length, prot);
if (res != 0)
{
klog("ReadMemory(): Failed to restore memory prot: %llX\n", res);
}
free(Packet);
Sockets::SendInt(Sock, 1);
}
void ListenerClientThread(void* tdParam, OrbisNetId Sock)
{
int Command = 0;
@@ -69,7 +170,7 @@ void ListenerClientThread(void* tdParam, OrbisNetId Sock)
return;
}
if (!Sockets::SendInt(Sock, GIPC_OK))
if (!Sockets::SendInt(Sock, 1))
{
klog("Failed to send confirm command.\n");
return;
@@ -85,7 +186,7 @@ void ListenerClientThread(void* tdParam, OrbisNetId Sock)
case GIPC_HELLO:
Sockets::SendInt(Sock, GIPC_OK);
Sockets::SendInt(Sock, 1);
break;
@@ -104,7 +205,7 @@ void ListenerClientThread(void* tdParam, OrbisNetId Sock)
Jailbreak();
Sockets::SendInt(Sock, GIPC_OK);
Sockets::SendInt(Sock, 1);
break;
@@ -112,12 +213,14 @@ void ListenerClientThread(void* tdParam, OrbisNetId Sock)
RestoreJail();
Sockets::SendInt(Sock, GIPC_OK);
Sockets::SendInt(Sock, 1);
break;
case GIPC_RW:
// Might not really need this.
case GIPC_RW:
ReadWriteMemory(Sock);
break;
case GIPC_PROT:
@@ -131,8 +234,6 @@ extern "C"
{
int __cdecl module_start(size_t argc, const void* args)
{
klog("Hello from Helper!\n");
klog("Helping with %d\n", getpid());
char serverAddress[0x200];
@@ -68,7 +68,7 @@ del /s /q /f $(IntDir)\*.oelf</NMakeCleanCommandLine>
<ClCompile Include="hde64.cpp" />
<ClCompile Include="LocalSocketListener.cpp" />
<ClCompile Include="OrbisLibGeneralHelper.cpp" />
<ClCompile Include="Socket.cpp" />
<ClCompile Include="Sockets.cpp" />
<ClCompile Include="Utilities.cpp" />
</ItemGroup>
<ItemGroup>
@@ -32,7 +32,7 @@
<ClCompile Include="Detour.cpp">
<Filter>Source Files\Utilities</Filter>
</ClCompile>
<ClCompile Include="Socket.cpp">
<ClCompile Include="Sockets.cpp">
<Filter>Source Files\Utilities</Filter>
</ClCompile>
</ItemGroup>
@@ -32,5 +32,28 @@ bool Sockets::SendLargeData(OrbisNetId Sock, unsigned char* data, size_t dataLen
CurrentPosition += res;
}
return true;
}
bool Sockets::RecvLargeData(OrbisNetId Sock, unsigned char* data, size_t dataLen)
{
size_t DataLeft = dataLen;
int Received = 0;
int res = 0;
while (DataLeft > 0)
{
size_t DataChunkSize = std::min((size_t)8192, DataLeft);
res = sceNetRecv(Sock, data + Received, DataChunkSize, 0);
if (res < 0)
{
return false;
}
Received += res;
DataLeft -= res;
}
return true;
}
+1 -1
View File
@@ -6,7 +6,7 @@ public:
static bool SendInt(OrbisNetId Sock, int val);
static bool RecvInt(OrbisNetId Sock, int* val);
static bool SendLargeData(OrbisNetId Sock, unsigned char* data, size_t dataLen);
static bool RecvLargeData(OrbisNetId Sock, unsigned char* data, size_t dataLen);
private:
};
@@ -45,4 +45,45 @@ void RestoreJail()
{
jbc_set_cred(&BackupCred);
}
}
#define ModuleMax 200
bool GetModuleFromAddress(uint64_t Address, OrbisKernelModuleInfo* out)
{
OrbisKernelModule List[ModuleMax];
size_t moduleCount;
auto res = sceKernelGetModuleList(List, sizeof(List), &moduleCount);
if (res != 0)
{
klog("GetModuleFromAddress(): Failed to get Module List: %llX\n", res);
return false;
}
for (int i = 0; i < ModuleMax; i++)
{
out->size = sizeof(OrbisKernelModuleInfo);
res = sceKernelGetModuleInfo(List[i], out);
if (res == 0)
{
for (int j = 0; j < out->segmentCount; j++)
{
auto baseAddress = (uint64_t)out->segmentInfo[j].address;
auto segSize = out->segmentInfo[j].size;
if (Address >= baseAddress && Address < (baseAddress + segSize))
{
return true;
}
}
}
}
return false;
}
bool IsMemoryMapped(uint64_t address)
{
OrbisKernelVirtualQueryInfo info;
return sceKernelVirtualQuery((void*)address, 0, &info, sizeof(info)) == 0;
}
+15 -1
View File
@@ -1,6 +1,20 @@
#pragma once
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
// Misc
void klog(const char* fmt, ...);
void Jailbreak();
void RestoreJail();
void RestoreJail();
bool GetModuleFromAddress(uint64_t Address, OrbisKernelModuleInfo* out);
bool IsMemoryMapped(uint64_t address);
@@ -0,0 +1,68 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<VCProjectVersion>15.0</VCProjectVersion>
<ProjectGuid>{95716bec-ff5a-4666-b8fe-547512ca38e0}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Makefile</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Makefile</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="Shared">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<NMakeOutput>eboot.bin</NMakeOutput>
<NMakePreprocessorDefinitions>_DEBUG;$(NMakePreprocessorDefinitions)</NMakePreprocessorDefinitions>
<NMakeBuildCommandLine>call build.bat $(IntDir) "$(TargetName)" "$(SolutionDir)"</NMakeBuildCommandLine>
<NMakeReBuildCommandLine>del /s /q /f $(IntDir)\*.o
del /s /q /f $(IntDir)\*.elf
del /s /q /f $(IntDir)\*.oelf
call build.bat $(IntDir) "$(TargetName)" "$(SolutionDir)"</NMakeReBuildCommandLine>
<NMakeCleanCommandLine>del /s /q /f $(IntDir)\*.o
del /s /q /f $(IntDir)\*.elf
del /s /q /f $(IntDir)\*.oelf</NMakeCleanCommandLine>
<OutDir>$(SolutionDir)</OutDir>
<NMakeIncludeSearchPath>$(OO_PS4_TOOLCHAIN)\include;$(NMakeIncludeSearchPath)</NMakeIncludeSearchPath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<NMakeOutput>eboot.bin</NMakeOutput>
<NMakePreprocessorDefinitions>NDEBUG;$(NMakePreprocessorDefinitions)</NMakePreprocessorDefinitions>
</PropertyGroup>
<ItemDefinitionGroup>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="main.cpp" />
<ClCompile Include="build.bat" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hh;hpp;hxx;hm;inl;inc;ipp;xsd</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="main.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="build.bat" />
</ItemGroup>
</Project>
+80
View File
@@ -0,0 +1,80 @@
SETLOCAL EnableDelayedExpansion
Rem Package information
set PKG_TITLE="My Homebrew"
set PKG_VERSION="1.00"
set PKG_ASSETS="assets"
set PKG_TITLE_ID="BREW00100"
set PKG_CONTENT_ID="IV0000-BREW00100_00-MYHOMEBREW000000"
Rem Libraries to link in
set libraries=-lc -lkernel -lc++
Rem set extra_flags=
Rem Read the script arguments into local vars
set intdir=%1
set targetname=%~2
set outputPath=%3
set outputElf=%intdir%\%targetname%.elf
set outputOelf=%intdir%\%targetname%.oelf
@mkdir %intdir%
Rem Compile object files for all the source files
for %%f in (*.c) do (
clang --target=x86_64-pc-freebsd12-elf -fPIC -funwind-tables -I"%OO_PS4_TOOLCHAIN%\\include" -I"%OO_PS4_TOOLCHAIN%\\include\\c++\\v1" %extra_flags% -c -o %intdir%\%%~nf.o %%~nf.c
)
for %%f in (*.cpp) do (
clang++ --target=x86_64-pc-freebsd12-elf -fPIC -funwind-tables -I"%OO_PS4_TOOLCHAIN%\\include" -I"%OO_PS4_TOOLCHAIN%\\include\\c++\\v1" %extra_flags% -c -o %intdir%\%%~nf.o %%~nf.cpp
)
Rem Get a list of object files for linking
set obj_files=
for %%f in (%1\\*.o) do set obj_files=!obj_files! .\%%f
Rem Link the input ELF
ld.lld -m elf_x86_64 -pie --script "%OO_PS4_TOOLCHAIN%\link.x" --eh-frame-hdr -o "%outputElf%" "-L%OO_PS4_TOOLCHAIN%\\lib" %libraries% --verbose "%OO_PS4_TOOLCHAIN%\lib\crt1.o" %obj_files%
Rem Create the eboot
%OO_PS4_TOOLCHAIN%\bin\windows\create-fself.exe -in "%outputElf%" --out "%outputOelf%" --eboot "eboot.bin" --paid 0x3800000000000011
Rem Create param.sfo
%OO_PS4_TOOLCHAIN%\bin\windows\PkgTool.Core.exe sfo_new sce_sys/param.sfo
%OO_PS4_TOOLCHAIN%\bin\windows\PkgTool.Core.exe sfo_setentry sce_sys/param.sfo APP_TYPE --type Integer --maxsize 4 --value 1
%OO_PS4_TOOLCHAIN%\bin\windows\PkgTool.Core.exe sfo_setentry sce_sys/param.sfo APP_VER --type Utf8 --maxsize 8 --value %PKG_VERSION%
%OO_PS4_TOOLCHAIN%\bin\windows\PkgTool.Core.exe sfo_setentry sce_sys/param.sfo ATTRIBUTE --type Integer --maxsize 4 --value 0
%OO_PS4_TOOLCHAIN%\bin\windows\PkgTool.Core.exe sfo_setentry sce_sys/param.sfo CATEGORY --type Utf8 --maxsize 4 --value "gd"
%OO_PS4_TOOLCHAIN%\bin\windows\PkgTool.Core.exe sfo_setentry sce_sys/param.sfo CONTENT_ID --type Utf8 --maxsize 48 --value %PKG_CONTENT_ID%
%OO_PS4_TOOLCHAIN%\bin\windows\PkgTool.Core.exe sfo_setentry sce_sys/param.sfo DOWNLOAD_DATA_SIZE --type Integer --maxsize 4 --value 0
%OO_PS4_TOOLCHAIN%\bin\windows\PkgTool.Core.exe sfo_setentry sce_sys/param.sfo SYSTEM_VER --type Integer --maxsize 4 --value 0
%OO_PS4_TOOLCHAIN%\bin\windows\PkgTool.Core.exe sfo_setentry sce_sys/param.sfo TITLE --type Utf8 --maxsize 128 --value %PKG_TITLE%
%OO_PS4_TOOLCHAIN%\bin\windows\PkgTool.Core.exe sfo_setentry sce_sys/param.sfo TITLE_ID --type Utf8 --maxsize 12 --value %PKG_TITLE_ID%
%OO_PS4_TOOLCHAIN%\bin\windows\PkgTool.Core.exe sfo_setentry sce_sys/param.sfo VERSION --type Utf8 --maxsize 8 --value %PKG_VERSION%
Rem Get a list of assets for packaging
set module_files=
for %%f in (sce_module\\*) do set module_files=!module_files! sce_module/%%~nxf
set asset_audio_files=
for %%f in (assets\\audio\\*) do set asset_audio_files=!asset_audio_files! assets/audio/%%~nxf
set asset_fonts_files=
for %%f in (assets\\fonts\\*) do set asset_fonts_files=!asset_fonts_files! assets/fonts/%%~nxf
set asset_images_files=
for %%f in (assets\\images\\*) do set asset_images_files=!asset_images_files! assets/images/%%~nxf
set asset_misc_files=
for %%f in (assets\\misc\\*) do set asset_misc_files=!asset_misc_files! assets/misc/%%~nxf
set asset_videos_files=
for %%f in (assets\\videos\\*) do set asset_videos_files=!asset_videos_files! assets/videos/%%~nxf
Rem Create gp4
%OO_PS4_TOOLCHAIN%\bin\windows\create-gp4.exe -out pkg.gp4 --content-id=%PKG_CONTENT_ID% --files "eboot.bin sce_sys/about/right.sprx sce_sys/param.sfo sce_sys/icon0.png %module_files% %asset_audio_files% %asset_fonts_files% %asset_images_files% %asset_misc_files% %asset_videos_files%"
Rem Create pkg
%OO_PS4_TOOLCHAIN%\bin\windows\PkgTool.Core.exe pkg_build pkg.gp4 ..
+7
View File
@@ -0,0 +1,7 @@
#include <stdio.h>
int main()
{
// Your code here...
return 0;
}
+3 -2
View File
@@ -46,8 +46,9 @@
</Reference>
<Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />
<Reference Include="SimpleUI">
<HintPath>C:\Users\grego\source\repos\SimpleUI-Framework\SimpleUI-Framework\bin\Debug\SimpleUI.dll</HintPath>
<Reference Include="SimpleUI, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>C:\Users\grego\source\repos\SimpleUI-Framework\SimpleUI-Framework\bin\Release\SimpleUI.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Buffers, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
@@ -43,7 +43,7 @@ namespace OrbisLib2.Common.API
if (Connect(DesiredTarget.IPAddress, Settings.CreateInstance().APIPort, TimeOut, out Socket Sock))
{
// Send Inital Packet.
var result = SendNextPacket(Sock, new APIPacket() { PacketVersion = Config.PacketVersion, Command = Command });
var result = SendNextPacket(Sock, new APIPacket() { PacketMagic="ORBIS_SUITE", PacketVersion = Config.PacketVersion, Command = Command });
// Call lambda for additional calls.
if (result == APIResults.API_OK && AdditionalCommunications != null)
@@ -130,6 +130,8 @@ namespace OrbisLib2.Common.API
[StructLayout(LayoutKind.Sequential, Pack = 4, CharSet = CharSet.Ansi, Size = 8), Serializable]
public struct APIPacket
{
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 10)]
public string PacketMagic;
public int PacketVersion;
public APICommands Command;
}
+1 -1
View File
@@ -61,6 +61,6 @@ namespace OrbisLib2.Common
/// <summary>
/// The version of the packets used to communicate with the Target Console.
/// </summary>
public static readonly int PacketVersion = 2;
public static readonly int PacketVersion = 3;
}
}
@@ -1,4 +1,5 @@
using System.Net.NetworkInformation;
using System.Data;
using System.Net.NetworkInformation;
using System.Net.Sockets;
using System.Text;
@@ -20,7 +21,7 @@ namespace OrbisLib2.Common.Helpers
while (Left > 0)
{
var chunkSize = Math.Min(s.ReceiveBufferSize, Left);
var chunkSize = Math.Min(8192, Left);
var res = s.Receive(data, Received, chunkSize, 0);
Received += res;
@@ -33,6 +34,28 @@ namespace OrbisLib2.Common.Helpers
}
}
public static void SendLarge(this Socket s, byte[] data)
{
try
{
int Left = data.Length;
int CurrentPosition = 0;
while (Left > 0)
{
var chunkSize = Math.Min(8192, Left);
var res = s.Send(data, CurrentPosition, chunkSize, 0);
Left -= res;
CurrentPosition += res;
}
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
}
/// <summary>
/// Sends an object and its size to the socket.
/// </summary>
+1 -1
View File
@@ -36,7 +36,7 @@
<ItemGroup>
<Reference Include="SimpleUI">
<HintPath>..\..\..\External\SimpleUI\SimpleUI\bin\Debug\net6.0-windows\SimpleUI.dll</HintPath>
<HintPath>..\..\..\External\SimpleUI\SimpleUI\bin\Release\net6.0-windows\SimpleUI.dll</HintPath>
</Reference>
</ItemGroup>
@@ -10,6 +10,7 @@ using System.Runtime.InteropServices;
using System.Security.Cryptography;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Markup;
using static SQLite.SQLite3;
namespace OrbisLib2.Targets
@@ -198,5 +199,68 @@ namespace OrbisLib2.Targets
return libraryList;
}
public byte[] ReadMemory(ulong Address, ulong Length)
{
if (!IsDebugging)
{
return new byte[0];
}
int readResult = 0;
var data = new byte[Length];
var result = API.SendCommand(Target, 6, APICommands.API_DBG_READ, (Socket Sock, APIResults Result) =>
{
var isDebugging = Sock.RecvInt32();
if (isDebugging == 1)
{
var Packet = new DbgRWPacket();
Packet.Address = Address;
Packet.Length = Length;
Sock.Send(Helper.StructToBytes(Packet));
// Status
readResult = Sock.RecvInt32();
// Recv the memory if the address was valid.
if (readResult == 1)
{
Sock.RecvLarge(data);
}
}
});
return readResult == 1 ? data : new byte[0];
}
public bool WriteMemory(ulong Address, byte[] Data)
{
if (!IsDebugging)
{
return false;
}
int writeResult = 0;
var result = API.SendCommand(Target, 6, APICommands.API_DBG_WRITE, (Socket Sock, APIResults Result) =>
{
var isDebugging = Sock.RecvInt32();
if (isDebugging == 1)
{
var Packet = new DbgRWPacket();
Packet.Address = Address;
Packet.Length = (ulong)Data.Length;
Sock.Send(Helper.StructToBytes(Packet));
// Send the memory to write.
Sock.SendLarge(Data);
// Status
writeResult = Sock.RecvInt32();
}
});
return writeResult == 1;
}
}
}
@@ -41,7 +41,7 @@
<HintPath>..\..\External\SimpleUI\SimpleUI\bin\Debug\net6.0-windows\Microsoft.Expression.Drawing.dll</HintPath>
</Reference>
<Reference Include="SimpleUI">
<HintPath>..\..\External\SimpleUI\SimpleUI\bin\Debug\net6.0-windows\SimpleUI.dll</HintPath>
<HintPath>..\..\External\SimpleUI\SimpleUI\bin\Release\net6.0-windows\SimpleUI.dll</HintPath>
</Reference>
</ItemGroup>
@@ -181,8 +181,7 @@
<HintPath>..\..\External\SimpleUI\SimpleUI\Libraries\Microsoft.Expression.Drawing.dll</HintPath>
</Reference>
<Reference Include="SimpleUI">
<HintPath>..\..\External\SimpleUI\SimpleUI\bin\Debug\net6.0-windows\SimpleUI.dll</HintPath>
<CopyLocal>True</CopyLocal>
<HintPath>..\..\External\SimpleUI\SimpleUI\bin\Release\net6.0-windows\SimpleUI.dll</HintPath>
</Reference>
</ItemGroup>
@@ -1 +1 @@
2415
2528
@@ -1 +1 @@
Version 3.0.2415 Debug Build Sunday January 15 2023 5:32 PM
Version 3.0.2528 Debug Build Thursday January 19 2023 10:59 PM
+7 -6
View File
@@ -1,10 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0-windows</TargetFramework>
<Nullable>enable</Nullable>
<UseWPF>true</UseWPF>
<UseWindowsForms>true</UseWindowsForms>
<PackageIcon></PackageIcon>
<ApplicationIcon>OrbisPeeknPoke.ico</ApplicationIcon>
</PropertyGroup>
@@ -53,14 +54,14 @@
</ItemGroup>
<ItemGroup>
<Reference Include="Be.Windows.Forms.HexBox">
<HintPath>..\..\External\Be.HexEditor\Be.Windows.Forms.HexBox\bin\Release\Be.Windows.Forms.HexBox.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Expression.Drawing">
<HintPath>..\..\External\SimpleUI\SimpleUI\bin\Debug\net6.0-windows\Microsoft.Expression.Drawing.dll</HintPath>
</Reference>
<Reference Include="SimpleUI">
<HintPath>..\..\External\SimpleUI\SimpleUI\bin\Debug\net6.0-windows\SimpleUI.dll</HintPath>
</Reference>
<Reference Include="WPFHexaEditor">
<HintPath>C:\Users\grego\.nuget\packages\wpfhexaeditor\2.1.7\lib\net5.0-windows7.0\WPFHexaEditor.dll</HintPath>
<HintPath>..\..\External\SimpleUI\SimpleUI\bin\Release\net6.0-windows\SimpleUI.dll</HintPath>
</Reference>
</ItemGroup>
@@ -69,7 +70,7 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="HexView.Wpf" Version="0.1.0" />
<PackageReference Include="BinaryTools.Elf" Version="0.3.0" />
</ItemGroup>
</Project>
+163 -75
View File
@@ -6,12 +6,12 @@
xmlns:local="clr-namespace:OrbisPeeknPoke"
xmlns:simpleControls="clr-namespace:SimpleUI.Controls;assembly=SimpleUI"
xmlns:controls="clr-namespace:OrbisPeeknPoke.Controls"
xmlns:hv="clr-namespace:HexView.Wpf;assembly=HexView.Wpf"
xmlns:hv="clr-namespace:Be.Windows.Forms;assembly=Be.Windows.Forms.HexBox"
mc:Ignorable="d"
Title="Peek n' Poke"
Height="640" Width="980"
MinHeight="640" MinWidth="980"
MaxHeight="640" MaxWidth="980">
Height="660" Width="837"
MinHeight="660" MinWidth="837"
MaxHeight="660" MaxWidth="837">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition/>
@@ -29,68 +29,19 @@
<!-- Separation bar -->
<Rectangle Grid.Column="0"
Height="0.5" VerticalAlignment="Top"
Height="0.6" VerticalAlignment="Top"
Fill="{DynamicResource WindowBackground}" Grid.ColumnSpan="2"/>
<!-- Separation bar Main Top -->
<Rectangle Grid.Column="0"
Height="1" VerticalAlignment="Bottom"
Fill="{DynamicResource WindowBackground}" Grid.ColumnSpan="2"/>
<!-- Current Target -->
<controls:CurrentTargetDisplay VerticalAlignment="Center" Grid.ColumnSpan="2"/>
<StackPanel Orientation="Horizontal"
HorizontalAlignment="Right" Grid.ColumnSpan="2">
<!-- SPRX Loader -->
<StackPanel HorizontalAlignment="Right"
Margin="6">
<StackPanel Orientation="Horizontal">
<simpleControls:SimpleTextField Name="BaseAddress"
FieldName="Base Address"
FieldText=""
IsReadOnly="False"
VerticalContentAlignment="Center"
Width="110"
Margin="0 0 6 0"/>
<simpleControls:SimpleTextField Grid.Column="0"
Name="Offset"
FieldName="Offset"
FieldText=""
IsReadOnly="False"
VerticalContentAlignment="Center"
Width="110"/>
</StackPanel>
<StackPanel Orientation="Horizontal"
Margin="0 6 0 0 "
HorizontalAlignment="Right">
<simpleControls:SimpleButton Name="SelectBase"
Content="Get Base Address"
Width="110"
Height="25"
Margin="0 0 6 0"
Click="SelectBase_Click"/>
<simpleControls:SimpleButton Name="Peek"
Content="Peek"
Width="52"
Height="25"
Margin="0 0 6 0"
Click="Peek_Click"/>
<simpleControls:SimpleButton Name="Poke"
Content="Poke"
Width="52"
Height="25"
Click="Poke_Click"/>
</StackPanel>
</StackPanel>
<!-- Current Debugging Process -->
<StackPanel HorizontalAlignment="Right"
Margin="0 6 6 6">
@@ -179,12 +130,126 @@
</StackPanel>
<!-- Main View -->
<hv:HexViewer x:Name="HexBox"
Grid.Row="1"
Height="507"
Width="934"
MaxWidth="934"
MaxHeight="507"/>
<WindowsFormsHost Grid.Row="1"
Height="Auto" Width="625"
HorizontalAlignment="Left"
x:Name="FormsHost">
<hv:HexBox x:Name="HexBox"
StringViewVisible="True"
UseFixedBytesPerLine="True"
VScrollBarVisible="false"
LineInfoVisible="True"
ColumnInfoVisible="True"
GroupSeparatorVisible="false"
Font="Segoe UI"
InfoForeColor="186, 105, 105"
ForeColor="220, 220, 220"
BackColor="60, 63, 65"
ChangedForeColor="186, 105, 105"
SelectionBackColor="100, 176, 75, 75"
SelectionForeColor="Gainsboro"
ShadowSelectionColor="100, 176, 75, 75"
BorderStyle="None"
MouseDown="HexBox_MouseDown"/>
<WindowsFormsHost.ContextMenu>
<ContextMenu>
<MenuItem Name="FollowPointer" Header="Follow Pointer" Click="FollowPointer_Click"/>
<MenuItem Name="ReturnPointer" Header="Return" Click="ReturnPointer_Click" IsEnabled="False"/>
<Separator/>
<MenuItem Name="CopyHex" Header="Copy Hex" Click="CopyHex_Click"/>
<MenuItem Name="PasteHex" Header="Paste Hex" Click="PasteHex_Click"/>
<Separator/>
<MenuItem Name="CopyText" Header="Copy Text" Click="CopyText_Click"/>
<MenuItem Name="PasteText" Header="Paste Text" Click="PasteText_Click"/>
<Separator/>
<MenuItem Name="SelectAll" Header="Select All" Click="SelectAll_Click"/>
</ContextMenu>
</WindowsFormsHost.ContextMenu>
</WindowsFormsHost>
<!-- Control Area -->
<Grid Grid.Row="1" HorizontalAlignment="Right">
<!-- Background -->
<Border
HorizontalAlignment="Right"
Width="192"
Background="{DynamicResource WindowBar}"/>
<StackPanel Orientation="Vertical"
VerticalAlignment="Top"
HorizontalAlignment="Right"
Margin="0 6 0 0">
<!-- Base Address -->
<StackPanel Orientation="Horizontal"
>
<simpleControls:SimpleTextField
Name="BaseAddress"
FieldName="Base Address"
FieldText=""
IsReadOnly="False"
VerticalContentAlignment="Center"
Width="143"
Margin="6 0 6 6"/>
<simpleControls:SimpleButton
Name="SelectBase"
Content="Get"
Width="31"
Height="31"
Margin="0 0 6 6"
Click="SelectBase_Click"/>
</StackPanel>
<!-- Offset / Len -->
<StackPanel Orientation="Horizontal">
<simpleControls:SimpleTextField Grid.Column="0"
Name="Offset"
FieldName="Offset"
FieldText=""
IsReadOnly="False"
Margin="6 0 6 6"
VerticalContentAlignment="Center"
Width="87"/>
<simpleControls:SimpleTextField Grid.Column="0"
Name="Length"
FieldName="Length"
FieldText="0x200"
IsReadOnly="False"
Margin="0 0 0 6"
VerticalContentAlignment="Center"
Width="87"/>
</StackPanel>
<!-- Peek / Poke -->
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right">
<simpleControls:SimpleButton Name="Peek"
Content="Peek"
Width="52"
Height="25"
Margin="0 0 6 0"
Click="Peek_Click"/>
<simpleControls:SimpleButton Name="Poke"
Content="Poke"
Width="52"
Height="25"
Margin="0 0 6 0"
Click="Poke_Click"/>
</StackPanel>
</StackPanel>
</Grid>
<!-- Info BG -->
<Rectangle Grid.Row="2"
@@ -197,28 +262,51 @@
VerticalAlignment="Center">
<!-- Address -->
<TextBlock
<StackPanel Orientation="Horizontal">
<TextBlock
Foreground="{DynamicResource Text}"
FontSize="13"
Margin="0 0 10 0">
<Bold>Address:</Bold> 0x400000
</TextBlock>
FontWeight="Bold"
Text="Address: ">
</TextBlock>
<TextBlock
Foreground="{DynamicResource Text}"
FontSize="13"
Margin="0 0 10 0"
Text="0x0">
</TextBlock>
</StackPanel>
<!-- Offset -->
<TextBlock
<StackPanel Orientation="Horizontal">
<TextBlock
Foreground="{DynamicResource Text}"
FontSize="13"
Margin="0 0 5 0">
<Bold>Offset:</Bold> 0x100
</TextBlock>
FontWeight="Bold"
Text="Offset: ">
</TextBlock>
<TextBlock
x:Name="OffsetValue"
Foreground="{DynamicResource Text}"
FontSize="13"
Margin="0 0 10 0"
Text="0x0">
</TextBlock>
</StackPanel>
<!-- Slection -->
<!-- Length -->
</StackPanel>
<!-- Separation bar Main Bottom -->
<Rectangle Grid.Column="0"
Grid.Row="2"
Height="1" VerticalAlignment="Top"
Fill="{DynamicResource WindowBackground}" Grid.ColumnSpan="2"/>
</Grid>
</simpleControls:SimpleWindow>
+267 -66
View File
@@ -1,12 +1,23 @@
using OrbisLib2.Common.Database.Types;
using Be.Windows.Forms;
using OrbisLib2.Common.Database.Types;
using OrbisLib2.Common.Dispatcher;
using OrbisLib2.Dialog;
using OrbisLib2.General;
using OrbisLib2.Targets;
using SimpleUI.Controls;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Net;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Windows;
using WpfHexaEditor;
using System.Windows.Forms;
using System.Windows.Forms.Integration;
using System.Windows.Input;
using System.Windows.Shell;
namespace OrbisPeeknPoke
{
@@ -15,8 +26,12 @@ namespace OrbisPeeknPoke
/// </summary>
public partial class MainWindow : SimpleWindow
{
private List<ulong> JumpList = new();
public MainWindow()
{
System.Windows.Forms.Application.EnableVisualStyles();
InitializeComponent();
DispatcherClient.Subscribe();
@@ -27,56 +42,19 @@ namespace OrbisPeeknPoke
Events.DBTouched += Events_DBTouched;
Events.SelectedTargetChanged += Events_SelectedTargetChanged;
HexBox.CurrentLineChanged += HexBox_CurrentLineChanged;
HexBox.CurrentPositionInLineChanged += HexBox_CurrentPositionInLineChanged;
}
public byte[] testData =
private void HexBox_CurrentPositionInLineChanged(object? sender, EventArgs e)
{
0x2F, 0x6C, 0x69, 0x62, 0x65, 0x78, 0x65, 0x63, 0x2F, 0x6C, 0x64, 0x2D,
0x65, 0x6C, 0x66, 0x2E, 0x73, 0x6F, 0x2E, 0x31, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x55, 0x48, 0x89, 0xE5,
0x41, 0x57, 0x41, 0x56, 0x53, 0x50, 0x48, 0x8D, 0x1D, 0x0F, 0x7E, 0x62,
0x01, 0x4C, 0x8D, 0x35, 0xE8, 0x7D, 0x62, 0x01, 0x48, 0x3B, 0x1D, 0x59,
0x08, 0x60, 0x01, 0x73, 0x33, 0x4C, 0x8D, 0x3D, 0xF8, 0x7D, 0x62, 0x01,
0x0F, 0x1F, 0x84, 0x00, 0x00, 0x00, 0x00, 0x00, 0x48, 0x8B, 0x03, 0x48,
0x85, 0xC0, 0x74, 0x02, 0xFF, 0xD0, 0x48, 0x83, 0xC3, 0x08, 0x4C, 0x39,
0xFB, 0x72, 0xED, 0xEB, 0x0F, 0x66, 0x66, 0x2E, 0x0F, 0x1F, 0x84, 0x00,
0x00, 0x00, 0x00, 0x00, 0x49, 0x83, 0xC6, 0xF8, 0x49, 0x8B, 0x06, 0x48,
0x85, 0xC0, 0x74, 0xF4, 0x48, 0x83, 0xF8, 0xFF, 0x74, 0x04, 0xFF, 0xD0,
0xEB, 0xEA, 0x48, 0x83, 0xC4, 0x08, 0x5B, 0x41, 0x5E, 0x41, 0x5F, 0x5D,
0xC3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x55, 0x48, 0x89, 0xE5, 0x41, 0x57, 0x41, 0x56,
0x53, 0x50, 0x44, 0x8B, 0x37, 0x48, 0x89, 0xF3, 0x4C, 0x8D, 0x7F, 0x08,
0xE8, 0xC7, 0xC7, 0x21, 0x01, 0x48, 0x89, 0xDF, 0xE8, 0xCF, 0xC7, 0x21,
0x01, 0x48, 0x8D, 0x3D, 0xA8, 0xE2, 0x20, 0x01, 0xE8, 0xC3, 0xC7, 0x21,
0x01, 0xE8, 0x4E, 0xFF, 0xFF, 0xFF, 0x31, 0xD2, 0x44, 0x89, 0xF7, 0x4C,
0x89, 0xFE, 0xE8, 0x21, 0xB4, 0xEC, 0x00, 0x89, 0xC3, 0x89, 0xDF, 0xE8,
0xB8, 0xC7, 0x21, 0x01, 0x89, 0xDF, 0xE8, 0x41, 0xB2, 0x21, 0x01, 0x0F,
0x0B, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90,
0x90, 0x90, 0x90, 0x90, 0x55, 0x48, 0x89, 0xE5, 0x48, 0x83, 0xEC, 0x10,
0x89, 0x4C, 0x24, 0x08, 0x48, 0x89, 0x14, 0x24, 0xBA, 0x08, 0x00, 0x00,
0x00, 0xB9, 0x0F, 0x00, 0x00, 0x00, 0x41, 0xB8, 0x08, 0x00, 0x00, 0x00,
0x45, 0x31, 0xC9, 0xE8, 0x08, 0x00, 0x00, 0x00, 0x48, 0x83, 0xC4, 0x10,
0x5D, 0xC3, 0x66, 0x90, 0x55, 0x48, 0x89, 0xE5, 0x41, 0x57, 0x41, 0x56,
0x41, 0x55, 0x41, 0x54, 0x53, 0x48, 0x83, 0xEC, 0x18, 0x45, 0x89, 0xC4,
0x49, 0x89, 0xFD, 0x48, 0x8B, 0x45, 0x10, 0x41, 0xBE, 0xFA, 0xFF, 0xFF,
0xFF, 0x48, 0x85, 0xC0, 0x0F, 0x84, 0x17, 0x03, 0x00, 0x00, 0x0F, 0xB6,
0x00, 0x83, 0xF8, 0x31, 0x0F, 0x85, 0x0B, 0x03, 0x00, 0x00, 0x83, 0x7D,
0x18, 0x70, 0x0F, 0x85, 0x01, 0x03, 0x00, 0x00, 0x41, 0xBE, 0xFE, 0xFF,
0xFF, 0xFF, 0x4D, 0x85, 0xED, 0x0F, 0x84, 0xF2, 0x02, 0x00, 0x00, 0x49,
0xC7, 0x45, 0x30, 0x00, 0x00, 0x00, 0x00, 0x49, 0x8B, 0x45, 0x40, 0x48,
0x85, 0xC0, 0x75, 0x13, 0x48, 0x8D, 0x05, 0x19, 0x84, 0x00, 0x00, 0x49,
0x89, 0x45, 0x40, 0x49, 0xC7, 0x45, 0x50, 0x00, 0x00, 0x00, 0x00, 0x49,
0x83, 0x7D, 0x48, 0x00, 0x75, 0x0B, 0x48, 0x8D, 0x3D, 0x0F, 0x84, 0x00,
0x00, 0x49, 0x89, 0x7D, 0x48, 0x83, 0xFE, 0xFF, 0xBF, 0x06, 0x00, 0x00,
0x00, 0x0F, 0x45, 0xFE, 0x85, 0xC9, 0x78, 0x15, 0x8D, 0x71, 0xF0, 0x83,
0xF9, 0x0F, 0x0F, 0x9F, 0xC3, 0x0F, 0x4E, 0xF1, 0x0F, 0xB6, 0xDB, 0xFF,
0xC3, 0x89, 0xF1, 0xEB, 0x04, 0xF7, 0xD9, 0x31, 0xDB, 0x41, 0x8D, 0x74,
0x24, 0xFF, 0x83, 0xFE, 0x08, 0x0F, 0x87, 0x86, 0x02, 0x00, 0x00, 0x83,
0xFA, 0x08, 0x0F, 0x85, 0x7D, 0x02, 0x00, 0x00, 0x83, 0xF9, 0x08, 0x0F,
0x8C, 0x74, 0x02, 0x00, 0x00, 0x83, 0xF9, 0x0F
};
OffsetValue.Text = $"0x{(((HexBox.CurrentLine - 1) * 0x10) + (HexBox.CurrentPositionInLine - 1)).ToString("X")}";
}
private void HexBox_CurrentLineChanged(object? sender, EventArgs e)
{
OffsetValue.Text = $"0x{(((HexBox.CurrentLine - 1) * 0x10) + (HexBox.CurrentPositionInLine - 1)).ToString("X")}";
}
#region Events
@@ -171,21 +149,109 @@ namespace OrbisPeeknPoke
#region Buttons
private bool TryConvertStringToUlong(string str, out ulong val)
{
if (str.StartsWith("0x"))
{
if (!ulong.TryParse(str.Substring(2), NumberStyles.HexNumber, CultureInfo.CurrentCulture, out val))
{
return false;
}
}
else
{
if (!ulong.TryParse(str, out val) && !ulong.TryParse(str, NumberStyles.HexNumber, CultureInfo.CurrentCulture, out val))
{
return false;
}
}
return true;
}
private bool GetPeekPokeInfo(out ulong address, out ulong length)
{
// Hex or decimal value of address
if (!TryConvertStringToUlong(BaseAddress.FieldText, out address))
{
SimpleMessageBox.ShowError(this, "Failed to parse Base Address please ensure that it is a valid hex or decimal number.", "Failed to parse Base Address.");
length = 0;
return false;
}
// Hex or decimal value of offset
ulong offset;
if (TryConvertStringToUlong(Offset.FieldText, out offset))
{
address += offset;
}
// Hex or decimal value of length
if (!TryConvertStringToUlong(Length.FieldText, out length))
{
SimpleMessageBox.ShowError(this, "Failed to parse Length please ensure that it is a valid hex or decimal number.", "Failed to parse Length.");
return false;
}
return true;
}
private void SelectBase_Click(object sender, RoutedEventArgs e)
{
Task.Run(() =>
{
var mainExecutable = TargetManager.SelectedTarget.Debug.GetLibraries().FirstOrDefault();
if (mainExecutable != null)
{
Dispatcher.Invoke(() => BaseAddress.FieldText = $"0x{mainExecutable.Segments[0].Address.ToString("X")}");
}
});
}
private void Peek_Click(object sender, RoutedEventArgs e)
{
HexBox.DataSource = new BinaryReader(new MemoryStream(testData));
//HexBox.DataContext = new BinaryReader(new MemoryStream(testData));
//HexBox.a = 0x400000;
GetPeekPokeInfo(out var address, out var length);
Task.Run(() =>
{
var data = TargetManager.SelectedTarget.Debug.ReadMemory(address, length);
if (data != null && data.Length > 0)
{
// Clear the jump list if were reading new memory.
if (JumpList.Count > 0 && address != JumpList.Last())
{
JumpList.Clear();
Dispatcher.Invoke(() => ReturnPointer.IsEnabled = false);
}
// Fill the hex box on the UI thread.
Dispatcher.Invoke(() =>
{
HexBox.VScrollBarVisible = true;
HexBox.ByteProvider = new DynamicByteProvider(data);
HexBox.VScrollBarVisible = false;
});
}
});
}
private void Poke_Click(object sender, RoutedEventArgs e)
{
if (HexBox.ByteProvider.Length <= 0)
return;
GetPeekPokeInfo(out var address, out var length);
byte[] bytes = new byte[HexBox.ByteProvider.Length];
//Grab the bytes from the hex window
for (int i = 0; i < HexBox.ByteProvider.Length; i++)
bytes[i] = HexBox.ByteProvider.ReadByte(i);
// Write bytes in task so we dont lock up the UI thread.
Task.Run(() => TargetManager.SelectedTarget.Debug.WriteMemory(address, bytes));
}
private void AttachProcess_Click(object sender, RoutedEventArgs e)
@@ -195,7 +261,7 @@ namespace OrbisPeeknPoke
private void DetachProcess_Click(object sender, RoutedEventArgs e)
{
TargetManager.SelectedTarget.Debug.Detach();
Task.Run(() => TargetManager.SelectedTarget.Debug.Detach());
}
private void LoadSomething_Click(object sender, RoutedEventArgs e)
@@ -205,34 +271,169 @@ namespace OrbisPeeknPoke
private void KillProcess_Click(object sender, RoutedEventArgs e)
{
var currentTarget = TargetManager.SelectedTarget;
var processList = TargetManager.SelectedTarget.Process.GetList();
var process = processList.Find(x => x.ProcessId == currentTarget.Debug.GetCurrentProcessId());
if (process != null)
Task.Run(() =>
{
if (process.AppId > 0)
var currentTarget = TargetManager.SelectedTarget;
var processList = TargetManager.SelectedTarget.Process.GetList();
var process = processList.Find(x => x.ProcessId == currentTarget.Debug.GetCurrentProcessId());
if (process != null)
{
currentTarget.Application.Stop(process.TitleId);
if (process.AppId > 0)
{
currentTarget.Application.Stop(process.TitleId);
}
else
{
SimpleMessageBox.ShowError(Window.GetWindow(this), $"Could not kill process \"{process.Name}\" because Orbis Suite doesnt currently support killing processes with out an appId.", "Error: Could not kill this process.");
}
}
else
{
SimpleMessageBox.ShowError(Window.GetWindow(this), $"Could not kill process \"{process.Name}\" because Orbis Suite doesnt currently support killing processes with out an appId.", "Error: Could not kill this process.");
}
}
});
}
private void RestartTarget_Click(object sender, RoutedEventArgs e)
{
TargetManager.SelectedTarget.Reboot();
Task.Run(() => TargetManager.SelectedTarget.Reboot());
}
private void ShutdownTarget_Click(object sender, RoutedEventArgs e)
{
TargetManager.SelectedTarget.Shutdown();
Task.Run(() => TargetManager.SelectedTarget.Shutdown());
}
#endregion
#region Context Menu
private void HexBox_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
{
if (e.Button == MouseButtons.Right)
{
FormsHost.ContextMenu.IsOpen = true;
}
}
private void CopyHex_Click(object sender, RoutedEventArgs e)
{
HexBox.CopyHex();
}
private void CopyText_Click(object sender, RoutedEventArgs e)
{
HexBox.Copy();
}
private void PasteText_Click(object sender, RoutedEventArgs e)
{
try
{
HexBox.Paste();
}
catch (Exception ex)
{
SimpleMessageBox.ShowError(this, $"Paste failed becase {ex.Message}", "Paste Failed.");
}
}
private void PasteHex_Click(object sender, RoutedEventArgs e)
{
try
{
HexBox.PasteHex();
}
catch (Exception ex)
{
SimpleMessageBox.ShowError(this, $"Paste failed becase {ex.Message}", "Paste Failed.");
}
}
private void SelectAll_Click(object sender, RoutedEventArgs e)
{
HexBox.SelectAll();
}
private void FollowPointer_Click(object sender, RoutedEventArgs e)
{
GetPeekPokeInfo(out var lastAddress, out var length);
byte[] RawJumpAddress = new byte[8];
//Grab 8 bytes
for (int i = 7; i >= 0; i--)
RawJumpAddress[i] = HexBox.ByteProvider.ReadByte(HexBox.SelectionStart + i);
// Hex or decimal value of offset
ulong offset;
if (TryConvertStringToUlong(Offset.FieldText, out offset))
{
lastAddress += offset;
}
ulong address;
try
{
address = BitConverter.ToUInt64(RawJumpAddress, 0);
}
catch
{
SimpleMessageBox.ShowError(this, "The memory was not a Pointer.", "The memory was not a Pointer.");
return;
}
Task.Run(() =>
{
var data = TargetManager.SelectedTarget.Debug.ReadMemory(address, length);
if (data != null && data.Length > 0)
{
// Add the last address to the list.
JumpList.Add(lastAddress);
Dispatcher.Invoke(() =>
{
ReturnPointer.IsEnabled = true;
BaseAddress.FieldText = $"0x{address.ToString("X")}";
Offset.FieldText = $"0x0";
HexBox.VScrollBarVisible = true;
HexBox.ByteProvider = new DynamicByteProvider(data);
HexBox.VScrollBarVisible = false;
});
}
});
}
private void ReturnPointer_Click(object sender, RoutedEventArgs e)
{
if (JumpList.Count == 0)
ReturnPointer.IsEnabled = false;
GetPeekPokeInfo(out var lastAddress, out var length);
Task.Run(() =>
{
var data = TargetManager.SelectedTarget.Debug.ReadMemory(JumpList.Last(), length);
if (data != null && data.Length > 0)
{
// Add the last address to the list.
JumpList.Remove(JumpList.Last());
Dispatcher.Invoke(() =>
{
// Disable if we are back where we started.
if (JumpList.Count == 0)
ReturnPointer.IsEnabled = false;
BaseAddress.FieldText = $"0x{lastAddress.ToString("X")}";
Offset.FieldText = $"0x0";
HexBox.VScrollBarVisible = true;
HexBox.ByteProvider = new DynamicByteProvider(data);
HexBox.VScrollBarVisible = false;
});
}
});
}
#endregion
}
}
+1 -1
View File
@@ -17,7 +17,7 @@ class Service : ServiceBase
Console.WriteLine("Starting");
var dp = new Dispatcher();
#if DEBUG
while (RunService) { Thread.Sleep(10); }
while (RunService) { Thread.Sleep(10); }
#endif
}