News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

MasmBasic

Started by jj2007, May 23, 2012, 10:16:07 PM

Previous topic - Next topic

jj2007

Update 15 April (download here):
QuoteLaunch
...
- the default timeout for a "normal" Launch is ten seconds; if you mostly need asynchronous launches,
  you can modify this value with e.g. SetLaunchTimeout 1 (in ms)

And this solved also the little problem with the ten seconds "hanging" of RichMasm ;-)

jj2007

Update 18 April features some improvements of the registry functions:
- SetReg64 allows to read the registry on a 64-bit system
- GetRegVal returns now
  1. a pointer to the string or the data in eax
  2. the type (REG_DWORD ...) in edx
  3. REG_QWORD values in xmm0; same for the first 16 bytes of REG_BINARY
- finally, xmm0 is now a valid argument for the fDate$() and fTime$() macros.

Below an example which reads the "Safer" keys and displays first the "official" LastModified value, and second, the real modification date and time as reported by the registry's timestamp.

include \masm32\MasmBasic\MasmBasic.inc      ; download
  Init
  Let esi="HKLM\SOFTWARE\Policies\Microsoft\Windows\Safer\CodeIdentifiers\0\Hashes\"
  GetRegKeyArray esi, My$(), LastMod()
  .if eax
      push eax

      xor ecx, ecx
      PrintLine esi, CrLf$, "... modified according to LastModified value:"
      .Repeat
            ; GetRegVal returns the LastModified REG_QWORD in xmm0:
            void GetRegVal(Cat$(esi+My$(ecx)), "LastModified", 0)
            PrintLine fDate$(xmm0, "dd MMMM yyyy   "), Tb$, fTime$(xmm0), Spc2$, My$(ecx)
            inc ecx
      .Until ecx>=stack

      xor ecx, ecx
      PrintLine CrLf$, "Hashes modified according to registry timestamp:"
      .Repeat
            PrintLine fDate$(LastMod(ecx), "dd MMMM yyyy   "), Tb$, fTime$(LastMod(ecx)), Spc2$, My$(ecx)
            inc ecx
      .Until ecx>=stack

      pop eax
  .endif
  Inkey Str$("\n%i keys found\n", eax)
  Exit
end start


Source & exe attached. The second attachment (RADAR) lists all software on your PC that suffered from a heap leak. Very interesting, but it works only on Windows 7 and higher, so right now I can't test it. Please post some example output :icon_mrgreen:

sinsi

QuotePlease post some example output
0 keys found
0 keys found

:biggrin:
🍺🍺🍺

jj2007

Hi sinsi,

Yesterday I tested it on Win7, and got the Who's Who of the software industry, Acrobat.exe on top... do you see HKLM\SOFTWARE\Microsoft\RADAR\HeapLeakDetection\DiagnosedApplications\ in regedit, or is it simply absent?

But wait - you are on Win8-64, right? This could do the trick:

  Init
  SetReg64
  Let esi="HKLM\SOFTWARE\Microsoft\RADAR\HeapLeakDetection\DiagnosedApplications\"
  GetRegKeyArray esi, Radar$(), Modified()


Modified package attached.

BTW first tests with SetReg64 failed miserably until I discovered that KEY_WOW64_32KEY was 100h, not 100 as set in Windows.inc (see also Don57,
windows.inc KEY_WOW64_32KEY def'n error
)

sinsi

 :t
HKLM\SOFTWARE\Microsoft\RADAR\HeapLeakDetection\DiagnosedApplications\
... modified according to Modifiedified value:
03 March 2014           00:00:00  BurnoutParadise.exe
14 May 2013     05:14:28  CNC4.game
21 January 2014         03:50:13  CoDWaW LanFixed.exe
04 August 2013          23:56:45  DllHost.exe
03 February 2014        01:05:19  eduke32.exe
01 April 2014           08:45:25  firefox.exe
09 February 2014        11:13:45  GasGuzzlers.exe
15 September 2013       08:33:07  IEXPLORE.EXE
27 June 2013    09:35:22  Need for Speed The Run.exe
07 January 2014         06:52:41  NFS11.exe
05 April 2014           06:26:25  NFS13.exe
20 November 2013        05:35:14  shift2u.exe
22 December 2013        00:19:09  simnow.exe
30 April 2013           08:29:50  Stronghold3.exe
10 April 2014           06:43:19  TiWorker.exe

15 keys found
🍺🍺🍺

jj2007

Thanks :biggrin:

Nice to see two competing browsers here. Would be even nicer to see how much they are leaking ;-)

01 April 2014           08:45:25  firefox.exe
15 September 2013       08:33:07  IEXPLORE.EXE

Gunther

Jochen,


HKLM\SOFTWARE\Microsoft\RADAR\HeapLeakDetection\DiagnosedApplications\
... modified according to Modifiedified value:
06 Februar 2014         00:00:00  ChessProgram13.exe
16 Januar 2014          19:00:27  firefox.exe
07 Oktober 2013         00:06:34  FlashPlayerPlugin_11_8_800_168.exe
12 Januar 2014          16:20:51  FlashPlayerPlugin_11_9_900_170.exe
17 Februar 2014         23:10:44  FlashPlayerPlugin_12_0_0_44.exe
02 April 2014           11:19:31  FlashPlayerPlugin_12_0_0_77.exe

