mirror of
https://github.com/HIllya51/LunaHook.git
synced 2024-10-22 23:18:16 +08:00
fix
This commit is contained in:
parent
196995c7d0
commit
b32d327842
@ -104,7 +104,16 @@ void ConsoleOutput(LPCSTR text, ...)
|
|||||||
|
|
||||||
void NotifyHookFound(HookParam hp, wchar_t *text)
|
void NotifyHookFound(HookParam hp, wchar_t *text)
|
||||||
{
|
{
|
||||||
wcscpy_s(hp.hookcode, HOOKCODE_LEN, HookCode::Generate(hp, GetCurrentProcessId()).c_str());
|
if (hp.jittype == JITTYPE::PC)
|
||||||
|
if (!(hp.type & MODULE_OFFSET))
|
||||||
|
if (AutoHandle<> process = OpenProcess(PROCESS_VM_READ | PROCESS_QUERY_INFORMATION, FALSE, GetCurrentProcessId()))
|
||||||
|
if (MEMORY_BASIC_INFORMATION info = {}; VirtualQueryEx(process, (LPCVOID)hp.address, &info, sizeof(info)))
|
||||||
|
{
|
||||||
|
|
||||||
|
hp.type |= MODULE_OFFSET;
|
||||||
|
hp.address -= (uint64_t)info.AllocationBase;
|
||||||
|
wcsncpy_s(hp.module, processName, ARRAYSIZE(hp.module));
|
||||||
|
}
|
||||||
HookFoundNotif buffer(hp, text);
|
HookFoundNotif buffer(hp, text);
|
||||||
WriteFile(hookPipe, &buffer, sizeof(buffer), DUMMY, nullptr);
|
WriteFile(hookPipe, &buffer, sizeof(buffer), DUMMY, nullptr);
|
||||||
}
|
}
|
||||||
|
@ -102,7 +102,10 @@ namespace
|
|||||||
auto info = *(HookFoundNotif*)buffer;
|
auto info = *(HookFoundNotif*)buffer;
|
||||||
auto OnHookFound = processRecordsByIds->at(processId).OnHookFound;
|
auto OnHookFound = processRecordsByIds->at(processId).OnHookFound;
|
||||||
std::wstring wide = info.text;
|
std::wstring wide = info.text;
|
||||||
if (wide.size() > STRING) OnHookFound(info.hp, std::move(info.text));
|
if (wide.size() > STRING) {
|
||||||
|
wcscpy_s(info.hp.hookcode,HOOKCODE_LEN, HookCode::Generate(info.hp, processId).c_str());
|
||||||
|
OnHookFound(info.hp, std::move(info.text));
|
||||||
|
}
|
||||||
info.hp.type &= ~CODEC_UTF16;
|
info.hp.type &= ~CODEC_UTF16;
|
||||||
if (auto converted = StringToWideString((char*)info.text, info.hp.codepage))
|
if (auto converted = StringToWideString((char*)info.text, info.hp.codepage))
|
||||||
if (converted->size() > STRING)
|
if (converted->size() > STRING)
|
||||||
|
@ -394,7 +394,7 @@ namespace
|
|||||||
if (hp.type & MODULE_OFFSET)
|
if (hp.type & MODULE_OFFSET)
|
||||||
HCode += L':' + std::wstring(hp.module);
|
HCode += L':' + std::wstring(hp.module);
|
||||||
if (hp.type & FUNCTION_OFFSET)
|
if (hp.type & FUNCTION_OFFSET)
|
||||||
HCode += L':' + StringToWideString(hp.function);
|
HCode += L':' + acastw(hp.function);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -215,7 +215,7 @@ size_t u32strlen(uint32_t *data)
|
|||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string wcasta(const std::wstring x)
|
std::string wcasta(const std::wstring& x)
|
||||||
{
|
{
|
||||||
std::string xx;
|
std::string xx;
|
||||||
for (auto c : x)
|
for (auto c : x)
|
||||||
@ -223,7 +223,7 @@ std::string wcasta(const std::wstring x)
|
|||||||
return xx;
|
return xx;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::wstring acastw(const std::string x)
|
std::wstring acastw(const std::string& x)
|
||||||
{
|
{
|
||||||
std::wstring xx;
|
std::wstring xx;
|
||||||
for (auto c : x)
|
for (auto c : x)
|
||||||
|
@ -33,8 +33,8 @@ std::string WideStringToString(const std::wstring &text, UINT cp = CP_UTF8);
|
|||||||
std::wstring StringToWideString(const std::string &text);
|
std::wstring StringToWideString(const std::string &text);
|
||||||
std::optional<std::wstring> StringToWideString(const std::string &text, UINT encoding);
|
std::optional<std::wstring> StringToWideString(const std::string &text, UINT encoding);
|
||||||
|
|
||||||
std::string wcasta(const std::wstring x);
|
std::string wcasta(const std::wstring& x);
|
||||||
std::wstring acastw(const std::string x);
|
std::wstring acastw(const std::string& x);
|
||||||
size_t u32strlen(uint32_t *data);
|
size_t u32strlen(uint32_t *data);
|
||||||
inline bool disable_mbwc = false;
|
inline bool disable_mbwc = false;
|
||||||
inline bool disable_wcmb = false;
|
inline bool disable_wcmb = false;
|
||||||
|
Loading…
Reference in New Issue
Block a user