Changeset 5932 for trunk/src/kernel32/winimagepeldr.cpp
- Timestamp:
- Jun 8, 2001, 1:04:26 PM (24 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kernel32/winimagepeldr.cpp
r5915 r5932 1 /* $Id: winimagepeldr.cpp,v 1.8 5 2001-06-06 10:33:16sandervl Exp $ */1 /* $Id: winimagepeldr.cpp,v 1.86 2001-06-08 11:04:25 sandervl Exp $ */ 2 2 3 3 /* … … 1384 1384 } 1385 1385 } 1386 1386 1387 1387 return(TRUE); 1388 1388 } … … 1391 1391 void Win32PeLdrImage::AddNameExport(ULONG virtaddr, char *apiname, ULONG ordinal, BOOL fAbsoluteAddress) 1392 1392 { 1393 ULONG nsize; 1393 ULONG nsize; 1394 int iApiNameLength = strlen(apiname); 1394 1395 1395 1396 if(nameexports == NULL) { 1396 nameExportSize= 4096; 1397 // think of a maximum of bytes per export name, 1398 // verify if this is true for MFC-DLLs, etc. 1399 nameExportSize = nrNameExports * (sizeof(NameExport) + 32); 1400 1397 1401 nameexports = (NameExport *)malloc(nameExportSize); 1398 1402 curnameexport = nameexports; 1399 1403 } 1400 1404 nsize = (ULONG)curnameexport - (ULONG)nameexports; 1401 if(nsize + sizeof(NameExport) + strlen(apiname)> nameExportSize) {1405 if(nsize + sizeof(NameExport) + iApiNameLength > nameExportSize) { 1402 1406 nameExportSize += 4096; 1403 1407 char *tmp = (char *)nameexports; … … 1413 1417 curnameexport->ordinal = ordinal; 1414 1418 *(ULONG *)curnameexport->name = 0; 1415 strcpy(curnameexport->name, apiname); 1416 1417 curnameexport->nlength = strlen(apiname) + 1; 1419 1420 curnameexport->nlength = iApiNameLength + 1; 1421 memcpy(curnameexport->name, apiname, curnameexport->nlength); 1422 1418 1423 if(curnameexport->nlength < sizeof(curnameexport->name)) 1419 1424 curnameexport->nlength = sizeof(curnameexport->name); … … 1442 1447 BOOL Win32PeLdrImage::AddForwarder(ULONG virtaddr, char *apiname, ULONG ordinal) 1443 1448 { 1444 char *forward = (char *)(realBaseAddress + (virtaddr - oh.ImageBase)); 1445 char *forwarddll, *forwardapi; 1446 Win32DllBase *WinDll; 1447 DWORD exportaddr; 1448 int forwardord; 1449 1450 forwarddll = strdup(forward); 1449 char *forward = (char *)(realBaseAddress + (virtaddr - oh.ImageBase)); 1450 char *forwarddll, *forwardapi; 1451 Win32DllBase *WinDll; 1452 DWORD exportaddr; 1453 int forwardord; 1454 int iForwardDllLength = strlen(forward); 1455 int iForwardApiLength; 1456 1457 if(iForwardDllLength == 0) 1458 return FALSE; 1459 1460 forwarddll = (char*)alloca(iForwardDllLength); 1451 1461 if(forwarddll == NULL) { 1462 DebugInt3(); 1452 1463 return FALSE; 1453 1464 } 1465 memcpy(forwarddll, forward, iForwardDllLength + 1); 1466 1454 1467 forwardapi = strchr(forwarddll, '.'); 1455 1468 if(forwardapi == NULL) { 1456 goto fail;1469 return FALSE; 1457 1470 } 1458 1471 *forwardapi++ = 0; 1459 if(strlen(forwarddll) == 0 || strlen(forwardapi) == 0) { 1460 goto fail; 1472 iForwardApiLength = strlen(forwardapi); 1473 if(iForwardApiLength == 0) { 1474 return FALSE; 1461 1475 } 1462 1476 WinDll = Win32DllBase::findModule(forwarddll); … … 1465 1479 if(WinDll == NULL) { 1466 1480 dprintf((LOG, "ERROR: couldn't find forwarder %s.%s", forwarddll, forwardapi)); 1467 goto fail;1481 return FALSE; 1468 1482 } 1469 1483 } … … 1473 1487 forwardord = atoi(forwardapi); 1474 1488 } 1475 if(forwardord != 0 || ( strlen(forwardapi)== 1 && *forwardapi == '0')) {1476 exportaddr = WinDll->getApi(forwardord);1477 } 1478 else 1489 if(forwardord != 0 || (iForwardApiLength == 1 && *forwardapi == '0')) { 1490 exportaddr = WinDll->getApi(forwardord); 1491 } 1492 else exportaddr = WinDll->getApi(forwardapi); 1479 1493 1480 1494 if(apiname) { … … 1484 1498 else { 1485 1499 dprintf((LOG, "address 0x%x @%d (0x%08x) forwarder %s.%s", virtaddr - oh.ImageBase, ordinal, virtaddr, forwarddll, forwardapi)); 1486 AddOrdExport(exportaddr, ordinal, TRUE); 1487 } 1488 free(forwarddll); 1500 AddOrdExport(exportaddr, ordinal, TRUE); 1501 } 1489 1502 return TRUE; 1490 1491 fail:1492 free(forwarddll);1493 return FALSE;1494 1503 } 1495 1504 //****************************************************************************** … … 1586 1595 return WinDll; 1587 1596 } 1597 1588 1598 //****************************************************************************** 1589 1599 /** All initial processing of imports is done here … … 1596 1606 BOOL Win32PeLdrImage::processImports(char *win32file) 1597 1607 { 1598 PIMAGE_IMPORT_DESCRIPTOR pID;1599 IMAGE_SECTION_HEADER shID;1600 IMAGE_SECTION_HEADER shExtra = {0};1601 PIMAGE_OPTIONAL_HEADER pOH;1602 int i,j, nrPages;1603 BOOL fBorland = 0;1604 int cModules;1605 char *pszModules;1606 char *pszCurModule;1607 char *pszTmp;1608 ULONG *pulImport;1609 ULONG ulCurFixup;1610 int Size;1611 Win32DllBase *WinDll;1612 Win32ImageBase *WinImage = NULL;1613 Section *section;1614 1615 /* "algorithm:"1616 * 1) get module names and store them1617 * a) check dwRVAModuleName is within .idata seg - if not find section1618 * 2) iterate thru functions of each module1619 * a) check OriginalFirstThunk is not 0 and that it points to a RVA.1620 * b) if not a) borland-styled PE-file - ARG!!!1621 * check FirstThunk1622 * c) check OriginalFirstThunk/FirstThunk ok RVAs and find right section1623 * d) store ordinal/name import1624 * 3) finished1625 */1626 1627 /* 1) get module names */1628 pID = (PIMAGE_IMPORT_DESCRIPTOR)ImageDirectoryOffset(win32file, IMAGE_DIRECTORY_ENTRY_IMPORT);1629 if (pID == NULL)1608 PIMAGE_IMPORT_DESCRIPTOR pID; 1609 IMAGE_SECTION_HEADER shID; 1610 IMAGE_SECTION_HEADER shExtra = {0}; 1611 PIMAGE_OPTIONAL_HEADER pOH; 1612 int i,j, nrPages; 1613 BOOL fBorland = 0; 1614 int cModules; 1615 char *pszModules; 1616 char *pszCurModule; 1617 char *pszTmp; 1618 ULONG *pulImport; 1619 ULONG ulCurFixup; 1620 int Size; 1621 Win32DllBase *WinDll; 1622 Win32ImageBase *WinImage = NULL; 1623 Section *section; 1624 1625 /* "algorithm:" 1626 * 1) get module names and store them 1627 * a) check dwRVAModuleName is within .idata seg - if not find section 1628 * 2) iterate thru functions of each module 1629 * a) check OriginalFirstThunk is not 0 and that it points to a RVA. 1630 * b) if not a) borland-styled PE-file - ARG!!! 1631 * check FirstThunk 1632 * c) check OriginalFirstThunk/FirstThunk ok RVAs and find right section 1633 * d) store ordinal/name import 1634 * 3) finished 1635 */ 1636 1637 /* 1) get module names */ 1638 pID = (PIMAGE_IMPORT_DESCRIPTOR)ImageDirectoryOffset(win32file, IMAGE_DIRECTORY_ENTRY_IMPORT); 1639 if (pID == NULL) 1630 1640 return TRUE; 1631 if (!GetSectionHdrByImageDir(win32file, IMAGE_DIRECTORY_ENTRY_IMPORT, &shID))1641 if (!GetSectionHdrByImageDir(win32file, IMAGE_DIRECTORY_ENTRY_IMPORT, &shID)) 1632 1642 return TRUE; 1633 1643 1634 //calc size of module list 1635 i = Size = cModules = 0; 1636 while (pID[i].Name != 0) 1637 { 1638 //test RVA inside ID-Section 1639 if (pID[i].Name >= shID.VirtualAddress && pID[i].Name < shID.VirtualAddress + max(shID.Misc.VirtualSize, shID.SizeOfRawData)) { 1640 pszTmp = (char*)(pID[i].Name + (ULONG)win32file); 1641 } 1642 else { 1643 //is the "Extra"-section already found or do we have to find it? 1644 if (pID[i].Name < shExtra.VirtualAddress || pID[i].Name >= shExtra.VirtualAddress + max(shExtra.Misc.VirtualSize, shExtra.SizeOfRawData)) { 1645 if (!GetSectionHdrByRVA(win32file, &shExtra, pID[i].Name)) 1646 return FALSE; 1647 } 1648 pszTmp = (char*)(pID[i].Name + (ULONG)win32file); 1649 } 1650 Size += strlen(pszTmp) + 1; 1651 i++; 1652 cModules++; 1653 } 1654 1655 pszModules = (char*)malloc(Size); 1656 assert(pszModules != NULL); 1657 j = 0; 1658 for (i = 0; i < cModules; i++) 1659 { 1660 //test RVA inside ID-Section 1661 if (pID[i].Name >= shID.VirtualAddress && pID[i].Name < shID.VirtualAddress + max(shID.Misc.VirtualSize, shID.SizeOfRawData)) { 1662 pszTmp = (char*)(pID[i].Name + (ULONG)win32file); 1663 } 1664 else { 1665 fBorland = TRUE; 1666 //is the "Extra"-section already found or do we have to find it? 1667 if (pID[i].Name < shExtra.VirtualAddress || pID[i].Name >= shExtra.VirtualAddress + max(shExtra.Misc.VirtualSize, shExtra.SizeOfRawData)) 1644 //calc size of module list 1645 i = Size = cModules = 0; 1646 while (pID[i].Name != 0) 1647 { 1648 //test RVA inside ID-Section 1649 if (pID[i].Name >= shID.VirtualAddress && pID[i].Name < shID.VirtualAddress + max(shID.Misc.VirtualSize, shID.SizeOfRawData)) { 1650 pszTmp = (char*)(pID[i].Name + (ULONG)win32file); 1651 } 1652 else { 1653 //is the "Extra"-section already found or do we have to find it? 1654 if (pID[i].Name < shExtra.VirtualAddress || pID[i].Name >= shExtra.VirtualAddress + max(shExtra.Misc.VirtualSize, shExtra.SizeOfRawData)) { 1655 if (!GetSectionHdrByRVA(win32file, &shExtra, pID[i].Name)) 1656 return FALSE; 1657 } 1658 pszTmp = (char*)(pID[i].Name + (ULONG)win32file); 1659 } 1660 Size += strlen(pszTmp) + 1; 1661 i++; 1662 cModules++; 1663 } 1664 1665 pszModules = (char*)alloca(Size); 1666 if(pszModules == NULL) { 1667 DebugInt3(); 1668 return FALSE; 1669 } 1670 j = 0; 1671 for (i = 0; i < cModules; i++) 1672 { 1673 //test RVA inside ID-Section 1674 if (pID[i].Name >= shID.VirtualAddress && pID[i].Name < shID.VirtualAddress + max(shID.Misc.VirtualSize, shID.SizeOfRawData)) { 1675 pszTmp = (char*)(pID[i].Name + (ULONG)win32file); 1676 } 1677 else { 1678 fBorland = TRUE; 1679 //is the "Extra"-section already found or do we have to find it? 1680 if (pID[i].Name < shExtra.VirtualAddress || pID[i].Name >= shExtra.VirtualAddress + max(shExtra.Misc.VirtualSize, shExtra.SizeOfRawData)) 1681 { 1682 if (GetSectionHdrByRVA(win32file, &shExtra, pID[i].Name)) { 1683 return FALSE; 1684 } 1685 } 1686 pszTmp = (char*)(pID[i].Name + (ULONG)win32file); 1687 } 1688 1689 int iTmpLength = strlen(pszTmp) + 1; 1690 memcpy(pszModules+j, pszTmp, iTmpLength); 1691 j += iTmpLength; 1692 } 1693 if (fBorland) 1694 dprintf((LOG, "Borland-styled PE-File." )); 1695 1696 //Store modules 1697 dprintf((LOG, "%d imported Modules: ", cModules )); 1698 1699 /* 2) functions */ 1700 pszCurModule = pszModules; 1701 pOH = (PIMAGE_OPTIONAL_HEADER)OPTHEADEROFF(win32file); 1702 for (i = 0; i < cModules; i++) 1703 { 1704 dprintf((LOG, "Module %s", pszCurModule )); 1705 if(pID[i].ForwarderChain) { 1706 dprintf((LOG, "ForwarderChain: %x", pID[i].ForwarderChain)); 1707 } 1708 // a) check that OriginalFirstThunk not is 0 and look for Borland-styled PE 1709 if (i == 0) 1668 1710 { 1669 if (GetSectionHdrByRVA(win32file, &shExtra, pID[i].Name)) { 1670 free(pszModules); 1671 return FALSE; 1672 } 1673 } 1674 pszTmp = (char*)(pID[i].Name + (ULONG)win32file); 1675 } 1676 1677 strcpy(pszModules+j, pszTmp); 1678 j += strlen(pszTmp) + 1; 1679 } 1680 if (fBorland) 1681 dprintf((LOG, "Borland-styled PE-File." )); 1682 1683 //Store modules 1684 dprintf((LOG, "%d imported Modules: ", cModules )); 1685 1686 /* 2) functions */ 1687 pszCurModule = pszModules; 1688 pOH = (PIMAGE_OPTIONAL_HEADER)OPTHEADEROFF(win32file); 1689 for (i = 0; i < cModules; i++) 1690 { 1691 dprintf((LOG, "Module %s", pszCurModule )); 1692 if(pID[i].ForwarderChain) { 1693 dprintf((LOG, "ForwarderChain: %x", pID[i].ForwarderChain)); 1694 } 1695 // a) check that OriginalFirstThunk not is 0 and look for Borland-styled PE 1696 if (i == 0) 1697 { 1698 //heavy borland-style test - assume array of thunks is within that style does not change 1699 if((ULONG)pID[i].u.OriginalFirstThunk == 0 || 1700 (ULONG)pID[i].u.OriginalFirstThunk < shID.VirtualAddress || 1701 (ULONG)pID[i].u.OriginalFirstThunk >= shID.VirtualAddress + max(shID.Misc.VirtualSize, shID.SizeOfRawData) || 1702 (ULONG)pID[i].u.OriginalFirstThunk >= pOH->DataDirectory[IMAGE_DIRECTORY_ENTRY_IMPORT].VirtualAddress && 1703 (ULONG)pID[i].u.OriginalFirstThunk < sizeof(*pID)*cModules + pOH->DataDirectory[IMAGE_DIRECTORY_ENTRY_IMPORT].VirtualAddress) 1711 //heavy borland-style test - assume array of thunks is within that style does not change 1712 if((ULONG)pID[i].u.OriginalFirstThunk == 0 || 1713 (ULONG)pID[i].u.OriginalFirstThunk < shID.VirtualAddress || 1714 (ULONG)pID[i].u.OriginalFirstThunk >= shID.VirtualAddress + max(shID.Misc.VirtualSize, shID.SizeOfRawData) || 1715 (ULONG)pID[i].u.OriginalFirstThunk >= pOH->DataDirectory[IMAGE_DIRECTORY_ENTRY_IMPORT].VirtualAddress && 1716 (ULONG)pID[i].u.OriginalFirstThunk < sizeof(*pID)*cModules + pOH->DataDirectory[IMAGE_DIRECTORY_ENTRY_IMPORT].VirtualAddress) 1717 { 1718 fBorland = TRUE; 1719 } 1720 } 1721 //light borland-style test 1722 if (pID[i].u.OriginalFirstThunk == 0 || fBorland) { 1723 pulImport = (ULONG*)pID[i].FirstThunk; 1724 } 1725 else pulImport = (ULONG*)pID[i].u.OriginalFirstThunk; 1726 1727 // b) check if RVA ok 1728 if (!(pulImport > 0 && (ULONG)pulImport < pOH->SizeOfImage)) { 1729 dprintf((LOG, "Invalid RVA %x", pulImport )); 1730 break; 1731 } 1732 // check section 1733 if ((ULONG)pulImport < shExtra.VirtualAddress || (ULONG)pulImport >= shExtra.VirtualAddress + max(shExtra.Misc.VirtualSize, shExtra.SizeOfRawData)) 1704 1734 { 1705 fBorland = TRUE; 1706 } 1707 } 1708 //light borland-style test 1709 if (pID[i].u.OriginalFirstThunk == 0 || fBorland) { 1710 pulImport = (ULONG*)pID[i].FirstThunk; 1711 } 1712 else pulImport = (ULONG*)pID[i].u.OriginalFirstThunk; 1713 1714 // b) check if RVA ok 1715 if (!(pulImport > 0 && (ULONG)pulImport < pOH->SizeOfImage)) { 1716 dprintf((LOG, "Invalid RVA %x", pulImport )); 1717 break; 1718 } 1719 // check section 1720 if ((ULONG)pulImport < shExtra.VirtualAddress || (ULONG)pulImport >= shExtra.VirtualAddress + max(shExtra.Misc.VirtualSize, shExtra.SizeOfRawData)) 1721 { 1722 if (!GetSectionHdrByRVA(win32file, &shExtra, (ULONG)pulImport)) 1723 { 1724 dprintf((LOG, "warning: could not find section for Thunk RVA %x", pulImport )); 1725 break; 1726 } 1727 } 1728 1729 //SvL: Load dll if needed 1730 dprintf((LOG, "**********************************************************************" )); 1731 dprintf((LOG, "************** Import Module %s ", pszCurModule )); 1732 dprintf((LOG, "**********************************************************************" )); 1733 WinDll = Win32DllBase::findModule(pszCurModule); 1734 1735 if(WinDll == NULL) 1736 { //not found, so load it 1737 if (WinExe != NULL && WinExe->matchModName(pszCurModule)) { 1738 WinImage = (Win32ImageBase *)WinExe; 1735 if (!GetSectionHdrByRVA(win32file, &shExtra, (ULONG)pulImport)) 1736 { 1737 dprintf((LOG, "warning: could not find section for Thunk RVA %x", pulImport )); 1738 break; 1739 } 1740 } 1741 1742 //Load dll if needed 1743 dprintf((LOG, "**********************************************************************" )); 1744 dprintf((LOG, "************** Import Module %s ", pszCurModule )); 1745 dprintf((LOG, "**********************************************************************" )); 1746 WinDll = Win32DllBase::findModule(pszCurModule); 1747 1748 if(WinDll == NULL) 1749 { //not found, so load it 1750 if (WinExe != NULL && WinExe->matchModName(pszCurModule)) { 1751 WinImage = (Win32ImageBase *)WinExe; 1752 } 1753 else { 1754 WinDll = loadDll(pszCurModule); 1755 if(WinDll == NULL) { 1756 return FALSE; 1757 } 1758 } 1739 1759 } 1740 1760 else { 1741 WinDll = loadDll(pszCurModule); 1742 if(WinDll == NULL) { 1743 return FALSE; 1744 } 1745 } 1746 } 1747 else { 1748 WinDll->AddRef(); 1749 dprintf((LOG, "Already found ", pszCurModule)); 1750 } 1751 if(WinDll != NULL) { 1752 //add the dll we just loaded to dependency list for this image 1753 addDependency(WinDll); 1754 1755 //Make sure the dependency list is correct (already done 1756 //in the ctor of Win32DllBase, but for LX dlls the parent is 1757 //then set to NULL; so change it here again 1758 WinDll->setUnloadOrder(this); 1759 WinImage = (Win32ImageBase *)WinDll; 1760 } 1761 else 1762 if(WinImage == NULL) { 1763 dprintf((LOG, "Unable to load dll %s", pszCurModule )); 1764 return FALSE; 1765 } 1766 1767 pulImport = (PULONG)((ULONG)pulImport + (ULONG)win32file); 1768 j = 0; 1769 ulCurFixup = (ULONG)pID[i].FirstThunk + (ULONG)win32file; 1770 1771 section = findSectionByOS2Addr(ulCurFixup); 1772 if(section == NULL) { 1773 dprintf((LOG, "Unable to find section for %x", ulCurFixup )); 1774 return FALSE; 1775 } 1776 //SvL: Read page from disk 1777 commitPage(ulCurFixup & ~0xfff, FALSE, SINGLE_PAGE); 1778 //SvL: Enable write access 1779 DosSetMem((PVOID)(ulCurFixup & ~0xfff), PAGE_SIZE, PAG_READ|PAG_WRITE); 1780 nrPages = 1; 1781 1782 while (pulImport[j] != 0) { 1783 if (pulImport[j] & IMAGE_ORDINAL_FLAG) { //ordinal 1784 dprintf((LOG, "0x%08x Imported function %s @%d", ulCurFixup , pszCurModule, (pulImport[j] & ~IMAGE_ORDINAL_FLAG) )); 1785 StoreImportByOrd(WinImage, pulImport[j] & ~IMAGE_ORDINAL_FLAG, ulCurFixup); 1786 } 1787 else { //name 1788 //check 1789 if (pulImport[j] < shExtra.VirtualAddress || pulImport[j] >= shExtra.VirtualAddress + max(shExtra.Misc.VirtualSize, shExtra.SizeOfRawData)) { 1790 if (!GetSectionHdrByRVA(win32file, &shExtra, pulImport[j])) 1761 WinDll->AddRef(); 1762 dprintf((LOG, "Already found ", pszCurModule)); 1763 } 1764 if(WinDll != NULL) { 1765 //add the dll we just loaded to dependency list for this image 1766 addDependency(WinDll); 1767 1768 //Make sure the dependency list is correct (already done 1769 //in the ctor of Win32DllBase, but for LX dlls the parent is 1770 //then set to NULL; so change it here again 1771 WinDll->setUnloadOrder(this); 1772 WinImage = (Win32ImageBase *)WinDll; 1773 } 1774 else 1775 if(WinImage == NULL) { 1776 dprintf((LOG, "Unable to load dll %s", pszCurModule )); 1777 return FALSE; 1778 } 1779 1780 pulImport = (PULONG)((ULONG)pulImport + (ULONG)win32file); 1781 j = 0; 1782 ulCurFixup = (ULONG)pID[i].FirstThunk + (ULONG)win32file; 1783 1784 section = findSectionByOS2Addr(ulCurFixup); 1785 if(section == NULL) { 1786 dprintf((LOG, "Unable to find section for %x", ulCurFixup )); 1787 return FALSE; 1788 } 1789 //Read page from disk 1790 commitPage(ulCurFixup & ~0xfff, FALSE, SINGLE_PAGE); 1791 //Enable write access 1792 DosSetMem((PVOID)(ulCurFixup & ~0xfff), PAGE_SIZE, PAG_READ|PAG_WRITE); 1793 nrPages = 1; 1794 1795 while (pulImport[j] != 0) { 1796 if (pulImport[j] & IMAGE_ORDINAL_FLAG) { //ordinal 1797 dprintf((LOG, "0x%08x Imported function %s @%d", ulCurFixup , pszCurModule, (pulImport[j] & ~IMAGE_ORDINAL_FLAG) )); 1798 StoreImportByOrd(WinImage, pulImport[j] & ~IMAGE_ORDINAL_FLAG, ulCurFixup); 1799 } 1800 else { //name 1801 //check 1802 if (pulImport[j] < shExtra.VirtualAddress || pulImport[j] >= shExtra.VirtualAddress + max(shExtra.Misc.VirtualSize, shExtra.SizeOfRawData)) 1791 1803 { 1792 dprintf((LOG, "warning: could not find section for Import Name RVA ", pulImport[j] ));1793 break;1794 }1795 }1796 //KSO - Aug 6 1998 1:15am:this eases comparing...1797 char *pszFunctionName = (char*)(pulImport[j] + (ULONG)win32file + 2);1798 dprintf((LOG, "0x%08x Imported function %s (0x%08x)", ulCurFixup, pszFunctionName, WinImage->getApi(pszFunctionName)));1799 StoreImportByName(WinImage, pszFunctionName, ulCurFixup);1800 }1801 ulCurFixup += sizeof(IMAGE_THUNK_DATA);1802 j++;1803 if((ulCurFixup & 0xfff) == 0) {1804 commitPage(ulCurFixup & ~0xfff, FALSE, SINGLE_PAGE);1805 DosSetMem((PVOID)(ulCurFixup & ~0xfff), PAGE_SIZE, PAG_READ|PAG_WRITE);1806 nrPages++;1807 }1808 }1809 //SvL: And restore original protection flags1810 ulCurFixup = (ULONG)pID[i].FirstThunk + pOH->ImageBase;1811 DosSetMem((PVOID)(ulCurFixup & ~0xfff), PAGE_SIZE*nrPages, section->pageflags);1812 1813 dprintf((LOG, "**********************************************************************" ));1814 dprintf((LOG, "************** End Import Module %s ", pszCurModule )); 1815 dprintf((LOG, "**********************************************************************" ));1816 1817 pszCurModule += strlen(pszCurModule) + 1;1818 }//for (i = 0; i < cModules; i++) 1819 1820 free(pszModules);1821 return TRUE;1804 if (!GetSectionHdrByRVA(win32file, &shExtra, pulImport[j])) 1805 { 1806 dprintf((LOG, "warning: could not find section for Import Name RVA ", pulImport[j] )); 1807 break; 1808 } 1809 } 1810 //KSO - Aug 6 1998 1:15am:this eases comparing... 1811 char *pszFunctionName = (char*)(pulImport[j] + (ULONG)win32file + 2); 1812 dprintf((LOG, "0x%08x Imported function %s (0x%08x)", ulCurFixup, pszFunctionName, WinImage->getApi(pszFunctionName))); 1813 StoreImportByName(WinImage, pszFunctionName, ulCurFixup); 1814 } 1815 ulCurFixup += sizeof(IMAGE_THUNK_DATA); 1816 j++; 1817 if((ulCurFixup & 0xfff) == 0) { 1818 commitPage(ulCurFixup & ~0xfff, FALSE, SINGLE_PAGE); 1819 DosSetMem((PVOID)(ulCurFixup & ~0xfff), PAGE_SIZE, PAG_READ|PAG_WRITE); 1820 nrPages++; 1821 } 1822 } 1823 //SvL: And restore original protection flags 1824 ulCurFixup = (ULONG)pID[i].FirstThunk + pOH->ImageBase; 1825 DosSetMem((PVOID)(ulCurFixup & ~0xfff), PAGE_SIZE*nrPages, section->pageflags); 1826 1827 dprintf((LOG, "**********************************************************************" )); 1828 dprintf((LOG, "************** End Import Module %s ", pszCurModule )); 1829 dprintf((LOG, "**********************************************************************" )); 1830 1831 pszCurModule += strlen(pszCurModule) + 1; 1832 }//for (i = 0; i < cModules; i++) 1833 return TRUE; 1822 1834 } 1823 1835 //****************************************************************************** … … 1898 1910 * with the linear search. 1899 1911 */ 1900 1912 1901 1913 // start in the middle of the tree 1902 1914 i = nrOrdExportsRegistered >> 1; 1903 1915 int iStep = i; 1904 1916 1905 1917 for(;;) 1906 1918 { 1907 1919 int iThisExport = curexport[i].ordinal; 1908 1920 1909 1921 iStep >>= 1; // next step will be narrower 1910 1922 … … 1960 1972 } 1961 1973 } 1962 1974 1963 1975 // not found yet. 1964 1976 break;
Note:
See TracChangeset
for help on using the changeset viewer.