Ignore:
Timestamp:
Nov 18, 2002, 2:54:12 PM (23 years ago)
Author:
sandervl
Message:

Added support for renaming of exported functions

File:
1 edited

Legend:

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

    r8887 r9411  
    1 /* $Id: winimagelx.cpp,v 1.17 2002-07-18 12:01:34 achimha Exp $ */
     1/* $Id: winimagelx.cpp,v 1.18 2002-11-18 13:53:54 sandervl Exp $ */
    22
    33/*
     
    7373    if(lpszCustomDllName) {
    7474       name = lpszCustomDllName;
    75        this->dwOrdinalBase = ::dwOrdinalBase;
     75       this->dwOrdinalBase    = ::dwOrdinalBase;
     76     
     77       if(lpszCustomExportPrefix) {
     78           this->lpszExportPrefix = strdup(::lpszCustomExportPrefix);
     79       }
    7680    }
    7781    else {
    7882       name = OSLibGetDllName(hinstance);
    79        this->dwOrdinalBase = 0;
     83       this->dwOrdinalBase    = 0;
     84       this->lpszExportPrefix = NULL;
    8085    }
    8186
     
    97102Win32LxImage::~Win32LxImage()
    98103{
     104    if(lpszExportPrefix) free(lpszExportPrefix);
     105
    99106    if(header) {
    100107        DosFreeMem(header);
     
    108115    ULONG       apiaddr;
    109116
     117    if(lpszExportPrefix)
     118    {//if this dll exports by name with a prefix, then concatenate the prefix
     119     //with the export name to get the OS/2 export name
     120        char *lpszNewName = (char *)alloca(strlen(name) + strlen(lpszExportPrefix)+1);
     121        if(lpszNewName == NULL) {
     122            DebugInt3();
     123            return 0;
     124        }
     125        strcpy(lpszNewName, lpszExportPrefix);
     126        strcat(lpszNewName, name);
     127        rc = DosQueryProcAddr(hinstanceOS2, 0, lpszNewName, (PFN *)&apiaddr);
     128        if(rc == NO_ERROR) {
     129            return(apiaddr);
     130        }
     131        //else try with the normal name
     132    }
    110133    rc = DosQueryProcAddr(hinstanceOS2, 0, name, (PFN *)&apiaddr);
    111134    if(rc)
    112135    {
    113             dprintf(("Win32LxImage::getApi %x %s -> rc = %d", hinstanceOS2, name, rc));
    114             return(0);
     136        dprintf(("Win32LxImage::getApi %x %s -> rc = %d", hinstanceOS2, name, rc));
     137        return(0);
    115138    }
    116139    return(apiaddr);
     
    123146    ULONG       apiaddr;
    124147
    125     rc = DosQueryProcAddr(hinstanceOS2, dwOrdinalBase + ordinal, NULL, (PFN *)&apiaddr);
     148    rc = DosQueryProcAddr(hinstanceOS2, dwOrdinalBase+ordinal, NULL, (PFN *)&apiaddr);
    126149    if(rc) {
    127150        dprintf(("Win32LxImage::getApi %x %d -> rc = %d", hinstanceOS2, ordinal, rc));
     
    131154}
    132155//******************************************************************************
    133 // here we build a fake PE header for an LX module. In Windows, HINSTANCE handles
    134 // actually contain the virtual address of of the PE header. We try to fill in
    135 // sensible values as much as possible...
    136156//******************************************************************************
    137157LPVOID Win32LxImage::buildHeader(DWORD MajorImageVersion, DWORD MinorImageVersion,
     
    144164    DWORD *ntsig;
    145165
    146     // AH TODO: we are wasting 60k address space here!!!! (at least without PAG_ANY)
    147166    rc = DosAllocMem(&header, 4096, PAG_READ | PAG_WRITE | PAG_COMMIT | flAllocMem);
    148167    if(rc) {
    149168        dprintf(("ERROR: buildHeader DosAllocMem failed!! (rc=%x)", rc));
    150169        DebugInt3();
    151         return NULL;
     170            return NULL;
    152171    }
    153172    memcpy(header, dosHeader, sizeof(dosHeader));
Note: See TracChangeset for help on using the changeset viewer.