Skip to content

Commit

Permalink
small bugfixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Artikash committed Sep 23, 2018
1 parent 524a0f3 commit 3df68a6
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 17 deletions.
4 changes: 2 additions & 2 deletions GUI/host/host.cc
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ namespace
case HOST_NOTIFICATION_TEXT:
{
auto info = *(ConsoleOutputNotif*)buffer;
Host::AddConsoleOutput(ToWString(info.message, CP_UTF8));
Host::AddConsoleOutput(StringToWideString(info.message, CP_UTF8));
}
break;
default:
Expand Down Expand Up @@ -256,7 +256,7 @@ namespace Host
ReadProcessMemory(pr.processHandle, hooks[i].hook_name, buffer.data(), hooks[i].name_length, nullptr);
}
ReleaseMutex(pr.sectionMutex);
return ToWString(buffer.c_str(), CP_UTF8);
return StringToWideString(buffer.c_str(), CP_UTF8);
}

TextThread* GetThread(ThreadParam tp)
Expand Down
6 changes: 3 additions & 3 deletions GUI/host/host.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ namespace Host
void AddConsoleOutput(std::wstring text);
}

inline std::wstring ToWString(const char* text, UINT encoding)
inline std::wstring StringToWideString(const std::string& text, UINT encoding)
{
std::wstring ret(strlen(text), 0);
ret.resize(MultiByteToWideChar(encoding, 0, text, -1, ret.data(), ret.capacity()));
std::wstring ret(text.size(), 0);
ret.resize(MultiByteToWideChar(encoding, 0, text.c_str(), -1, ret.data(), ret.capacity()));
return ret;
}

Expand Down
14 changes: 4 additions & 10 deletions GUI/host/textthread.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,10 @@ void TextThread::Flush()
std::wstring sentence;
{
LOCK(ttMutex);
if (buffer.size() < 400 && (GetTickCount() - timestamp < FlushDelay || buffer.size() == 0)) return;
if (status & USING_UNICODE)
{
sentence = std::wstring((wchar_t*)buffer.data(), buffer.size() / 2);
}
else
{
buffer.push_back(0); // Null terminate
sentence = ToWString(buffer.data(), status & USING_UTF8 ? CP_UTF8 : SHIFT_JIS);
}
if (buffer.size() < 400 && (GetTickCount() - timestamp < FlushDelay || buffer.size() < 2)) return;
sentence = status & USING_UNICODE
? std::wstring((wchar_t*)buffer.data(), buffer.size() / 2)
: StringToWideString(std::string(buffer.data(), buffer.size()), status & USING_UTF8 ? CP_UTF8 : SHIFT_JIS);
buffer.clear();
}
AddSentence(sentence);
Expand Down
4 changes: 2 additions & 2 deletions GUI/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ MainWindow::MainWindow(QWidget *parent) :
QSettings settings("NextHooker.ini", QSettings::IniFormat);
if (settings.contains("Window")) this->setGeometry(settings.value("Window").toRect());
// TODO: add GUI for changing this
if (settings.contains("Flush_Delay")) TextThread::FlushDelay = settings.value("Flush Delay").toUInt();
if (settings.contains("Flush_Delay")) TextThread::FlushDelay = settings.value("Flush_Delay").toUInt();

processCombo = findChild<QComboBox*>("processCombo");
ttCombo = findChild<QComboBox*>("ttCombo");
Expand All @@ -36,7 +36,7 @@ MainWindow::MainWindow(QWidget *parent) :
);

ReloadExtensions();
Host::AddConsoleOutput(L"NextHooker beta v3.2.0 by Artikash\r\nSource code and more information available under GPLv3 at https://github.com/Artikash/NextHooker");
Host::AddConsoleOutput(L"NextHooker beta v3.2.1 by Artikash\r\nSource code and more information available under GPLv3 at https://github.com/Artikash/NextHooker");
}

MainWindow::~MainWindow()
Expand Down

0 comments on commit 3df68a6

Please sign in to comment.