Changes between Initial Version and Version 1 of Ticket #7213


Ignore:
Timestamp:
Jan 25, 2018 3:21:21 PM (10 months ago)
Author:
Maik Riechert
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #7213 – Description

    initial v1  
    88
    99{{{
     10// First try in the current process in case the python symbols would
     11// be already loaded
     12HANDLE hProcess = GetCurrentProcess();
    1013HMODULE ahModules[100];
    1114DWORD nSizeNeeded = 0;
    1215
    1316EnumProcessModules(hProcess, ahModules, sizeof(ahModules),
    14 &nSizeNeeded);
     17                    &nSizeNeeded);
     18
     19const size_t nModules =
     20    std::min(size_t(100),
     21             static_cast<size_t>(nSizeNeeded) / sizeof(HMODULE));
     22for( size_t i = 0; i < nModules; i++ )
     23{
     24    if( GetProcAddress(ahModules[i], "Py_SetProgramName") )
     25    {
     26        libHandle = ahModules[i];
     27        CPLDebug("VRT", "Current process has python symbols loaded");
     28        break;
     29    }
     30}
    1531}}}
    1632