From 5464831d79d031f5ce2dd64c98e34f7eef33a01a Mon Sep 17 00:00:00 2001 From: dude719 Date: Sun, 1 Jan 2017 03:26:42 -0400 Subject: [PATCH] Fixed scrolling and optimized navigating nodes via up and down arrows. --- ReClass/CChildFrame.cpp | 10 +- ReClass/CChildView.cpp | 268 ++++++++++++++++++++++++++-------------- ReClass/CChildView.h | 1 + ReClass/CMainFrame.cpp | 31 ++--- ReClass/CNodeClass.h | 1 - ReClass/DialogModules.h | 43 +++---- ReClass/ReClass2016.cpp | 102 +++++++-------- ReClass/ReClass2016.h | 1 + 8 files changed, 276 insertions(+), 181 deletions(-) diff --git a/ReClass/CChildFrame.cpp b/ReClass/CChildFrame.cpp index af2f65d..de66557 100644 --- a/ReClass/CChildFrame.cpp +++ b/ReClass/CChildFrame.cpp @@ -28,6 +28,8 @@ CChildFrame::~CChildFrame( ) BOOL CChildFrame::PreCreateWindow( CREATESTRUCT& cs ) { + //cs.cy += g_FontHeight; + // TODO: Modify the Window class or styles here by modifying the CREATESTRUCT cs if (!CMDIChildWndEx::PreCreateWindow( cs )) return FALSE; @@ -61,10 +63,12 @@ void CChildFrame::OnFileClose( ) int CChildFrame::OnCreate( LPCREATESTRUCT lpCreateStruct ) { + //lpCreateStruct->cy += g_FontHeight; + if (CMDIChildWndEx::OnCreate( lpCreateStruct ) == -1) return -1; - // create a view to occupy the client area of the frame + // Create a view to occupy the client area of the frame if (!m_ChildView.Create( NULL, NULL, AFX_WS_DEFAULT_VIEW, CRect( 0, 0, 0, 0 ), this, AFX_IDW_PANE_FIRST, NULL )) { TRACE0( "Failed to create view window\n" ); @@ -82,9 +86,9 @@ void CChildFrame::OnSetFocus( CWnd* pOldWnd ) BOOL CChildFrame::OnCmdMsg( UINT nID, int nCode, void* pExtra, AFX_CMDHANDLERINFO* pHandlerInfo ) { - // let the view have first crack at the command + // Let the view have first crack at the command if (m_ChildView.OnCmdMsg( nID, nCode, pExtra, pHandlerInfo )) return TRUE; - // otherwise, do default handling + // Otherwise, do default handling return CMDIChildWndEx::OnCmdMsg( nID, nCode, pExtra, pHandlerInfo ); } diff --git a/ReClass/CChildView.cpp b/ReClass/CChildView.cpp index ed872fe..582d3cc 100644 --- a/ReClass/CChildView.cpp +++ b/ReClass/CChildView.cpp @@ -145,16 +145,18 @@ END_MESSAGE_MAP( ) // CChildView message handlers BOOL CChildView::PreCreateWindow( CREATESTRUCT& cs ) { + //cs.cy += g_FontHeight; if (!CWnd::PreCreateWindow( cs )) return FALSE; - cs.dwExStyle |= WS_EX_CLIENTEDGE; + cs.dwExStyle |= WS_EX_STATICEDGE; cs.style &= ~WS_BORDER; - cs.lpszClass = AfxRegisterWndClass( CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS, ::LoadCursor( NULL, IDC_ARROW ), (HBRUSH)(COLOR_WINDOWFRAME), NULL ); + cs.lpszClass = AfxRegisterWndClass( CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS, ::LoadCursor( NULL, IDC_ARROW ), (HBRUSH)COLOR_WINDOWFRAME, NULL ); return TRUE; } int CChildView::OnCreate( LPCREATESTRUCT lpCreateStruct ) { + lpCreateStruct->cy += g_FontHeight; if (CWnd::OnCreate( lpCreateStruct ) == -1) return -1; @@ -188,65 +190,110 @@ void CChildView::OnKeyDown( UINT nChar, UINT nRepCnt, UINT nFlags ) { if (nChar == VK_DOWN) { - if (Selected.size( ) > 0) + auto firstSelected = Selected.begin( ); + if (firstSelected != Selected.end( )) { - HotSpot* firstSelected = &Selected[0]; - if (firstSelected->Address != HotSpots[HotSpots.size( ) - 1].Address) + if (firstSelected->object->GetType( ) == nt_pointer) { - g_ReClassApp.ClearSelection( ); - Selected.clear( ); + CNodePtr* pPtrNode = (CNodePtr*)firstSelected->object; + CNodeBase* pFindClassNode = (CNodeBase*)pPtrNode->GetClass( ); - for (UINT i = 0; i < HotSpots.size( ); i++) + auto found = std::find_if( HotSpots.begin( ), HotSpots.end( ), + [pFindClassNode] ( const HotSpot hs ) { return (hs.object == pFindClassNode); } ); + if (found != HotSpots.end( )) { - if (HotSpots[i].Type != HS_SELECT) - continue; - if (firstSelected->Address != HotSpots[i].Address) - continue; - if (HotSpots[0].object == firstSelected->object) // stop from crashing - continue; + ClearSelection( ); - size_t nextAddress = HotSpots[i].Address + firstSelected->object->GetMemorySize( ); + found->object->Select( ); + Selected.push_back( *found ); + } + } + else if (firstSelected->object->GetType( ) == nt_class) + { + CNodeClass* pClassNode = (CNodeClass*)firstSelected->object; + CNodeBase* pFindNode = (CNodeBase*)pClassNode->GetNode( 0 ); - UINT newIndex = 0; - for (int j = 0; HotSpots[i + j].Address != nextAddress; j++) - newIndex = i + j + 1; + auto found = std::find_if( HotSpots.begin( ), HotSpots.end( ), + [pFindNode] ( const HotSpot hs ) { return (hs.object == pFindNode); } ); + if (found != HotSpots.end( )) + { + ClearSelection( ); - HotSpots[newIndex].object->Select( ); - Selected.push_back( HotSpots[newIndex] ); + found->object->Select( ); + Selected.push_back( *found ); + } + } + else + { + if (HotSpots[0].object != firstSelected->object) + { + ULONG_PTR findAddress = firstSelected->Address + firstSelected->object->GetMemorySize( ); - break; + auto found = std::find_if( HotSpots.begin( ), HotSpots.end( ), + [findAddress] ( const HotSpot hs ) { return (hs.Address == findAddress); } ); + if (found != HotSpots.end( )) + { + if (found->Address == HotSpots.back( ).Address) + { + if (m_Scroll.IsWindowEnabled( )) + m_Scroll.SetScrollPos( m_Scroll.GetScrollPos( ) + 1 ); + } + + ClearSelection( ); + found->object->Select( ); + Selected.push_back( *found ); + } + //else // Not found + //{ + // CNodeBase* selectedObject = firstSelected->object; + // CNodeBase* selectedObjectParent = selectedObject->GetParent( ); + // if (selectedObjectParent->GetType( ) == nt_class) + // { + // + // } + //} } } + + // Force redraw so it doesn't appear laggy + Invalidate( ); } } else if (nChar == VK_UP) { - if (Selected.size( ) > 0) + auto firstSelected = Selected.begin( ); + if (firstSelected != Selected.end( )) { - HotSpot* firstSelected = &Selected[0]; - if (firstSelected->Address != HotSpots[0].Address) + if ( + firstSelected->Address == (HotSpots[0].Address + HotSpots[0].object->GetMemorySize( )) || + firstSelected->object == HotSpots.begin( )->object) { - g_ReClassApp.ClearSelection( ); - Selected.clear( ); - - for (UINT i = 0; i < HotSpots.size( ); i++) + if (m_Scroll.IsWindowEnabled( )) { - if (HotSpots[i].Type != HS_SELECT) - continue; - if (firstSelected->Address != HotSpots[i].Address) - continue; + INT scrollPos = m_Scroll.GetScrollPos( ); + m_Scroll.SetScrollPos( (scrollPos != 0) ? scrollPos - 1 : 0 ); + } + } - HotSpots[i - 1].object->Select( ); - Selected.push_back( HotSpots[i - 1] ); + ULONG_PTR findAddress = firstSelected->Address; - break; - } + auto found = std::find_if( HotSpots.begin( ), HotSpots.end( ), + [findAddress] ( const HotSpot hs ) { return (hs.Address == findAddress); } ); + if (found != HotSpots.end( )) + { + ClearSelection( ); + if (found != HotSpots.begin( )) + found--; + found->object->Select( ); + Selected.push_back( *found ); } + + // Force redraw so it doesn't appear laggy + Invalidate( ); } } else if (nChar == VK_DELETE) { - //isDeleting = true; // Ghetto fix to stop crashing from OnMouseHover for (UINT i = 0; i < Selected.size( ); i++) { CNodeClass* pClass = (CNodeClass*)Selected[i].object->GetParent( ); @@ -258,7 +305,6 @@ void CChildView::OnKeyDown( UINT nChar, UINT nRepCnt, UINT nFlags ) } } Selected.clear( ); - //isDeleting = false; } CWnd::OnKeyDown( nChar, nRepCnt, nFlags ); @@ -286,10 +332,10 @@ void CChildView::OnLButtonDblClk( UINT nFlags, CPoint point ) m_Edit.SetSel( 0, 1024 ); return; } - else if (HotSpots[i].Type == HS_SCINTILLA_EDIT) - { - - } + //else if (HotSpots[i].Type == HS_SCINTILLA_EDIT) + //{ + // //(HotSpots[i].object)-> + //} } } } @@ -381,8 +427,10 @@ void CChildView::OnLButtonDown( UINT nFlags, CPoint point ) { if (nFlags == MK_LBUTTON) { - g_ReClassApp.ClearSelection( ); - Selected.clear( ); + //g_ReClassApp.ClearSelection( ); + //Selected.clear( ); + ClearSelection( ); + pHitObject->Select( ); Selected.push_back( HotSpots[i] ); } @@ -429,8 +477,10 @@ void CChildView::OnLButtonDown( UINT nFlags, CPoint point ) idx2 = idxTemp; } - g_ReClassApp.ClearSelection( ); - Selected.clear( ); + //g_ReClassApp.ClearSelection( ); + //Selected.clear( ); + ClearSelection( ); + for (UINT s = idx1; s <= idx2; s++) { pClass->GetNode( s )->Select( ); @@ -456,7 +506,6 @@ void CChildView::OnLButtonDown( UINT nFlags, CPoint point ) if (HotSpots[i].Type == HS_DELETE) { - //isDeleting = true; // Ghetto fix to stop crashing from OnMouseHover for (UINT i = 0; i < Selected.size( ); i++) { CNodeClass* pClass = (CNodeClass*)Selected[i].object->GetParent( ); @@ -468,7 +517,6 @@ void CChildView::OnLButtonDown( UINT nFlags, CPoint point ) } } Selected.clear( ); - //isDeleting = false; } if ((HotSpots[i].Type == HS_CHANGE_A) || (HotSpots[i].Type == HS_CHANGE_X)) @@ -533,6 +581,38 @@ void CChildView::OnLButtonDown( UINT nFlags, CPoint point ) void CChildView::OnRButtonDown( UINT nFlags, CPoint point ) { m_Edit.ShowWindow( SW_HIDE ); + + //for (auto hs : HotSpots) + //{ + // if (hs.Rect.PtInRect( point )) + // { + // CNodeBase* pHitObject = (CNodeBase*)hs.object; + // if (hs.Type == HS_CLICK) + // { + // pHitObject->Update( hs ); + // } + // else if (hs.Type == HS_SELECT) + // { + // if (nFlags == MK_RBUTTON) + // { + // ClearSelection( ); + // + // pHitObject->Select( ); + // Selected.push_back( hs ); + // + // CRect client; + // GetClientRect( &client ); + // ClientToScreen( &client ); + // + // CMenu menu; + // menu.LoadMenu( MAKEINTRESOURCE( IDR_MENU_QUICKMODIFY ) ); + // menu.GetSubMenu( 0 )->TrackPopupMenu( TPM_LEFTALIGN | TPM_HORNEGANIMATION, client.left + hs.Rect.left + point.x, client.top + point.y, this ); + // } + // } + // Invalidate( ); + // } + //} + for (UINT i = 0; i < HotSpots.size( ); i++) { if (HotSpots[i].Rect.PtInRect( point )) @@ -546,8 +626,8 @@ void CChildView::OnRButtonDown( UINT nFlags, CPoint point ) { if (nFlags == MK_RBUTTON) { - g_ReClassApp.ClearSelection( ); - Selected.clear( ); + ClearSelection( ); + pHitObject->Select( ); Selected.push_back( HotSpots[i] ); @@ -569,24 +649,18 @@ void CChildView::OnRButtonDown( UINT nFlags, CPoint point ) void CChildView::OnPaint( ) { - CRect clientRect( 0, 0, 0, 0 ); - DWORD classSize = 0; - CPaintDC paintDC( this ); // device context for painting CMemDC memDC( paintDC, this ); - CDC& DC = memDC.GetDC( ); - - //HotSpots.clear( ); - + CDC& dc = memDC.GetDC( ); + DWORD classSize = 0; + CRect clientRect; GetClientRect( &clientRect ); - - DC.FillSolidRect( &clientRect, g_crBackground ); + //clientRect.bottom += g_FontHeight; + dc.FillSolidRect( &clientRect, g_crBackground ); if (m_pClass != NULL) { - ViewInfo View; - - DC.SelectObject( &g_ViewFont ); + dc.SelectObject( &g_ViewFont ); HotSpots.clear( ); @@ -594,6 +668,7 @@ void CChildView::OnPaint( ) m_Memory.SetSize( classSize ); ReClassReadMemory( (LPVOID)m_pClass->GetOffset( ), m_Memory.Data( ), classSize ); + ViewInfo View; #ifdef _DEBUG View.pChildView = this; // For testing #endif @@ -601,7 +676,7 @@ void CChildView::OnPaint( ) View.pData = m_Memory.Data( ); View.Classes = &g_ReClassApp.m_Classes; View.client = &clientRect; - View.dc = &DC; + View.dc = &dc; View.Level = 0; View.HotSpots = &HotSpots; View.bMultiSelected = (Selected.size( ) > 1) ? true : false; @@ -609,13 +684,12 @@ void CChildView::OnPaint( ) if (m_Scroll.IsWindowVisible( )) View.client->right -= SB_WIDTH; - int ypos = m_Scroll.GetScrollPos( ) * g_FontHeight; - - int DrawMax = m_pClass->Draw( View, 0, -ypos ) + ypos; + int ypos = (m_Scroll.GetScrollPos( ) * g_FontHeight); + int DrawMax = m_pClass->Draw( View, 0, -ypos ) + ypos + g_FontHeight; if (m_pClass->RequestPosition != -1) { - if ((m_pClass->RequestPosition >= 0) && ((unsigned int)m_pClass->RequestPosition < g_ReClassApp.m_Classes.size( ))) + if ((m_pClass->RequestPosition >= 0) && (m_pClass->RequestPosition < (int)g_ReClassApp.m_Classes.size( ))) { int idx = -1; for (UINT i = 0; i < g_ReClassApp.m_Classes.size( ); i++) @@ -633,6 +707,7 @@ void CChildView::OnPaint( ) if (clientRect.Height( ) < DrawMax) { SCROLLINFO si; + ZeroMemory( &si, sizeof( SCROLLINFO ) ); si.cbSize = sizeof( SCROLLINFO ); si.fMask = SIF_PAGE | SIF_RANGE; si.nMin = 0; @@ -647,30 +722,24 @@ void CChildView::OnPaint( ) m_Scroll.ShowScrollBar( FALSE ); } - - // This makes tabs CMDIFrameWnd* pFrame = STATIC_DOWNCAST( CMDIFrameWnd, AfxGetApp( )->m_pMainWnd ); CChildFrame* pChild = STATIC_DOWNCAST( CChildFrame, pFrame->GetActiveFrame( ) ); - if (pChild->m_ChildView.m_hWnd == m_hWnd) { pChild->SetWindowText( m_pClass->GetName( ) ); pChild->SetTitle( m_pClass->GetName( ) ); pFrame->UpdateFrameTitleForDocument( m_pClass->GetName( ) ); - //char txt[256]; - //sprintf (txt,"Total HotSpots: %i",HotSpots.size()); - - //dc.SetTextColor(0xFF0000); - //dc.SetBkColor(0x000000); - //dc.SetBkMode(OPAQUE); - //dc.DrawText(txt,-1,&CRect(0,0,0,0), DT_LEFT | DT_NOCLIP | DT_NOPREFIX); + //TCHAR txt[256] = { 0 }; + //_tprintf_s( txt, _T( "Total HotSpots: %i" ), HotSpots.size( ) ); + //dc.SetTextColor( 0x555556 ); + //dc.SetBkColor( 0xFFFFFF ); + //dc.SetBkMode( OPAQUE ); + //dc.DrawText( txt, -1, &CRect( 0, 0, 0, 0 ), DT_LEFT | DT_NOCLIP | DT_NOPREFIX ); } - //for (UINT i=0; i < HotSpots.size();i++) - //{ + //for (UINT i = 0; i < HotSpots.size();i++) // dc.DrawFocusRect(HotSpots[i].Rect); - //} } } @@ -687,9 +756,15 @@ void CChildView::OnSize( UINT nType, int cx, int cy ) void CChildView::OnVScroll( UINT nSBCode, UINT nPos, CScrollBar* pScrollBar ) { m_Edit.ShowWindow( SW_HIDE ); + if (nSBCode == SB_THUMBPOSITION || nSBCode == SB_THUMBTRACK) { - m_Scroll.SetScrollPos( nPos ); + pScrollBar->SetScrollPos( nPos ); + Invalidate( ); + } + else if (nSBCode == SB_LINEUP || nSBCode == SB_LINEDOWN) + { + pScrollBar->SetScrollPos( pScrollBar->GetScrollPos( ) + ((nSBCode == SB_LINEUP) ? -1 : 1) ); Invalidate( ); } @@ -705,7 +780,10 @@ BOOL CChildView::OnMouseWheel( UINT nFlags, short zDelta, CPoint pt ) { if (m_Scroll.IsWindowVisible( )) { - m_Scroll.SetScrollPos( m_Scroll.GetScrollPos( ) - zDelta / g_FontHeight ); + if (GetAsyncKeyState( VK_LCONTROL )) + m_Scroll.SetScrollPos( m_Scroll.GetScrollPos( ) + ((zDelta < 0) ? 1 : -1) ); + else + m_Scroll.SetScrollPos( m_Scroll.GetScrollPos( ) - ((int)zDelta / g_FontHeight) ); m_Edit.ShowWindow( SW_HIDE ); m_ToolTip.ShowWindow( SW_HIDE ); Invalidate( ); @@ -922,9 +1000,11 @@ UINT CChildView::FindNodeIndex( CNodeBase* pNode ) CNodeBase* CChildView::FindNodeFromIndex( CNodeBase* currentlySelectedNode, UINT index ) { CNodeBase* pNode = currentlySelectedNode; - if (!pNode->GetParent( )) + if (!pNode) return NULL; CNodeClass* pClass = (CNodeClass*)pNode->GetParent( ); + if (!pClass) + return NULL; if (index >= pClass->NodeCount( )) return NULL; return pClass->GetNode( index ); @@ -1428,6 +1508,13 @@ void CChildView::ReplaceSelectedWithType( NodeType Type ) Invalidate( FALSE ); } +void CChildView::ClearSelection( ) +{ + for (int i = 0; i < Selected.size( ); i++) + Selected[i].object->Unselect( ); + Selected.clear( ); +} + void CChildView::OnTypeHex64( ) { ReplaceSelectedWithType( nt_hex64 ); @@ -1783,28 +1870,29 @@ BOOL CChildView::OnCmdMsg( UINT nID, int nCode, void* pExtra, AFX_CMDHANDLERINFO { if (nCode == CN_UPDATE_COMMAND_UI) { - if (nID >= WM_CHANGECLASSMENU && nID < (WM_CHANGECLASSMENU + WM_MAXITEMS)) + if ((nID >= WM_CHANGECLASSMENU) && (nID < (WM_CHANGECLASSMENU + WM_MAXITEMS))) { ((CCmdUI*)pExtra)->Enable( TRUE ); return TRUE; } } - if (nCode == CN_COMMAND) + else if (nCode == CN_COMMAND) { - if (nID >= WM_CHANGECLASSMENU && nID < (WM_CHANGECLASSMENU + WM_MAXITEMS)) + if ((nID >= WM_CHANGECLASSMENU) && (nID < (WM_CHANGECLASSMENU + WM_MAXITEMS))) { UINT idx = nID - WM_CHANGECLASSMENU; - CNodeBase* pNode = (CNodeBase*)ExchangeTarget.object; + CNodeBase* pNode = ExchangeTarget.object; + NodeType nodeType = pNode->GetType( ); - if (pNode->GetType( ) == nt_array) + if (nodeType == nt_array) { ((CNodeArray*)pNode)->SetClass( g_ReClassApp.m_Classes[idx] ); } - if (pNode->GetType( ) == nt_instance) + else if (nodeType == nt_instance) { ((CNodeClassInstance*)pNode)->SetClass( g_ReClassApp.m_Classes[idx] ); } - if (pNode->GetType( ) == nt_pointer) + else if (nodeType == nt_pointer) { ((CNodePtr*)pNode)->SetClass( g_ReClassApp.m_Classes[idx] ); } diff --git a/ReClass/CChildView.h b/ReClass/CChildView.h index f4ce756..b69b0de 100644 --- a/ReClass/CChildView.h +++ b/ReClass/CChildView.h @@ -32,6 +32,7 @@ class CChildView : public CWnd void InsertBytes( CNodeClass* pClass, UINT idx, DWORD Length ); void ReplaceSelectedWithType( NodeType Type ); + void ClearSelection( ); void StandardTypeUpdate( CCmdUI *pCmdUI ); diff --git a/ReClass/CMainFrame.cpp b/ReClass/CMainFrame.cpp index c880c34..2fa3f9f 100644 --- a/ReClass/CMainFrame.cpp +++ b/ReClass/CMainFrame.cpp @@ -85,6 +85,8 @@ CMainFrame::~CMainFrame( ) int CMainFrame::OnCreate( LPCREATESTRUCT lpCreateStruct ) { + //lpCreateStruct->cy += g_FontHeight * 40; + if (CMDIFrameWndEx::OnCreate( lpCreateStruct ) == -1) return -1; @@ -95,21 +97,22 @@ int CMainFrame::OnCreate( LPCREATESTRUCT lpCreateStruct ) CMDITabInfo mdiTabParams; mdiTabParams.m_style = CMFCTabCtrl::STYLE_3D; mdiTabParams.m_tabLocation = CMFCTabCtrl::LOCATION_TOP; - mdiTabParams.m_nTabBorderSize = 4; + mdiTabParams.m_nTabBorderSize = 2; mdiTabParams.m_bActiveTabCloseButton = TRUE; mdiTabParams.m_bTabIcons = TRUE; mdiTabParams.m_bAutoColor = TRUE; mdiTabParams.m_bDocumentMenu = TRUE; - mdiTabParams.m_bFlatFrame = FALSE; + mdiTabParams.m_bEnableTabSwap = TRUE; + mdiTabParams.m_bFlatFrame = TRUE; EnableMDITabbedGroups( TRUE, mdiTabParams ); m_RibbonBar.Create( this ); m_RibbonBar.LoadFromResource( IDR_RIBBON ); // enable Visual Studio 2005 style docking window behavior - CDockingManager::SetDockingMode( DT_STANDARD ); + CDockingManager::SetDockingMode( DT_SMART ); // enable Visual Studio 2005 style docking window auto-hide behavior - EnableAutoHidePanes( CBRS_BORDER_3D ); + EnableAutoHidePanes( CBRS_ALIGN_TOP ); // create docking windows if (!CreateDockingWindows( )) @@ -136,21 +139,21 @@ int CMainFrame::OnCreate( LPCREATESTRUCT lpCreateStruct ) // This improves the usability of the taskbar because the document name is visible with the thumbnail. ModifyStyle( 0, FWS_PREFIXTITLE ); - //Update Colors - CMFCRibbonColorButton* pColor; + // Update Colors + CMFCRibbonColorButton* pColor = NULL; pColor = (CMFCRibbonColorButton*)m_RibbonBar.FindByID( ID_BUTTON_CLR_BACKGROUND ); pColor->SetColor( g_crBackground ); pColor = (CMFCRibbonColorButton*)m_RibbonBar.FindByID( ID_BUTTON_CLR_SELECT ); pColor->SetColor( g_crSelect ); pColor = (CMFCRibbonColorButton*)m_RibbonBar.FindByID( ID_BUTTON_CLR_HIDDEN ); pColor->SetColor( g_crHidden ); pColor = (CMFCRibbonColorButton*)m_RibbonBar.FindByID( ID_BUTTON_CLR_OFFSET ); pColor->SetColor( g_crOffset ); pColor = (CMFCRibbonColorButton*)m_RibbonBar.FindByID( ID_BUTTON_CLR_ADDRESS ); pColor->SetColor( g_crAddress ); - pColor = (CMFCRibbonColorButton*)m_RibbonBar.FindByID( ID_BUTTON_CLR_TYPE ); pColor->SetColor( g_crType ); - pColor = (CMFCRibbonColorButton*)m_RibbonBar.FindByID( ID_BUTTON_CLR_NAME ); pColor->SetColor( g_crName ); + pColor = (CMFCRibbonColorButton*)m_RibbonBar.FindByID( ID_BUTTON_CLR_TYPE ); pColor->SetColor( g_crType ); + pColor = (CMFCRibbonColorButton*)m_RibbonBar.FindByID( ID_BUTTON_CLR_NAME ); pColor->SetColor( g_crName ); pColor = (CMFCRibbonColorButton*)m_RibbonBar.FindByID( ID_BUTTON_CLR_INDEX ); pColor->SetColor( g_crIndex ); pColor = (CMFCRibbonColorButton*)m_RibbonBar.FindByID( ID_BUTTON_CLR_VALUE ); pColor->SetColor( g_crValue ); pColor = (CMFCRibbonColorButton*)m_RibbonBar.FindByID( ID_BUTTON_CLR_COMMENT ); pColor->SetColor( g_crComment ); pColor = (CMFCRibbonColorButton*)m_RibbonBar.FindByID( ID_BUTTON_CLR_VTABLE ); pColor->SetColor( g_crVTable ); - pColor = (CMFCRibbonColorButton*)m_RibbonBar.FindByID( ID_BUTTON_CLR_FUNCTION ); pColor->SetColor( g_crFunction ); - pColor = (CMFCRibbonColorButton*)m_RibbonBar.FindByID( ID_BUTTON_CLR_TEXT ); pColor->SetColor( g_crChar ); + pColor = (CMFCRibbonColorButton*)m_RibbonBar.FindByID( ID_BUTTON_CLR_FUNCTION ); pColor->SetColor( g_crFunction ); + pColor = (CMFCRibbonColorButton*)m_RibbonBar.FindByID( ID_BUTTON_CLR_TEXT ); pColor->SetColor( g_crChar ); pColor = (CMFCRibbonColorButton*)m_RibbonBar.FindByID( ID_BUTTON_CLR_CUSTOM ); pColor->SetColor( g_crCustom ); pColor = (CMFCRibbonColorButton*)m_RibbonBar.FindByID( ID_BUTTON_CLR_HEX ); pColor->SetColor( g_crHex ); @@ -222,6 +225,7 @@ void CMainFrame::OnButtonClrCustom( ) BOOL CMainFrame::PreCreateWindow( CREATESTRUCT& cs ) { + //cs.cy += g_FontHeight; if (!CMDIFrameWndEx::PreCreateWindow( cs )) return FALSE; if (g_bTop) @@ -261,10 +265,7 @@ void CMainFrame::OnWindowManager( ) void CMainFrame::OnApplicationLook( UINT id ) { - CWaitCursor wait; - g_ReClassApp.m_nAppLook = id; - switch (g_ReClassApp.m_nAppLook) { @@ -369,7 +370,7 @@ BOOL CMainFrame::OnCmdMsg( UINT nID, int nCode, void* pExtra, AFX_CMDHANDLERINFO { if (nCode == CN_UPDATE_COMMAND_UI) { - CCmdUI* pCmdUI = static_cast(pExtra); + CCmdUI* pCmdUI = (CCmdUI*)pExtra; if (nID >= WM_CLASSMENU && nID < (WM_CLASSMENU + WM_MAXITEMS)) { pCmdUI->Enable( TRUE ); @@ -389,7 +390,7 @@ BOOL CMainFrame::OnCmdMsg( UINT nID, int nCode, void* pExtra, AFX_CMDHANDLERINFO if (nCode == CN_COMMAND) { - if (nID >= WM_CLASSMENU && nID < (WM_CLASSMENU + WM_MAXITEMS)) + if ((nID >= WM_CLASSMENU) && (nID < (WM_CLASSMENU + WM_MAXITEMS))) { UINT idx = nID - WM_CLASSMENU; diff --git a/ReClass/CNodeClass.h b/ReClass/CNodeClass.h index 69a11e0..acaae3f 100644 --- a/ReClass/CNodeClass.h +++ b/ReClass/CNodeClass.h @@ -14,7 +14,6 @@ class CNodeClass : public CNodeBase virtual int Draw( ViewInfo& View, int x, int y ); VOID SetChildFrame( class CChildFrame* pChild ) { pChildWindow = pChild; } - class CChildFrame* GetChildFrame( ) { return pChildWindow; } public: diff --git a/ReClass/DialogModules.h b/ReClass/DialogModules.h index 0efe81d..0d7d716 100644 --- a/ReClass/DialogModules.h +++ b/ReClass/DialogModules.h @@ -4,24 +4,24 @@ class CDialogModules : public CDialogEx { - DECLARE_DYNAMIC(CDialogModules) + DECLARE_DYNAMIC( CDialogModules ) public: - CDialogModules(CWnd* pParent = NULL); - virtual ~CDialogModules(); + CDialogModules( CWnd* pParent = NULL ); + virtual ~CDialogModules( ); enum { IDD = IDD_DIALOG_MODULES }; protected: - virtual void DoDataExchange(CDataExchange* pDX); + virtual void DoDataExchange( CDataExchange* pDX ); - DECLARE_MESSAGE_MAP() + DECLARE_MESSAGE_MAP( ) - afx_msg void OnEnChangeModuleName(); - afx_msg void OnSize(UINT nType, int cx, int cy); - afx_msg void OnColumnClick(NMHDR* pNMHDR, LRESULT* pResult); - afx_msg void OnDblClkListControl(NMHDR* pNMHDR, LRESULT* pResult); - afx_msg void OnGetMinMaxInfo(MINMAXINFO *lpinfo); - afx_msg void OnContextMenu(CWnd* pWnd, CPoint pos); + afx_msg void OnEnChangeModuleName( ); + afx_msg void OnSize( UINT nType, int cx, int cy ); + afx_msg void OnColumnClick( NMHDR* pNMHDR, LRESULT* pResult ); + afx_msg void OnDblClkListControl( NMHDR* pNMHDR, LRESULT* pResult ); + afx_msg void OnGetMinMaxInfo( MINMAXINFO *lpinfo ); + afx_msg void OnContextMenu( CWnd* pWnd, CPoint pos ); private: enum @@ -34,20 +34,21 @@ class CDialogModules : public CDialogEx NUM_OF_COLUMNS }; - int FindModuleByName(const TCHAR* szName); - CNodeClass* GetClassByName(const TCHAR* szClassName); + int FindModuleByName( const TCHAR* szName ); + CNodeClass* GetClassByName( const TCHAR* szClassName ); - typedef struct COMPARESTRUCT { + typedef struct COMPARESTRUCT + { CListCtrl* pListCtrl; int iColumn; bool bAscending; } *LPCOMPARESTRUCT; - static int CALLBACK CompareFunction(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort); + static int CALLBACK CompareFunction( LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort ); //public: CImageList m_ModuleIcons; - + CButton m_SymbolLoad; CListCtrl m_ModuleList; @@ -62,10 +63,10 @@ class CDialogModules : public CDialogEx std::vector m_hModuleIcons; CRect m_OriginalSize; - void SetSelected(); + void SetSelected( ); - virtual BOOL OnInitDialog(); - virtual void OnOK(); - virtual int AddData(int Index, LPCTSTR ModuleName, LPCTSTR ModulePath, LPCTSTR StartAddress, LPCTSTR EndAddress, LPCTSTR ModuleSize, LPARAM lParam); - virtual void BuildList(); + virtual BOOL OnInitDialog( ); + virtual void OnOK( ); + virtual int AddData( int Index, LPCTSTR ModuleName, LPCTSTR ModulePath, LPCTSTR StartAddress, LPCTSTR EndAddress, LPCTSTR ModuleSize, LPARAM lParam ); + virtual void BuildList( ); }; \ No newline at end of file diff --git a/ReClass/ReClass2016.cpp b/ReClass/ReClass2016.cpp index 88d21c3..05ed880 100644 --- a/ReClass/ReClass2016.cpp +++ b/ReClass/ReClass2016.cpp @@ -96,9 +96,9 @@ void CReClass2016App::ResizeMemoryFont( int font_width, int font_height ) BOOL CReClass2016App::InitInstance( ) { - //#ifdef _DEBUG - //Utils::CreateDbgConsole( _T( "dbg" ) ); - //#endif + #ifdef _DEBUG + Utils::CreateDbgConsole( _T( "dbg" ) ); + #endif INITCOMMONCONTROLSEX InitCtrls; InitCtrls.dwSize = sizeof( InitCtrls ); @@ -219,12 +219,11 @@ BOOL CReClass2016App::InitInstance( ) #undef PushIcon CMainFrame* pFrame = new CMainFrame( ); - m_pMainWnd = pFrame; - if (!pFrame) - return FALSE; - if (!pFrame->LoadFrame( IDR_MAINFRAME )) + if (!pFrame || !pFrame->LoadFrame( IDR_MAINFRAME )) return FALSE; + m_pMainWnd = pFrame; + pFrame->m_hMenuDefault = m_hMDIMenu; pFrame->m_hAccelTable = m_hMDIAccel; @@ -238,7 +237,7 @@ BOOL CReClass2016App::InitInstance( ) g_ProcessID = NULL; g_AttachedProcessAddress = NULL; - // Initialize the editor + // Initialize the Scintilla editor if (!Scintilla_RegisterClasses( m_hInstance )) { AfxMessageBox( _T( "Scintilla failed to initiailze" ) ); @@ -672,57 +671,58 @@ void CReClass2016App::OnButtonFooter( ) CMainFrame* CReClass2016App::GetMainFrame( ) { - return STATIC_DOWNCAST( CMainFrame, g_ReClassApp.m_pMainWnd ); + return STATIC_DOWNCAST( CMainFrame, m_pMainWnd ); } CMFCRibbonBar* CReClass2016App::GetRibbonBar( ) { - return &GetMainFrame( )->m_RibbonBar; + return (CMFCRibbonBar*)&GetMainFrame( )->m_RibbonBar; } CNodeBase* CReClass2016App::CreateNewNode( NodeType Type ) { - if (Type == nt_class) return new CNodeClass; - - if (Type == nt_hex64) return new CNodeHex64; - if (Type == nt_hex32) return new CNodeHex32; - if (Type == nt_hex16) return new CNodeHex16; - if (Type == nt_hex8) return new CNodeHex8; - - if (Type == nt_bits) return new CNodeBits; - - if (Type == nt_int64) return new CNodeInt64; - if (Type == nt_int32) return new CNodeInt32; - if (Type == nt_int16) return new CNodeInt16; - if (Type == nt_int8) return new CNodeInt8; - - if (Type == nt_uint64) return new CNodeQWORD; - if (Type == nt_uint32) return new CNodeDWORD; - if (Type == nt_uint16) return new CNodeWORD; - if (Type == nt_uint8) return new CNodeByte; - - if (Type == nt_vec2) return new CNodeVec2; - if (Type == nt_vec3) return new CNodeVec3; - if (Type == nt_quat) return new CNodeQuat; - if (Type == nt_matrix) return new CNodeMatrix; - - if (Type == nt_float) return new CNodeFloat; - if (Type == nt_double) return new CNodeDouble; - - if (Type == nt_custom) return new CNodeCustom; - if (Type == nt_text) return new CNodeText; - if (Type == nt_pchar) return new CNodeCharPtr; - if (Type == nt_pwchar) return new CNodeWCharPtr; - if (Type == nt_unicode) return new CNodeUnicode; - - if (Type == nt_vtable) return new CNodeVTable; - if (Type == nt_functionptr) return new CNodeFunctionPtr; - if (Type == nt_function) return new CNodeFunction; - - if (Type == nt_pointer) return new CNodePtr; - if (Type == nt_array) return new CNodeArray; - if (Type == nt_instance) return new CNodeClassInstance; - + switch (Type) + { + case nt_class: return new CNodeClass; + + case nt_hex64: return new CNodeHex64; + case nt_hex32: return new CNodeHex32; + case nt_hex16: return new CNodeHex16; + case nt_hex8: return new CNodeHex8; + case nt_bits: return new CNodeBits; + + case nt_int64: return new CNodeInt64; + case nt_int32: return new CNodeInt32; + case nt_int16: return new CNodeInt16; + case nt_int8: return new CNodeInt8; + + case nt_uint64: return new CNodeQWORD; + case nt_uint32: return new CNodeDWORD; + case nt_uint16: return new CNodeWORD; + case nt_uint8: return new CNodeByte; + + case nt_vec2: return new CNodeVec2; + case nt_vec3: return new CNodeVec3; + case nt_quat: return new CNodeQuat; + case nt_matrix: return new CNodeMatrix; + + case nt_float: return new CNodeFloat; + case nt_double: return new CNodeDouble; + + case nt_custom: return new CNodeCustom; + case nt_text: return new CNodeText; + case nt_pchar: return new CNodeCharPtr; + case nt_pwchar: return new CNodeWCharPtr; + case nt_unicode: return new CNodeUnicode; + + case nt_vtable: return new CNodeVTable; + case nt_functionptr: return new CNodeFunctionPtr; + case nt_function: return new CNodeFunction; + + case nt_pointer: return new CNodePtr; + case nt_array: return new CNodeArray; + case nt_instance: return new CNodeClassInstance; + } return NULL; } diff --git a/ReClass/ReClass2016.h b/ReClass/ReClass2016.h index 476a0c3..dfd2f1a 100644 --- a/ReClass/ReClass2016.h +++ b/ReClass/ReClass2016.h @@ -25,6 +25,7 @@ class CReClass2016App : public CWinAppEx CString m_strCurrentFilePath; std::vector m_Classes; + //std::vector m_Selected; CDialogConsole* m_pConsole;