diff --git a/build/dxwnd.0.ini b/build/dxwnd.0.ini deleted file mode 100644 index dfdaf5d..0000000 --- a/build/dxwnd.0.ini +++ /dev/null @@ -1,34 +0,0 @@ -[window] -posx=50 -posy=50 -sizx=320 -sizy=200 -lang=default -;lang=automatic -;updatepaths=1 -;debug=1 -;multiprocesshook=0 -;checkadmin=0 -[texture] -MinTexX=16 -MaxTexX=0 -MinTexY=16 -MaxTexY=0 -[keymapping] -timetoggle=0x72 -altf4=0x73 -timeslow=0x74 -timefast=0x75 -cliptoggle= -refresh= -logtoggle= -plocktoggle= -fpstoggle= -printscreen=0x7B -corner=0x7A -freezetime=0x79 -fullscreen=0x0D -workarea= -desktop= - - diff --git a/build/dxwnd.dll b/build/dxwnd.dll index b5b3282..f16fa96 100644 --- a/build/dxwnd.dll +++ b/build/dxwnd.dll @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:f80de53cd4be510b1bd1357b345ca6353b3d2b8a00a459b3d736f67b62bdee85 -size 660480 +oid sha256:49d7c2658bf62db9650233f60f2cf5dd82912f2a522c26d4c115891440ccabd9 +size 659968 diff --git a/build/dxwnd.exe b/build/dxwnd.exe index e202d7b..275e23a 100644 --- a/build/dxwnd.exe +++ b/build/dxwnd.exe @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:17c2ae808e9f1b33fb9f412cc91d8c501cec58f395a2e9d098c008abc9285e74 -size 576000 +oid sha256:c966fe71e5250ed781b9e1415ce53fec601a93c4384893a2afb78bab76d75e56 +size 640512 diff --git a/build/dxwnd.ini b/build/dxwnd.ini deleted file mode 100644 index 7f729a0..0000000 --- a/build/dxwnd.ini +++ /dev/null @@ -1,5 +0,0 @@ -[window] -posx=50 -posy=50 -sizx=320 -sizy=200 diff --git a/build/exports/Duke Nukem - Manhattan Project (D3D8).dxw b/build/exports/Duke Nukem - Manhattan Project (D3D8).dxw index 18b7b30..4eca481 100644 --- a/build/exports/Duke Nukem - Manhattan Project (D3D8).dxw +++ b/build/exports/Duke Nukem - Manhattan Project (D3D8).dxw @@ -5,10 +5,10 @@ module0=p3shared opengllib0= ver0=8 coord0=0 -flag0=134217762 +flag0=134217770 flagg0=1207959552 flagh0=20 -flagi0=4 +flagi0=4194308 tflag0=0 initx0=0 inity0=0 @@ -24,3 +24,14 @@ maxfps0=0 initts0=0 winver0=0 maxres0=-1 +launchpath0= +notes0= +registry0= +flagj0=0 +flagk0=0 +flagl0=0 +flagm0=0 +dflag0=0 +swapeffect0=0 +maxddinterface0=7 +slowratio0=1 diff --git a/build/exports/Midnight GT Primary Racer.dxw b/build/exports/Midnight GT Primary Racer.dxw new file mode 100644 index 0000000..fc8fb88 --- /dev/null +++ b/build/exports/Midnight GT Primary Racer.dxw @@ -0,0 +1,31 @@ +[target] +title0=Midnight GT Primary Racer +path0=D:\Games\Midnight GT Primary Racer\game.exe +launchpath0= +module0= +opengllib0= +notes0= +registry0= +ver0=0 +coord0=0 +flag0=136314914 +flagg0=1207959552 +flagh0=20 +flagi0=138412036 +flagj0=4226 +flagk0=65552 +flagl0=0 +flagm0=0 +tflag0=0 +dflag0=0 +posx0=50 +posy0=50 +sizx0=800 +sizy0=600 +maxfps0=0 +initts0=0 +winver0=0 +maxres0=-1 +swapeffect0=0 +maxddinterface0=7 +slowratio0=2 diff --git a/build/exports/Total Annihilation.dxw b/build/exports/Total Annihilation.dxw new file mode 100644 index 0000000..1efaa12 --- /dev/null +++ b/build/exports/Total Annihilation.dxw @@ -0,0 +1,31 @@ +[target] +title0=Total Annihilation +path0=D:\Games\TOTA\totala.exe +launchpath0= +module0= +opengllib0= +notes0= +registry0= +ver0=1 +coord0=0 +flag0=136314914 +flagg0=1207959552 +flagh0=20 +flagi0=138412036 +flagj0=4224 +flagk0=0 +flagl0=0 +flagm0=0 +tflag0=0 +dflag0=0 +posx0=50 +posy0=50 +sizx0=800 +sizy0=600 +maxfps0=0 +initts0=0 +winver0=0 +maxres0=-1 +swapeffect0=0 +maxddinterface0=7 +slowratio0=2 diff --git a/build/readme-relnotes.txt b/build/readme-relnotes.txt index dcaf90c..91bdde8 100644 --- a/build/readme-relnotes.txt +++ b/build/readme-relnotes.txt @@ -1142,3 +1142,8 @@ fix: logic for restering last window position on multimonitor configurations add: "Help -> View Help" to show help page add: "Fix GlobalUnlock" flag to fix GlobalUnlock bad errorcodes in "Grand Prix World" and possibly other games. add: revised log configuration, added "Separate" mode to make each process to write on a dedicated file. + +v2.03.74 +fix: logging of dwFOURCC field text value +fix: Injection routine: avoid closing a few handles that should not be closed, simplified logic. +add: GUI global configuration panel \ No newline at end of file diff --git a/dll/Inject.cpp b/dll/Inject.cpp index a15bb83..8e88915 100644 --- a/dll/Inject.cpp +++ b/dll/Inject.cpp @@ -59,7 +59,7 @@ BOOL Inject(DWORD pID, const char * DLL_NAME) } CloseHandle(hThread); CloseHandle(hProc); - CloseHandle(hLib); + //CloseHandle(hLib); return true; } diff --git a/dll/dxhelper.cpp b/dll/dxhelper.cpp index 60a1b9f..64b4113 100644 --- a/dll/dxhelper.cpp +++ b/dll/dxhelper.cpp @@ -1834,8 +1834,8 @@ static char *sFourCC(DWORD fcc) char *t=&sRet[0]; for(i=0; i<4; i++){ c = fcc & (0xFF); - *t++ = isprint(c) ? c : '.'; - c = c >> 8; + *(t++) = isprint(c) ? c : '.'; + fcc = fcc >> 8; } *t = 0; return sRet; diff --git a/dll/dxhook.cpp b/dll/dxhook.cpp index fcadba5..4a8d6e9 100644 --- a/dll/dxhook.cpp +++ b/dll/dxhook.cpp @@ -1530,7 +1530,6 @@ void HookInit(TARGETMAP *target, HWND hwnd) else if(dxw.dwFlags7 & CPUMAXUSAGE) CreateThread(NULL, 0, CpuLimit, NULL, 0, NULL); - } LPCSTR ProcToString(LPCSTR proc) diff --git a/dll/dxwnd.aps b/dll/dxwnd.aps index fe3472b..55e0ccb 100644 Binary files a/dll/dxwnd.aps and b/dll/dxwnd.aps differ diff --git a/dll/dxwnd.cpp b/dll/dxwnd.cpp index 9527585..d8d9631 100644 --- a/dll/dxwnd.cpp +++ b/dll/dxwnd.cpp @@ -27,7 +27,7 @@ along with this program. If not, see . #include "TlHelp32.h" -#define VERSION "2.03.73" +#define VERSION "2.03.74" #define DDTHREADLOCK 1 //#define LOCKTHREADS diff --git a/dll/dxwnd.vs2008.sln b/dll/dxwnd.vs2008.sln deleted file mode 100644 index 0d2e531..0000000 --- a/dll/dxwnd.vs2008.sln +++ /dev/null @@ -1,20 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 10.00 -# Visual Studio 2008 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "dxwnd", "dxwnd.vs2008.vcproj", "{579E7FE7-2745-4100-A802-23511711FCDE}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Release|Win32 = Release|Win32 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {579E7FE7-2745-4100-A802-23511711FCDE}.Debug|Win32.ActiveCfg = Debug|Win32 - {579E7FE7-2745-4100-A802-23511711FCDE}.Debug|Win32.Build.0 = Debug|Win32 - {579E7FE7-2745-4100-A802-23511711FCDE}.Release|Win32.ActiveCfg = Release|Win32 - {579E7FE7-2745-4100-A802-23511711FCDE}.Release|Win32.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/dll/dxwnd.vs2008.suo b/dll/dxwnd.vs2008.suo index 0df8b16..b035987 100644 Binary files a/dll/dxwnd.vs2008.suo and b/dll/dxwnd.vs2008.suo differ diff --git a/dll/kernel32.cpp b/dll/kernel32.cpp index a90eb59..c90973d 100644 --- a/dll/kernel32.cpp +++ b/dll/kernel32.cpp @@ -8,7 +8,7 @@ //#undef IsTraceDW //#define IsTraceDW TRUE -#define LOCKINJECTIONTHREADS +//#define LOCKINJECTIONTHREADS #define TRYFATNAMES TRUE extern HRESULT WINAPI extDirectDrawEnumerateA(LPDDENUMCALLBACK, LPVOID); @@ -920,8 +920,7 @@ BOOL WINAPI extCreateProcessA( extern BOOL Inject(DWORD, const char *); LPVOID LastExceptionPtr = 0; - //dwCreationFlags |= DEBUG_ONLY_THIS_PROCESS; - dwCreationFlags |= (DEBUG_ONLY_THIS_PROCESS|DEBUG_PROCESS); + dwCreationFlags |= DEBUG_ONLY_THIS_PROCESS; res=(*pCreateProcessA)( lpApplicationName, lpCommandLine, @@ -934,92 +933,89 @@ BOOL WINAPI extCreateProcessA( while(bContinueDebugging) { if (!WaitForDebugEvent(&debug_event, INFINITE)) break; - OutTrace("CreateProcess: event=%x(%s)\n", debug_event.dwDebugEventCode, ExplainDebugEvent(debug_event.dwDebugEventCode)); + OutTraceB("CreateProcess: WaitForDebugEvent pid=%x tid=%x event=%x(%s)\n", + debug_event.dwProcessId, debug_event.dwThreadId, debug_event.dwDebugEventCode, ExplainDebugEvent(debug_event.dwDebugEventCode)); switch(debug_event.dwDebugEventCode){ - case EXIT_PROCESS_DEBUG_EVENT: - //OutTrace("CreateProcess: event=%x(%s) process terminated\n", debug_event.dwDebugEventCode, ExplainDebugEvent(debug_event.dwDebugEventCode)); - bContinueDebugging=false; - break; - case CREATE_PROCESS_DEBUG_EVENT: - //OutTrace("CreateProcess: event=%x(%s) process started\n", debug_event.dwDebugEventCode, ExplainDebugEvent(debug_event.dwDebugEventCode)); - GetModuleFileName(GetModuleHandle("dxwnd"), path, MAX_PATH); - OutTrace("CreateProcess: injecting path=%s\n", path); - if(!Inject(lpProcessInformation->dwProcessId, path)){ - OutTrace("CreateProcess: Injection ERROR pid=%x dll=%s\n", lpProcessInformation->dwProcessId, path); - } + case EXIT_PROCESS_DEBUG_EVENT: + bContinueDebugging=false; + break; + case CREATE_PROCESS_DEBUG_EVENT: + GetModuleFileName(GetModuleHandle("dxwnd"), path, MAX_PATH); + OutTrace("CreateProcess: injecting path=%s\n", path); + if(!Inject(lpProcessInformation->dwProcessId, path)){ + OutTrace("CreateProcess: Injection ERROR pid=%x dll=%s\n", lpProcessInformation->dwProcessId, path); + } #ifdef LOCKINJECTIONTHREADS - extern LPVOID GetThreadStartAddress(HANDLE); - DWORD TargetHandle; - DWORD EndlessLoop; - EndlessLoop=0x9090FEEB; // assembly for JMP to here, NOP, NOP - SIZE_T BytesCount; - TargetHandle = (DWORD)OpenProcess( - PROCESS_QUERY_INFORMATION|PROCESS_VM_OPERATION|PROCESS_VM_READ|PROCESS_VM_WRITE, - FALSE, - lpProcessInformation->dwProcessId); - if(TargetHandle){ - StartAddress = GetThreadStartAddress(lpProcessInformation->hThread); - OutTrace("CreateProcess: StartAddress=%x\n", StartAddress); - if(StartAddress){ - if(!ReadProcessMemory(lpProcessInformation->hProcess, StartAddress, &StartingCode, 4, &BytesCount)){ - OutTrace("CreateProcess: ReadProcessMemory error=%d\n", GetLastError()); - } - OutTrace("CreateProcess: StartCode=%x\n", StartingCode); - if(!WriteProcessMemory(lpProcessInformation->hProcess, StartAddress, &EndlessLoop, 4, &BytesCount)){ - OutTrace("CreateProcess: WriteProcessMemory error=%d\n", GetLastError()); + HANDLE TargetHandle; + extern LPVOID GetThreadStartAddress(HANDLE); + DWORD EndlessLoop; + EndlessLoop=0x9090FEEB; // assembly for JMP to here, NOP, NOP + SIZE_T BytesCount; + TargetHandle = (DWORD)OpenProcess( + PROCESS_QUERY_INFORMATION|PROCESS_VM_OPERATION|PROCESS_VM_READ|PROCESS_VM_WRITE, + FALSE, + lpProcessInformation->dwProcessId); + if(TargetHandle){ + StartAddress = GetThreadStartAddress(lpProcessInformation->hThread); + OutTrace("CreateProcess: StartAddress=%x\n", StartAddress); + if(StartAddress){ + if(!ReadProcessMemory(lpProcessInformation->hProcess, StartAddress, &StartingCode, 4, &BytesCount)){ + OutTrace("CreateProcess: ReadProcessMemory error=%d\n", GetLastError()); + } + OutTrace("CreateProcess: StartCode=%x\n", StartingCode); + if(!WriteProcessMemory(lpProcessInformation->hProcess, StartAddress, &EndlessLoop, 4, &BytesCount)){ + OutTrace("CreateProcess: WriteProcessMemory error=%d\n", GetLastError()); + } } } - } #endif - OutTrace("CreateProcess: injection started\n", res); - CloseHandle(((CREATE_PROCESS_DEBUG_INFO *)&debug_event.u)->hProcess); - CloseHandle(((CREATE_PROCESS_DEBUG_INFO *)&debug_event.u)->hThread); - CloseHandle(((CREATE_PROCESS_DEBUG_INFO *)&debug_event.u)->hFile); - break; - case EXIT_THREAD_DEBUG_EVENT: - //OutTrace("CreateProcess: event=%x(%s) injection terminated\n", debug_event.dwDebugEventCode, ExplainDebugEvent(debug_event.dwDebugEventCode)); + OutTrace("CreateProcess: injection started\n", res); + CloseHandle(debug_event.u.CreateProcessInfo.hFile); + break; + case EXCEPTION_DEBUG_EVENT: + { + LPEXCEPTION_DEBUG_INFO ei; + ei=(LPEXCEPTION_DEBUG_INFO)&debug_event.u; + OutTraceE("CreateProcess: EXCEPTION code=%x flags=%x addr=%x firstchance=%x\n", + ei->ExceptionRecord.ExceptionCode, + ei->ExceptionRecord.ExceptionFlags, + ei->ExceptionRecord.ExceptionAddress, + debug_event.u.Exception.dwFirstChance); + // exception twice in same address, then do not continue. + if(LastExceptionPtr == ei->ExceptionRecord.ExceptionAddress) bContinueDebugging = FALSE; + //if(ei->dwFirstChance == 0) bContinueDebugging = FALSE; + LastExceptionPtr = ei->ExceptionRecord.ExceptionAddress; + } + bContinueDebugging=false; + break; + case LOAD_DLL_DEBUG_EVENT: + //OutTrace("CreateProcess: event=%x(%s) dll=%s address=%x\n", + // debug_event.dwDebugEventCode, ExplainDebugEvent(debug_event.dwDebugEventCode), + // ((LOAD_DLL_DEBUG_INFO *)&debug_event.u)->lpImageName, ((LOAD_DLL_DEBUG_INFO *)&debug_event.u)->lpBaseOfDll); + CloseHandle(debug_event.u.LoadDll.hFile); + break; + case CREATE_THREAD_DEBUG_EVENT: + OutTraceB("CreateProcess: THREAD %x\n", debug_event.u.CreateThread.hThread); + break; + case EXIT_THREAD_DEBUG_EVENT: #ifdef LOCKINJECTIONTHREADS - if(TargetHandle && StartAddress){ - if(dxw.dwFlags5 & FREEZEINJECTEDSON){ - OutTrace("CreateProcess: FREEZEINJECTEDSON leaving son process in endless loop\n", GetLastError()); + if(TargetHandle && StartAddress){ + if(dxw.dwFlags5 & FREEZEINJECTEDSON){ + OutTrace("CreateProcess: FREEZEINJECTEDSON leaving son process in endless loop\n", GetLastError()); + } + else{ + if(!WriteProcessMemory(lpProcessInformation->hProcess, StartAddress, &StartingCode, 4, &BytesCount)){ + OutTrace("CreateProcess: WriteProcessMemory error=%d\n", GetLastError()); + } + } + CloseHandle((HANDLE)TargetHandle); + OutTrace("CreateProcess: injection terminated\n", res); } - else{ - if(!WriteProcessMemory(lpProcessInformation->hProcess, StartAddress, &StartingCode, 4, &BytesCount)){ - OutTrace("CreateProcess: WriteProcessMemory error=%d\n", GetLastError()); - } - } - CloseHandle((HANDLE)TargetHandle); - OutTrace("CreateProcess: injection terminated\n", res); - } #endif - bContinueDebugging=false; - case EXCEPTION_DEBUG_EVENT: - //OutTrace("CreateProcess: event=%x(%s)\n", debug_event.dwDebugEventCode, ExplainDebugEvent(debug_event.dwDebugEventCode)); - { - LPEXCEPTION_DEBUG_INFO ei; - ei=(LPEXCEPTION_DEBUG_INFO)&debug_event.u; - OutTraceE("CreateProcess: EXCEPTION code=%x flags=%x addr=%x firstchance=%x\n", - ei->ExceptionRecord.ExceptionCode, - ei->ExceptionRecord.ExceptionFlags, - ei->ExceptionRecord.ExceptionAddress, - debug_event.u.Exception.dwFirstChance); - // exception twice in same address, then do not continue. - if(LastExceptionPtr == ei->ExceptionRecord.ExceptionAddress) bContinueDebugging = FALSE; - //if(ei->dwFirstChance == 0) bContinueDebugging = FALSE; - LastExceptionPtr = ei->ExceptionRecord.ExceptionAddress; - } - break; - case LOAD_DLL_DEBUG_EVENT: - //OutTrace("CreateProcess: event=%x(%s) dll=%s address=%x\n", - // debug_event.dwDebugEventCode, ExplainDebugEvent(debug_event.dwDebugEventCode), - // ((LOAD_DLL_DEBUG_INFO *)&debug_event.u)->lpImageName, ((LOAD_DLL_DEBUG_INFO *)&debug_event.u)->lpBaseOfDll); - CloseHandle(((LOAD_DLL_DEBUG_INFO *)&debug_event.u)->hFile); - break; - case CREATE_THREAD_DEBUG_EVENT: - CloseHandle(((CREATE_THREAD_DEBUG_INFO *)&debug_event.u)->hThread); - break; - default: - break; + OutTraceB("CreateProcess: thread exit code=%x\n", debug_event.u.ExitThread.dwExitCode); + bContinueDebugging=false; + default: + break; } if(bContinueDebugging){ ContinueDebugEvent(debug_event.dwProcessId, @@ -1027,12 +1023,17 @@ BOOL WINAPI extCreateProcessA( dwContinueStatus); } else{ - DebugSetProcessKillOnExit(FALSE); ContinueDebugEvent(debug_event.dwProcessId, debug_event.dwThreadId, DBG_CONTINUE); - DebugActiveProcessStop(debug_event.dwProcessId); + if(!DebugSetProcessKillOnExit(FALSE)){ + OutTraceE("CreateProcess: DebugSetProcessKillOnExit ERROR err=%d\n", GetLastError()); + } + if(!DebugActiveProcessStop(debug_event.dwProcessId)){ + OutTraceE("CreateProcess: DebugActiveProcessStop ERROR err=%d\n", GetLastError()); + MessageBox(NULL, "Error in DebugActiveProcessStop", "dxwnd", MB_OK); + } } } - OutTrace("CreateProcess: detached\n", res); + OutTrace("CreateProcess: detached\n"); } else{ res=(*pCreateProcessA)( diff --git a/host/-dxwndhost.vs2008.suo b/host/-dxwndhost.vs2008.suo new file mode 100644 index 0000000..a23812b Binary files /dev/null and b/host/-dxwndhost.vs2008.suo differ diff --git a/host/CGlobalSettings.cpp b/host/CGlobalSettings.cpp new file mode 100644 index 0000000..c1afa05 --- /dev/null +++ b/host/CGlobalSettings.cpp @@ -0,0 +1,218 @@ +// CGlobalSettings.cpp : implementation file +// + +#include "stdafx.h" +#include "dxwndhost.h" +//#include "dxwndhostView.h" +#include "CGlobalSettings.h" + +extern char gInitPath[]; + +Key_Type FKeys[] = { + {IDC_KEY_LABEL1, "Time toggle", IDC_KEY_COMBO1, "timetoggle", 0}, + {IDC_KEY_LABEL2, "Time fast", IDC_KEY_COMBO2, "timefast", 0}, + {IDC_KEY_LABEL3, "Time slow", IDC_KEY_COMBO3, "timeslow", 0}, + {IDC_KEY_LABEL4, "Alt-F4", IDC_KEY_COMBO4, "altf4", 0}, + {IDC_KEY_LABEL5, "Clip toggle", IDC_KEY_COMBO5, "cliptoggle", 0}, + {IDC_KEY_LABEL6, "Refresh", IDC_KEY_COMBO6, "refresh", 0}, + {IDC_KEY_LABEL7, "Log toggle", IDC_KEY_COMBO7, "logtoggle", 0}, + {IDC_KEY_LABEL8, "label4", IDC_KEY_COMBO8, "plogtoggle", 0}, + {IDC_KEY_LABEL9, "FPS toggle", IDC_KEY_COMBO9, "fpstoggle", 0}, + {IDC_KEY_LABEL10, "Print screen", IDC_KEY_COMBO10, "printscreen", 0}, + {IDC_KEY_LABEL11, "Corner tog.", IDC_KEY_COMBO11, "corner", 0}, + {IDC_KEY_LABEL12, "Time freeze", IDC_KEY_COMBO12, "freezetime", 0}, + {IDC_KEY_LABEL13, "Fullscr. t.", IDC_KEY_COMBO13, "fullscreen", 0}, + {IDC_KEY_LABEL14, "Work area t.", IDC_KEY_COMBO14, "workarea", 0}, + {IDC_KEY_LABEL15, "Desktop t.", IDC_KEY_COMBO15, "desktop", 0}, + {0, "", 0, 0} +}; + +Key_Type HKeys[] = { + {IDC_HKEY_LABEL1, "Minimize", IDC_HKEY_COMBO1, "minimize", 0}, + {IDC_HKEY_LABEL2, "Restore", IDC_HKEY_COMBO2, "restore", 0}, + {IDC_HKEY_LABEL3, "Kill proc.", IDC_HKEY_COMBO3, "kill", 0}, + {0, "", 0, 0} +}; + +KeyCombo_Type FKeyCombo[] = { + {-1, "--"}, + {VK_F1, "F1"}, + {VK_F2, "F2"}, + {VK_F3, "F3"}, + {VK_F5, "F5"}, + {VK_F6, "F6"}, + {VK_F7, "F7"}, + {VK_F8, "F8"}, + {VK_F9, "F9"}, + {VK_F10, "F10"}, + {VK_F11, "F11"}, + {VK_F12, "F12"}, + {0, ""} +}; + +KeyCombo_Type HKeyCombo[] = { + {-1, "--"}, + {VK_END, "END"}, + {VK_HOME, "HOME"}, + {VK_DELETE, "DEL"}, + {VK_ESCAPE, "ESC"}, + {VK_F1, "F1"}, + {VK_F2, "F2"}, + {VK_F3, "F3"}, + {VK_F5, "F5"}, + {VK_F6, "F6"}, + {VK_F7, "F7"}, + {VK_F8, "F8"}, + {VK_F9, "F9"}, + {VK_F10, "F10"}, + {VK_F11, "F11"}, + {VK_F12, "F12"}, + {0, ""} +}; + +// CGlobalSettings dialog + +IMPLEMENT_DYNAMIC(CGlobalSettings, CDialog) + +CGlobalSettings::CGlobalSettings(CWnd* pParent /*=NULL*/) + : CDialog(CGlobalSettings::IDD, pParent) +{ +} + +CGlobalSettings::~CGlobalSettings() +{ +} + +void CGlobalSettings::DoDataExchange(CDataExchange* pDX) +{ + CDialog::DoDataExchange(pDX); + DDX_Check(pDX, IDC_CONFIG_DEBUGMODE, m_DebugMode); + DDX_Check(pDX, IDC_CONFIG_AUTOHIDE, m_AutoHideMode); + DDX_Check(pDX, IDC_CONFIG_CHECKADMIN, m_CheckAdminRights); + DDX_Check(pDX, IDC_CONFIG_SAVEPATHS, m_UpdatePaths); + DDX_Text (pDX, IDC_TEX_MINX, m_TexMinX); + DDX_Text (pDX, IDC_TEX_MINY, m_TexMinY); + DDX_Text (pDX, IDC_TEX_MAXX, m_TexMaxX); + DDX_Text (pDX, IDC_TEX_MAXY, m_TexMaxY); +} + +BEGIN_MESSAGE_MAP(CGlobalSettings, CDialog) +END_MESSAGE_MAP() + +#define IDPaletteTIMER 2 + +// CPaletteDialog message handlers + +//static void SetKeys(HWND hDlg, Key_Type *FKeys, KeyCombo_Type *FKeyCombo) +//{ +// for(int i=0; FKeys[i].iLabelResourceId; i++){ +// int iCursor = 0; +// DWORD dwKey; +// dwKey = GetPrivateProfileInt("keymapping", FKeys[i].sIniLabel, -1, gInitPath); +// SetDlgItemText(hDlg,FKeys[i].iLabelResourceId,FKeys[i].sLabel); +// CComboBox *pCombo=(CComboBox *)GetDlgItem(FKeys[i].iComboResourceId); +// pCombo->Clear(); +// for(int j=0; FKeyCombo[j].dwVKeyCode; j++) { +// pCombo->AddString(FKeyCombo[j].sVKeyLabel); +// if(dwKey == FKeyCombo[j].dwVKeyCode) iCursor=j; +// } +// pCombo->SetCurSel(iCursor); +// } +//} + +BOOL CGlobalSettings::OnInitDialog() +{ + for(int i=0; FKeys[i].iLabelResourceId; i++){ + int iCursor = 0; + DWORD dwKey; + dwKey = GetPrivateProfileInt("keymapping", FKeys[i].sIniLabel, -1, gInitPath); + SetDlgItemText(FKeys[i].iLabelResourceId,FKeys[i].sLabel); + CComboBox *pCombo=(CComboBox *)GetDlgItem(FKeys[i].iComboResourceId); + pCombo->Clear(); + for(int j=0; FKeyCombo[j].dwVKeyCode; j++) { + pCombo->AddString(FKeyCombo[j].sVKeyLabel); + if(dwKey == FKeyCombo[j].dwVKeyCode) iCursor=j; + } + pCombo->SetCurSel(iCursor); + } + for(int i=0; HKeys[i].iLabelResourceId; i++){ + int iCursor = 0; + DWORD dwKey; + dwKey = GetPrivateProfileInt("keymapping", HKeys[i].sIniLabel, -1, gInitPath); + SetDlgItemText(HKeys[i].iLabelResourceId,HKeys[i].sLabel); + CComboBox *pCombo=(CComboBox *)GetDlgItem(HKeys[i].iComboResourceId); + pCombo->Clear(); + for(int j=0; HKeyCombo[j].dwVKeyCode; j++) { + pCombo->AddString(HKeyCombo[j].sVKeyLabel); + if(dwKey == HKeyCombo[j].dwVKeyCode) iCursor=j; + } + pCombo->SetCurSel(iCursor); + } + //SetKeys(this, FKeys, FKeyCombo); + //SetKeys(this, HKeys, HKeyCombo); + + m_DebugMode = GetPrivateProfileInt("window", "debug", 0, gInitPath); + m_AutoHideMode = GetPrivateProfileInt("window", "autohide", 0, gInitPath); + m_CheckAdminRights = GetPrivateProfileInt("window", "checkadmin", 0, gInitPath); + m_UpdatePaths = GetPrivateProfileInt("window", "updatepaths", 1, gInitPath); + m_TexMinX = GetPrivateProfileInt("texture", "MinTexX", 0, gInitPath); + m_TexMinY = GetPrivateProfileInt("texture", "MinTexY", 0, gInitPath); + m_TexMaxX = GetPrivateProfileInt("texture", "MaxTexX", 0, gInitPath); + m_TexMaxY = GetPrivateProfileInt("texture", "MaxTexY", 0, gInitPath); + CDialog::OnInitDialog(); + return TRUE; // return TRUE unless you set the focus to a control + // EXCEPTION: OCX Property Pages should return FALSE +} + +void CGlobalSettings::OnOK() +{ + char val[32]; + CDialog::OnOK(); + // boolean flags + sprintf_s(val, sizeof(val), "%i", m_DebugMode); + WritePrivateProfileString("window", "debug", val, gInitPath); + sprintf_s(val, sizeof(val), "%i", m_AutoHideMode); + WritePrivateProfileString("window", "autohide", val, gInitPath); + sprintf_s(val, sizeof(val), "%i", m_CheckAdminRights); + WritePrivateProfileString("window", "checkadmin", val, gInitPath); + sprintf_s(val, sizeof(val), "%i", m_UpdatePaths); + WritePrivateProfileString("window", "updatepaths", val, gInitPath); + // texture limits + sprintf_s(val, sizeof(val), "%i", m_TexMinX); + WritePrivateProfileString("texture", "MinTexX", val, gInitPath); + sprintf_s(val, sizeof(val), "%i", m_TexMinY); + WritePrivateProfileString("texture", "MinTexY", val, gInitPath); + sprintf_s(val, sizeof(val), "%i", m_TexMaxX); + WritePrivateProfileString("texture", "MaxTexX", val, gInitPath); + sprintf_s(val, sizeof(val), "%i", m_TexMaxY); + WritePrivateProfileString("texture", "MaxTexY", val, gInitPath); + // fkeys + for(int i=0; FKeys[i].iLabelResourceId; i++){ + int iCursor = 0; + DWORD dwKey; + CComboBox *pCombo=(CComboBox *)GetDlgItem(FKeys[i].iComboResourceId); + dwKey = FKeyCombo[pCombo->GetCurSel()].dwVKeyCode; + if(dwKey != -1) { + char sKNum[20]; + sprintf_s(sKNum, sizeof(sKNum), "%i", dwKey); + WritePrivateProfileString("keymapping", FKeys[i].sIniLabel, sKNum, gInitPath); + } + else + WritePrivateProfileString("keymapping", FKeys[i].sIniLabel, "", gInitPath); + } + // hot keys + for(int i=0; HKeys[i].iLabelResourceId; i++){ + int iCursor = 0; + DWORD dwKey; + CComboBox *pCombo=(CComboBox *)GetDlgItem(HKeys[i].iComboResourceId); + dwKey = HKeyCombo[pCombo->GetCurSel()].dwVKeyCode; + if(dwKey != -1) { + char sKNum[20]; + sprintf_s(sKNum, sizeof(sKNum), "%i", dwKey); + WritePrivateProfileString("keymapping", HKeys[i].sIniLabel, sKNum, gInitPath); + } + else + WritePrivateProfileString("keymapping", HKeys[i].sIniLabel, "", gInitPath); + } + //(CDxwndhostView *)(this->GetParent())->UpdateHotKeys(); +} diff --git a/host/CGlobalSettings.h b/host/CGlobalSettings.h new file mode 100644 index 0000000..d961c61 --- /dev/null +++ b/host/CGlobalSettings.h @@ -0,0 +1,47 @@ +#pragma once + +typedef struct { + int iLabelResourceId; + char *sLabel; + int iComboResourceId; + char *sIniLabel; + int iComboSelection; +} Key_Type; + +typedef struct { + DWORD dwVKeyCode; + char *sVKeyLabel; +} KeyCombo_Type; + +// CGlobalSettings dialog + +class CGlobalSettings : public CDialog +{ + DECLARE_DYNAMIC(CGlobalSettings) + +public: + CGlobalSettings(CWnd* pParent = NULL); // standard constructor + virtual ~CGlobalSettings(); + +// Dialog Data + enum { IDD = IDD_GLOBAL_CONFIG }; + +protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support + + BOOL m_DebugMode; + BOOL m_UpdatePaths; + BOOL m_AutoHideMode; + BOOL m_CheckAdminRights; + int m_TexMinX; + int m_TexMinY; + int m_TexMaxX; + int m_TexMaxY; + + DECLARE_MESSAGE_MAP() +public: +public: + virtual BOOL OnInitDialog(); +protected: + virtual void OnOK(); +}; diff --git a/host/alt-ctrl-shift.png b/host/alt-ctrl-shift.png new file mode 100644 index 0000000..3067b33 Binary files /dev/null and b/host/alt-ctrl-shift.png differ diff --git a/host/alt.png b/host/alt.png new file mode 100644 index 0000000..57c9d2b Binary files /dev/null and b/host/alt.png differ diff --git a/host/dxwndhost.aps b/host/dxwndhost.aps index 105de25..b86bcd5 100644 Binary files a/host/dxwndhost.aps and b/host/dxwndhost.aps differ diff --git a/host/dxwndhost.rc b/host/dxwndhost.rc index e2fabd8..df676ff 100644 Binary files a/host/dxwndhost.rc and b/host/dxwndhost.rc differ diff --git a/host/dxwndhost.vs2008.sln b/host/dxwndhost.vs2008.sln deleted file mode 100644 index 5bf4fb1..0000000 --- a/host/dxwndhost.vs2008.sln +++ /dev/null @@ -1,20 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 10.00 -# Visual Studio 2008 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "dxwndhost", "dxwndhost.vs2008.vcproj", "{FD0B0234-8EC5-43C0-A384-1B881DD3D925}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Release|Win32 = Release|Win32 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {FD0B0234-8EC5-43C0-A384-1B881DD3D925}.Debug|Win32.ActiveCfg = Debug|Win32 - {FD0B0234-8EC5-43C0-A384-1B881DD3D925}.Debug|Win32.Build.0 = Debug|Win32 - {FD0B0234-8EC5-43C0-A384-1B881DD3D925}.Release|Win32.ActiveCfg = Release|Win32 - {FD0B0234-8EC5-43C0-A384-1B881DD3D925}.Release|Win32.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/host/dxwndhost.vs2008.suo b/host/dxwndhost.vs2008.suo index 9fc09eb..fa826d6 100644 Binary files a/host/dxwndhost.vs2008.suo and b/host/dxwndhost.vs2008.suo differ diff --git a/host/dxwndhost.vs2008.vcproj b/host/dxwndhost.vs2008.vcproj index bbe4e0b..c567b8d 100644 --- a/host/dxwndhost.vs2008.vcproj +++ b/host/dxwndhost.vs2008.vcproj @@ -221,6 +221,10 @@ Name="Source Files" Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" > + + @@ -504,6 +508,10 @@ RelativePath=".\cdib.h" > + + @@ -617,6 +625,14 @@ Name="Resource Files" Filter="ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" > + + + + @@ -698,6 +714,22 @@ > + + + + + + + + diff --git a/host/dxwndhostView.cpp b/host/dxwndhostView.cpp index 50e25ae..4a3299f 100644 --- a/host/dxwndhostView.cpp +++ b/host/dxwndhostView.cpp @@ -17,6 +17,7 @@ #include "PaletteDialog.h" #include "TimeSliderDialog.h" #include "ShimsDialog.h" +#include "CGlobalSettings.h" #ifdef _DEBUG #define new DEBUG_NEW @@ -126,13 +127,13 @@ BEGIN_MESSAGE_MAP(CDxwndhostView, CListView) ON_COMMAND(ID_FILE_IMPORT, OnImport) ON_COMMAND(ID_DELETE, OnDelete) ON_COMMAND(ID_FILE_SORTPROGRAMSLIST, OnSort) + ON_COMMAND(ID_EDIT_GLOBALSETTINGS, OnGlobalSettings) ON_COMMAND(ID_FILE_CLEARALLLOGS, OnClearAllLogs) ON_COMMAND(ID_FILE_GOTOTRAYICON, OnGoToTrayIcon) ON_COMMAND(ID_FILE_SAVE, OnSaveFile) ON_COMMAND(ID_HOOK_START, OnHookStart) ON_COMMAND(ID_HOOK_STOP, OnHookStop) ON_COMMAND(ID_DXAPP_EXIT, OnExit) - ON_WM_RBUTTONDOWN() ON_COMMAND(ID_RUN, OnRun) ON_COMMAND(ID_TRAY_RESTORE, OnTrayRestore) ON_COMMAND(ID_VIEW_STATUS, OnViewStatus) @@ -150,6 +151,8 @@ BEGIN_MESSAGE_MAP(CDxwndhostView, CListView) ON_COMMAND(ID_MOVE_UP, OnMoveUp) ON_COMMAND(ID_MOVE_DOWN, OnMoveDown) ON_COMMAND(ID_MOVE_BOTTOM, OnMoveBottom) + ON_WM_RBUTTONDOWN() + ON_WM_HOTKEY() //}}AFX_MSG_MAP END_MESSAGE_MAP() @@ -1105,6 +1108,44 @@ void CDxwndhostView::OnDraw(CDC* pDC) ASSERT_VALID(pDoc); } +void CDxwndhostView::OnHotKey(UINT nHotKeyId, UINT nKey1, UINT nKey2) +{ + switch(nHotKeyId){ + case 0: // minimize + this->OnWindowMinimize(); + break; + case 1: // restore + this->OnWindowRestore(); + break; + case 2: // kill + this->OnProcessKill(); + break; + } +} + +void VKeyError(char *key) +{ + char Msg[81]; + sprintf(Msg, "RegisterHotKey(%s) failed err=%d", key, GetLastError()); + MessageBox(NULL, Msg, "DxWnd error", MB_OK+MB_ICONWARNING); +} + +void CDxwndhostView::UpdateHotKeys() +{ + // Hot Keys + DWORD dwKey; + extern Key_Type HKeys[]; + extern KeyCombo_Type HKeyCombo[]; + // MessageBox("update global settings", "debug", MB_OK); + for(int i=0; HKeys[i].iLabelResourceId; i++){ + dwKey = GetPrivateProfileInt("keymapping", HKeys[i].sIniLabel, 0, gInitPath); + if(dwKey) { + UnregisterHotKey(this->GetSafeHwnd(), i); + if(!RegisterHotKey(this->GetSafeHwnd(), i, MOD_ALT+MOD_SHIFT+MOD_CONTROL, dwKey)) VKeyError(HKeys[i].sIniLabel); + } + } +} + void CDxwndhostView::OnInitialUpdate() { CListView::OnInitialUpdate(); @@ -1167,6 +1208,17 @@ void CDxwndhostView::OnInitialUpdate() pTitles = &PrivateMaps[0]; pTargets= &TargetMaps[0]; + // Hot Keys + //DWORD dwKey; + //extern Key_Type HKeys[]; + //extern KeyCombo_Type HKeyCombo[]; + //for(int i=0; HKeys[i].iLabelResourceId; i++){ + // dwKey = GetPrivateProfileInt("keymapping", HKeys[i].sIniLabel, 0, gInitPath); + // if(dwKey) if(!RegisterHotKey(this->GetSafeHwnd(), i, MOD_ALT+MOD_SHIFT+MOD_CONTROL, dwKey)) VKeyError(HKeys[i].sIniLabel); + //} + UpdateHotKeys(); + + // Transient mode if(gTransientMode){ this->OnRun(); } @@ -1651,28 +1703,29 @@ void CDxwndhostView::OnResume() extern HWND find_main_window(unsigned long); -void CDxwndhostView::OnWindowMinimize() +static void SendMessageToHookedWin(DWORD message) { DXWNDSTATUS DxWndStatus; - if ((GetHookStatus(&DxWndStatus) == DXW_RUNNING) && (DxWndStatus.hWnd!=NULL)) - //::PostMessage(DxWndStatus.hWnd, WM_SYSCOMMAND, SC_MINIMIZE, 0); - ::PostMessage(find_main_window(DxWndStatus.dwPid), WM_SYSCOMMAND, SC_MINIMIZE, 0); + HWND TargethWnd; + if (GetHookStatus(&DxWndStatus) == DXW_RUNNING){ + TargethWnd = (DxWndStatus.hWnd) ? DxWndStatus.hWnd : find_main_window(DxWndStatus.dwPid); + ::PostMessage(TargethWnd, WM_SYSCOMMAND, message, 0); + } +} + +void CDxwndhostView::OnWindowMinimize() +{ + SendMessageToHookedWin(SC_MINIMIZE); } void CDxwndhostView::OnWindowRestore() { - DXWNDSTATUS DxWndStatus; - if ((GetHookStatus(&DxWndStatus) == DXW_RUNNING) && (DxWndStatus.hWnd!=NULL)) - //::PostMessage(DxWndStatus.hWnd, WM_SYSCOMMAND, SC_RESTORE, 0); - ::PostMessage(find_main_window(DxWndStatus.dwPid), WM_SYSCOMMAND, SC_RESTORE, 0); + SendMessageToHookedWin(SC_RESTORE); } void CDxwndhostView::OnWindowClose() { - DXWNDSTATUS DxWndStatus; - if ((GetHookStatus(&DxWndStatus) == DXW_RUNNING) && (DxWndStatus.hWnd!=NULL)) - //::PostMessage(DxWndStatus.hWnd, WM_SYSCOMMAND, SC_CLOSE, 0); - ::PostMessage(find_main_window(DxWndStatus.dwPid), WM_SYSCOMMAND, SC_CLOSE, 0); + SendMessageToHookedWin(SC_CLOSE); } void CDxwndhostView::OnTaskbarHide() @@ -2211,6 +2264,13 @@ void CDxwndhostView::OnViewPalette() pDlg->ShowWindow(SW_SHOW); } +void CDxwndhostView::OnGlobalSettings() +{ + CGlobalSettings *pDlg = new CGlobalSettings(); + BOOL ret = pDlg->Create(CGlobalSettings::IDD, this); + pDlg->ShowWindow(SW_SHOW); +} + void CDxwndhostView::OnViewTimeSlider() { CTimeSliderDialog *pDlg = new CTimeSliderDialog(); @@ -2401,7 +2461,7 @@ DWORD WINAPI StartDebug(void *p) (strlen(ThInfo->PM->launchpath)>0) ? ThInfo->PM->launchpath : ThInfo->TM->path, 0, 0, false, DEBUG_PROCESS|DEBUG_ONLY_THIS_PROCESS, NULL, path, &sinfo, &pinfo)){ sprintf(DebugMessage, "CREATE PROCESS error=%d", GetLastError()); - MessageBoxEx(0, DebugMessage, "ERROR", MB_YESNO | MB_ICONQUESTION, NULL); + MessageBoxEx(0, DebugMessage, "ERROR", MB_ICONEXCLAMATION|MB_OK, NULL); } CString strEventMessage; @@ -2421,7 +2481,7 @@ DWORD WINAPI StartDebug(void *p) if(!Inject(pinfo.dwProcessId, path)){ // DXW_STRING_INJECTION sprintf(DebugMessage,"Injection error: pid=%x dll=%s", pinfo.dwProcessId, path); - MessageBoxEx(0, DebugMessage, "Injection", MB_ICONEXCLAMATION, NULL); + MessageBoxEx(0, DebugMessage, "Injection", MB_ICONEXCLAMATION|MB_OK, NULL); } #ifdef LOCKINJECTIONTHREADS extern LPVOID GetThreadStartAddress(HANDLE); @@ -2434,11 +2494,11 @@ DWORD WINAPI StartDebug(void *p) if(StartAddress){ if(!ReadProcessMemory(pinfo.hProcess, StartAddress, &StartingCode, 4, &BytesCount)){ sprintf(DebugMessage,"ReadProcessMemory error=%d", GetLastError()); - MessageBoxEx(0, DebugMessage, "Injection", MB_ICONEXCLAMATION, NULL); + MessageBoxEx(0, DebugMessage, "Injection", MB_ICONEXCLAMATION|MB_OK, NULL); } if(!WriteProcessMemory(pinfo.hProcess, StartAddress, &EndlessLoop, 4, &BytesCount)){ sprintf(DebugMessage,"WriteProcessMemory error=%d", GetLastError()); - MessageBoxEx(0, DebugMessage, "Injection", MB_ICONEXCLAMATION, NULL); + MessageBoxEx(0, DebugMessage, "Injection", MB_ICONEXCLAMATION|MB_OK, NULL); } } } @@ -2455,7 +2515,7 @@ DWORD WINAPI StartDebug(void *p) if(TargetHandle && StartAddress){ if(!WriteProcessMemory(pinfo.hProcess, StartAddress, &StartingCode, 4, &BytesCount)){ sprintf(DebugMessage,"WriteProcessMemory error=%d", GetLastError()); - MessageBoxEx(0, DebugMessage, "Injection", MB_ICONEXCLAMATION, NULL); + MessageBoxEx(0, DebugMessage, "Injection", MB_ICONEXCLAMATION|MB_OK, NULL); } } if(TargetHandle) CloseHandle((HANDLE)TargetHandle); diff --git a/host/dxwndhostView.h b/host/dxwndhostView.h index 287005a..835cbd0 100644 --- a/host/dxwndhostView.h +++ b/host/dxwndhostView.h @@ -15,6 +15,7 @@ class CDxwndhostView : public CListView { protected: // Create from serialization only features. CDxwndhostView(); + afx_msg void OnHotKey(UINT, UINT, UINT); DECLARE_DYNCREATE(CDxwndhostView) BOOL isUpdated; void SaveConfigFile(); @@ -43,6 +44,7 @@ public: virtual BOOL PreCreateWindow(CREATESTRUCT& cs); protected: virtual void OnInitialUpdate(); // Called once after the initial construction. + void UpdateHotKeys(); //}}AFX_VIRTUAL // Implementation @@ -76,6 +78,7 @@ protected: afx_msg void OnTaskbarHide(); afx_msg void OnTaskbarShow(); afx_msg void OnSort(); + afx_msg void OnGlobalSettings(); afx_msg void OnViewLog(); afx_msg void OnDeleteLog(); afx_msg void OnDebugView(); diff --git a/host/host.aps b/host/host.aps index 561c5ce..2ead7e8 100644 Binary files a/host/host.aps and b/host/host.aps differ diff --git a/host/res/alt-ctrl-shift.bmp b/host/res/alt-ctrl-shift.bmp new file mode 100644 index 0000000..0caa8d2 Binary files /dev/null and b/host/res/alt-ctrl-shift.bmp differ diff --git a/host/res/alt.bmp b/host/res/alt.bmp new file mode 100644 index 0000000..20b2a79 Binary files /dev/null and b/host/res/alt.bmp differ diff --git a/host/resource b/host/resource index d39417f..2c6819e 100644 Binary files a/host/resource and b/host/resource differ