Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#3280: Selection shifts when MemoryMap is updated #3291

Open
wants to merge 1 commit into
base: development
Choose a base branch
from

Conversation

foralost
Copy link
Contributor

Restoring the selection after the MMap is updated by holding the no. of row which was selected earlier.

brave.exe.-.PID_.14892.-.Module_.chrome_elf.dll.-.Thread_.7908.-.x64dbg.2023-12-17.11-10-38.mp4

Closes #3280 .

@AppVeyorBot
Copy link

Download x64dbg 1.0.1837 (commit 203a6a2b29 by @foralost)

@mrexodia
Copy link
Member

Hm, I think it would be better to select based on the “closest” address since most likely the number of rows updates in an application with high memory pressure… I’ll take a look when I’m back home!

@foralost
Copy link
Contributor Author

Hm, Im thinking about some delta like oldAdresses - currAddress, but im wondering what if there are multiple entries which are 'equally' distant?

... or maybe something more sophisticated

@mrexodia
Copy link
Member

How about storing the currently-selected base+size and selecting the region that overlaps (or is just before) the previous range?

@@ -444,6 +446,11 @@ void MemoryMapView::refreshMapSlot()
setCellContent(i, ColAddress, ToPtrString((duint)mbi.BaseAddress));
setCellUserdata(i, ColAddress, (duint)mbi.BaseAddress);

if((duint)mbi.BaseAddress == currSelectedAddressRow)
{
oldAddressFound = true;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it's necessary to delay setting the selection and storing the state. You can directly call setSingleSelection here to simplify everything. Also the variable name is no longer accurate, it should be something like prevSelectedBase

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the reloadData function below caused some problems with setSingleSelection (it was jumping around like crazy)

@foralost
Copy link
Contributor Author

How about storing the currently-selected base+size and selecting the region that overlaps (or is just before) the previous range?

Ok, soooooo we would be interested in selecting only the region based on selected address?
Like:
User clicks address -> We find the base address & size -> We store them -> We select the whole region (base address + sections and stuff)

*** the memory updates ***
aaand tbh what now?

We look at the old base address -> We fetch its new base address & size -> We find the intersection (common range/addresses) -> We select now the intersected range?

@mrexodia
Copy link
Member

mrexodia commented Dec 18, 2023

It could be something like this:

void updateMemoryMap():
  oldStart = getCellUserdata(firstSelectedRow, ColAddress)
  oldEnd = getCellUserdata(lastSelectedRow, ColAddress) + getCellUserdata(lastSelectedRow, ColSize)

  firstSelectedRow = 0, lastSelectedRow = 0
  for(const region : memoryMap)
    if region.base < oldStart:
      firstSelectedRow++
    if region.base < oldEnd:
      lastSelectedRow++

    setCellContent(...)

  setSelection(firstSelectedRow, lastSelectedRow)

Since regions (lines) in the memory map never overlap each other there will be a few possibilities:

  • We just find a region where region.base == oldStart
  • The region was split, we will select the first region that overlaps with the old selection
  • The region was freed, we will select the first region before the oldselection

The problem starts when multiple regions are selected, the algorithm for selecting the first region will work fine in this case but the part with lastSelectedRow is just made up and need experimentation...

Another issue will be with the sorting, in that case there isn't much we can do except find the first selected region and then just expanding the selection down with the same amount as initially.

@foralost
Copy link
Contributor Author

foralost commented Jan 8, 2024

Ok, will try to work on it this weekend ;)

@thug-shaker

This comment was marked as spam.

@foralost
Copy link
Contributor Author

foralost commented Jul 13, 2024

Ok so as I have understood, instead of selection of specific table lines (addresses), we should always think about selectiong a region/span of addresses (including sizes).

image
This selection would indicate a range of addresses 000002BB03090000 - 00007DF433EA0000 + its size (both inclusive).

Whatever pop ups in this range of newly updated memoryview, should be also selected (cause its within range).

When something drops out select range (inside of it) we just don't select it in the newly outputted memory view (its line would be also gone). The selection stays as is.

When the beginning/ending line is dropped, then we should select a line which address + size overlaps with the old start/end, in the UI being it probably an upper/below line.

There is no possibility to select multiple regions in x64dbg, so I think its ok.
Hello from the dead ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Selection shifts when MemoryMap is updated
4 participants