From c80f36efff8293e5b9a2f54a72e8e5d28ad20248 Mon Sep 17 00:00:00 2001 From: Akash Mozumdar Date: Sun, 10 Jun 2018 04:53:14 -0400 Subject: [PATCH] remove unused code from textthread and related files --- gui/window.cpp | 107 ++++++++++++++++---------------- vnr/texthook/host/hookman.cc | 26 -------- vnr/texthook/host/hookman.h | 1 - vnr/texthook/host/textthread.cc | 18 ------ vnr/texthook/host/textthread.h | 11 ---- 5 files changed, 52 insertions(+), 111 deletions(-) diff --git a/gui/window.cpp b/gui/window.cpp index 5b9c09f..a3ed7d9 100644 --- a/gui/window.cpp +++ b/gui/window.cpp @@ -128,10 +128,6 @@ BOOL CALLBACK OptionDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) GetWindowText(GetDlgItem(hDlg, IDC_EDIT4), str, 0x80); DWORD sd = std::stoul(str); insert_delay = sd > 200 ? sd : 200; - if (IsDlgButtonChecked(hDlg, IDC_CHECK6)) - { - man->ResetRepeatStatus(); - } auto_inject = IsDlgButtonChecked(hDlg, IDC_CHECK1); auto_insert = IsDlgButtonChecked(hDlg, IDC_CHECK2); clipboard_flag = IsDlgButtonChecked(hDlg, IDC_CHECK3); @@ -376,56 +372,57 @@ void ClickButton(HWND hWnd, HWND h) } } -DWORD ThreadFilter(TextThread* thread, BYTE* out, DWORD len, DWORD new_line, PVOID data, bool space) -{ - DWORD status = thread->Status(); - if (global_filter && !new_line && thread->Number() != 0) - { - if (status & USING_UNICODE) - { - DWORD i, j; - len /= 2; - LPWSTR str = (LPWSTR)out; - for (i = 0, j = 0; i < len; i++) - { - WCHAR c = str[i]; - if (!uni_filter->Find(c)) - str[j++] = c; - } - memset(str + j, 0, (len - j) * 2); - len = j * 2; - } - else - { - DWORD i, j; - for (i = 0, j = 0; i < len; i++) - { - WORD c = out[i]; - if (!IsDBCSLeadByte(c & 0xFF)) - { - if (!mb_filter->Find(c)) - out[j++] = c & 0xFF; - } - else if (i + 1 < len) - { - - c = out[i + 1]; - c <<= 8; - c |= out[i]; - if (!mb_filter->Find(c)) - { - out[j++] = c & 0xFF; - out[j++] = c >> 8; - } - i++; - } - } - memset(out + j, 0, len - j); - len = j; - } - } - return len; -} +// Artikash 6/10/2018: Removed because unused. Left commented to make cleaning up gui code easier later. +//DWORD ThreadFilter(TextThread* thread, BYTE* out, DWORD len, DWORD new_line, PVOID data, bool space) +//{ +// DWORD status = thread->Status(); +// if (global_filter && !new_line && thread->Number() != 0) +// { +// if (status & USING_UNICODE) +// { +// DWORD i, j; +// len /= 2; +// LPWSTR str = (LPWSTR)out; +// for (i = 0, j = 0; i < len; i++) +// { +// WCHAR c = str[i]; +// if (!uni_filter->Find(c)) +// str[j++] = c; +// } +// memset(str + j, 0, (len - j) * 2); +// len = j * 2; +// } +// else +// { +// DWORD i, j; +// for (i = 0, j = 0; i < len; i++) +// { +// WORD c = out[i]; +// if (!IsDBCSLeadByte(c & 0xFF)) +// { +// if (!mb_filter->Find(c)) +// out[j++] = c & 0xFF; +// } +// else if (i + 1 < len) +// { +// +// c = out[i + 1]; +// c <<= 8; +// c |= out[i]; +// if (!mb_filter->Find(c)) +// { +// out[j++] = c & 0xFF; +// out[j++] = c >> 8; +// } +// i++; +// } +// } +// memset(out + j, 0, len - j); +// len = j; +// } +// } +// return len; +//} DWORD ThreadOutput(TextThread* thread, BYTE* out, DWORD len, DWORD new_line, PVOID data, bool space) { @@ -594,7 +591,7 @@ bool IsUnicodeHook(const ProcessRecord& pr, DWORD hook); DWORD ThreadCreate(TextThread* thread) { thread->RegisterOutputCallBack(ThreadOutput, 0); - thread->RegisterFilterCallBack(ThreadFilter, 0); + //thread->RegisterFilterCallBack(ThreadFilter, 0); AddToCombo(*thread, false); const auto& tp = thread->GetThreadParameter(); auto pr = man->GetProcessRecord(tp->pid); diff --git a/vnr/texthook/host/hookman.cc b/vnr/texthook/host/hookman.cc index bf25bdb..36ce260 100644 --- a/vnr/texthook/host/hookman.cc +++ b/vnr/texthook/host/hookman.cc @@ -340,32 +340,6 @@ void HookManager::ClearCurrent() //LeaveCriticalSection(&hmcs); //ConsoleOutput("vnrhost:ClearCurrent: unlock"); } -void HookManager::ResetRepeatStatus() -{ - HM_LOCK; - //ConsoleOutput("vnrhost:ResetRepeatStatus: lock"); - //EnterCriticalSection(&hmcs); - for (auto i : threadTable) - { - i.second->ResetRepeatStatus(); - } - - //LeaveCriticalSection(&hmcs); - //ConsoleOutput("vnrhost:ResetRepeatStatus: unlock"); -} -//void HookManager::LockHookman(){ EnterCriticalSection(&hmcs); } -//void HookManager::UnlockHookman(){ LeaveCriticalSection(&hmcs); } - -/*void HookManager::SetProcessEngineType(DWORD pid, DWORD type) -{ - int i; - for (i=0;inext, - *tt; - while (t) { - tt = t; - t = tt->next; - delete tt; - } - //head=new RepeatCountNode; - head->count = head->repeat = 0; - status &= ~REPEAT_NUMBER_DECIDED; -} void TextThread::AddLineBreak() { if (sentence_length == 0) return; diff --git a/vnr/texthook/host/textthread.h b/vnr/texthook/host/textthread.h index 9b6a786..0998b5a 100644 --- a/vnr/texthook/host/textthread.h +++ b/vnr/texthook/host/textthread.h @@ -50,7 +50,6 @@ public: void Reset(); void AddText(const BYTE *con,int len, bool new_line, bool space); // jichi 10/27/2013: add const; remove console; add space void RemoveSingleRepeatAuto(const BYTE *con, int &len); // jichi 10/27/2013: add const - void ResetRepeatStatus(); void AddLineBreak(); void DispatchLastSentence(); @@ -72,16 +71,6 @@ public: return (ThreadOutputFilterCallback)_InterlockedExchange((long*)&output,(long)cb); } - ThreadOutputFilterCallback RegisterFilterCallBack(ThreadOutputFilterCallback cb, PVOID data) - { - app_data = data; - return (ThreadOutputFilterCallback)_InterlockedExchange((long*)&filter,(long)cb); - } - - void SetRepeatFlag() { status |= CYCLIC_REPEAT; } - void ClearNewLineFlag() { status &= ~BUFF_NEWLINE; } - void ClearRepeatFlag() { status &= ~CYCLIC_REPEAT; } - private: ThreadParameter tp;