Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Partial Port to MacOSX
  • Loading branch information
tarekwiz committed Mar 5, 2019
commit fe6ac77dea945d628ba424acc8d32f891a6c5d09
Binary file added .DS_Store
Binary file not shown.
Binary file added NativeCore/.DS_Store
Binary file not shown.
2 changes: 2 additions & 0 deletions NativeCore/ReClassNET_Plugin.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@

#ifdef __linux__
#define RC_CallConv
#elif __APPLE__
#define RC_CallConv
#elif _WIN32
#define RC_CallConv __stdcall
#else
Expand Down
Binary file added NativeCore/Unix/.DS_Store
Binary file not shown.
11 changes: 9 additions & 2 deletions NativeCore/Unix/ControlRemoteProcess.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@ extern "C" void RC_CallConv ControlRemoteProcess(RC_Pointer handle, ControlRemot
{
signal = SIGCONT;
}

kill(static_cast<pid_t>(reinterpret_cast<intptr_t>(handle)), signal);
#ifdef __linux__
kill(static_cast<pid_t>(reinterpret_cast<intptr_t>(handle)), signal);
#elif __APPLE__
task_t task;

task_for_pid(current_task(), (int)id, &task);
return (RC_Pointer)task;
#endif

}
2 changes: 1 addition & 1 deletion NativeCore/Unix/Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
WORKDIR = `pwd`

CC = gcc
CXX = gcc
CXX = gcc -std=c++17
AR = ar
LD = g++
WINDRES = windres
Expand Down
12 changes: 11 additions & 1 deletion NativeCore/Unix/OpenRemoteProcess.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
#include "NativeCore.hpp"
#include <mach/mach_init.h>
#include <mach/mach_vm.h>


extern "C" RC_Pointer RC_CallConv OpenRemoteProcess(RC_Pointer id, ProcessAccess desiredAccess)
{
return id;
#ifdef __linux__
return id;
#elif __APPLE__
task_t task;

task_for_pid(current_task(), *(int*)&id, &task);
return (RC_Pointer)task;
#endif
}
38 changes: 24 additions & 14 deletions NativeCore/Unix/ReadRemoteMemory.cpp
Original file line number Diff line number Diff line change
@@ -1,21 +1,31 @@
#include <sys/uio.h>

#ifdef __APPLE__
#include <mach/mach_init.h>
#include <mach/mach_vm.h>
#include <mach/mach.h>
#endif
#include "NativeCore.hpp"

extern "C" bool RC_CallConv ReadRemoteMemory(RC_Pointer handle, RC_Pointer address, RC_Pointer buffer, int offset, int size)
{
iovec local[1];
iovec remote[1];

local[0].iov_base = (static_cast<uint8_t*>(buffer) + offset);
local[0].iov_len = size;
remote[0].iov_base = address;
remote[0].iov_len = size;

if (process_vm_readv(static_cast<pid_t>(reinterpret_cast<intptr_t>(handle)), local, 1, remote, 1, 0) != size)
{
return false;
}
#ifdef __linux__
iovec local[1];
iovec remote[1];

local[0].iov_base = (static_cast<uint8_t*>(buffer) + offset);
local[0].iov_len = size;
remote[0].iov_base = address;
remote[0].iov_len = size;

if (process_vm_readv(static_cast<pid_t>(reinterpret_cast<intptr_t>(handle)), local, 1, remote, 1, 0) != size)
{
return false;
}

return true;
#elif __APPLE__
uint32_t sz;
return vm_read(*(vm_map_t*)&handle, (vm_address_t) address, (vm_size_t) size, (vm_offset_t *)(static_cast<uint8_t*>(buffer) + offset), &sz) == KERN_SUCCESS;
#endif

return true;
}
40 changes: 26 additions & 14 deletions NativeCore/Unix/WriteRemoteMemory.cpp
Original file line number Diff line number Diff line change
@@ -1,21 +1,33 @@
#include <sys/uio.h>
#ifdef __APPLE__
#include <mach/mach_init.h>
#include <mach/mach_vm.h>
#include <mach/mach.h>
#endif

#include "NativeCore.hpp"

extern "C" bool RC_CallConv WriteRemoteMemory(RC_Pointer handle, RC_Pointer address, RC_Pointer buffer, int offset, int size)
{
iovec local[1];
iovec remote[1];

local[0].iov_base = (static_cast<uint8_t*>(buffer) + offset);
local[0].iov_len = size;
remote[0].iov_base = address;
remote[0].iov_len = size;

if (process_vm_writev(static_cast<pid_t>(reinterpret_cast<intptr_t>(handle)), local, 1, remote, 1, 0) != size)
{
return false;
}

return true;

#ifdef __linux__
iovec local[1];
iovec remote[1];

local[0].iov_base = (static_cast<uint8_t*>(buffer) + offset);
local[0].iov_len = size;
remote[0].iov_base = address;
remote[0].iov_len = size;

if (process_vm_writev(static_cast<pid_t>(reinterpret_cast<intptr_t>(handle)), local, 1, remote, 1, 0) != size)
{
return false;
}

return true;
#elif __APPLE__
uint32_t sz;
return vm_write(*(vm_map_t*)&handle , (vm_address_t) address, (vm_offset_t)(static_cast<uint8_t*>(buffer) + offset), size) == KERN_SUCCESS;
#endif

}