News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

MasmBasic

Started by jj2007, October 06, 2009, 08:24:57 PM

Previous topic - Next topic

jj2007

Quote from: AntariyIn MbTryCatch you're using EBX and ESI, but not preserving them (there is one path with return of EXCEPTION_CONTINUE_EXECUTION).

Thanks, Alex. It's corrected today (14 May, here).

I also added a "descriptive text" option to SetErrLine:

  Try         ; set the start label
     mov ecx, 4
     .Repeat
      Print Str$("44444444/%i = ", ecx)
      mov eax, 44444444
      cdq
      SetErrLine "reason\tdiv ecx"
      div ecx
      PrintLine Str$(eax)
      dec ecx
   .Until Sign?
  Catch only   ; "only" signals skip if no problems
     mov eax, 31415926   ; ... otherwise, change your results here...
     PrintLine "undefined"   ; ... or issue a warning, etc.
  Finally         ; needed after "only"
   .if LastEx(code)   ; we better give some extra info
        PrintLine CrLf$, "We had an exception at ", CrLf$, "address", Tb$,\
        Hex$(LastEx(addr)), CrLf$, "code", Tb$, Hex$(LastEx(code)), CrLf$, LastEx(info)
   .endif

We had an exception at
address 00401092
code    C0000094
reason  div ecx


Full example attached.

Antariy

Quote from: jj2007 on May 14, 2012, 02:55:21 PM
Thanks, Alex.

:thumbu


Incrementing [0] is illegal

44444444/4 = 11111111
44444444/3 = 14814814
44444444/2 = 22222222
44444444/1 = 44444444
44444444/0 = undefined

Ouch, we had an exception at
address 00401092
code    C0000094
reason  div ecx

Let's try again, outside the Try/Catch block??

Exception (line 35?):
Code    C0000005
EIP     00401174
Error   inc [0] failed


It is also possible to obtain a line number from a map file, not placing it into exe.
Need to specify /Zd switch to the ML when translating and /MAP /MAPINFO:LINES for LINK when building.
The section in resulting MAP file is named "Line numbers for"... and contains the correspondencies between source lines and code offset relative to start of the section. I.e., if code section (segment) starts at 401000, then just need to add this to offset from MAP to get resulting virtual address.

jj2007

Quote from: Antariy on May 16, 2012, 03:01:01 AM
Need to specify /Zd switch to the ML when translating and /MAP /MAPINFO:LINES for LINK when building.

Alex,

You are a source of inspiration :U

See \masm32\RichMasm\Res\SkelTryCatch.asc in the 18 May version. Open in RichMasm, hit F6, see the exception messages; quit and see how the editor jumps to the first line that triggered an exception :bg

You need ML.exe version 6.15 or JWasm, and the standard linker coming with the Masm32 SDK - see here for more info.

Simple example:

Quoteinclude \masm32\MasmBasic\MasmBasic.inc   ; download
   Init tc   ; install the try/catch handler
   ErrLines   ; blank or on means use them, off means don't
   xor ecx, ecx   ; you should go to jail for accessing address zero, but we'll be kind
   inc dword ptr [ecx]   ; RichMasm will select this line after exiting the program
   Inkey "Can you see this text?"   ; no, you can't... we have a non-continuable exception before ;-)
   Exit
   TryCatchEnd   ; activate the handler - must be last instruction before "end start"
end start

  OPT_Assembler   JWasm         ; only ml.exe 6.15 works ok (Hex$ may not look good in JWasm, ml 8+ don't do /Zd)
  OPT_DebugA   /Zd         ; generate info for mapinfo:lines
  OPT_DebugL   /map /mapinfo:lines      ; recent ml.exe and link.exe versions can't do that
  OPT_Linker   link         ; you need the Masm32 version, i.e. the old 1998 link.exe

guga

Excelent work JJ  :U


One question...how do you managed to enable the hyperlinked text in a richedit control ? ( i mean the "Hi guga", instead of http://guga.com)
Do you have some small example of this ?

I tried to make a riechedit control works this way but it keeps showing the full url

jj2007

Hi Guga,

The trick is to disable EM_AUTOURLDETECT and then roll your own via CFM_LINK. Warning, it may cost you some sleepless night :wink

guga

many tks..i´ll give a try

hmm...you mean using it with EM_SETEVENTMASK, EM_GETEVENTMASK and EM_AUTOURLDETECT ?

guga

I´m confused...It is not working....

is disabling autourldetect realy necessary ?

what about using CFE_HIDDEN ?
I mean, i wonder if it may work if i grab somehow the string memory (the "url" that is surrounding the string), and through EN_LINK i hide only the url string somehow.

Is this c code usefull ?
http://www.tek-tips.com/viewthread.cfm?qid=317950

dedndave

this might help...
http://www.codeproject.com/Articles/9196/Links-with-arbitrary-text-in-a-RichTextBox
when i read these code project articles, i find it very helpful to browse through the discussions at the bottom   :bg

jj2007

Quote from: guga on May 20, 2012, 05:20:24 AM
I´m confused...It is not working....
What do you expect after only one sleepless night? :green

Quote
is disabling autourldetect realy necessary ?

See Dave's link, under "Caveats"

Quote
what about using CFE_HIDDEN ?

Sounds interesting, but you would still have to see the link style for a piece of text, right?

Quote
Is this c code usefull ?
http://www.tek-tips.com/viewthread.cfm?qid=317950

That was 2005 - judge yourself:
Quoteok, for my life I have no idea what the problem is. ... I'll probably post this in it's own thread pretty soon here...

By the way, RichMasm supports several types of hyperlinks:


1. plain http (it will ask)
2. open a local file (directly)
3. jump to internal anchor ("you need resources")
4. insert a file replacing the link
5. while hovering over a MB keyword (Print, Init, Recall, ...), the mouse cursor becomes a question mark. Right-click then to see help.

Source attached - it needs the path name.