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){
if(hasstoped)return true;
std::lock_guard _(settextmutex);
on_text_recv_checkissaved(thread);
if(!plugins->dispatch(thread,output))return false;

View File

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

View File

@ -195,13 +195,14 @@ namespace
namespace Host
{
std::mutex syncmutex;
void Start(ProcessEventHandler Connect, ProcessEventHandler Disconnect, ThreadEventHandler Create, ThreadEventHandler Destroy, TextThread::OutputCallback Output,bool createconsole)
{
OnConnect = Connect;
OnDisconnect = Disconnect;
OnCreate = [Create](TextThread& thread) { Create(thread); thread.Start(); };
OnDestroy = [Destroy](TextThread& thread) { thread.Stop(); Destroy(thread); };
TextThread::Output = Output;
OnConnect = [=](auto &&...args){std::lock_guard _(syncmutex);Connect(args...);};
OnDisconnect = [=](auto &&...args){std::lock_guard _(syncmutex);Disconnect(args...);};
OnCreate = [=](TextThread& thread) {std::lock_guard _(syncmutex); Create(thread); thread.Start(); };
OnDestroy = [=](TextThread& thread) {std::lock_guard _(syncmutex); thread.Stop(); Destroy(thread); };
TextThread::Output = [=](auto &&...args){std::lock_guard _(syncmutex);return Output(args...);};
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){
Start(Connect,Disconnect,Create,Destroy,Output,false);
OnConsole=console;
HookInsert=hookinsert;
embedcallback=embed;
OnConsole=[=](auto &&...args){std::lock_guard _(syncmutex);console(args...);};
HookInsert=[=](auto &&...args){std::lock_guard _(syncmutex);hookinsert(args...);};
embedcallback=[=](auto &&...args){std::lock_guard _(syncmutex);embed(args...);};
Host::AddConsoleOutput(ProjectHomePage);
}
constexpr auto PROCESS_INJECT_ACCESS=(