flat assembler
Message board for the users of flat assembler.

Index > IDE Development > New run-in-debugger option for fasmw

Goto page 1, 2  Next
Author
Thread Post new topic Reply to topic
macomics



Joined: 26 Jan 2021
Posts: 984
Location: Russia
macomics 29 Feb 2024, 15:23
I added fasmw option to run a compiled program in debugger.
These new settings are saved in the program's ini file.
Now, when "Debug mode" is activated, compiled program will run through debugger program. When deactivated, the launch will be performed directly (as before).
You can specify the path to the debugging program in the corresponding dialog box.

Here is the file with new lines I added.

Complete

ADD: To apply the patch, unzip the archive to the fasm1 root folder and run install.bat

I have updated the patch so that the value of the INCLUDE variable is set to the standard placement relative to the position of the patch files.


Description:
Filesize: 15.1 KB
Viewed: 3952 Time(s)

Screenshot_20240302_224426.png


Description:
Filesize: 16.68 KB
Viewed: 4236 Time(s)

Screenshot_20240229_181354.png


Description: Updated: for upload
flat assembler 1.73.32 for Windows
size: 1038 kilobytes
last update: 21 Sep 2024 12:13:15 UTC

Download
Filename: RunInDebugger-fasmw-1.73.32.zip
Filesize: 5.43 KB
Downloaded: 166 Time(s)



Last edited by macomics on 21 Sep 2024, 16:11; edited 15 times in total
Post 29 Feb 2024, 15:23
View user's profile Send private message Reply with quote
macomics



Joined: 26 Jan 2021
Posts: 984
Location: Russia
macomics 29 Feb 2024, 20:35
It is also necessary to put "Browse" button in dialog window.
Post 29 Feb 2024, 20:35
View user's profile Send private message Reply with quote
macomics



Joined: 26 Jan 2021
Posts: 984
Location: Russia
macomics 01 Mar 2024, 07:03
Added Browse button. Changed the stack memory allocation to use VirtualAlloc/VirtualFree.
Post 01 Mar 2024, 07:03
View user's profile Send private message Reply with quote
MatQuasar



Joined: 25 Oct 2023
Posts: 105
MatQuasar 01 Mar 2024, 11:02
Your Assembly skill is way above mine. As an end user, is there any software that can read your FASMW_PATCH.ASM and patch my copy of FASMW source file?
Post 01 Mar 2024, 11:02
View user's profile Send private message Reply with quote
macomics



Joined: 26 Jan 2021
Posts: 984
Location: Russia
macomics 01 Mar 2024, 13:35
---


Last edited by macomics on 04 Mar 2024, 08:31; edited 1 time in total
Post 01 Mar 2024, 13:35
View user's profile Send private message Reply with quote
MatQuasar



Joined: 25 Oct 2023
Posts: 105
MatQuasar 01 Mar 2024, 14:12
Thanks, it works. Took me awhile to figure out the patched version is NOT fasmw.asm, but fasmw_patch(ed).asm.

Tested OK with disassembler IDA Free.


Description:
Filesize: 47.57 KB
Viewed: 4158 Time(s)

Capture.PNG


Post 01 Mar 2024, 14:12
View user's profile Send private message Reply with quote
MatQuasar



Joined: 25 Oct 2023
Posts: 105
MatQuasar 01 Mar 2024, 14:22
Just one suggestion, with MS naming convention, it is recommended to append "..." after "Browse" --> "Browse..." for any action that open a dialog.

Nice work overall! I speak for myself.
Post 01 Mar 2024, 14:22
View user's profile Send private message Reply with quote
macomics



Joined: 26 Jan 2021
Posts: 984
Location: Russia
macomics 01 Mar 2024, 15:16
Then correct the name of the button on line 3877 in FASMW.ASM file. I will update the patch with a new name.
Code:
dialogitem 'BUTTON','Browse...',ID_BROWSE,200,12,42,14,WS_VISIBLE+WS_TABSTOP    


ADD: I also want to warn you. If the path and file name of the debugger contain spaces, then you must specify the file name in quotation marks. I removed the forced quoting of the debugger file name, but left it for the program name.

