Archive: Need help making win32 calls


Need help making win32 calls
I'm having some issues figuring out how to manually call functions in general. I'm starting out with duplicating the functionality of MessageBox, but I've run into a few quirks.

Here's the function definition:
int MessageBox( HWND hWnd, // handle to owner window
LPCTSTR lpText, // text in message box
LPCTSTR lpCaption, // message box title
UINT uType // message box style );

And here's my attempt to invoke it from NSIS:
strcpy $R0 "title"
strcpy $R1 "text"
System::Call "user32::MessageBoxA(i, t, t, i) (0, $R0, $R1, 1)"

The message box pops up, however both the title and the text are empty. I'm not sure if "" automatically appends '\0'. On the same note, I'm not sure what NSIS uses for NULL.

Looking through the tutorial, I find myself very confused about:
System::Call 'YourDllName::YourDllFunction(i, *i, t) i(.r0, r1, .r2) .r3'

I haven't seen anything in the documentation that says what '.r0' means. (I know what $r0 is...)

I'm doubly confused when later, we see the example:
(function definition)
int CmGetHotSyncExecPath(TCHAR *pPath, int *piSize);
(nsis declaration)
CmGetHotSyncExecPath(t, *i) i
(nsis invocation)
System::Call 'CondMgr::CmGetHotSyncExecPath(t, *i) i(.r0, r1r1).r2'

What is r1r1??? And once again, what is '.r0'?

Here's the tutorial:
http://nsis.sourceforge.net/Calling_...stem.dll::Call


Use R0 and R1 instead of $R0 and $R1 in your call to pass by reference. To pass strings by value they must be surrounded by quotes.

Stu


Have you looked at the System plug-in documentation?

r0-r9 is for $0-$9 and R0-R9 is for $R0-$R9.
Use a . to gain output in a variable.
For example, if you ended your call with i.r0 you would get your message box result in $0 (1 for OK or 2 for Cancel).

Stu


I didn't when I was trying to understand that I reviewed the Variables section of the documentation, i.e.

4.2.2 Other Writable Variables
$0, $1, $2, $3, $4, $5, $6, $7, $8, $9, $R0, $R1, $R2, $R3, $R4, $R5, $R6, $R7, $R8, $R9

Registers. These variables can be used just like user variables...

which wasn't helping a whole lot heh.


So my last question is dealing with passing a function pointer. Compiling the following lines results in:
install function "test" not referenced - zeroing code (269-271) out


Function test
MessageBox MB_OK 'This is a test.'
FunctionEnd

(snip)

System::Call "kernel32::CopyFileEx(t R0, t R1, k test)"


You need to read up on callbacks in the System plug-in documentation.

Stu


Anders, the reason is actually in my Billboard thread that I started. It's so I can use CopyFileEx... I'm trying to display images based on copy progress(I'm just trying to learn how to use system calls right now).

Afrow UK, I just found the docs on callbacks, sorry about that.