Skip to content
This repository has been archived by the owner on Nov 17, 2024. It is now read-only.

Commit

Permalink
some
Browse files Browse the repository at this point in the history
  • Loading branch information
HIllya51 committed Oct 11, 2024
1 parent e0b0db1 commit a963692
Show file tree
Hide file tree
Showing 10 changed files with 242 additions and 114 deletions.
2 changes: 1 addition & 1 deletion Lang/en.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
#define ProcessRange "hijacking process located from 0x%p to 0x%p"
#define WarningDummy "WARNING injected process is very small, possibly a dummy!"
#define WndSelectProcess L"SelectProcess"
#define WndLunaHostGui L"LunaHost Gui"
#define WndLunaHostGui L"LunaHost GUI"
#define WndSetting L"Setting"
#define WndPlugins L"Plugins"
#define NotifyInvalidHookCode L"Invalid HookCode"
Expand Down
2 changes: 1 addition & 1 deletion Lang/ru.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
#define ProcessRange u8"Перехват процесса в диапазоне адресов с 0x%p по 0x%p"
#define WarningDummy u8"ПРЕДУПРЕЖДЕНИЕ: внедренный процесс очень мал, возможно, это пустышка!"
#define WndSelectProcess L"Выбор процесса"
#define WndLunaHostGui L"LunaHost - Gui"
#define WndLunaHostGui L"LunaHost - GUI"
#define WndSetting L"Настройки"
#define WndPlugins L"Плагины"
#define NotifyInvalidHookCode L"Неверный код хука"
Expand Down
2 changes: 1 addition & 1 deletion Lang/zh.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
#define ProcessRange u8"获取到进程内存地址范围 0x%p 到 0x%p"
#define WarningDummy u8"警告,注入的进程内存很小,可能是无用进程!"
#define WndSelectProcess L"选择进程"
#define WndLunaHostGui L"LunaHost Gui"
#define WndLunaHostGui L"LunaHost GUI"
#define WndSetting L"设置"
#define WndPlugins L"插件"
#define NotifyInvalidHookCode L"特殊码无效"
Expand Down
10 changes: 10 additions & 0 deletions LunaHook/engine64/vita3k.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,13 @@ namespace
s = std::regex_replace(s, std::regex(R"(#\w+(\[.+?\])?)"), "");
return write_string_overwrite(data, len, s);
}
bool FPCSG00815(void *data, size_t *len, HookParam *hp)
{
auto s = std::string((char *)data, *len);
s = std::regex_replace(s, std::regex(R"(\s*(#n)*\s*)"), "");
s = std::regex_replace(s, std::regex(R"(#\w+(\[.+?\])?)"), "");
return write_string_overwrite(data, len, s);
}
bool FPCSG00855(void *data, size_t *len, HookParam *hp)
{
auto s = std::string((char *)data, *len);
Expand Down Expand Up @@ -559,6 +566,9 @@ namespace
{0x801a2ba8, {CODEC_UTF8, 0, 0, 0, FPCSG00855_2<1>, "PCSG00855"}},
{0x801a2d9e, {CODEC_UTF8, 0, 0, 0, FPCSG00855_2<2>, "PCSG00855"}},
{0x801a2e68, {CODEC_UTF8, 0, 0, 0, FPCSG00855_2<3>, "PCSG00855"}},
// PsychicEmotion6 (サイキックエモーション ムー)
{0x80035948, {CODEC_UTF8, 9, 0, 0, FPCSG00815, "PCSG00815"}},
{0x80034580, {CODEC_UTF8, 6, 0, 0, FPCSG00815, "PCSG00815"}},
};
return 1;
}();
Expand Down
146 changes: 113 additions & 33 deletions LunaHook/engine64/yuzu.cpp

Large diffs are not rendered by default.

