diff --git a/Pepper/CChildFrm.cpp b/Pepper/CChildFrm.cpp index 3c9d924..013663f 100644 --- a/Pepper/CChildFrm.cpp +++ b/Pepper/CChildFrm.cpp @@ -84,6 +84,21 @@ void CChildFrame::OnDestroy() --reinterpret_cast(AfxGetMainWnd())->GetChildFramesCount(); } +auto CChildFrame::GetSplitRight()->CSplitterEx& +{ + return m_stSplitterRight; +} + +auto CChildFrame::GetSplitRightTop()->CSplitterEx& +{ + return m_stSplitterRightTop; +} + +auto CChildFrame::GetSplitRightBot()->CSplitterEx& +{ + return m_stSplitterRightBottom; +} + BOOL CChildFrame::OnEraseBkgnd(CDC* pDC) { return CMDIChildWndEx::OnEraseBkgnd(pDC); diff --git a/Pepper/CChildFrm.h b/Pepper/CChildFrm.h index 2a6fbfd..72152a1 100644 --- a/Pepper/CChildFrm.h +++ b/Pepper/CChildFrm.h @@ -7,16 +7,12 @@ #pragma once #include "CSplitterEx.h" -import Utility; -using namespace util; - class CChildFrame : public CMDIChildWndEx { public: - CSplitterEx m_stSplitterMain; - CSplitterEx m_stSplitterRight; - CSplitterEx m_stSplitterRightTop; - CSplitterEx m_stSplitterRightBottom; + [[nodiscard]] auto GetSplitRight() -> CSplitterEx&; + [[nodiscard]] auto GetSplitRightTop() -> CSplitterEx&; + [[nodiscard]] auto GetSplitRightBot() -> CSplitterEx&; private: afx_msg BOOL OnEraseBkgnd(CDC* pDC); afx_msg void OnClose(); @@ -28,8 +24,12 @@ class CChildFrame : public CMDIChildWndEx DECLARE_MESSAGE_MAP(); DECLARE_DYNCREATE(CChildFrame); private: - bool m_fSplitterCreated { false }; - bool m_fClosing { false }; //Indicates that tab is closing now. + CSplitterEx m_stSplitterMain; + CSplitterEx m_stSplitterRight; + CSplitterEx m_stSplitterRightTop; + CSplitterEx m_stSplitterRightBottom; UINT m_cx { }; UINT m_cy { }; + bool m_fSplitterCreated { false }; + bool m_fClosing { false }; //Indicates that tab is closing now. }; \ No newline at end of file diff --git a/Pepper/CFileLoader.h b/Pepper/CFileLoader.h index cbb9510..e207f44 100644 --- a/Pepper/CFileLoader.h +++ b/Pepper/CFileLoader.h @@ -35,18 +35,18 @@ class CFileLoader : public CWnd IHexCtrl* pHexCtrl { }; bool fWhole { }; }; - bool m_fLoaded { false }; - bool m_fModified { false }; - bool m_fWritable { false }; + static constexpr DWORD m_dwStyle { WS_POPUP | WS_OVERLAPPEDWINDOW }; + static constexpr DWORD m_dwExStyle { WS_EX_APPWINDOW }; //To force to the taskbar. CPepperDoc* m_pMainDoc { }; IHexCtrlPtr m_pHex { HEXCTRL::CreateHexCtrl() }; HEXCREATE m_hcs; HEXDATA m_hds; - const DWORD m_dwStyle { WS_POPUP | WS_OVERLAPPEDWINDOW }; - const DWORD m_dwExStyle { WS_EX_APPWINDOW }; //To force to the taskbar. LARGE_INTEGER m_stFileSize { }; //Size of the loaded PE file. HANDLE m_hFile { }; HANDLE m_hMapObject { }; //Returned by CreateFileMappingW. LPVOID m_lpBase { }; std::vector m_vecCheck; + bool m_fLoaded { false }; + bool m_fModified { false }; + bool m_fWritable { false }; }; \ No newline at end of file diff --git a/Pepper/CMainFrm.h b/Pepper/CMainFrm.h index ab4865c..4f6f912 100644 --- a/Pepper/CMainFrm.h +++ b/Pepper/CMainFrm.h @@ -8,7 +8,7 @@ #include import Utility; -using namespace util; +using namespace Util; class CMainFrame : public CMDIFrameWndEx { diff --git a/Pepper/CPepper.cpp b/Pepper/CPepper.cpp index 5539ed8..e876d93 100644 --- a/Pepper/CPepper.cpp +++ b/Pepper/CPepper.cpp @@ -29,8 +29,8 @@ BOOL CAboutDlg::OnInitDialog() { CDialogEx::OnInitDialog(); - const auto wstrVerPepper = std::format(L"Pepper: PE32/PE32+ Binaries Analyzer v{}.{}.{}", util::PEPPER_VERSION_MAJOR, - util::PEPPER_VERSION_MINOR, util::PEPPER_VERSION_PATCH); + const auto wstrVerPepper = std::format(L"Pepper: PE32/PE32+ Binaries Analyzer v{}.{}.{}", Util::PEPPER_VERSION_MAJOR, + Util::PEPPER_VERSION_MINOR, Util::PEPPER_VERSION_PATCH); GetDlgItem(IDC_LINK_PEPPER)->SetWindowTextW(wstrVerPepper.data()); const auto wstrVerLibpe = std::format(L"libpe: PE32/PE32+ Binaries Parsing Library v{}.{}.{}", libpe::LIBPE_VERSION_MAJOR, libpe::LIBPE_VERSION_MINOR, libpe::LIBPE_VERSION_PATCH); diff --git a/Pepper/CPepperDoc.cpp b/Pepper/CPepperDoc.cpp index 2d99bcb..bd131eb 100644 --- a/Pepper/CPepperDoc.cpp +++ b/Pepper/CPepperDoc.cpp @@ -11,7 +11,7 @@ #include import Utility; -using namespace util; +using namespace Util; IMPLEMENT_DYNCREATE(CPepperDoc, CDocument) diff --git a/Pepper/CPepperDoc.h b/Pepper/CPepperDoc.h index 56a344a..1a70c25 100644 --- a/Pepper/CPepperDoc.h +++ b/Pepper/CPepperDoc.h @@ -17,7 +17,7 @@ class CPepperDoc : public CDocument [[nodiscard]] auto GetFileLoader() -> CFileLoader&; void SetEditMode(bool fEditMode); [[nodiscard]] bool IsEditMode() { return m_fEditMode; } - [[nodiscard]] auto GetFileInfo() -> util::PEFILEINFO&; + [[nodiscard]] auto GetFileInfo() -> Util::PEFILEINFO&; [[nodiscard]] auto GetOffsetFromVA(ULONGLONG ullVA) -> DWORD; [[nodiscard]] auto GetOffsetFromRVA(ULONGLONG ullRVA) -> DWORD; [[nodiscard]] auto GetDOSHeader() -> std::optional&; @@ -71,7 +71,7 @@ class CPepperDoc : public CDocument std::optional m_optBoundImp; std::optional m_optDelayImp; std::optional m_optComDescr; - util::PEFILEINFO m_stFileInfo; + Util::PEFILEINFO m_stFileInfo; bool m_fEditMode { false }; bool m_fHasCur { false }; bool m_fHasIco { false }; diff --git a/Pepper/CTreeEx.h b/Pepper/CTreeEx.h index f0cf4a1..7d0468e 100644 --- a/Pepper/CTreeEx.h +++ b/Pepper/CTreeEx.h @@ -9,13 +9,11 @@ class CTreeEx : public CTreeCtrl { - DECLARE_DYNAMIC(CTreeEx); - CTreeEx() = default; - virtual ~CTreeEx() = default; protected: afx_msg BOOL OnEraseBkgnd(CDC* pDC); afx_msg void OnKillFocus(CWnd* pNewWnd); afx_msg void OnLButtonDown(UINT nFlags, CPoint point); afx_msg void OnPaint(); - DECLARE_MESSAGE_MAP() + DECLARE_MESSAGE_MAP(); + DECLARE_DYNAMIC(CTreeEx); }; \ No newline at end of file diff --git a/Pepper/CViewLeft.cpp b/Pepper/CViewLeft.cpp index 2e1bb84..08d3f35 100644 --- a/Pepper/CViewLeft.cpp +++ b/Pepper/CViewLeft.cpp @@ -9,7 +9,7 @@ #include "res/resource.h" import Utility; -using namespace util; +using namespace Util; IMPLEMENT_DYNCREATE(CViewLeft, CView) diff --git a/Pepper/CViewRightBL.h b/Pepper/CViewRightBL.h index 4b98842..47975da 100644 --- a/Pepper/CViewRightBL.h +++ b/Pepper/CViewRightBL.h @@ -16,6 +16,7 @@ import Utility; using namespace HEXCTRL; using namespace LISTEX; +using namespace Util; class CViewRightBL : public CView { diff --git a/Pepper/CViewRightBR.cpp b/Pepper/CViewRightBR.cpp index f1262d0..5503214 100644 --- a/Pepper/CViewRightBR.cpp +++ b/Pepper/CViewRightBR.cpp @@ -139,30 +139,30 @@ void CViewRightBR::OnUpdate(CView* /*pSender*/, LPARAM lHint, CObject* pHint) GetClientRect(&rcClient); m_stListTLSCallbacks->SetWindowPos(this, 0, 0, rcClient.Width(), rcClient.Height(), SWP_SHOWWINDOW | SWP_NOACTIVATE | SWP_NOZORDER); m_hwndActive = m_stListTLSCallbacks->m_hWnd; - m_pChildFrame->m_stSplitterRightBottom.ShowCol(1); - m_pChildFrame->m_stSplitterRightBottom.SetColumnInfo(0, rcParent.Width() / 2, 0); + m_pChildFrame->GetSplitRightBot().ShowCol(1); + m_pChildFrame->GetSplitRightBot().SetColumnInfo(0, rcParent.Width() / 2, 0); } break; case IDC_TREE_RESOURCE: - m_pChildFrame->m_stSplitterRightBottom.ShowCol(1); - m_pChildFrame->m_stSplitterRightBottom.SetColumnInfo(0, rcParent.Width() / 3, 0); + m_pChildFrame->GetSplitRightBot().ShowCol(1); + m_pChildFrame->GetSplitRightBot().SetColumnInfo(0, rcParent.Width() / 3, 0); break; case IDC_SHOW_RESOURCE_RBR: m_pResData = reinterpret_cast(pHint); ShowResource(m_pResData); - m_pChildFrame->m_stSplitterRightBottom.ShowCol(1); - m_pChildFrame->m_stSplitterRightBottom.SetColumnInfo(0, rcParent.Width() / 3, 0); + m_pChildFrame->GetSplitRightBot().ShowCol(1); + m_pChildFrame->GetSplitRightBot().SetColumnInfo(0, rcParent.Width() / 3, 0); break; case IDC_LIST_DEBUG_ENTRY: CreateDebugEntry(HIWORD(lHint)); - m_pChildFrame->m_stSplitterRightBottom.ShowCol(1); - m_pChildFrame->m_stSplitterRightBottom.SetColumnInfo(0, rcParent.Width() / 2, 0); + m_pChildFrame->GetSplitRightBot().ShowCol(1); + m_pChildFrame->GetSplitRightBot().SetColumnInfo(0, rcParent.Width() / 2, 0); break; default: - m_pChildFrame->m_stSplitterRightBottom.HideCol(1); + m_pChildFrame->GetSplitRightBot().HideCol(1); } - m_pChildFrame->m_stSplitterRightBottom.RecalcLayout(); + m_pChildFrame->GetSplitRightBot().RecalcLayout(); } BOOL CViewRightBR::OnCommand(WPARAM wParam, LPARAM lParam) @@ -177,6 +177,8 @@ BOOL CViewRightBR::OnCommand(WPARAM wParam, LPARAM lParam) void CViewRightBR::OnDraw(CDC* pDC) { + constexpr auto clrBkIcons { RGB(230, 230, 230) }; + CRect rcClipBox; pDC->GetClipBox(rcClipBox); const auto sizeScroll = GetTotalSize(); @@ -198,12 +200,12 @@ void CViewRightBR::OnDraw(CDC* pDC) case RTYPE_CURSOR: case RTYPE_BITMAP: case RTYPE_ICON: - pDC->FillSolidRect(rcClipBox, m_clrBkIcons); + pDC->FillSolidRect(rcClipBox, clrBkIcons); m_stImgRes.Draw(pDC, 0, { x, y }, ILD_NORMAL); break; case RTYPE_GROUP_CURSOR: case RTYPE_GROUP_ICON: - pDC->FillSolidRect(rcClipBox, m_clrBkIcons); + pDC->FillSolidRect(rcClipBox, clrBkIcons); for (const auto& iter : m_vecImgRes) { IMAGEINFO imgInfo; iter->GetImageInfo(0, &imgInfo); @@ -218,7 +220,7 @@ void CViewRightBR::OnDraw(CDC* pDC) } break; case RTYPE_PNG: - pDC->FillSolidRect(rcClipBox, m_clrBkIcons); + pDC->FillSolidRect(rcClipBox, clrBkIcons); m_imgPng.AlphaBlend(pDC->m_hDC, x, y, m_iImgResWidth, m_iImgResHeight, 0, 0, m_iImgResWidth, m_iImgResHeight); break; case RES_LOAD_ERROR: @@ -595,8 +597,7 @@ void CViewRightBR::CreateListTLSCallbacks() int listindex { }; for (const auto& iterCallbacks : pTLS->vecTLSCallbacks) { - m_stListTLSCallbacks->InsertItem(listindex, std::format(L"{:08X}", iterCallbacks).data()); - ++listindex; + m_stListTLSCallbacks->InsertItem(listindex++, std::format(L"{:08X}", iterCallbacks).data()); } } diff --git a/Pepper/CViewRightBR.h b/Pepper/CViewRightBR.h index 6c7a352..adb5668 100644 --- a/Pepper/CViewRightBR.h +++ b/Pepper/CViewRightBR.h @@ -12,7 +12,7 @@ #include import Utility; -using namespace util; +using namespace Util; using namespace LISTEX; class CWndSampleDlg final : public CWnd @@ -60,6 +60,7 @@ class CViewRightBR final : public CScrollView DECLARE_MESSAGE_MAP(); DECLARE_DYNCREATE(CViewRightBR); private: + static constexpr auto m_clrBkImgList { RGB(250, 250, 250) }; HWND m_hwndActive { }; CChildFrame* m_pChildFrame { }; CPepperDoc* m_pMainDoc { }; @@ -72,8 +73,6 @@ class CViewRightBR final : public CScrollView IListExPtr m_stListTLSCallbacks { CreateListEx() }; LOGFONTW m_lf { }; LOGFONTW m_hdrlf { }; - COLORREF m_clrBkIcons { RGB(230, 230, 230) }; - COLORREF m_clrBkImgList { RGB(250, 250, 250) }; EResType m_eResTypeToDraw { }; int m_iImgResWidth { }; //Width of the whole image to draw. int m_iImgResHeight { }; //Height of the whole image to draw. diff --git a/Pepper/CViewRightTL.cpp b/Pepper/CViewRightTL.cpp index c9edff1..981e342 100644 --- a/Pepper/CViewRightTL.cpp +++ b/Pepper/CViewRightTL.cpp @@ -59,8 +59,8 @@ void CViewRightTL::OnInitialUpdate() else { m_wstrFileType = L"File type: unknown"; } - m_wstrPepperVersion = std::format(L"Pepper v{}.{}.{}", util::PEPPER_VERSION_MAJOR, - util::PEPPER_VERSION_MINOR, util::PEPPER_VERSION_PATCH); + m_wstrPepperVersion = std::format(L"Pepper v{}.{}.{}", Util::PEPPER_VERSION_MAJOR, + Util::PEPPER_VERSION_MINOR, Util::PEPPER_VERSION_PATCH); m_stlcs.stColor.clrTooltipText = RGB(255, 255, 255); m_stlcs.stColor.clrTooltipBk = RGB(0, 132, 132); @@ -193,8 +193,8 @@ void CViewRightTL::OnUpdate(CView* /*pSender*/, LPARAM lHint, CObject* /*pHint*/ m_pwndActive->SetWindowPos(this, 0, 0, rcClient.Width(), rcClient.Height(), SWP_SHOWWINDOW | SWP_NOACTIVATE | SWP_NOZORDER); } - fShowRow ? m_pChildFrame->m_stSplitterRight.ShowRow(1) : m_pChildFrame->m_stSplitterRight.HideRow(1); - m_pChildFrame->m_stSplitterRight.RecalcLayout(); + fShowRow ? m_pChildFrame->GetSplitRight().ShowRow(1) : m_pChildFrame->GetSplitRight().HideRow(1); + m_pChildFrame->GetSplitRight().RecalcLayout(); } void CViewRightTL::OnDraw(CDC* pDC) diff --git a/Pepper/CViewRightTL.h b/Pepper/CViewRightTL.h index 0093dde..fe12f9f 100644 --- a/Pepper/CViewRightTL.h +++ b/Pepper/CViewRightTL.h @@ -16,6 +16,7 @@ import Utility; using namespace LISTEX; using namespace HEXCTRL; +using namespace Util; class CViewRightTL : public CView { diff --git a/Pepper/CViewRightTR.cpp b/Pepper/CViewRightTR.cpp index 1ebff78..cc6f0bf 100644 --- a/Pepper/CViewRightTR.cpp +++ b/Pepper/CViewRightTR.cpp @@ -8,6 +8,7 @@ #include "CViewRightTR.h" import Utility; +using namespace Util; IMPLEMENT_DYNCREATE(CViewRightTR, CView) @@ -59,14 +60,14 @@ void CViewRightTR::OnUpdate(CView* /*pSender*/, LPARAM lHint, CObject* pHint) ::ShowWindow(m_hwndActive, SW_HIDE); m_stHexEdit->ClearData(); m_hwndActive = m_stHexEdit->GetWindowHandle(EHexWnd::WND_MAIN); - m_pChildFrame->m_stSplitterRightTop.ShowCol(1); - m_pChildFrame->m_stSplitterRightTop.SetColumnInfo(0, rcParent.Width() / 3, 0); + m_pChildFrame->GetSplitRightTop().ShowCol(1); + m_pChildFrame->GetSplitRightTop().SetColumnInfo(0, rcParent.Width() / 3, 0); ::SetWindowPos(m_hwndActive, m_hWnd, 0, 0, rcClient.Width(), rcClient.Height(), SWP_SHOWWINDOW | SWP_NOACTIVATE | SWP_NOZORDER); break; case IDC_HEX_RIGHT_TR: CreateHexResources(reinterpret_cast(pHint)); - m_pChildFrame->m_stSplitterRightTop.ShowCol(1); - m_pChildFrame->m_stSplitterRightTop.SetColumnInfo(0, rcParent.Width() / 3, 0); + m_pChildFrame->GetSplitRightTop().ShowCol(1); + m_pChildFrame->GetSplitRightTop().SetColumnInfo(0, rcParent.Width() / 3, 0); break; case ID_DOC_EDITMODE: OnDocEditMode(); @@ -75,11 +76,11 @@ void CViewRightTR::OnUpdate(CView* /*pSender*/, LPARAM lHint, CObject* pHint) if (m_hwndActive) { ::ShowWindow(m_hwndActive, SW_HIDE); } - m_pChildFrame->m_stSplitterRightTop.HideCol(1); + m_pChildFrame->GetSplitRightTop().HideCol(1); break; } - m_pChildFrame->m_stSplitterRightTop.RecalcLayout(); + m_pChildFrame->GetSplitRightTop().RecalcLayout(); } void CViewRightTR::OnDraw(CDC* /*pDC*/) diff --git a/Pepper/Utility.ixx b/Pepper/Utility.ixx index 2cb5ec7..1a8a20d 100644 --- a/Pepper/Utility.ixx +++ b/Pepper/Utility.ixx @@ -5,20 +5,20 @@ * Pepper is a PE32 (x86) and PE32+ (x64) binares viewer/editor. * ****************************************************************************************************/ module; +#include "HexCtrl.h" #include -#include #include +#include #include #include #include -#include "HexCtrl.h" export module Utility; import libpe; #define TO_WSTR_MAP(x) {x, L## #x} -export namespace util +export namespace Util { constexpr auto PEPPER_VERSION_MAJOR = 1; constexpr auto PEPPER_VERSION_MINOR = 5; @@ -196,7 +196,7 @@ export namespace util auto dwSavedFiles { 0UL }; bool fAllSaveOK { true }; - for (const auto vecRes = libpe::FlatResources(*pRes); const auto & ref : vecRes) { + for (const auto & ref : libpe::FlatResources(*pRes)) { using enum EResType; std::wstring_view wsvExt; switch (eResType) { @@ -231,14 +231,14 @@ export namespace util wstrPathFile += L"_"; } else { - wstrPathFile += std::format(L"ResID_{}_", ref.wNameID); + wstrPathFile += std::format(L"RESID_{}_", ref.wNameID); } if (!ref.wsvLangStr.empty()) { wstrPathFile += ref.wsvLangStr; } else { - wstrPathFile += std::format(L"LangID_{}", ref.wLangID); + wstrPathFile += std::format(L"LANGID_{}", ref.wLangID); } wstrPathFile += wsvExt; @@ -252,7 +252,7 @@ export namespace util } if (fAllSaveOK) { - MessageBoxW(nullptr, std::format(L"All {} files were saved successfully!", dwSavedFiles).data(), L"Success", MB_ICONINFORMATION); + MessageBoxW(nullptr, std::format(L"All {} files were saved successfully.", dwSavedFiles).data(), L"Success", MB_ICONINFORMATION); } else { MessageBoxW(nullptr, std::format(L"Some issues occured during the save process.\r\nOnly {} files were saved successfully.", dwSavedFiles).data(),