This commit is contained in:
恍兮惚兮 2024-08-19 05:24:37 +08:00
parent c4127c4e3a
commit 48f521b909
4 changed files with 19 additions and 45 deletions

View File

@ -61,7 +61,7 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR}/version)
include(generate_product_version) include(generate_product_version)
set(VERSION_MAJOR 3) set(VERSION_MAJOR 3)
set(VERSION_MINOR 9) set(VERSION_MINOR 10)
set(VERSION_PATCH 0) set(VERSION_PATCH 0)
set(VERSION_REVISION 0) set(VERSION_REVISION 0)

View File

@ -171,30 +171,6 @@ std::wstring adjustSpacesSTD(const std::wstring &text, HookParam hp)
return text; return text;
} }
} }
std::wstring limitTextWidth(const std::wstring &text, int size)
{
auto lines = strSplit(text, L"\n");
std::for_each(lines.begin(), lines.end(), [=](auto &line)
{
if(line.size()<=size)
return;
std::wstring ret;
for(int i=0;i<line.size();i++){
ret+=line[i];
if((i<line.size()-1) &&( ((1+i)%size)==0)){
ret+=L'\n';
}
}
line=ret; });
std::wstring ret;
for (int i = 0; i < lines.size(); i++)
{
ret += lines[i];
if (i < lines.size() - 1)
ret += L'\n';
}
return ret;
}
bool isPauseKeyPressed() bool isPauseKeyPressed()
{ {
return WinKey::isKeyControlPressed() || WinKey::isKeyShiftPressed() && !WinKey::isKeyReturnPressed(); return WinKey::isKeyControlPressed() || WinKey::isKeyShiftPressed() && !WinKey::isKeyReturnPressed();
@ -299,8 +275,6 @@ bool TextHook::waitfornotify(TextOutput_T *buffer, void *data, size_t *len, Thre
return false; return false;
translatecache.insert(std::make_pair(hash, translate)); translatecache.insert(std::make_pair(hash, translate));
} }
if (embedsharedmem->line_text_length_limit)
translate = limitTextWidth(translate, embedsharedmem->line_text_length_limit);
if (hp.newlineseperator) if (hp.newlineseperator)
strReplace(translate, L"\n", hp.newlineseperator); strReplace(translate, L"\n", hp.newlineseperator);
translate = adjustSpacesSTD(translate, hp); translate = adjustSpacesSTD(translate, hp);

View File

@ -21,10 +21,11 @@ typedef bool (*OutputCallback)(wchar_t *, char *, ThreadParam, const wchar_t *);
typedef void (*ConsoleHandler)(const wchar_t *); typedef void (*ConsoleHandler)(const wchar_t *);
typedef void (*HookInsertHandler)(uint64_t, const wchar_t *); typedef void (*HookInsertHandler)(uint64_t, const wchar_t *);
typedef void (*EmbedCallback)(const wchar_t *, ThreadParam); typedef void (*EmbedCallback)(const wchar_t *, ThreadParam);
#define XXXX char name[HOOK_NAME_SIZE];\ #define XXXX \
wchar_t hookcode[HOOKCODE_LEN];\ char name[HOOK_NAME_SIZE]; \
wcscpy_s(hookcode, HOOKCODE_LEN, thread.hp.hookcode);\ wchar_t hookcode[HOOKCODE_LEN]; \
strcpy_s(name, HOOK_NAME_SIZE, thread.hp.name); wcscpy_s(hookcode, HOOKCODE_LEN, thread.hp.hookcode); \
strcpy_s(name, HOOK_NAME_SIZE, thread.hp.name);
C_LUNA_API void Luna_Start(ProcessEvent Connect, ProcessEvent Disconnect, ThreadEvent Create, ThreadEvent Destroy, OutputCallback Output, ConsoleHandler console, HookInsertHandler hookinsert, EmbedCallback embed) C_LUNA_API void Luna_Start(ProcessEvent Connect, ProcessEvent Disconnect, ThreadEvent Create, ThreadEvent Destroy, OutputCallback Output, ConsoleHandler console, HookInsertHandler hookinsert, EmbedCallback embed)
{ {
Host::StartEx( Host::StartEx(
@ -33,17 +34,16 @@ C_LUNA_API void Luna_Start(ProcessEvent Connect, ProcessEvent Disconnect, Thread
[=](const TextThread &thread) [=](const TextThread &thread)
{ {
XXXX XXXX
Create(hookcode, name, thread.tp); Create(hookcode, name, thread.tp);
}, },
[=](const TextThread &thread) [=](const TextThread &thread)
{ {
XXXX XXXX
Destroy(hookcode, name, thread.tp); Destroy(hookcode, name, thread.tp);
}, },
[=](const TextThread &thread, std::wstring &output) [=](const TextThread &thread, std::wstring &output)
{ {
XXXX XXXX return Output(hookcode, name, thread.tp, output.c_str());
return Output(hookcode, name, thread.tp, output.c_str());
}, },
[=](const std::wstring &output) [=](const std::wstring &output)
{ {
@ -77,7 +77,7 @@ C_LUNA_API void Luna_Settings(int flushDelay, bool filterRepetition, int default
TextThread::filterRepetition = filterRepetition; TextThread::filterRepetition = filterRepetition;
Host::defaultCodepage = defaultCodepage; Host::defaultCodepage = defaultCodepage;
TextThread::maxBufferSize = maxBufferSize; TextThread::maxBufferSize = maxBufferSize;
TextThread::maxHistorySize=maxHistorySize; TextThread::maxHistorySize = maxHistorySize;
} }
C_LUNA_API bool Luna_InsertHookCode(DWORD pid, LPCWSTR hookcode) C_LUNA_API bool Luna_InsertHookCode(DWORD pid, LPCWSTR hookcode)
@ -87,13 +87,15 @@ C_LUNA_API bool Luna_InsertHookCode(DWORD pid, LPCWSTR hookcode)
Host::InsertHook(pid, hp.value()); Host::InsertHook(pid, hp.value());
return hp.has_value(); return hp.has_value();
} }
C_LUNA_API wchar_t* Luna_QueryThreadHistory(ThreadParam tp){ C_LUNA_API wchar_t *Luna_QueryThreadHistory(ThreadParam tp)
auto s=Host::GetThread(tp).storage.Acquire(); {
auto str=(wchar_t*)malloc(sizeof(wchar_t)*(s->size()+1)); auto s = Host::GetThread(tp).storage.Acquire();
wcscpy(str,s->c_str()); auto str = (wchar_t *)malloc(sizeof(wchar_t) * (s->size() + 1));
wcscpy(str, s->c_str());
return str; return str;
} }
C_LUNA_API void Luna_FreePtr(void* ptr){ C_LUNA_API void Luna_FreePtr(void *ptr)
{
free(ptr); free(ptr);
} }
C_LUNA_API void Luna_RemoveHook(DWORD pid, uint64_t addr) C_LUNA_API void Luna_RemoveHook(DWORD pid, uint64_t addr)
@ -104,7 +106,7 @@ struct simplehooks
{ {
wchar_t hookcode[HOOKCODE_LEN]; wchar_t hookcode[HOOKCODE_LEN];
wchar_t *text; wchar_t *text;
simplehooks() : text(0){}; simplehooks() : text(0) {};
}; };
typedef void (*findhookcallback_t)(wchar_t *hookcode, const wchar_t *text); typedef void (*findhookcallback_t)(wchar_t *hookcode, const wchar_t *text);
C_LUNA_API void Luna_FindHooks(DWORD pid, SearchParam sp, findhookcallback_t findhookcallback) C_LUNA_API void Luna_FindHooks(DWORD pid, SearchParam sp, findhookcallback_t findhookcallback)
@ -115,7 +117,7 @@ C_LUNA_API void Luna_FindHooks(DWORD pid, SearchParam sp, findhookcallback_t fin
wcscpy_s(hookcode,HOOKCODE_LEN, hp.hookcode); wcscpy_s(hookcode,HOOKCODE_LEN, hp.hookcode);
findhookcallback(hookcode,text.c_str()); }); findhookcallback(hookcode,text.c_str()); });
} }
C_LUNA_API void Luna_EmbedSettings(DWORD pid, UINT32 waittime, UINT8 fontCharSet, bool fontCharSetEnabled, wchar_t *fontFamily, UINT32 spaceadjustpolicy, UINT32 keeprawtext, bool fastskipignore, UINT32 line_text_length_limit) C_LUNA_API void Luna_EmbedSettings(DWORD pid, UINT32 waittime, UINT8 fontCharSet, bool fontCharSetEnabled, wchar_t *fontFamily, UINT32 spaceadjustpolicy, UINT32 keeprawtext, bool fastskipignore)
{ {
auto sm = Host::GetEmbedSharedMem(pid); auto sm = Host::GetEmbedSharedMem(pid);
if (!sm) if (!sm)
@ -127,7 +129,6 @@ C_LUNA_API void Luna_EmbedSettings(DWORD pid, UINT32 waittime, UINT8 fontCharSet
sm->spaceadjustpolicy = spaceadjustpolicy; sm->spaceadjustpolicy = spaceadjustpolicy;
sm->keeprawtext = keeprawtext; sm->keeprawtext = keeprawtext;
sm->fastskipignore = fastskipignore; sm->fastskipignore = fastskipignore;
sm->line_text_length_limit=line_text_length_limit;
} }
C_LUNA_API bool Luna_checkisusingembed(DWORD pid, uint64_t address, uint64_t ctx1, uint64_t ctx2) C_LUNA_API bool Luna_checkisusingembed(DWORD pid, uint64_t address, uint64_t ctx1, uint64_t ctx2)
{ {

View File

@ -28,7 +28,6 @@ struct EmbedSharedMem
wchar_t fontFamily[100]; wchar_t fontFamily[100];
UINT codepage; UINT codepage;
bool fastskipignore; bool fastskipignore;
UINT32 line_text_length_limit;
}; };
class TextHook class TextHook
{ {