Perhaps I will add automatic quoting for the debugger file name, if there are spaces in the string, to the proc of the dialog box. But that will be later.
Post 01 Mar 2024, 15:16
View user's profile Send private message Reply with quote
MatQuasar



Joined: 25 Oct 2023
Posts: 105
MatQuasar 01 Mar 2024, 16:06
Strange, it still opens my Assembly program in IDA Free despite having white space in between the path name.

Code:
C:\Program Files\IDA Freeware 8.3\ida64.exe    


I am running on Windows 10 22H2 Pro.


Description:
Filesize: 2.57 KB
Viewed: 4116 Time(s)

Capture.PNG


Post 01 Mar 2024, 16:06
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20363
Location: In your JS exploiting you and your system
revolution 01 Mar 2024, 16:23
Add support for parameters.
Code:
"c:\path\to\my debugger.exe" /option value "%" /another-option    
Where % is replaced with the name of the file.
Post 01 Mar 2024, 16:23
View user's profile Send private message Visit poster's website Reply with quote
macomics



Joined: 26 Jan 2021
Posts: 984
Location: Russia
macomics 01 Mar 2024, 16:41
fasmw does not have ready-made string functions. I will add advanced processing of the debugger name string a little later.

It is necessary not only to add automatic quoting of the debugger file name, but also to determine the presence of quotation marks and additional parameters in the string.

I think it will be easier to add a separate line for the debugger arguments. And the name of the program being debugged should be replaced not with one character, but with some kind of understandable template. For example, "$exename" - without quotes.

Just to add options, I removed the automatic quoting of debugger file name. So that you can set additional options in string. Then the name of the program being debugged is supplied to this line with the last parameter in quotation marks.

Code:
"C:\path\to\my debugger.exe" /option value /more /andMore /debug_file     
With this assignment, the last option will receive a value in the form of the name of the file being debugged.
Code:
"C:\path\to\my debugger.exe" /option value /more /andMore /debug_file "C:\path to source\my program.exe"    


Alternatively, we can add options for generating debugging information (fasm -s <symbols>) and a template for substituting the name of a file with debugging information.
Code:
"C:\path\to\my debugger.exe" /option value /more /andMore /debug_symbols $symbols /debug_file $exename    
Post 01 Mar 2024, 16:41
View user's profile Send private message Reply with quote
ProMiNick



Joined: 24 Mar 2012
Posts: 802
Location: Russian Federation, Sochi
ProMiNick 01 Mar 2024, 18:52
What is bad - we got numerios of fasm exes (original of different versions, and numerous of patched ones).
That is good that fasm is open source and could be patched directly.
but most of patchs are used only by their authors, and erased from memory of other users.
But may be would be better to add to official fasm IDE (fasmw fasmgw) ability of loading to fasm address space libraries (of course with executing their libinit with OS launcher) (and maybe ability to unload them). And of course ability to see list of such plugins. Without any requirements to inner plugin structure. I think that could help popularise fasm better. So, would be two abilities to add to fasm additional functional - patching and writing plugin.
Plugins could be listed, they could be crosscompatibable with each other e.t.c.
Post 01 Mar 2024, 18:52
View user's profile Send private message Send e-mail Reply with quote
macomics



Joined: 26 Jan 2021
Posts: 984
Location: Russia
macomics 01 Mar 2024, 22:16
---


Last edited by macomics on 04 Mar 2024, 08:31; edited 1 time in total
Post 01 Mar 2024, 22:16
View user's profile Send private message Reply with quote
macomics



Joined: 26 Jan 2021
Posts: 984
Location: Russia
macomics 02 Mar 2024, 19:38
Updated
Post 02 Mar 2024, 19:38
View user's profile Send private message Reply with quote
macomics



Joined: 26 Jan 2021
Posts: 984
Location: Russia
macomics 03 Mar 2024, 20:22
I can say that the patch is completely ready. Now, when Debug Mode is enabled, a .fas file is additionally generated, and its absolute name can be passed to the debugger via $symbols.

So far, I can no longer think of what settings fasmw can pass to the debugger through its parameters, substituting the necessary values.
Maybe, though...
You can pass parameters to the debugger that fasmw could not interpret from its command line.
Or I can add a template to pass the name of the source (.asm) file to the debugger.
Post 03 Mar 2024, 20:22
View user's profile Send private message Reply with quote
MatQuasar



