mirror of
https://github.com/HIllya51/LunaTranslator.git
synced 2024-12-27 15:44:12 +08:00
.
This commit is contained in:
parent
1056df85c6
commit
97c6999f9b
@ -4,6 +4,7 @@ namespace
|
||||
auto isVirtual = true;
|
||||
auto idxDescriptor = isVirtual == true ? 2 : 1;
|
||||
auto idxEntrypoint = idxDescriptor + 1;
|
||||
std::string Vita3KGameID;
|
||||
uintptr_t getDoJitAddress()
|
||||
{
|
||||
auto RegisterBlockSig1 = "40 55 53 56 57 41 54 41 56 41 57 48 8D 6C 24 E9 48 81 EC 90 00 00 00 48 8B ?? ?? ?? ?? ?? 48 33 C4 48 89 45 07 4D 8B F1 49 8B F0 48 8B FA 48 8B D9 4C 8B 7D 77 48 8B 01 48 8D 55 C7 FF 50 10";
|
||||
@ -45,24 +46,60 @@ namespace
|
||||
};
|
||||
std::unordered_map<uintptr_t, emfuncinfo> emfunctionhooks;
|
||||
|
||||
bool checkiscurrentgame(const emfuncinfo &em)
|
||||
}
|
||||
|
||||
namespace
|
||||
{
|
||||
void trygetgameinwindowtitle()
|
||||
{
|
||||
|
||||
HookParam hp;
|
||||
hp.address = 0x3000;
|
||||
hp.text_fun = [](hook_stack *stack, HookParam *hp, TextBuffer *buffer, uintptr_t *split)
|
||||
{
|
||||
static std::wstring last;
|
||||
// vita3k Vulkan模式GetWindowText会卡住
|
||||
auto getSecondSubstring = [](const std::wstring &str) -> std::wstring
|
||||
{
|
||||
size_t firstPos = str.find(L'|');
|
||||
if (firstPos == std::wstring::npos)
|
||||
return L"";
|
||||
size_t nextPos = str.find(L'|', firstPos + 1);
|
||||
if (nextPos == std::wstring::npos)
|
||||
return L"";
|
||||
size_t start = firstPos + 1;
|
||||
size_t end = nextPos;
|
||||
return str.substr(start, end - start);
|
||||
};
|
||||
auto wininfos = get_proc_windows();
|
||||
for (auto &&info : wininfos)
|
||||
{
|
||||
if (info.title.find(acastw(em._id)) != info.title.npos)
|
||||
return true;
|
||||
auto game = getSecondSubstring(info.title);
|
||||
if (!game.size())
|
||||
continue;
|
||||
std::wregex reg1(L"\\((.*?)\\)");
|
||||
std::wsmatch match;
|
||||
if (!std::regex_search(game, match, reg1))
|
||||
return;
|
||||
auto curr = match[1].str();
|
||||
if (last == curr)
|
||||
return;
|
||||
Vita3KGameID = wcasta(curr);
|
||||
last = curr;
|
||||
return HostInfo(HOSTINFO::EmuGameName, WideStringToString(game).c_str());
|
||||
}
|
||||
return false;
|
||||
};
|
||||
hp.type = DIRECT_READ;
|
||||
NewHook(hp, "Vita3KGameInfo");
|
||||
}
|
||||
}
|
||||
|
||||
bool vita3k::attach_function()
|
||||
{
|
||||
ConsoleOutput("[Compatibility] Vita3k 0.1.9 3339+");
|
||||
auto DoJitPtr = getDoJitAddress();
|
||||
if (DoJitPtr == 0)
|
||||
return false;
|
||||
trygetgameinwindowtitle();
|
||||
spDefault.isjithook = true;
|
||||
spDefault.minAddress = 0;
|
||||
spDefault.maxAddress = -1;
|
||||
@ -84,9 +121,8 @@ bool vita3k::attach_function()
|
||||
if (emfunctionhooks.find(em_address) == emfunctionhooks.end())
|
||||
return;
|
||||
auto op = emfunctionhooks.at(em_address);
|
||||
if (!(checkiscurrentgame(op)))
|
||||
if (Vita3KGameID.size() && (op._id != Vita3KGameID))
|
||||
return;
|
||||
|
||||
HookParam hpinternal;
|
||||
hpinternal.address = entrypoint;
|
||||
hpinternal.emu_addr = em_address; // 用于生成hcode
|
||||
|
@ -62,22 +62,20 @@ namespace
|
||||
std::string version{""};
|
||||
} game_info;
|
||||
bool checkiscurrentgame(const emfuncinfo &em)
|
||||
{
|
||||
auto wininfos = get_proc_windows();
|
||||
for (auto &&info : wininfos)
|
||||
{
|
||||
if ((game_info.version.size()) && game_info.name.size() && (game_info.id != 0))
|
||||
{
|
||||
// 判断是有效的info
|
||||
auto checkversion = (em._version == 0) || (std::string(em._version) == (game_info.version));
|
||||
auto checkid = (std::stoll(em._id, 0, 16) == game_info.id);
|
||||
if (checkid && checkversion)
|
||||
return checkid && checkversion;
|
||||
}
|
||||
else
|
||||
{
|
||||
// 加载游戏后在hook,没有办法获取id。
|
||||
// 标题里没有id,只有version,没啥必要判断了,直接true得了。
|
||||
return true;
|
||||
}
|
||||
else if ((em._version == 0) || (info.title.find(acastw(em._version)) != info.title.npos))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
bool Hook_Network_RoomMember_SendGameInfo()
|
||||
@ -147,17 +145,11 @@ namespace
|
||||
size_t firstPos = str.find(L'|');
|
||||
if (firstPos == std::wstring::npos)
|
||||
return L"";
|
||||
size_t lastPos = str.rfind(L'|');
|
||||
if (lastPos == std::wstring::npos)
|
||||
return L"";
|
||||
lastPos = str.rfind(L'|', lastPos - 1);
|
||||
if (lastPos == std::wstring::npos)
|
||||
return L"";
|
||||
lastPos = str.rfind(L'(', lastPos - 1);
|
||||
if (lastPos == std::wstring::npos)
|
||||
size_t nextPos = str.find(L'|', firstPos + 1);
|
||||
if (nextPos == std::wstring::npos)
|
||||
return L"";
|
||||
size_t start = firstPos + 1;
|
||||
size_t end = lastPos;
|
||||
size_t end = nextPos;
|
||||
return str.substr(start, end - start);
|
||||
};
|
||||
auto wininfos = get_proc_windows();
|
||||
|
@ -274,21 +274,23 @@ namespace ppsspp
|
||||
std::string TITLE{""};
|
||||
} game_info;
|
||||
bool checkiscurrentgame(const emfuncinfo &em)
|
||||
{
|
||||
auto wininfos = get_proc_windows();
|
||||
for (auto &&info : wininfos)
|
||||
{
|
||||
if (game_info.DISC_ID.size())
|
||||
{
|
||||
std::smatch match;
|
||||
if (std::regex_match(game_info.DISC_ID, match, std::regex(em._id)))
|
||||
return true;
|
||||
return std::regex_match(game_info.DISC_ID, match, std::regex(em._id));
|
||||
}
|
||||
else if (std::regex_search(info.title, std::wregex(acastw(em._id))))
|
||||
else
|
||||
{
|
||||
auto wininfos = get_proc_windows();
|
||||
for (auto &&info : wininfos)
|
||||
{
|
||||
if (std::regex_search(info.title, std::wregex(acastw(em._id))))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
std::unordered_set<uintptr_t> breakpoints;
|
||||
|
||||
inline bool IsValidAddress(const uintptr_t address)
|
||||
|
@ -735,27 +735,27 @@ bool Engine::isAddressWritable(const wchar_t *p, size_t count)
|
||||
|
||||
BOOL CALLBACK EnumWindowsProc(HWND hwnd, LPARAM lParam)
|
||||
{
|
||||
std::vector<WindowInfo> *windowList = reinterpret_cast<std::vector<WindowInfo> *>(lParam);
|
||||
auto *hwnds = reinterpret_cast<std::vector<HWND> *>(lParam);
|
||||
DWORD processId;
|
||||
GetWindowThreadProcessId(hwnd, &processId);
|
||||
if (processId == GetCurrentProcessId())
|
||||
{
|
||||
auto length = GetWindowTextLengthW(hwnd);
|
||||
auto title = std::vector<WCHAR>(length + 1);
|
||||
GetWindowTextW(hwnd, title.data(), title.size());
|
||||
|
||||
WindowInfo windowInfo;
|
||||
windowInfo.handle = hwnd;
|
||||
windowInfo.title = title.data();
|
||||
|
||||
windowList->push_back(windowInfo);
|
||||
}
|
||||
if (GetWindowThreadProcessId(hwnd, &processId) && (processId == GetCurrentProcessId()))
|
||||
hwnds->push_back(hwnd);
|
||||
return TRUE;
|
||||
}
|
||||
std::vector<WindowInfo> get_proc_windows()
|
||||
{
|
||||
std::vector<HWND> hwnds;
|
||||
std::vector<WindowInfo> windows;
|
||||
EnumWindows(EnumWindowsProc, reinterpret_cast<LPARAM>(&windows));
|
||||
EnumWindows(EnumWindowsProc, reinterpret_cast<LPARAM>(&hwnds));
|
||||
for (auto hwnd : hwnds)
|
||||
{
|
||||
WindowInfo windowInfo;
|
||||
windowInfo.handle = hwnd;
|
||||
auto length = GetWindowTextLengthW(hwnd);
|
||||
auto title = std::vector<WCHAR>(length + 1);
|
||||
GetWindowTextW(hwnd, title.data(), title.size());
|
||||
windowInfo.title = title.data();
|
||||
windows.emplace_back(windowInfo);
|
||||
}
|
||||
return windows;
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
|
||||
set(VERSION_MAJOR 6)
|
||||
set(VERSION_MINOR 7)
|
||||
set(VERSION_PATCH 1)
|
||||
set(VERSION_PATCH 2)
|
||||
set(VERSION_REVISION 0)
|
||||
set(LUNA_VERSION "{${VERSION_MAJOR},${VERSION_MINOR},${VERSION_PATCH},${VERSION_REVISION}}")
|
||||
add_library(VERSION_DEF ${CMAKE_CURRENT_LIST_DIR}/version_def.cpp)
|
||||
|
Loading…
x
Reference in New Issue
Block a user