mirror of
https://github.com/HIllya51/LunaHook.git
synced 2025-01-12 12:59:31 +08:00
maybe0
This commit is contained in:
parent
e95fbfc4e9
commit
f7c06d0cb9
@ -16,51 +16,37 @@ BOOL APIENTRY DllMain(HMODULE hModule,
|
||||
}
|
||||
|
||||
typedef void (*ProcessEvent)(DWORD);
|
||||
typedef void (*ThreadEvent)(wchar_t *, char *, ThreadParam);
|
||||
typedef bool (*OutputCallback)(wchar_t *, char *, ThreadParam, const wchar_t *);
|
||||
typedef void (*ThreadEvent)(const wchar_t *, const char *, ThreadParam);
|
||||
typedef bool (*OutputCallback)(const wchar_t *, const char *, ThreadParam, const wchar_t *);
|
||||
typedef void (*ConsoleHandler)(const wchar_t *);
|
||||
typedef void (*HookInsertHandler)(uint64_t, const wchar_t *);
|
||||
typedef void (*EmbedCallback)(const wchar_t *, ThreadParam);
|
||||
#define XXXX \
|
||||
char name[HOOK_NAME_SIZE]; \
|
||||
wchar_t hookcode[HOOKCODE_LEN]; \
|
||||
wcscpy_s(hookcode, HOOKCODE_LEN, thread.hp.hookcode); \
|
||||
strcpy_s(name, HOOK_NAME_SIZE, thread.hp.name);
|
||||
template <typename T>
|
||||
std::optional<T> checkoption(bool check, T &&t)
|
||||
{
|
||||
if (check)
|
||||
return std::move(t);
|
||||
return {};
|
||||
}
|
||||
C_LUNA_API void Luna_Start(ProcessEvent Connect, ProcessEvent Disconnect, ThreadEvent Create, ThreadEvent Destroy, OutputCallback Output, ConsoleHandler console, HookInsertHandler hookinsert, EmbedCallback embed, ConsoleHandler Warning)
|
||||
{
|
||||
Host::StartEx(
|
||||
Connect,
|
||||
Disconnect,
|
||||
[=](const TextThread &thread)
|
||||
{
|
||||
XXXX
|
||||
Create(hookcode, name, thread.tp);
|
||||
},
|
||||
[=](const TextThread &thread)
|
||||
{
|
||||
XXXX
|
||||
Destroy(hookcode, name, thread.tp);
|
||||
},
|
||||
[=](const TextThread &thread, std::wstring &output)
|
||||
{
|
||||
XXXX return Output(hookcode, name, thread.tp, output.c_str());
|
||||
},
|
||||
[=](const std::wstring &output)
|
||||
{
|
||||
console(output.c_str());
|
||||
},
|
||||
[=](uint64_t addr, const std::wstring &output)
|
||||
{
|
||||
hookinsert(addr, output.c_str());
|
||||
},
|
||||
[=](const std::wstring &output, const ThreadParam &tp)
|
||||
{
|
||||
embed(output.c_str(), tp);
|
||||
},
|
||||
[=](const std::wstring &output)
|
||||
{
|
||||
Warning(output.c_str());
|
||||
});
|
||||
checkoption(Connect, std::function<void(DWORD)>(Connect)),
|
||||
checkoption(Disconnect, std::function<void(DWORD)>(Disconnect)),
|
||||
checkoption(Create, [=](const TextThread &thread)
|
||||
{ Create(thread.hp.hookcode, thread.hp.name, thread.tp); }),
|
||||
checkoption(Destroy, [=](const TextThread &thread)
|
||||
{ Destroy(thread.hp.hookcode, thread.hp.name, thread.tp); }),
|
||||
checkoption(Output, [=](const TextThread &thread, std::wstring &output)
|
||||
{ return Output(thread.hp.hookcode, thread.hp.name, thread.tp, output.c_str()); }),
|
||||
checkoption(console, [=](const std::wstring &output)
|
||||
{ console(output.c_str()); }),
|
||||
checkoption(hookinsert, [=](uint64_t addr, const std::wstring &output)
|
||||
{ hookinsert(addr, output.c_str()); }),
|
||||
checkoption(embed, [=](const std::wstring &output, const ThreadParam &tp)
|
||||
{ embed(output.c_str(), tp); }),
|
||||
checkoption(Warning, [=](const std::wstring &output)
|
||||
{ Warning(output.c_str()); }));
|
||||
}
|
||||
C_LUNA_API void Luna_Inject(DWORD pid, LPCWSTR basepath)
|
||||
{
|
||||
|
@ -217,18 +217,20 @@ namespace Host
|
||||
|
||||
// CreatePipe();
|
||||
}
|
||||
void StartEx(ProcessEventHandler Connect, ProcessEventHandler Disconnect, ThreadEventHandler Create, ThreadEventHandler Destroy, TextThread::OutputCallback Output, std::optional<ConsoleHandler> console, std::optional<HookInsertHandler> hookinsert, std::optional<EmbedCallback> embed, std::optional<ConsoleHandler> warning)
|
||||
void StartEx(std::optional<ProcessEventHandler> Connect, std::optional<ProcessEventHandler> Disconnect, std::optional<ThreadEventHandler> Create, std::optional<ThreadEventHandler> Destroy, std::optional<TextThread::OutputCallback> Output, std::optional<ConsoleHandler> console, std::optional<HookInsertHandler> hookinsert, std::optional<EmbedCallback> embed, std::optional<ConsoleHandler> warning)
|
||||
{
|
||||
Start(Connect, Disconnect, Create, Destroy, Output, !console.has_value());
|
||||
if (warning.has_value())
|
||||
Start(Connect.value_or([](auto) {}), Disconnect.value_or([](auto) {}), Create.value_or([](auto &) {}), Destroy.value_or([](auto &) {}), Output.value_or([](auto &, auto &)
|
||||
{ return false; }),
|
||||
!console);
|
||||
if (warning)
|
||||
OnWarning = warning.value();
|
||||
if (console.has_value())
|
||||
if (console)
|
||||
OnConsole = [=](auto &&...args)
|
||||
{std::lock_guard _(outputmutex);console.value()(std::forward<decltype(args)>(args)...); };
|
||||
if (hookinsert.has_value())
|
||||
if (hookinsert)
|
||||
HookInsert = [=](auto &&...args)
|
||||
{std::lock_guard _(threadmutex);hookinsert.value()(std::forward<decltype(args)>(args)...); };
|
||||
if (embed.has_value())
|
||||
if (embed)
|
||||
embedcallback = [=](auto &&...args)
|
||||
{std::lock_guard _(outputmutex);embed.value()(std::forward<decltype(args)>(args)...); };
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ namespace Host
|
||||
using HookInsertHandler = std::function<void(uint64_t, const std::wstring &)>;
|
||||
using EmbedCallback = std::function<void(const std::wstring &, const ThreadParam &)>;
|
||||
void Start(ProcessEventHandler Connect, ProcessEventHandler Disconnect, ThreadEventHandler Create, ThreadEventHandler Destroy, TextThread::OutputCallback Output, bool createconsole = true);
|
||||
void StartEx(ProcessEventHandler Connect, ProcessEventHandler Disconnect, ThreadEventHandler Create, ThreadEventHandler Destroy, TextThread::OutputCallback Output, std::optional<ConsoleHandler> console, std::optional<HookInsertHandler> hookinsert, std::optional<EmbedCallback> embed, std::optional<ConsoleHandler> warning);
|
||||
void StartEx(std::optional<ProcessEventHandler> Connect, std::optional<ProcessEventHandler> Disconnect, std::optional<ThreadEventHandler> Create, std::optional<ThreadEventHandler> Destroy, std::optional<TextThread::OutputCallback> Output, std::optional<ConsoleHandler> console, std::optional<HookInsertHandler> hookinsert, std::optional<EmbedCallback> embed, std::optional<ConsoleHandler> warning);
|
||||
void InjectProcess(DWORD processId, const std::wstring locationX = L"");
|
||||
bool CreatePipeAndCheck(DWORD processId);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user