mirror of
https://github.com/Artikash/Textractor.git
synced 2024-12-23 17:04:12 +08:00
remove old gui
This commit is contained in:
parent
a4eede1b4e
commit
3f6348e7d0
37
oldgui/ITH.h
37
oldgui/ITH.h
@ -1,37 +0,0 @@
|
|||||||
/* Copyright (C) 2010-2012 kaosu (qiupf2000@gmail.com)
|
|
||||||
* This file is part of the Interactive Text Hooker.
|
|
||||||
|
|
||||||
* Interactive Text Hooker is free software: you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU General Public License as published
|
|
||||||
* by the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include <Windows.h>
|
|
||||||
#include <string>
|
|
||||||
#include <sstream>
|
|
||||||
#include <ios>
|
|
||||||
#include <memory>
|
|
||||||
#include <stdexcept>
|
|
||||||
#include <assert.h>
|
|
||||||
#include <WindowsX.h>
|
|
||||||
#include <algorithm>
|
|
||||||
#include <Psapi.h>
|
|
||||||
#include <vector>
|
|
||||||
#include <map>
|
|
||||||
#include <CommCtrl.h>
|
|
||||||
#include <intrin.h>
|
|
||||||
#include <sstream>
|
|
||||||
#include <regex>
|
|
||||||
#include <set>
|
|
||||||
#include "profile/pugixml.h"
|
|
||||||
#pragma warning(disable: 4146)
|
|
@ -1,70 +0,0 @@
|
|||||||
// Generated by ResEdit 1.6.6
|
|
||||||
// Copyright (C) 2006-2015
|
|
||||||
// http://www.resedit.net
|
|
||||||
|
|
||||||
#include <windows.h>
|
|
||||||
#include <commctrl.h>
|
|
||||||
#include "resource.h"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//
|
|
||||||
// Dialog resources
|
|
||||||
//
|
|
||||||
LANGUAGE LANG_JAPANESE, SUBLANG_JAPANESE_JAPAN
|
|
||||||
IDD_DIALOG2 DIALOGEX 100, 100, 341, 210
|
|
||||||
STYLE DS_MODALFRAME | DS_SHELLFONT | WS_CAPTION | WS_VISIBLE | WS_POPUP | WS_SYSMENU
|
|
||||||
CAPTION "Process Explorer"
|
|
||||||
FONT 8, "MS Shell Dlg", 400, 0, 1
|
|
||||||
{
|
|
||||||
DEFPUSHBUTTON "OK", IDOK, 281, 189, 53, 14, 0, WS_EX_LEFT
|
|
||||||
PUSHBUTTON "Remove Profile", IDC_BUTTON6, 226, 189, 53, 14, 0, WS_EX_LEFT
|
|
||||||
CONTROL "", IDC_LIST1, WC_LISTVIEW, WS_TABSTOP | WS_BORDER | LVS_ALIGNLEFT | LVS_SHOWSELALWAYS | LVS_SINGLESEL | LVS_REPORT, 7, 20, 327, 164, WS_EX_LEFT
|
|
||||||
LTEXT "Process", IDC_STATIC, 7, 7, 65, 13, SS_LEFT | SS_CENTERIMAGE, WS_EX_LEFT
|
|
||||||
PUSHBUTTON "Attach", IDC_BUTTON2, 61, 189, 53, 14, 0, WS_EX_LEFT
|
|
||||||
PUSHBUTTON "Detach", IDC_BUTTON3, 116, 189, 53, 14, 0, WS_EX_LEFT
|
|
||||||
PUSHBUTTON "Add Profile", IDC_BUTTON5, 171, 189, 53, 14, 0, WS_EX_LEFT
|
|
||||||
PUSHBUTTON "Refresh", IDC_BUTTON1, 7, 189, 53, 14, 0, WS_EX_LEFT
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
LANGUAGE LANG_JAPANESE, SUBLANG_JAPANESE_JAPAN
|
|
||||||
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
|
|
||||||
{
|
|
||||||
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
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//
|
|
||||||
// Icon resources
|
|
||||||
//
|
|
||||||
LANGUAGE LANG_JAPANESE, SUBLANG_JAPANESE_JAPAN
|
|
||||||
IDI_ICON1 ICON "icon1.ico"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//
|
|
||||||
// Version Information resources
|
|
||||||
//
|
|
||||||
LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
|
|
||||||
1 VERSIONINFO
|
|
||||||
FILEVERSION 0,0,0,0
|
|
||||||
PRODUCTVERSION 0,0,0,0
|
|
||||||
FILEOS VOS_UNKNOWN
|
|
||||||
FILETYPE VFT_UNKNOWN
|
|
||||||
FILESUBTYPE VFT2_UNKNOWN
|
|
||||||
FILEFLAGSMASK 0
|
|
||||||
FILEFLAGS 0
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
@ -1,144 +0,0 @@
|
|||||||
#include "ProcessWindow.h"
|
|
||||||
#include "resource.h"
|
|
||||||
#include "host.h"
|
|
||||||
#include "hookman.h"
|
|
||||||
#include "ProfileManager.h"
|
|
||||||
#include "profile/Profile.h"
|
|
||||||
|
|
||||||
extern HookManager* man; // main.cpp
|
|
||||||
extern ProfileManager* pfman; // ProfileManager.cpp
|
|
||||||
|
|
||||||
ProcessWindow::ProcessWindow(HWND hDialog) : hDlg(hDialog)
|
|
||||||
{
|
|
||||||
hbRefresh = GetDlgItem(hDlg, IDC_BUTTON1);
|
|
||||||
hbAttach = GetDlgItem(hDlg, IDC_BUTTON2);
|
|
||||||
hbDetach = GetDlgItem(hDlg, IDC_BUTTON3);
|
|
||||||
hbAddProfile = GetDlgItem(hDlg, IDC_BUTTON5);
|
|
||||||
hbRemoveProfile = GetDlgItem(hDlg, IDC_BUTTON6);
|
|
||||||
EnableWindow(hbAddProfile, FALSE);
|
|
||||||
EnableWindow(hbRemoveProfile, FALSE);
|
|
||||||
hlProcess = GetDlgItem(hDlg, IDC_LIST1);
|
|
||||||
heOutput = GetDlgItem(hDlg, IDC_EDIT1);
|
|
||||||
ListView_SetExtendedListViewStyleEx(hlProcess, LVS_EX_FULLROWSELECT, LVS_EX_FULLROWSELECT);
|
|
||||||
InitProcessDlg();
|
|
||||||
RefreshProcess();
|
|
||||||
EnableWindow(hbDetach, FALSE);
|
|
||||||
EnableWindow(hbAttach, FALSE);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ProcessWindow::InitProcessDlg()
|
|
||||||
{
|
|
||||||
LVCOLUMN lvc = {};
|
|
||||||
lvc.mask = LVCF_FMT | LVCF_TEXT | LVCF_WIDTH;
|
|
||||||
lvc.fmt = LVCFMT_RIGHT; // left-aligned column
|
|
||||||
lvc.cx = 40;
|
|
||||||
lvc.pszText = L"PID";
|
|
||||||
ListView_InsertColumn(hlProcess, 0, &lvc);
|
|
||||||
lvc.cx = 100;
|
|
||||||
lvc.fmt = LVCFMT_LEFT; // left-aligned column
|
|
||||||
lvc.pszText = L"Name";
|
|
||||||
ListView_InsertColumn(hlProcess, 1, &lvc);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ProcessWindow::RefreshProcess()
|
|
||||||
{
|
|
||||||
ListView_DeleteAllItems(hlProcess);
|
|
||||||
LVITEM item = {};
|
|
||||||
item.mask = LVIF_TEXT | LVIF_PARAM | LVIF_STATE;
|
|
||||||
DWORD idProcess[1024], cbNeeded;
|
|
||||||
WCHAR path[MAX_PATH];
|
|
||||||
|
|
||||||
if (EnumProcesses(idProcess, sizeof(idProcess), &cbNeeded))
|
|
||||||
{
|
|
||||||
DWORD len = cbNeeded / sizeof(DWORD);
|
|
||||||
for (DWORD i = 0; i < len; ++i)
|
|
||||||
{
|
|
||||||
DWORD pid = idProcess[i];
|
|
||||||
UniqueHandle hProcess(OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, pid));
|
|
||||||
if (hProcess)
|
|
||||||
{
|
|
||||||
if (GetProcessImageFileName(hProcess.get(), path, MAX_PATH))
|
|
||||||
{
|
|
||||||
WCHAR buffer[256];
|
|
||||||
std::swprintf(buffer, L"%d", pid);
|
|
||||||
PWCHAR name = wcsrchr(path, L'\\') + 1;
|
|
||||||
item.pszText = buffer;
|
|
||||||
item.lParam = pid;
|
|
||||||
ListView_InsertItem(hlProcess, &item);
|
|
||||||
ListView_SetItemText(hlProcess, item.iItem, 1, name);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void ProcessWindow::AttachProcess()
|
|
||||||
{
|
|
||||||
DWORD pid = GetSelectedPID();
|
|
||||||
if (InjectProcess(pid))
|
|
||||||
RefreshThreadWithPID(pid, true);
|
|
||||||
else
|
|
||||||
ConsoleOutput(L"NextHooker: could not inject");
|
|
||||||
}
|
|
||||||
|
|
||||||
void ProcessWindow::DetachProcess()
|
|
||||||
{
|
|
||||||
DWORD pid = GetSelectedPID();
|
|
||||||
::DetachProcess(pid);
|
|
||||||
RefreshThreadWithPID(pid, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ProcessWindow::CreateProfileForSelectedProcess()
|
|
||||||
{
|
|
||||||
DWORD pid = GetSelectedPID();
|
|
||||||
auto path = GetProcessPath(pid);
|
|
||||||
if (!path.empty())
|
|
||||||
{
|
|
||||||
Profile* pf = pfman->CreateProfile(pid);
|
|
||||||
pfman->SaveProfiles();
|
|
||||||
RefreshThread(ListView_GetSelectionMark(hlProcess));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void ProcessWindow::DeleteProfileForSelectedProcess()
|
|
||||||
{
|
|
||||||
DWORD pid = GetSelectedPID();
|
|
||||||
auto path = GetProcessPath(pid);
|
|
||||||
if (!path.empty())
|
|
||||||
{
|
|
||||||
pfman->DeleteProfile(path);
|
|
||||||
RefreshThread(ListView_GetSelectionMark(hlProcess));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void ProcessWindow::RefreshThread(int index)
|
|
||||||
{
|
|
||||||
LVITEM item = {};
|
|
||||||
item.mask = LVIF_PARAM;
|
|
||||||
item.iItem = index;
|
|
||||||
ListView_GetItem(hlProcess, &item);
|
|
||||||
DWORD pid = item.lParam;
|
|
||||||
bool isAttached = man->GetHostPipe(pid) != NULL;
|
|
||||||
RefreshThreadWithPID(pid, isAttached);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ProcessWindow::RefreshThreadWithPID(DWORD pid, bool isAttached)
|
|
||||||
{
|
|
||||||
EnableWindow(hbDetach, isAttached);
|
|
||||||
EnableWindow(hbAttach, !isAttached);
|
|
||||||
auto path = GetProcessPath(pid);
|
|
||||||
bool hasProfile = !path.empty() && pfman->HasProfile(path);
|
|
||||||
EnableWindow(hbAddProfile, isAttached && !hasProfile);
|
|
||||||
EnableWindow(hbRemoveProfile, hasProfile);
|
|
||||||
if (pid == GetCurrentProcessId())
|
|
||||||
EnableWindow(hbAttach, FALSE);
|
|
||||||
}
|
|
||||||
|
|
||||||
DWORD ProcessWindow::GetSelectedPID()
|
|
||||||
{
|
|
||||||
LVITEM item = {};
|
|
||||||
item.mask = LVIF_PARAM;
|
|
||||||
item.iItem = ListView_GetSelectionMark(hlProcess);
|
|
||||||
ListView_GetItem(hlProcess, &item);
|
|
||||||
return item.lParam;
|
|
||||||
}
|
|
@ -1,23 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
#include "ITH.h"
|
|
||||||
|
|
||||||
class ProcessWindow
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
ProcessWindow(HWND hDialog);
|
|
||||||
void InitProcessDlg();
|
|
||||||
void RefreshProcess();
|
|
||||||
void AttachProcess();
|
|
||||||
void DetachProcess();
|
|
||||||
void CreateProfileForSelectedProcess();
|
|
||||||
void DeleteProfileForSelectedProcess();
|
|
||||||
void RefreshThread(int index);
|
|
||||||
private:
|
|
||||||
void RefreshThreadWithPID(DWORD pid, bool isAttached);
|
|
||||||
DWORD GetSelectedPID();
|
|
||||||
HWND hDlg;
|
|
||||||
HWND hlProcess;
|
|
||||||
HWND hbRefresh,hbAttach,hbDetach,hbAddProfile,hbRemoveProfile;
|
|
||||||
HWND heOutput;
|
|
||||||
};
|
|
@ -1,166 +0,0 @@
|
|||||||
#include "ProfileManager.h"
|
|
||||||
#include "profile/Profile.h"
|
|
||||||
#include "host.h"
|
|
||||||
#include "hookman.h"
|
|
||||||
#include "vnrhook/include/types.h"
|
|
||||||
#include "vnrhook/include/const.h"
|
|
||||||
#include "utility.h"
|
|
||||||
#include "profile/misc.h"
|
|
||||||
|
|
||||||
extern HookManager* man; // main.cpp
|
|
||||||
ProfileManager* pfman;
|
|
||||||
|
|
||||||
ProfileManager::ProfileManager()
|
|
||||||
{
|
|
||||||
LoadProfiles();
|
|
||||||
}
|
|
||||||
|
|
||||||
ProfileManager::~ProfileManager()
|
|
||||||
{
|
|
||||||
SaveProfiles();
|
|
||||||
}
|
|
||||||
|
|
||||||
Profile* ProfileManager::GetProfile(DWORD pid)
|
|
||||||
{
|
|
||||||
std::wstring path = GetProcessPath(pid);
|
|
||||||
if (!path.empty())
|
|
||||||
{
|
|
||||||
auto node = profile_tree.find(path);
|
|
||||||
if (node != profile_tree.end())
|
|
||||||
return node->second.get();
|
|
||||||
}
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ProfileManager::CreateProfile(pugi::xml_node game)
|
|
||||||
{
|
|
||||||
auto file = game.child(L"File");
|
|
||||||
auto profile = game.child(L"Profile");
|
|
||||||
if (!file || !profile)
|
|
||||||
return false;
|
|
||||||
auto path = file.attribute(L"Path");
|
|
||||||
if (!path)
|
|
||||||
return false;
|
|
||||||
auto profile_title = game.attribute(L"Title");
|
|
||||||
auto title = profile_title ? profile_title.value() : L"";
|
|
||||||
auto pf = new Profile(title);
|
|
||||||
if (!pf->XmlReadProfile(profile))
|
|
||||||
return false;
|
|
||||||
CSLock lock(cs);
|
|
||||||
auto& oldProfile = profile_tree[path.value()];
|
|
||||||
if (!oldProfile)
|
|
||||||
oldProfile.swap(profile_ptr(pf));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
Profile* ProfileManager::CreateProfile(DWORD pid)
|
|
||||||
{
|
|
||||||
CSLock lock(cs);
|
|
||||||
auto path = GetProcessPath(pid);
|
|
||||||
auto& pf = profile_tree[path];
|
|
||||||
if (!pf)
|
|
||||||
{
|
|
||||||
std::wstring title = GetProcessTitle(pid);
|
|
||||||
pf.reset(new Profile(title));
|
|
||||||
}
|
|
||||||
return pf.get();
|
|
||||||
}
|
|
||||||
|
|
||||||
void ProfileManager::WriteProfileXml(const std::wstring& path, Profile& pf, pugi::xml_node root)
|
|
||||||
{
|
|
||||||
auto game = root.append_child(L"Game");
|
|
||||||
auto file_node = game.append_child(L"File");
|
|
||||||
file_node.append_attribute(L"Path") = path.c_str();
|
|
||||||
auto profile_node = game.append_child(L"Profile");
|
|
||||||
pf.XmlWriteProfile(profile_node);
|
|
||||||
if (!pf.Title().empty())
|
|
||||||
{
|
|
||||||
if (!game.attribute(L"Title"))
|
|
||||||
game.append_attribute(L"Title");
|
|
||||||
game.attribute(L"Title") = pf.Title().c_str();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void ProfileManager::LoadProfiles()
|
|
||||||
{
|
|
||||||
pugi::xml_document doc;
|
|
||||||
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);
|
|
||||||
std::unique_ptr<char[]> buffer(new char[size]);
|
|
||||||
ReadFile(hFile.get(), buffer.get(), size, &size, NULL);
|
|
||||||
auto result = doc.load_buffer(buffer.get(), size);
|
|
||||||
if (!result)
|
|
||||||
return;
|
|
||||||
auto root = doc.root().child(L"NextHookerProfile");
|
|
||||||
if (!root)
|
|
||||||
return;
|
|
||||||
for (auto game = root.begin(); game != root.end(); ++game)
|
|
||||||
CreateProfile(*game);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ProfileManager::SaveProfiles()
|
|
||||||
{
|
|
||||||
pugi::xml_document doc;
|
|
||||||
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"NextHooker_Profile.xml", GENERIC_WRITE, 0, CREATE_ALWAYS));
|
|
||||||
if (hFile.get() != INVALID_HANDLE_VALUE)
|
|
||||||
{
|
|
||||||
FileWriter fw(hFile.get());
|
|
||||||
doc.save(fw);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void ProfileManager::DeleteProfile(const std::wstring& path)
|
|
||||||
{
|
|
||||||
CSLock lock(cs);
|
|
||||||
profile_tree.erase(profile_tree.find(path));
|
|
||||||
}
|
|
||||||
|
|
||||||
Profile* ProfileManager::GetProfile(const std::wstring& path)
|
|
||||||
{
|
|
||||||
if (path.empty())
|
|
||||||
return nullptr;
|
|
||||||
auto it = profile_tree.find(path);
|
|
||||||
if (it == profile_tree.end())
|
|
||||||
return nullptr;
|
|
||||||
return it->second.get();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ProfileManager::HasProfile(const std::wstring& path)
|
|
||||||
{
|
|
||||||
return profile_tree.find(path) != profile_tree.end();
|
|
||||||
}
|
|
||||||
|
|
||||||
DWORD ProfileManager::CountProfiles()
|
|
||||||
{
|
|
||||||
return profile_tree.size();
|
|
||||||
}
|
|
||||||
|
|
||||||
DWORD SaveProcessProfile(TextThread* thread)
|
|
||||||
{
|
|
||||||
ThreadParameter tp = thread->GetThreadParameter();
|
|
||||||
std::wstring path = GetProcessPath(tp.pid);
|
|
||||||
if (path.empty())
|
|
||||||
return 0;
|
|
||||||
pugi::xml_document doc;
|
|
||||||
pugi::xml_node profile_node = doc.append_child(L"Profile");
|
|
||||||
Profile* pf = pfman->GetProfile(tp.pid);
|
|
||||||
if (pf != NULL)
|
|
||||||
pf->Clear();
|
|
||||||
else
|
|
||||||
pf = pfman->CreateProfile(tp.pid);
|
|
||||||
|
|
||||||
pf->AddHook(hook_ptr(new HookProfile(man->GetHookParam(tp.pid, tp.hook), man->GetHookName(tp.pid, tp.hook))));
|
|
||||||
pf->AddThread(thread_ptr(new ThreadProfile(man->GetHookName(tp.pid, tp.hook), tp.retn, tp.spl, tp.hook, 0, THREAD_MASK_RETN | THREAD_MASK_SPLIT, L"")));
|
|
||||||
|
|
||||||
pf->XmlReadProfile(profile_node);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
@ -1,34 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
#include "ITH.h"
|
|
||||||
#include "utility.h" // UniqueHandle, CriticalSection
|
|
||||||
|
|
||||||
class Profile;
|
|
||||||
|
|
||||||
class ProfileManager
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
ProfileManager();
|
|
||||||
~ProfileManager();
|
|
||||||
Profile* CreateProfile(DWORD pid);
|
|
||||||
Profile* GetProfile(DWORD pid);
|
|
||||||
Profile* GetProfile(const std::wstring& path);
|
|
||||||
void LoadProfiles();
|
|
||||||
void SaveProfiles();
|
|
||||||
void DeleteProfile(const std::wstring& path);
|
|
||||||
void UpdateHookAddresses(DWORD pid);
|
|
||||||
bool HasProfile(const std::wstring& path);
|
|
||||||
private:
|
|
||||||
typedef std::unique_ptr<Profile> profile_ptr;
|
|
||||||
typedef std::map<std::wstring, profile_ptr> profile_map;
|
|
||||||
|
|
||||||
ProfileManager(const ProfileManager&);
|
|
||||||
ProfileManager operator=(const ProfileManager&);
|
|
||||||
|
|
||||||
DWORD CountProfiles();
|
|
||||||
bool CreateProfile(pugi::xml_node game);
|
|
||||||
void WriteProfileXml(const std::wstring& path, Profile& pf, pugi::xml_node doc);
|
|
||||||
// locate profile with executable path
|
|
||||||
profile_map profile_tree;
|
|
||||||
CriticalSection cs;
|
|
||||||
};
|
|
@ -1,49 +0,0 @@
|
|||||||
#include "TextBuffer.h"
|
|
||||||
|
|
||||||
DWORD WINAPI FlushThread(LPVOID lParam)
|
|
||||||
{
|
|
||||||
TextBuffer* t = (TextBuffer*)lParam;
|
|
||||||
while (t->Running())
|
|
||||||
{
|
|
||||||
t->Flush();
|
|
||||||
Sleep(10);
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
TextBuffer::TextBuffer(HWND edit) : hThread(IthCreateThread(FlushThread, (DWORD)this)),
|
|
||||||
hEdit(edit),
|
|
||||||
running(true)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
TextBuffer::~TextBuffer()
|
|
||||||
{
|
|
||||||
running = false;
|
|
||||||
WaitForSingleObject(hThread.get(), 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
void TextBuffer::AddText(std::wstring text, bool line)
|
|
||||||
{
|
|
||||||
CSLock lock(cs);
|
|
||||||
this->str.append(text);
|
|
||||||
line_break = line;
|
|
||||||
}
|
|
||||||
|
|
||||||
void TextBuffer::Flush()
|
|
||||||
{
|
|
||||||
CSLock lock(cs);
|
|
||||||
if (line_break || str.empty())
|
|
||||||
return;
|
|
||||||
DWORD t = Edit_GetTextLength(hEdit);
|
|
||||||
Edit_SetSel(hEdit, t, -1);
|
|
||||||
Edit_ReplaceSel(hEdit, str.c_str());
|
|
||||||
str.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
void TextBuffer::ClearBuffer()
|
|
||||||
{
|
|
||||||
CSLock lock(cs);
|
|
||||||
str.clear();
|
|
||||||
line_break = false;
|
|
||||||
}
|
|
@ -1,21 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
#include "ITH.h"
|
|
||||||
#include "utility.h" // UniqueHandle, CriticalSection
|
|
||||||
|
|
||||||
class TextBuffer
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
TextBuffer(HWND edit);
|
|
||||||
~TextBuffer();
|
|
||||||
void Flush();
|
|
||||||
void AddText(std::wstring text, bool line);
|
|
||||||
void ClearBuffer();
|
|
||||||
bool Running() { return running; }
|
|
||||||
private:
|
|
||||||
CriticalSection cs;
|
|
||||||
bool line_break, running;
|
|
||||||
UniqueHandle hThread;
|
|
||||||
HWND hEdit;
|
|
||||||
std::wstring str;
|
|
||||||
};
|
|
@ -1,55 +0,0 @@
|
|||||||
/* Copyright (C) 2010-2012 kaosu (qiupf2000@gmail.com)
|
|
||||||
* This file is part of the Interactive Text Hooker.
|
|
||||||
|
|
||||||
* Interactive Text Hooker is free software: you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU General Public License as published
|
|
||||||
* by the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "ITH.h"
|
|
||||||
#include "host.h"
|
|
||||||
#include "vnrhook/include/const.h"
|
|
||||||
#include "vnrhook/include/types.h"
|
|
||||||
#include "language.h"
|
|
||||||
#include "utility.h"
|
|
||||||
#include "profile/misc.h"
|
|
||||||
|
|
||||||
extern HookManager* man;
|
|
||||||
extern HWND hwndProcessComboBox;
|
|
||||||
|
|
||||||
DWORD ProcessCommand(const std::wstring& cmd, DWORD pid)
|
|
||||||
{
|
|
||||||
using std::wregex;
|
|
||||||
using std::regex_match;
|
|
||||||
std::match_results<std::wstring::const_iterator> m;
|
|
||||||
|
|
||||||
if (regex_match(cmd, m, wregex(L"/p(\\d+)", wregex::icase)))
|
|
||||||
{
|
|
||||||
pid = std::stoul(m[1].str());
|
|
||||||
InjectProcess(pid);
|
|
||||||
}
|
|
||||||
else if (regex_match(cmd, m, wregex(L"/h(.+)", wregex::icase)))
|
|
||||||
{
|
|
||||||
HookParam hp = {};
|
|
||||||
if (Parse(m[1].str(), hp))
|
|
||||||
InsertHook(pid, hp);
|
|
||||||
}
|
|
||||||
else if (regex_match(cmd, m, wregex(L":(?:h|help)", wregex::icase)))
|
|
||||||
{
|
|
||||||
ConsoleOutput(Usage);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ConsoleOutput(L"Unknown command. Type :h or :help for help.");
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
BIN
oldgui/icon1.ico
BIN
oldgui/icon1.ico
Binary file not shown.
Before Width: | Height: | Size: 766 B |
@ -1,128 +0,0 @@
|
|||||||
/* Copyright (C) 2010-2012 kaosu (qiupf2000@gmail.com)
|
|
||||||
* This file is part of the Interactive Text Hooker.
|
|
||||||
|
|
||||||
* Interactive Text Hooker is free software: you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU General Public License as published
|
|
||||||
* by the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
const wchar_t* Warning=L"Warning!";
|
|
||||||
//command.cpp
|
|
||||||
const wchar_t* ErrorSyntax=L"Syntax error";
|
|
||||||
const wchar_t* Usage = L"Syntax:\r\n\
|
|
||||||
\r\n\
|
|
||||||
:H[ELP] - print help\r\n\
|
|
||||||
Loader options:\r\n\
|
|
||||||
/P[{process_id|Nprocess_name}] - attach to process\r\n\
|
|
||||||
\r\n\
|
|
||||||
Hook options:\r\n\
|
|
||||||
/H[X]{A|B|W|S|Q}[N][data_offset[*drdo]][:sub_offset[*drso]]@addr[:module[:{name|#ordinal}]]\r\n\
|
|
||||||
\r\n\
|
|
||||||
All numbers in /H (except ordinal) are hexadecimal without any prefixes";
|
|
||||||
|
|
||||||
const wchar_t* ExtendedUsage = L"/H[X]{A|B|W|S|Q}[N][data_offset[*drdo]][:sub_offset[*drso]]@addr[:[module[:{name|#ordinal}]]]\r\n\
|
|
||||||
\r\n\
|
|
||||||
Set additional custom hook\r\n\
|
|
||||||
\r\n\
|
|
||||||
Hook types :\r\n\
|
|
||||||
A - DBCS char\r\n\
|
|
||||||
B - DBCS char(big-endian)\r\n\
|
|
||||||
W - UCS2 char\r\n\
|
|
||||||
S - MBCS string\r\n\
|
|
||||||
Q - UTF-16 string\r\n\
|
|
||||||
\r\n\
|
|
||||||
Parameters:\r\n\
|
|
||||||
X - use hardware breakpoints\r\n\
|
|
||||||
N - don't use contexts\r\n\
|
|
||||||
data_offset - stack offset to char / string pointer\r\n\
|
|
||||||
drdo - add a level of indirection to data_offset\r\n\
|
|
||||||
sub_offset - stack offset to subcontext\r\n\
|
|
||||||
drso - add a level of indirection to sub_offset\r\n\
|
|
||||||
addr - address of the hook\r\n\
|
|
||||||
module - name of the module to use as base for 'addr'\r\n\
|
|
||||||
name - name of the 'module' export to use as base for 'addr'\r\n\
|
|
||||||
ordinal - number of the 'module' export ordinal to use as base for 'addr'\r\n\
|
|
||||||
\r\n\
|
|
||||||
Negative values of 'data_offset' and 'sub_offset' refer to registers: \r\n\
|
|
||||||
- 4 for EAX, -8 for ECX, -C for EDX, -10 for EBX, -14 for ESP, -18 for EBP, -1C for ESI, -20 for EDI\r\n\
|
|
||||||
\r\n\
|
|
||||||
\"Add a level of indirection\" means in C/C++ style: (*(ESP+data_offset)+drdo) instead of (ESP+data_offset)\r\n\
|
|
||||||
\r\n\
|
|
||||||
All numbers except ordinal are hexadecimal without any prefixes";
|
|
||||||
|
|
||||||
//inject.cpp
|
|
||||||
const wchar_t* ErrorRemoteThread=L"Can't create remote thread.";
|
|
||||||
const wchar_t* ErrorOpenProcess=L"Can't open process.";
|
|
||||||
const wchar_t* ErrorNoProcess=L"Process not found";
|
|
||||||
const wchar_t* SelfAttach=L"Please do not attach to ITH.exe";
|
|
||||||
const wchar_t* AlreadyAttach=L"Process already attached.";
|
|
||||||
const wchar_t* FormatInject=L"Inject process %d. Module base %.8X";
|
|
||||||
//main.cpp
|
|
||||||
const wchar_t* NotAdmin=L"Can't enable SeDebugPrevilege. ITH might malfunction.\r\n\
|
|
||||||
Please run ITH as administrator or turn off UAC.";
|
|
||||||
//pipe.cpp
|
|
||||||
const wchar_t* ErrorCreatePipe=L"Can't create text pipe or too many instance.";
|
|
||||||
const wchar_t* FormatDetach=L"Process %d detached.";
|
|
||||||
const wchar_t* ErrorCmdQueueFull=L"Command queue full.";
|
|
||||||
const wchar_t* ErrorNoAttach=L"No process attached.";
|
|
||||||
|
|
||||||
//profile.cpp
|
|
||||||
const wchar_t* ErrorMonitor=L"Can't monitor process.";
|
|
||||||
//utility.cpp
|
|
||||||
const wchar_t* InitMessage=L"Copyright (C) 2010-2012 kaosu (qiupf2000@gmail.com)\r\n\
|
|
||||||
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 (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.";
|
|
||||||
const wchar_t* FormatLink=L"Link from thread%.4x to thread%.4x.";
|
|
||||||
const wchar_t* ErrorLink=L"Link failed. Source or/and destination thread not found.";
|
|
||||||
const wchar_t* ErrorDeleteCombo=L"Error delete from combo.";
|
|
||||||
|
|
||||||
//window.cpp
|
|
||||||
const wchar_t* ClassName=L"NextHooker";
|
|
||||||
const wchar_t* ClassNameAdmin=L"NextHooker (Administrator)";
|
|
||||||
const wchar_t* ErrorNotSplit=L"Need to enable split first!";
|
|
||||||
const wchar_t* ErrorNotModule=L"Need to enable module first!";
|
|
||||||
//Main window buttons
|
|
||||||
const wchar_t* ButtonTitleProcess=L"Process";
|
|
||||||
const wchar_t* ButtonTitleThread=L"Thread";
|
|
||||||
const wchar_t* ButtonTitleHook=L"Hook";
|
|
||||||
const wchar_t* ButtonTitleProfile=L"Profile";
|
|
||||||
const wchar_t* ButtonTitleOption=L"Option";
|
|
||||||
const wchar_t* ButtonTitleClear=L"Clear";
|
|
||||||
const wchar_t* ButtonTitleSave=L"Save";
|
|
||||||
const wchar_t* ButtonTitleTop=L"Top";
|
|
||||||
//Hook window
|
|
||||||
const wchar_t* SpecialHook=L"Special hook, no AGTH equivalent.";
|
|
||||||
//Process window
|
|
||||||
const wchar_t* TabTitlePID=L"PID";
|
|
||||||
const wchar_t* TabTitleMemory=L"Memory";
|
|
||||||
const wchar_t* TabTitleName=L"Name";
|
|
||||||
const wchar_t* TabTitleTID=L"TID";
|
|
||||||
const wchar_t* TabTitleStart=L"Start";
|
|
||||||
const wchar_t* TabTitleModule=L"Module";
|
|
||||||
const wchar_t* TabTitleState=L"State";
|
|
||||||
const wchar_t* SuccessAttach=L"Attach ITH to process successfully.";
|
|
||||||
const wchar_t* FailAttach=L"Failed to attach ITH to process.";
|
|
||||||
const wchar_t* SuccessDetach=L"ITH detach from process.";
|
|
||||||
const wchar_t* FailDetach=L"Detach failed.";
|
|
||||||
//Profile window
|
|
||||||
const wchar_t* ProfileExist=L"Profile already exists.";
|
|
||||||
const wchar_t* SuccessAddProfile=L"Profile added.";
|
|
||||||
const wchar_t* FailAddProfile=L"Fail to add profile";
|
|
||||||
const wchar_t* TabTitleNumber=L"No.";
|
|
||||||
const wchar_t* NoFile=L"Can't find file.";
|
|
||||||
const wchar_t* PathDismatch=L"Process name dismatch, continue?";
|
|
||||||
const wchar_t* SuccessImportProfile=L"Import profile success";
|
|
||||||
//const wchar_t* SuccessAddProfile=L"Profile added.";
|
|
@ -1,86 +0,0 @@
|
|||||||
/* Copyright (C) 2010-2012 kaosu (qiupf2000@gmail.com)
|
|
||||||
* This file is part of the Interactive Text Hooker.
|
|
||||||
|
|
||||||
* Interactive Text Hooker is free software: you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU General Public License as published
|
|
||||||
* by the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
extern const wchar_t* Warning;
|
|
||||||
//command.cpp
|
|
||||||
extern const wchar_t* ErrorSyntax;
|
|
||||||
extern const wchar_t* Usage;
|
|
||||||
extern const wchar_t* ExtendedUsage;
|
|
||||||
//inject.cpp
|
|
||||||
extern const wchar_t* ErrorRemoteThread;
|
|
||||||
extern const wchar_t* ErrorOpenProcess;
|
|
||||||
extern const wchar_t* ErrorNoProcess;
|
|
||||||
extern const wchar_t* SelfAttach;
|
|
||||||
extern const wchar_t* AlreadyAttach;
|
|
||||||
extern const wchar_t* FormatInject;
|
|
||||||
//main.cpp
|
|
||||||
extern const wchar_t* NotAdmin;
|
|
||||||
//pipe.cpp
|
|
||||||
extern const wchar_t* ErrorCreatePipe;
|
|
||||||
extern const wchar_t* FormatDetach;
|
|
||||||
extern const wchar_t* ErrorCmdQueueFull;
|
|
||||||
extern const wchar_t* ErrorNoAttach;
|
|
||||||
|
|
||||||
//profile.cpp
|
|
||||||
extern const wchar_t* ErrorMonitor;
|
|
||||||
|
|
||||||
//utility.cpp
|
|
||||||
extern const wchar_t* InitMessage;
|
|
||||||
extern const wchar_t* BackgroundMsg;
|
|
||||||
extern const wchar_t* ErrorLinkExist;
|
|
||||||
extern const wchar_t* ErrorCylicLink;
|
|
||||||
extern const wchar_t* FormatLink;
|
|
||||||
extern const wchar_t* ErrorLink;
|
|
||||||
extern const wchar_t* ErrorDeleteCombo;
|
|
||||||
|
|
||||||
//window.cpp
|
|
||||||
extern const wchar_t* ClassName;
|
|
||||||
extern const wchar_t* ClassNameAdmin;
|
|
||||||
extern const wchar_t* ErrorNotSplit;
|
|
||||||
extern const wchar_t* ErrorNotModule;
|
|
||||||
//Main window buttons
|
|
||||||
extern const wchar_t* ButtonTitleProcess;
|
|
||||||
extern const wchar_t* ButtonTitleThread;
|
|
||||||
extern const wchar_t* ButtonTitleHook;
|
|
||||||
extern const wchar_t* ButtonTitleProfile;
|
|
||||||
extern const wchar_t* ButtonTitleOption;
|
|
||||||
extern const wchar_t* ButtonTitleClear;
|
|
||||||
extern const wchar_t* ButtonTitleSave;
|
|
||||||
extern const wchar_t* ButtonTitleTop;
|
|
||||||
//Hook window
|
|
||||||
extern const wchar_t* SpecialHook;
|
|
||||||
//Process window
|
|
||||||
extern const wchar_t* TabTitlePID;
|
|
||||||
extern const wchar_t* TabTitleMemory;
|
|
||||||
extern const wchar_t* TabTitleName;
|
|
||||||
extern const wchar_t* TabTitleTID;
|
|
||||||
extern const wchar_t* TabTitleStart;
|
|
||||||
extern const wchar_t* TabTitleModule;
|
|
||||||
extern const wchar_t* TabTitleState;
|
|
||||||
extern const wchar_t* SuccessAttach;
|
|
||||||
extern const wchar_t* FailAttach;
|
|
||||||
extern const wchar_t* SuccessDetach;
|
|
||||||
extern const wchar_t* FailDetach;
|
|
||||||
//Profile window
|
|
||||||
extern const wchar_t* ProfileExist;
|
|
||||||
extern const wchar_t* SuccessAddProfile;
|
|
||||||
extern const wchar_t* FailAddProfile;
|
|
||||||
extern const wchar_t* TabTitleNumber;
|
|
||||||
extern const wchar_t* NoFile;
|
|
||||||
extern const wchar_t* PathDismatch;
|
|
||||||
extern const wchar_t* SuccessImportProfile;
|
|
176
oldgui/main.cpp
176
oldgui/main.cpp
@ -1,176 +0,0 @@
|
|||||||
/* Copyright (C) 2010-2012 kaosu (qiupf2000@gmail.com)
|
|
||||||
* This file is part of the Interactive Text Hooker.
|
|
||||||
|
|
||||||
* Interactive Text Hooker is free software: you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU General Public License as published
|
|
||||||
* by the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "ITH.h"
|
|
||||||
#include "host.h"
|
|
||||||
#include "hookman.h"
|
|
||||||
#include "profile/Profile.h"
|
|
||||||
#include "ProfileManager.h"
|
|
||||||
|
|
||||||
HINSTANCE hIns;
|
|
||||||
ATOM MyRegisterClass(HINSTANCE hInstance);
|
|
||||||
BOOL InitInstance(HINSTANCE hInstance, DWORD nCmdShow, RECT *rc);
|
|
||||||
RECT window;
|
|
||||||
extern HWND hMainWnd; // windows.cpp
|
|
||||||
extern ProfileManager* pfman; // ProfileManager.cpp
|
|
||||||
|
|
||||||
HookManager* man;
|
|
||||||
LONG split_time;
|
|
||||||
|
|
||||||
std::map<std::wstring, long> setting;
|
|
||||||
|
|
||||||
void SaveSettings()
|
|
||||||
{
|
|
||||||
WINDOWPLACEMENT wndpl;
|
|
||||||
wndpl.length = sizeof(WINDOWPLACEMENT);
|
|
||||||
GetWindowPlacement(hMainWnd, &wndpl);
|
|
||||||
setting[L"window_left"] = wndpl.rcNormalPosition.left;
|
|
||||||
setting[L"window_right"] = wndpl.rcNormalPosition.right;
|
|
||||||
setting[L"window_top"] = wndpl.rcNormalPosition.top;
|
|
||||||
setting[L"window_bottom"] = wndpl.rcNormalPosition.bottom;
|
|
||||||
setting[L"split_time"] = split_time;
|
|
||||||
|
|
||||||
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"NextHookerSetting");
|
|
||||||
for (auto it = setting.begin(); it != setting.end(); ++it)
|
|
||||||
root.append_attribute(it->first.c_str()).set_value(it->second);
|
|
||||||
doc.save(fw);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void DefaultSettings()
|
|
||||||
{
|
|
||||||
setting[L"split_time"] = 200;
|
|
||||||
setting[L"window_left"] = 100;
|
|
||||||
setting[L"window_right"] = 800;
|
|
||||||
setting[L"window_top"] = 100;
|
|
||||||
setting[L"window_bottom"] = 600;
|
|
||||||
}
|
|
||||||
|
|
||||||
void InitializeSettings()
|
|
||||||
{
|
|
||||||
split_time = setting[L"split_time"];
|
|
||||||
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 (window.right < window.left || window.right - window.left < 600)
|
|
||||||
window.right = window.left + 600;
|
|
||||||
if (window.bottom < window.top || window.bottom - window.top < 200)
|
|
||||||
window.bottom = window.top + 200;
|
|
||||||
}
|
|
||||||
|
|
||||||
void LoadSettings()
|
|
||||||
{
|
|
||||||
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);
|
|
||||||
std::unique_ptr<char[]> buffer(new char[size]);
|
|
||||||
ReadFile(hFile.get(), buffer.get(), size, &size, NULL);
|
|
||||||
pugi::xml_document doc;
|
|
||||||
auto result = doc.load_buffer_inplace(buffer.get(), size);
|
|
||||||
if (!result)
|
|
||||||
return;
|
|
||||||
auto root = doc.root().child(L"NextHookerSetting");
|
|
||||||
for (auto attr = root.attributes_begin(); attr != root.attributes_end(); ++attr)
|
|
||||||
{
|
|
||||||
auto it = setting.find(attr->name());
|
|
||||||
if (it != setting.end())
|
|
||||||
it->second = std::stoul(attr->value());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
extern LPCWSTR ClassName, ClassNameAdmin;
|
|
||||||
static WCHAR mutex[] = L"ITH_RUNNING";
|
|
||||||
DWORD FindITH()
|
|
||||||
{
|
|
||||||
HWND hwnd = FindWindow(ClassName, ClassName);
|
|
||||||
if (hwnd == NULL)
|
|
||||||
hwnd = FindWindow(ClassName, ClassNameAdmin);
|
|
||||||
if (hwnd)
|
|
||||||
{
|
|
||||||
ShowWindow(hwnd, SW_SHOWNORMAL);
|
|
||||||
SetForegroundWindow(hwnd);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
LONG WINAPI UnhandledExcept(_EXCEPTION_POINTERS *ExceptionInfo)
|
|
||||||
{
|
|
||||||
wchar_t path_name[512]; // fully qualified path name
|
|
||||||
WCHAR code[16];
|
|
||||||
EXCEPTION_RECORD* rec = ExceptionInfo->ExceptionRecord;
|
|
||||||
std::swprintf(code, L"%08X", rec->ExceptionCode);
|
|
||||||
MEMORY_BASIC_INFORMATION info;
|
|
||||||
if (VirtualQuery(rec->ExceptionAddress, &info, sizeof(info)))
|
|
||||||
{
|
|
||||||
if (GetModuleFileName((HMODULE)info.AllocationBase, path_name, 512))
|
|
||||||
{
|
|
||||||
LPWSTR name = wcsrchr(path_name, L'\\');
|
|
||||||
if (name)
|
|
||||||
{
|
|
||||||
DWORD addr = (DWORD)rec->ExceptionAddress;
|
|
||||||
std::swprintf(name, L"%s:%08X", name + 1, addr - (DWORD)info.AllocationBase);
|
|
||||||
MessageBox(NULL, name, code, MB_OK);
|
|
||||||
TerminateProcess(GetCurrentProcess(), 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
std::swprintf(path_name, L"%08X", rec->ExceptionAddress);
|
|
||||||
MessageBox(NULL, path_name, code, MB_OK);
|
|
||||||
TerminateProcess(GetCurrentProcess(), 0);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
|
|
||||||
{
|
|
||||||
InitCommonControls();
|
|
||||||
if (StartHost())
|
|
||||||
{
|
|
||||||
SetUnhandledExceptionFilter(UnhandledExcept);
|
|
||||||
man = GetHostHookManager();
|
|
||||||
pfman = new ProfileManager();
|
|
||||||
DefaultSettings();
|
|
||||||
LoadSettings();
|
|
||||||
InitializeSettings();
|
|
||||||
man->SetSplitInterval(split_time);
|
|
||||||
hIns = hInstance;
|
|
||||||
MyRegisterClass(hIns);
|
|
||||||
InitInstance(hIns, FALSE, &window);
|
|
||||||
MSG msg;
|
|
||||||
while (GetMessage(&msg, NULL, 0, 0))
|
|
||||||
{
|
|
||||||
TranslateMessage(&msg);
|
|
||||||
DispatchMessage(&msg);
|
|
||||||
}
|
|
||||||
delete pfman;
|
|
||||||
man = NULL;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
FindITH();
|
|
||||||
}
|
|
||||||
CloseHost();
|
|
||||||
TerminateProcess(GetCurrentProcess(), 0);
|
|
||||||
}
|
|
@ -1,293 +0,0 @@
|
|||||||
/* Copyright (C) 2010-2012 kaosu (qiupf2000@gmail.com)
|
|
||||||
* This file is part of the Interactive Text Hooker.
|
|
||||||
|
|
||||||
* Interactive Text Hooker is free software: you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU General Public License as published
|
|
||||||
* by the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
#include "host.h"
|
|
||||||
#include "hookman.h"
|
|
||||||
#include "vnrhook/include/types.h"
|
|
||||||
#include "vnrhook/include/const.h"
|
|
||||||
#include "Profile.h"
|
|
||||||
#include "misc.h"
|
|
||||||
#include <algorithm>
|
|
||||||
#include "pugixml.h"
|
|
||||||
|
|
||||||
extern HookManager* man;
|
|
||||||
|
|
||||||
Profile::Profile(const std::wstring& title) :
|
|
||||||
select_index(-1),
|
|
||||||
title(title)
|
|
||||||
{}
|
|
||||||
|
|
||||||
const std::unordered_set<hook_ptr>& Profile::Hooks() const
|
|
||||||
{
|
|
||||||
return hooks;
|
|
||||||
}
|
|
||||||
|
|
||||||
const std::vector<thread_ptr>& Profile::Threads() const
|
|
||||||
{
|
|
||||||
return threads;
|
|
||||||
}
|
|
||||||
|
|
||||||
const std::unordered_set<link_ptr>& Profile::Links() const
|
|
||||||
{
|
|
||||||
return links;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Profile::XmlReadProfile(pugi::xml_node profile)
|
|
||||||
{
|
|
||||||
auto hooks_node = profile.child(L"Hooks");
|
|
||||||
auto threads_node = profile.child(L"Threads");
|
|
||||||
auto links_node = profile.child(L"Links");
|
|
||||||
if (hooks_node && !XmlReadProfileHook(hooks_node))
|
|
||||||
return false;
|
|
||||||
if (threads_node && !XmlReadProfileThread(threads_node))
|
|
||||||
return false;
|
|
||||||
if (links_node && !XmlReadProfileLink(links_node))
|
|
||||||
return false;
|
|
||||||
auto select_node = profile.child(L"Select");
|
|
||||||
if (select_node)
|
|
||||||
{
|
|
||||||
auto thread_index = select_node.attribute(L"ThreadIndex");
|
|
||||||
if (!thread_index)
|
|
||||||
return false;
|
|
||||||
DWORD tmp_select = std::stoul(thread_index.value(), NULL, 16);
|
|
||||||
select_index = tmp_select & 0xFFFF;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Profile::XmlReadProfileHook(pugi::xml_node hooks_node)
|
|
||||||
{
|
|
||||||
for (auto hook = hooks_node.begin(); hook != hooks_node.end(); ++hook)
|
|
||||||
{
|
|
||||||
std::wstring name = hook->name();
|
|
||||||
if (name.empty() || name.compare(L"Hook") != 0)
|
|
||||||
return false;
|
|
||||||
auto type = hook->attribute(L"Type");
|
|
||||||
if (!type || type.empty())
|
|
||||||
return false;
|
|
||||||
auto code = hook->attribute(L"Code");
|
|
||||||
if (!code)
|
|
||||||
return false;
|
|
||||||
std::wstring code_value = code.value();
|
|
||||||
HookParam hp = {};
|
|
||||||
switch (type.value()[0])
|
|
||||||
{
|
|
||||||
case L'H':
|
|
||||||
if (code_value[0] != L'/')
|
|
||||||
return false;
|
|
||||||
if (code_value[1] != L'H' && code_value[1] != L'h')
|
|
||||||
return false;
|
|
||||||
if (Parse(code_value.substr(2), hp))
|
|
||||||
{
|
|
||||||
auto name = hook->attribute(L"Name");
|
|
||||||
if (!name || name.empty())
|
|
||||||
AddHook(hook_ptr(new HookProfile(hp, L"")));
|
|
||||||
else
|
|
||||||
AddHook(hook_ptr(new HookProfile(hp, name.value())));
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Profile::XmlReadProfileThread(pugi::xml_node threads_node)
|
|
||||||
{
|
|
||||||
std::wstring hook_name_buffer;
|
|
||||||
for (auto thread = threads_node.begin(); thread != threads_node.end(); ++thread)
|
|
||||||
{
|
|
||||||
std::wstring name = thread->name();
|
|
||||||
if (name.empty() || name.compare(L"Thread") != 0)
|
|
||||||
return false;
|
|
||||||
auto hook_name = thread->attribute(L"HookName");
|
|
||||||
if (!hook_name)
|
|
||||||
return false;
|
|
||||||
auto context = thread->attribute(L"Context");
|
|
||||||
if (!context)
|
|
||||||
return false;
|
|
||||||
auto sub_context = thread->attribute(L"SubContext");
|
|
||||||
if (!sub_context)
|
|
||||||
return false;
|
|
||||||
auto mask = thread->attribute(L"Mask");
|
|
||||||
if (!mask)
|
|
||||||
return false;
|
|
||||||
DWORD mask_tmp = std::stoul(mask.value(), NULL, 16);
|
|
||||||
auto comment = thread->attribute(L"Comment");
|
|
||||||
auto retn = std::stoul(context.value(), NULL, 16);
|
|
||||||
auto split = std::stoul(sub_context.value(), NULL, 16);
|
|
||||||
WORD flags = mask_tmp & 0xFFFF;
|
|
||||||
auto tp = new ThreadProfile(hook_name.value(), retn, split, 0, 0, flags,
|
|
||||||
comment.value());
|
|
||||||
AddThread(thread_ptr(tp));
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Profile::XmlReadProfileLink(pugi::xml_node links_node)
|
|
||||||
{
|
|
||||||
for (auto link = links_node.begin(); link != links_node.end(); ++link)
|
|
||||||
{
|
|
||||||
std::wstring name = link->name();
|
|
||||||
if (name.empty() || name.compare(L"Link") != 0)
|
|
||||||
return false;
|
|
||||||
auto from = link->attribute(L"From");
|
|
||||||
if (!from)
|
|
||||||
return false;
|
|
||||||
DWORD link_from = std::stoul(from.value(), NULL, 16);
|
|
||||||
auto to = link->attribute(L"To");
|
|
||||||
if (!to)
|
|
||||||
return false;
|
|
||||||
DWORD link_to = std::stoul(to.value(), NULL, 16);
|
|
||||||
auto lp = new LinkProfile(link_from & 0xFFFF, link_to & 0xFFFF);
|
|
||||||
AddLink(link_ptr(lp));
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Profile::XmlWriteProfile(pugi::xml_node profile_node)
|
|
||||||
{
|
|
||||||
if (!hooks.empty())
|
|
||||||
{
|
|
||||||
auto node = profile_node.append_child(L"Hooks");
|
|
||||||
XmlWriteProfileHook(node);
|
|
||||||
}
|
|
||||||
if (!threads.empty())
|
|
||||||
{
|
|
||||||
auto node = profile_node.append_child(L"Threads");
|
|
||||||
XmlWriteProfileThread(node);
|
|
||||||
}
|
|
||||||
if (!links.empty())
|
|
||||||
{
|
|
||||||
auto node = profile_node.append_child(L"Links");
|
|
||||||
XmlWriteProfileLink(node);
|
|
||||||
}
|
|
||||||
if (select_index != 0xFFFF)
|
|
||||||
{
|
|
||||||
auto node = profile_node.append_child(L"Select");
|
|
||||||
node.append_attribute(L"ThreadIndex") = select_index;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Profile::XmlWriteProfileHook(pugi::xml_node hooks_node)
|
|
||||||
{
|
|
||||||
for (auto hook = hooks.begin(); hook != hooks.end(); ++hook)
|
|
||||||
{
|
|
||||||
auto hook_node = hooks_node.append_child(L"Hook");
|
|
||||||
hook_node.append_attribute(L"Type") = L"H";
|
|
||||||
hook_node.append_attribute(L"Code") = ParseCode((*hook)->HP()).c_str();
|
|
||||||
if (!(*hook)->Name().empty())
|
|
||||||
hook_node.append_attribute(L"Name") = (*hook)->Name().c_str();
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Profile::XmlWriteProfileThread(pugi::xml_node threads_node)
|
|
||||||
{
|
|
||||||
for (auto thread = threads.begin(); thread != threads.end(); ++thread)
|
|
||||||
{
|
|
||||||
const std::wstring& name = (*thread)->HookName();
|
|
||||||
if (name.empty())
|
|
||||||
return false;
|
|
||||||
auto node = threads_node.append_child(L"Thread");
|
|
||||||
node.append_attribute(L"HookName") = name.c_str();
|
|
||||||
std::wstring hex = ToHexString((*thread)->Flags() & (THREAD_MASK_RETN | THREAD_MASK_SPLIT));
|
|
||||||
node.append_attribute(L"Mask") = hex.c_str();
|
|
||||||
hex = ToHexString((*thread)->Split());
|
|
||||||
node.append_attribute(L"SubContext") = hex.c_str();
|
|
||||||
hex = ToHexString((*thread)->Return());
|
|
||||||
node.append_attribute(L"Context") = hex.c_str();
|
|
||||||
if (!(*thread)->Comment().empty())
|
|
||||||
node.append_attribute(L"Comment") = (*thread)->Comment().c_str();
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Profile::XmlWriteProfileLink(pugi::xml_node links_node)
|
|
||||||
{
|
|
||||||
for (auto link = links.begin(); link != links.end(); ++link)
|
|
||||||
{
|
|
||||||
auto node = links_node.append_child(L"Link");
|
|
||||||
node.append_attribute(L"From") = ToHexString((*link)->FromIndex()).c_str();
|
|
||||||
node.append_attribute(L"To") = ToHexString((*link)->ToIndex()).c_str();
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Profile::Clear()
|
|
||||||
{
|
|
||||||
title = L"";
|
|
||||||
select_index = -1;
|
|
||||||
hooks.clear();
|
|
||||||
threads.clear();
|
|
||||||
links.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Profile::AddHook(hook_ptr hook)
|
|
||||||
{
|
|
||||||
hooks.insert(std::move(hook));
|
|
||||||
}
|
|
||||||
|
|
||||||
// add the thread profile and return its index
|
|
||||||
int Profile::AddThread(thread_ptr tp)
|
|
||||||
{
|
|
||||||
auto it = std::find_if(threads.begin(), threads.end(), [&tp](thread_ptr& thread)
|
|
||||||
{
|
|
||||||
return thread->HookName().compare(tp->HookName()) == 0 &&
|
|
||||||
thread->Return() == tp->Return() &&
|
|
||||||
thread->Split() == tp->Split();
|
|
||||||
});
|
|
||||||
if (it != threads.end())
|
|
||||||
return it - threads.begin();
|
|
||||||
threads.push_back(std::move(tp));
|
|
||||||
return threads.size() - 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Profile::AddLink(link_ptr link)
|
|
||||||
{
|
|
||||||
links.insert(std::move(link));
|
|
||||||
}
|
|
||||||
|
|
||||||
const std::wstring& Profile::Title() const
|
|
||||||
{
|
|
||||||
return title;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Profile::IsThreadSelected(thread_ptr_iter thread_profile)
|
|
||||||
{
|
|
||||||
if (thread_profile != threads.end())
|
|
||||||
{
|
|
||||||
auto thread_index = thread_profile - threads.begin();
|
|
||||||
return select_index == thread_index;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
thread_ptr_iter Profile::FindThread(const ThreadParameter* tp, const std::wstring& hook_name) const
|
|
||||||
{
|
|
||||||
auto thread_profile = std::find_if(threads.begin(), threads.end(),
|
|
||||||
[&tp, &hook_name](const thread_ptr& thread_profile) -> bool
|
|
||||||
{
|
|
||||||
return thread_profile->HookName().compare(hook_name) == 0
|
|
||||||
&& thread_profile->Return() == tp->retn
|
|
||||||
&& thread_profile->Split() == tp->spl;
|
|
||||||
});
|
|
||||||
return thread_profile;
|
|
||||||
}
|
|
@ -1,171 +0,0 @@
|
|||||||
/* Copyright (C) 2010-2012 kaosu (qiupf2000@gmail.com)
|
|
||||||
* This file is part of the Interactive Text Hooker.
|
|
||||||
|
|
||||||
* Interactive Text Hooker is free software: you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU General Public License as published
|
|
||||||
* by the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include "vnrhook/include/types.h" // HookParam
|
|
||||||
#include <string>
|
|
||||||
#include <memory>
|
|
||||||
#include <vector>
|
|
||||||
#include <unordered_set>
|
|
||||||
|
|
||||||
struct ThreadParameter;
|
|
||||||
class TextThread;
|
|
||||||
class HookProfile;
|
|
||||||
class ThreadProfile;
|
|
||||||
class LinkProfile;
|
|
||||||
typedef std::unique_ptr<HookProfile> hook_ptr;
|
|
||||||
typedef std::unique_ptr<ThreadProfile> thread_ptr;
|
|
||||||
typedef std::unique_ptr<LinkProfile> link_ptr;
|
|
||||||
typedef std::vector<thread_ptr>::const_iterator thread_ptr_iter;
|
|
||||||
namespace pugi {
|
|
||||||
class xml_node;
|
|
||||||
}
|
|
||||||
|
|
||||||
#define THREAD_MASK_RETN 1
|
|
||||||
#define THREAD_MASK_SPLIT 2
|
|
||||||
|
|
||||||
class HookProfile
|
|
||||||
{
|
|
||||||
HookParam hp;
|
|
||||||
std::wstring name;
|
|
||||||
public:
|
|
||||||
HookProfile(const HookParam& hp, const std::wstring& name) :
|
|
||||||
hp(hp),
|
|
||||||
name(name)
|
|
||||||
{}
|
|
||||||
const HookParam& HP() const { return hp; };
|
|
||||||
const std::wstring& Name() const { return name; };
|
|
||||||
};
|
|
||||||
|
|
||||||
class ThreadProfile
|
|
||||||
{
|
|
||||||
std::wstring hook_name;
|
|
||||||
DWORD retn;
|
|
||||||
DWORD split;
|
|
||||||
DWORD hook_addr;
|
|
||||||
WORD hm_index, flags;
|
|
||||||
std::wstring comment;
|
|
||||||
public:
|
|
||||||
ThreadProfile(const std::wstring& hook_name,
|
|
||||||
DWORD retn,
|
|
||||||
DWORD split,
|
|
||||||
DWORD hook_addr,
|
|
||||||
WORD hm_index,
|
|
||||||
WORD flags,
|
|
||||||
const std::wstring& comment) :
|
|
||||||
hook_name(hook_name),
|
|
||||||
retn(retn),
|
|
||||||
split(split),
|
|
||||||
hook_addr(hook_addr),
|
|
||||||
hm_index(hm_index),
|
|
||||||
flags(flags),
|
|
||||||
comment(comment)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
const std::wstring& HookName() const { return hook_name; }
|
|
||||||
const std::wstring& Comment() const { return comment; }
|
|
||||||
DWORD Return() const { return retn; }
|
|
||||||
DWORD Split() const { return split; }
|
|
||||||
DWORD& HookAddress() { return hook_addr; }
|
|
||||||
WORD& HookManagerIndex() { return hm_index; }
|
|
||||||
WORD Flags() const { return flags; }
|
|
||||||
};
|
|
||||||
|
|
||||||
class LinkProfile
|
|
||||||
{
|
|
||||||
WORD from_index, to_index;
|
|
||||||
public:
|
|
||||||
LinkProfile(WORD from_index, WORD to_index) :
|
|
||||||
from_index(from_index),
|
|
||||||
to_index(to_index)
|
|
||||||
{}
|
|
||||||
WORD FromIndex() const { return from_index; }
|
|
||||||
WORD ToIndex() const { return to_index; }
|
|
||||||
};
|
|
||||||
|
|
||||||
namespace std {
|
|
||||||
template<>
|
|
||||||
struct hash<hook_ptr> {
|
|
||||||
size_t operator()(const hook_ptr &r) const
|
|
||||||
{
|
|
||||||
return hash<DWORD>{}(r->HP().address)
|
|
||||||
^ hash<DWORD>{}(r->HP().module)
|
|
||||||
^ hash<DWORD>{}(r->HP().function);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
template<>
|
|
||||||
struct equal_to<hook_ptr> {
|
|
||||||
bool operator()(const hook_ptr& r, const hook_ptr& r2) const
|
|
||||||
{
|
|
||||||
return r->HP().address == r2->HP().address
|
|
||||||
&& r->HP().module == r2->HP().module
|
|
||||||
&& r->HP().function == r2->HP().function;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
template<>
|
|
||||||
struct hash<link_ptr> {
|
|
||||||
size_t operator()(const link_ptr &r) const
|
|
||||||
{
|
|
||||||
return hash<WORD>{}(r->FromIndex())
|
|
||||||
^ hash<WORD>{}(r->ToIndex());
|
|
||||||
}
|
|
||||||
};
|
|
||||||
template<>
|
|
||||||
struct equal_to<link_ptr> {
|
|
||||||
bool operator()(const link_ptr& r, const link_ptr& r2) const
|
|
||||||
{
|
|
||||||
return r->FromIndex() == r2->FromIndex()
|
|
||||||
&& r->ToIndex() == r2->ToIndex();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
class Profile
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
Profile(const std::wstring& title);
|
|
||||||
bool XmlReadProfile(pugi::xml_node profile_node);
|
|
||||||
bool XmlWriteProfile(pugi::xml_node profile_node);
|
|
||||||
void AddHook(hook_ptr hook);
|
|
||||||
int AddThread(thread_ptr tp);
|
|
||||||
void AddLink(link_ptr lp);
|
|
||||||
void Clear();
|
|
||||||
const std::unordered_set<hook_ptr>& Hooks() const;
|
|
||||||
const std::vector<thread_ptr>& Threads() const;
|
|
||||||
const std::unordered_set<link_ptr>& Links() const;
|
|
||||||
const std::wstring& Title() const;
|
|
||||||
thread_ptr_iter FindThread(const ThreadParameter* tp, const std::wstring& hook_name) const;
|
|
||||||
WORD& SelectedIndex() { return select_index; }
|
|
||||||
bool IsThreadSelected(thread_ptr_iter thread_profile);
|
|
||||||
|
|
||||||
private:
|
|
||||||
bool XmlReadProfileHook(pugi::xml_node hooks_node);
|
|
||||||
bool XmlReadProfileThread(pugi::xml_node threads_node);
|
|
||||||
bool XmlReadProfileLink(pugi::xml_node links_node);
|
|
||||||
bool XmlWriteProfileHook(pugi::xml_node hooks_node);
|
|
||||||
bool XmlWriteProfileThread(pugi::xml_node threads_node);
|
|
||||||
bool XmlWriteProfileLink(pugi::xml_node links_node);
|
|
||||||
|
|
||||||
std::wstring title;
|
|
||||||
std::unordered_set<hook_ptr> hooks;
|
|
||||||
std::vector<thread_ptr> threads;
|
|
||||||
std::unordered_set<link_ptr> links;
|
|
||||||
|
|
||||||
WORD select_index;
|
|
||||||
};
|
|
@ -1,275 +0,0 @@
|
|||||||
#include "misc.h"
|
|
||||||
#include <regex>
|
|
||||||
#include <memory>
|
|
||||||
#include "host.h"
|
|
||||||
#include "vnrhook/include/const.h"
|
|
||||||
#include "vnrhook/include/types.h"
|
|
||||||
|
|
||||||
DWORD Hash(const std::wstring& module, int length)
|
|
||||||
{
|
|
||||||
DWORD hash = 0;
|
|
||||||
auto end = (length < 0 || static_cast<size_t>(length) > module.length()) ?
|
|
||||||
module.end() :
|
|
||||||
module.begin() + length;
|
|
||||||
for (auto it = module.begin(); it != end; ++it)
|
|
||||||
hash = _rotr(hash, 7) + *it;
|
|
||||||
return hash;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Parse(const std::wstring& cmd, HookParam& hp)
|
|
||||||
{
|
|
||||||
using std::wregex;
|
|
||||||
using std::regex_search;
|
|
||||||
// /H[X]{A|B|W|S|Q}[N][data_offset[*drdo]][:sub_offset[*drso]]@addr[:[module[:{name|#ordinal}]]]
|
|
||||||
wregex rx(L"^X?([ABWSQ])(N)?", wregex::icase);
|
|
||||||
std::match_results<std::wstring::const_iterator> m;
|
|
||||||
auto start = cmd.begin();
|
|
||||||
auto end = cmd.end();
|
|
||||||
bool result = regex_search(start, end, m, rx);
|
|
||||||
if (!result)
|
|
||||||
return result;
|
|
||||||
start = m[0].second;
|
|
||||||
if (m[2].matched)
|
|
||||||
hp.type |= NO_CONTEXT;
|
|
||||||
|
|
||||||
switch (m[1].first[0])
|
|
||||||
{
|
|
||||||
case L's':
|
|
||||||
case L'S':
|
|
||||||
hp.type |= USING_STRING;
|
|
||||||
break;
|
|
||||||
case L'e':
|
|
||||||
case L'E':
|
|
||||||
hp.type |= STRING_LAST_CHAR;
|
|
||||||
case L'a':
|
|
||||||
case L'A':
|
|
||||||
hp.type |= BIG_ENDIAN;
|
|
||||||
hp.length_offset = 1;
|
|
||||||
break;
|
|
||||||
case L'b':
|
|
||||||
case L'B':
|
|
||||||
hp.length_offset = 1;
|
|
||||||
break;
|
|
||||||
case L'h':
|
|
||||||
case L'H':
|
|
||||||
hp.type |= PRINT_DWORD;
|
|
||||||
case L'q':
|
|
||||||
case L'Q':
|
|
||||||
hp.type |= USING_STRING | USING_UNICODE;
|
|
||||||
break;
|
|
||||||
case L'l':
|
|
||||||
case L'L':
|
|
||||||
hp.type |= STRING_LAST_CHAR;
|
|
||||||
case L'w':
|
|
||||||
case L'W':
|
|
||||||
hp.type |= USING_UNICODE;
|
|
||||||
hp.length_offset = 1;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
// [data_offset[*drdo]]
|
|
||||||
std::wstring data_offset(L"(-?[[:xdigit:]]+)"), drdo(L"(\\*-?[[:xdigit:]]+)?");
|
|
||||||
rx = wregex(L"^" + data_offset + drdo, wregex::icase);
|
|
||||||
result = regex_search(start, end, m, rx);
|
|
||||||
if (result)
|
|
||||||
{
|
|
||||||
start = m[0].second;
|
|
||||||
hp.offset = std::stoul(m[1].str(), NULL, 16);
|
|
||||||
if (m[2].matched)
|
|
||||||
{
|
|
||||||
hp.type |= DATA_INDIRECT;
|
|
||||||
hp.index = std::stoul(m[2].str().substr(1), NULL, 16);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// [:sub_offset[*drso]]
|
|
||||||
std::wstring sub_offset(L"(-?[[:xdigit:]]+)"), drso(L"(\\*-?[[:xdigit:]]+)?");
|
|
||||||
rx = wregex(L"^:" + sub_offset + drso, wregex::icase);
|
|
||||||
result = regex_search(start, end, m, rx);
|
|
||||||
if (result)
|
|
||||||
{
|
|
||||||
start = m[0].second;
|
|
||||||
hp.type |= USING_SPLIT;
|
|
||||||
hp.split = std::stoul(m[1].str(), NULL, 16);
|
|
||||||
if (m[2].matched)
|
|
||||||
{
|
|
||||||
hp.type |= SPLIT_INDIRECT;
|
|
||||||
hp.split_index = std::stoul(m[2].str().substr(1), NULL, 16);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// @addr
|
|
||||||
rx = wregex(L"^@[[:xdigit:]]+", wregex::icase);
|
|
||||||
result = regex_search(start, end, m, rx);
|
|
||||||
if (!result)
|
|
||||||
return false;
|
|
||||||
start = m[0].second;
|
|
||||||
hp.address = std::stoul(m[0].str().substr(1), NULL, 16);
|
|
||||||
if (hp.offset & 0x80000000)
|
|
||||||
hp.offset -= 4;
|
|
||||||
if (hp.split & 0x80000000)
|
|
||||||
hp.split -= 4;
|
|
||||||
|
|
||||||
// [:[module[:{name|#ordinal}]]]
|
|
||||||
// ":" -> module == NULL &% function == NULL
|
|
||||||
// "" -> MODULE_OFFSET && module == NULL && function == addr
|
|
||||||
// ":GDI.dll" -> MODULE_OFFSET && module != NULL
|
|
||||||
// ":GDI.dll:strlen" -> MODULE_OFFSET | FUNCTION_OFFSET && module != NULL && function != NULL
|
|
||||||
// ":GDI.dll:#123" -> MODULE_OFFSET | FUNCTION_OFFSET && module != NULL && function != NULL
|
|
||||||
std::wstring module(L"([^:]+)"), name(L"[^:[:space:]]+"), ordinal(L"\\d+");
|
|
||||||
rx = wregex(L"^:(" + module + L"(:" + name + L"|#" + ordinal + L")?)?$", wregex::icase);
|
|
||||||
result = regex_search(start, end, m, rx);
|
|
||||||
if (result) // :[module[:{name|#ordinal}]]
|
|
||||||
{
|
|
||||||
if (m[1].matched) // module
|
|
||||||
{
|
|
||||||
hp.type |= MODULE_OFFSET;
|
|
||||||
std::wstring module = m[2];
|
|
||||||
std::transform(module.begin(), module.end(), module.begin(), ::towlower);
|
|
||||||
hp.module = Hash(module);
|
|
||||||
if (m[3].matched) // :name|#ordinal
|
|
||||||
{
|
|
||||||
hp.type |= FUNCTION_OFFSET;
|
|
||||||
hp.function = Hash(m[3].str().substr(1));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
rx = wregex(L"^!([[:xdigit:]]+)(!([[:xdigit:]]+))?$", wregex::icase);
|
|
||||||
result = regex_search(start, end, m, rx);
|
|
||||||
if (result)
|
|
||||||
{
|
|
||||||
hp.type |= MODULE_OFFSET;
|
|
||||||
hp.module = std::stoul(m[1].str(), NULL, 16);
|
|
||||||
if (m[2].matched)
|
|
||||||
{
|
|
||||||
hp.type |= FUNCTION_OFFSET;
|
|
||||||
hp.function = std::stoul(m[2].str().substr(1), NULL, 16);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Hack. Hook is relative to the executable. Store the original address in function.
|
|
||||||
// hp.module == NULL && hp.function != NULL
|
|
||||||
hp.type |= MODULE_OFFSET;
|
|
||||||
hp.function = hp.address;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::wstring ParseCode(const HookParam& hp)
|
|
||||||
{
|
|
||||||
std::wstring code(L"/H");
|
|
||||||
WCHAR c;
|
|
||||||
if (hp.type & PRINT_DWORD)
|
|
||||||
c = L'H';
|
|
||||||
else if (hp.type & USING_UNICODE)
|
|
||||||
{
|
|
||||||
if (hp.type & USING_STRING)
|
|
||||||
c = L'Q';
|
|
||||||
else if (hp.type & STRING_LAST_CHAR)
|
|
||||||
c = L'L';
|
|
||||||
else
|
|
||||||
c = L'W';
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (hp.type & USING_STRING)
|
|
||||||
c = L'S';
|
|
||||||
else if (hp.type & BIG_ENDIAN)
|
|
||||||
c = L'A';
|
|
||||||
else if (hp.type & STRING_LAST_CHAR)
|
|
||||||
c = L'E';
|
|
||||||
else
|
|
||||||
c = L'B';
|
|
||||||
}
|
|
||||||
code += c;
|
|
||||||
if (hp.type & NO_CONTEXT)
|
|
||||||
code += L'N';
|
|
||||||
if (hp.offset >> 31)
|
|
||||||
code += L'-' + ToHexString(-(hp.offset + 4));
|
|
||||||
else
|
|
||||||
code += ToHexString(hp.offset);
|
|
||||||
if (hp.type & DATA_INDIRECT)
|
|
||||||
{
|
|
||||||
if (hp.index >> 31)
|
|
||||||
code += L'*-' + ToHexString(-hp.index);
|
|
||||||
else
|
|
||||||
code += L'*' + ToHexString(hp.index);
|
|
||||||
}
|
|
||||||
if (hp.type & USING_SPLIT)
|
|
||||||
{
|
|
||||||
if (hp.split >> 31)
|
|
||||||
code += L":-" + ToHexString(-(4 + hp.split));
|
|
||||||
else
|
|
||||||
code += L":" + ToHexString(hp.split);
|
|
||||||
}
|
|
||||||
if (hp.type & SPLIT_INDIRECT)
|
|
||||||
{
|
|
||||||
if (hp.split_index >> 31)
|
|
||||||
code += L"*-" + ToHexString(-hp.split_index);
|
|
||||||
else
|
|
||||||
code += L"*" + ToHexString(hp.split_index);
|
|
||||||
}
|
|
||||||
if (hp.module)
|
|
||||||
{
|
|
||||||
code += L"@" + ToHexString(hp.address) + L"!" + ToHexString(hp.module);
|
|
||||||
if (hp.function)
|
|
||||||
code += L"!" + ToHexString(hp.function);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Hack. The original address is stored in the function field
|
|
||||||
// if (module == NULL && function != NULL).
|
|
||||||
// MODULE_OFFSET and FUNCTION_OFFSET are removed from HookParam.type in
|
|
||||||
// TextHook::UnsafeInsertHookCode() and can not be used here.
|
|
||||||
if (hp.function)
|
|
||||||
code += L"@" + ToHexString(hp.function);
|
|
||||||
else
|
|
||||||
code += L"@" + ToHexString(hp.address) + L":";
|
|
||||||
}
|
|
||||||
return code;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
std::string toMultiByteString(const std::wstring& unicodeString)
|
|
||||||
{
|
|
||||||
int cbMultiByte = WideCharToMultiByte(932, 0, unicodeString.c_str(), unicodeString.length(),
|
|
||||||
NULL, 0, NULL, NULL);
|
|
||||||
auto lpMultiByteStr = std::make_unique<CHAR[]>(cbMultiByte);
|
|
||||||
WideCharToMultiByte(932, 0, unicodeString.c_str(), unicodeString.length(),
|
|
||||||
lpMultiByteStr.get(), cbMultiByte, NULL, NULL);
|
|
||||||
return std::string(lpMultiByteStr.get(), cbMultiByte);
|
|
||||||
}
|
|
||||||
|
|
||||||
std::wstring toUnicodeString(const std::string& mbString)
|
|
||||||
{
|
|
||||||
int cchWideChar = MultiByteToWideChar(932, 0, mbString.c_str(), mbString.length(), NULL, 0);
|
|
||||||
auto lpWideCharStr = std::make_unique<WCHAR[]>(cchWideChar);
|
|
||||||
MultiByteToWideChar(932, 0, mbString.c_str(), mbString.length(), lpWideCharStr.get(), cchWideChar);
|
|
||||||
return std::wstring(lpWideCharStr.get(), cchWideChar);
|
|
||||||
}
|
|
||||||
|
|
||||||
std::wstring GetHookNameByAddress(const ProcessRecord& pr, DWORD hook_address)
|
|
||||||
{
|
|
||||||
std::wstring hook_name;
|
|
||||||
WaitForSingleObject(pr.hookman_mutex, 0);
|
|
||||||
auto hooks = (const Hook*)pr.hookman_map;
|
|
||||||
for (int i = 0; i < MAX_HOOK; ++i)
|
|
||||||
{
|
|
||||||
auto& hook = hooks[i];
|
|
||||||
if (hook.Address() == hook_address)
|
|
||||||
{
|
|
||||||
std::unique_ptr<CHAR[]> name(new CHAR[hook.NameLength()]);
|
|
||||||
// name is zero terminated
|
|
||||||
if (ReadProcessMemory(pr.process_handle, hooks[i].Name(), name.get(), hook.NameLength(), NULL))
|
|
||||||
hook_name = toUnicodeString(name.get());
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ReleaseMutex(pr.hookman_mutex);
|
|
||||||
return hook_name;
|
|
||||||
}
|
|
@ -1,22 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
#include <Windows.h>
|
|
||||||
#include <string>
|
|
||||||
#include <sstream>
|
|
||||||
|
|
||||||
struct HookParam;
|
|
||||||
struct ProcessRecord;
|
|
||||||
|
|
||||||
bool Parse(const std::wstring& cmd, HookParam& hp);
|
|
||||||
DWORD Hash(const std::wstring& module, int length = -1);
|
|
||||||
std::wstring ParseCode(const HookParam& hp);
|
|
||||||
std::string toMultiByteString(const std::wstring& unicodeString);
|
|
||||||
std::wstring toUnicodeString(const std::string& mbString);
|
|
||||||
std::wstring GetHookNameByAddress(const ProcessRecord& pr, DWORD hook_address);
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
std::wstring ToHexString(T i) {
|
|
||||||
std::wstringstream ss;
|
|
||||||
ss << std::uppercase << std::hex << i;
|
|
||||||
return ss.str();
|
|
||||||
}
|
|
@ -1,71 +0,0 @@
|
|||||||
/**
|
|
||||||
* pugixml parser - version 1.6
|
|
||||||
* --------------------------------------------------------
|
|
||||||
* Copyright (C) 2006-2015, by Arseny Kapoulkine (arseny.kapoulkine@gmail.com)
|
|
||||||
* Report bugs and download new versions at http://pugixml.org/
|
|
||||||
*
|
|
||||||
* This library is distributed under the MIT License. See notice at the end
|
|
||||||
* of this file.
|
|
||||||
*
|
|
||||||
* This work is based on the pugxml parser, which is:
|
|
||||||
* Copyright (C) 2003, by Kristen Wegner (kristen@tima.net)
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef HEADER_PUGICONFIG_HPP
|
|
||||||
#define HEADER_PUGICONFIG_HPP
|
|
||||||
|
|
||||||
// Uncomment this to enable wchar_t mode
|
|
||||||
#define PUGIXML_WCHAR_MODE
|
|
||||||
|
|
||||||
// Uncomment this to disable XPath
|
|
||||||
// #define PUGIXML_NO_XPATH
|
|
||||||
|
|
||||||
// Uncomment this to disable STL
|
|
||||||
// #define PUGIXML_NO_STL
|
|
||||||
|
|
||||||
// Uncomment this to disable exceptions
|
|
||||||
// #define PUGIXML_NO_EXCEPTIONS
|
|
||||||
|
|
||||||
// Set this to control attributes for public classes/functions, i.e.:
|
|
||||||
// #define PUGIXML_API __declspec(dllexport) // to export all public symbols from DLL
|
|
||||||
// #define PUGIXML_CLASS __declspec(dllimport) // to import all classes from DLL
|
|
||||||
// #define PUGIXML_FUNCTION __fastcall // to set calling conventions to all public functions to fastcall
|
|
||||||
// In absence of PUGIXML_CLASS/PUGIXML_FUNCTION definitions PUGIXML_API is used instead
|
|
||||||
|
|
||||||
// Tune these constants to adjust memory-related behavior
|
|
||||||
// #define PUGIXML_MEMORY_PAGE_SIZE 32768
|
|
||||||
// #define PUGIXML_MEMORY_OUTPUT_STACK 10240
|
|
||||||
// #define PUGIXML_MEMORY_XPATH_PAGE_SIZE 4096
|
|
||||||
|
|
||||||
// Uncomment this to switch to header-only version
|
|
||||||
// #define PUGIXML_HEADER_ONLY
|
|
||||||
|
|
||||||
// Uncomment this to enable long long support
|
|
||||||
// #define PUGIXML_HAS_LONG_LONG
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Copyright (c) 2006-2015 Arseny Kapoulkine
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person
|
|
||||||
* obtaining a copy of this software and associated documentation
|
|
||||||
* files (the "Software"), to deal in the Software without
|
|
||||||
* restriction, including without limitation the rights to use,
|
|
||||||
* copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
* copies of the Software, and to permit persons to whom the
|
|
||||||
* Software is furnished to do so, subject to the following
|
|
||||||
* conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be
|
|
||||||
* included in all copies or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
||||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
|
||||||
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
||||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
|
||||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
||||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
||||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|
||||||
* OTHER DEALINGS IN THE SOFTWARE.
|
|
||||||
*/
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,14 +0,0 @@
|
|||||||
#ifndef IDC_STATIC
|
|
||||||
#define IDC_STATIC (-1)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define IDD_DIALOG2 102
|
|
||||||
#define IDD_DIALOG4 104
|
|
||||||
#define IDI_ICON1 110
|
|
||||||
#define IDC_EDIT1 1011
|
|
||||||
#define IDC_BUTTON1 1020
|
|
||||||
#define IDC_BUTTON2 1021
|
|
||||||
#define IDC_BUTTON3 1022
|
|
||||||
#define IDC_BUTTON5 1024
|
|
||||||
#define IDC_LIST1 1028
|
|
||||||
#define IDC_BUTTON6 40000
|
|
@ -1,302 +0,0 @@
|
|||||||
/* Copyright (C) 2010-2012 kaosu (qiupf2000@gmail.com)
|
|
||||||
* This file is part of the Interactive Text Hooker.
|
|
||||||
|
|
||||||
* Interactive Text Hooker is free software: you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU General Public License as published
|
|
||||||
* by the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "utility.h"
|
|
||||||
#include "host.h"
|
|
||||||
#include "hookman.h"
|
|
||||||
#include "vnrhook/include/types.h"
|
|
||||||
#include "vnrhook/include/const.h"
|
|
||||||
#include "profile/misc.h"
|
|
||||||
|
|
||||||
extern HookManager* man; // main.cpp
|
|
||||||
|
|
||||||
std::wstring GetDriveLetter(const std::wstring& devicePath);
|
|
||||||
std::wstring GetWindowsPath(const std::wstring& fileObjectPath);
|
|
||||||
PVOID GetAllocationBase(DWORD pid, LPCVOID);
|
|
||||||
std::wstring GetModuleFileNameAsString(DWORD pid, PVOID allocationBase);
|
|
||||||
std::wstring GetModuleFileNameAsString();
|
|
||||||
std::wstring GetProcessPath(HANDLE hProc);
|
|
||||||
|
|
||||||
void ConsoleOutput(LPCWSTR text)
|
|
||||||
{
|
|
||||||
man->AddConsoleOutput(text);
|
|
||||||
}
|
|
||||||
|
|
||||||
std::wstring GetProcessPath(DWORD pid)
|
|
||||||
{
|
|
||||||
UniqueHandle hProc(OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, pid));
|
|
||||||
if (hProc)
|
|
||||||
return GetProcessPath(hProc.get());
|
|
||||||
else
|
|
||||||
return L"";
|
|
||||||
}
|
|
||||||
|
|
||||||
std::wstring GetProcessPath(HANDLE hProc)
|
|
||||||
{
|
|
||||||
wchar_t path[MAX_PATH];
|
|
||||||
GetProcessImageFileName(hProc, path, MAX_PATH);
|
|
||||||
return GetWindowsPath(path);
|
|
||||||
}
|
|
||||||
|
|
||||||
std::wstring GetWindowsPath(const std::wstring& path)
|
|
||||||
{
|
|
||||||
// path is in device form
|
|
||||||
// \Device\HarddiskVolume2\Windows\System32\taskhost.exe
|
|
||||||
auto pathOffset = path.find(L'\\', 1) + 1;
|
|
||||||
pathOffset = path.find(L'\\', pathOffset);
|
|
||||||
std::wstring devicePath = path.substr(0, pathOffset); // \Device\HarddiskVolume2
|
|
||||||
std::wstring dosDrive = GetDriveLetter(devicePath); // C:
|
|
||||||
if (dosDrive.empty())
|
|
||||||
return path;
|
|
||||||
std::wstring dosPath = dosDrive; // C:
|
|
||||||
dosPath += path.substr(pathOffset); // C:\Windows\System32\taskhost.exe
|
|
||||||
return dosPath;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::wstring GetDriveLetter(const std::wstring& devicePath)
|
|
||||||
{
|
|
||||||
for (wchar_t drive = L'A'; drive <= L'Z'; drive++)
|
|
||||||
{
|
|
||||||
wchar_t szDriveName[3] = { drive, L':', L'\0' };
|
|
||||||
wchar_t szTarget[512];
|
|
||||||
if (QueryDosDevice(szDriveName, szTarget, 512))
|
|
||||||
if (devicePath.compare(szTarget) == 0)
|
|
||||||
return szDriveName;
|
|
||||||
}
|
|
||||||
return L"";
|
|
||||||
}
|
|
||||||
|
|
||||||
std::wstring GetCode(const HookParam& hp, DWORD pid)
|
|
||||||
{
|
|
||||||
std::wstring code(L"/H");
|
|
||||||
WCHAR c;
|
|
||||||
if (hp.type & PRINT_DWORD)
|
|
||||||
c = L'H';
|
|
||||||
else if (hp.type & USING_UNICODE)
|
|
||||||
{
|
|
||||||
if (hp.type & USING_STRING)
|
|
||||||
c = L'Q';
|
|
||||||
else if (hp.type & STRING_LAST_CHAR)
|
|
||||||
c = L'L';
|
|
||||||
else
|
|
||||||
c = L'W';
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (hp.type & USING_STRING)
|
|
||||||
c = L'S';
|
|
||||||
else if (hp.type & BIG_ENDIAN)
|
|
||||||
c = L'A';
|
|
||||||
else if (hp.type & STRING_LAST_CHAR)
|
|
||||||
c = L'E';
|
|
||||||
else
|
|
||||||
c = L'B';
|
|
||||||
}
|
|
||||||
code += c;
|
|
||||||
if (hp.type & NO_CONTEXT)
|
|
||||||
code += L'N';
|
|
||||||
if (hp.offset >> 31)
|
|
||||||
code += L"-" + ToHexString(-(hp.offset + 4));
|
|
||||||
else
|
|
||||||
code += ToHexString(hp.offset);
|
|
||||||
if (hp.type & DATA_INDIRECT)
|
|
||||||
{
|
|
||||||
if (hp.index >> 31)
|
|
||||||
code += L"*-" + ToHexString(-hp.index);
|
|
||||||
else
|
|
||||||
code += L"*" + ToHexString(hp.index);
|
|
||||||
}
|
|
||||||
if (hp.type & USING_SPLIT)
|
|
||||||
{
|
|
||||||
if (hp.split >> 31)
|
|
||||||
code += L":-" + ToHexString(-(4 + hp.split));
|
|
||||||
else
|
|
||||||
code += L":" + ToHexString(hp.split);
|
|
||||||
}
|
|
||||||
if (hp.type & SPLIT_INDIRECT)
|
|
||||||
{
|
|
||||||
if (hp.split_index >> 31)
|
|
||||||
code += L"*-" + ToHexString(-hp.split_index);
|
|
||||||
else
|
|
||||||
code += L"*" + ToHexString(hp.split_index);
|
|
||||||
}
|
|
||||||
if (pid)
|
|
||||||
{
|
|
||||||
PVOID allocationBase = GetAllocationBase(pid, (LPCVOID)hp.address);
|
|
||||||
if (allocationBase)
|
|
||||||
{
|
|
||||||
std::wstring path = GetModuleFileNameAsString(pid, allocationBase);
|
|
||||||
if (!path.empty())
|
|
||||||
{
|
|
||||||
auto fileName = path.substr(path.rfind(L'\\') + 1);
|
|
||||||
DWORD relativeHookAddress = hp.address - (DWORD)allocationBase;
|
|
||||||
code += L"@" + ToHexString(relativeHookAddress) + L":" + fileName;
|
|
||||||
return code;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (hp.module)
|
|
||||||
{
|
|
||||||
code += L"@" + ToHexString(hp.address) + L"!" + ToHexString(hp.module);
|
|
||||||
if (hp.function)
|
|
||||||
code += L"!" + ToHexString(hp.function);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Hack. The original address is stored in the function field
|
|
||||||
// if (module == NULL && function != NULL).
|
|
||||||
// MODULE_OFFSET and FUNCTION_OFFSET are removed from HookParam.type in
|
|
||||||
// TextHook::UnsafeInsertHookCode() and can not be used here.
|
|
||||||
if (hp.function)
|
|
||||||
code += L"@" + ToHexString(hp.function);
|
|
||||||
else
|
|
||||||
code += L"@" + ToHexString(hp.address) + L":";
|
|
||||||
}
|
|
||||||
return code;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::wstring GetModuleFileNameAsString(DWORD pid, PVOID allocationBase)
|
|
||||||
{
|
|
||||||
UniqueHandle hProc(OpenProcess(PROCESS_ALL_ACCESS, FALSE, pid));
|
|
||||||
if (hProc.get())
|
|
||||||
{
|
|
||||||
WCHAR path[MAX_PATH];
|
|
||||||
if (GetModuleFileNameEx(hProc.get(), (HMODULE)allocationBase, path, MAX_PATH))
|
|
||||||
return path;
|
|
||||||
}
|
|
||||||
return L"";
|
|
||||||
}
|
|
||||||
|
|
||||||
PVOID GetAllocationBase(DWORD pid, LPCVOID addr)
|
|
||||||
{
|
|
||||||
UniqueHandle hProc(OpenProcess(PROCESS_ALL_ACCESS, FALSE, pid));
|
|
||||||
if (hProc.get())
|
|
||||||
{
|
|
||||||
MEMORY_BASIC_INFORMATION info;
|
|
||||||
if (VirtualQueryEx(hProc.get(), addr, &info, sizeof(info)))
|
|
||||||
{
|
|
||||||
if (info.Type & MEM_IMAGE)
|
|
||||||
return info.AllocationBase;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
struct TitleParam
|
|
||||||
{
|
|
||||||
DWORD pid, buffer_len, retn_len;
|
|
||||||
std::wstring buffer;
|
|
||||||
};
|
|
||||||
|
|
||||||
BOOL CALLBACK EnumProc(HWND hwnd, LPARAM lParam)
|
|
||||||
{
|
|
||||||
TitleParam* p = (TitleParam*)lParam;
|
|
||||||
DWORD pid;
|
|
||||||
GetWindowThreadProcessId(hwnd, &pid);
|
|
||||||
if (pid == p->pid)
|
|
||||||
{
|
|
||||||
if (GetWindowLong(hwnd, GWL_STYLE) & WS_VISIBLE)
|
|
||||||
{
|
|
||||||
int len = GetWindowTextLength(hwnd);
|
|
||||||
std::unique_ptr<wchar_t[]> result(new wchar_t[len + 1]);
|
|
||||||
GetWindowText(hwnd, result.get(), len + 1);
|
|
||||||
p->buffer = result.get();
|
|
||||||
p->retn_len = p->buffer.size();
|
|
||||||
if (!p->buffer.empty())
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::wstring GetProcessTitle(DWORD pid)
|
|
||||||
{
|
|
||||||
TitleParam p;
|
|
||||||
p.pid = pid;
|
|
||||||
p.buffer_len = 0;
|
|
||||||
p.retn_len = 0;
|
|
||||||
EnumWindows(EnumProc, (LPARAM)&p);
|
|
||||||
return p.buffer;
|
|
||||||
}
|
|
||||||
|
|
||||||
WindowsError::WindowsError(DWORD error_code) : error_code(error_code), msg("")
|
|
||||||
{
|
|
||||||
CHAR str[512];
|
|
||||||
std::sprintf(str, "error code 0x%8x", error_code);
|
|
||||||
msg = str;
|
|
||||||
}
|
|
||||||
|
|
||||||
const char *WindowsError::what() const
|
|
||||||
{
|
|
||||||
return msg.c_str();
|
|
||||||
}
|
|
||||||
|
|
||||||
HANDLE IthCreateThread(LPVOID start_addr, DWORD param)
|
|
||||||
{
|
|
||||||
return CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)start_addr, (LPVOID)param, 0, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
std::wstring GetModuleFileNameAsString()
|
|
||||||
{
|
|
||||||
WCHAR path[MAX_PATH];
|
|
||||||
GetModuleFileName(NULL, path, MAX_PATH);
|
|
||||||
return path;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool IthCreateDirectory(LPCWSTR name)
|
|
||||||
{
|
|
||||||
std::wstring path = GetModuleFileNameAsString();
|
|
||||||
path = path.substr(0, path.rfind(L'\\') + 1) + name;
|
|
||||||
BOOL error_code = CreateDirectory(path.c_str(), NULL);
|
|
||||||
return error_code != 0 || GetLastError() == ERROR_ALREADY_EXISTS;
|
|
||||||
}
|
|
||||||
|
|
||||||
HANDLE IthCreateFile(LPCWSTR name, DWORD option, DWORD share, DWORD disposition)
|
|
||||||
{
|
|
||||||
std::wstring path = GetModuleFileNameAsString();
|
|
||||||
path = path.substr(0, path.rfind(L'\\') + 1) + name;
|
|
||||||
return CreateFile(path.c_str(), option, share, NULL, disposition, FILE_ATTRIBUTE_NORMAL, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
//SJIS->Unicode. mb must be null-terminated. wc_length is the length of wc in characters.
|
|
||||||
int MB_WC(const char* mb, wchar_t* wc, int wc_length)
|
|
||||||
{
|
|
||||||
return MultiByteToWideChar(932, 0, mb, -1, wc, wc_length);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Count characters in wide string. mb_length is the number of bytes from mb to convert or
|
|
||||||
// -1 if the string is null terminated.
|
|
||||||
int MB_WC_count(const char* mb, int mb_length)
|
|
||||||
{
|
|
||||||
return MultiByteToWideChar(932, 0, mb, mb_length, NULL, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Unicode->SJIS. Analogous to MB_WC.
|
|
||||||
int WC_MB(const wchar_t *wc, char* mb, int mb_length)
|
|
||||||
{
|
|
||||||
return WideCharToMultiByte(932, 0, wc, -1, mb, mb_length, NULL, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
std::wstring GetEntryString(TextThread* thread)
|
|
||||||
{
|
|
||||||
ThreadParameter tp = thread->GetThreadParameter();
|
|
||||||
std::wstring buffer;
|
|
||||||
buffer.resize(200);
|
|
||||||
buffer.resize(swprintf(&buffer[0], L"%.4X:%.4d:0x%08X:0x%08X:0x%08X:", thread->Number(), tp.pid, tp.hook, tp.retn, tp.spl));
|
|
||||||
buffer += man->GetHookName(tp.pid, tp.hook);
|
|
||||||
return buffer;
|
|
||||||
}
|
|
107
oldgui/utility.h
107
oldgui/utility.h
@ -1,107 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
#include "ITH.h"
|
|
||||||
#include "textthread.h"
|
|
||||||
|
|
||||||
struct HookParam;
|
|
||||||
struct ProcessRecord;
|
|
||||||
|
|
||||||
DWORD ProcessCommand(const std::wstring& cmd, DWORD pid);
|
|
||||||
std::wstring GetProcessPath(DWORD pid);
|
|
||||||
void ConsoleOutput(LPCWSTR);
|
|
||||||
void ConsoleOutput(LPCSTR text);
|
|
||||||
std::wstring GetProcessTitle(DWORD pid);
|
|
||||||
std::wstring GetCode(const HookParam& hp, DWORD pid = 0);
|
|
||||||
|
|
||||||
// http://codesequoia.wordpress.com/2012/08/26/stdunique_ptr-for-windows-handles/
|
|
||||||
struct HandleDeleter
|
|
||||||
{
|
|
||||||
typedef HANDLE pointer;
|
|
||||||
void operator() (HANDLE h)
|
|
||||||
{
|
|
||||||
if (h != INVALID_HANDLE_VALUE) {
|
|
||||||
CloseHandle(h);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
typedef std::unique_ptr<HANDLE, HandleDeleter> UniqueHandle;
|
|
||||||
|
|
||||||
class FileWriter : public pugi::xml_writer
|
|
||||||
{
|
|
||||||
HANDLE hFile;
|
|
||||||
public:
|
|
||||||
FileWriter(HANDLE hFile) : hFile(hFile) {};
|
|
||||||
~FileWriter() {};
|
|
||||||
|
|
||||||
virtual void write(const void* data, size_t size)
|
|
||||||
{
|
|
||||||
DWORD dwNumberOfBytesWritten;
|
|
||||||
WriteFile(hFile, data, size, &dwNumberOfBytesWritten, NULL);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
class WindowsError : public std::exception
|
|
||||||
{
|
|
||||||
private:
|
|
||||||
std::string msg;
|
|
||||||
DWORD error_code;
|
|
||||||
public:
|
|
||||||
WindowsError(DWORD error_code);
|
|
||||||
virtual const char *what() const;
|
|
||||||
};
|
|
||||||
|
|
||||||
HANDLE IthCreateThread(LPVOID start_addr, DWORD param);
|
|
||||||
bool IthCreateDirectory(LPCWSTR name);
|
|
||||||
HANDLE IthCreateFile(LPCWSTR name, DWORD option, DWORD share, DWORD disposition);
|
|
||||||
int MB_WC(const char* mb, wchar_t* wc, int wc_length);
|
|
||||||
int MB_WC_count(const char* mb, int mb_length);
|
|
||||||
int WC_MB(const wchar_t *wc, char* mb, int mb_length);
|
|
||||||
std::wstring GetEntryString(TextThread * thread);
|
|
||||||
bool Parse(const std::wstring& cmd, HookParam& hp);
|
|
||||||
|
|
||||||
// http://jrdodds.blogs.com/blog/2004/08/raii_in_c.html
|
|
||||||
class CriticalSection
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
CriticalSection()
|
|
||||||
{
|
|
||||||
::InitializeCriticalSection(&m_rep);
|
|
||||||
}
|
|
||||||
~CriticalSection()
|
|
||||||
{
|
|
||||||
::DeleteCriticalSection(&m_rep);
|
|
||||||
}
|
|
||||||
void Enter()
|
|
||||||
{
|
|
||||||
::EnterCriticalSection(&m_rep);
|
|
||||||
}
|
|
||||||
void Leave()
|
|
||||||
{
|
|
||||||
::LeaveCriticalSection(&m_rep);
|
|
||||||
}
|
|
||||||
private:
|
|
||||||
CriticalSection(const CriticalSection&);
|
|
||||||
CriticalSection& operator=(const CriticalSection&);
|
|
||||||
|
|
||||||
CRITICAL_SECTION m_rep;
|
|
||||||
};
|
|
||||||
|
|
||||||
class CSLock
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
CSLock(CriticalSection& a_section)
|
|
||||||
: m_section(a_section)
|
|
||||||
{
|
|
||||||
m_section.Enter();
|
|
||||||
}
|
|
||||||
~CSLock()
|
|
||||||
{
|
|
||||||
m_section.Leave();
|
|
||||||
}
|
|
||||||
private:
|
|
||||||
CSLock(const CSLock&);
|
|
||||||
CSLock& operator=(const CSLock&);
|
|
||||||
|
|
||||||
CriticalSection& m_section;
|
|
||||||
};
|
|
@ -1,2 +0,0 @@
|
|||||||
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@";
|
|
@ -1,646 +0,0 @@
|
|||||||
/* Copyright (C) 2010-2012 kaosu (qiupf2000@gmail.com)
|
|
||||||
* This file is part of the Interactive Text Hooker.
|
|
||||||
|
|
||||||
* Interactive Text Hooker is free software: you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU General Public License as published
|
|
||||||
* by the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
#include "window.h"
|
|
||||||
#include "ProcessWindow.h"
|
|
||||||
#include "resource.h"
|
|
||||||
#include "language.h"
|
|
||||||
#include "host.h"
|
|
||||||
#include "hookman.h"
|
|
||||||
#include "vnrhook/include/const.h"
|
|
||||||
#include "version.h"
|
|
||||||
#include "ProfileManager.h"
|
|
||||||
#include "profile/Profile.h"
|
|
||||||
#include "TextBuffer.h"
|
|
||||||
#include "profile/misc.h"
|
|
||||||
|
|
||||||
#define CMD_SIZE 512
|
|
||||||
|
|
||||||
static WNDPROC proc, proccmd, procChar;
|
|
||||||
static WCHAR last_cmd[CMD_SIZE];
|
|
||||||
extern HINSTANCE hIns; // main.cpp
|
|
||||||
|
|
||||||
HWND hMainWnd, hwndCombo, hwndProcessComboBox, hwndEdit, hwndCmd;
|
|
||||||
HWND hwndProcess;
|
|
||||||
HWND hwndOption, hwndTop, hwndClear, hwndSave, hwndExtensions, hwndRemoveHook;
|
|
||||||
HWND hProcDlg, hOptionDlg;
|
|
||||||
HBRUSH hWhiteBrush;
|
|
||||||
DWORD background;
|
|
||||||
ProcessWindow* pswnd;
|
|
||||||
TextBuffer* texts;
|
|
||||||
extern ProfileManager* pfman; // ProfileManager.cpp
|
|
||||||
extern HookManager* man; // main.cpp
|
|
||||||
#define COMMENT_BUFFER_LENGTH 512
|
|
||||||
static WCHAR comment_buffer[COMMENT_BUFFER_LENGTH];
|
|
||||||
|
|
||||||
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
|
|
||||||
void SaveSettings(); // main.cpp
|
|
||||||
extern LONG split_time, process_time, inject_delay, insert_delay,
|
|
||||||
auto_inject, auto_insert, clipboard_flag, cyclic_remove, global_filter; //main.cpp
|
|
||||||
static int last_select, last_edit;
|
|
||||||
|
|
||||||
ATOM MyRegisterClass(HINSTANCE hInstance)
|
|
||||||
{
|
|
||||||
WNDCLASSEX wcex;
|
|
||||||
wcex.cbSize = sizeof(WNDCLASSEX);
|
|
||||||
wcex.style = CS_HREDRAW | CS_VREDRAW;
|
|
||||||
wcex.lpfnWndProc = WndProc;
|
|
||||||
wcex.cbClsExtra = 0;
|
|
||||||
wcex.cbWndExtra = 0;
|
|
||||||
wcex.hInstance = hInstance;
|
|
||||||
wcex.hIcon = NULL;
|
|
||||||
wcex.hCursor = NULL;
|
|
||||||
wcex.hbrBackground = GetStockBrush(WHITE_BRUSH);
|
|
||||||
wcex.lpszMenuName = NULL;
|
|
||||||
wcex.lpszClassName = ClassName;
|
|
||||||
wcex.hIconSm = LoadIcon(hInstance, (LPWSTR)IDI_ICON1);
|
|
||||||
return RegisterClassEx(&wcex);
|
|
||||||
}
|
|
||||||
|
|
||||||
BOOL InitInstance(HINSTANCE hInstance, DWORD nAdmin, RECT* rc)
|
|
||||||
{
|
|
||||||
hIns = hInstance;
|
|
||||||
LPCWSTR name = (nAdmin) ? ClassNameAdmin : ClassName;
|
|
||||||
hMainWnd = CreateWindow(ClassName, name, WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN,
|
|
||||||
rc->left, rc->top, rc->right - rc->left, rc->bottom - rc->top, NULL, NULL, hInstance, 0);
|
|
||||||
if (!hMainWnd)
|
|
||||||
return FALSE;
|
|
||||||
ShowWindow(hMainWnd, SW_SHOWNORMAL);
|
|
||||||
UpdateWindow(hMainWnd);
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
DWORD SaveProcessProfile(TextThread* thread); // ProfileManager.cpp
|
|
||||||
|
|
||||||
BOOL CALLBACK OptionDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
|
||||||
{
|
|
||||||
switch (uMsg)
|
|
||||||
{
|
|
||||||
case WM_INITDIALOG:
|
|
||||||
{
|
|
||||||
SetWindowText(GetDlgItem(hDlg, IDC_EDIT1), std::to_wstring((long long)split_time).c_str());
|
|
||||||
}
|
|
||||||
return TRUE;
|
|
||||||
case WM_COMMAND:
|
|
||||||
{
|
|
||||||
DWORD wmId = LOWORD(wParam);
|
|
||||||
DWORD wmEvent = HIWORD(wParam);
|
|
||||||
switch (wmId)
|
|
||||||
{
|
|
||||||
case IDOK:
|
|
||||||
{
|
|
||||||
WCHAR str[128];
|
|
||||||
GetWindowText(GetDlgItem(hDlg, IDC_EDIT1), str, 0x80);
|
|
||||||
DWORD st = std::stoul(str);
|
|
||||||
split_time = st > 100 ? st : 100;
|
|
||||||
man->SetSplitInterval(split_time);
|
|
||||||
}
|
|
||||||
case IDCANCEL:
|
|
||||||
EndDialog(hDlg, 0);
|
|
||||||
hOptionDlg = NULL;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
BOOL CALLBACK ProcessDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
|
||||||
{
|
|
||||||
switch (uMsg)
|
|
||||||
{
|
|
||||||
case WM_INITDIALOG:
|
|
||||||
{
|
|
||||||
pswnd = new ProcessWindow(hDlg);
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
case WM_COMMAND:
|
|
||||||
{
|
|
||||||
DWORD wmId, wmEvent;
|
|
||||||
wmId = LOWORD(wParam);
|
|
||||||
wmEvent = HIWORD(wParam);
|
|
||||||
switch (wmId)
|
|
||||||
{
|
|
||||||
case WM_DESTROY:
|
|
||||||
case IDOK:
|
|
||||||
EndDialog(hDlg, NULL);
|
|
||||||
hProcDlg = NULL;
|
|
||||||
delete pswnd;
|
|
||||||
pswnd = NULL;
|
|
||||||
break;
|
|
||||||
case IDC_BUTTON1:
|
|
||||||
pswnd->RefreshProcess();
|
|
||||||
break;
|
|
||||||
case IDC_BUTTON2:
|
|
||||||
pswnd->AttachProcess();
|
|
||||||
break;
|
|
||||||
case IDC_BUTTON3:
|
|
||||||
pswnd->DetachProcess();
|
|
||||||
break;
|
|
||||||
case IDC_BUTTON5:
|
|
||||||
pswnd->CreateProfileForSelectedProcess();
|
|
||||||
break;
|
|
||||||
case IDC_BUTTON6:
|
|
||||||
pswnd->DeleteProfileForSelectedProcess();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return TRUE;
|
|
||||||
|
|
||||||
case WM_NOTIFY:
|
|
||||||
{
|
|
||||||
LPNMHDR dr = (LPNMHDR)lParam;
|
|
||||||
switch (dr->code)
|
|
||||||
{
|
|
||||||
case LVN_ITEMCHANGED:
|
|
||||||
if (dr->idFrom == IDC_LIST1)
|
|
||||||
{
|
|
||||||
NMLISTVIEW *nmlv = (LPNMLISTVIEW)lParam;
|
|
||||||
if (nmlv->uNewState & LVIS_SELECTED)
|
|
||||||
pswnd->RefreshThread(nmlv->iItem);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return TRUE;
|
|
||||||
default:
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
LRESULT CALLBACK EditProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
|
||||||
{
|
|
||||||
|
|
||||||
switch (message)
|
|
||||||
{
|
|
||||||
case WM_CHAR: //Filter user input.
|
|
||||||
if (GetKeyState(VK_CONTROL) & 0x8000)
|
|
||||||
{
|
|
||||||
if (wParam == 1)
|
|
||||||
{
|
|
||||||
Edit_SetSel(hwndEdit, 0, -1);
|
|
||||||
SendMessage(hwndEdit, WM_COPY, 0, 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
case WM_LBUTTONUP:
|
|
||||||
if (hwndEdit)
|
|
||||||
SendMessage(hwndEdit, WM_COPY, 0, 0);
|
|
||||||
default:
|
|
||||||
{
|
|
||||||
return proc(hWnd, message, wParam, lParam);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
LRESULT CALLBACK EditCmdProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
|
||||||
{
|
|
||||||
switch (message)
|
|
||||||
{
|
|
||||||
case WM_KEYDOWN:
|
|
||||||
if (wParam == VK_UP)
|
|
||||||
{
|
|
||||||
SetWindowText(hWnd, last_cmd);
|
|
||||||
SetFocus(hWnd);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case WM_CHAR:
|
|
||||||
if (wParam == VK_RETURN)
|
|
||||||
{
|
|
||||||
DWORD s = 0, pid = 0;
|
|
||||||
WCHAR str[32];
|
|
||||||
if (GetWindowTextLength(hWnd) == 0)
|
|
||||||
break;
|
|
||||||
GetWindowText(hWnd, last_cmd, CMD_SIZE);
|
|
||||||
//IthBreak();
|
|
||||||
if (GetWindowText(hwndProcessComboBox, str, 32))
|
|
||||||
pid = std::stoul(str);
|
|
||||||
ProcessCommand(last_cmd, pid);
|
|
||||||
Edit_SetSel(hWnd, 0, -1);
|
|
||||||
Edit_ReplaceSel(hWnd, &s);
|
|
||||||
SetFocus(hWnd);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return CallWindowProc(proccmd, hWnd, message, wParam, lParam);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CreateButtons(HWND hWnd)
|
|
||||||
{
|
|
||||||
hwndProcess = CreateWindow(L"Button", L"Process", WS_CHILD | WS_VISIBLE,
|
|
||||||
0, 0, 0, 0, hWnd, 0, hIns, NULL);
|
|
||||||
hwndOption = CreateWindow(L"Button", L"Option", WS_CHILD | WS_VISIBLE,
|
|
||||||
0, 0, 0, 0, hWnd, 0, hIns, NULL);
|
|
||||||
hwndClear = CreateWindow(L"Button", L"Clear", WS_CHILD | WS_VISIBLE,
|
|
||||||
0, 0, 0, 0, hWnd, 0, hIns, NULL);
|
|
||||||
hwndSave = CreateWindow(L"Button", L"Save", WS_CHILD | WS_VISIBLE,
|
|
||||||
0, 0, 0, 0, hWnd, 0, hIns, NULL);
|
|
||||||
hwndExtensions = CreateWindow(L"Button", L"Extensions", WS_CHILD | WS_VISIBLE,
|
|
||||||
0, 0, 0, 0, hWnd, 0, hIns, NULL);
|
|
||||||
hwndRemoveHook = CreateWindow(L"Button", L"Unhook", WS_CHILD | WS_VISIBLE,
|
|
||||||
0, 0, 0, 0, hWnd, 0, hIns, NULL);
|
|
||||||
hwndTop = CreateWindow(L"Button", L"Top", WS_CHILD | WS_VISIBLE | BS_PUSHLIKE | BS_CHECKBOX,
|
|
||||||
0, 0, 0, 0, hWnd, 0, hIns, NULL);
|
|
||||||
hwndProcessComboBox = CreateWindow(L"ComboBox", NULL,
|
|
||||||
WS_CHILD | WS_VISIBLE | CBS_DROPDOWNLIST |
|
|
||||||
CBS_SORT | WS_VSCROLL | WS_TABSTOP,
|
|
||||||
0, 0, 0, 0, hWnd, 0, hIns, NULL);
|
|
||||||
hwndCmd = CreateWindowEx(WS_EX_CLIENTEDGE, L"Edit", NULL,
|
|
||||||
WS_CHILD | WS_VISIBLE | ES_NOHIDESEL | ES_LEFT | ES_AUTOHSCROLL,
|
|
||||||
0, 0, 0, 0, hWnd, 0, hIns, NULL);
|
|
||||||
hwndEdit = CreateWindowEx(WS_EX_CLIENTEDGE, L"Edit", NULL,
|
|
||||||
WS_CHILD | WS_VISIBLE | ES_NOHIDESEL | WS_VSCROLL |
|
|
||||||
ES_LEFT | ES_MULTILINE | ES_AUTOVSCROLL,
|
|
||||||
0, 0, 0, 0, hWnd, 0, hIns, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ClickButton(HWND hWnd, HWND h)
|
|
||||||
{
|
|
||||||
if (h == hwndProcess)
|
|
||||||
{
|
|
||||||
if (hProcDlg)
|
|
||||||
SetForegroundWindow(hProcDlg);
|
|
||||||
else
|
|
||||||
hProcDlg = CreateDialog(hIns, (LPWSTR)IDD_DIALOG2, 0, ProcessDlgProc);
|
|
||||||
}
|
|
||||||
else if (h == hwndOption)
|
|
||||||
{
|
|
||||||
if (hOptionDlg)
|
|
||||||
SetForegroundWindow(hOptionDlg);
|
|
||||||
else
|
|
||||||
hOptionDlg = CreateDialog(hIns, (LPWSTR)IDD_DIALOG4, 0, OptionDlgProc);
|
|
||||||
}
|
|
||||||
else if (h == hwndClear)
|
|
||||||
{
|
|
||||||
man->ClearCurrent();
|
|
||||||
}
|
|
||||||
else if (h == hwndTop)
|
|
||||||
{
|
|
||||||
if (Button_GetCheck(h) == BST_CHECKED)
|
|
||||||
{
|
|
||||||
Button_SetCheck(h, BST_UNCHECKED);
|
|
||||||
SetWindowPos(hWnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE);
|
|
||||||
if (hProcDlg)
|
|
||||||
SetWindowPos(hProcDlg, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE);
|
|
||||||
if (hOptionDlg)
|
|
||||||
SetWindowPos(hOptionDlg, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Button_SetCheck(h, BST_CHECKED);
|
|
||||||
SetWindowPos(hWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE);
|
|
||||||
if (hProcDlg)
|
|
||||||
SetWindowPos(hProcDlg, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE);
|
|
||||||
if (hOptionDlg)
|
|
||||||
SetWindowPos(hOptionDlg, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (h == hwndSave)
|
|
||||||
{
|
|
||||||
WCHAR str[32];
|
|
||||||
if (GetWindowText(hwndCombo, str, 32))
|
|
||||||
{
|
|
||||||
TextThread* current = man->FindSingle(std::stoul(str, nullptr, 16));
|
|
||||||
SaveProcessProfile(current);
|
|
||||||
}
|
|
||||||
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)
|
|
||||||
{
|
|
||||||
WCHAR str[32];
|
|
||||||
if (GetWindowText(hwndCombo, str, 32))
|
|
||||||
{
|
|
||||||
std::wstring entry(str);
|
|
||||||
std::size_t i;
|
|
||||||
DWORD threadNumber = std::stoul(entry, &i, 16);
|
|
||||||
entry = entry.substr(i + 1);
|
|
||||||
DWORD pid = std::stoul(entry, &i);
|
|
||||||
entry = entry.substr(i + 1);
|
|
||||||
DWORD addr = std::stoul(entry, NULL, 16);
|
|
||||||
if (threadNumber != 0)
|
|
||||||
RemoveHook(pid, addr);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
std::wstring ThreadOutput(TextThread* thread, std::wstring output)
|
|
||||||
{
|
|
||||||
if (thread->Status() & CURRENT_SELECT) texts->AddText(output, false);
|
|
||||||
return output;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool GetHookParam(DWORD pid, DWORD hook_addr, HookParam& hp)
|
|
||||||
{
|
|
||||||
if (!pid)
|
|
||||||
return false;
|
|
||||||
hp = man->GetHookParam(pid, hook_addr);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::wstring CreateEntryWithLink(ThreadParameter tp, std::wstring& entry)
|
|
||||||
{
|
|
||||||
std::wstring entryWithLink = entry;
|
|
||||||
if (tp.pid == 0)
|
|
||||||
entryWithLink += L"ConsoleOutput";
|
|
||||||
HookParam hp = {};
|
|
||||||
if (GetHookParam(tp.pid, tp.hook, hp))
|
|
||||||
entryWithLink += L" (" + GetCode(hp, tp.pid) + L")";
|
|
||||||
return entryWithLink;
|
|
||||||
}
|
|
||||||
|
|
||||||
void AddToCombo(TextThread& thread, bool replace)
|
|
||||||
{
|
|
||||||
std::wstring entry = GetEntryString(&thread);
|
|
||||||
std::wstring entryWithLink = CreateEntryWithLink(thread.GetThreadParameter(), entry);
|
|
||||||
int i = ComboBox_FindString(hwndCombo, -1, entry.c_str());
|
|
||||||
if (replace)
|
|
||||||
{
|
|
||||||
int sel = ComboBox_GetCurSel(hwndCombo);
|
|
||||||
if (i != CB_ERR)
|
|
||||||
ComboBox_DeleteString(hwndCombo, i);
|
|
||||||
ComboBox_AddString(hwndCombo, entryWithLink.c_str());
|
|
||||||
ComboBox_SetCurSel(hwndCombo, sel);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (i == CB_ERR)
|
|
||||||
ComboBox_AddString(hwndCombo, entryWithLink.c_str());
|
|
||||||
// Why set current selection to 0 when the new thread is selected?
|
|
||||||
if (thread.Status() & CURRENT_SELECT)
|
|
||||||
ComboBox_SetCurSel(hwndCombo, 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void ThreadRemove(TextThread* thread)
|
|
||||||
{
|
|
||||||
std::wstring entry = GetEntryString(thread);
|
|
||||||
if (thread->GetThreadParameter().pid == 0)
|
|
||||||
entry += L"ConsoleOutput";
|
|
||||||
int i = ComboBox_FindString(hwndCombo, 0, entry.c_str());
|
|
||||||
if (i != CB_ERR)
|
|
||||||
{
|
|
||||||
if (ComboBox_DeleteString(hwndCombo, i) == CB_ERR)
|
|
||||||
ConsoleOutput(ErrorDeleteCombo);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void SetEditText(LPCWSTR wc)
|
|
||||||
{
|
|
||||||
DWORD line;
|
|
||||||
Edit_SetText(hwndEdit, wc);
|
|
||||||
line = Edit_GetLineCount(hwndEdit);
|
|
||||||
SendMessage(hwndEdit, EM_LINESCROLL, 0, line);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ThreadReset(TextThread* thread)
|
|
||||||
{
|
|
||||||
texts->ClearBuffer();
|
|
||||||
man->SetCurrent(thread);;
|
|
||||||
|
|
||||||
std::wstring text = thread->GetStore();
|
|
||||||
SetEditText(text.c_str());
|
|
||||||
|
|
||||||
WCHAR buffer[16];
|
|
||||||
std::swprintf(buffer, L"%04X", thread->Number());
|
|
||||||
DWORD tmp = ComboBox_FindString(hwndCombo, 0, buffer);
|
|
||||||
if (tmp != CB_ERR)
|
|
||||||
ComboBox_SetCurSel(hwndCombo, tmp);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool IsUnicodeHook(const ProcessRecord& pr, DWORD hook);
|
|
||||||
|
|
||||||
void ThreadCreate(TextThread* thread)
|
|
||||||
{
|
|
||||||
thread->RegisterOutputCallBack(ThreadOutput);
|
|
||||||
//thread->RegisterFilterCallBack(ThreadFilter, 0);
|
|
||||||
AddToCombo(*thread, false);
|
|
||||||
auto tp = thread->GetThreadParameter();
|
|
||||||
auto hook = man->GetHookParam(tp.pid, tp.hook);
|
|
||||||
if (hook.type & USING_UNICODE) thread->Status() |= USING_UNICODE;
|
|
||||||
auto pf = pfman->GetProfile(tp.pid);
|
|
||||||
if (!pf)
|
|
||||||
return;
|
|
||||||
const std::wstring& hook_name = man->GetHookName(tp.pid, tp.hook);
|
|
||||||
auto thread_profile = pf->FindThread(&thread->GetThreadParameter(), hook_name);
|
|
||||||
if (thread_profile != pf->Threads().end())
|
|
||||||
{
|
|
||||||
(*thread_profile)->HookManagerIndex() = thread->Number();
|
|
||||||
auto thread_index = thread_profile - pf->Threads().begin();
|
|
||||||
if (pf->IsThreadSelected(thread_profile))
|
|
||||||
ThreadReset(thread);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool IsUnicodeHook(const ProcessRecord& pr, DWORD hook)
|
|
||||||
{
|
|
||||||
bool res = false;
|
|
||||||
WaitForSingleObject(pr.hookman_mutex, 0);
|
|
||||||
auto hooks = (const Hook*)pr.hookman_map;
|
|
||||||
for (DWORD i = 0; i < MAX_HOOK; i++)
|
|
||||||
{
|
|
||||||
if (hooks[i].Address() == hook)
|
|
||||||
{
|
|
||||||
res = hooks[i].Type() & USING_UNICODE;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ReleaseMutex(pr.hookman_mutex);
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
void RegisterProcess(DWORD pid)
|
|
||||||
{
|
|
||||||
auto path = GetProcessPath(pid);
|
|
||||||
if (!path.empty())
|
|
||||||
{
|
|
||||||
WCHAR str[MAX_PATH];
|
|
||||||
std::swprintf(str, L"%04d:%s", pid, path.substr(path.rfind(L'\\') + 1).c_str());
|
|
||||||
ComboBox_AddString(hwndProcessComboBox, str);
|
|
||||||
if (ComboBox_GetCount(hwndProcessComboBox) == 1)
|
|
||||||
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()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void RemoveProcessList(DWORD pid)
|
|
||||||
{
|
|
||||||
WCHAR str[MAX_PATH];
|
|
||||||
std::swprintf(str, L"%04d", pid);
|
|
||||||
DWORD i = ComboBox_FindString(hwndProcessComboBox, 0, str);
|
|
||||||
DWORD j = ComboBox_GetCurSel(hwndProcessComboBox);
|
|
||||||
if (i != CB_ERR)
|
|
||||||
{
|
|
||||||
DWORD k = ComboBox_DeleteString(hwndProcessComboBox, i);
|
|
||||||
if (i == j)
|
|
||||||
ComboBox_SetCurSel(hwndProcessComboBox, 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
|
||||||
{
|
|
||||||
switch (message)
|
|
||||||
{
|
|
||||||
case WM_CREATE:
|
|
||||||
CreateButtons(hWnd);
|
|
||||||
// Add text to the window.
|
|
||||||
Edit_LimitText(hwndEdit, -1);
|
|
||||||
SendMessage(hwndEdit, WM_INPUTLANGCHANGEREQUEST, 0, 0x411);
|
|
||||||
proc = (WNDPROC)SetWindowLong(hwndEdit, GWL_WNDPROC, (LONG)EditProc);
|
|
||||||
proccmd = (WNDPROC)SetWindowLong(hwndCmd, GWL_WNDPROC, (LONG)EditCmdProc);
|
|
||||||
hwndCombo = CreateWindow(L"ComboBox", NULL,
|
|
||||||
WS_CHILD | WS_VISIBLE | CBS_DROPDOWNLIST |
|
|
||||||
CBS_SORT | WS_VSCROLL | WS_TABSTOP,
|
|
||||||
0, 0, 0, 0, hWnd, 0, hIns, NULL);
|
|
||||||
{
|
|
||||||
HDC hDC = GetDC(hWnd);
|
|
||||||
int nHeight = -MulDiv(12, GetDeviceCaps(hDC, LOGPIXELSY), 72);
|
|
||||||
ReleaseDC(hWnd, hDC);
|
|
||||||
HFONT hf = CreateFont(nHeight, 0, 0, 0, FW_LIGHT, FALSE, FALSE, FALSE, SHIFTJIS_CHARSET,
|
|
||||||
OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, CLEARTYPE_QUALITY, DEFAULT_PITCH | FF_DONTCARE,
|
|
||||||
L"MS Gothic");
|
|
||||||
hWhiteBrush = GetStockBrush(WHITE_BRUSH);
|
|
||||||
SendMessage(hwndCmd, WM_SETFONT, (WPARAM)hf, 0);
|
|
||||||
SendMessage(hwndEdit, WM_SETFONT, (WPARAM)hf, 0);
|
|
||||||
SendMessage(hwndCombo, WM_SETFONT, (WPARAM)hf, 0);
|
|
||||||
SendMessage(hwndProcessComboBox, WM_SETFONT, (WPARAM)hf, 0);
|
|
||||||
texts = new TextBuffer(hwndEdit);
|
|
||||||
man->RegisterThreadCreateCallback(ThreadCreate);
|
|
||||||
man->RegisterThreadRemoveCallback(ThreadRemove);
|
|
||||||
man->RegisterThreadResetCallback(ThreadReset);
|
|
||||||
TextThread* console = man->FindSingle(0);
|
|
||||||
console->RegisterOutputCallBack(ThreadOutput);
|
|
||||||
AddToCombo(*console, false);
|
|
||||||
man->RegisterProcessAttachCallback(RegisterProcess);
|
|
||||||
man->RegisterProcessDetachCallback(RemoveProcessList);
|
|
||||||
OpenHost();
|
|
||||||
{
|
|
||||||
static const WCHAR program_name[] = L"NextHooker beta v";
|
|
||||||
//static const WCHAR program_version[] = L"3.0";
|
|
||||||
static WCHAR version_info[256];
|
|
||||||
std::swprintf(version_info, L"%s%s (%s)", program_name, program_version, build_date);
|
|
||||||
man->AddConsoleOutput(version_info);
|
|
||||||
man->AddConsoleOutput(InitMessage);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (background == 0)
|
|
||||||
man->AddConsoleOutput(BackgroundMsg);
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
case WM_COMMAND:
|
|
||||||
{
|
|
||||||
DWORD wmId, wmEvent, dwId;
|
|
||||||
wmId = LOWORD(wParam);
|
|
||||||
wmEvent = HIWORD(wParam);
|
|
||||||
switch (wmEvent)
|
|
||||||
{
|
|
||||||
case EN_VSCROLL:
|
|
||||||
{
|
|
||||||
SCROLLBARINFO info = { sizeof(info) };
|
|
||||||
GetScrollBarInfo(hwndEdit, OBJID_VSCROLL, &info);
|
|
||||||
InvalidateRect(hwndEdit, 0, 1);
|
|
||||||
ValidateRect(hwndEdit, &info.rcScrollBar);
|
|
||||||
RedrawWindow(hwndEdit, 0, 0, RDW_ERASE);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case CBN_SELENDOK:
|
|
||||||
{
|
|
||||||
if ((HWND)lParam == hwndProcessComboBox)
|
|
||||||
return 0;
|
|
||||||
dwId = ComboBox_GetCurSel(hwndCombo);
|
|
||||||
int len = ComboBox_GetLBTextLen(hwndCombo, dwId);
|
|
||||||
if (len > 0)
|
|
||||||
{
|
|
||||||
LPWSTR pwcEntry = new WCHAR[len + 1];
|
|
||||||
len = ComboBox_GetLBText(hwndCombo, dwId, pwcEntry);
|
|
||||||
DWORD num = std::stoul(pwcEntry, NULL, 16);
|
|
||||||
man->SelectCurrent(num);
|
|
||||||
delete[] pwcEntry;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
case BN_CLICKED:
|
|
||||||
ClickButton(hWnd, (HWND)lParam);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case WM_SETFOCUS:
|
|
||||||
SetFocus(hwndEdit);
|
|
||||||
return 0;
|
|
||||||
case WM_SIZE:
|
|
||||||
{
|
|
||||||
WORD width = LOWORD(lParam);
|
|
||||||
WORD height = HIWORD(lParam);
|
|
||||||
DWORD l = width / 7;
|
|
||||||
WORD h = HIWORD(GetDialogBaseUnits()); // height of the system font
|
|
||||||
h = h + (h / 2);
|
|
||||||
HDC hDC = GetDC(hWnd);
|
|
||||||
RECT rc;
|
|
||||||
GetClientRect(hWnd, &rc);
|
|
||||||
FillRect(hDC, &rc, hWhiteBrush);
|
|
||||||
ReleaseDC(hWnd, hDC);
|
|
||||||
MoveWindow(hwndProcess, 0, 0, l, h, TRUE);
|
|
||||||
MoveWindow(hwndOption, l * 1, 0, l, h, TRUE);
|
|
||||||
MoveWindow(hwndTop, l * 2, 0, l, h, TRUE);
|
|
||||||
MoveWindow(hwndClear, l * 3, 0, l, h, TRUE);
|
|
||||||
MoveWindow(hwndExtensions, l * 4, 0, l, h, TRUE);
|
|
||||||
MoveWindow(hwndRemoveHook, l * 5, 0, l, h, TRUE);
|
|
||||||
MoveWindow(hwndSave, l * 6, 0, width - 6 * l, h, TRUE);
|
|
||||||
l *= 2;
|
|
||||||
MoveWindow(hwndProcessComboBox, 0, h, l, 200, TRUE);
|
|
||||||
MoveWindow(hwndCmd, l, h, width - l, h, TRUE);
|
|
||||||
MoveWindow(hwndCombo, 0, h * 2, width, 200, TRUE);
|
|
||||||
h *= 3;
|
|
||||||
MoveWindow(hwndEdit, 0, h, width, height - h, TRUE);
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
case WM_DESTROY:
|
|
||||||
man->RegisterThreadCreateCallback(0);
|
|
||||||
man->RegisterThreadRemoveCallback(0);
|
|
||||||
man->RegisterThreadResetCallback(0);
|
|
||||||
man->RegisterProcessAttachCallback(0);
|
|
||||||
man->RegisterProcessDetachCallback(0);
|
|
||||||
//delete texts;
|
|
||||||
SaveSettings();
|
|
||||||
PostQuitMessage(0);
|
|
||||||
return 0;
|
|
||||||
default:
|
|
||||||
return DefWindowProc(hWnd, message, wParam, lParam);
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
@ -1,20 +0,0 @@
|
|||||||
/* Copyright (C) 2010-2012 kaosu (qiupf2000@gmail.com)
|
|
||||||
* This file is part of the Interactive Text Hooker.
|
|
||||||
|
|
||||||
* Interactive Text Hooker is free software: you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU General Public License as published
|
|
||||||
* by the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include "ITH.h"
|
|
Loading…
x
Reference in New Issue
Block a user