- NSIS Discussion
- Could not find symbol... (Creating a .DLL Plug-In)
Archive: Could not find symbol... (Creating a .DLL Plug-In)
DITMan
5th June 2003 20:39 UTC
Could not find symbol... (Creating a .DLL Plug-In)
Hi, reading some posts in the forum, and with the answers I got in the other thread I started, I'm still wondering how to close MSN Messenger... well, I've found this piece of code, and I'm TRYING to turn it into a NSIS .DLL Plug-In, but whenever I try to load it, I get this messages:
Output folder: C:\DOCUME~1\DITMan\CONFIG~1\Temp
Extract: C:\DOCUME~1\DITMan\CONFIG~1\Temp\nst624.tmp
Could not find symbol: KillProc
Completed
I'll attach the source code for the .DLL, and my .NSI (I know, everything is UGLY, but it should work)
BTW, I think I'm exporting the KillProc function right, but I have NO idea in windows programming, so every feedback will be VERY VERY appreciated, and I think this plug-in is quite useful for NSIS :)
kichik
5th June 2003 20:54 UTC
The problem is that your DLL is written in C++ but the export must be C style. Take a look at the InstallOptions code (written in C++ too) and you'll see that every exported function declaration starts with extern "C".
Looking at your DLLs code I see that it tries to terminate the messenger process. This is not a good idea. Terminating a process must be the last resort and only when the process is frozen or misbehaving. It would be better to only find out if the process is running and cancel the installation.
It's also not a good idea to kill a process by name because you can't be sure the user haven't changed the name of the EXE file or maybe even ran another process with the same name that has nothing to do with your installation.
BTW, If you're using NSIS 2 it would be simpler to put your compiled DLL in the plugins directory and call it using DLLName::Function
kichik
5th June 2003 20:56 UTC
Oh, and WM_DESTROY means nothing in the script, it's just a text. When converting to a number NSIS will think it's 0. You shuold use ${WM_DESTROY}, it's a define. You should also include WinMessages.nsh that defines this, or else, again, it will be treated as 0.
DITMan
6th June 2003 16:37 UTC
Thanks... i need to terminate the process because many people I distributed the .DLL as a separate installer didn't know how to fully close MSN Messenger, and my previous install method (a simple .ZIP Self Extractor) didn't do its job. I send the raw DLL to those people who know what are they doing (and who can rename programs, etc...) but for my John Users ;P I need to kill the process :)
Thanks a lot, I'll have a look at that code :)
DITMan
6th June 2003 16:41 UTC
OMG! I just had to add extern "C" to the function I was exporting... I thought it would be more difficult :P
Now I'll investigate how to get a string out from the stack :P
popstring(string_where_i_want_to_keep_the_parameter) will do ???:P
DITMan
6th June 2003 17:06 UTC
Okey... I think my DLL works but when scripting, if I use the 'summarized' form for calling the function in the DLL, I get a compilation error :(
Invalid command: KillProcDLL::KillProc
Error in script "C:\Archivos de programa\NSIS\Examples\kaka.nsi" on line 23 -- aborting creation process
I've also tried using KillProcDLL.dll::KillProc :(
I'm using NSIS 2.0b3 (I think so :P)
DITMan
6th June 2003 17:10 UTC
Okaaaay solved too... :P I should try more things before posting... My dll works now like a charm and does what it is expected to do :D
How would you all DLL programmers return values from the DLL? with pushstring or storing it in another variable?? It's to keep the current DLL Plug-In style :) thanks.
Afrow UK
6th June 2003 18:27 UTC
When you're dll is done, make sure to put it on the archive!!!
A nice thing to add would be a...
KillProcDLL::KillProc "App Name"
Where App Name could be some common Windows programs, which you would list in the readme.
Good work!
-Stu :)
DITMan
6th June 2003 19:36 UTC
Okay, that's easy... but it's quite easy by now... you can erase any process by its name, like msnmsgr.exe or notepad.exe...
It's almost done, it returns the error code in $R0, so push it before calling this function...
It needs some more testing, but it's close to 'final release' :P, i've got tu put up the documentation and give credits to the real author (and remove the pre-generated comments by VC++ :P)
C ya!
kichik
7th June 2003 11:07 UTC
I'd choose reboot over termination every time possible. As stated in the MSDN documentation for TerminateProcess:
The TerminateProcess function is used to unconditionally cause a process to exit. Use it only in extreme circumstances. The state of global data maintained by dynamic-link libraries (DLLs) may be compromised if TerminateProcess is used rather than ExitProcess.
kichik
8th June 2003 18:51 UTC
Originally posted by DITMan
How would you all DLL programmers return values from the DLL? with pushstring or storing it in another variable?? It's to keep the current DLL Plug-In style :) thanks.
The convention is to push the return value on the stack.