mirror of
https://github.com/HIllya51/LunaTranslator.git
synced 2024-12-28 08:04:13 +08:00
fix
This commit is contained in:
parent
7d3d76ac2a
commit
78295d2c15
43
.github/scripts/build_lunahook.py
vendored
43
.github/scripts/build_lunahook.py
vendored
@ -4,7 +4,7 @@ import subprocess
|
|||||||
rootDir = os.path.dirname(__file__)
|
rootDir = os.path.dirname(__file__)
|
||||||
if not rootDir:
|
if not rootDir:
|
||||||
rootDir = os.path.abspath(".")
|
rootDir = os.path.abspath(".")
|
||||||
rootDir=os.path.abspath(os.path.join(rootDir,'../../cpp/LunaHook'))
|
rootDir = os.path.abspath(os.path.join(rootDir, "../../cpp/LunaHook"))
|
||||||
if len(sys.argv) and sys.argv[1] == "loadversion":
|
if len(sys.argv) and sys.argv[1] == "loadversion":
|
||||||
os.chdir(rootDir)
|
os.chdir(rootDir)
|
||||||
with open("CMakeLists.txt", "r", encoding="utf8") as ff:
|
with open("CMakeLists.txt", "r", encoding="utf8") as ff:
|
||||||
@ -21,15 +21,15 @@ if len(sys.argv) and sys.argv[1] == "merge":
|
|||||||
language = ["Chinese", "English", "Russian", "TradChinese"]
|
language = ["Chinese", "English", "Russian", "TradChinese"]
|
||||||
for lang in language:
|
for lang in language:
|
||||||
shutil.copytree(
|
shutil.copytree(
|
||||||
f"build/{lang}_64/Release_{lang}",
|
f"build/{lang}_64/Release_{lang}",
|
||||||
f"../build/Release_{lang}",
|
f"../build/Release_{lang}",
|
||||||
dirs_exist_ok=True,
|
dirs_exist_ok=True,
|
||||||
)
|
)
|
||||||
shutil.copytree(
|
shutil.copytree(
|
||||||
f"build/{lang}_winxp/Release_{lang}_winxp",
|
f"build/{lang}_winxp/Release_{lang}_winxp",
|
||||||
f"../build/Release_{lang}",
|
f"../build/Release_{lang}",
|
||||||
dirs_exist_ok=True,
|
dirs_exist_ok=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
targetdir = f"../build/Release_{lang}"
|
targetdir = f"../build/Release_{lang}"
|
||||||
target = f"builds/Release_{lang}.zip"
|
target = f"builds/Release_{lang}.zip"
|
||||||
@ -72,7 +72,7 @@ def build_langx_xp(lang, core):
|
|||||||
os.system(rf"curl -SLo YY-Thunks-1.0.7-Binary.zip " + url)
|
os.system(rf"curl -SLo YY-Thunks-1.0.7-Binary.zip " + url)
|
||||||
os.system(rf"7z x -y YY-Thunks-1.0.7-Binary.zip -o../../libs/YY-Thunks")
|
os.system(rf"7z x -y YY-Thunks-1.0.7-Binary.zip -o../../libs/YY-Thunks")
|
||||||
os.system("dir")
|
os.system("dir")
|
||||||
flags='' if core else ' -DBUILD_GUI=ON -DBUILD_CLI=ON '
|
flags = "" if core else " -DBUILD_GUI=ON -DBUILD_CLI=ON "
|
||||||
with open("do.bat", "w") as ff:
|
with open("do.bat", "w") as ff:
|
||||||
ff.write(
|
ff.write(
|
||||||
rf"""
|
rf"""
|
||||||
@ -83,11 +83,26 @@ cmake --build ../build/x86_{lang}_xp --config Release --target ALL_BUILD -j 14
|
|||||||
)
|
)
|
||||||
os.system(f"cmd /c do.bat")
|
os.system(f"cmd /c do.bat")
|
||||||
|
|
||||||
|
|
||||||
os.chdir(os.path.join(rootDir, "scripts"))
|
os.chdir(os.path.join(rootDir, "scripts"))
|
||||||
if sys.argv[1] == "plg32":
|
if sys.argv[1] == "plugin":
|
||||||
os.system(f"cmd /c buildplugin32.bat")
|
bits = sys.argv[2]
|
||||||
elif sys.argv[1] == "plg64":
|
with open("buildplugin.bat", "w") as ff:
|
||||||
os.system(f"cmd /c buildplugin64.bat")
|
if bits == "32":
|
||||||
|
ff.write(
|
||||||
|
rf"""
|
||||||
|
cmake -DBUILD_CORE=OFF -DUSESYSQTPATH=1 -DBUILD_PLUGIN=ON ../CMakeLists.txt -G "Visual Studio 17 2022" -A win32 -T host=x86 -B ../build/plugin32
|
||||||
|
cmake --build ../build/plugin32 --config Release --target ALL_BUILD -j 14
|
||||||
|
"""
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
ff.write(
|
||||||
|
rf"""
|
||||||
|
cmake -DBUILD_CORE=OFF -DUSESYSQTPATH=1 -DBUILD_PLUGIN=ON ../CMakeLists.txt -G "Visual Studio 17 2022" -A x64 -T host=x64 -B ../build/plugin64
|
||||||
|
cmake --build ../build/plugin64 --config Release --target ALL_BUILD -j 14
|
||||||
|
"""
|
||||||
|
)
|
||||||
|
os.system(f"cmd /c buildplugin.bat")
|
||||||
elif sys.argv[1] == "build":
|
elif sys.argv[1] == "build":
|
||||||
lang = sys.argv[2]
|
lang = sys.argv[2]
|
||||||
bit = sys.argv[3]
|
bit = sys.argv[3]
|
||||||
|
18
.github/workflows/buildlunahook.yml
vendored
18
.github/workflows/buildlunahook.yml
vendored
@ -35,12 +35,10 @@ jobs:
|
|||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
include:
|
include:
|
||||||
- cmd: plg32
|
- bits: 32
|
||||||
qtarch: win32_msvc2019
|
qtarch: win32_msvc2019
|
||||||
target: plugin32
|
- bits: 64
|
||||||
- cmd: plg64
|
|
||||||
qtarch: win64_msvc2019_64
|
qtarch: win64_msvc2019_64
|
||||||
target: plugin64
|
|
||||||
permissions:
|
permissions:
|
||||||
id-token: write
|
id-token: write
|
||||||
attestations: write
|
attestations: write
|
||||||
@ -59,21 +57,17 @@ jobs:
|
|||||||
arch: ${{ matrix.qtarch }}
|
arch: ${{ matrix.qtarch }}
|
||||||
dir: ${{ runner.temp }}
|
dir: ${{ runner.temp }}
|
||||||
setup-python: true
|
setup-python: true
|
||||||
- run: python .github/scripts/build_lunahook.py ${{ matrix.cmd }}
|
- run: python .github/scripts/build_lunahook.py plugin ${{ matrix.bits }}
|
||||||
- run: python .github/scripts/packlunahook.py
|
- run: python .github/scripts/packlunahook.py
|
||||||
|
|
||||||
# - name: Generate attestation for artifact
|
|
||||||
# uses: actions/attest-build-provenance@v1
|
|
||||||
# with:
|
|
||||||
# subject-path: builds/${{ matrix.target }}.zip
|
|
||||||
- uses: actions/upload-artifact@v4
|
- uses: actions/upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
name: ${{ matrix.target }}
|
name: plugin${{ matrix.bits }}
|
||||||
path: cpp/LunaHook/builds/${{ matrix.target }}.zip
|
path: cpp/LunaHook/builds/plugin${{ matrix.bits }}.zip
|
||||||
- uses: softprops/action-gh-release@v2
|
- uses: softprops/action-gh-release@v2
|
||||||
with:
|
with:
|
||||||
tag_name: LunaHook
|
tag_name: LunaHook
|
||||||
files: cpp/LunaHook/builds/${{ matrix.target }}.zip
|
files: cpp/LunaHook/builds/plugin${{ matrix.bits }}.zip
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
build_x:
|
build_x:
|
||||||
|
@ -1750,7 +1750,8 @@ bool WillPlus::attach_function()
|
|||||||
succ |= insertwillplus6();
|
succ |= insertwillplus6();
|
||||||
succ |= willX();
|
succ |= willX();
|
||||||
succ |= _xxx();
|
succ |= _xxx();
|
||||||
|
PcHooks::hookGDIFunctions(GetGlyphOutlineA);
|
||||||
|
PcHooks::hookGDIFunctions(GetGlyphOutlineW);
|
||||||
return succ;
|
return succ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,22 +11,30 @@
|
|||||||
// http://bytes.com/topic/c/answers/135834-defining-wide-character-strings-macros
|
// http://bytes.com/topic/c/answers/135834-defining-wide-character-strings-macros
|
||||||
// #define LPASTE(s) L##s
|
// #define LPASTE(s) L##s
|
||||||
// #define L(s) LPASTE(s)
|
// #define L(s) LPASTE(s)
|
||||||
#define NEW_HOOK(ptr, _dll, _fun, _data, _data_ind, _split_off, _split_ind, _type, _len_off) \
|
|
||||||
{ \
|
Synchronized<std::set<void *>> hookonce;
|
||||||
HookParam hp; \
|
#define NEW_HOOK(ptr, _dll, _fun, _data, _data_ind, _split_off, _split_ind, _type, _len_off) \
|
||||||
wcsncpy_s(hp.module, _dll, MAX_MODULE_SIZE - 1); \
|
{ \
|
||||||
strncpy_s(hp.function, #_fun, MAX_MODULE_SIZE - 1); \
|
HookParam hp; \
|
||||||
hp.offset = _data; \
|
wcsncpy_s(hp.module, _dll, MAX_MODULE_SIZE - 1); \
|
||||||
hp.index = _data_ind; \
|
strncpy_s(hp.function, #_fun, MAX_MODULE_SIZE - 1); \
|
||||||
hp.split = _split_off; \
|
hp.offset = _data; \
|
||||||
hp.split_index = _split_ind; \
|
hp.index = _data_ind; \
|
||||||
hp.type = _type | MODULE_OFFSET | FUNCTION_OFFSET; \
|
hp.split = _split_off; \
|
||||||
hp.length_offset = _len_off; \
|
hp.split_index = _split_ind; \
|
||||||
if ((!ptr) || \
|
hp.type = _type | MODULE_OFFSET | FUNCTION_OFFSET; \
|
||||||
(GetModuleHandle(hp.module) && \
|
hp.length_offset = _len_off; \
|
||||||
GetProcAddress(GetModuleHandle(hp.module), hp.function) && \
|
auto currptr = GetModuleHandle(hp.module) ? GetProcAddress(GetModuleHandle(hp.module), hp.function) : nullptr; \
|
||||||
GetProcAddress(GetModuleHandle(hp.module), hp.function) == ptr)) \
|
bool dohook = false; \
|
||||||
NewHook(hp, #_fun); \
|
if (ptr) \
|
||||||
|
dohook = currptr == ptr; \
|
||||||
|
else if (currptr) \
|
||||||
|
dohook = hookonce->find(currptr) == hookonce->end(); \
|
||||||
|
if (dohook) \
|
||||||
|
{ \
|
||||||
|
NewHook(hp, #_fun); \
|
||||||
|
hookonce->insert(currptr); \
|
||||||
|
} \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define NEW_MODULE_HOOK(_module, _fun, _data, _data_ind, _split_off, _split_ind, _type, _len_off) \
|
#define NEW_MODULE_HOOK(_module, _fun, _data, _data_ind, _split_off, _split_ind, _type, _len_off) \
|
||||||
@ -42,7 +50,13 @@
|
|||||||
hp.split_index = _split_ind; \
|
hp.split_index = _split_ind; \
|
||||||
hp.type = _type | MODULE_OFFSET | FUNCTION_OFFSET; \
|
hp.type = _type | MODULE_OFFSET | FUNCTION_OFFSET; \
|
||||||
hp.length_offset = _len_off; \
|
hp.length_offset = _len_off; \
|
||||||
NewHook(hp, #_fun); \
|
auto currptr = GetProcAddress(_module, hp.function); \
|
||||||
|
auto dohook = currptr ? hookonce->find(currptr) == hookonce->end() : false; \
|
||||||
|
if (dohook) \
|
||||||
|
{ \
|
||||||
|
NewHook(hp, #_fun); \
|
||||||
|
hookonce->insert(currptr); \
|
||||||
|
} \
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef _WIN64
|
#ifndef _WIN64
|
||||||
@ -71,16 +85,6 @@ enum args
|
|||||||
};
|
};
|
||||||
#endif // _WIN64
|
#endif // _WIN64
|
||||||
|
|
||||||
bool once_hookGDIFunctions = false;
|
|
||||||
bool once_hookGDIPlusFunctions = false;
|
|
||||||
bool once_hookD3DXFunctions = false;
|
|
||||||
bool once_hookOtherPcFunctions = false;
|
|
||||||
#define once_run_pchooks(x) \
|
|
||||||
{ \
|
|
||||||
if (once_##x) \
|
|
||||||
return; \
|
|
||||||
once_##x = true; \
|
|
||||||
}
|
|
||||||
constexpr short arg_sz = (short)sizeof(void *);
|
constexpr short arg_sz = (short)sizeof(void *);
|
||||||
void PcHooks::hookGdiGdiplusD3dxFunctions()
|
void PcHooks::hookGdiGdiplusD3dxFunctions()
|
||||||
{
|
{
|
||||||
@ -98,7 +102,6 @@ void PcHooks::hookGdiGdiplusD3dxFunctions()
|
|||||||
// jichi 7/17/2014: Renamed from InitDefaultHook
|
// jichi 7/17/2014: Renamed from InitDefaultHook
|
||||||
void PcHooks::hookGDIFunctions(void *ptr)
|
void PcHooks::hookGDIFunctions(void *ptr)
|
||||||
{
|
{
|
||||||
once_run_pchooks(hookGDIFunctions);
|
|
||||||
// gdi32.dll
|
// gdi32.dll
|
||||||
NEW_HOOK(ptr, L"gdi32.dll", GetTextExtentPoint32A, s_arg2, 0, s_arg1, 0, USING_STRING, s_arg3 / arg_sz)
|
NEW_HOOK(ptr, L"gdi32.dll", GetTextExtentPoint32A, s_arg2, 0, s_arg1, 0, USING_STRING, s_arg3 / arg_sz)
|
||||||
NEW_HOOK(ptr, L"gdi32.dll", GetTextExtentExPointA, s_arg2, 0, s_arg1, 0, USING_STRING, s_arg3 / arg_sz)
|
NEW_HOOK(ptr, L"gdi32.dll", GetTextExtentExPointA, s_arg2, 0, s_arg1, 0, USING_STRING, s_arg3 / arg_sz)
|
||||||
@ -139,7 +142,6 @@ void PcHooks::hookGDIFunctions(void *ptr)
|
|||||||
// jichi 6/18/2015: GDI+ functions
|
// jichi 6/18/2015: GDI+ functions
|
||||||
void PcHooks::hookGDIPlusFunctions()
|
void PcHooks::hookGDIPlusFunctions()
|
||||||
{
|
{
|
||||||
once_run_pchooks(hookGDIPlusFunctions);
|
|
||||||
HMODULE hModule = ::GetModuleHandleA("gdiplus.dll");
|
HMODULE hModule = ::GetModuleHandleA("gdiplus.dll");
|
||||||
if (!hModule)
|
if (!hModule)
|
||||||
return;
|
return;
|
||||||
@ -162,7 +164,6 @@ void PcHooks::hookGDIPlusFunctions()
|
|||||||
|
|
||||||
void PcHooks::hookD3DXFunctions(HMODULE d3dxModule)
|
void PcHooks::hookD3DXFunctions(HMODULE d3dxModule)
|
||||||
{
|
{
|
||||||
once_run_pchooks(hookD3DXFunctions);
|
|
||||||
if (GetProcAddress(d3dxModule, "D3DXCreateTextA"))
|
if (GetProcAddress(d3dxModule, "D3DXCreateTextA"))
|
||||||
{
|
{
|
||||||
NEW_MODULE_HOOK(d3dxModule, D3DXCreateTextA, s_arg3, 0, 0, 0, USING_STRING, 0)
|
NEW_MODULE_HOOK(d3dxModule, D3DXCreateTextA, s_arg3, 0, 0, 0, USING_STRING, 0)
|
||||||
@ -219,7 +220,6 @@ void PcHooks::hookD3DXFunctions(HMODULE d3dxModule)
|
|||||||
// Note: All functions does not have NO_CONTEXT attribute and will be filtered.
|
// Note: All functions does not have NO_CONTEXT attribute and will be filtered.
|
||||||
void PcHooks::hookOtherPcFunctions(void *ptr)
|
void PcHooks::hookOtherPcFunctions(void *ptr)
|
||||||
{
|
{
|
||||||
once_run_pchooks(hookOtherPcFunctions);
|
|
||||||
// int TextHook::InitHook(LPVOID addr, DWORD data, DWORD data_ind, DWORD split_off, DWORD split_ind, WORD type, DWORD len_off)
|
// int TextHook::InitHook(LPVOID addr, DWORD data, DWORD data_ind, DWORD split_off, DWORD split_ind, WORD type, DWORD len_off)
|
||||||
|
|
||||||
// http://msdn.microsoft.com/en-us/library/78zh94ax.aspx
|
// http://msdn.microsoft.com/en-us/library/78zh94ax.aspx
|
||||||
|
Loading…
x
Reference in New Issue
Block a user