Ignore:
Timestamp:
Oct 10, 2000, 7:14:09 PM (25 years ago)
Author:
sandervl
Message:

pe loader fixes, add system32\drivers dir during installation, add build date + time during kernel32 load

File:
1 edited

Legend:

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

    r4471 r4474  
    1 /* $Id: winimagepeldr.cpp,v 1.59 2000-10-09 18:35:26 sandervl Exp $ */
     1/* $Id: winimagepeldr.cpp,v 1.60 2000-10-10 17:14:08 sandervl Exp $ */
    22
    33/*
     
    1414 *       (circular dependencies; have to check what NT does)
    1515 *
    16  * NOTE: RSRC_LOAD is a special flag to only load the resource directory
     16 * NOTE: FLAG_PELDR_LOADASDATAFILE is a special flag to only load the resource directory
    1717 *       of a PE image. Processing imports, sections etc is not done.
    18  *       Nor is it put into the linked list of dlls (if it's a dll).
    1918 *       This is useful for GetVersionSize/Resource in case it wants to
    2019 *       get version info of an image that is not loaded.
     
    103102//******************************************************************************
    104103//******************************************************************************
    105 Win32PeLdrImage::Win32PeLdrImage(char *pszFileName, BOOL isExe, int loadtype) :
     104Win32PeLdrImage::Win32PeLdrImage(char *pszFileName, BOOL isExe) :
    106105    Win32ImageBase(-1),
    107     nrsections(0), imageSize(0),
     106    nrsections(0), imageSize(0), dwFlags(0),
    108107    imageVirtBase(-1), realBaseAddress(0), imageVirtEnd(0),
    109108    nrNameExports(0), nrOrdExports(0), nameexports(NULL), ordexports(NULL),
     
    111110{
    112111 HFILE  dllfile;
    113 
    114   loadType = loadtype;
    115112
    116113  strcpy(szFileName, pszFileName);
     
    282279  nSections = NR_SECTIONS(win32file);
    283280
    284   if(loadType == REAL_LOAD)
     281  if(!(dwFlags & FLAG_PELDR_LOADASDATAFILE))
    285282  {
    286283   imageSize = 0;
     
    307304        if(IsSectionType(win32file, &psh[i], IMAGE_DIRECTORY_ENTRY_EXPORT))
    308305        {
    309             dprintf((LOG, ".edata" ));
    310             addSection(SECTION_EXPORT, psh[i].PointerToRawData,
    311                    psh[i].SizeOfRawData, psh[i].VirtualAddress + oh.ImageBase,
    312                    psh[i].Misc.VirtualSize, psh[i].Characteristics);
    313             continue;
     306            //SvL: Angus.exe has empty export section that's really an
     307            //     uninitialized data section
     308            if(psh[i].SizeOfRawData) {
     309                 dprintf((LOG, ".edata" ));
     310                 addSection(SECTION_EXPORT, psh[i].PointerToRawData,
     311                      psh[i].SizeOfRawData, psh[i].VirtualAddress + oh.ImageBase,
     312                      psh[i].Misc.VirtualSize, psh[i].Characteristics);
     313                 continue;
     314            }
    314315        }
    315316        if(IsSectionType(win32file, &psh[i], IMAGE_DIRECTORY_ENTRY_RESOURCE))
     
    439440  }
    440441
    441   if(loadType == REAL_LOAD)
     442  if(!(dwFlags & FLAG_PELDR_LOADASDATAFILE))
    442443  {
    443444   if(tlsDir = (IMAGE_TLS_DIRECTORY *)ImageDirectoryOffset(win32file, IMAGE_DIRECTORY_ENTRY_TLS))
     
    554555  }
    555556
    556   if (loadType == REAL_LOAD)
     557  if(!(dwFlags & (FLAG_PELDR_LOADASDATAFILE | FLAG_PELDR_SKIPIMPORTS)))
    557558  {
    558    if(processImports((char *)win32file) == FALSE) {
    559         dprintf((LOG, "Failed to process imports!" ));
    560         goto failure;
    561    }
    562   }
    563 
     559        if(processImports((char *)win32file) == FALSE) {
     560             dprintf((LOG, "Failed to process imports!" ));
     561             goto failure;
     562        }
     563  }
    564564  return(TRUE);
     565
    565566failure:
    566567  if(memmap) {
     
    730731
    731732  //SvL: We don't care where the image is loaded for resource lookup
    732   if(fh.Characteristics & IMAGE_FILE_RELOCS_STRIPPED && loadType == REAL_LOAD) {
     733  if(fh.Characteristics & IMAGE_FILE_RELOCS_STRIPPED && !(dwFlags & FLAG_PELDR_LOADASDATAFILE)) {
    733734        return allocFixedMem(reservedMem);
    734735  }
     
    898899
    899900        case SECTION_READONLYDATA:
     901        case SECTION_EXPORT:
    900902        default:
    901903                section[i].pageflags = PAG_READ;
    902904                break;
    903905        }
     906        if(section[i].flags & (IMAGE_SCN_CNT_INITIALIZED_DATA|IMAGE_SCN_CNT_UNINITIALIZED_DATA)) {
     907                //SvL: sometimes i.e. import/export sections also contain data
     908                //     must make them read/write
     909                section[i].pageflags = PAG_WRITE;
     910        }
     911
    904912  }
    905913  return(TRUE);
     
    14861494  {
    14871495    dprintf((LOG, "Module %s", pszCurModule ));
    1488     dprintf((LOG, "ForwarderChain: %x", pID[i].ForwarderChain));
     1496    if(pID[i].ForwarderChain) {
     1497        dprintf((LOG, "ForwarderChain: %x", pID[i].ForwarderChain));
     1498    }
    14891499    //  a) check that OriginalFirstThunk not is 0 and look for Borland-styled PE
    14901500    if (i == 0)
Note: See TracChangeset for help on using the changeset viewer.