forked from Public-Mirror/Textractor
remove extension code from host
This commit is contained in:
parent
f4980d6eb6
commit
a290c36b52
@ -347,9 +347,10 @@ void ClickButton(HWND hWnd, HWND h)
|
||||
}
|
||||
}
|
||||
|
||||
void ThreadOutput(TextThread* thread, std::wstring output)
|
||||
std::wstring ThreadOutput(TextThread* thread, std::wstring output)
|
||||
{
|
||||
if (thread->Status() & CURRENT_SELECT) texts->AddText(output, false);
|
||||
return output;
|
||||
}
|
||||
|
||||
bool GetHookParam(DWORD pid, DWORD hook_addr, HookParam& hp)
|
||||
|
@ -1,36 +0,0 @@
|
||||
#include "Extensions.h"
|
||||
#include <Windows.h>
|
||||
#include <map>
|
||||
#include <vector>
|
||||
|
||||
std::map<DWORD, ExtensionFunction> extensionFunctions;
|
||||
|
||||
void LoadExtensions()
|
||||
{
|
||||
wchar_t path[MAX_PATH];
|
||||
wchar_t* end = path + GetModuleFileNameW(nullptr, path, MAX_PATH);
|
||||
while (*(--end) != L'\\');
|
||||
*(end + 1) = L'*';
|
||||
*(end + 2) = L'\0';
|
||||
WIN32_FIND_DATAW fileData;
|
||||
HANDLE file = FindFirstFileW(path, &fileData);
|
||||
do
|
||||
{
|
||||
if (!(fileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
|
||||
{
|
||||
if (wcsstr(fileData.cFileName, L"_nexthooker_extension.dll"))
|
||||
{
|
||||
extensionFunctions[wcstoul(fileData.cFileName, nullptr, 10)] = (ExtensionFunction)GetProcAddress(LoadLibraryW(fileData.cFileName), "NewSentence");
|
||||
}
|
||||
}
|
||||
} while (FindNextFileW(file, &fileData) != 0);
|
||||
}
|
||||
|
||||
std::wstring DispatchSentenceToExtensions(std::wstring sentence, DWORD64 info)
|
||||
{
|
||||
for (auto extension : extensionFunctions)
|
||||
{
|
||||
sentence = extension.second(sentence, info);
|
||||
}
|
||||
return sentence;
|
||||
}
|
@ -1,6 +0,0 @@
|
||||
#include <Windows.h>
|
||||
#include <string>
|
||||
|
||||
typedef std::wstring (*ExtensionFunction)(std::wstring, DWORD64);
|
||||
void LoadExtensions();
|
||||
std::wstring DispatchSentenceToExtensions(std::wstring sentence, DWORD64 info);
|
@ -11,13 +11,11 @@ set(vnrhost_src
|
||||
host.h
|
||||
pipe.h
|
||||
textthread.h
|
||||
winmutex.h
|
||||
hookman.cc
|
||||
host.cc
|
||||
pipe.cc
|
||||
textthread.cc
|
||||
${PROJECT_SOURCE_DIR}/winmutex/winmutex.h
|
||||
${PROJECT_SOURCE_DIR}/extensions/Extensions.cpp
|
||||
${PROJECT_SOURCE_DIR}/extensions/Extensions.h
|
||||
)
|
||||
|
||||
add_library(vnrhost SHARED ${vnrhost_src})
|
||||
|
@ -12,7 +12,7 @@
|
||||
#include "vnrhook/include/const.h"
|
||||
#include "vnrhook/include/defs.h"
|
||||
#include "vnrhook/include/types.h"
|
||||
#include "winmutex/winmutex.h"
|
||||
#include "winmutex.h"
|
||||
#include <atlbase.h>
|
||||
|
||||
#define HM_LOCK CriticalSectionLocker hmLocker(hmCs) // Synchronized scope for accessing private data
|
||||
|
@ -7,7 +7,6 @@
|
||||
#include "vnrhook/include/const.h"
|
||||
#include "vnrhook/include/defs.h"
|
||||
#include "vnrhook/include/types.h"
|
||||
#include "extensions/Extensions.h"
|
||||
|
||||
HANDLE preventDuplicationMutex;
|
||||
|
||||
@ -58,7 +57,6 @@ DLLEXPORT bool StartHost()
|
||||
}
|
||||
else
|
||||
{
|
||||
LoadExtensions();
|
||||
::running = true;
|
||||
::man = new HookManager;
|
||||
return true;
|
||||
|
@ -8,8 +8,7 @@
|
||||
#include "host.h"
|
||||
#include "textthread.h"
|
||||
#include "vnrhook/include/const.h"
|
||||
#include "extensions/Extensions.h"
|
||||
#include "winmutex/winmutex.h"
|
||||
#include "winmutex.h"
|
||||
|
||||
extern HookManager* man;
|
||||
extern HWND dummyWindow;
|
||||
@ -54,7 +53,7 @@ void TextThread::AddSentence()
|
||||
sentence = std::wstring(converted, MultiByteToWideChar(932, 0, sentenceBuffer.data(), sentenceBuffer.size(), converted, sentenceBuffer.size()));
|
||||
delete[] converted;
|
||||
}
|
||||
AddSentence(DispatchSentenceToExtensions(sentence, status));
|
||||
AddSentence(sentence);
|
||||
sentenceBuffer.clear();
|
||||
}
|
||||
|
||||
@ -62,7 +61,7 @@ void TextThread::AddSentence(std::wstring sentence)
|
||||
{
|
||||
TT_LOCK;
|
||||
sentence.append(L"\r\n");
|
||||
if (output) output(this, sentence);
|
||||
if (output) sentence = output(this, sentence);
|
||||
storage.append(sentence);
|
||||
}
|
||||
|
||||
|
@ -25,7 +25,7 @@ struct ThreadParameter
|
||||
#define CURRENT_SELECT 0x1000
|
||||
|
||||
class TextThread;
|
||||
typedef void(*ThreadOutputCallback)(TextThread*, std::wstring data);
|
||||
typedef std::wstring(*ThreadOutputCallback)(TextThread*, std::wstring data);
|
||||
|
||||
//extern DWORD split_time,repeat_count,global_filter,cyclic_remove;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user