180 changes: 105 additions & 75 deletions LunaHook/engines/emujitarg.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,89 +2,119 @@
#ifdef _WIN64
namespace RPCS3
{
class emu_arg{
hook_stack* stack;
public:
emu_arg(hook_stack* stack_):stack(stack_){};
uintptr_t operator [](int idx){
auto base=stack->rbx;
auto args=(uintptr_t*)(stack->rbp+0x18+8*3);
return base+args[idx];
}
};
class emu_arg
{
hook_stack *stack;

public:
emu_arg(hook_stack *stack_) : stack(stack_) {};
uintptr_t operator[](int idx)
{
auto base = stack->rbx;
auto args = (uintptr_t *)(stack->rbp + 0x18 + 8 * 3);
return base + args[idx];
}
};
}
namespace YUZU
{
class emu_arg{
hook_stack* stack;
public:
emu_arg(hook_stack* stack_):stack(stack_){};
uintptr_t operator [](int idx){
auto base=stack->r13;
auto args=(uintptr_t*)stack->r15;
return base+args[idx];
}
};
class emu_arg
{
hook_stack *stack;
bool is64;

public:
emu_arg(hook_stack *stack_, uintptr_t em_addr = 0) : stack(stack_), is64(em_addr == 0 || em_addr > 0x80004000) {};
uintptr_t operator[](int idx)
{
auto base = stack->r13;
if (is64)
{
auto args = (uintptr_t *)stack->r15;
return base + args[idx];
}
else
{
// 0x204000
auto args = (DWORD *)stack->r15;
return base + args[idx];
}
}
};
}
namespace VITA3K
{
class emu_addr{
hook_stack* stack;
DWORD addr;
public:
emu_addr(hook_stack* stack_,DWORD addr_):stack(stack_),addr(addr_){};
operator uintptr_t(){
auto base=stack->r13;
return base+addr;
}
operator DWORD*(){
return (DWORD*)(uintptr_t)*this;
}
};
class emu_arg{
hook_stack* stack;
public:
emu_arg(hook_stack* stack_):stack(stack_){};
uintptr_t operator [](int idx){
auto args=(uint32_t*)stack->r15;
return emu_addr(stack,args[idx]);
}
};
class emu_addr
{
hook_stack *stack;
DWORD addr;

public:
emu_addr(hook_stack *stack_, DWORD addr_) : stack(stack_), addr(addr_) {};
operator uintptr_t()
{
auto base = stack->r13;
return base + addr;
}
operator DWORD *()
{
return (DWORD *)(uintptr_t) * this;
}
};
class emu_arg
{
hook_stack *stack;

public:
emu_arg(hook_stack *stack_) : stack(stack_) {};
uintptr_t operator[](int idx)
{
auto args = (uint32_t *)stack->r15;
return emu_addr(stack, args[idx]);
}
};
}
#endif
namespace PPSSPP{
namespace PPSSPP
{
inline DWORD x86_baseaddr;
class emu_addr{
hook_stack* stack;
DWORD addr;
public:
emu_addr(hook_stack* stack_,DWORD addr_):stack(stack_),addr(addr_){};
operator uintptr_t(){
#ifndef _WIN64
auto base=x86_baseaddr;
#else
auto base=stack->rbx;
#endif
return base+addr;
}
operator DWORD*(){
return (DWORD*)(uintptr_t)*this;
}
};
class emu_arg{
hook_stack* stack;
public:
class emu_addr
{
hook_stack *stack;
DWORD addr;

public:
emu_addr(hook_stack *stack_, DWORD addr_) : stack(stack_), addr(addr_) {};
operator uintptr_t()
{
#ifndef _WIN64
auto base = x86_baseaddr;
#else
auto base = stack->rbx;
#endif
return base + addr;
}
operator DWORD *()
{
return (DWORD *)(uintptr_t) * this;
}
};
class emu_arg
{
hook_stack *stack;

emu_arg(hook_stack* stack_):stack(stack_){};
uintptr_t operator [](int idx){
#ifndef _WIN64
auto args=stack->ebp;
#else
auto args=stack->r14;
#endif
auto offR = -0x80;
auto offset = offR + 0x10 + idx * 4;
return (uintptr_t)emu_addr(stack,*(uint32_t*)(args+offset));
}
};
public:
emu_arg(hook_stack *stack_) : stack(stack_) {};
uintptr_t operator[](int idx)
{
#ifndef _WIN64
auto args = stack->ebp;
#else
auto args = stack->r14;
#endif
auto offR = -0x80;
auto offset = offR + 0x10 + idx * 4;
return (uintptr_t)emu_addr(stack, *(uint32_t *)(args + offset));
}
};
}
8 changes: 8 additions & 0 deletions LunaHook/engines/ppsspp/specialgames.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,11 @@ namespace ppsspp
strReplace(s, "\n\r\n", "\n");
return write_string_overwrite(data, len, s);
}
bool FNPJH50127(void *data, size_t *len, HookParam *hp)
{
StringCharReplacer((char *)data, len, "\\n", 2, '\n');
return true;
}
bool FULJM05690(void *data, size_t *len, HookParam *hp)
{
auto s = std::string((char *)data, *len);
Expand Down Expand Up @@ -400,6 +405,9 @@ namespace ppsspp
{0x8889CCC, {CODEC_UTF8, 1, 0, 0, FNPJH50459, "NPJH50716"}}, // 会有两三条后续文本都被一次性提取到。
// マイナスエイト
{0x88DC218, {0, 0, 0, 0, FULJM05690, "ULJM06341"}},
// Tokimeki Memorial 4
{0x899a510, {0, 2, 0, 0, FNPJH50127, "NPJH50127"}},
{0x88719dc, {0, 1, 0, 0, FNPJH50127, "NPJH50127"}},
};

}
2 changes: 1 addition & 1 deletion LunaHook/hookfinder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ void SafeSendJitVeh(hook_stack *stack, uintptr_t address, uintptr_t em_addr, JIT
{
#ifdef _WIN64
case JITTYPE::YUZU:
str = (char *)YUZU::emu_arg(stack)[i];
str = (char *)YUZU::emu_arg(stack, em_addr)[i];
break;
case JITTYPE::VITA3K:
str = (char *)VITA3K::emu_arg(stack)[i];
Expand Down
2 changes: 1 addition & 1 deletion LunaHook/texthook.cc
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ uintptr_t jitgetaddr(hook_stack *stack, HookParam *hp)
case JITTYPE::VITA3K:
return VITA3K::emu_arg(stack)[hp->argidx];
case JITTYPE::YUZU:
return YUZU::emu_arg(stack)[hp->argidx];
return YUZU::emu_arg(stack, hp->emu_addr)[hp->argidx];
#endif
case JITTYPE::PPSSPP:
return PPSSPP::emu_arg(stack)[hp->argidx];
Expand Down
2 changes: 1 addition & 1 deletion LunaHost/LunaHostDll.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ C_LUNA_API void Luna_embedcallback(DWORD pid, LPCWSTR text, LPCWSTR trans)
auto sm = Host::GetEmbedSharedMem(pid);
if (!sm)
return;
wcscpy_s(sm->text, 1000, trans);
wcsncpy(sm->text, trans, ARRAYSIZE(sm->text));
char eventname[1000];
sprintf(eventname, LUNA_EMBED_notify_event, pid, djb2_n2((const unsigned char *)(text), wcslen(text) * 2));
win_event event1(eventname);
Expand Down

0 comments on commit a963692

Please sign in to comment.