Subject: | strawberry-perl-5.18.4.1-32bit: perl518.dll cannot be relocated |
Date: | Fri, 17 Apr 2015 10:11:54 +0000 |
To: | "bug-Perl-Dist-Strawberry [...] rt.cpan.org" <bug-Perl-Dist-Strawberry [...] rt.cpan.org> |
From: | John Unsworth <John.Unsworth [...] owmessaging.com> |
Using strawberry-perl-5.18.4.1-32bit.msi.
I need to load perl518.dll in my application to use embedded perl calls. However if perl518.dll needs to be relocated (a common requirement of windows dlls) a memory access error occurs.
I built a simple Visual C application:
printf("Trying to load perl518.dll ...\n");
HMODULE hm = LoadLibrary(L"C:\\strawberry518\\perl\\bin\\perl518.dll");
if (hm == NULL)
{
LPVOID lpMsgBuf;
LPTSTR args[2];
args[0] = L"perl518.dll";
args[1] = NULL;
FormatMessage(
FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS |
FORMAT_MESSAGE_ARGUMENT_ARRAY,
NULL,
GetLastError(),
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
(LPTSTR) &lpMsgBuf,
0,
(va_list*)args
);
printf("Error %d %S\n", GetLastError(), (const char*)lpMsgBuf);
}
If the application is built so that it loads at perl518 preferred address 0x63300000 then the above load results in:
Trying to load perl518.dll ...
Error 998 Invalid access to memory location.
The error occurs in the dll initialization function.
If I change the application base address so it doesn't clash then it loads successfully:
TestLoad.exe C:\SmartSVN\CPMDS\Atlas\v4.0\shared\Bin\TestLoad.exe 64300000-6431A000
perl518.dll C:\strawberry518\perl\bin\perl518.dll 63300000-6347E000
It cannot be guaranteed that 63300000 will be available and so the dll has to be able to relocate. The same applies to any other dlls that you supply. This is a standard windows requirement.
Regards,
John.