CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!
CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!
Path: blob/master/Windows/Debugger/CtrlMemView.h
Views: 1401
#pragma once12//////////////////////////////////////////////////////////////////////////3//CtrlDisAsmView4// CtrlDisAsmView.cpp5//////////////////////////////////////////////////////////////////////////6//This Win32 control is made to be flexible and usable with7//every kind of CPU architecture that has fixed width instruction words.8//Just supply it an instance of a class derived from Debugger, with all methods9//overridden for full functionality.10//11//To add to a dialog box, just draw a User Control in the dialog editor,12//and set classname to "CtrlDisAsmView". you also need to call CtrlDisAsmView::init()13//before opening this dialog, to register the window class.14//15//To get a class instance to be able to access it, just use getFrom(HWND wnd).1617#include <cstdint>18#include <vector>19#include "Core/Debugger/DebugInterface.h"20#include "Core/Debugger/MemBlockInfo.h"2122enum OffsetSpacing {23offsetSpace = 3, // the number of blank lines that should be left to make space for the offsets24offsetLine = 1, // the line on which the offsets should be written25};2627enum CommonToggles {28On,29Off,30};3132class CtrlMemView33{34public:35CtrlMemView(HWND _wnd);36~CtrlMemView();37static void init();38static void deinit();39static LRESULT CALLBACK wndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);40static CtrlMemView *getFrom(HWND wnd);4142void setDebugger(DebugInterface *deb) {43debugger_ = deb;44}45DebugInterface *getDebugger() {46return debugger_;47}48std::vector<u32> searchString(const std::string &searchQuery);49void onPaint(WPARAM wParam, LPARAM lParam);50void onVScroll(WPARAM wParam, LPARAM lParam);51void onKeyDown(WPARAM wParam, LPARAM lParam);52void onChar(WPARAM wParam, LPARAM lParam);53void onMouseDown(WPARAM wParam, LPARAM lParam, int button);54void onMouseUp(WPARAM wParam, LPARAM lParam, int button);55void onMouseMove(WPARAM wParam, LPARAM lParam, int button);56void redraw();57void gotoAddr(unsigned int addr);5859void drawOffsetScale(HDC hdc);60void toggleOffsetScale(CommonToggles toggle);61void setHighlightType(MemBlockFlags flags);6263private:64bool ParseSearchString(const std::string &query, bool asHex, std::vector<uint8_t> &data);65void updateStatusBarText();66void search(bool continueSearch);67uint32_t pickTagColor(const std::string &tag);6869enum class GotoMode {70RESET,71RESET_IF_OUTSIDE,72FROM_CUR,73EXTEND,74};75static GotoMode GotoModeFromModifiers(bool isRightClick);76void UpdateSelectRange(uint32_t target, GotoMode mode);77void GotoPoint(int x, int y, GotoMode mode);78void ScrollWindow(int lines, GotoMode mdoe);79void ScrollCursor(int bytes, GotoMode mdoe);8081static wchar_t szClassName[];82DebugInterface *debugger_ = nullptr;8384HWND wnd;85HFONT font;86HFONT underlineFont;8788bool redrawScheduled_ = false;89// Whether to draw things using focused styles.90bool hasFocus_ = false;91MemBlockFlags highlightFlags_ = MemBlockFlags::ALLOC;9293// Current cursor position.94uint32_t curAddress_ = 0;95// Selected range, which should always be around the cursor.96uint32_t selectRangeStart_ = 0;97uint32_t selectRangeEnd_ = 0;98// Last select reset position, for selecting ranges.99uint32_t lastSelectReset_ = 0;100// Address of the first displayed byte.101uint32_t windowStart_ = 0;102// Number of bytes displayed per row.103int rowSize_ = 16;104105// Width of one monospace character (to maintain grid.)106int charWidth_ = 0;107// Height of one row of bytes.108int rowHeight_ = 0;109// Y position of offset header (at top.)110int offsetPositionY_;111// X position of addresses (at left.)112int addressStartX_ = 0;113// X position of hex display.114int hexStartX_ = 0;115// X position of text display.116int asciiStartX_ = 0;117// Whether cursor is within text display or hex display.118bool asciiSelected_ = false;119// Which nibble is selected, if in hex display. 0 means leftmost, i.e. most significant.120int selectedNibble_ = 0;121122bool displayOffsetScale_ = false;123124// Number of rows visible as of last redraw.125int visibleRows_ = 0;126// Position and size as of last redraw.127RECT rect_;128129// Last used search query, used when continuing a search.130std::string searchQuery_;131// Address of last match when continuing search.132uint32_t matchAddress_ = 0xFFFFFFFF;133// Whether a search is in progress.134bool searching_ = false;135};136137138