remove unused code from textthread and related files

This commit is contained in:
Akash Mozumdar 2018-06-10 04:53:14 -04:00
parent bb0133bc58
commit c80f36efff
5 changed files with 52 additions and 111 deletions

View File

@ -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);

View File

@ -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;i<MAX_REGISTER;i++)
if (record[i].pid_register==pid) break;
if (i<MAX_REGISTER)
{
record[i].engine_register|=type;
}
}*/
ProcessRecord *HookManager::GetProcessRecord(DWORD pid)
{

View File

@ -49,7 +49,6 @@ public:
ProcessRecord *GetProcessRecord(DWORD pid);
//void LockHookman();
//void UnlockHookman();
void ResetRepeatStatus();
void ClearCurrent();
void SelectCurrent(DWORD num);
void SetCurrent(TextThread *it);

View File

@ -220,24 +220,6 @@ void TextThread::RemoveSingleRepeatAuto(const BYTE *con, int &len)
}
}
void TextThread::ResetRepeatStatus()
{
last=0;
repeat_single=0;
repeat_single_current=0;
repeat_single_count=0;
repeat_detect_count=0;
RepeatCountNode *t = head->next,
*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;

View File

@ -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;