Ignore:
Timestamp:
Nov 26, 1999, 1:05:20 AM (26 years ago)
Author:
sandervl
Message:

Allow executable api exports

File:
1 edited

Legend:

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

    r1835 r1844  
    1 /* $Id: winimagepeldr.cpp,v 1.16 1999-11-24 19:52:34 sandervl Exp $ */
     1/* $Id: winimagepeldr.cpp,v 1.17 1999-11-26 00:05:19 sandervl Exp $ */
    22
    33/*
     
    315315                tlsDir = (IMAGE_TLS_DIRECTORY *)ImageDirectoryOffset(win32file, IMAGE_DIRECTORY_ENTRY_TLS);
    316316                if(tlsDir) {
    317                         fout << "TLS Directory" << endl;
    318                         fout << "TLS Address of Index     " << hex((ULONG)tlsDir->AddressOfIndex) << endl;
    319                         fout << "TLS Address of Callbacks " << hex((ULONG)tlsDir->AddressOfCallBacks) << endl;
    320                         fout << "TLS SizeOfZeroFill       " << hex(tlsDir->SizeOfZeroFill) << endl;
    321                         fout << "TLS Characteristics      " << hex(tlsDir->Characteristics) << endl;
    322317                        addSection(SECTION_TLS, psh[i].PointerToRawData,
    323318                                   psh[i].SizeOfRawData, psh[i].VirtualAddress + oh.ImageBase,
     
    440435                goto failure;
    441436        }
     437        fout << "TLS Directory" << endl;
     438        fout << "TLS Address of Index     " << hex((ULONG)tlsDir->AddressOfIndex) << endl;
     439        fout << "TLS Address of Callbacks " << hex((ULONG)tlsDir->AddressOfCallBacks) << endl;
     440        fout << "TLS SizeOfZeroFill       " << hex(tlsDir->SizeOfZeroFill) << endl;
     441        fout << "TLS Characteristics      " << hex(tlsDir->Characteristics) << endl;
    442442        setTLSAddress((char *)sect->realvirtaddr);
    443443        setTLSInitSize(tlsDir->EndAddressOfRawData - tlsDir->StartAddressOfRawData);
     
    463463        commitPage((ULONG)pFixups, FALSE);
    464464   }
    465    if(fh.Characteristics & IMAGE_FILE_DLL) {
     465//   if(fh.Characteristics & IMAGE_FILE_DLL) {
    466466        if(processExports((char *)win32file) == FALSE) {
    467467                fout << "Failed to process exported apis" << endl;
    468468                goto failure;
    469469        }
    470    }
     470//   }
    471471  }
    472472
     
    14321432//******************************************************************************
    14331433//******************************************************************************
     1434ULONG Win32PeLdrImage::getApi(char *name)
     1435{
     1436  ULONG       apiaddr, i, apilen;
     1437  char       *apiname;
     1438  char        tmp[4];
     1439  NameExport *curexport;
     1440  ULONG       ulAPIOrdinal;                      /* api requested by ordinal */
     1441 
     1442  apilen = strlen(name) + 1;
     1443  if(apilen < 4)
     1444  {
     1445        *(ULONG *)tmp = 0;
     1446        strcpy(tmp, name);
     1447        apiname = tmp;
     1448  }
     1449  else  apiname = name;
     1450
     1451  curexport = nameexports;
     1452  for(i=0; i<nrNameExports; i++)
     1453  {
     1454    if(apilen == curexport->nlength &&
     1455       *(ULONG *)curexport->name == *(ULONG *)name)
     1456    {
     1457        if(strcmp(curexport->name, name) == 0)
     1458                return(curexport->virtaddr);
     1459    }
     1460    curexport = (NameExport *)((ULONG)curexport->name + curexport->nlength);
     1461  }
     1462  return(0);
     1463}
     1464//******************************************************************************
     1465//******************************************************************************
     1466ULONG Win32PeLdrImage::getApi(int ordinal)
     1467{
     1468 ULONG       apiaddr, i;
     1469 OrdExport  *curexport;
     1470 NameExport *nexport;
     1471
     1472  curexport = ordexports;
     1473  for(i=0;i<nrOrdExports;i++) {
     1474        if(curexport->ordinal == ordinal)
     1475                return(curexport->virtaddr);
     1476        curexport++;
     1477  }
     1478  //Name exports also contain an ordinal, so check this
     1479  nexport = nameexports;
     1480  for(i=0;i<nrNameExports;i++) {
     1481        if(nexport->ordinal == ordinal)
     1482                return(nexport->virtaddr);
     1483
     1484        nexport = (NameExport *)((ULONG)nexport->name + nexport->nlength);
     1485  }
     1486  return(0);
     1487}
     1488//******************************************************************************
     1489//******************************************************************************
    14341490ULONG MissingApi()
    14351491{
Note: See TracChangeset for help on using the changeset viewer.