mirror of
https://github.com/HIllya51/LunaTranslator.git
synced 2025-01-13 07:33:53 +08:00
.
This commit is contained in:
parent
1ff6c2567f
commit
72634e51e4
3
.gitmodules
vendored
3
.gitmodules
vendored
@ -4,9 +4,6 @@
|
||||
[submodule "src/plugins/libs/rapidfuzz-cpp"]
|
||||
path = cpp/libs/rapidfuzz-cpp
|
||||
url = https://github.com/rapidfuzz/rapidfuzz-cpp
|
||||
[submodule "src/plugins/libs/wechat-ocr"]
|
||||
path = cpp/libs/wechat-ocr
|
||||
url = https://github.com/swigger/wechat-ocr
|
||||
[submodule "src/plugins/libs/Clipper2"]
|
||||
path = cpp/libs/Clipper2
|
||||
url = https://github.com/AngusJohnson/Clipper2
|
||||
|
@ -95,16 +95,6 @@ bool PyStand::CheckEnviron(const wchar_t *rtp)
|
||||
SetEnvironmentVariableW(L"PYSTAND_HOME", _home.c_str());
|
||||
SetEnvironmentVariableW(L"PYSTAND_RUNTIME", _runtime.c_str());
|
||||
|
||||
// unnecessary to init PYSTAND_SCRIPT here.
|
||||
#if 0
|
||||
SetEnvironmentVariableW(L"PYSTAND_SCRIPT", _script.c_str());
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
wprintf(L"%s - %s\n", _pystand.c_str(), path);
|
||||
MessageBoxW(NULL, _pystand.c_str(), _home.c_str(), MB_OK);
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -223,7 +213,9 @@ int PyStand::DetectScript()
|
||||
return -1;
|
||||
}
|
||||
SetEnvironmentVariableW(L"PYSTAND_SCRIPT", _script.c_str());
|
||||
|
||||
std::vector<wchar_t> buffer(MAX_PATH);
|
||||
GetModuleFileNameW(GetModuleHandle(0), buffer.data(), MAX_PATH);
|
||||
SetEnvironmentVariableW(L"LUNA_EXE_NAME", buffer.data());
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit ed98928c66707988d4eb2c49a31c41380a08931c
|
||||
Subproject commit 7598be97d333837c460c778dd16ba8d945fefdba
|
@ -1 +1 @@
|
||||
Subproject commit cbdf84388cea0f12d8a02d9bac28d806b178302a
|
||||
Subproject commit 6ec7699ef20ddf87687c6b055be35ec6a034020c
|
@ -1 +0,0 @@
|
||||
Subproject commit 2faebdc1ce91100acfaa550d83a8a470e98b9035
|
@ -1 +1 @@
|
||||
Subproject commit 6f60a1b76fb812c6af5db1bc7abdec0001edd43f
|
||||
Subproject commit 27d66a24b55a2f7baf91c06c196ba1a2d256c2db
|
@ -1,7 +1,7 @@
|
||||
|
||||
set(VERSION_MAJOR 6)
|
||||
set(VERSION_MINOR 16)
|
||||
set(VERSION_PATCH 16)
|
||||
set(VERSION_PATCH 17)
|
||||
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)
|
||||
|
@ -1,20 +1,15 @@
|
||||
|
||||
project(wcocr)
|
||||
|
||||
set(wcocr_src wechat-ocr/src/mojocall.cpp wechat-ocr/src/ocr_protobuf.pb.cc wechat-ocr/src/wechatocr.cpp)
|
||||
message(${wcocr_src})
|
||||
string(REPLACE ";" ";../libs/" wcocr_src "${wcocr_src}")
|
||||
message(${wcocr_src})
|
||||
set(wcocr_src "../libs/${wcocr_src}")
|
||||
message(${wcocr_src})
|
||||
set(wcocr_src wechat-ocr/src/mojocall.cpp wechat-ocr/src/ocr_common.pb.cc wechat-ocr/src/ocr_wx3.pb.cc wechat-ocr/src/ocr_wx4.pb.cc wechat-ocr/src/wechatocr.cpp)
|
||||
|
||||
|
||||
add_library(wcocr MODULE wcocr.cpp ${wcocr_src})
|
||||
target_include_directories(wcocr PUBLIC ../libs/wechat-ocr/vs.proj PUBLIC ../libs/wechat-ocr/src PRIVATE ../libs/wechat-ocr/spt)
|
||||
target_include_directories(wcocr PUBLIC wechat-ocr/vs.proj PUBLIC wechat-ocr/src PRIVATE wechat-ocr/spt)
|
||||
|
||||
target_compile_options(wcocr
|
||||
PUBLIC
|
||||
/std:c++17
|
||||
/std:c++20
|
||||
/MD
|
||||
/wd4018
|
||||
/DUNICODE
|
||||
@ -22,9 +17,9 @@ target_compile_options(wcocr
|
||||
)
|
||||
|
||||
if(${CMAKE_SIZEOF_VOID_P} EQUAL 8)
|
||||
target_link_libraries(wcocr ${CMAKE_SOURCE_DIR}/libs/wechat-ocr/spt/x64/libprotobuf-lite.lib ${CMAKE_SOURCE_DIR}/libs/wechat-ocr/spt/x64/mmmojo_64.lib)
|
||||
target_link_libraries(wcocr ${CMAKE_CURRENT_SOURCE_DIR}/wechat-ocr/spt/x64/libprotobuf-lite.lib ${CMAKE_CURRENT_SOURCE_DIR}/wechat-ocr/spt/x64/mmmojo_64.lib)
|
||||
target_link_options(wcocr PRIVATE "/DELAYLOAD:mmmojo_64.dll")
|
||||
else()
|
||||
target_link_libraries(wcocr ${CMAKE_SOURCE_DIR}/libs/wechat-ocr/spt/x86/libprotobuf-lite.lib ${CMAKE_SOURCE_DIR}/libs/wechat-ocr/spt/x86/mmmojo.lib)
|
||||
target_link_libraries(wcocr ${CMAKE_CURRENT_SOURCE_DIR}/wechat-ocr/spt/x86/libprotobuf-lite.lib ${CMAKE_CURRENT_SOURCE_DIR}/wechat-ocr/spt/x86/mmmojo.lib)
|
||||
target_link_options(wcocr PRIVATE "/DELAYLOAD:mmmojo.dll")
|
||||
endif()
|
||||
|
@ -124,7 +124,8 @@ def getpidexe(pid):
|
||||
|
||||
|
||||
def getcurrexe():
|
||||
return getpidexe(os.getpid())
|
||||
# getpidexe(os.getpid())谜之有人获取到的结果是None,无法理解,那就先回档吧。
|
||||
return os.environ.get("LUNA_EXE_NAME", getpidexe(os.getpid()))
|
||||
|
||||
|
||||
def test_injectable_1(pid):
|
||||
|
@ -10,8 +10,9 @@ class OCR(baseocr):
|
||||
|
||||
timestamp = int(time.time() * 1000)
|
||||
url = "https://lens.google.com/v3/upload?stcs={}".format(timestamp)
|
||||
# https://github.com/AuroraWright/owocr/blob/master/owocr/ocr.py#L209C9-L209C204
|
||||
headers = {
|
||||
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36",
|
||||
"User-Agent": "Mozilla/5.0 (SMART-TV; Linux; Tizen 6.0) AppleWebKit/538.1 (KHTML, like Gecko) Version/6.0 TV Safari/538.1 STvPlus/9e6462f14a056031e5b32ece2af7c3ca,gzip(gfe),gzip(gfe)"
|
||||
}
|
||||
cookies = {"SOCS": "CAESEwgDEgk0ODE3Nzk3MjQaAmVuIAEaBgiA_LyaBg"}
|
||||
files = {"encoded_image": ("screenshot.png", imagebinary, "image/png")}
|
||||
|
@ -19,13 +19,13 @@ class wcocr:
|
||||
for function in [self.findwechat, self.findqqnt]:
|
||||
try:
|
||||
wechatocr_path, wechat_path = function()
|
||||
if any([not os.path.exists(_) for _ in (wechatocr_path, wechat_path)]):
|
||||
continue
|
||||
self.pobj = wcocr_init(wechatocr_path, wechat_path)
|
||||
if self.pobj:
|
||||
break
|
||||
except:
|
||||
print_exc()
|
||||
if any([not os.path.exists(_) for _ in (wechatocr_path, wechat_path)]):
|
||||
continue
|
||||
self.pobj = wcocr_init(wechatocr_path, wechat_path)
|
||||
if self.pobj:
|
||||
break
|
||||
if not self.pobj:
|
||||
raise Exception("找不到(微信和WeChatOCR)或(QQNT和TencentOCR)")
|
||||
|
||||
@ -52,20 +52,34 @@ class wcocr:
|
||||
base = winreg.QueryValueEx(k, "InstallPath")[0]
|
||||
winreg.CloseKey(k)
|
||||
WeChatexe = os.path.join(base, "WeChat.exe")
|
||||
if not os.path.exists(WeChatexe):
|
||||
# 4.x
|
||||
WeChatexe = os.path.join(base, "Weixin.exe")
|
||||
version = winsharedutils.queryversion(WeChatexe)
|
||||
if not version:
|
||||
raise Exception
|
||||
|
||||
versionf = ".".join((str(_) for _ in version))
|
||||
wechat_path = os.path.join(base, "[" + versionf + "]")
|
||||
wechatocr_path = (
|
||||
os.getenv("APPDATA") + r"\Tencent\WeChat\XPlugin\Plugins\WeChatOCR"
|
||||
)
|
||||
wechatocr_path = os.path.join(
|
||||
wechatocr_path,
|
||||
os.listdir(wechatocr_path)[0],
|
||||
r"extracted\WeChatOCR.exe",
|
||||
)
|
||||
APPDATA = os.getenv("APPDATA")
|
||||
if version[0] == 4:
|
||||
wechat_path = os.path.join(base, versionf)
|
||||
wechatocr_path = os.path.join(
|
||||
APPDATA, r"Tencent\xwechat\XPlugin\plugins\WeChatOcr"
|
||||
)
|
||||
wechatocr_path = os.path.join(
|
||||
wechatocr_path,
|
||||
os.listdir(wechatocr_path)[0],
|
||||
r"extracted\wxocr.dll",
|
||||
)
|
||||
elif version[0] == 3:
|
||||
wechat_path = os.path.join(base, "[" + versionf + "]")
|
||||
wechatocr_path = os.path.join(
|
||||
APPDATA, r"Tencent\WeChat\XPlugin\Plugins\WeChatOCR"
|
||||
)
|
||||
wechatocr_path = os.path.join(
|
||||
wechatocr_path,
|
||||
os.listdir(wechatocr_path)[0],
|
||||
r"extracted\WeChatOCR.exe",
|
||||
)
|
||||
return wechatocr_path, wechat_path
|
||||
|
||||
def __del__(self):
|
||||
@ -89,9 +103,9 @@ class wcocr:
|
||||
|
||||
fp = CFUNCTYPE(None, c_int, c_int, c_int, c_int, c_char_p)(cb)
|
||||
succ = wcocr_ocr(self.pobj, imgfile.encode("utf8"), fp)
|
||||
os.remove(imgfile)
|
||||
if not succ:
|
||||
return
|
||||
os.remove(imgfile)
|
||||
boxs = []
|
||||
texts = []
|
||||
for line in ret:
|
||||
|
Loading…
x
Reference in New Issue
Block a user