diff --git a/.gitignore b/.gitignore index 52370e1a..788384ac 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,3 @@ -LunaTranslator/transkiroku LunaTranslator/userconfig lunatranslator/cache @@ -21,38 +20,14 @@ Thumbs.db *.recipe *.wav build/ -LunaTranslator/testapi.py -plugins/winsharedutils/Release -plugins/winsharedutils/x64 -plugins/winsharedutils/.vs -plugins/winsharedutils/builds -plugins/winsharedutils/build -plugins/winrtutils/builds -plugins/winrtutils/build +plugins/builds +plugins/build -LunaTranslator/files/plugins/Magpie_v0.9.1/cache - - -plugins/exec/.vs -plugins/exec/out -plugins/exec/builds - -plugins/shareddllproxy/Release -plugins/shareddllproxy/out -plugins/shareddllproxy/builds -plugins/shareddllproxy/.vs - - -plugins/winxp_proxy_host/build -plugins/winxp_proxy_host/builds LunaTranslator/files/plugins LunaTranslator/files/ocr LunaTranslator/files/data LunaTranslator/chrome_cache - -plugins/winrtsnapshot/Release -plugins/winrtsnapshot/x64 -plugins/winrtsnapshot/.vs \ No newline at end of file +plugins/.vscode/settings.json diff --git a/LunaTranslator/LunaTranslator/ocrengines/local.py b/LunaTranslator/LunaTranslator/ocrengines/local.py index 1f61806f..15e40572 100644 --- a/LunaTranslator/LunaTranslator/ocrengines/local.py +++ b/LunaTranslator/LunaTranslator/ocrengines/local.py @@ -10,7 +10,7 @@ import os import gobject class ocrwrapper: def __init__(self) -> None: - self.dll=CDLL(gobject.GetDllpath(('ocr32.dll','ocr64.dll'))) + self.dll=CDLL(gobject.GetDllpath(('LunaOCR32.dll','LunaOCR64.dll'))) def _OcrInit(self,szDetModel, szRecModel, szKeyPath,szClsModel='', nThreads=4): _OcrInit=self.dll.OcrInit diff --git a/LunaTranslator/files/defaultconfig/static_data.json b/LunaTranslator/files/defaultconfig/static_data.json index 0254d2df..c058c7d9 100644 --- a/LunaTranslator/files/defaultconfig/static_data.json +++ b/LunaTranslator/files/defaultconfig/static_data.json @@ -282,7 +282,7 @@ "64":[ "./files/plugins/DLL64/winsharedutils64.dll", "./files/plugins/DLL64/winrtutils64.dll", - "./files/plugins/DLL64/ocr64.dll", + "./files/plugins/DLL64/LunaOCR64.dll", "./files/plugins/DLL64/libmecab.dll", "./files/plugins/DLL64/libcurl-x64.dll", "./files/plugins/DLL64/LunaHost64.dll" @@ -290,7 +290,7 @@ "32":[ "./files/plugins/DLL32/winsharedutils32.dll", "./files/plugins/DLL32/winrtutils32.dll", - "./files/plugins/DLL32/ocr32.dll", + "./files/plugins/DLL32/LunaOCR32.dll", "./files/plugins/DLL32/libmecab.dll", "./files/plugins/DLL32/libcurl.dll", "./files/plugins/DLL32/LunaHost32.dll" diff --git a/LunaTranslator/pack.py b/LunaTranslator/pack.py index 1b3e96b6..7741b83a 100644 --- a/LunaTranslator/pack.py +++ b/LunaTranslator/pack.py @@ -5,14 +5,14 @@ x86=int(sys.argv[1]) if x86: nuitkadist=r'..\build\x86\LunaTranslator_main.dist' targetdir=r'..\build\LunaTranslator_x86' - launch=r'..\plugins\exec\builds\_x86' + launch=r'..\plugins\builds\_x86' downlevel=f'C:\Windows\SysWOW64\downlevel' target='LunaTranslator_x86.zip' baddll='DLL64' else: baddll='DLL32' target='LunaTranslator.zip' - launch=r'..\plugins\exec\builds\_x64' + launch=r'..\plugins\builds\_x64' nuitkadist=r'..\build\x64\LunaTranslator_main.dist' targetdir=r'..\build\LunaTranslator' downlevel=f'C:\Windows\system32\downlevel' @@ -30,7 +30,8 @@ def get_import_table(file_path): if os.path.exists(targetdir): shutil.rmtree(targetdir) shutil.copytree(nuitkadist,targetdir_in) -shutil.copytree(launch,targetdir,dirs_exist_ok=True) +for f in ['LunaTranslator_admin.exe','LunaTranslator.exe']: + shutil.copy(os.path.join(launch,f),targetdir) shutil.copytree(r'.\files',rf'{targetdir}\files') shutil.copy(r'..\LICENSE',targetdir) diff --git a/plugins/CMakeLists.txt b/plugins/CMakeLists.txt new file mode 100644 index 00000000..9ce41b72 --- /dev/null +++ b/plugins/CMakeLists.txt @@ -0,0 +1,31 @@ +cmake_minimum_required(VERSION 3.16) + +project(LunaPlugins) + +set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") +set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake) + +add_compile_options( + /std:c++17 + /MP + /wd4018 + /DUNICODE + /D_UNICODE +) + +if(${CMAKE_SIZEOF_VOID_P} EQUAL 8) + set(CMAKE_FINAL_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/builds/${CMAKE_BUILD_TYPE}_x64) +else() + set(CMAKE_FINAL_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/builds/${CMAKE_BUILD_TYPE}_x86) +endif() +set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY $<1:${CMAKE_FINAL_OUTPUT_DIRECTORY}>) +set(CMAKE_LIBRARY_OUTPUT_DIRECTORY $<1:${CMAKE_FINAL_OUTPUT_DIRECTORY}>) +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY $<1:${CMAKE_FINAL_OUTPUT_DIRECTORY}>) + +include(libs/libs.cmake) + +add_subdirectory(exec) +add_subdirectory(shareddllproxy) +add_subdirectory(winrtutils) +add_subdirectory(winsharedutils) + \ No newline at end of file diff --git a/plugins/exec/CMakeLists.txt b/plugins/exec/CMakeLists.txt index 748d0c1a..02857834 100644 --- a/plugins/exec/CMakeLists.txt +++ b/plugins/exec/CMakeLists.txt @@ -1,26 +1,6 @@ -cmake_minimum_required(VERSION 3.16) project(LUNA) -set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") -set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake) - -add_compile_options( - /std:c++17 - /MP - /wd4018 - /DUNICODE - /D_UNICODE -) - -if(${CMAKE_SIZEOF_VOID_P} EQUAL 8) - set(CMAKE_FINAL_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/builds/${CMAKE_BUILD_TYPE}_x64) -else() - set(CMAKE_FINAL_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/builds/${CMAKE_BUILD_TYPE}_x86) -endif() -set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY $<1:${CMAKE_FINAL_OUTPUT_DIRECTORY}>) -set(CMAKE_LIBRARY_OUTPUT_DIRECTORY $<1:${CMAKE_FINAL_OUTPUT_DIRECTORY}>) -set(CMAKE_RUNTIME_OUTPUT_DIRECTORY $<1:${CMAKE_FINAL_OUTPUT_DIRECTORY}>) add_executable(LunaTranslator luna.cpp luna.rc) #target_link_options(LunaTranslator PRIVATE /MANIFESTUAC:level="asInvoker") diff --git a/plugins/exec/v141_xp_cmake.bat b/plugins/exec/v141_xp_cmake.bat deleted file mode 100644 index 18ed9b01..00000000 --- a/plugins/exec/v141_xp_cmake.bat +++ /dev/null @@ -1,2 +0,0 @@ -cmake ./CMakeLists.txt -G "Visual Studio 15 2017" -A win32 -T v141_xp -B ./build -cmake --build ./build --config Release --target ALL_BUILD -j 14 diff --git a/plugins/shareddllproxy/Detours-4.0.1/include/detours.h b/plugins/libs/Detours-4.0.1/include/detours.h similarity index 100% rename from plugins/shareddllproxy/Detours-4.0.1/include/detours.h rename to plugins/libs/Detours-4.0.1/include/detours.h diff --git a/plugins/shareddllproxy/Detours-4.0.1/include/detver.h b/plugins/libs/Detours-4.0.1/include/detver.h similarity index 100% rename from plugins/shareddllproxy/Detours-4.0.1/include/detver.h rename to plugins/libs/Detours-4.0.1/include/detver.h diff --git a/plugins/shareddllproxy/Detours-4.0.1/include/syelog.h b/plugins/libs/Detours-4.0.1/include/syelog.h similarity index 100% rename from plugins/shareddllproxy/Detours-4.0.1/include/syelog.h rename to plugins/libs/Detours-4.0.1/include/syelog.h diff --git a/plugins/shareddllproxy/Detours-4.0.1/lib.X64/detours.lib b/plugins/libs/Detours-4.0.1/lib.X64/detours.lib similarity index 100% rename from plugins/shareddllproxy/Detours-4.0.1/lib.X64/detours.lib rename to plugins/libs/Detours-4.0.1/lib.X64/detours.lib diff --git a/plugins/shareddllproxy/Detours-4.0.1/lib.X64/syelog.lib b/plugins/libs/Detours-4.0.1/lib.X64/syelog.lib similarity index 100% rename from plugins/shareddllproxy/Detours-4.0.1/lib.X64/syelog.lib rename to plugins/libs/Detours-4.0.1/lib.X64/syelog.lib diff --git a/plugins/shareddllproxy/Detours-4.0.1/lib.X86/detours.lib b/plugins/libs/Detours-4.0.1/lib.X86/detours.lib similarity index 100% rename from plugins/shareddllproxy/Detours-4.0.1/lib.X86/detours.lib rename to plugins/libs/Detours-4.0.1/lib.X86/detours.lib diff --git a/plugins/shareddllproxy/Detours-4.0.1/lib.X86/syelog.lib b/plugins/libs/Detours-4.0.1/lib.X86/syelog.lib similarity index 100% rename from plugins/shareddllproxy/Detours-4.0.1/lib.X86/syelog.lib rename to plugins/libs/Detours-4.0.1/lib.X86/syelog.lib diff --git a/plugins/libs/VC-LTL helper for cmake.cmake b/plugins/libs/VC-LTL helper for cmake.cmake new file mode 100644 index 00000000..e5eac93b --- /dev/null +++ b/plugins/libs/VC-LTL helper for cmake.cmake @@ -0,0 +1,88 @@ +cmake_minimum_required(VERSION 3.5.2) + +# +# VC-LTL自动化加载配置,建议你将此文件单独复制到你的工程再使用,该文件能自动识别当前环境是否存在VC-LTL,并且自动应用。 +# +# 使用方法: +# 1. 在“CMakeLists.txt” 添加 “include("VC-LTL helper for cmake.cmake")”。 +# +# VC-LTL默认搜索顺序 +# 1. “VC-LTL helper for cmake.cmake”所在根目录,即 ${CMAKE_CURRENT_LIST_DIR} +# 2. 当前CMake根目录,即 ${CMAKE_CURRENT_SOURCE_DIR}/VC-LTL +# 3. 当前项目根目录,即 ${PROJECT_SOURCE_DIR}/VC-LTL +# 4. 当前CMake父目录,即 ${CMAKE_CURRENT_SOURCE_DIR}/../VC-LTL +# 5. 当前项目根目录,即 ${PROJECT_SOURCE_DIR}/../VC-LTL +# 6. 注册表HKEY_CURRENT_USER\Code\VC-LTL@Root +# +# 把VC-LTL放在其中一个位置即可,VC-LTL就能被自动引用。 +# +# 如果你对默认搜索顺序不满,你可以修改此文件。你也可以直接指定${VC_LTL_Root}宏更加任性的去加载VC-LTL。 +# + + + + +#####################################################################VC-LTL设置##################################################################### + +#控制TargetPlatform版本,目前可用版本为5.1.2600.0 6.0.6000.0(默认) 6.2.9200.0 10.0.10240.0 10.0.19041.0 +#set(WindowsTargetPlatformMinVersion "10.0.10240.0") + +#启用干净的导入表,消除 ucrt apiset(如:api-ms-win-crt-time-l1-1-0.dll),满足强迫症患者。 +#set(CleanImport "true") + +#################################################################################################################################################### + +if(NOT VC_LTL_Root) + if(EXISTS ${CMAKE_CURRENT_LIST_DIR}/_msvcrt.h) + set(VC_LTL_Root ${CMAKE_CURRENT_LIST_DIR}) + endif() +endif() + +if(NOT VC_LTL_Root) + if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/VC-LTL/_msvcrt.h) + set(VC_LTL_Root ${CMAKE_CURRENT_SOURCE_DIR}/VC-LTL) + endif() +endif() + +if(NOT VC_LTL_Root) + if(EXISTS ${PROJECT_SOURCE_DIR}/VC-LTL/_msvcrt.h) + set(VC_LTL_Root ${PROJECT_SOURCE_DIR}/VC-LTL) + endif() +endif() + +if(NOT VC_LTL_Root) + if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/../VC-LTL/_msvcrt.h) + set(VC_LTL_Root ${CMAKE_CURRENT_SOURCE_DIR}/../VC-LTL) + endif() +endif() + +if(NOT VC_LTL_Root) + if(EXISTS ${PROJECT_SOURCE_DIR}/../VC-LTL/_msvcrt.h) + set(VC_LTL_Root ${PROJECT_SOURCE_DIR}/../VC-LTL) + endif() +endif() + +if(NOT VC_LTL_Root) + EXECUTE_PROCESS(COMMAND reg query "HKEY_CURRENT_USER\\Code\\VC-LTL" -v "Root" + OUTPUT_VARIABLE FOUND_FILE + ERROR_VARIABLE ERROR_INFO + ) + + string(REGEX MATCH "[a-zA-Z]:\\\\.+\\\\" + FOUND_LTL + ${FOUND_FILE}) + if (NOT ${FOUND_LTL} STREQUAL "") + set(VC_LTL_Root ${FOUND_LTL}) + endif() + + if(NOT DEFINED VC_LTL_Root) + string(REGEX MATCH "\\\\\\\\.+\\\\" FOUND_LTL ${FOUND_FILE}) + if (NOT ${FOUND_LTL} STREQUAL "") + set(VC_LTL_Root ${FOUND_LTL}) + endif() + endif() +endif() + +if(VC_LTL_Root) + include("${VC_LTL_Root}\\config\\config.cmake") +endif() diff --git a/plugins/libs/libs.cmake b/plugins/libs/libs.cmake new file mode 100644 index 00000000..10c2e950 --- /dev/null +++ b/plugins/libs/libs.cmake @@ -0,0 +1,14 @@ +if(${CMAKE_SIZEOF_VOID_P} EQUAL 8) + set(Detours ${CMAKE_CURRENT_LIST_DIR}/Detours-4.0.1/lib.X64/detours.lib) +else() + set(Detours ${CMAKE_CURRENT_LIST_DIR}/Detours-4.0.1/lib.X86/detours.lib) +endif() + +include_directories(${CMAKE_CURRENT_LIST_DIR}) +include_directories(${CMAKE_CURRENT_LIST_DIR}/Detours-4.0.1/include) + + +if(${CMAKE_SIZEOF_VOID_P} EQUAL 4) + set(LTLPlatform "Win32") +endif() +include("${CMAKE_CURRENT_LIST_DIR}/VC-LTL helper for cmake.cmake") \ No newline at end of file diff --git a/plugins/shareddllproxy/CMakeLists.txt b/plugins/shareddllproxy/CMakeLists.txt index f0138270..81704b90 100644 --- a/plugins/shareddllproxy/CMakeLists.txt +++ b/plugins/shareddllproxy/CMakeLists.txt @@ -1,38 +1,16 @@ -cmake_minimum_required(VERSION 3.16) project(shareddllproxy) - -set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") -set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake) - -add_compile_options( - /std:c++17 - /MP - /wd4018 - /DUNICODE - /D_UNICODE -) - -if(${CMAKE_SIZEOF_VOID_P} EQUAL 8) - set(CMAKE_FINAL_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/builds/${CMAKE_BUILD_TYPE}_x64) -else() - set(CMAKE_FINAL_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/builds/${CMAKE_BUILD_TYPE}_x86) -endif() -set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY $<1:${CMAKE_FINAL_OUTPUT_DIRECTORY}>) -set(CMAKE_LIBRARY_OUTPUT_DIRECTORY $<1:${CMAKE_FINAL_OUTPUT_DIRECTORY}>) -set(CMAKE_RUNTIME_OUTPUT_DIRECTORY $<1:${CMAKE_FINAL_OUTPUT_DIRECTORY}>) -include_directories(Detours-4.0.1/include) add_executable(shareddllproxy shareddllproxy.cpp dllinject.cpp ntleas.cpp) if(${CMAKE_SIZEOF_VOID_P} EQUAL 8) add_library(x64lib magpie.cpp lossless.cpp) - target_link_libraries(shareddllproxy x64lib ${CMAKE_SOURCE_DIR}/Detours-4.0.1/lib.X64/detours.lib) + target_link_libraries(shareddllproxy x64lib ${Detours}) set_target_properties(shareddllproxy PROPERTIES OUTPUT_NAME "shareddllproxy64") else() add_subdirectory(voiceroid2) add_library(x86lib dreye.cpp jbj7.cpp kingsoft.cpp le.cpp neospeech.cpp LR.cpp) - target_link_libraries(shareddllproxy x86lib voiceroid2 ${CMAKE_SOURCE_DIR}/Detours-4.0.1/lib.X86/detours.lib) + target_link_libraries(shareddllproxy x86lib voiceroid2 ${Detours}) set_target_properties(shareddllproxy PROPERTIES OUTPUT_NAME "shareddllproxy32") endif() diff --git a/plugins/shareddllproxy/v141_xp_cmake.bat b/plugins/shareddllproxy/v141_xp_cmake.bat deleted file mode 100644 index 148dda86..00000000 --- a/plugins/shareddllproxy/v141_xp_cmake.bat +++ /dev/null @@ -1,2 +0,0 @@ -cmake ./CMakeLists.txt -G "Visual Studio 15 2017" -A win32 -T v141_xp -B ./build/_xp -cmake --build ./build/_xp --config Release --target ALL_BUILD -j 14 diff --git a/plugins/winrtutils/CMakeLists.txt b/plugins/winrtutils/CMakeLists.txt index 2d5269ff..7cb89a25 100644 --- a/plugins/winrtutils/CMakeLists.txt +++ b/plugins/winrtutils/CMakeLists.txt @@ -1,26 +1,6 @@ -cmake_minimum_required(VERSION 3.16) project(winrtutils) -set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") -set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake) - -add_compile_options( - /std:c++17 - /MP - /wd4018 - /DUNICODE - /D_UNICODE -) - -if(${CMAKE_SIZEOF_VOID_P} EQUAL 8) - set(CMAKE_FINAL_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/builds/${CMAKE_BUILD_TYPE}_x64) -else() - set(CMAKE_FINAL_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/builds/${CMAKE_BUILD_TYPE}_x86) -endif() -set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY $<1:${CMAKE_FINAL_OUTPUT_DIRECTORY}>) -set(CMAKE_LIBRARY_OUTPUT_DIRECTORY $<1:${CMAKE_FINAL_OUTPUT_DIRECTORY}>) -set(CMAKE_RUNTIME_OUTPUT_DIRECTORY $<1:${CMAKE_FINAL_OUTPUT_DIRECTORY}>) add_library(winrtutils MODULE winrtsnapshot.cpp cinterface.cpp dllmain.cpp pch.cpp winrtocr.cpp ) diff --git a/plugins/winsharedutils/CMakeLists.txt b/plugins/winsharedutils/CMakeLists.txt index 20dc706d..a132fb2d 100644 --- a/plugins/winsharedutils/CMakeLists.txt +++ b/plugins/winsharedutils/CMakeLists.txt @@ -1,26 +1,6 @@ -cmake_minimum_required(VERSION 3.16) project(winsharedutils) -set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") -set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake) - -add_compile_options( - /std:c++17 - /MP - /wd4018 - /DUNICODE - /D_UNICODE -) - -if(${CMAKE_SIZEOF_VOID_P} EQUAL 8) - set(CMAKE_FINAL_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/builds/${CMAKE_BUILD_TYPE}_x64) -else() - set(CMAKE_FINAL_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/builds/${CMAKE_BUILD_TYPE}_x86) -endif() -set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY $<1:${CMAKE_FINAL_OUTPUT_DIRECTORY}>) -set(CMAKE_LIBRARY_OUTPUT_DIRECTORY $<1:${CMAKE_FINAL_OUTPUT_DIRECTORY}>) -set(CMAKE_RUNTIME_OUTPUT_DIRECTORY $<1:${CMAKE_FINAL_OUTPUT_DIRECTORY}>) add_library(winsharedutils MODULE otsu.cpp cinterface.cpp clipboard.cpp lnk.cpp dllmain.cpp levenshtein.cpp muteprocess.cpp sapi_dll.cpp simplemecab.cpp SimpleBrowser.cpp MWebBrowser.cpp icon.cpp) diff --git a/plugins/winsharedutils/v141_xp_cmake.bat b/plugins/winsharedutils/v141_xp_cmake.bat deleted file mode 100644 index 148dda86..00000000 --- a/plugins/winsharedutils/v141_xp_cmake.bat +++ /dev/null @@ -1,2 +0,0 @@ -cmake ./CMakeLists.txt -G "Visual Studio 15 2017" -A win32 -T v141_xp -B ./build/_xp -cmake --build ./build/_xp --config Release --target ALL_BUILD -j 14