Author Topic: !rv ?  (Read 6453 times)

Don57

  • Guest
!rv ?
« 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.

hutch--

  • Administrator
  • Member
  • ******
  • Posts: 10573
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: !rv ?
« Reply #1 on: February 18, 2013, 05:40:45 PM »
Don,

just have a look in the macros file for masm32, its easy enough to use.
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :skrewy:

Don57

  • Guest
Re: !rv ?
« Reply #2 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.

hfheatherfox07

  • Member
  • ***
  • Posts: 464
Re: !rv ?
« Reply #3 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:
Your code and your skills will be assimilated. Your programming language is irrelevant.
We are the ASM Borg and you will become part of us. Compile and be assembled.

jj2007

  • Member
  • *****
  • Posts: 13873
  • Assembly is fun ;-)
    • MasmBasic
Re: !rv ?
« Reply #4 on: February 18, 2013, 06:43:48 PM »
I 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"

dedndave

  • Member
  • *****
  • Posts: 8828
  • Still using Abacus 2.0
    • DednDave
Re: !rv ?
« Reply #5 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.....
Code: [Select]
    .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

hutch--

  • Administrator
  • Member
  • ******
  • Posts: 10573
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: !rv ?
« Reply #6 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
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :skrewy:

Don57

  • Guest
Re: !rv ?
« Reply #7 on: February 19, 2013, 02:48:56 AM »
Thanks. I've never used macros before. The .IF statement added to the confusion.