The MASM Forum

General => The Campus => Topic started by: Don57 on February 18, 2013, 05:38:51 PM

Title: !rv ?
Post by: Don57 on February 18, 2013, 05:38:51 PM
I am trying to shorten my code and make it more readable by using rv. Which I understand is short for return value. Somebody on the forum, a while back, sorry I don't remember who gave me help with some code that includes !rv. I am not sure what it stands for, perhaps no return value?

      .IF !rv(CreateProcess,NULL,ADDR sz_LogDumpCommand,0,0,0,CREATE_NO_WINDOW or CREATE_NEW_PROCESS_GROUP,0,0, ADDR sui,ADDR pi)
   
      .ENDIF

I know the rv statement is suppost to be on the same line it doesn't look like it pasted that way.
Title: Re: !rv ?
Post by: hutch-- on February 18, 2013, 05:40:45 PM
Don,

just have a look in the macros file for masm32, its easy enough to use.
Title: Re: !rv ?
Post by: Don57 on February 18, 2013, 05:58:10 PM
I have read the entire macro help file, rv is simple enough, I just don't understand the ! operator in front of it. I keep thinking it is a boolean NOT which doesn't make any sense, and I can't find any reference to the operator.
Title: Re: !rv ?
Post by: hfheatherfox07 on February 18, 2013, 06:17:05 PM
2 words :
qWord territory

qWord style is rv macros , almost every thing ....
Wait for him to post .....  :biggrin:
Title: Re: !rv ?
Post by: jj2007 on February 18, 2013, 06:43:48 PM
Quote from: Don57 on February 18, 2013, 05:58:10 PMI keep thinking it is a boolean NOT which doesn't make any sense, and I can't find any reference to the operator.

It is, it is:

.IF !rv(CreateProcess....
  MsgBox "you got a fat problem"
Title: Re: !rv ?
Post by: dedndave on February 18, 2013, 10:17:43 PM
i'll make it simple for you, Don   :P

"rv" is a macro
besides giving you the return value, it allows things like defining text strings and so on
by "return value", they mean "whatever the function returns in EAX"
have a look at masm32\help\hlhelp.chm
open that file, Macro Catagories, Code Calling Macros (first catagory)
you found that, already   :t

the "!" operator is logical NOT
but, it is not part of the macro name
it is part of the .if/.endif syntax
to understand how it's used.....
    .if rv(.....)
    .endif

in this code, if the return value is non-zero, the code inside the .if/.endif block will be executed

as you know, some API functions return 0 to indicate success, some return 0 to indicate an error
so ".if rv" means "if the return value is non-zero"
".if !rv" means "if the return value is zero"

and, yes......
i don't think anyone uses the rv macro more than qWord   :biggrin:
you can look at his code for many examples
Title: Re: !rv ?
Post by: hutch-- on February 18, 2013, 10:27:49 PM
The problem appears to be from using a compact form of .IF.

Try using the expanded form.


    .IF rv(whatever) == 0
      do this
    .ENDIF
Title: Re: !rv ?
Post by: Don57 on February 19, 2013, 02:48:56 AM
Thanks. I've never used macros before. The .IF statement added to the confusion.