Archive: $R0 vs. $0... should it make a difference?


$R0 vs. $0... should it make a difference?
Hello all.

I'm using the Processes Plug-in to check to see if a certain process is running or not.

Try the below code. If you don't have the Windows Calculator (Start-->Run-->calc) running you will get 0 in the message box. If you do have it running, you will get a 1. This is great, however now re-compile the below code and change the two instances of "$R0" below to just "$0".

Now you don't any answer in the message box...what gives? I'm so confused. Thanks for your help.



Name Test
OutFile Test.exe
Section ""
Processes::FindProcess Calc
Pop $R0
MessageBox MB_OK "Result: $R0"
SectionEnd

Strange. If you check the variables with dumpstate::debug, you'll find that $R0 contains the value and not $0.

This works:


Name Test
OutFile Test.exe
Section ""
Processes::FindProcess Calc
Pop $0
MessageBox MB_OK "Result: $R0"
SectionEnd

Could this guy be having the same problem?
http://forums.winamp.com/showthread....hreadid=233453

-Stu

Thanks for checking this out Afrow. This is very strange. I found this works too:


Name Test
OutFile Test.exe
Section ""
Processes::FindProcess Calc
MessageBox MB_OK "Result: $R0"
SectionEnd

It looks like you don't even need to pop it. It is like the plug-in sets the $R0 variable before it finishes.

So if the $R0 is all ready set (to 0 or 1), then by popping it, I would think that it would erase the value, and set it to null. That would be the case if the stack was empty, but it can't be empty because when we "Pop $R0" and then "MessageBox $R0", we get a value (0 or 1).

So then if the stack is not empty, Popping $0 and then MessageBox'in $0 should also work....:confused:

I'm so confused.

Perhaps kichik or the plugin author can shed some light on this.

-Stu


I emailed the author, good idea Afrow, thanks.


In the plug-in's source code, it always uses $R0 to pass the data, not the stack.


Originally posted by kichik
In the plug-in's source code, it always uses $R0 to pass the data, not the stack.
Ahhhhh..... the source code! Thanks for your help kichik.

In the wiki, there are still plug-ins that output to either $0 or $R0 generally because of the old syntax with CallInstDLL instruction. Maybe it would be a good idea to change those plug-ins to use the stack syntax to pass values, like most of the other plug-ins.