2016-01-06 00:01:17 +09:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
// host.h
|
|
|
|
// 8/23/2013 jichi
|
|
|
|
// Branch: ITH/IHF.h, rev 105
|
|
|
|
|
2018-08-22 12:24:55 -04:00
|
|
|
#include "common.h"
|
2018-07-23 12:25:02 -07:00
|
|
|
#include "textthread.h"
|
|
|
|
#include "../vnrhook/include/types.h"
|
|
|
|
|
2018-08-22 12:24:55 -04:00
|
|
|
#define DLLEXPORT __declspec(dllexport)
|
|
|
|
|
2018-07-23 12:25:02 -07:00
|
|
|
struct ProcessRecord
|
|
|
|
{
|
|
|
|
HANDLE process_handle;
|
|
|
|
HANDLE hookman_mutex;
|
|
|
|
HANDLE hookman_section;
|
|
|
|
LPVOID hookman_map;
|
|
|
|
HANDLE hostPipe;
|
|
|
|
};
|
|
|
|
|
2018-07-24 10:39:02 -07:00
|
|
|
typedef std::function<void(DWORD)> ProcessEventCallback;
|
|
|
|
typedef std::function<void(TextThread*)> ThreadEventCallback;
|
2018-07-23 12:25:02 -07:00
|
|
|
|
|
|
|
struct ThreadParameterHasher
|
|
|
|
{
|
|
|
|
size_t operator()(const ThreadParameter& tp) const
|
|
|
|
{
|
2018-08-04 03:16:14 -04:00
|
|
|
return std::hash<__int64>()(tp.pid << 6) + std::hash<__int64>()(tp.hook) + std::hash<__int64>()(tp.retn) + std::hash<__int64>()(tp.spl);
|
2018-07-23 12:25:02 -07:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
namespace Host
|
|
|
|
{
|
2018-08-21 22:43:30 -04:00
|
|
|
DLLEXPORT void Start(ProcessEventCallback onAttach, ProcessEventCallback onDetach, ThreadEventCallback onCreate, ThreadEventCallback onRemove);
|
2018-07-23 12:25:02 -07:00
|
|
|
DLLEXPORT void Close();
|
|
|
|
DLLEXPORT bool InjectProcess(DWORD pid, DWORD timeout = 5000);
|
|
|
|
DLLEXPORT bool DetachProcess(DWORD pid);
|
|
|
|
|
|
|
|
DLLEXPORT bool InsertHook(DWORD pid, HookParam hp, std::string name = "");
|
|
|
|
DLLEXPORT bool RemoveHook(DWORD pid, DWORD addr);
|
|
|
|
DLLEXPORT HookParam GetHookParam(DWORD pid, DWORD addr);
|
2018-08-21 22:43:30 -04:00
|
|
|
DLLEXPORT HookParam GetHookParam(ThreadParameter tp);
|
2018-07-23 12:25:02 -07:00
|
|
|
DLLEXPORT std::wstring GetHookName(DWORD pid, DWORD addr);
|
|
|
|
|
2018-08-21 22:43:30 -04:00
|
|
|
DLLEXPORT TextThread* GetThread(ThreadParameter tp);
|
2018-07-23 12:25:02 -07:00
|
|
|
DLLEXPORT void AddConsoleOutput(std::wstring text);
|
|
|
|
}
|
2016-01-06 00:01:17 +09:00
|
|
|
|
2018-08-21 22:43:30 -04:00
|
|
|
void DispatchText(ThreadParameter tp, const BYTE *text, int len);
|
2018-07-23 12:25:02 -07:00
|
|
|
void RemoveThreads(bool(*RemoveIf)(ThreadParameter, ThreadParameter), ThreadParameter cmp);
|
|
|
|
void RegisterProcess(DWORD pid, HANDLE hostPipe);
|
|
|
|
void UnregisterProcess(DWORD pid);
|
2016-01-06 00:01:17 +09:00
|
|
|
|
|
|
|
// EOF
|