IIS Module does not set dll path and LoadLibrary call does not specify 
libraries current dir as start of search path
--------------------------------------------------------------------------------------------------------------------

                 Key: AXIS2C-939
                 URL: https://issues.apache.org/jira/browse/AXIS2C-939
             Project: Axis2-C
          Issue Type: Bug
          Components: transport/http
    Affects Versions: Current (Nightly)
         Environment: Windows XP, IIS 5.1
            Reporter: Dave Meier
            Priority: Blocker


I have a services dll that depends on other dlls.  When I use 
axis2_http_server.exe it works fine, but under the IIS module, my service dll 
fails to load with a "Failed in creating DLL" message.

I modified the code and was able to get it to work and can provide a diff once 
I learn how to do that.  The change involved setting the dll path in the IIS 
module code and modifying the LoadLibrary call that Axis2C uses to load the 
service dll.  The second change involves telling LoadLibrary to search the same 
directory where the dll is located first when looking for other dlls that the 
service dll depends upon.  This change avoids a problem where an incorrect dll 
is picked up from somewhere else in the search path (aka "dll hell").

------------------------------------------------------------------------------------------------------------------------------
Change 1 - file "axis2_isapi_plugin.c", method 
"HttpExtensionProc(LPEXTENSION_CONTROL_BLOCK lpECB)"
------------------------------------------------------------------------------------------------------------------------------

    DWORD WINAPI HttpExtensionProc(LPEXTENSION_CONTROL_BLOCK lpECB) 

{

    DWORD rc = HSE_STATUS_ERROR;
    lpECB->dwHttpStatusCode = HTTP_INTERNAL_SERVER_ERROR;
    if (axis2_worker)
    {
        // windows cannot find the correct dlls unless the dir is set
        // but we want to reset to previous dir after the load
        char szOriginalPath[_MAX_PATH + 1];
        char szPath[_MAX_PATH + 1];
        DWORD dwBufferSize = 0;
        ZeroMemory(szOriginalPath, sizeof szOriginalPath);
        dwBufferSize = sizeof szOriginalPath;
#if _WIN32_WINNT >= 0x0502 // we stop supporting old WIN OSs
        GetDllDirectory( dwBufferSize, szOriginalPath );
#else
        GetCurrentDirectory( dwBufferSize, szOriginalPath );
#endif // _WIN32_WINNT >= 0x050

        ZeroMemory(szPath, sizeof szPath);
        dwBufferSize = sizeof szPath;
        lpECB->GetServerVariable(lpECB->ConnID, "APPL_PHYSICAL_PATH", szPath, 
&dwBufferSize);
        if ( strlen( szPath ) > 0 )
        {
            // windows cannot find the correct dlls unless the path is set
#if _WIN32_WINNT >= 0x0502 // we stop supporting old WIN OSs
            SetDllDirectory( szPath );
#else
            SetCurrentDirectory( szPath );
#endif // _WIN32_WINNT >= 0x050
        }


        AXIS2_IIS_WORKER_PROCESS_REQUEST(axis2_worker, axutil_env, lpECB);

        // windows cannot find the correct dlls unless the dir is set
        // but we want to reset to previous dir after the load
#if _WIN32_WINNT >= 0x0502 // we stop supporting old WIN OSs
        SetDllDirectory( szOriginalPath );
#else
        SetCurrentDirectory( szOriginalPath );
#endif // _WIN32_WINNT >= 0x050
    }
    else
        return HSE_STATUS_ERROR;

    return HSE_STATUS_SUCCESS;
}


------------------------------------------------------------------------------------------------------------------------------
Change 2 - file "axutil_windows.c", method "callLoadLib(char *lib)":
------------------------------------------------------------------------------------------------------------------------------

    return LoadLibraryEx(lib, NULL, LOAD_WITH_ALTERED_SEARCH_PATH);  // was 
"return LoadLibrary(lib);"



-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to