really final fixes for beta release

This commit is contained in:
Akash Mozumdar 2018-07-13 11:47:16 -04:00
parent a05714fdae
commit ef36cb9274
14 changed files with 54 additions and 179 deletions

View File

@ -14,11 +14,15 @@ set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE "${CMAKE_BINARY_DIR}/Release")
set(CMAKE_WARN_ON_ABSOLUTE_INSTALL_DESTINATION ON) set(CMAKE_WARN_ON_ABSOLUTE_INSTALL_DESTINATION ON)
execute_process(COMMAND "cmd" " /C date /T" OUTPUT_VARIABLE FULLDATE)
# set(DATE "07/13/2018")
string(SUBSTRING ${FULLDATE} 0 10 BUILD_DATE)
set(BUILD_DATE ${BUILD_DATE})
set(CPACK_GENERATOR "ZIP") set(CPACK_GENERATOR "ZIP")
set(CPACK_PACKAGE_VERSION_MAJOR 3) set(CPACK_PACKAGE_VERSION_MAJOR 1)
set(CPACK_PACKAGE_VERSION_MINOR 5640) set(CPACK_PACKAGE_VERSION_MINOR 0)
set(CPACK_PACKAGE_VERSION_PATCH 1) set(CPACK_PACKAGE_VERSION_PATCH 0)
set(CPACK_SOURCE_GENERATOR "ZIP") set(CPACK_SOURCE_GENERATOR "ZIP")
set(CPACK_SOURCE_IGNORE_FILES "/CVS/;/\\\\.svn/;/\\\\.bzr/;/\\\\.hg/;/\\\\.git/;\\\\.swp$;\\\\.#;/#" ".*\\\\.user$" "\\\\.gitignore$" "\\\\.gitmodules$" "\\\\.git$") set(CPACK_SOURCE_IGNORE_FILES "/CVS/;/\\\\.svn/;/\\\\.bzr/;/\\\\.hg/;/\\\\.git/;\\\\.swp$;\\\\.#;/#" ".*\\\\.user$" "\\\\.gitignore$" "\\\\.gitmodules$" "\\\\.git$")
include(CPack) include(CPack)

View File

@ -1,10 +1,9 @@
// Generated by ResEdit 1.6.5 // Generated by ResEdit 1.6.6
// Copyright (C) 2006-2015 // Copyright (C) 2006-2015
// http://www.resedit.net // http://www.resedit.net
#include <windows.h> #include <windows.h>
#include <commctrl.h> #include <commctrl.h>
#include <richedit.h>
#include "resource.h" #include "resource.h"
@ -32,27 +31,16 @@ FONT 8, "MS Shell Dlg", 400, 0, 1
LANGUAGE LANG_JAPANESE, SUBLANG_JAPANESE_JAPAN LANGUAGE LANG_JAPANESE, SUBLANG_JAPANESE_JAPAN
IDD_DIALOG4 DIALOGEX 150, 100, 123, 185 IDD_DIALOG4 DIALOGEX 150, 100, 123, 71
STYLE DS_MODALFRAME | DS_SHELLFONT | WS_CAPTION | WS_VISIBLE | WS_POPUP | WS_SYSMENU STYLE DS_MODALFRAME | DS_SHELLFONT | WS_CAPTION | WS_VISIBLE | WS_POPUP | WS_SYSMENU
CAPTION "Option" CAPTION "Option"
FONT 8, "MS Shell Dlg", 400, 0, 1 FONT 8, "MS Shell Dlg", 400, 0, 1
{ {
DEFPUSHBUTTON "OK", IDOK, 8, 164, 50, 14, 0, WS_EX_LEFT LTEXT "More options coming soon?", 0, 18, 25, 88, 9, SS_LEFT, WS_EX_LEFT
PUSHBUTTON "Cancel", IDCANCEL, 65, 164, 50, 14, 0, WS_EX_LEFT DEFPUSHBUTTON "OK", IDOK, 5, 52, 50, 14, 0, WS_EX_LEFT
PUSHBUTTON "Cancel", IDCANCEL, 63, 52, 50, 14, 0, WS_EX_LEFT
EDITTEXT IDC_EDIT1, 60, 7, 55, 14, ES_AUTOHSCROLL, WS_EX_LEFT EDITTEXT IDC_EDIT1, 60, 7, 55, 14, ES_AUTOHSCROLL, WS_EX_LEFT
LTEXT "Split time", IDC_STATIC, 7, 7, 47, 13, SS_LEFT | SS_CENTERIMAGE, WS_EX_LEFT LTEXT "Split time", IDC_STATIC, 7, 7, 47, 13, SS_LEFT | SS_CENTERIMAGE, WS_EX_LEFT
EDITTEXT IDC_EDIT2, 60, 25, 55, 14, ES_AUTOHSCROLL, WS_EX_LEFT
LTEXT "Process delay", IDC_STATIC, 7, 26, 47, 13, SS_LEFT | SS_CENTERIMAGE, WS_EX_LEFT
EDITTEXT IDC_EDIT3, 60, 45, 55, 14, ES_AUTOHSCROLL, WS_EX_LEFT
LTEXT "Inject delay", IDC_STATIC, 7, 45, 47, 13, SS_LEFT | SS_CENTERIMAGE, WS_EX_LEFT
EDITTEXT IDC_EDIT4, 60, 65, 55, 14, ES_AUTOHSCROLL, WS_EX_LEFT
LTEXT "Insert delay", IDC_STATIC, 7, 65, 47, 13, SS_LEFT | SS_CENTERIMAGE, WS_EX_LEFT
AUTOCHECKBOX "Auto attach", IDC_CHECK1, 7, 87, 54, 10, 0, WS_EX_LEFT
AUTOCHECKBOX "Auto insert", IDC_CHECK2, 62, 87, 50, 10, 0, WS_EX_LEFT
AUTOCHECKBOX "Auto copy to clipboard", IDC_CHECK3, 7, 103, 88, 10, 0, WS_EX_LEFT
AUTOCHECKBOX "Auto suppress repetition", IDC_CHECK4, 7, 119, 95, 10, 0, WS_EX_LEFT
AUTOCHECKBOX "Reset character filter", IDC_CHECK6, 7, 149, 81, 8, 0, WS_EX_LEFT
AUTOCHECKBOX "Enable global filter", IDC_CHECK5, 7, 134, 75, 10, 0, WS_EX_LEFT
} }

