Author Topic: A guide to the RichMasm editor  (Read 6502 times)

jj2007

  • Moderator
  • Member
  • *****
  • Posts: 7752
  • Assembler is fun ;-)
    • MasmBasic
Re: A guide to the RichMasm editor
« Reply #15 on: February 14, 2017, 08:09:42 PM »
How do I deal with this?
Code: [Select]
Error A2106: Cannot open file: "tmp_file.asm" [ENOENT]

Sorry for that, mabdelouahab :icon14:

It works for me with Win7-64 and Win10, Italian versions. Now the question is why RichMasm can't open (or can't find) your tmp_file.asm :(

Does your folder name contain non-Ansi characters? If yes, then version 14 Feb 2017 should work for you. I just uploaded it, there was a SetCurrentDirectoryA that made the assembly fail if the path contained "true" Unicode. Please let me know if it works now.

Anybody else having this kind of problems?
« Last Edit: February 14, 2017, 10:44:26 PM by jj2007 »

LordAdef

  • Member
  • ***
  • Posts: 264
Re: A guide to the RichMasm editor
« Reply #16 on: February 15, 2017, 07:44:48 PM »
Rock solid here JJ.

By the way, did you notice this line in his report:

Quote
*** Assemble, link and run صندوق رسالة ***


jj2007

  • Moderator
  • Member
  • *****
  • Posts: 7752
  • Assembler is fun ;-)
    • MasmBasic
Re: A guide to the RichMasm editor
« Reply #17 on: February 15, 2017, 10:42:39 PM »
Rock solid here JJ.

Thanks :biggrin:

Quote
By the way, did you notice this line in his report:

Quote
*** Assemble, link and run صندوق رسالة ***

Yes indeed, RichMasm used Ansi filenames - call it a bug. The latest version (15 Feb) handles it correctly (F9 produces the big MessageBox):



Project attached, needs MasmBasic 15 Feb 2017.

jj2007

  • Moderator
  • Member
  • *****
  • Posts: 7752
  • Assembler is fun ;-)
    • MasmBasic
Re: A guide to the RichMasm editor
« Reply #18 on: March 21, 2017, 05:59:50 AM »
The attached beta has a new version of RichMasm allowing, inter alia, to translate hyperlinks very directly into source code - see second attachment.

GuiParas      equ "ToolTips for the SysLink control", w300, h80
include \masm32\MasmBasic\Res\MbGui.asm
  GuiControl GetHelp, "syslink", h0+20, "Click here to download MasmBasic, or here for online help"
  GuiControl VisitMoscow, "syslink", y0+20, h0+40, "Get info on Moscow: Развлечения, история, музеи, рестораны-кафе, гостиницы, информация"

Event Command
  .if NotifyCode==NM_CLICK && (wParam==GetHelp || wParam==VisitMoscow)
      wMsgBox 0, Link$(), "Open this page?", MB_OKCANCEL
      If_ eax==IDOK Then <wShEx Link$()>
  .endif
GuiEnd
Rsrc
#include "resource.h"
IDI_APPLICATION ICON      "\\Masm32\\MasmBasic\\icons\\Smiley.ico"
01 RT_MANIFEST      "\\Masm32\\MasmBasic\\Res\\XpManifest.xml"
Rsrc

This is how it looks in the editor:

EDIT: Beta removed, the current version has the new features now.
« Last Edit: April 29, 2017, 01:27:30 AM by jj2007 »

jj2007

  • Moderator
  • Member
  • *****
  • Posts: 7752
  • Assembler is fun ;-)
    • MasmBasic
Re: A guide to the RichMasm editor
« Reply #19 on: May 01, 2017, 09:47:06 AM »
As Edsger Wybe Dijkstra once noted,
Quote
It is practically impossible to teach good programming to students that have had a prior exposure to Visual Studio: as potential programmers they are mentally mutilated beyond hope of regeneration.

For these poor beings, who spread their PROTOs and MACROs over a dozen tiny files in order to call their mess a "project", there is HELP now: The attached RichMasm beta extends the search feature (select a word, hit F3) to files that are INCLUDEd in the source.

This is limited to those files that are included by an UPPERCASE INCLUDE at the moment when the file was opened. So to test it, change the desired include to INCLUDE, then save and reload the file:

include \masm32\MasmBasic\MasmBasic.inc
; include \masm32\include\masm32rt.inc

INCLUDE mymacros.inc
INCLUDElib msvcrt.lib

Here, only mymacros.inc is included in the search.

TWell

  • Member
  • ****
  • Posts: 748
Re: A guide to the RichMasm editor
« Reply #20 on: May 01, 2017, 12:41:44 PM »
Quote
It is practically impossible to teach good programming to students that have had a prior exposure to BASIC: as potential programmers they are mentally mutilated beyond hope of regeneration.
At that time BASIC was weak with subroutines and structured programming. Quick Basic and Turbo Basic correct some problems.

Asm programmers needs those little files when creating libraries as ml don't have support for COMDAT.

EDIT: forgot to say [h]jwasm and asmc have support for it.

A good IDE's have a 'Find in files' feature, like poide.exe has.
« Last Edit: May 01, 2017, 07:35:01 PM by TWell »

hutch--

  • Administrator
  • Member
  • ******
  • Posts: 4930
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: A guide to the RichMasm editor
« Reply #21 on: May 01, 2017, 01:53:25 PM »
I wonder what capacity the COMDAT (common data) has that cannot be done with MASM's "PUBLIC" keyword. It is routine to make something PUBLIC in MASM and access it from other modules.
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :biggrin:

