mirror of
https://github.com/HIllya51/LunaHook.git
synced 2024-11-27 07:44:02 +08:00
muv
This commit is contained in:
parent
943f098682
commit
4a56a39d68
@ -1,6 +1,7 @@
|
|||||||
#include "RUGP.h"
|
#include "RUGP.h"
|
||||||
|
|
||||||
namespace { // unnamed rUGP
|
namespace
|
||||||
|
{ // unnamed rUGP
|
||||||
|
|
||||||
/********************************************************************************************
|
/********************************************************************************************
|
||||||
rUGP hook:
|
rUGP hook:
|
||||||
@ -22,13 +23,14 @@ void SpecialHookRUGP1(hook_stack* stack, HookParam *hp, uintptr_t *data, uintpt
|
|||||||
// CC_UNUSED(split);
|
// CC_UNUSED(split);
|
||||||
DWORD *_stack = (DWORD *)stack->base;
|
DWORD *_stack = (DWORD *)stack->base;
|
||||||
DWORD i, val;
|
DWORD i, val;
|
||||||
for (i = 0; i < 4; i++) {
|
for (i = 0; i < 4; i++)
|
||||||
|
{
|
||||||
val = *_stack++;
|
val = *_stack++;
|
||||||
if ((val >> 16) == 0)
|
if ((val >> 16) == 0)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
if (i < 4) {
|
if (i < 4)
|
||||||
|
{
|
||||||
hp->offset = i << 2;
|
hp->offset = i << 2;
|
||||||
*data = val;
|
*data = val;
|
||||||
*len = 2;
|
*len = 2;
|
||||||
@ -43,21 +45,27 @@ void SpecialHookRUGP1(hook_stack* stack, HookParam *hp, uintptr_t *data, uintpt
|
|||||||
bool InsertRUGP1Hook()
|
bool InsertRUGP1Hook()
|
||||||
{
|
{
|
||||||
DWORD low;
|
DWORD low;
|
||||||
if (!Util::CheckFile(L"rvmm.dll")) {
|
if (!Util::CheckFile(L"rvmm.dll"))
|
||||||
|
{
|
||||||
ConsoleOutput("rUGP: rvmm.dll does not exist");
|
ConsoleOutput("rUGP: rvmm.dll does not exist");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// WCHAR str[0x40];
|
// WCHAR str[0x40];
|
||||||
LPVOID ch = (LPVOID)0x8140;
|
LPVOID ch = (LPVOID)0x8140;
|
||||||
enum { range = 0x20000 };
|
enum
|
||||||
|
{
|
||||||
|
range = 0x20000
|
||||||
|
};
|
||||||
low = (DWORD)GetModuleHandleW(L"rvmm.dll");
|
low = (DWORD)GetModuleHandleW(L"rvmm.dll");
|
||||||
DWORD t = SearchPattern(low + range, processStopAddress, &ch, 4) + range;
|
DWORD t = SearchPattern(low + range, processStopAddress, &ch, 4) + range;
|
||||||
BYTE *s = (BYTE *)(low + t);
|
BYTE *s = (BYTE *)(low + t);
|
||||||
// if (t) {
|
// if (t) {
|
||||||
if (t != range) { // jichi 10/1/2013: Changed to compare with 0x20000
|
if (t != range)
|
||||||
|
{ // jichi 10/1/2013: Changed to compare with 0x20000
|
||||||
if (*(s - 2) != 0x81)
|
if (*(s - 2) != 0x81)
|
||||||
return false;
|
return false;
|
||||||
if (DWORD i = SafeFindEnclosingAlignedFunction((DWORD)s, 0x200)) {
|
if (DWORD i = SafeFindEnclosingAlignedFunction((DWORD)s, 0x200))
|
||||||
|
{
|
||||||
HookParam hp;
|
HookParam hp;
|
||||||
hp.address = i;
|
hp.address = i;
|
||||||
hp.text_fun = SpecialHookRUGP1;
|
hp.text_fun = SpecialHookRUGP1;
|
||||||
@ -65,9 +73,12 @@ bool InsertRUGP1Hook()
|
|||||||
ConsoleOutput("INSERT rUGP#1");
|
ConsoleOutput("INSERT rUGP#1");
|
||||||
return NewHook(hp, "rUGP");
|
return NewHook(hp, "rUGP");
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
t = SearchPattern(low, range, &s, 4);
|
t = SearchPattern(low, range, &s, 4);
|
||||||
if (!t) {
|
if (!t)
|
||||||
|
{
|
||||||
ConsoleOutput("rUGP: pattern not found");
|
ConsoleOutput("rUGP: pattern not found");
|
||||||
// ConsoleOutput("Can't find characteristic instruction.");
|
// ConsoleOutput("Can't find characteristic instruction.");
|
||||||
return false;
|
return false;
|
||||||
@ -75,8 +86,8 @@ bool InsertRUGP1Hook()
|
|||||||
|
|
||||||
s = (BYTE *)(low + t);
|
s = (BYTE *)(low + t);
|
||||||
for (int i = 0; i < 0x200; i++, s--)
|
for (int i = 0; i < 0x200; i++, s--)
|
||||||
if (s[0] == 0x90
|
if (s[0] == 0x90 && *(DWORD *)(s - 3) == 0x90909090)
|
||||||
&& *(DWORD *)(s - 3) == 0x90909090) {
|
{
|
||||||
t = low + t - i + 1;
|
t = low + t - i + 1;
|
||||||
// swprintf(str, L"HookAddr 0x%.8x", t);
|
// swprintf(str, L"HookAddr 0x%.8x", t);
|
||||||
// ConsoleOutput(str);
|
// ConsoleOutput(str);
|
||||||
@ -181,7 +192,8 @@ bool InsertRUGP1Hook()
|
|||||||
bool InsertRUGP2Hook()
|
bool InsertRUGP2Hook()
|
||||||
{
|
{
|
||||||
auto module = GetModuleHandleW(L"vm60.dll");
|
auto module = GetModuleHandleW(L"vm60.dll");
|
||||||
if (!module /*|| !SafeFillRange(L"vm60.dll", &low, &high)*/) {
|
if (!module /*|| !SafeFillRange(L"vm60.dll", &low, &high)*/)
|
||||||
|
{
|
||||||
ConsoleOutput("rUGP2: vm60.dll does not exist");
|
ConsoleOutput("rUGP2: vm60.dll does not exist");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -194,10 +206,14 @@ bool InsertRUGP2Hook()
|
|||||||
0x89, 0x45, 0x08, // 1001e524 8945 08 mov dword ptr ss:[ebp+0x8],eax
|
0x89, 0x45, 0x08, // 1001e524 8945 08 mov dword ptr ss:[ebp+0x8],eax
|
||||||
0x89, 0x75, 0x0c // 1001e527 8975 0c mov dword ptr ss:[ebp+0xc],esi
|
0x89, 0x75, 0x0c // 1001e527 8975 0c mov dword ptr ss:[ebp+0xc],esi
|
||||||
};
|
};
|
||||||
enum { addr_offset = 0x1001e51d - 0x1001e515 };
|
enum
|
||||||
|
{
|
||||||
|
addr_offset = 0x1001e51d - 0x1001e515
|
||||||
|
};
|
||||||
ULONG addr = MemDbg::findBytes(bytes, sizeof(bytes), (DWORD)module, Util::QueryModuleLimits(module).second);
|
ULONG addr = MemDbg::findBytes(bytes, sizeof(bytes), (DWORD)module, Util::QueryModuleLimits(module).second);
|
||||||
// GROWL_DWORD(addr);
|
// GROWL_DWORD(addr);
|
||||||
if (!addr) {
|
if (!addr)
|
||||||
|
{
|
||||||
ConsoleOutput("rUGP2: pattern not found");
|
ConsoleOutput("rUGP2: pattern not found");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -212,10 +228,55 @@ bool InsertRUGP2Hook()
|
|||||||
|
|
||||||
} // unnamed namespace
|
} // unnamed namespace
|
||||||
|
|
||||||
bool InsertRUGPHook()
|
namespace
|
||||||
{ return InsertRUGP1Hook() || InsertRUGP2Hook(); }
|
{
|
||||||
|
// マブラヴ オルタネイティヴ クロニクルズ04
|
||||||
|
bool h3()
|
||||||
|
{
|
||||||
|
|
||||||
bool RUGP::attach_function() {
|
auto low = GetModuleHandleW(L"rvmm.dll");
|
||||||
|
if (!low)
|
||||||
return InsertRUGPHook();
|
return false;
|
||||||
|
auto [s, e] = Util::QueryModuleLimits(low);
|
||||||
|
auto caller = findiatcallormov((DWORD)GetGlyphOutlineA, (DWORD)low, s, e);
|
||||||
|
ConsoleOutput("%p", caller);
|
||||||
|
if (!caller)
|
||||||
|
return false;
|
||||||
|
auto func = findfuncstart(caller, 0x200, true);
|
||||||
|
if (!func)
|
||||||
|
return false;
|
||||||
|
// a2 == 33088
|
||||||
|
BYTE sig[] = {0x81, XX, 0x40, 0x81, 0x00, 0x00};
|
||||||
|
if (!MemDbg::findBytes(sig, sizeof(sig), func, caller))
|
||||||
|
return false;
|
||||||
|
auto refs = findxref_reverse_checkcallop(func, s, e, 0xe8);
|
||||||
|
if (refs.size() == 1)
|
||||||
|
{
|
||||||
|
auto f2 = findfuncstart(refs[0], 0x100, true);
|
||||||
|
if (f2)
|
||||||
|
{
|
||||||
|
HookParam hp;
|
||||||
|
hp.address = f2;
|
||||||
|
hp.offset = get_stack(2);
|
||||||
|
hp.type = CODEC_ANSI_BE;
|
||||||
|
return NewHook(hp, "rUGP3");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
HookParam hp;
|
||||||
|
hp.address = func;
|
||||||
|
hp.offset = get_stack(2);
|
||||||
|
hp.split = get_stack(1);
|
||||||
|
hp.type = NO_CONTEXT | CODEC_ANSI_BE | USING_SPLIT;
|
||||||
|
return NewHook(hp, "rUGP3");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
bool InsertRUGPHook()
|
||||||
|
{
|
||||||
|
return InsertRUGP1Hook() || InsertRUGP2Hook();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool RUGP::attach_function()
|
||||||
|
{
|
||||||
|
|
||||||
|
return InsertRUGPHook() || h3();
|
||||||
}
|
}
|
@ -1,13 +1,15 @@
|
|||||||
|
|
||||||
|
|
||||||
class RUGP:public ENGINE{
|
class RUGP : public ENGINE
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
RUGP(){
|
RUGP()
|
||||||
|
{
|
||||||
|
|
||||||
check_by = CHECK_BY::CUSTOM;
|
check_by = CHECK_BY::CUSTOM;
|
||||||
check_by_target=[](){
|
check_by_target = []()
|
||||||
|
{
|
||||||
return (wcsstr(processName_lower, L"rugp") || Util::CheckFile(L"rugp.exe"));
|
return (wcsstr(processName_lower, L"rugp") || Util::CheckFile(L"rugp.exe"));
|
||||||
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
bool attach_function();
|
bool attach_function();
|
||||||
|
Loading…
Reference in New Issue
Block a user