Changeset 124
- Timestamp:
- Dec 17, 2001, 12:21:18 AM (24 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/helpers/dosh.h
r123 r124 531 531 typedef struct _NEHEADER 532 532 { 533 CHAR achNE[2]; // 00: "NE" magic 534 BYTE bLinkerVersion; // 02: linker version 535 BYTE bLinkerRevision; // 03: linker revision 536 USHORT usEntryTblOfs; // 04: ofs from this to entrytable 537 USHORT usEntryTblLen; // 06: length of entrytable 538 ULONG ulChecksum; // 08: MS: reserved, OS/2: checksum 539 USHORT usFlags; // 0c: flags 533 CHAR achNE[2]; // 00: "NE" magic ne_magic 534 BYTE bLinkerVersion; // 02: linker version ne_ver 535 BYTE bLinkerRevision; // 03: linker revision ne_rev 536 USHORT usEntryTblOfs; // 04: ofs from this to entrytable ne_enttab 537 USHORT usEntryTblLen; // 06: length of entrytable ne_cbenttab 538 ULONG ulChecksum; // 08: MS: reserved, OS/2: checksum ne_crc 539 USHORT usFlags; // 0c: flags ne_flags 540 540 /* 541 541 #define NENOTP 0x8000 // Not a process == library 542 542 #define NENOTMPSAFE 0x4000 // Process is not multi-processor safe 543 // (Win3.1 SDK: "reserved") 543 544 #define NEIERR 0x2000 // Errors in image 544 545 #define NEBOUND 0x0800 // Bound Family/API 546 // (Win3.1 SDK: "first segment contains code 547 // that loads the application") 545 548 #define NEAPPTYP 0x0700 // Application type mask 549 // (Win3.1 SDK: "reserved") 546 550 #define NENOTWINCOMPAT 0x0100 // Not compatible with P.M. Windowing 551 // (Win3.1 SDK: "reserved") 547 552 #define NEWINCOMPAT 0x0200 // Compatible with P.M. Windowing 553 // (Win3.1 SDK: "reserved") 548 554 #define NEWINAPI 0x0300 // Uses P.M. Windowing API 555 // (Win3.1 SDK: "reserved") 549 556 #define NEFLTP 0x0080 // Floating-point instructions 550 557 #define NEI386 0x0040 // 386 instructions … … 552 559 #define NEI086 0x0010 // 8086 instructions 553 560 #define NEPROT 0x0008 // Runs in protected mode only 561 // (Win3.1 SDK: "reserved") 554 562 #define NEPPLI 0x0004 // Per-Process Library Initialization 563 // (Win3.1 SDK: "reserved") 555 564 #define NEINST 0x0002 // Instance data 556 565 #define NESOLO 0x0001 // Solo data (single data) 557 566 */ 558 USHORT usAutoDataSegNo; // 0e: auto-data seg no. 559 USHORT usInitlHeapSize; // 10: initl. heap size 560 USHORT usInitlStackSize; // 12: initl. stack size 561 ULONG ulCSIP; // 14: CS:IP 562 ULONG ulSSSP; // 18: SS:SP 563 USHORT usSegTblEntries; // 1c: segment tbl entry count 564 USHORT usModuleTblEntries; // 1e: module ref. table entry count 565 USHORT usNonResdTblLen; // 20: non-resd. name tbl length 566 USHORT usSegTblOfs; // 22: segment tbl ofs 567 USHORT usResTblOfs; // 24: resource tbl ofs 568 USHORT usResdNameTblOfs; // 26: resd. name tbl ofs 569 USHORT usModRefTblOfs; // 28: module ref. table ofs 570 USHORT usImportTblOfs; // 2a: import tbl ofs 571 ULONG ulNonResdTblOfs; // 2c: non-resd. name tbl ofs 572 USHORT usMoveableEntries; // 30: moveable entry pts. count 573 USHORT usLogicalSectShift; // 32: logcl. sector shift 574 USHORT usResSegmCount; // 34: resource segm. count 575 BYTE bTargetOS; // 36: target OS (NEOS_* flags) 576 BYTE bFlags2; // 37: addtl. flags 567 USHORT usAutoDataSegNo; // 0e: auto-data seg no. ne_autodata 568 // (Win3.1 SDK: "0 if both NEINST and NESOLO are cleared") 569 USHORT usInitlHeapSize; // 10: initl. heap size ne_heap 570 // (Win3.1 SDK: "0 if no local allocation") 571 USHORT usInitlStackSize; // 12: initl. stack size ne_stack 572 // (Win3.1 SDK: "0 if SS != DS") 573 ULONG ulCSIP; // 14: CS:IP ne_csip 574 ULONG ulSSSP; // 18: SS:SP ne_sssp 575 USHORT usSegTblEntries; // 1c: segment tbl entry count ne_cseg 576 USHORT usModuleTblEntries; // 1e: module ref. table entry count ne_cmod 577 USHORT usNonResdTblLen; // 20: non-resd. name tbl length ne_cbnrestab 578 USHORT usSegTblOfs; // 22: segment tbl ofs ne_segtab 579 // (from start of NEHEADER) 580 USHORT usResTblOfs; // 24: resource tbl ofs ne_rsrctab 581 // (from start of NEHEADER) 582 USHORT usResdNameTblOfs; // 26: resd. name tbl ofs ne_restab 583 // (from start of NEHEADER) 584 USHORT usModRefTblOfs; // 28: module ref. table ofs ne_modtab 585 // (from start of NEHEADER) 586 USHORT usImportTblOfs; // 2a: import name tbl ofs ne_imptab 587 // (from start of NEHEADER) 588 ULONG ulNonResdTblOfs; // 2c: non-resd. name tbl ofs ne_nrestab 589 // (from start of EXE!) 590 USHORT usMoveableEntries; // 30: moveable entry points count ne_cmovent 591 USHORT usLogicalSectShift; // 32: logcl. sector shift ne_align 592 // (Win3.1 SDK: "typically 4, but default is 9") 593 USHORT usResSegmCount; // 34: resource segm. count ne_cres 594 BYTE bTargetOS; // 36: target OS (NEOS_* flags) ne_exetyp 595 BYTE bFlags2; // 37: addtl. flags ne_flagsothers 596 // Win3.1 SDK: 597 // bit 1 --> Win2.x, but runs in Win3.x protected mode 598 // bit 2 --> Win2.x that supports prop. fonts 599 // bit 3 --> exec contains fastload area 600 /* 601 #define NELONGNAMES 0x01 602 #define NEWINISPROT 0x02 603 #define NEWINGETPROPFON 0x04 604 #define NEWLOAPPL 0x80 605 */ 606 // the following are not listed in newexe.h, but are documented for Win3.x 577 607 USHORT usFastLoadOfs; // 38: fast-load area ofs 578 608 USHORT usFastLoadLen; // 3a: fast-load area length … … 780 810 } LXITER, *PLXITER; 781 811 812 /* 813 *@@ OS2NERESTBLENTRY: 814 * OS/2 NE resource table entry. 815 * 816 *@@added V0.9.16 (2001-12-08) [umoeller] 817 */ 818 819 typedef struct _OS2NERESTBLENTRY 820 { 821 USHORT usType; 822 USHORT usID; 823 } OS2NERESTBLENTRY, *POS2NERESTBLENTRY; 824 825 /* 826 *@@ OS2NESEGMENT: 827 * OS/2 NE segment definition. 828 * 829 *@@added V0.9.16 (2001-12-08) [umoeller] 830 */ 831 832 typedef struct _OS2NESEGMENT // New .EXE segment table entry 833 { 834 unsigned short ns_sector; // File sector of start of segment 835 unsigned short ns_cbseg; // Number of bytes in file 836 unsigned short ns_flags; // Attribute flags 837 unsigned short ns_minalloc; // Minimum allocation in bytes 838 } OS2NESEGMENT, *POS2NESEGMENT; 839 782 840 #pragma pack() 783 841 … … 902 960 OBJECTPAGETABLEENTRY *pObjPageTbl; // pLXHeader->ulPageCount 903 961 962 // the following fields are set after doshLoadOS2NEMaps 963 BOOL fOS2NEMapsLoaded; 964 POS2NERESTBLENTRY paOS2NEResTblEntry; 965 POS2NESEGMENT paOS2NESegments; 966 904 967 #endif 905 968 } EXECUTABLE, *PEXECUTABLE; … … 970 1033 971 1034 VOID doshFreeLXMaps(PEXECUTABLE pExec); 1035 1036 APIRET doshLoadOS2NEMaps(PEXECUTABLE pExec); 1037 1038 VOID doshFreeNEMaps(PEXECUTABLE pExec); 972 1039 973 1040 APIRET doshExecClose(PEXECUTABLE *ppExec); -
trunk/src/helpers/dosh2.c
r123 r124 392 392 * -- ERROR_NOT_ENOUGH_MEMORY: malloc() failed. 393 393 * 394 * -- ERROR_INVALID_EXE_SIGNATURE: unknown 395 * executable type... the given file probably 396 * isn't even an executable. 394 * -- ERROR_INVALID_EXE_SIGNATURE (191): header is 395 * neither plain DOS, nor NE, nor LX, nor PE. 396 * The given file probably isn't even an 397 * executable. This you will get if you 398 * pass in COM, BAT, or CMD files. 399 * 400 * -- ERROR_BAD_EXE_FORMAT (193): header was 401 * recognized, but the header data was 402 * not understood. 397 403 * 398 404 * -- ERROR_INVALID_PARAMETER: ppExec is NULL. … … 419 425 * I am not sure whether PE supports such things 420 426 * as well... if so, it should be supported too. 427 * 428 * @@todo: 429 * 430 * win95 \WINDOWS\extract.exe is NE with a non-standard format 431 * win16 \WINDOWS\EXPAND.EXE 432 * win16 \WINDOWS\MSD.EXE" 421 433 * 422 434 *@@added V0.9.0 [umoeller] … … 428 440 *@@changed V0.9.16 (2001-12-08) [umoeller]: now using OPEN_SHARE_DENYWRITE 429 441 *@@changed V0.9.16 (2001-12-08) [umoeller]: fLibrary was never set, works for LX and NE now 442 *@@changed V0.9.16 (2001-12-08) [umoeller]: some speed optimizations, changed some return codes 430 443 */ 431 444 … … 496 509 // remove the DOS header info, since we have none 497 510 // V0.9.12 (2001-05-03) [umoeller] 498 free (pExec->pDosExeHeader); 499 pExec->pDosExeHeader = 0; 511 FREE(pExec->pDosExeHeader); 500 512 } 501 513 else … … 523 535 // was found) or pDosExeHeader->ulNewHeaderOfs 524 536 // V0.9.12 (2001-05-03) [umoeller] 525 CHAR achNewHeaderType[2] = "";526 537 ULONG cbRead; 527 528 cbRead = sizeof(achNewHeaderType); 529 if (!(arc = doshReadAt(hFile, 530 ulNewHeaderOfs, 531 FILE_BEGIN, 532 &cbRead, 533 achNewHeaderType))) 538 PBYTE pbHeader; 539 540 // now, we used to read in the first two chars 541 // to check out if we have PE or LX or NE and 542 // then read the header accordingly... but 543 // that wasn't terribly efficient. So load 544 // a chunk of data and then do a realloc() 545 // instead. 546 547 // take the largest of LXHEADER and NEHEADER and PEHEADER 548 cbRead = sizeof(LXHEADER); 549 if (sizeof(NEHEADER) > cbRead) 550 cbRead = sizeof(NEHEADER); 551 if (sizeof(PEHEADER) > cbRead) 552 cbRead = sizeof(PEHEADER); 553 554 if (!(pbHeader = malloc(cbRead))) 555 arc = ERROR_NOT_ENOUGH_MEMORY; 556 else if (!(arc = doshReadAt(hFile, 557 ulNewHeaderOfs, 558 FILE_BEGIN, 559 &cbRead, 560 pbHeader))) 534 561 { 535 562 PBYTE pbCheckOS = NULL; 536 563 537 // reset file ptr 538 /* DosSetFilePtr(hFile, 539 ulNewHeaderOfs, 540 FILE_BEGIN, 541 &ulLocal); 542 */ 564 PSZ achNewHeaderType = (PSZ)pbHeader; 543 565 544 566 if (!memcmp(achNewHeaderType, "NE", 2)) … … 546 568 // New Executable: 547 569 pExec->ulExeFormat = EXEFORMAT_NE; 548 // allocate NE header 549 if ( pExec->pNEHeader = (PNEHEADER)malloc(sizeof(NEHEADER)))570 571 if (cbRead < sizeof(NEHEADER)) 550 572 { 551 // read in NE header 552 pExec->cbNEHeader = sizeof(NEHEADER); 553 if (!(arc = doshReadAt(hFile, 554 ulNewHeaderOfs, 555 FILE_BEGIN, 556 &pExec->cbNEHeader, 557 (PBYTE)pExec->pNEHeader))) 558 { 559 if (pExec->cbNEHeader == sizeof(NEHEADER)) 560 { 561 pbCheckOS = &pExec->pNEHeader->bTargetOS; 562 // set library flag V0.9.16 (2001-12-08) [umoeller] 563 if (pExec->pNEHeader->usFlags & 0x8000) 564 // library: 565 pExec->fLibrary = TRUE; 566 } 567 else 568 // V0.9.16 (2001-12-08) [umoeller] 569 arc = ERROR_INVALID_EXE_SIGNATURE; 570 } 573 arc = ERROR_BAD_EXE_FORMAT; 574 FREE(pbHeader); 571 575 } 572 576 else 573 arc = ERROR_NOT_ENOUGH_MEMORY; 577 { 578 pExec->pNEHeader = (PNEHEADER)realloc(pbHeader, 579 sizeof(NEHEADER)); 580 pExec->cbNEHeader = sizeof(NEHEADER); 581 pbCheckOS = &pExec->pNEHeader->bTargetOS; 582 // set library flag V0.9.16 (2001-12-08) [umoeller] 583 if (pExec->pNEHeader->usFlags & 0x8000) 584 // library: 585 pExec->fLibrary = TRUE; 586 } 574 587 } 575 else if ( (memcmp(achNewHeaderType, "LX", 2) == 0)576 || (memcmp(achNewHeaderType, "LE", 2) == 0)588 else if ( (!memcmp(achNewHeaderType, "LX", 2)) 589 || (!memcmp(achNewHeaderType, "LE", 2)) 577 590 // this is used by SMARTDRV.EXE 578 591 ) … … 580 593 // OS/2 Linear Executable: 581 594 pExec->ulExeFormat = EXEFORMAT_LX; 582 // allocate LX header 583 if ( pExec->pLXHeader = (PLXHEADER)malloc(sizeof(LXHEADER)))595 596 if (cbRead < sizeof(LXHEADER)) 584 597 { 598 arc = ERROR_BAD_EXE_FORMAT; 599 FREE(pbHeader); 600 } 601 else 602 { 603 pExec->pLXHeader = (PLXHEADER)realloc(pbHeader, 604 sizeof(LXHEADER)); 585 605 // read in LX header 586 606 pExec->cbLXHeader = sizeof(LXHEADER); 587 if (!(arc = doshReadAt(hFile, 588 ulNewHeaderOfs, 589 FILE_BEGIN, 590 &pExec->cbLXHeader, 591 (PBYTE)pExec->pLXHeader))) 607 pbCheckOS = (PBYTE)(&pExec->pLXHeader->usTargetOS); 608 // set library flag V0.9.16 (2001-12-08) [umoeller] 609 if (pExec->pLXHeader->ulFlags & 0x8000) 610 // library: 611 pExec->fLibrary = TRUE; 612 } 613 } 614 else if (!memcmp(achNewHeaderType, "PE", 2)) 615 { 616 pExec->ulExeFormat = EXEFORMAT_PE; 617 618 if (cbRead < sizeof(PEHEADER)) 619 { 620 arc = ERROR_BAD_EXE_FORMAT; 621 FREE(pbHeader); 622 } 623 else 624 { 625 // PE has a standard header of 24 bytes 626 // plus an extended header, so check what 627 // we've got 628 ULONG cbPE = 24 629 + ((PPEHEADER)pbHeader)->usHeaderSize; 630 pExec->pPEHeader = (PPEHEADER)realloc(pbHeader, 631 cbPE); 632 633 pExec->cbPEHeader = cbPE; 634 pExec->ulOS = EXEOS_WIN32; 635 pExec->f32Bits = TRUE; 636 637 // we have the first 24 bytes already, so 638 // go for the next chunk 639 if (cbRead = pExec->pPEHeader->usHeaderSize) 592 640 { 593 if (pExec->cbLXHeader == sizeof(LXHEADER)) 641 if (!(arc = doshReadAt(hFile, 642 ulNewHeaderOfs + 24, 643 FILE_BEGIN, 644 &cbRead, 645 (PBYTE)pExec->pPEHeader + 24))) 594 646 { 595 pbCheckOS = (PBYTE)(&pExec->pLXHeader->usTargetOS);596 // set library flag V0.9.16 (2001-12-08) [umoeller]597 if (pExec->pLXHeader->ulFlags & 0x8000)598 // library:599 pExec->fLibrary = TRUE;600 647 } 601 648 else 602 // V0.9.16 (2001-12-08) [umoeller] 603 arc = ERROR_INVALID_EXE_SIGNATURE; 649 arc = ERROR_BAD_EXE_FORMAT; 604 650 } 605 }606 else607 arc = ERROR_NOT_ENOUGH_MEMORY;608 }609 else if (memcmp(achNewHeaderType, "PE", 2) == 0)610 {611 PEHEADER PEHeader = {0};612 613 pExec->ulExeFormat = EXEFORMAT_PE;614 pExec->ulOS = EXEOS_WIN32;615 pExec->f32Bits = TRUE;616 617 // V0.9.10 (2001-04-08) [lafaix]618 // read in standard PE header619 cbRead = 24;620 if (!(arc = doshReadAt(hFile,621 ulNewHeaderOfs,622 FILE_BEGIN,623 &cbRead,624 (PBYTE)&PEHeader)))625 {626 // allocate PE header627 if (pExec->pPEHeader = (PPEHEADER)malloc(24 + PEHeader.usHeaderSize))628 {629 // copy standard PE header630 memcpy(pExec->pPEHeader,631 &PEHeader,632 24);633 634 // read in optional PE header635 if (!(arc = DosRead(hFile,636 &pExec->pPEHeader->usReserved3,637 PEHeader.usHeaderSize,638 &pExec->cbPEHeader)))639 pExec->cbPEHeader += 24;640 }641 else642 arc = ERROR_NOT_ENOUGH_MEMORY;643 651 } 644 652 } … … 648 656 649 657 if (pbCheckOS) 658 { 650 659 // BYTE to check for operating system 651 660 // (NE and LX): … … 671 680 break; 672 681 } 673 } // end if (!(arc = DosSetFilePtr(hFile, 682 } 683 } 674 684 } 675 685 } // end if (!(arc = DosSetFilePtr(hFile, … … 1841 1851 { 1842 1852 // 32-bit OS/2 executable: 1843 if (cResources = pExec->pLXHeader->ulResTblCnt) 1853 PLXHEADER pLXHeader = pExec->pLXHeader; 1854 if (cResources = pLXHeader->ulResTblCnt) 1844 1855 { 1845 1856 #pragma pack(1) // V0.9.9 (2001-04-02) [umoeller] … … 1876 1887 1877 1888 ENSURE_SAFE(DosSetFilePtr(pExec->hfExe, 1878 p Exec->pLXHeader->ulResTblOfs1889 pLXHeader->ulResTblOfs 1879 1890 + ulNewHeaderOfs, // V0.9.12 (2001-05-03) [umoeller] 1880 1891 FILE_BEGIN, … … 1896 1907 for (i = 0; i < cResources; i++) 1897 1908 { 1898 ULONG ulOfsThis = p Exec->pLXHeader->ulObjTblOfs1909 ULONG ulOfsThis = pLXHeader->ulObjTblOfs 1899 1910 + ulNewHeaderOfs // V0.9.12 (2001-05-03) [umoeller] 1900 1911 + ( sizeof(ot) … … 1925 1936 else if (pExec->ulExeFormat == EXEFORMAT_NE) 1926 1937 { 1938 PNEHEADER pNEHeader = pExec->pNEHeader; 1939 1927 1940 if (pExec->ulOS == EXEOS_OS2) 1928 1941 { 1929 1942 // 16-bit OS/2 executable: 1930 cResources = p Exec->pNEHeader->usResSegmCount;1943 cResources = pNEHeader->usResSegmCount; 1931 1944 1932 1945 if (cResources) … … 1956 1969 1957 1970 ENSURE_SAFE(DosSetFilePtr(pExec->hfExe, 1958 p Exec->pNEHeader->usResTblOfs1971 pNEHeader->usResTblOfs 1959 1972 + ulNewHeaderOfs, // V0.9.12 (2001-05-03) [umoeller] 1960 1973 FILE_BEGIN, … … 1975 1988 ENSURE_SAFE(DosSetFilePtr(pExec->hfExe, 1976 1989 ulNewHeaderOfs // V0.9.12 (2001-05-03) [umoeller] 1977 + p Exec->pNEHeader->usSegTblOfs1990 + pNEHeader->usSegTblOfs 1978 1991 + (sizeof(ns) 1979 * ( p Exec->pNEHeader->usSegTblEntries1980 - p Exec->pNEHeader->usResSegmCount1992 * ( pNEHeader->usSegTblEntries 1993 - pNEHeader->usResSegmCount 1981 1994 + i)), 1982 1995 FILE_BEGIN, … … 2001 2014 2002 2015 ENSURE(DosSetFilePtr(pExec->hfExe, 2003 p Exec->pNEHeader->usResTblOfs2016 pNEHeader->usResTblOfs 2004 2017 + ulNewHeaderOfs, // V0.9.12 (2001-05-03) [umoeller] 2005 2018 FILE_BEGIN, … … 2055 2068 2056 2069 ENSURE_SAFE(DosSetFilePtr(pExec->hfExe, 2057 p Exec->pNEHeader->usResTblOfs2070 pNEHeader->usResTblOfs 2058 2071 + ulNewHeaderOfs, 2059 2072 FILE_BEGIN, … … 2208 2221 APIRET arc; 2209 2222 2223 PLXHEADER pLXHeader; 2224 2210 2225 if (!pExec) 2211 2226 arc = ERROR_INVALID_PARAMETER; 2212 else if (pExec->ulExeFormat != EXEFORMAT_LX)2213 arc = ERROR_INVALID_EXE_SIGNATURE;2214 2227 else if (pExec->fLXMapsLoaded) 2215 2228 // already loaded: 2216 2229 arc = NO_ERROR; 2230 else if ( (pExec->ulExeFormat != EXEFORMAT_LX) 2231 || (!(pLXHeader = pExec->pLXHeader)) 2232 ) 2233 arc = ERROR_INVALID_EXE_SIGNATURE; 2217 2234 else 2218 2235 { 2219 PLXHEADER pLXHeader = pExec->pLXHeader;2220 2236 ULONG ulNewHeaderOfs = 0; 2221 2237 ULONG cb; … … 2263 2279 (PBYTE)pExec->pObjPageTbl))) 2264 2280 ) 2265 ; 2281 { 2282 } 2266 2283 } 2267 2284 } … … 2290 2307 FREE(pExec->pObjPageTbl); 2291 2308 pExec->fLXMapsLoaded = FALSE; 2309 } 2310 2311 /* 2312 *@@ doshLoadOS2NEMaps: 2313 * 2314 * This works only if 2315 * 2316 * -- ulExeFormat == EXEFORMAT_NE and 2317 * 2318 * -- ulOS == EXEOS_OS2, 2319 * 2320 * but not with Win16 NE executables. 2321 * 2322 *@@added V0.9.16 (2001-12-08) [umoeller] 2323 */ 2324 2325 APIRET doshLoadOS2NEMaps(PEXECUTABLE pExec) 2326 { 2327 APIRET arc; 2328 2329 PNEHEADER pNEHeader; 2330 2331 if (!pExec) 2332 arc = ERROR_INVALID_PARAMETER; 2333 else if (pExec->fOS2NEMapsLoaded) 2334 // already loaded: 2335 arc = NO_ERROR; 2336 else if ( (pExec->ulExeFormat != EXEFORMAT_NE) 2337 || (pExec->ulOS != EXEOS_OS2) 2338 || (!(pNEHeader = pExec->pNEHeader)) 2339 ) 2340 arc = ERROR_INVALID_EXE_SIGNATURE; 2341 else 2342 { 2343 ULONG ulNewHeaderOfs = 0; 2344 ULONG cb; 2345 2346 if (pExec->pDosExeHeader) 2347 // executable has DOS stub: V0.9.12 (2001-05-03) [umoeller] 2348 ulNewHeaderOfs = pExec->pDosExeHeader->ulNewHeaderOfs; 2349 2350 // resource table 2351 if ( (!(arc = doshAllocArray(pNEHeader->usResSegmCount, 2352 sizeof(OS2NERESTBLENTRY), 2353 (PBYTE*)&pExec->paOS2NEResTblEntry, 2354 &cb))) 2355 && (!(arc = doshReadAt(pExec->hfExe, 2356 pNEHeader->usResTblOfs 2357 + ulNewHeaderOfs, 2358 FILE_BEGIN, 2359 &cb, 2360 (PBYTE)pExec->paOS2NEResTblEntry))) 2361 ) 2362 { 2363 // resource segments 2364 if ( (!(arc = doshAllocArray(pNEHeader->usResSegmCount, 2365 sizeof(OS2NESEGMENT), 2366 (PBYTE*)&pExec->paOS2NESegments, 2367 &cb))) 2368 && (!(arc = doshReadAt(pExec->hfExe, 2369 pNEHeader->usResTblOfs 2370 + ulNewHeaderOfs 2371 - cb, // pNEHeader->usResSegmCount * sizeof(struct new_seg) 2372 FILE_BEGIN, 2373 &cb, 2374 (PBYTE)pExec->paOS2NESegments))) 2375 ) 2376 { 2377 } 2378 } 2379 2380 if (!arc) 2381 pExec->fOS2NEMapsLoaded = TRUE; 2382 else 2383 doshFreeNEMaps(pExec); 2384 } 2385 2386 return (arc); 2387 } 2388 2389 /* 2390 *@@ doshFreeNEMaps: 2391 * 2392 *@@added V0.9.16 (2001-12-08) [umoeller] 2393 */ 2394 2395 VOID doshFreeNEMaps(PEXECUTABLE pExec) 2396 { 2397 FREE(pExec->paOS2NEResTblEntry); 2398 FREE(pExec->paOS2NESegments); 2399 pExec->fOS2NEMapsLoaded = FALSE; 2292 2400 } 2293 2401 … … 2337 2445 2338 2446 doshFreeLXMaps(pExec); 2447 doshFreeNEMaps(pExec); 2339 2448 2340 2449 // fixed the memory leaks with the missing fields,
Note:
See TracChangeset
for help on using the changeset viewer.