Problem with LoadLibrary() when booting with tmboot on windows 7/2008 R2.
838285Feb 9 2011 — edited Feb 16 2011I’ve noticed a problem loading libraries in windows 7 when booting a server with tmboot. The server starts correctly when the dll file is in the same folder as the current executable, or if the full path to the library is specified but fails when the dll is in a folder specified in the path. The executable itself loads the dll correctly when started directly from the command prompt.
I made a simple server to illustrate the problem:
#include<windows.h>
#include <atmi.h>
using namespace std;
int tpsvrinit(int argc, char *argv[])
{
HINSTANCE hinstLib;
try
{
hinstLib = LoadLibrary(TEXT("oci7112d_11.dll"));
}
catch(...) {}
if(!hinstLib)
{
DWORD dw = GetLastError();
LPVOID lpMsgBuf;
LPVOID lpDisplayBuf;
//sprintf(lpstrString, "%d", dw);
FormatMessage(
FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
dw,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
(LPTSTR) &lpMsgBuf,
0, NULL );
LPSTR cErr;
wsprintf(cErr,TEXT("Erorr %lu: %s"), dw, lpMsgBuf);
MessageBox(NULL,(LPTSTR) cErr, TEXT("Error"), MB_OK);
}
return 0;
}
void tpsvrdone()
{
}
Running the server directly from the command prompt results in no error while booting it from tmboot yields “Error 53: The network path was not found.”
If you hard code the absolute path of the dll it loads it successfully.
I’ve added a system(“set PATH > path.txt”); to the executable and it definitely has the correct folder C:\oc\domain\6.6.0\install\lib in the path.
I'm running Tuxedo 11r1 and building with visual studio 2008 on a 64 bit windows 7 machine. I experience the same problem with windows 2008 R2.
I was wondering if you’ve seen any problems dynamically loading dlls from the PATH with executables launched with tmboot?
Thanks.
EDIT:
I'm updating the post with new information:
The problem occurs because tmboot adds an extra \ \ BIN in the path when launched from tmboot. If there is a \LIB in the path it will also add \ \ LIB. These paths show up as network paths in windows 2008 R2 but not in 2008 R1, and once they fail to connect windows 2008 R2 it doesn't search any further.
I tested with Tuxedo 10R3 and the double backslash BIN's are not being added. Furthermore specifying the full path in TUXENV in 11r1 will prevent tmboot from adding the extraneous \\BIN's and \\LIB's, but that's not really an option for our configuration.
Edited by: 835282 on Feb 9, 2011 1:35 PM
Edited by: 835282 on Feb 16, 2011 10:51 AM
Edited by: 835282 on Feb 16, 2011 11:03 AM