x64dbg / x64dbg

An open-source user mode debugger for Windows. Optimized for reverse engineering and malware analysis.
http://x64dbg.com
Other
44.76k stars 2.43k forks source link

Main window position and size cannot be saved #3437

Closed 793359277 closed 2 months ago

793359277 commented 2 months ago

Operating System

Win10 x64 22H2 19045.2965

x64dbg Version

Aug 30 2024

Describe the issue

Main window position and size cannot be saved

As of today, the latest version still does this The virtual machine Win11 test is fine.

snapshot_2022-09-07_14-52, This version is ok. But I used a version of 2024 before, which was normal. I don't know when the above problem started to appear(Previously my system was Win10 2004).

Steps to reproduce

  1. unknown
  2. unknown
  3. unknown

Attachments

12

13

793359277 commented 2 months ago

I think there might be something wrong with my system, but I'm not sure what caused it.

793359277 commented 2 months ago

If I run with x64dbg debugging, the window position is magically preserved, but if I run directly I still get the error.

2.4mb GIF 15

793359277 commented 2 months ago

The test found that if the left position of the window is less than 0 when closing, the window position and size can be saved normally, which is very strange.

15

793359277 commented 2 months ago

I created a new system account and ran x64dbg with this account, but this problem did not occur. What is going on? I can't find the reason. Help me.

mrexodia commented 2 months ago

The window position is saved in x64dbg.ini. Make sure the folder is writable, otherwise the settings will reset to the default.

torusrxxx commented 2 months ago

When x64dbg crashes on exit the settings may not be saved. And system configuration have a role as well. I see inconsistent results when I connect two monitors with different DPI settings. Sometimes the window size saved is magnified by DPI scaling on next startup, but not always. Maybe something buggy with the system. Even the explorer doesn't always look correct with such monitor settings.

793359277 commented 2 months ago

The window position is saved in x64dbg.ini. Make sure the folder is writable, otherwise the settings will reset to the default.

All the settings in x64dbg can be saved, such as events, engines, exception settings, etc., but the window position is a problem

793359277 commented 2 months ago

When x64dbg crashes on exit the settings may not be saved. And system configuration have a role as well. I see inconsistent results when I connect two monitors with different DPI settings. Sometimes the window size saved is magnified by DPI scaling on next startup, but not always. Maybe something buggy with the system. Even the explorer doesn't always look correct with such monitor settings.

All the settings in x64dbg can be saved, such as events, engines, exception settings, etc., but the window position is a problem.
15

793359277 commented 2 months ago

The window position is saved in x64dbg.ini. Make sure the folder is writable, otherwise the settings will reset to the default.

All the settings in x64dbg can be saved, such as events, engines, exception settings, etc., but the window position is a problem. 15

793359277 commented 2 months ago

The window position is saved in x64dbg.ini. Make sure the folder is writable, otherwise the settings will reset to the default.

The snapshot_2022-09-07_14-52 mentioned above has no problem. I started the latest version, adjusted the window size and position, closed the software, and BridgeSettingFlush returned true. I manually copied the latest version of x64dbg.ini to the 2022-09-07 version directory, started the 2022-09-07 version of x64dbg.exe, and the window position and size were retained and reproduced. This shows that the memory configuration items have been successfully written to x64dbg.ini when exiting, and it should be a problem when starting the software.

793359277 commented 2 months ago

This problem does exist, but others cannot reproduce it under normal circumstances. If possible, I hope to optimize the code for saving and reading the window position and size.

In order to use it normally, I had to write a plug-in to record the window position and size. When x64dbg exits, it is recorded with GetWindowRect, and when it starts, MoveWindow is used to adjust the window information, so this problem will not occur.

mrexodia commented 2 months ago

The code for saving the window information is rather simple:

https://github.com/x64dbg/x64dbg/blob/74c6d2a5792ce2f7b8555fd527104f2a469ec168/src/gui/Src/Gui/MainWindow.cpp#L960-L987

Then the restore is called on startup:

https://github.com/x64dbg/x64dbg/blob/74c6d2a5792ce2f7b8555fd527104f2a469ec168/src/gui/Src/Gui/MainWindow.cpp#L989-L1038

mrexodia commented 2 months ago

Perhaps the change happens because restoreGeometry is called in the constructor of MainWindow?

https://github.com/x64dbg/x64dbg/blob/74c6d2a5792ce2f7b8555fd527104f2a469ec168/src/gui/Src/Gui/MainWindow.cpp#L416-L419

For me this is working, but maybe there is some bug in Qt here? This forum post hints that it is broken: https://forum.qt.io/topic/76589/proper-way-to-restore-state-geometry-on-application-start

mrexodia commented 2 months ago

I pushed an attempted fix to the development branch. A new snapshot should be released soon, please try it and let me know (make sure to remove your plugin first obviously).

torusrxxx commented 2 months ago

Previously, there is a problem that x64dbg flashes briefly at the initial position before being moved to saved position and size, that's why it was changed.

mrexodia commented 2 months ago

Yes, but now we are doing both. I just re-added the code that gets executed on the first event in the event loop, so if the previous restore worked this will not change anything. I did not observe any flashing, but I was on a remote session so maybe it's different on your end?

793359277 commented 2 months ago

I pushed an attempted fix to the development branch. A new snapshot should be released soon, please try it and let me know (make sure to remove your plugin first obviously).

snapshot_2024-09-10_15-35 I tested it and it worked fine. The window information was correctly restored at startup.

mrexodia commented 2 months ago

Good to hear it's resolved!