Ignore:
Timestamp:
Feb 20, 2003, 10:47:01 AM (23 years ago)
Author:
sandervl
Message:

Added custombuild API for registering a callback for LX Dll loading thru LoadLibrary*()

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/kernel32/wprocess.cpp

    r9802 r9828  
    1 /* $Id: wprocess.cpp,v 1.180 2003-02-13 17:16:50 sandervl Exp $ */
     1/* $Id: wprocess.cpp,v 1.181 2003-02-20 09:47:01 sandervl Exp $ */
    22
    33/*
     
    5151#include <win\ntddk.h>
    5252
     53#include <custombuild.h>
     54
    5355#define DBG_LOCALLOG    DBG_wprocess
    5456#include "dbglocal.h"
     
    8890static TEB      *threadList = 0;
    8991static VMutex    threadListMutex;
     92
     93/**
     94 * LoadLibraryExA callback for LX Dlls, it's call only on the initial load.
     95 * Maintained by ODIN_SetLxDllLoadCallback().
     96 * Note! Because of some hacks it may also be called from Win32LxDll::Release().
     97 */
     98PFNLXDLLLOAD pfnLxDllLoadCallback = NULL;
    9099
    91100
     
    451460//******************************************************************************
    452461// ODIN_SetTIBSwitch: override TIB switching
    453 // 
     462//
    454463// Parameters:
    455464//      BOOL fSwitchTIB
     
    743752    fDisableLXDllLoading = TRUE;
    744753}
     754
     755
     756/**
     757 * Custombuild API for registering a callback for LX Dll loading thru LoadLibrary*().
     758 * @returns Success indicator.
     759 * @param   pfn     Pointer to callback.
     760 *                  NULL if callback is deregistered.
     761 */
     762BOOL WIN32API ODIN_SetLxDllLoadCallback(PFNLXDLLLOAD pfn)
     763{
     764    pfnLxDllLoadCallback = pfn;
     765    return TRUE;
     766}
     767
    745768
    746769/**
     
    942965     *      Try load the executable using LoadLibrary
    943966     *      IF successfully loaded THEN
    944      *          IF LX dll and is using the PE Loader THEN
    945      *              Set Load library.
    946      *              Inc reference count.
     967     *          Try find registered/pe2lx object.
     968     *          IF callback Then
     969     *              If callback give green light Then
     970     *                  Find registered lx object.
     971     *              Else
     972     *                  Unload it if loaded.
     973     *              Endif
    947974     *          Endif
    948      *          Inc dynamic reference count.
    949      *          RETURN successfully.
     975     *          IF module object found Then
     976     *              IF LX dll and is using the PE Loader THEN
     977     *                  Set Load library.
     978     *                  Inc reference count.
     979     *              Endif
     980     *              Inc dynamic reference count.
     981     *              RETURN successfully.
     982     *          Else
     983     *              fail.
     984     *          Endif
    950985     *      Endif
    951986     *  Endif
     
    959994            /* OS/2 dll, system dll, converted dll or win32k took care of it. */
    960995            pModule = Win32DllBase::findModuleByOS2Handle(hDll);
     996            /* Custombuild customizing may take care of it too. */
     997            if (pfnLxDllLoadCallback)
     998            {
     999                /* If callback says yes, continue load it, else fail. */
     1000                if (pfnLxDllLoadCallback(hDll, pModule ? pModule->getInstanceHandle() : NULL))
     1001                    pModule = Win32DllBase::findModuleByOS2Handle(hDll);
     1002                else if (pModule)
     1003                {
     1004                    pModule->Release();
     1005                    pModule = NULL;
     1006                }
     1007            }
    9611008            if (pModule)
    9621009            {
     
    18351882#endif
    18361883
    1837     if(bInheritHandles && lpStartupInfo->dwFlags & STARTF_USESTDHANDLES) 
     1884    if(bInheritHandles && lpStartupInfo->dwFlags & STARTF_USESTDHANDLES)
    18381885    {
    18391886        //Translate standard handles if the child needs to inherit them
     
    18451892        retcode |= HMHandleTranslateToOS2(lpStartupInfo->hStdError, &startinfo.hStdError);
    18461893
    1847         if(retcode) { 
     1894        if(retcode) {
    18481895            SetLastError(ERROR_INVALID_HANDLE);
    18491896            return FALSE;
     
    23212368//******************************************************************************
    23222369// ODIN_SetProcAddress: Override a dll export
    2323 // 
     2370//
    23242371// Parameters:
    23252372//      HMODULE hModule         Module handle
     
    23312378//
    23322379//******************************************************************************
    2333 FARPROC WIN32API ODIN_SetProcAddress(HMODULE hModule, LPCSTR lpszProc, 
     2380FARPROC WIN32API ODIN_SetProcAddress(HMODULE hModule, LPCSTR lpszProc,
    23342381                                     FARPROC pfnNewProc)
    23352382{
Note: See TracChangeset for help on using the changeset viewer.