Joined: 25 Oct 2023
Posts: 105
MatQuasar 12 Mar 2024, 16:56
Hi macomics.

Inspired by Tomasz FASM 2 latest video (and his advice in Discord chatroom), I found an alternative way to launch debugger from software breakpoint.

Here's how with WinDbg: (for other debugger may need to modify registry)
1. Download the Windows SDK installer from: https://developer.microsoft.com/en-us/windows/downloads/windows-sdk/
2. Select "Debugging tools for Windows" and proceed
3. Run Command Prompt as administrator
4. Run "windbg -I"

Now can open FASMW.exe IDE with Assembly code, and insert "int3" at the beginning line, click Run and it opens WinDbg automatically! Embarassed


Description: WinDbg x64 registered as a postmortem debugger
Filesize: 20.29 KB
Viewed: 3705 Time(s)

Capture.PNG


Post 12 Mar 2024, 16:56
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8356
Location: Kraków, Poland
Tomasz Grysztar 12 Mar 2024, 17:00
MatQuasar wrote:
Inspired by Tomasz FASM 2 latest video (and his advice in Discord chatroom), I found an alternative way to launch debugger from software breakpoint.
See also my videos about setting up OllyDbg and x64dbg as JIT/postmortem debuggers. I only used WinDbg to debug ARM64 programs because I saw no good equivalent of OllyDbg/x64dbg for ARM architecture.
Post 12 Mar 2024, 17:00
View user's profile Send private message Visit poster's website Reply with quote
macomics



Joined: 26 Jan 2021
Posts: 984
Location: Russia
macomics 12 Mar 2024, 17:34
MatQuasar wrote:
Here's how with WinDbg: (for other debugger may need to modify registry)
1. Download the Windows SDK installer from: https://developer.microsoft.com/en-us/windows/downloads/windows-sdk/
2. Select "Debugging tools for Windows" and proceed
3. Run Command Prompt as administrator
4. Run "windbg -I"

Now can open FASMW.exe IDE with Assembly code, and insert "int3" at the beginning line, click Run and it opens WinDbg automatically!
I know about the default debugger option. But! With your approach, you are debugging a deliberately non-working program. So, let's say you forgot to remove int3 from it and posted it. Then your code will not work on another computer. While embedding this feature into the IDE, I think it is the right approach.
Post 12 Mar 2024, 17:34
View user's profile Send private message Reply with quote
xiaolaba



Joined: 31 Jan 2015
Posts: 15
xiaolaba 26 Aug 2024, 01:25
macomics wrote:
I added fasmw option to run a compiled program in debugger.
These new settings are saved in the program's ini file.
Now, when "Debug mode" is activated, compiled program will run through debugger program. When deactivated, the launch will be performed directly (as before).
You can specify the path to the debugging program in the corresponding dialog box.

Here is the file with new lines I added.

Complete


when drag and drop the FASMW.EXE to install.bat, something went wrong after awhile, it was close to well done, please help. error code like this,

Code:
include 'win32ax.inc'
error: file not found.
    


Description:
Filesize: 67.34 KB
Viewed: 973 Time(s)

FASMW_debugger_setup.JPG



_________________
best regards,
xiao
Post 26 Aug 2024, 01:25
View user's profile Send private message Visit poster's website Reply with quote
macomics



Joined: 26 Jan 2021
Posts: 984
Location: Russia
macomics 26 Aug 2024, 14:21
You do not have the INCLUDE environment variable set, which should include the path to the FASM files. It must contain a path E:\FASM\INCLUDE
Code:
;; To check
echo %INCLUDE%    


It is assumed that you are using FASM and have set the value of this variable for ease of use. Otherwise, you will have to do this every time before launching FASM.EXE. It is not required to use FASMW.EXE. It uses an option from its own INI file.

ADD: I have updated the patch so that the value of the INCLUDE variable is set to the standard placement relative to the position of the patch files.
Post 26 Aug 2024, 14:21
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  
Goto page 1, 2  Next

< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.