diff --git a/Source/Project64/N64System/Debugger/Debugger-Commands.cpp b/Source/Project64/N64System/Debugger/Debugger-Commands.cpp index f344075e9..84dde7dbe 100644 --- a/Source/Project64/N64System/Debugger/Debugger-Commands.cpp +++ b/Source/Project64/N64System/Debugger/Debugger-Commands.cpp @@ -136,6 +136,7 @@ LRESULT CDebugCommandsView::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARA LRESULT CDebugCommandsView::OnDestroy(void) { + UnhookWindowsHookEx(hWinMessageHook); return 0; } diff --git a/Source/Project64/N64System/Debugger/Debugger-ViewMemory.cpp b/Source/Project64/N64System/Debugger/Debugger-ViewMemory.cpp index bb75122d1..134097c62 100644 --- a/Source/Project64/N64System/Debugger/Debugger-ViewMemory.cpp +++ b/Source/Project64/N64System/Debugger/Debugger-ViewMemory.cpp @@ -14,6 +14,9 @@ #include "Symbols.h" #include "DMALog.h" +CDebugMemoryView* CDebugMemoryView::_this = NULL; +HHOOK CDebugMemoryView::hWinMessageHook = NULL; + CDebugMemoryView::CDebugMemoryView(CDebuggerUI * debugger) : CDebugDialog(debugger), m_MemoryList(NULL) @@ -115,10 +118,15 @@ LRESULT CDebugMemoryView::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM m_SymInfo.Attach(GetDlgItem(IDC_SYM_INFO)); m_DMAInfo.Attach(GetDlgItem(IDC_DMA_INFO)); + _this = this; + + DWORD dwThreadID = ::GetCurrentThreadId(); + hWinMessageHook = SetWindowsHookEx(WH_GETMESSAGE, (HOOKPROC)HookProc, NULL, dwThreadID); + WindowCreated(); m_AutoRefreshThread = CreateThread(NULL, 0, AutoRefreshProc, (void*)this, 0, NULL); - + return TRUE; } @@ -132,6 +140,33 @@ DWORD WINAPI CDebugMemoryView::AutoRefreshProc(void* _this) } } +void CDebugMemoryView::InterceptMouseWheel(WPARAM wParam, LPARAM lParam) +{ + uint32_t newAddress = m_DataStartLoc - ((short)HIWORD(wParam) / WHEEL_DELTA) * 16; + + m_DataStartLoc = newAddress; + + m_MemAddr.SetValue(m_DataStartLoc, false, true); +} + +LRESULT CALLBACK CDebugMemoryView::HookProc(int nCode, WPARAM wParam, LPARAM lParam) +{ + MSG *pMsg = (MSG*)lParam; + + if (pMsg->message == WM_MOUSEWHEEL) + { + BOOL bHandled = TRUE; + _this->InterceptMouseWheel(pMsg->wParam, pMsg->lParam); + } + + if (nCode < 0) + { + return CallNextHookEx(hWinMessageHook, nCode, wParam, lParam); + } + + return 0; +} + LRESULT CDebugMemoryView::OnDestroy(void) { if (m_AutoRefreshThread != NULL) @@ -145,6 +180,7 @@ LRESULT CDebugMemoryView::OnDestroy(void) delete m_MemoryList; m_MemoryList = NULL; } + UnhookWindowsHookEx(hWinMessageHook); return 0; } diff --git a/Source/Project64/N64System/Debugger/Debugger-ViewMemory.h b/Source/Project64/N64System/Debugger/Debugger-ViewMemory.h index 94ed3e6e6..d9ca22813 100644 --- a/Source/Project64/N64System/Debugger/Debugger-ViewMemory.h +++ b/Source/Project64/N64System/Debugger/Debugger-ViewMemory.h @@ -60,6 +60,12 @@ private: enum { MemoryToDisplay = 0x100 }; + static CDebugMemoryView* _this; + static HHOOK hWinMessageHook; + static LRESULT CALLBACK HookProc(int nCode, WPARAM wParam, LPARAM lParam); + + void InterceptMouseWheel(WPARAM wParam, LPARAM lParam); + CEditNumber m_MemAddr; CListCtrl * m_MemoryList; CAddSymbolDlg m_AddSymbolDlg;