jj2007

  • Moderator
  • Member
  • *****
  • Posts: 7752
  • Assembler is fun ;-)
    • MasmBasic
Re: A guide to the RichMasm editor
« Reply #22 on: May 02, 2017, 03:00:21 AM »
A good IDE's have a 'Find in files' feature, like poide.exe has.

Pelle's IDE is among the better ones, but the "find in files" feature is a joke. Check out the RichMasm beta to see the difference.

TWell

  • Member
  • ****
  • Posts: 748
Re: A guide to the RichMasm editor
« Reply #23 on: May 02, 2017, 03:48:26 AM »
I tried to download it, but Avast ate it.
So what kind of feature it should be?

LordAdef

  • Member
  • ***
  • Posts: 264
Re: A guide to the RichMasm editor
« Reply #24 on: May 02, 2017, 04:00:51 AM »
Tim, bypass Avast for 10 minutes and download it. Avast is not asm community friend  :icon_redface:

LiaoMi

  • Member
  • **
  • Posts: 170
Re: A guide to the RichMasm editor
« Reply #25 on: May 02, 2017, 04:20:39 AM »
Hi!

I compared the toolbar by looking at the picture in this top and noticed that only my menu is so badly displayed ... About how it looks like you can see below - https://ibb.co/bWF8Lk


Maybe this problem has already happened?

Thankeee!

jj2007

  • Moderator
  • Member
  • *****
  • Posts: 7752
  • Assembler is fun ;-)
    • MasmBasic
Re: A guide to the RichMasm editor
« Reply #26 on: May 02, 2017, 05:36:26 AM »
only my menu is so badly displayed

The menu font is a problem indeed. One day I will have to find a solution :(

Reason is that when the Aero themes came out, the old GetWindowDC trick stopped working.

@Tim: really, can't you disable Avast for 5 minutes?? Btw Jotti shows that 16 out of 19 AVs are OK with that RM beta. For the unpacked version, it's 18/19 OK.

LordAdef

  • Member
  • ***
  • Posts: 264
Re: A guide to the RichMasm editor
« Reply #27 on: May 02, 2017, 03:33:34 PM »
Working fine here JJ

jj2007

  • Moderator
  • Member
  • *****
  • Posts: 7752
  • Assembler is fun ;-)
    • MasmBasic
Detecting and debugging heap corruption
« Reply #28 on: May 22, 2017, 09:36:45 PM »
A simple demo showing how to detect heap corruption:

Code: [Select]
include \masm32\include\masm32rt.inc ; plain Masm32

.code
txString db "Hello, this is a simple string, 50 characters long", 0
start:
  mov esi, rv(HeapAlloc, rv(GetProcessHeap), HEAP_ZERO_MEMORY, 22h) ; 22h=34 bytes, not enough for txString

  print "before doing illegal things to esi="
  print hex$(esi), 13, 10

  invoke lstrcpy, esi, addr txString ; this is commonly called "buffer overflow"
  print " after doing illegal things", 13, 10, 10, "[" ; but it works just fine, because the heap
  print esi, "]", 13, 10, 10 ; doesn't yet know that it's "corrupt" now ;-)

  print "----- OK, we are now freeing esi, and strange things will happen: -----"
  invoke HeapFree, rv(GetProcessHeap), 0, esi
  inkey "----- buffer was freed -----"
  exit

end start ; OPT_Debug 1 ; this option requires RichMasm

When hitting F6 in RichMasm (MasmBasic's IDE), you will see this output:
Code: [Select]
before doing illegal things to esi=002A5920
 after doing illegal things

[Hello, this is a simple string, 50 characters long]

----- OK, we are now freeing esi, and strange things will happen: -----
## HEAP[HeapCorruption.exe]:
## Heap block at 002A5918 modified at 002A5942 past requested size of 22

## HEAP[HeapCorruption.exe]:
## Invalid address specified to RtlFreeHeap( 002A0000, 002A5920 )
----- buffer was freed -----

Project attached. Let me know if it can be improved.

jj2007

  • Moderator
  • Member
  • *****
  • Posts: 7752
  • Assembler is fun ;-)
    • MasmBasic
Rich text to the forum
« Reply #29 on: July 11, 2017, 10:37:19 PM »
With MasmBasic version 11 July 2017, the formatted output has been improved: select text, hit F11, paste in a reply. Example:

include \masm32\MasmBasic\MasmBasic.inc         ; download
  if 0  ; copy the line below, then hit F6 to get the db version
        chartab                 dw "10","01","12","21","13","31"
        ; expected output:
        chartab                 db "0","1","1","0","2","1","1","2","3","1","1","3"
  endif
  Init                          ; *** translate Masm dw format to db for use with UAsm ***
  Let esi=Clip$()               ; get string from clipboard (limit is about 160k)
  lea ecx, [2*Len(esi)]         ; the byte format is longer, so we need a bigger buffer
  Let edi=New$(ecx)
  push esi
  push edi
  .Repeat
        lodsb
        If_ al=="w" Then mov al, "b"    ; dw->db
        stosb
        .Break .if !al
        .if al==34
                push [esi]
                lodsb
                movsb           ; first digit
                mov al, 34
                stosb
                mov al, ","
                stosb
                mov al, 34
                stosb
                pop eax
                stosb           ; second digit
                movsb           ; second quote
        .endif
  .Until 0
  pop edi
  pop esi
  Inkey "Before: ", esi, CrLf$, "After:  ", edi, CrLf$, "Copy to clipboard? (y)", CrLf$
  If_ eax=="y" Then SetClip$ edi
EndOfCode