Textractor_test/GUI/host/host.h

42 lines
1.3 KiB
C
Raw Normal View History

#pragma once
// host.h
// 8/23/2013 jichi
// Branch: ITH/IHF.h, rev 105
2018-08-23 00:24:55 +08:00
#include "common.h"
2018-07-24 03:25:02 +08:00
#include "textthread.h"
typedef std::function<void(DWORD)> ProcessEventCallback;
typedef std::function<void(std::shared_ptr<TextThread>)> ThreadEventCallback;
2018-07-24 03:25:02 +08:00
namespace Host
{
2018-10-08 12:26:43 +08:00
void Start(ProcessEventCallback onAttach, ProcessEventCallback onDetach, ThreadEventCallback onCreate, ThreadEventCallback onRemove, TextThread::OutputCallback output);
2018-08-25 00:50:20 +08:00
void Close();
2018-08-25 02:04:23 +08:00
bool InjectProcess(DWORD processId, DWORD timeout = 5000);
void DetachProcess(DWORD processId);
2018-08-25 02:04:23 +08:00
void InsertHook(DWORD processId, HookParam hp, std::string name = "");
void RemoveHook(DWORD processId, uint64_t addr);
2018-08-25 00:50:20 +08:00
HookParam GetHookParam(DWORD processId, uint64_t addr);
inline HookParam GetHookParam(ThreadParam tp) { return GetHookParam(tp.pid, tp.hook); }
std::wstring GetHookName(DWORD processId, uint64_t addr);
inline std::wstring GetHookName(ThreadParam tp) { return GetHookName(tp.pid, tp.hook); }
2018-08-25 00:50:20 +08:00
std::shared_ptr<TextThread> GetThread(ThreadParam tp);
2018-08-25 00:50:20 +08:00
void AddConsoleOutput(std::wstring text);
2018-07-24 03:25:02 +08:00
}
2018-09-22 09:27:59 +08:00
2018-11-02 09:59:13 +08:00
inline UINT DEFAULT_CODEPAGE = SHIFT_JIS;
inline std::wstring StringToWideString(const std::string& text, UINT encoding = DEFAULT_CODEPAGE)
2018-09-22 09:27:59 +08:00
{
2018-09-30 01:10:07 +08:00
std::wstring ret(text.size() + 1, 0);
ret.resize(MultiByteToWideChar(encoding, 0, text.c_str(), -1, ret.data(), ret.capacity()) - 1);
2018-09-22 09:27:59 +08:00
return ret;
}
// EOF