Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

#623 pythoncomloader.dll and undefined LoadLibraryEx behavior

closed-fixed
nobody
com (105)
5
2012-12-27
2012-12-21
Anonymous
No

MSDN's documentation for LoadLibraryEx states "The behavior is undefined when LOAD_WITH_ALTERED_SEARCH_PATHflag is set, and lpFileName specifiies a relative path."

com/win32com/src/PythonCOMLoader.cpp: HMODULE hpycom = LoadLibraryEx(DLL_DELEGATE, NULL, LOAD_WITH_ALTERED_SEARCH_PATH);
setup.py: ccargs.append('/DDLL_DELEGATE=\\"pythoncom%s.dll\\"' % (suffix,))

An absolute path should be used instead.

Discussion

  • Mark Hammond
    Mark Hammond
    2012-12-21

    Thanks for the patch! It seems to be that instead of referencing __ImageBase we could just pass the HINSTANCE from DllMain as a param - is there any reason that would not work?

     
  • Mark Hammond
    Mark Hammond
    2012-12-21

    oops - I was too quick in my scan of the patch. It can't be passed as a param, but having it as a global is probably still fine IMO.

     

  • Anonymous
    2012-12-21

    v2 of patch with HINSTANCE global

     

  • Anonymous
    2012-12-21

    Yes, a global HINSTANCE works fine. Patch attached.

    (Please disregard previous patch, it neglects to actaully assign hpycom. I didn't have a VS2008 compiler to test with)

    The current patch fixes my issue with loading out of a virtual env.

     

  • Anonymous
    2012-12-22

    v3 of patch with correct DllMain signature to compile under STRICT

     
  • Mark Hammond
    Mark Hammond
    2012-12-27

    • status: open --> closed-fixed
     
  • Mark Hammond
    Mark Hammond
    2012-12-27

    Awesome, thanks! Checked in as rev 4295:860ef545eb60