View File

@ -84,7 +84,7 @@ void ProcessWindow::AttachProcess()
void ProcessWindow::DetachProcess() void ProcessWindow::DetachProcess()
{ {
DWORD pid = GetSelectedPID(); DWORD pid = GetSelectedPID();
if (DetachProcessById(pid) == 0) DetachProcessById(pid);
RefreshThreadWithPID(pid, false); RefreshThreadWithPID(pid, false);
} }

View File

@ -8,15 +8,9 @@
#include "profile/misc.h" #include "profile/misc.h"
extern HookManager* man; // main.cpp extern HookManager* man; // main.cpp
extern LONG auto_inject, auto_insert, inject_delay; // main.cpp
extern LONG insert_delay, process_time; // main.cpp
bool MonitorFlag;
ProfileManager* pfman; ProfileManager* pfman;
DWORD WINAPI MonitorThread(LPVOID lpThreadParameter); ProfileManager::ProfileManager()
ProfileManager::ProfileManager() :
hMonitorThread(IthCreateThread(MonitorThread, 0))
{ {
LoadProfiles(); LoadProfiles();
} }
@ -24,7 +18,6 @@ hMonitorThread(IthCreateThread(MonitorThread, 0))
ProfileManager::~ProfileManager() ProfileManager::~ProfileManager()
{ {
SaveProfiles(); SaveProfiles();
WaitForSingleObject(hMonitorThread.get(), 0);
} }
Profile* ProfileManager::GetProfile(DWORD pid) Profile* ProfileManager::GetProfile(DWORD pid)
@ -91,7 +84,7 @@ void ProfileManager::WriteProfileXml(const std::wstring& path, Profile& pf, pugi
void ProfileManager::LoadProfiles() void ProfileManager::LoadProfiles()
{ {
pugi::xml_document doc; pugi::xml_document doc;
UniqueHandle hFile(IthCreateFile(L"ITH_Profile.xml", GENERIC_READ, FILE_SHARE_READ, OPEN_EXISTING)); UniqueHandle hFile(IthCreateFile(L"NextHooker_Profile.xml", GENERIC_READ, FILE_SHARE_READ, OPEN_EXISTING));
if (hFile.get() == INVALID_HANDLE_VALUE) if (hFile.get() == INVALID_HANDLE_VALUE)
return; return;
DWORD size = GetFileSize(hFile.get(), NULL); DWORD size = GetFileSize(hFile.get(), NULL);
@ -100,7 +93,7 @@ void ProfileManager::LoadProfiles()
auto result = doc.load_buffer(buffer.get(), size); auto result = doc.load_buffer(buffer.get(), size);
if (!result) if (!result)
return; return;
auto root = doc.root().child(L"ITH_Profile"); auto root = doc.root().child(L"NextHookerProfile");
if (!root) if (!root)
return; return;
for (auto game = root.begin(); game != root.end(); ++game) for (auto game = root.begin(); game != root.end(); ++game)
@ -110,13 +103,13 @@ void ProfileManager::LoadProfiles()
void ProfileManager::SaveProfiles() void ProfileManager::SaveProfiles()
{ {
pugi::xml_document doc; pugi::xml_document doc;
auto root = doc.append_child(L"ITH_Profile"); auto root = doc.append_child(L"NextHookerProfile");
for (auto it = profile_tree.begin(); it != profile_tree.end(); ++it) { for (auto it = profile_tree.begin(); it != profile_tree.end(); ++it) {
auto& path = it->first; auto& path = it->first;
auto& profile = it->second; auto& profile = it->second;
WriteProfileXml(path, *profile, root); WriteProfileXml(path, *profile, root);
} }
UniqueHandle hFile(IthCreateFile(L"ITH_Profile.xml", GENERIC_WRITE, 0, CREATE_ALWAYS)); UniqueHandle hFile(IthCreateFile(L"NextHooker_Profile.xml", GENERIC_WRITE, 0, CREATE_ALWAYS));
if (hFile.get() != INVALID_HANDLE_VALUE) if (hFile.get() != INVALID_HANDLE_VALUE)
{ {
FileWriter fw(hFile.get()); FileWriter fw(hFile.get());
@ -150,56 +143,6 @@ DWORD ProfileManager::CountProfiles()
return profile_tree.size(); return profile_tree.size();
} }
DWORD WINAPI InjectThread(LPVOID lpThreadParameter)
{
DWORD pid = (DWORD)lpThreadParameter;
Sleep(inject_delay);
if (man == NULL)
return 0;
DWORD status = InjectProcessById(pid);
if (!auto_insert)
return status;
if (status == -1)
return status;
Sleep(insert_delay);
const Profile* pf = pfman->GetProfile(pid);
if (pf)
{
SendParam sp;
sp.type = 0;
for (auto hp = pf->Hooks().begin(); hp != pf->Hooks().end(); ++hp)
{
std::string name = toMultiByteString((*hp)->Name());
InsertHook(pid, const_cast<HookParam*>(&(*hp)->HP()), name);
}
}
return status;
}
DWORD WINAPI MonitorThread(LPVOID lpThreadParameter)
{
while (MonitorFlag)
{
DWORD aProcesses[1024], cbNeeded, cProcesses;
if (!EnumProcesses(aProcesses, sizeof(aProcesses), &cbNeeded))
break;
cProcesses = cbNeeded / sizeof(DWORD);
for (size_t i = 0; i < cProcesses; ++i)
{
Sleep(process_time);
if (!auto_inject || man == NULL || man->GetProcessRecord(aProcesses[i]))
continue;
std::wstring process_path = GetProcessPath(aProcesses[i]);
if (!process_path.empty() && pfman->HasProfile(process_path))
{
UniqueHandle hThread(IthCreateThread(InjectThread, aProcesses[i]));
WaitForSingleObject(hThread.get(), 0);
}
}
}
return 0;
}
DWORD SaveProcessProfile(DWORD pid) DWORD SaveProcessProfile(DWORD pid)
{ {
std::wstring path = GetProcessPath(pid); std::wstring path = GetProcessPath(pid);

View File

@ -31,5 +31,4 @@ private:
// locate profile with executable path // locate profile with executable path
profile_map profile_tree; profile_map profile_tree;
CriticalSection cs; CriticalSection cs;
UniqueHandle hMonitorThread;
}; };

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 766 B

View File

@ -81,7 +81,7 @@ const wchar_t* InitMessage=L"Copyright (C) 2010-2012 kaosu (qiupf2000@gmail.com
Copyright (C) 2015 Stomp (zorkzero@hotmail.com)\r\n\ Copyright (C) 2015 Stomp (zorkzero@hotmail.com)\r\n\
Copyright (C) 2016-2017 mireado (mireado@daum.net)\r\n\ Copyright (C) 2016-2017 mireado (mireado@daum.net)\r\n\
Copyright (C) 2018 Artikash (akashmozumdar@gmail.com)\r\n\ Copyright (C) 2018 Artikash (akashmozumdar@gmail.com)\r\n\
Source code available at github.com/Artikash/NextHooker"; Source code available at github.com/Artikash/NextHooker (GPLv3 License)";
const wchar_t* BackgroundMsg=L"Type \":h\" or \":help\" for help."; const wchar_t* BackgroundMsg=L"Type \":h\" or \":help\" for help.";
const wchar_t* ErrorLinkExist=L"Link exist."; const wchar_t* ErrorLinkExist=L"Link exist.";
const wchar_t* ErrorCylicLink=L"Link failed. No cyclic link allowed."; const wchar_t* ErrorCylicLink=L"Link failed. No cyclic link allowed.";

View File

@ -27,14 +27,11 @@ ATOM MyRegisterClass(HINSTANCE hInstance);
BOOL InitInstance(HINSTANCE hInstance, DWORD nCmdShow, RECT *rc); BOOL InitInstance(HINSTANCE hInstance, DWORD nCmdShow, RECT *rc);
RECT window; RECT window;
extern HWND hMainWnd; // windows.cpp extern HWND hMainWnd; // windows.cpp
extern bool MonitorFlag; // ProfileManager.cpp
extern ProfileManager* pfman; // ProfileManager.cpp extern ProfileManager* pfman; // ProfileManager.cpp
HookManager* man; HookManager* man;
Settings* setman; Settings* setman;
LONG split_time, cyclic_remove, global_filter; LONG split_time;
LONG process_time, inject_delay, insert_delay,
auto_inject, auto_insert, clipboard_flag;
std::map<std::wstring, long> setting; std::map<std::wstring, long> setting;
@ -48,21 +45,13 @@ void SaveSettings()
setting[L"window_top"] = wndpl.rcNormalPosition.top; setting[L"window_top"] = wndpl.rcNormalPosition.top;
setting[L"window_bottom"] = wndpl.rcNormalPosition.bottom; setting[L"window_bottom"] = wndpl.rcNormalPosition.bottom;
setting[L"split_time"] = split_time; setting[L"split_time"] = split_time;
setting[L"process_time"] = process_time;
setting[L"inject_delay"] = inject_delay;
setting[L"insert_delay"] = insert_delay;
setting[L"auto_inject"] = auto_inject;
setting[L"auto_insert"] = auto_insert;
setting[L"auto_copy"] = clipboard_flag;
setting[L"auto_suppress"] = cyclic_remove;
setting[L"global_filter"] = global_filter;
UniqueHandle hFile(IthCreateFile(L"ITH.xml", GENERIC_WRITE, FILE_SHARE_READ, CREATE_ALWAYS)); UniqueHandle hFile(IthCreateFile(L"NextHooker.xml", GENERIC_WRITE, FILE_SHARE_READ, CREATE_ALWAYS));
if (hFile.get() != INVALID_HANDLE_VALUE) if (hFile.get() != INVALID_HANDLE_VALUE)
{ {
FileWriter fw(hFile.get()); FileWriter fw(hFile.get());
pugi::xml_document doc; pugi::xml_document doc;
auto root = doc.root().append_child(L"ITH_Setting"); auto root = doc.root().append_child(L"NextHookerSetting");
for (auto it = setting.begin(); it != setting.end(); ++it) for (auto it = setting.begin(); it != setting.end(); ++it)
root.append_attribute(it->first.c_str()).set_value(it->second); root.append_attribute(it->first.c_str()).set_value(it->second);
doc.save(fw); doc.save(fw);
@ -72,14 +61,6 @@ void SaveSettings()
void DefaultSettings() void DefaultSettings()
{ {
setting[L"split_time"] = 200; setting[L"split_time"] = 200;
setting[L"process_time"] = 50;
setting[L"inject_delay"] = 3000;
setting[L"insert_delay"] = 500;
setting[L"auto_inject"] = 1;
setting[L"auto_insert"] = 1;
setting[L"auto_copy"] = 0;
setting[L"auto_suppress"] = 0;
setting[L"global_filter"] = 0;
setting[L"window_left"] = 100; setting[L"window_left"] = 100;
setting[L"window_right"] = 800; setting[L"window_right"] = 800;
setting[L"window_top"] = 100; setting[L"window_top"] = 100;
@ -89,28 +70,11 @@ void DefaultSettings()
void InitializeSettings() void InitializeSettings()
{ {
split_time = setting[L"split_time"]; split_time = setting[L"split_time"];
process_time = setting[L"process_time"];
inject_delay = setting[L"inject_delay"];
insert_delay = setting[L"insert_delay"];
auto_inject = setting[L"auto_inject"];
auto_insert = setting[L"auto_insert"];
clipboard_flag = setting[L"auto_copy"];
cyclic_remove = setting[L"auto_suppress"];
global_filter = setting[L"global_filter"];
window.left = setting[L"window_left"]; window.left = setting[L"window_left"];
window.right = setting[L"window_right"]; window.right = setting[L"window_right"];
window.top = setting[L"window_top"]; window.top = setting[L"window_top"];
window.bottom = setting[L"window_bottom"]; window.bottom = setting[L"window_bottom"];
if (auto_inject > 1)
auto_inject = 1;
if (auto_insert > 1)
auto_insert = 1;
if (clipboard_flag > 1)
clipboard_flag = 1;
if (cyclic_remove > 1)
cyclic_remove = 1;
if (window.right < window.left || window.right - window.left < 600) if (window.right < window.left || window.right - window.left < 600)
window.right = window.left + 600; window.right = window.left + 600;
if (window.bottom < window.top || window.bottom - window.top < 200) if (window.bottom < window.top || window.bottom - window.top < 200)
@ -119,7 +83,7 @@ void InitializeSettings()
void LoadSettings() void LoadSettings()
{ {
UniqueHandle hFile(IthCreateFile(L"ITH.xml", GENERIC_READ, FILE_SHARE_READ, OPEN_EXISTING)); UniqueHandle hFile(IthCreateFile(L"NextHooker.xml", GENERIC_READ, FILE_SHARE_READ, OPEN_EXISTING));
if (hFile.get() != INVALID_HANDLE_VALUE) if (hFile.get() != INVALID_HANDLE_VALUE)
{ {
DWORD size = GetFileSize(hFile.get(), NULL); DWORD size = GetFileSize(hFile.get(), NULL);
@ -129,7 +93,7 @@ void LoadSettings()
auto result = doc.load_buffer_inplace(buffer.get(), size); auto result = doc.load_buffer_inplace(buffer.get(), size);
if (!result) if (!result)
return; return;
auto root = doc.root().child(L"ITH_Setting"); auto root = doc.root().child(L"NextHookerSetting");
for (auto attr = root.attributes_begin(); attr != root.attributes_end(); ++attr) for (auto attr = root.attributes_begin(); attr != root.attributes_end(); ++attr)
{ {
auto it = setting.find(attr->name()); auto it = setting.find(attr->name());
@ -184,20 +148,17 @@ LONG WINAPI UnhandledExcept(_EXCEPTION_POINTERS *ExceptionInfo)
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{ {
InitCommonControls(); InitCommonControls();
CreateMutex(NULL, TRUE, L"ITH_MAIN_RUNNING");
if (OpenHost()) if (OpenHost())
{ {
SetUnhandledExceptionFilter(UnhandledExcept); SetUnhandledExceptionFilter(UnhandledExcept);
GetHostHookManager(&man); GetHostHookManager(&man);
GetHostSettings(&setman); GetHostSettings(&setman);
setman->splittingInterval = 200; setman->splittingInterval = 200;
MonitorFlag = true;
pfman = new ProfileManager(); pfman = new ProfileManager();
DefaultSettings(); DefaultSettings();
LoadSettings(); LoadSettings();
InitializeSettings(); InitializeSettings();
setman->splittingInterval = split_time; setman->splittingInterval = split_time;
setman->clipboardFlag = clipboard_flag > 0;
hIns = hInstance; hIns = hInstance;
MyRegisterClass(hIns); MyRegisterClass(hIns);
InitInstance(hIns, FALSE, &window); InitInstance(hIns, FALSE, &window);
@ -207,10 +168,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
TranslateMessage(&msg); TranslateMessage(&msg);
DispatchMessage(&msg); DispatchMessage(&msg);
} }
//delete mb_filter;
//delete uni_filter;
delete pfman; delete pfman;
MonitorFlag = false;
man = NULL; man = NULL;
} }
else else

View File

@ -5,19 +5,10 @@
#define IDD_DIALOG2 102 #define IDD_DIALOG2 102
#define IDD_DIALOG4 104 #define IDD_DIALOG4 104
#define IDI_ICON1 110 #define IDI_ICON1 110
#define IDC_CHECK1 1000
#define IDC_CHECK2 1001
#define IDC_CHECK3 1002
#define IDC_CHECK4 1003
#define IDC_CHECK5 1004
#define IDC_EDIT1 1011 #define IDC_EDIT1 1011
#define IDC_EDIT2 1012
#define IDC_EDIT3 1013
#define IDC_EDIT4 1014
#define IDC_BUTTON1 1020 #define IDC_BUTTON1 1020
#define IDC_BUTTON2 1021 #define IDC_BUTTON2 1021
#define IDC_BUTTON3 1022 #define IDC_BUTTON3 1022
#define IDC_BUTTON5 1024 #define IDC_BUTTON5 1024
#define IDC_LIST1 1028 #define IDC_LIST1 1028
#define IDC_BUTTON6 40000 #define IDC_BUTTON6 40000
#define IDC_CHECK6 40001

View File

@ -1,2 +1,2 @@
const wchar_t* build_date=L"27.01.2013"; const wchar_t* build_date=L"@BUILD_DATE@";
const WCHAR program_version[] = L"@CPACK_PACKAGE_VERSION_MAJOR@.@CPACK_PACKAGE_VERSION_MINOR@.@CPACK_PACKAGE_VERSION_PATCH@"; const WCHAR program_version[] = L"@CPACK_PACKAGE_VERSION_MAJOR@.@CPACK_PACKAGE_VERSION_MINOR@.@CPACK_PACKAGE_VERSION_PATCH@";

View File

@ -36,7 +36,7 @@ extern HINSTANCE hIns; // main.cpp
HWND hMainWnd, hwndCombo, hwndProcessComboBox, hwndEdit, hwndCmd; HWND hMainWnd, hwndCombo, hwndProcessComboBox, hwndEdit, hwndCmd;
HWND hwndProcess; HWND hwndProcess;
HWND hwndOption, hwndTop, hwndClear, hwndSave, hwndRemoveLink, hwndRemoveHook; HWND hwndOption, hwndTop, hwndClear, hwndSave, hwndExtensions, hwndRemoveHook;
HWND hProcDlg, hOptionDlg; HWND hProcDlg, hOptionDlg;
HBRUSH hWhiteBrush; HBRUSH hWhiteBrush;
DWORD background; DWORD background;
@ -94,14 +94,6 @@ BOOL CALLBACK OptionDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
case WM_INITDIALOG: case WM_INITDIALOG:
{ {
SetWindowText(GetDlgItem(hDlg, IDC_EDIT1), std::to_wstring((long long)split_time).c_str()); SetWindowText(GetDlgItem(hDlg, IDC_EDIT1), std::to_wstring((long long)split_time).c_str());
SetWindowText(GetDlgItem(hDlg, IDC_EDIT2), std::to_wstring((long long)process_time).c_str());
SetWindowText(GetDlgItem(hDlg, IDC_EDIT3), std::to_wstring((long long)inject_delay).c_str());
SetWindowText(GetDlgItem(hDlg, IDC_EDIT4), std::to_wstring((long long)insert_delay).c_str());
CheckDlgButton(hDlg, IDC_CHECK1, auto_inject);
CheckDlgButton(hDlg, IDC_CHECK2, auto_insert);
CheckDlgButton(hDlg, IDC_CHECK3, clipboard_flag);
CheckDlgButton(hDlg, IDC_CHECK4, cyclic_remove);
CheckDlgButton(hDlg, IDC_CHECK5, global_filter);
} }
return TRUE; return TRUE;
case WM_COMMAND: case WM_COMMAND:
@ -116,23 +108,7 @@ BOOL CALLBACK OptionDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
GetWindowText(GetDlgItem(hDlg, IDC_EDIT1), str, 0x80); GetWindowText(GetDlgItem(hDlg, IDC_EDIT1), str, 0x80);
DWORD st = std::stoul(str); DWORD st = std::stoul(str);
split_time = st > 100 ? st : 100; split_time = st > 100 ? st : 100;
GetWindowText(GetDlgItem(hDlg, IDC_EDIT2), str, 0x80);
DWORD pt = std::stoul(str);
process_time = pt > 50 ? pt : 50;
GetWindowText(GetDlgItem(hDlg, IDC_EDIT3), str, 0x80);
DWORD jd = std::stoul(str);
inject_delay = jd > 1000 ? jd : 1000;
GetWindowText(GetDlgItem(hDlg, IDC_EDIT4), str, 0x80);
DWORD sd = std::stoul(str);
insert_delay = sd > 200 ? sd : 200;
auto_inject = IsDlgButtonChecked(hDlg, IDC_CHECK1);
auto_insert = IsDlgButtonChecked(hDlg, IDC_CHECK2);
clipboard_flag = IsDlgButtonChecked(hDlg, IDC_CHECK3);
cyclic_remove = IsDlgButtonChecked(hDlg, IDC_CHECK4);
global_filter = IsDlgButtonChecked(hDlg, IDC_CHECK5);
setman->clipboardFlag = clipboard_flag;
setman->splittingInterval = split_time; setman->splittingInterval = split_time;
if (auto_inject == 0) auto_insert = 0;
} }
case IDCANCEL: case IDCANCEL:
EndDialog(hDlg, 0); EndDialog(hDlg, 0);
@ -281,7 +257,7 @@ void CreateButtons(HWND hWnd)
0, 0, 0, 0, hWnd, 0, hIns, NULL); 0, 0, 0, 0, hWnd, 0, hIns, NULL);
hwndSave = CreateWindow(L"Button", L"Save", WS_CHILD | WS_VISIBLE, hwndSave = CreateWindow(L"Button", L"Save", WS_CHILD | WS_VISIBLE,
0, 0, 0, 0, hWnd, 0, hIns, NULL); 0, 0, 0, 0, hWnd, 0, hIns, NULL);
hwndRemoveLink = CreateWindow(L"Button", L"Unlink", WS_CHILD | WS_VISIBLE, hwndExtensions = CreateWindow(L"Button", L"Extensions", WS_CHILD | WS_VISIBLE,
0, 0, 0, 0, hWnd, 0, hIns, NULL); 0, 0, 0, 0, hWnd, 0, hIns, NULL);
hwndRemoveHook = CreateWindow(L"Button", L"Unhook", WS_CHILD | WS_VISIBLE, hwndRemoveHook = CreateWindow(L"Button", L"Unhook", WS_CHILD | WS_VISIBLE,
0, 0, 0, 0, hWnd, 0, hIns, NULL); 0, 0, 0, 0, hWnd, 0, hIns, NULL);
@ -351,6 +327,10 @@ void ClickButton(HWND hWnd, HWND h)
} }
pfman->SaveProfiles(); pfman->SaveProfiles();
} }
else if (h == hwndExtensions)
{
man->AddConsoleOutput(L"GUI for managing your extensions coming soon. Please do it manually for now.");
}
else if (h == hwndRemoveHook) else if (h == hwndRemoveHook)
{ {
WCHAR str[32]; WCHAR str[32];
@ -364,7 +344,7 @@ void ClickButton(HWND hWnd, HWND h)
entry = entry.substr(i + 1); entry = entry.substr(i + 1);
DWORD addr = std::stoul(entry, NULL, 16); DWORD addr = std::stoul(entry, NULL, 16);
if (threadNumber != 0) if (threadNumber != 0)
Host_RemoveHook(pid, addr); RemoveHook(pid, addr);
} }
} }
} }
@ -547,7 +527,7 @@ DWORD ThreadRemove(TextThread* thread)
return 0; return 0;
} }
DWORD RegisterProcessList(DWORD pid) DWORD RegisterProcess(DWORD pid)
{ {
auto path = GetProcessPath(pid); auto path = GetProcessPath(pid);
if (!path.empty()) if (!path.empty())
@ -558,6 +538,14 @@ DWORD RegisterProcessList(DWORD pid)
if (ComboBox_GetCount(hwndProcessComboBox) == 1) if (ComboBox_GetCount(hwndProcessComboBox) == 1)
ComboBox_SetCurSel(hwndProcessComboBox, 0); ComboBox_SetCurSel(hwndProcessComboBox, 0);
} }
Profile* pf = pfman->GetProfile(pid);
if (pf)
{
for (auto i = pf->Hooks().begin(); i != pf->Hooks().end(); ++i)
{
InsertHook(pid, &i->get()->HP(), toMultiByteString(i->get()->Name()));
}
}
return 0; return 0;
} }
@ -610,16 +598,16 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
TextThread* console = man->FindSingle(0); TextThread* console = man->FindSingle(0);
console->RegisterOutputCallBack(ThreadOutput, NULL); console->RegisterOutputCallBack(ThreadOutput, NULL);
AddToCombo(*console, false); AddToCombo(*console, false);
man->RegisterProcessAttachCallback(RegisterProcessList); man->RegisterProcessAttachCallback(RegisterProcess);
man->RegisterProcessDetachCallback(RemoveProcessList); man->RegisterProcessDetachCallback(RemoveProcessList);
//man->RegisterProcessNewHookCallback(RefreshProfileOnNewHook); Artikash 5/30/2018 TODO: Finish implementing this. //man->RegisterProcessNewHookCallback(RefreshProfileOnNewHook); Artikash 5/30/2018 TODO: Finish implementing this.
man->RegisterAddRemoveLinkCallback(AddRemoveLink); man->RegisterAddRemoveLinkCallback(AddRemoveLink);
StartHost(); StartHost();
{ {
static const WCHAR program_name[] = L"Interactive Text Hooker"; static const WCHAR program_name[] = L"NextHooker beta v";
//static const WCHAR program_version[] = L"3.0"; //static const WCHAR program_version[] = L"3.0";
static WCHAR version_info[256]; static WCHAR version_info[256];
std::swprintf(version_info, L"%s %s (%s)", program_name, program_version, build_date); std::swprintf(version_info, L"%s%s (%s)", program_name, program_version, build_date);
man->AddConsoleOutput(version_info); man->AddConsoleOutput(version_info);
man->AddConsoleOutput(InitMessage); man->AddConsoleOutput(InitMessage);
} }
@ -688,7 +676,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
MoveWindow(hwndOption, l * 1, 0, l, h, TRUE); MoveWindow(hwndOption, l * 1, 0, l, h, TRUE);
MoveWindow(hwndTop, l * 2, 0, l, h, TRUE); MoveWindow(hwndTop, l * 2, 0, l, h, TRUE);
MoveWindow(hwndClear, l * 3, 0, l, h, TRUE); MoveWindow(hwndClear, l * 3, 0, l, h, TRUE);
MoveWindow(hwndRemoveLink, l * 4, 0, l, h, TRUE); MoveWindow(hwndExtensions, l * 4, 0, l, h, TRUE);
MoveWindow(hwndRemoveHook, l * 5, 0, l, h, TRUE); MoveWindow(hwndRemoveHook, l * 5, 0, l, h, TRUE);
MoveWindow(hwndSave, l * 6, 0, width - 6 * l, h, TRUE); MoveWindow(hwndSave, l * 6, 0, width - 6 * l, h, TRUE);
l *= 2; l *= 2;

View File

@ -4,6 +4,10 @@
// ntdll.h 10/14/2011 // ntdll.h 10/14/2011
/* Artikash 7/13/2018: WHERE THE FUCK DID THIS FILE COME FROM?
Redefines a bunch of stuff in the standard windows headers (especially winnt.h) but has additional information that isn't documented anywhere else I can find.
It's like someone stole this file from Microsoft's internal database of windows source code?? */
#include <windows.h> #include <windows.h>
#ifdef _MSC_VER #ifdef _MSC_VER

View File

@ -219,7 +219,7 @@ IHFSERVICE void IHFAPI GetHostSettings(Settings **p)
} }
} }
IHFSERVICE DWORD IHFAPI InsertHook(DWORD pid, HookParam *hp, std::string name) IHFSERVICE DWORD IHFAPI InsertHook(DWORD pid, const HookParam *hp, std::string name)
{ {
HANDLE commandPipe = man->GetCommandPipe(pid); HANDLE commandPipe = man->GetCommandPipe(pid);
if (commandPipe == nullptr) if (commandPipe == nullptr)
@ -234,7 +234,7 @@ IHFSERVICE DWORD IHFAPI InsertHook(DWORD pid, HookParam *hp, std::string name)
return 0; return 0;
} }
IHFSERVICE DWORD IHFAPI Host_RemoveHook(DWORD pid, DWORD addr) IHFSERVICE DWORD IHFAPI RemoveHook(DWORD pid, DWORD addr)
{ {
HANDLE commandPipe = man->GetCommandPipe(pid); HANDLE commandPipe = man->GetCommandPipe(pid);
if (commandPipe == nullptr) if (commandPipe == nullptr)

View File

@ -24,9 +24,9 @@ IHFSERVICE DWORD IHFAPI Host_GetPIDByName(LPCWSTR pwcTarget);
IHFSERVICE bool IHFAPI InjectProcessById(DWORD pid, DWORD timeout = 5000); IHFSERVICE bool IHFAPI InjectProcessById(DWORD pid, DWORD timeout = 5000);
IHFSERVICE bool IHFAPI DetachProcessById(DWORD pid); IHFSERVICE bool IHFAPI DetachProcessById(DWORD pid);
IHFSERVICE bool IHFAPI Host_HijackProcess(DWORD pid); IHFSERVICE bool IHFAPI Host_HijackProcess(DWORD pid);
IHFSERVICE DWORD IHFAPI InsertHook(DWORD pid, HookParam *hp, std::string name = ""); IHFSERVICE DWORD IHFAPI InsertHook(DWORD pid, const HookParam *hp, std::string name = "");
IHFSERVICE DWORD IHFAPI Host_ModifyHook(DWORD pid, HookParam *hp); IHFSERVICE DWORD IHFAPI Host_ModifyHook(DWORD pid, HookParam *hp);
IHFSERVICE DWORD IHFAPI Host_RemoveHook(DWORD pid, DWORD addr); IHFSERVICE DWORD IHFAPI RemoveHook(DWORD pid, DWORD addr);
IHFSERVICE DWORD IHFAPI Host_AddLink(DWORD from, DWORD to); IHFSERVICE DWORD IHFAPI Host_AddLink(DWORD from, DWORD to);
IHFSERVICE DWORD IHFAPI Host_UnLink(DWORD from); IHFSERVICE DWORD IHFAPI Host_UnLink(DWORD from);
IHFSERVICE DWORD IHFAPI Host_UnLinkAll(DWORD from); IHFSERVICE DWORD IHFAPI Host_UnLinkAll(DWORD from);