Commit 86d09347 authored by peastman's avatar peastman
Browse files

Deleted obsolete files

parent 8b69b9c0
// [AsmJit/WinRemoteRuntime]
// Contribution for remote process handling.
//
// [License]
// Zlib - See LICENSE.md file in the package.
// [Export]
#define ASMJIT_EXPORTS
// [Dependencies - AsmJit]
#include "../base.h"
// [Guard - Windows]
#if defined(ASMJIT_OS_WINDOWS)
#include "winremoteruntime.h"
namespace asmjit {
namespace contrib {
// ============================================================================
// [asmjit::contrib::WinRemoteRuntime - Construction / Destruction]
// ============================================================================
WinRemoteRuntime::WinRemoteRuntime(HANDLE hProcess) :
_memMgr(hProcess) {
// We are patching another process so enable keep-virtual-memory option.
_memMgr.setKeepVirtualMemory(true);
}
WinRemoteRuntime::~WinRemoteRuntime() {}
// ============================================================================
// [asmjit::contrib::WinRemoteRuntime - Interface]
// ============================================================================
uint32_t WinRemoteRuntime::add(void** dest, BaseAssembler* assembler) {
// Disallow generation of no code.
size_t codeSize = assembler->getCodeSize();
if (codeSize == 0) {
*dest = NULL;
return kErrorInvalidState;
}
// Allocate temporary memory where the code will be stored and relocated.
void* codeData = ASMJIT_ALLOC(codeSize);
if (codeData == NULL) {
*dest = NULL;
return kErrorNoHeapMemory;
}
// Allocate a permanent remote process memory.
void* processMemPtr = _memMgr.alloc(codeSize, kVMemAllocPermanent);
if (processMemPtr == NULL) {
ASMJIT_FREE(codeData);
*dest = NULL;
return kErrorNoVirtualMemory;
}
// Relocate and write the code to the process memory.
assembler->relocCode(codeData, (uintptr_t)processMemPtr);
::WriteProcessMemory(getProcessHandle(), processMemPtr, codeData, codeSize, NULL);
ASMJIT_FREE(codeData);
*dest = processMemPtr;
return kErrorOk;
}
// NOP.
Error WinRemoteRuntime::release(void* p) {
return kErrorOk;
}
} // contrib namespace
} // asmjit namespace
// [Guard - Windows]
#endif // ASMJIT_OS_WINDOWS
// [AsmJit]
// Complete x86/x64 JIT and Remote Assembler for C++.
//
// [License]
// Zlib - See LICENSE.md file in the package.
// [Guard]
#ifndef _ASMJIT_CONTRIB_WINREMOTERUNTIME_H
#define _ASMJIT_CONTRIB_WINREMOTERUNTIME_H
#include "../base.h"
#if defined(ASMJIT_OS_WINDOWS)
namespace asmjit {
namespace contrib {
//! \addtogroup asmjit_contrib
//! \{
// ============================================================================
// [asmjit::contrib::WinRemoteRuntime]
// ============================================================================
//! WinRemoteRuntime can be used to inject code to a remote process.
struct WinRemoteRuntime : public Runtime {
ASMJIT_NO_COPY(WinRemoteRuntime)
// --------------------------------------------------------------------------
// [Construction / Destruction]
// --------------------------------------------------------------------------
//! Create a `WinRemoteRuntime` instance for a given `hProcess`.
ASMJIT_API WinRemoteRuntime(HANDLE hProcess);
//! Destroy the `WinRemoteRuntime` instance.
ASMJIT_API virtual ~WinRemoteRuntime();
// --------------------------------------------------------------------------
// [Accessors]
// --------------------------------------------------------------------------
//! Get the remote process handle.
ASMJIT_INLINE HANDLE getProcessHandle() const {
return _memMgr.getProcessHandle();
}
//! Get the remote memory manager.
ASMJIT_INLINE VMemMgr* getMemMgr() const {
return const_cast<VMemMgr*>(&_memMgr);
}
// --------------------------------------------------------------------------
// [Interface]
// --------------------------------------------------------------------------
ASMJIT_API virtual uint32_t add(void** dest, BaseAssembler* assembler);
ASMJIT_API virtual Error release(void* p);
// --------------------------------------------------------------------------
// [Members]
// --------------------------------------------------------------------------
//! Remove memory manager.
VMemMgr _memMgr;
};
//! \}
} // contrib namespace
} // asmjit namespace
// [Guard]
#endif // ASMJIT_OS_WINDOWS
#endif // _ASMJIT_CONTRIB_WINREMOTERUNTIME_H
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment