aboutsummaryrefslogtreecommitdiff
path: root/client/src/injection
diff options
context:
space:
mode:
authorauth12 <[email protected]>2020-07-21 13:07:42 -0700
committerauth12 <[email protected]>2020-07-21 13:07:42 -0700
commitf09669dd5846d95b063712571ccb7519910a0d6e (patch)
tree902f5ad201651f2d96ccf619e90b76cfa06a7b9b /client/src/injection
parentSyscalls. (diff)
downloadloader-f09669dd5846d95b063712571ccb7519910a0d6e.tar.xz
loader-f09669dd5846d95b063712571ccb7519910a0d6e.zip
Added game selection.
Started process wrapper. Removed asmjit.
Diffstat (limited to 'client/src/injection')
-rw-r--r--client/src/injection/mapper.h19
-rw-r--r--client/src/injection/process.cpp71
-rw-r--r--client/src/injection/process.h19
3 files changed, 100 insertions, 9 deletions
diff --git a/client/src/injection/mapper.h b/client/src/injection/mapper.h
index 0d9026e..d1cfa5c 100644
--- a/client/src/injection/mapper.h
+++ b/client/src/injection/mapper.h
@@ -2,12 +2,13 @@
namespace mmap {
-struct mapper_data_t {
- size_t image_size;
- uint32_t entry;
- uint32_t base;
- std::string imports;
- std::vector<char> image;
-};
-
-}; // namespace mmap \ No newline at end of file
+ void thread(tcp::client& client) {
+ while (client.mapper_data.imports.empty()) {
+ std::this_thread::sleep_for(std::chrono::milliseconds(100));
+ }
+
+
+
+ }
+
+}; \ No newline at end of file
diff --git a/client/src/injection/process.cpp b/client/src/injection/process.cpp
new file mode 100644
index 0000000..954e9a8
--- /dev/null
+++ b/client/src/injection/process.cpp
@@ -0,0 +1,71 @@
+#include "../include.h"
+#include "../util/io.h"
+#include "../util/syscalls.h"
+#include "../util/util.h"
+#include "process.h"
+
+process::process(const SYSTEM_PROCESS_INFORMATION* info) {
+ std::wstring name;
+ name.resize(info->ImageName.Length);
+
+ std::memcpy(&name[0], &info->ImageName.Buffer[0], name.size());
+
+ m_name = util::wide_to_multibyte(name);
+ m_id = int(info->UniqueProcessId);
+}
+
+process::~process() {
+ m_name.clear();
+}
+
+bool process::open() {
+ CLIENT_ID cid = { HANDLE(m_id), 0 };
+ OBJECT_ATTRIBUTES oa;
+ oa.Length = sizeof(oa);
+ oa.Attributes = 0;
+ oa.RootDirectory = 0;
+ oa.SecurityDescriptor = 0;
+ oa.ObjectName = 0;
+ oa.SecurityQualityOfService = 0;
+
+ static auto nt_open = g_syscalls.get<native::NtOpenProcess>("NtOpenProcess");
+
+ if (!NT_SUCCESS(nt_open(&m_handle, PROCESS_ALL_ACCESS, &oa, &cid))) {
+ io::logger->error("failed to open handle to {}.", m_name);
+ return false;
+ }
+
+ return true;
+}
+
+bool process::read(const uintptr_t addr, void* data, const size_t size) {
+ static auto nt_read = g_syscalls.get<native::NtReadVirtualMemory>("NtReadVirtualMemory");
+ if (!m_handle) {
+ io::logger->error("invalid process handle.", m_name);
+ return false;
+ }
+
+ ULONG read;
+ if (!NT_SUCCESS(nt_read(m_handle, reinterpret_cast<void*>(addr), data, size, &read))) {
+ io::logger->error("failed to read to {}.", m_name);
+ return false;
+ }
+
+ return true;
+}
+
+bool process::write(const uintptr_t addr, void* data, const size_t size) {
+ static auto nt_write = g_syscalls.get<native::NtWiteVirtualMemory>("NtWiteVirtualMemory");
+ if (!m_handle) {
+ io::logger->error("invalid process handle.", m_name);
+ return false;
+ }
+
+ ULONG wrote;
+ if (!NT_SUCCESS(nt_write(m_handle, reinterpret_cast<void*>(addr), data, size, &wrote))) {
+ io::logger->error("failed to write to {}.", m_name);
+ return false;
+ }
+
+ return true;
+}
diff --git a/client/src/injection/process.h b/client/src/injection/process.h
new file mode 100644
index 0000000..574713a
--- /dev/null
+++ b/client/src/injection/process.h
@@ -0,0 +1,19 @@
+#pragma once
+
+class process {
+ int m_id;
+ std::string m_name;
+
+ HANDLE m_handle = INVALID_HANDLE_VALUE;
+public:
+ process() = default;
+ process(const SYSTEM_PROCESS_INFORMATION* info);
+ ~process();
+
+ bool open();
+ bool read(const uintptr_t addr, void* data, const size_t size);
+ bool write(const uintptr_t addr, void* data, const size_t size);
+
+ auto &get_name() { return m_name; }
+ auto &get_id() { return m_id; }
+}; \ No newline at end of file