Author Topic: Latest update 24 September 2019  (Read 393 times)

hutch--

  • Administrator
  • Member
  • ******
  • Posts: 6662
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Latest update 24 September 2019
« on: September 24, 2019, 06:49:27 AM »
IMPORTANT

Additions and changes have been applied to the help file, the library modules and the macro file. It is important that you update ALL of these so that you get the full functionality. Replace the earlier help file with the current one, overwrite the existing m64lib files with the current ones and replace the earlier macro file with the current one.
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :skrewy:

hutch--

  • Administrator
  • Member
  • ******
  • Posts: 6662
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: Latest update 24 September 2019
« Reply #1 on: September 24, 2019, 07:00:26 AM »
Here are the latest examples, some are already in this subforum but are bundled together so they can easily be added to the existing examples.
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :skrewy:

hutch--

  • Administrator
  • Member
  • ******
  • Posts: 6662
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: Latest update 24 September 2019
« Reply #2 on: September 25, 2019, 09:38:07 PM »
This example shows how to use the macros that use the command line processing modules in the m64lib library. The design is a space delimited set of command line arguments where text with spaces can be used when enclosed by double quotes.

EXAMPLE appname one "two 2" three four "the number 5" 6 seven eight

This is the example code. You allocate 2 QWORD values, either LOCAL or in one of the .DATA sections, call the "CmdBegin" macro using the two arguments. When the macro returns, you have a pointer to a QWORD array of the arguments on the command line and importantly, the argument count.

As the pointer array is allocated memory, you must not go past the last array member or you will get a paging fault. The design does not impose an argument limit but a normal command line length will impose a limit from the command line. It is possible to set very long command lines from CreateProcess and this system will handle large counts but it would be an unusual task to perform this and would probably be a form of exploit.

; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤

    include \masm32\include64\masm64rt.inc

    .code

; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤

 entry_point proc

    USING r12,r13
    LOCAL parr  :QWORD
    LOCAL acnt  :QWORD

    SaveRegs

  ; --------------------------------------------
  ; get command line pointer array and arg count
  ; --------------------------------------------
    CmdBegin parr,acnt                              ; start here

  ; -----------------------------------
  ; loop through command tail arguments
  ; -----------------------------------
    mov r12, parr                                   ; load array pointer into r12
    mov r13, acnt                                   ; load argument count into r13
  lpst:
    conout QWORD PTR [r12],lf                       ; QWORD PTR for array member
    add r12, 8                                      ; add 8 to get next array member
    sub r13, 1                                      ; decrement the argument counter
    jnz lpst                                        ; loop back if not zero

    conout "arg count = ",str$(acnt),lf,lf          ; display arg count
  ; -----------------------------------

  ; ***********************************
  ; free cmd arg processing memory
  ; ***********************************
    CmdEnd                                          ; end here

    RestoreRegs
    .exit

 entry_point endp

; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤

    end
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :skrewy: