Skip to content

Commit

Permalink
really final fixes for beta release
Browse files Browse the repository at this point in the history
  • Loading branch information
Artikash committed Jul 13, 2018
1 parent a05714f commit ef36cb9
Show file tree
Hide file tree
Showing 14 changed files with 54 additions and 179 deletions.
10 changes: 7 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,15 @@ set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE "${CMAKE_BINARY_DIR}/Release")

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_PACKAGE_VERSION_MAJOR 3)
set(CPACK_PACKAGE_VERSION_MINOR 5640)
set(CPACK_PACKAGE_VERSION_PATCH 1)
set(CPACK_PACKAGE_VERSION_MAJOR 1)
set(CPACK_PACKAGE_VERSION_MINOR 0)
set(CPACK_PACKAGE_VERSION_PATCH 0)
set(CPACK_SOURCE_GENERATOR "ZIP")
set(CPACK_SOURCE_IGNORE_FILES "/CVS/;/\\\\.svn/;/\\\\.bzr/;/\\\\.hg/;/\\\\.git/;\\\\.swp$;\\\\.#;/#" ".*\\\\.user$" "\\\\.gitignore$" "\\\\.gitmodules$" "\\\\.git$")
include(CPack)
Expand Down
22 changes: 5 additions & 17 deletions gui/ITHVNR.rc
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
// Generated by ResEdit 1.6.5
// Generated by ResEdit 1.6.6
// Copyright (C) 2006-2015
// http://www.resedit.net

#include <windows.h>
#include <commctrl.h>
#include <richedit.h>
#include "resource.h"


Expand Down Expand Up @@ -32,27 +31,16 @@ FONT 8, "MS Shell Dlg", 400, 0, 1


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
CAPTION "Option"
FONT 8, "MS Shell Dlg", 400, 0, 1
{
DEFPUSHBUTTON "OK", IDOK, 8, 164, 50, 14, 0, WS_EX_LEFT
PUSHBUTTON "Cancel", IDCANCEL, 65, 164, 50, 14, 0, WS_EX_LEFT
LTEXT "More options coming soon?", 0, 18, 25, 88, 9, SS_LEFT, 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
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
}


Expand Down
4 changes: 2 additions & 2 deletions gui/ProcessWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ void ProcessWindow::AttachProcess()
void ProcessWindow::DetachProcess()
{
DWORD pid = GetSelectedPID();
if (DetachProcessById(pid) == 0)
RefreshThreadWithPID(pid, false);
DetachProcessById(pid);
RefreshThreadWithPID(pid, false);
}

void ProcessWindow::CreateProfileForSelectedProcess()
Expand Down
67 changes: 5 additions & 62 deletions gui/ProfileManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,16 @@
#include "profile/misc.h"

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;

DWORD WINAPI MonitorThread(LPVOID lpThreadParameter);

ProfileManager::ProfileManager() :
hMonitorThread(IthCreateThread(MonitorThread, 0))
ProfileManager::ProfileManager()
{
LoadProfiles();
}

ProfileManager::~ProfileManager()
{
SaveProfiles();
WaitForSingleObject(hMonitorThread.get(), 0);
}

Profile* ProfileManager::GetProfile(DWORD pid)
Expand Down Expand Up @@ -91,7 +84,7 @@ void ProfileManager::WriteProfileXml(const std::wstring& path, Profile& pf, pugi
void ProfileManager::LoadProfiles()
{
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)
return;
DWORD size = GetFileSize(hFile.get(), NULL);
Expand All @@ -100,7 +93,7 @@ void ProfileManager::LoadProfiles()
auto result = doc.load_buffer(buffer.get(), size);
if (!result)
return;
auto root = doc.root().child(L"ITH_Profile");
auto root = doc.root().child(L"NextHookerProfile");
if (!root)
return;
for (auto game = root.begin(); game != root.end(); ++game)
Expand All @@ -110,13 +103,13 @@ void ProfileManager::LoadProfiles()
void ProfileManager::SaveProfiles()
{
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) {
auto& path = it->first;
auto& profile = it->second;
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)
{
FileWriter fw(hFile.get());
Expand Down Expand Up @@ -150,56 +143,6 @@ DWORD ProfileManager::CountProfiles()
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)
{
std::wstring path = GetProcessPath(pid);
Expand Down
1 change: 0 additions & 1 deletion gui/ProfileManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,4 @@ class ProfileManager
// locate profile with executable path
profile_map profile_tree;
CriticalSection cs;
UniqueHandle hMonitorThread;
};
Binary file modified gui/icon1.ico
Binary file not shown.
2 changes: 1 addition & 1 deletion gui/language.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) 2016-2017 mireado (mireado@daum.net)\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* ErrorLinkExist=L"Link exist.";
const wchar_t* ErrorCylicLink=L"Link failed. No cyclic link allowed.";
Expand Down
52 changes: 5 additions & 47 deletions gui/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,11 @@ ATOM MyRegisterClass(HINSTANCE hInstance);
BOOL InitInstance(HINSTANCE hInstance, DWORD nCmdShow, RECT *rc);
RECT window;
extern HWND hMainWnd; // windows.cpp
extern bool MonitorFlag; // ProfileManager.cpp
extern ProfileManager* pfman; // ProfileManager.cpp