6 keys found


Gunther
You have to know the facts before you can distort them.

jj2007

Thanks. Gunther. How dare you run such old versions of Flash?? I haven't rebooted my machine today, but I am sure Adobe has a better version for us, with better performance and less risks, grosses Indianerehrenwort ;-)

Here results from a rarely used notebook with no Internet connection:

HKLM\SOFTWARE\Microsoft\RADAR\HeapLeakDetection\DiagnosedApplications\
... modified according to ModifiedValue:
05 January 2014         00:00:00  firefox.exe
20 March 2014           17:31:46  InsertDeleteNumArrays.exe
10 November 2012        23:13:25  OllyDbg.exe
04 January 2014         20:15:58  svchost.exe_netsvcs
10 November 2012        20:37:00  TrustedInstaller.exe

Hint: One of these leaky apps is from a well-known hobby coder testing his library ;-)

hutch--

 :biggrin:

Flash is not the problem I have, its the McCafee crap that is bundled with it. I have to uninstall it every time Flash wants an upgrade.

Gunther

Quote from: hutch-- on April 19, 2014, 08:35:50 PM
:biggrin:
Flash is not the problem I have, its the McCafee crap that is bundled with it. I have to uninstall it every time Flash wants an upgrade.

that is the point.

Gunther
You have to know the facts before you can distort them.

jj2007

ArrayMerge had a problem with differently sized arrays. It is fixed in version 22 April 2014.

The code below will now work correctly.

include \masm32\MasmBasic\MasmBasic.inc
  Init                  ; ## merge two string arrays ##
  Dim Dest$()
  Dim Src$()
  xor ecx, ecx
  .Repeat
      .if ecx<3
            Let Dest$(ecx)=Str$("Destination #%i", ecx)
      .endif
      Let Src$(ecx)=Str$("Source #%i", ecx)
      inc ecx
  .Until ecx>=10
  ArrayMerge Dest$(), Src$()
  push Dest$(?)      ; put the new element counter on the stack
  xor ecx, ecx
  .Repeat
      Print Str$("\n#%i\t", ecx), Dest$(ecx)      ; see dest 0...2, then source 0...9
      inc ecx
  .Until ecx>=stack
  pop eax
  Exit
end start


Output:
#0      Destination #0
#1      Destination #1
#2      Destination #2
#3      Source #0
#4      Source #1
...
#12      Source #9

jj2007

Version 25 April supports ArraySet for strings and numerical arrays.
Excerpt from MbSnippets.asc:

include \masm32\MasmBasic\MasmBasic.inc
  Init                 
  PrintLine "ArraySet strings:"
  ArraySet My$() = "These", "are", "four", "strings"
  Let My$(My$(?))="Only strings support"      ; My$(?) is the current number
  Let My$(My$(?))="dynamic expansion"         ; of elements in the array
  For_ ecx=0 To My$(?)-1
      PrintLine Str$(ecx), Tb$, My$(ecx)
  Next

  PrintLine CrLf$, "Same with numerical arrays:"  ; could be DWORD, REAL4, REAL8
  Dim MyNum(5) As DWORD      ; create an array with 6 elements (0 .. 5)
  ArraySet MyNum() = 11, 22, 33, 44, 55, 66      ; assign values
  xor ecx, ecx
  .Repeat
      Print Str$(MyNum(ecx)), Spc2$
      inc ecx
  .Until ecx>=MyNum(?)
  Exit
end start

Output:

ArraySet strings:
0       These
1       are
2       four
3       strings
4       Only strings support
5       dynamic expansion

Same with numerical arrays:
11  22  33  44  55  66

jj2007

Version 31 May 2014 (download) fixes an odd bug: I had built the tinf.lib used for the new UnzipFile function with /subsystem:CONSOLE, so all code using tinf had a console window, including the spreadsheet viewer.

The new UnzipFile decompresses zipped files to a buffer; more in \Masm32\MasmBasic\MbGuide.rtf

Check also the improved QSort function; it allows now to sort string matrices by column, as demonstrated in the spreadsheet viewer.

jj2007

Update 5 June (download) - the unzipper is now even simpler to use:

include \masm32\MasmBasic\MasmBasic.inc
  Init
  UnzipInit "\Masm32\MasmBasic\Res\UnicodeTest.zip"
  ; now restore the first file, and don't forget the timestamp
  FileWrite Files$(0), UnzipFile(0), GfLastWrite(0)
  UnzipExit      ; cleanup
  Exit
end start


It handles Unicode file names, and you can retrieve the optional comment, too.
Full example here.

jj2007

Tonight's version of MasmBasic had a little bug in the deb macro:

include \masm32\MasmBasic\MasmBasic.inc     
  Init
  MovVal f:xmm1, "12345678901234567890"
  deb 1, "Result", f:xmm1
  Exit
end start


You have the latest version with the bugfix if the box displays
Result     f:xmm1          1.234567890123457e+19

If you see any other number, download the latest version here.

For latest additions, see True Unicode in the Campus.