Skip to content

Commit

Permalink
some
Browse files Browse the repository at this point in the history
  • Loading branch information
HIllya51 committed Nov 9, 2024
1 parent 4427d28 commit ac7843e
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 15 deletions.
44 changes: 41 additions & 3 deletions cpp/LunaHook/LunaHook/engine64/yuzu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -912,15 +912,15 @@ namespace
}
void F0100B0601852A000(TextBuffer *buffer, HookParam *hp)
{
auto s = buffer->strW();
auto s = buffer->viewW();
static std::wstring last;
if (last == s)
return buffer->clear();
last = s;
}
void F010027100C79A000(TextBuffer *buffer, HookParam *hp)
{
auto s = buffer->strA();
auto s = buffer->viewA();
static std::string last;
if (last == s)
return buffer->clear();
Expand Down Expand Up @@ -1775,6 +1775,18 @@ namespace
s = std::regex_replace(s, std::regex("@[0-9]"), "");
buffer->from(s);
}
void F01000EA00B23C000(TextBuffer *buffer, HookParam *hp)
{
auto s = buffer->strW();
s = std::regex_replace(s, std::wregex(L"[`@](.*?)@"), L"$1");
s = std::regex_replace(s, std::wregex(L"\\$\\[(.*?)\\$/(.*?)\\$\\]"), L"$1");
s = std::regex_replace(s, std::wregex(L"\\$K\\d+(.*?)\\$K\\d+"), L"$1");
s = std::regex_replace(s, std::wregex(L"\\$A\\d+"), L"");
strReplace(s, L"$2", L"");
strReplace(s, L"$1", L"山田");
strReplace(s, L"$(3)", L"");
buffer->from(s);
}
void F010060301588A000(TextBuffer *buffer, HookParam *hp)
{
auto s = buffer->strA();
Expand Down Expand Up @@ -2059,7 +2071,24 @@ namespace
namespace
{
#pragma optimize("", off)
// 必须禁止优化这个函数,或者引用一下参数,否则参数被优化没了。
void TT0100A4700BC98000(const char *_) {}
#pragma optimize("", on)

void T0100A4700BC98000(TextBuffer *buffer, HookParam *)
{
auto s = buffer->strA();
HookParam hp;
hp.address = (uintptr_t)TT0100A4700BC98000;
hp.offset = GETARG1;
hp.type = CODEC_UTF8 | USING_STRING;
static auto _ = NewHook(hp, "0100A4700BC98000");
TT0100A4700BC98000(s.c_str());
// buffer->clear();
}
}
namespace
{
#pragma optimize("", off)
void F01006530151F0000_collect(const wchar_t *_) {}
#pragma optimize("", on)
void F01006530151F0000(TextBuffer *buffer, HookParam *)
Expand Down Expand Up @@ -3284,6 +3313,15 @@ namespace
// Money Parasite ~Usotsuki na Onna~
{0x2169ac, {0, 0, 0, 0, F0100A250191E8000<false>, "0100A250191E8000", "1.0.0"}},
{0x217030, {0, 0, 0, 0, F0100A250191E8000<true>, "0100A250191E8000", "1.0.0"}},
// 三国恋戦記~オトメの兵法!~
{0x800644A0, {CODEC_UTF16, 1, 0, 0, F01000EA00B23C000, "01000EA00B23C000", "1.0.0"}},
// 三国恋戦記~思いでがえし~+学園恋戦記
{0x80153B20, {CODEC_UTF16, 8, 0, 0, F01000EA00B23C000, "01003B6014B38000", "1.0.0"}},
// 殺人探偵ジャック・ザ・リッパー
{0x8000ED30, {CODEC_UTF8, 0, 0, 0, T0100A4700BC98000, "0100A4700BC98000", "1.0.0"}}, // 1.0.0有漏的
{0x8000ED1C, {CODEC_UTF8, 0, 0, 0, T0100A4700BC98000, "0100A4700BC98000", "1.0.0"}},
{0x8000ED3C, {CODEC_UTF8, 0, 0, 0, T0100A4700BC98000, "0100A4700BC98000", "1.0.0"}},
{0x8003734C, {CODEC_UTF8, 2, 0, 0, F010027100C79A000, "0100A4700BC98000", "1.0.2"}}, // 完整
};
return 1;
}();
Expand Down
13 changes: 8 additions & 5 deletions cpp/LunaHook/LunaHook/util/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,20 +94,23 @@ struct WindowInfo
};
std::vector<WindowInfo> get_proc_windows();

