1
This commit is contained in:
恍兮惚兮 2024-02-08 16:45:23 +08:00
parent ebe0048bb2
commit fea96595c5
10 changed files with 20 additions and 10 deletions

View File

@ -25,9 +25,10 @@ else()
endif()
set(CMAKE_FINAL_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/builds/${CMAKE_BUILD_TYPE}_x${bitappendix})
set(binary_out_putpath ${CMAKE_SOURCE_DIR}/builds/output)
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}>)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY $<1:${binary_out_putpath}>)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY $<1:${binary_out_putpath}>)
include_directories(.)
include(libs/libs.cmake)

View File

@ -53,3 +53,4 @@
#define MenuRemoveHook L"RemoveHook"
#define MenuDetachProcess L"DetachProcess"
#define DefaultFont L"Arial"
#define InVaildPlugin L"InVaild Plugin"

View File

@ -1,5 +1,6 @@
add_executable(LunaHost WIN32 controls.cpp main.cpp processlistwindow.cpp LunaHost.cpp window.cpp luna.rc pluginmanager.cpp pluginexample.cpp)
add_executable(LunaHost WIN32 controls.cpp main.cpp processlistwindow.cpp LunaHost.cpp window.cpp luna.rc pluginmanager.cpp Plugin/pluginexample.cpp)
target_precompile_headers(LunaHost REUSE_FROM pch)
set_target_properties(LunaHost PROPERTIES OUTPUT_NAME "LunaHost${bitappendix}")
target_link_libraries(LunaHost pch host ${YY_Thunks_for_WinXP})
add_subdirectory(Plugin)

View File

@ -41,7 +41,7 @@ std::optional<std::wstring>SelectFile(HWND hwnd){
ZeroMemory(&ofn, sizeof(ofn));
ofn.lStructSize = sizeof(ofn);
ofn.hwndOwner = hwnd;
ofn.lpstrFilter = L"Plugin Files (.dll)\0*.dll\0";
ofn.lpstrFilter = L"Plugin Files\0*.dll;*.xdll\0";
ofn.lpstrFile = szFileName;
ofn.nMaxFile = sizeof(szFileName);
ofn.Flags = OFN_EXPLORER | OFN_FILEMUSTEXIST | OFN_HIDEREADONLY;

View File

@ -3,7 +3,7 @@
#include"processlistwindow.h"
#include"textthread.h"
#include"pluginmanager.h"
#include"plugin.h"
#include"Plugin/plugindef.h"
class LunaHost:public mainwindow{
int64_t currentselect=0;

View File

@ -0,0 +1,4 @@
add_library(ToClipboard MODULE pluginexample.cpp)
target_precompile_headers(ToClipboard REUSE_FROM pch)
set_target_properties(ToClipboard PROPERTIES LIBRARY_OUTPUT_DIRECTORY "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/plugin${bitappendix}")

View File

@ -1,4 +1,4 @@
#include"plugin.h"
#include"plugindef.h"
bool ProcessSentence(std::wstring& sentence, SentenceInfo sentenceInfo);

View File

@ -1,7 +1,8 @@
#include"pluginmanager.h"
#include<filesystem>
#include"plugin.h"
#include"Plugin/plugindef.h"
#include<fstream>
#include"Lang/Lang.h"
std::vector<char> readfile(const wchar_t* fname) {
FILE* f;
_wfopen_s(&f, fname, L"rb");
@ -60,13 +61,14 @@ bool pluginmanager::dispatch(const InfoForExtension* sentenceInfo, std::wstring&
HeapFree(GetProcessHeap(), 0, sentenceBuffer);
return !sentence.empty();
}
std::optional<std::pair<std::wstring,LPVOID>> pluginmanager::checkisvalidplugin(const std::wstring& pl){
auto path=std::filesystem::path(pl);
if (!std::filesystem::exists(path))return{};
if (!std::filesystem::is_regular_file(path))return{};
auto appendix=path.extension().wstring();
stolower(appendix);
if(appendix!=std::wstring(L".dll"))return {};
if((appendix!=std::wstring(L".dll"))&&(appendix!=std::wstring(L".xdll")))return {};
auto dll=LoadLibraryW(pl.c_str());
if(!dll)return {};
auto OnNewSentence=GetProcAddress(dll,"OnNewSentence");
@ -94,6 +96,7 @@ bool pluginmanager::addplugin(const std::wstring& p){
return true;
}
else{
MessageBoxW(0,InVaildPlugin,L"Error",0);
return false;
}
}

View File

@ -1,4 +1,4 @@
#include"plugin.h"
#include"Plugin/plugindef.h"
#include"textthread.h"
class pluginmanager{
std::vector<std::pair<std::wstring,LPVOID>>OnNewSentenceS;