This commit is contained in:
恍兮惚兮 2024-12-03 19:51:33 +08:00
parent ea2a650084
commit 987a4ebd52

View File

@ -5,7 +5,6 @@ namespace
auto idxDescriptor = isVirtual == true ? 2 : 1; auto idxDescriptor = isVirtual == true ? 2 : 1;
auto idxEntrypoint = idxDescriptor + 1; auto idxEntrypoint = idxDescriptor + 1;
std::string Vita3KGameID; std::string Vita3KGameID;
std::atomic<uintptr_t> unindexablehooks_near = 0;
uintptr_t getDoJitAddress() uintptr_t getDoJitAddress()
{ {
// Vita3K\external\dynarmic\src\dynarmic\backend\x64\emit_x64.h // Vita3K\external\dynarmic\src\dynarmic\backend\x64\emit_x64.h
@ -38,7 +37,6 @@ namespace
const char *_id; const char *_id;
}; };
std::unordered_map<uintptr_t, emfuncinfo> emfunctionhooks; std::unordered_map<uintptr_t, emfuncinfo> emfunctionhooks;
std::unordered_map<std::string, std::function<bool(uintptr_t)>> unindexablehooks;
} }
namespace namespace
@ -79,28 +77,7 @@ namespace
return; return;
Vita3KGameID = wcasta(curr); Vita3KGameID = wcasta(curr);
last = curr; last = curr;
HostInfo(HOSTINFO::EmuGameName, WideStringToString(game).c_str()); return HostInfo(HOSTINFO::EmuGameName, WideStringToString(game).c_str());
for (auto &&[id, ptr] : unindexablehooks)
{
if (id == Vita3KGameID)
{
HookParam hp;
static int __fake = 0x10;
hp.address = __fake++;
hp.type = DIRECT_READ;
hp.user_value = (uintptr_t)&ptr;
hp.text_fun = [](hook_stack *stack, HookParam *hp, TextBuffer *buffer, uintptr_t *split)
{
auto __ = unindexablehooks_near.load();
if (!__)
return;
if ((*((decltype(ptr) *)hp->user_value))(__))
hp->type |= HOOK_EMPTY;
};
NewHook(hp, (id + " Loader").c_str());
}
}
return;
} }
}; };
hp.type = DIRECT_READ; hp.type = DIRECT_READ;
@ -123,7 +100,6 @@ bool vita3k::attach_function()
{ {
auto descriptor = *argidx(stack, idxDescriptor + 1); // r8 auto descriptor = *argidx(stack, idxDescriptor + 1); // r8
auto entrypoint = *argidx(stack, idxEntrypoint + 1); // r9 auto entrypoint = *argidx(stack, idxEntrypoint + 1); // r9
unindexablehooks_near.store(entrypoint);
auto em_address = *(uint32_t *)descriptor; auto em_address = *(uint32_t *)descriptor;
if (em_address < 0x80000000) if (em_address < 0x80000000)
em_address += 0x80000000; // 0.1.9 3339 em_address += 0x80000000; // 0.1.9 3339
@ -522,7 +498,6 @@ namespace
auto _ = []() auto _ = []()
{ {
unindexablehooks = {};
emfunctionhooks = { emfunctionhooks = {
// 追放選挙 // 追放選挙
{0x8002e176, {0, 0, 0, 0, FPCSG01023, "PCSG01023"}}, // dialogue+name,sjis {0x8002e176, {0, 0, 0, 0, FPCSG01023, "PCSG01023"}}, // dialogue+name,sjis