template <typename StringT>
size_t strSize(const StringT &s)
{
return s.size() * sizeof(StringT::value_type);
}

template <typename StringT>
auto allocateString(const StringT &s) -> typename StringT::value_type *
{
size_t t = s.size();
typename StringT::value_type *_data = new typename StringT::value_type[t + 1];
strcpyEx(_data, s.data());
memcpy(_data, s.data(), strSize(s));
_data[t] = 0;
return _data;
}

template <typename StringT>
size_t strSize(const StringT &s)
{
return s.size() * sizeof(StringT::value_type);
}

bool IsShiftjisWord(WORD w);
bool IsShiftjisLeadByte(BYTE b);
10 changes: 5 additions & 5 deletions cpp/LunaHook/include/stringutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ std::optional<std::wstring> StringToWideString(const std::string &text, UINT enc

std::optional<std::wstring> StringToWideString(std::string_view text, UINT encoding)
{
std::vector<wchar_t> buffer(text.size() + 1);
std::vector<wchar_t> buffer(text.size());
if (disable_mbwc)
{
int _s = text.size();
Expand All @@ -122,8 +122,8 @@ std::optional<std::wstring> StringToWideString(std::string_view text, UINT encod
}
else
{
if (int length = MultiByteToWideChar(encoding, 0, text.data(), text.size() + 1, buffer.data(), buffer.size()))
return std::wstring(buffer.data(), length - 1);
if (int length = MultiByteToWideChar(encoding, 0, text.data(), text.size(), buffer.data(), buffer.size()))
return std::wstring(buffer.data(), length);
return {};
}
}
Expand Down Expand Up @@ -157,7 +157,7 @@ std::string WideStringToString(const wchar_t *text, UINT cp)
}
std::string WideStringToString(std::wstring_view text, UINT cp)
{
std::vector<char> buffer((text.size() + 1) * 4);
std::vector<char> buffer((text.size()) * 4);
if (disable_wcmb)
{
int _s = text.size();
Expand All @@ -178,7 +178,7 @@ std::string WideStringToString(std::wstring_view text, UINT cp)
}
else
{
WideCharToMultiByte(cp, 0, text.data(), -1, buffer.data(), buffer.size(), nullptr, nullptr);
WideCharToMultiByte(cp, 0, text.data(), text.size(), buffer.data(), buffer.size(), nullptr, nullptr);
return buffer.data();
}
}
Expand Down
2 changes: 1 addition & 1 deletion cpp/version.cmake
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

set(VERSION_MAJOR 5)
set(VERSION_MINOR 56)
set(VERSION_PATCH 5)
set(VERSION_PATCH 6)

include(${CMAKE_CURRENT_LIST_DIR}/version/generate_product_version.cmake)
9 changes: 8 additions & 1 deletion py/LunaTranslator/myutils/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -378,9 +378,16 @@ def findgameuidofpath(gamepath, findall=False):
use = savehook_new_list
else:
use = sub["games"]
minidx = len(use)
minuid = None
for uid in uids:
if uid in use:
return uid, use
idx = use.index(uid)
if minidx > idx:
minidx = idx
minuid = uid
if minuid:
return minuid, use
if findall:
return collect
else:
Expand Down

0 comments on commit ac7843e

Please sign in to comment.