Old 14th November 2014, 19:28   #1
parasoul
Senior Member
 
Join Date: Aug 2007
Posts: 117
Question Plugin not Recognized by NSIS

Hello,
I'm compiling a NSIS plugin in Watcom using C++. I'm exporting a simple NSIS function:

PHP Code:
#define NSISFUNC(name) extern "C" void __declspec(dllexport) name(HWND hWndParent, int string_size, int* variables, stack_t** stacktop, extra_parameters* extra)
NSISFUNC(Test)
{
MessageBox(0,"test",0,0);

The export is showing in CFF Explorer:
http://i.gyazo.com/af29352caf9ab10d58a55c630cb4ca9b.png

The file is being built as a DLL:
http://i.gyazo.com/bfb0566d76a126c6d060e06a9bcc931e.png

when I try to compile:
Quote:
Name: "Memento"
OutFile: "Memento.exe"
XPStyle: on
ShowInstDetails: show
Section: ""
Invalid command: Test::Test
I'm 100% positive Test.dll is in the correct directory

I'm not sure exactly how NSIS's compiler resolves a plugin function, but I assume that it looks for the presence of the DLL -> make sure that it's a DLL -> presence of an export matching the function name -> done

Any idea what the problem is here?

Here's a download to Test.dll:
https://www.sendspace.com/file/4kz9ip

Many thanks
parasoul is offline   Reply With Quote
Old 14th November 2014, 20:48   #2
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,263
The VirtualSize field in the IMAGE_SECTION_HEADER for IMAGE_DIRECTORY_ENTRY_EXPORT is zero which is why makensis fails to find the export.

I don't know if your compiler/linker fails to follow the PE spec or if it is OK to set it to zero even though it contains initialized data, if that is the case then it is a bug in makensis.

Edit: I changed the way makensis looks for the exports section, should be fixed in the next release...

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 15th November 2014, 00:40   #3
parasoul
Senior Member
 
Join Date: Aug 2007
Posts: 117
Sounds great, Anders. Where can I acquire this new makensis?

Many thanks
parasoul is offline   Reply With Quote
Old 15th November 2014, 02:03   #4
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,263
Unless you compile it yourself you have to wait until the next release, next year probably. It is also probably possible to patch v2.46 with a hex editor if you can figure out which bytes to change or patch your dll after linking. Your final option is to use a different linker. Mingw and Visual Studio can both be used for free...

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 15th November 2014, 03:43   #5
parasoul
Senior Member
 
Join Date: Aug 2007
Posts: 117
Ok I see. Can you please just tell me what source file needs to be changed? I'll go ahead and compile it myself

edit:

I assume this is the line that needs to be changed:
http://i.gyazo.com/25f0611ed45e8bdc40802f0ecc7cd133.png

?

Thanks again
parasoul is offline   Reply With Quote
Old 15th November 2014, 06:22   #6
JasonFriday13
Major Dude
 
JasonFriday13's Avatar
 
Join Date: May 2005
Location: New Zealand
Posts: 886
It's been committed in svn: http://sourceforge.net/p/nsis/code/6569/.

"Only a MouseHelmet will save you from a MouseTrap" -Jason Ross (Me)
NSIS 3 POSIX Ninja
Wiki Profile
JasonFriday13 is offline   Reply With Quote
Old 15th November 2014, 07:11   #7
parasoul
Senior Member
 
Join Date: Aug 2007
Posts: 117
Thanks very much Jason and Anders. All settled now.
parasoul is offline   Reply With Quote
Old 15th November 2014, 18:40   #8
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,263
Patch for v3.0b1: 8B 52 08 8B --> 8B 52 10 8B (sort of untested) I believe the code in 2.46 is @ 00019EA6 but I'm not sure if it is possible to patch it.

Your plugin crashed on exit when I tested it, make sure the function is cdecl and not stdcall.

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump