1 // NOTE: Apologies for the quality of this code, this is really from pre-opensource Dolphin - that is, 2003. 2 3 #pragma once 4 5 ////////////////////////////////////////////////////////////////////////// 6 //CtrlDisAsmView 7 // CtrlDisAsmView.cpp 8 ////////////////////////////////////////////////////////////////////////// 9 //This Win32 control is made to be flexible and usable with 10 //every kind of CPU architecture that has fixed width instruction words. 11 //Just supply it an instance of a class derived from Debugger, with all methods 12 //overridden for full functionality. 13 // 14 //To add to a dialog box, just draw a User Control in the dialog editor, 15 //and set classname to "CtrlDisAsmView". you also need to call CtrlDisAsmView::init() 16 //before opening this dialog, to register the window class. 17 // 18 //To get a class instance to be able to access it, just use getFrom(HWND wnd). 19 20 #include <cstdint> 21 #include "Core/Debugger/DebugInterface.h" 22 #include "Core/Debugger/MemBlockInfo.h" 23 24 enum OffsetSpacing { 25 offsetSpace = 3, // the number of blank lines that should be left to make space for the offsets 26 offsetLine = 1, // the line on which the offsets should be written 27 }; 28 29 enum CommonToggles { 30 On, 31 Off, 32 }; 33 34 class CtrlMemView 35 { 36 HWND wnd; 37 HFONT font; 38 HFONT underlineFont; 39 RECT rect; 40 41 unsigned int curAddress; 42 unsigned int windowStart; 43 int rowHeight; 44 int rowSize; 45 int offsetPositionY; 46 47 int addressStart; 48 int charWidth; 49 int hexStart; 50 int asciiStart; 51 bool asciiSelected; 52 int selectedNibble; 53 54 bool displayOffsetScale = false; 55 56 int visibleRows; 57 58 std::string searchQuery; 59 60 61 int matchAddress; 62 bool searching; 63 bool searchStringValue; 64 65 bool hasFocus; 66 static wchar_t szClassName[]; 67 DebugInterface *debugger; 68 69 MemBlockFlags highlightFlags_ = MemBlockFlags::ALLOC; 70 71 void updateStatusBarText(); 72 void search(bool continueSearch); 73 uint32_t pickTagColor(const std::string &tag); 74 public: 75 CtrlMemView(HWND _wnd); 76 ~CtrlMemView(); 77 static void init(); 78 static void deinit(); 79 static LRESULT CALLBACK wndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam); 80 static CtrlMemView * getFrom(HWND wnd); 81 setDebugger(DebugInterface * deb)82 void setDebugger(DebugInterface *deb) 83 { 84 debugger=deb; 85 } getDebugger()86 DebugInterface *getDebugger() 87 { 88 return debugger; 89 } 90 std::vector<u32> searchString(std::string searchQuery); 91 void onPaint(WPARAM wParam, LPARAM lParam); 92 void onVScroll(WPARAM wParam, LPARAM lParam); 93 void onKeyDown(WPARAM wParam, LPARAM lParam); 94 void onChar(WPARAM wParam, LPARAM lParam); 95 void onMouseDown(WPARAM wParam, LPARAM lParam, int button); 96 void onMouseUp(WPARAM wParam, LPARAM lParam, int button); 97 void onMouseMove(WPARAM wParam, LPARAM lParam, int button); 98 void redraw(); 99 100 void gotoPoint(int x, int y); 101 void gotoAddr(unsigned int addr); 102 void scrollWindow(int lines); 103 void scrollCursor(int bytes); 104 105 void drawOffsetScale(HDC hdc); 106 void toggleOffsetScale(CommonToggles toggle); 107 void toggleStringSearch(CommonToggles toggle); 108 void setHighlightType(MemBlockFlags flags); 109 }; 110