Old 20th January 2011, 15:07   #1
yotambarzilay
Junior Member
 
Join Date: Jan 2011
Posts: 1
Question Problem sending string arg to DLL function

Hey all,
I need some assistant.
I'm calling a DLL function from an NSIS script. The function takes a char* as an argument. However, when I send a string to the DLL function, I only get the first char of the string.

Here's the call to the function:
Processes::KillParentProcess "chrome"

I get the string in the DLL by using popstring(char* str)

To debug, I used a message box and only got "c" instead of "chrome"

I'd really appreciate some input on this
yotambarzilay is offline   Reply With Quote
Old 15th April 2011, 21:40   #2
rebot
Junior Member
 
Join Date: Apr 2011
Posts: 6
I'm having the same issue....anybody have any advice? Popstring is returning only the first character from the string parameter.
rebot is offline   Reply With Quote
Old 15th April 2011, 22:09   #3
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
Are you using Unicode NSIS with a non-unicode DLL or maybe vice-versa?

Some code would help too.

Stu
Afrow UK is offline   Reply With Quote
Old 15th April 2011, 22:27   #4
rebot
Junior Member
 
Join Date: Apr 2011
Posts: 6
Unicode NSIS with Unicode RealProgress plugin.

From the call to plugin:
RealProgress:etailProgress /NOUNLOAD 30 40

Debugging the plugin code...in the function

int popstring(TCHAR *str, int len)
{
stack_t *th;

if (!g_stacktop || !*g_stacktop) return 1;
th=(*g_stacktop);
lstrcpyn(str, th->text, len);
*g_stacktop=th->next;
GlobalFree((HGLOBAL)th);
return 0;
}

str is returning '3' (as opposed to '30') when called from the DetailProgress function...

extern "C"
void __declspec(dllexport) DetailProgress(HWND hWndParent, int string_size,
TCHAR *variables, stack_t **stacktop,
extra_parameters *extra)
{
g_hWndParent=hWndParent;

EXDLL_INIT();
{
TCHAR szParam[8];

// Attempt to get a parameter.
if (popstring(szParam, 8) == 0)
{

//szParam evaluated at this point is '3'
//MessageBox(hWndParent, szParam, "Add szParam", MB_OK);


// Get the number of details to be printed.
g_iProgressBarAdd = str2int(szParam);

.
.
etc.
rebot is offline   Reply With Quote
Old 15th April 2011, 22:37   #5
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
Are you definitely using Unicode character set in the plug-in? Sounds to me like you aren't because a Unicode '3' would be an ASCII '3' padded with a leading NULL byte thereby terminating the string as a single ASCII character.

Stu
Afrow UK is offline   Reply With Quote
Old 15th April 2011, 22:39   #6
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
I should probably elaborate a bit more:

* Check you have Unicode selected in Properties (that one is too obvious I know)
* Check you have since done a Clean/Rebuild
* Are you using the Unicode pluginapi.lib and header?

Stu
Afrow UK is offline   Reply With Quote
Old 16th April 2011, 00:09   #7
rebot
Junior Member
 
Join Date: Apr 2011
Posts: 6
Yes. Unicode versions of all.
rebot is offline   Reply With Quote
Old 16th April 2011, 09:30   #8
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
Well I'll need more than that. Attach the files including the vcxproj.

Stu
Afrow UK is offline   Reply With Quote
Old 18th April 2011, 17:43   #9
rebot
Junior Member
 
Join Date: Apr 2011
Posts: 6
vcproj file can be found here
rebot is offline   Reply With Quote
Old 18th April 2011, 18:21   #10
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
I said files including the vcproj. I can't build without all the files.

Stu
Afrow UK is offline   Reply With Quote
Old 29th April 2011, 00:26   #11
rebot
Junior Member
 
Join Date: Apr 2011
Posts: 6
Plugin files can be found below:

RealProgress.cpp
RealProgress.vcproj
RealProgress.dsp
RealProgress.sln
rebot is offline   Reply With Quote
Old 30th April 2011, 09:41   #12
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
I can't see any reference to the Unicode plug-in API in there. You should really use that. For an example, look at my Aero plug-in which has both ANSI and Unicode plug-in APIs bundled and a build configuration for each. Also if you use the plug-in API you get myatoi and myatou so you don't need to use CRT (which you want to avoid).

Stu
Afrow UK is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

Tags
char, dll, function, problem, string

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