HookManager* man;
Settings* setman;
LONG split_time, cyclic_remove, global_filter;
LONG process_time, inject_delay, insert_delay,
auto_inject, auto_insert, clipboard_flag;
LONG split_time;

std::map<std::wstring, long> setting;

Expand All @@ -48,21 +45,13 @@ void SaveSettings()
setting[L"window_top"] = wndpl.rcNormalPosition.top;
setting[L"window_bottom"] = wndpl.rcNormalPosition.bottom;
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)
{
FileWriter fw(hFile.get());
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)
root.append_attribute(it->first.c_str()).set_value(it->second);
doc.save(fw);
Expand All @@ -72,14 +61,6 @@ void SaveSettings()
void DefaultSettings()
{
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_right"] = 800;
setting[L"window_top"] = 100;
Expand All @@ -89,28 +70,11 @@ void DefaultSettings()
void InitializeSettings()
{
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.right = setting[L"window_right"];
window.top = setting[L"window_top"];
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)
window.right = window.left + 600;
if (window.bottom < window.top || window.bottom - window.top < 200)
Expand All @@ -119,7 +83,7 @@ void InitializeSettings()

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)
{
DWORD size = GetFileSize(hFile.get(), NULL);
Expand All @@ -129,7 +93,7 @@ void LoadSettings()
auto result = doc.load_buffer_inplace(buffer.get(), size);
if (!result)
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)
{
auto it = setting.find(attr->name());
Expand Down Expand Up @@ -184,20 +148,17 @@ LONG WINAPI UnhandledExcept(_EXCEPTION_POINTERS *ExceptionInfo)
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
InitCommonControls();
CreateMutex(NULL, TRUE, L"ITH_MAIN_RUNNING");
if (OpenHost())
{
SetUnhandledExceptionFilter(UnhandledExcept);
GetHostHookManager(&man);
GetHostSettings(&setman);
setman->splittingInterval = 200;
MonitorFlag = true;
pfman = new ProfileManager();
DefaultSettings();
LoadSettings();
InitializeSettings();
setman->splittingInterval = split_time;
setman->clipboardFlag = clipboard_flag > 0;
hIns = hInstance;
MyRegisterClass(hIns);
InitInstance(hIns, FALSE, &window);
Expand All @@ -207,10 +168,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
TranslateMessage(&msg);
DispatchMessage(&msg);
}
//delete mb_filter;
//delete uni_filter;
delete pfman;
MonitorFlag = false;
man = NULL;
}
else
Expand Down
9 changes: 0 additions & 9 deletions gui/resource.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,10 @@
#define IDD_DIALOG2 102
#define IDD_DIALOG4 104
#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_EDIT2 1012
#define IDC_EDIT3 1013
#define IDC_EDIT4 1014
#define IDC_BUTTON1 1020
#define IDC_BUTTON2 1021
#define IDC_BUTTON3 1022
#define IDC_BUTTON5 1024
#define IDC_LIST1 1028
#define IDC_BUTTON6 40000
#define IDC_CHECK6 40001
2 changes: 1 addition & 1 deletion gui/version.h.in
Original file line number Diff line number Diff line change
@@ -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@";
Loading

0 comments on commit ef36cb9

Please sign in to comment.