Archive: calling DLL - help needed


calling DLL - help needed
  I have a code fragment like this

StrCpy$0 "removetray"

>StrCpy $1 ""
>StrCpy $2 ""
then a dll-call of "install.dll"
$1 contains the result

this dll knows what to do. i need a hint to (re)build this call
http://nsis.sourceforge.net/Docs/System/System.html
http://nsis.sourceforge.net/Calling_...tem.dll_plugin

That DLL you are going to call, is it a NSIS plugin-DLL or some other kind of DLL?

If it's a NSIS plug-in DLL, i.e. a DLL that implements the NSIS plug-in API, you would call it simple with a:
SomePlugin::SomeFunction [Arg_1 Arg_2 ... Arg_N]

If it is not a NSIS plug-in DLL, you can still call it by using the NSIS System plug-in. Though this will be more complex!

(The System plug-in has a manual. See 'NSIS\Docs\System\System.html' for details!)


If you look closer, you'll see he already linked to the system plugin readme himself. I think he needs help with the system::call syntax.

What is the syntax of the dll function you're trying to call?


a) no nsis dll - external found. there is an install.exe for 64bit buit 32bit has only the dll

b) i have neither nor a clue - for EXE it would be 'install.exe "removetray"'

and each time i dig in i get more and more confused
could be like this

System::Call 'YourDllName::YourDllFunction(i, *i, t) i(.r0, r1, .r2) .r1'
but
YourDllFunction = unknown
t = unknown

#

i found a "public nsisfunc" which handles the command line parameters, maybe my "YourDllFunction"?

1) It will be impossible to call a Non-NSIS DLL, unless you know the exact definition of the exported function you want to call! Only if you know the exact definition of the function you want to call, preferably in C notation, you may use the System plug-in to call it.

A proper description of a function exported from some DLL looks like this:
http://msdn.microsoft.com/en-us/libr...=vs.85%29.aspx


2) Just in case you are not aware of this yet: It is NOT possible to call any 64-Bit DLL's from NSIS. That's NOT a limitation of NSIS, but a limitation of the operating systems. 32-Bit processes can't load/use 64-Bit DLL's. There is NO way around that.

(Creating 64-Bit processes from a 32-Bit process works perfectly fine though)


2) i mentioned for 64bit an exe-file, same purpos as dll/32bit but exe

1) i work on this ;)

i created some code with the system plugin and the result here is, that the install.dll must be called directly
RegisterDLL $PLUGINSDIR\System.dll Call 0
RegisterDLL $PLUGINSDIR\install.dll nsisfunc 0

so the next questzion - again: what ist YourDllName::YourDllFunction

System::Call 'install::nsisfunc(i, *i, t) i(.r0) .r1'
returns "1" with correct parameter in $0
other tests returned "-1"

install.dll is extracted on runtime, not as a plugin

That "install.dll", is that a DLL you created yourself or is it some 3rd-party DLL ???

(1) If it's your own DLL, then please show us some code. The code (C/C++) inside the DLL you want to call!

(2) If it's a 3rd-party DLL, then please show as the API specification provided by whoever created the DLL.

Note: If that is a 3rd-party DLL, but no API specification is publicly available, forget about calling it from NSIS!


that is some of the main problem - 3rd party and no doc.
its used to install a printer driver - and its older and noone available for support (gave up).

the other solution is to wrap that installation with my code and files - quick and dirty.
the major problem around is that the installer creates a failure message - but install
files correctly and need reboot. i can uninstall all files without a reboot but i dont have
knowledge how to install this driver so i try the original routines.

oh, this is suprising

  StrCpy$0 "in"

StrCpy $1 ""
StrCpy $2 ""
install::nsisfunc 'install::nsisfunc(i, *i, t) i(.r0, r1, .r2) .r1'
Messagebox mb_ok "install1: '$0' '$1' '$2'"

StrCpy $0 "in"
StrCpy $1 ""
StrCpy $2 ""
install::nsisfunc '(i, *i, t) i(.r0, r1, .r2) .r1'
Messagebox mb_ok "install2: '$0' '$1' '$2'"
both return same (error) message as i know similar from the installer.
but i had to copy the dll to nsis plugins, strange

Originally posted by Brummelchen
that is some of the main problem - 3rd party and no doc.
Then this is a lost case. Unless are able to reverse engineer the existing DLL :rolleyes:

Currently you are calling a function names "nsisfunc" from the DLL "install.dll". Does that DLL really export a function of that name?

Also you are using this function like nsisfunc(int X, int *Y, char* Z). Is that how the function is defined?

If so, how do you know that the function is defined like this? You said no Docs are available for the DLL, so where is that info from?

[EDIT]

Sorry, my first comment was wrong.

Now I noticed that you are not calling the DLL via System plug-in. You calling it as if it was a NSIS plug-in DLL.

And you are passing a single String argument to it, which appears to be formated in a System-plugin-like syntax :eek:

Previously you said that your DLL is not a NSIS plug-in DLL. So you are contradicting yourself. I give up...

reverse engineering aint really possible - its possible to showup assembler but not the source code.
"nsisfunc" is given by the installer made in nsis - and there is a name in this file.

RegisterDLL $PLUGINSDIR\install.dll nsisfunc 0
nsis code aint possible to reverse too, creates some crap, only hints.
i can only rewrite it from my experience and investigations with google and nsis wiki.

so i put some code with system-plugin and reversed that file to compare if i am wrong.
first i was wrong but the structur of any plugin dll is close to dllname::command so i
tried install.dll as a plugin. it works this way but i still think it was not written for this purpose.

easter is close to end and my spare time too. keep fingers crossed.

The 'RegisterDLL' command is used to register COM DLL's. That's yet another completely different thing :rolleyes:


maybe - but its the reversed command from any nsis package using dll:function
its not documented in the online help