This commit is contained in:
恍兮惚兮 2024-05-12 00:14:34 +08:00
parent 386df5c300
commit 4b966dd46c
3 changed files with 9 additions and 10 deletions

View File

@ -395,7 +395,6 @@ void LunaHost::updatelisttext(const std::wstring&text,LONG_PTR data){
} }
bool LunaHost::on_text_recv(TextThread& thread, std::wstring& output){ bool LunaHost::on_text_recv(TextThread& thread, std::wstring& output){
if(hasstoped)return true; if(hasstoped)return true;
std::lock_guard _(settextmutex);
on_text_recv_checkissaved(thread); on_text_recv_checkissaved(thread);
if(!plugins->dispatch(thread,output))return false; if(!plugins->dispatch(thread,output))return false;

View File

@ -80,7 +80,6 @@ public:
class LunaHost:public mainwindow{ class LunaHost:public mainwindow{
Pluginwindow* pluginwindow=0; Pluginwindow* pluginwindow=0;
std::set<DWORD>attachedprocess; std::set<DWORD>attachedprocess;
std::mutex settextmutex;
lineedit* g_hEdit_userhook; lineedit* g_hEdit_userhook;
gridlayout* mainlayout; gridlayout* mainlayout;
button* g_hButton_insert; button* g_hButton_insert;

View File

@ -195,13 +195,14 @@ namespace
namespace Host namespace Host
{ {
std::mutex syncmutex;
void Start(ProcessEventHandler Connect, ProcessEventHandler Disconnect, ThreadEventHandler Create, ThreadEventHandler Destroy, TextThread::OutputCallback Output,bool createconsole) void Start(ProcessEventHandler Connect, ProcessEventHandler Disconnect, ThreadEventHandler Create, ThreadEventHandler Destroy, TextThread::OutputCallback Output,bool createconsole)
{ {
OnConnect = Connect; OnConnect = [=](auto &&...args){std::lock_guard _(syncmutex);Connect(args...);};
OnDisconnect = Disconnect; OnDisconnect = [=](auto &&...args){std::lock_guard _(syncmutex);Disconnect(args...);};
OnCreate = [Create](TextThread& thread) { Create(thread); thread.Start(); }; OnCreate = [=](TextThread& thread) {std::lock_guard _(syncmutex); Create(thread); thread.Start(); };
OnDestroy = [Destroy](TextThread& thread) { thread.Stop(); Destroy(thread); }; OnDestroy = [=](TextThread& thread) {std::lock_guard _(syncmutex); thread.Stop(); Destroy(thread); };
TextThread::Output = Output; TextThread::Output = [=](auto &&...args){std::lock_guard _(syncmutex);return Output(args...);};
textThreadsByParams->try_emplace(console, console, HookParam{}, CONSOLE); textThreadsByParams->try_emplace(console, console, HookParam{}, CONSOLE);
@ -216,9 +217,9 @@ namespace Host
void StartEx(ProcessEventHandler Connect, ProcessEventHandler Disconnect, ThreadEventHandler Create, ThreadEventHandler Destroy, TextThread::OutputCallback Output,ConsoleHandler console,HookInsertHandler hookinsert,EmbedCallback embed){ void StartEx(ProcessEventHandler Connect, ProcessEventHandler Disconnect, ThreadEventHandler Create, ThreadEventHandler Destroy, TextThread::OutputCallback Output,ConsoleHandler console,HookInsertHandler hookinsert,EmbedCallback embed){
Start(Connect,Disconnect,Create,Destroy,Output,false); Start(Connect,Disconnect,Create,Destroy,Output,false);
OnConsole=console; OnConsole=[=](auto &&...args){std::lock_guard _(syncmutex);console(args...);};
HookInsert=hookinsert; HookInsert=[=](auto &&...args){std::lock_guard _(syncmutex);hookinsert(args...);};
embedcallback=embed; embedcallback=[=](auto &&...args){std::lock_guard _(syncmutex);embed(args...);};
Host::AddConsoleOutput(ProjectHomePage); Host::AddConsoleOutput(ProjectHomePage);
} }
constexpr auto PROCESS_INJECT_ACCESS=( constexpr auto PROCESS_INJECT_ACCESS=(