Ignore:
Timestamp:
Mar 19, 2014, 11:31:01 PM (11 years ago)
Author:
dmik
Message:

python: Merge vendor 2.7.6 to trunk.

Location:
python/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • python/trunk

  • python/trunk/PC/dl_nt.c

    r2 r391  
    44
    55About the only reason for having this, is so initall() can automatically
    6 be called, removing that burden (and possible source of frustration if 
     6be called, removing that burden (and possible source of frustration if
    77forgotten) from the programmer.
    88
     
    4747void _LoadActCtxPointers()
    4848{
    49         HINSTANCE hKernel32 = GetModuleHandleW(L"kernel32.dll");
    50         if (hKernel32)
    51                 pfnGetCurrentActCtx = (PFN_GETCURRENTACTCTX) GetProcAddress(hKernel32, "GetCurrentActCtx");
    52         // If we can't load GetCurrentActCtx (ie, pre XP) , don't bother with the rest.
    53         if (pfnGetCurrentActCtx) {
    54                 pfnActivateActCtx = (PFN_ACTIVATEACTCTX) GetProcAddress(hKernel32, "ActivateActCtx");
    55                 pfnDeactivateActCtx = (PFN_DEACTIVATEACTCTX) GetProcAddress(hKernel32, "DeactivateActCtx");
    56                 pfnAddRefActCtx = (PFN_ADDREFACTCTX) GetProcAddress(hKernel32, "AddRefActCtx");
    57                 pfnReleaseActCtx = (PFN_RELEASEACTCTX) GetProcAddress(hKernel32, "ReleaseActCtx");
    58         }
     49    HINSTANCE hKernel32 = GetModuleHandleW(L"kernel32.dll");
     50    if (hKernel32)
     51        pfnGetCurrentActCtx = (PFN_GETCURRENTACTCTX) GetProcAddress(hKernel32, "GetCurrentActCtx");
     52    // If we can't load GetCurrentActCtx (ie, pre XP) , don't bother with the rest.
     53    if (pfnGetCurrentActCtx) {
     54        pfnActivateActCtx = (PFN_ACTIVATEACTCTX) GetProcAddress(hKernel32, "ActivateActCtx");
     55        pfnDeactivateActCtx = (PFN_DEACTIVATEACTCTX) GetProcAddress(hKernel32, "DeactivateActCtx");
     56        pfnAddRefActCtx = (PFN_ADDREFACTCTX) GetProcAddress(hKernel32, "AddRefActCtx");
     57        pfnReleaseActCtx = (PFN_RELEASEACTCTX) GetProcAddress(hKernel32, "ReleaseActCtx");
     58    }
    5959}
    6060
    6161ULONG_PTR _Py_ActivateActCtx()
    6262{
    63         ULONG_PTR ret = 0;
    64         if (PyWin_DLLhActivationContext && pfnActivateActCtx)
    65                 if (!(*pfnActivateActCtx)(PyWin_DLLhActivationContext, &ret)) {
    66                         OutputDebugString("Python failed to activate the activation context before loading a DLL\n");
    67                         ret = 0; // no promise the failing function didn't change it!
    68                 }
    69         return ret;
     63    ULONG_PTR ret = 0;
     64    if (PyWin_DLLhActivationContext && pfnActivateActCtx)
     65        if (!(*pfnActivateActCtx)(PyWin_DLLhActivationContext, &ret)) {
     66            OutputDebugString("Python failed to activate the activation context before loading a DLL\n");
     67            ret = 0; // no promise the failing function didn't change it!
     68        }
     69    return ret;
    7070}
    7171
    7272void _Py_DeactivateActCtx(ULONG_PTR cookie)
    7373{
    74         if (cookie && pfnDeactivateActCtx)
    75                 if (!(*pfnDeactivateActCtx)(0, cookie))
    76                         OutputDebugString("Python failed to de-activate the activation context\n");
     74    if (cookie && pfnDeactivateActCtx)
     75        if (!(*pfnDeactivateActCtx)(0, cookie))
     76            OutputDebugString("Python failed to de-activate the activation context\n");
    7777}
    7878
    79 BOOL    WINAPI  DllMain (HANDLE hInst,
    80                                                 ULONG ul_reason_for_call,
    81                                                 LPVOID lpReserved)
     79BOOL    WINAPI  DllMain (HANDLE hInst,
     80                                                ULONG ul_reason_for_call,
     81                                                LPVOID lpReserved)
    8282{
    83         switch (ul_reason_for_call)
    84         {
    85                 case DLL_PROCESS_ATTACH:
    86                         PyWin_DLLhModule = hInst;
    87                         // 1000 is a magic number I picked out of the air.  Could do with a #define, I spose...
    88                         LoadString(hInst, 1000, dllVersionBuffer, sizeof(dllVersionBuffer));
     83    switch (ul_reason_for_call)
     84    {
     85        case DLL_PROCESS_ATTACH:
     86            PyWin_DLLhModule = hInst;
     87            // 1000 is a magic number I picked out of the air.  Could do with a #define, I spose...
     88            LoadString(hInst, 1000, dllVersionBuffer, sizeof(dllVersionBuffer));
    8989
    90                         // and capture our activation context for use when loading extensions.
    91                         _LoadActCtxPointers();
    92                         if (pfnGetCurrentActCtx && pfnAddRefActCtx)
    93                                 if ((*pfnGetCurrentActCtx)(&PyWin_DLLhActivationContext))
    94                                         if (!(*pfnAddRefActCtx)(PyWin_DLLhActivationContext))
    95                                                 OutputDebugString("Python failed to load the default activation context\n");
    96                         break;
     90            // and capture our activation context for use when loading extensions.
     91            _LoadActCtxPointers();
     92            if (pfnGetCurrentActCtx && pfnAddRefActCtx)
     93                if ((*pfnGetCurrentActCtx)(&PyWin_DLLhActivationContext))
     94                    if (!(*pfnAddRefActCtx)(PyWin_DLLhActivationContext))
     95                        OutputDebugString("Python failed to load the default activation context\n");
     96            break;
    9797
    98                 case DLL_PROCESS_DETACH:
    99                         if (pfnReleaseActCtx)
    100                                 (*pfnReleaseActCtx)(PyWin_DLLhActivationContext);
    101                         break;
    102         }
    103         return TRUE;
     98        case DLL_PROCESS_DETACH:
     99            if (pfnReleaseActCtx)
     100                (*pfnReleaseActCtx)(PyWin_DLLhActivationContext);
     101            break;
     102    }
     103    return TRUE;
    104104}
    105105
Note: See TracChangeset for help on using the changeset viewer.