Changeset 59


Ignore:
Timestamp:
Apr 16, 2001, 9:29:52 PM (24 years ago)
Author:
umoeller
Message:

Various fixes for V0.9.10.

Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/helpers/dosh.h

    r56 r59  
    1313 */
    1414
    15 /*      This file Copyright (C) 1997-2000 Ulrich M”ller,
     15/*      This file Copyright (C) 1997-2001 Ulrich M”ller,
    1616 *                                        Dmitry A. Steklenev.
    1717 *      This file is part of the "XWorkplace helpers" source package.
     
    417417     *
    418418     *@@changed V0.9.7 (2000-12-20) [umoeller]: fixed NE offset
     419     *@@changed V0.9.9 (2001-04-06) [lafaix]: additional fields defined
    419420     */
    420421
     
    436437         USHORT usRelocTableOfs;        // 18: reloc table ofs.header (Win: >= 0x40)
    437438         USHORT usOverlayNo;            // 1a: overlay no.
    438          ULONG  ulLinkerVersion;        // 1c: linker version (if 0x18 > 0x28)
    439          ULONG  ulUnused1;              // 20: unused
    440          ULONG  ulUnused2;              // 24: exe.h says the following fields are
    441          ULONG  ulUnused3;              // 28:   'behavior bits'
    442          ULONG  ulUnused4;              // 3c:
     439         USHORT usLinkerVersion;        // 1c: linker version (if 0x18 > 0x28)
     440         USHORT usUnused1;              // 1e: unused
     441         USHORT usBehaviorBits;         // 20: exe.h says this field contains
     442                                        //     'behavior bits'
     443         USHORT usUnused2;              // 22: unused
     444         USHORT usOEMIdentifier;        // 24: OEM identifier
     445         USHORT usOEMInformation;       // 26: OEM information
     446         ULONG  ulUnused3;              // 28:
     447         ULONG  ulUnused4;              // 2c:
    443448         ULONG  ulUnused5;              // 30:
    444449         ULONG  ulUnused6;              // 34:
    445450         ULONG  ulUnused7;              // 38:
    446          ULONG  ulNewHeaderOfs;         // new header ofs (if 0x18 > 0x40)
     451         ULONG  ulNewHeaderOfs;         // 3c: new header ofs (if 0x18 > 0x40)
    447452                    // fixed this from USHORT, thanks Martin Lafaix
    448453                    // V0.9.7 (2000-12-20) [umoeller]
     
    461466     *      which comes after the DOS header in the
    462467     *      EXE file (at DOSEXEHEADER.ulNewHeaderOfs).
     468     *
     469     *@@changed V0.9.9 (2001-04-06) [lafaix]: fixed typo in usMoveableEntries
    463470     */
    464471
     
    486493        USHORT    usImportTblOfs;       // 2a: import tbl ofs
    487494        ULONG     ulNonResdTblOfs;      // 2c: non-resd. name tbl ofs
    488         USHORT    usMoveableEntires;    // 30: moveable entry pts. count
     495        USHORT    usMoveableEntries;    // 30: moveable entry pts. count
    489496        USHORT    usLogicalSectShift;   // 32: logcl. sector shift
    490497        USHORT    usResSegmCount;       // 34: resource segm. count
     
    502509     *      which comes after the DOS header in the
    503510     *      EXE file (at DOSEXEHEADER.ulNewHeaderOfs).
     511     *
     512     *@@changed V0.9.9 (2001-04-06) [lafaix]: fixed auto data object and ulinstanceDemdCnt
    504513     */
    505514
     
    549558        ULONG     ulNonResdNameTblLen;  // 8c: non-resdnt name tbl length
    550559        ULONG     ulNonResdNameTblCS;   // 90: non-res name tbl checksum
    551         ULONG     ulAutoDataSegObjCnt;  // 94: auto dataseg object count
     560        ULONG     ulAutoDataSegObj;     // 94: auto dataseg object
    552561        ULONG     ulDebugOfs;           // 98: debug info ofs
    553562        ULONG     ulDebugLen;           // 9c: debug info length
    554563        ULONG     ulInstancePrelCnt;    // a0: instance preload count
    555         ULONG     ulinstanceDemdCnt;    // a0: instance demand count
     564        ULONG     ulInstanceDemdCnt;    // a0: instance demand count
    556565        ULONG     ulHeapSize16;         // a8: heap size (16-bit)
    557566        ULONG     ulStackSize;          // ac: stack size
    558567    } LXHEADER, *PLXHEADER;
     568
     569    /*
     570     *@@ PEHEADER:
     571     *      portable executable (PE) header format,
     572     *      which comes after the DOS header in the
     573     *      EXE file (at DOSEXEHEADER.ulNewHeaderOfs).
     574     *
     575     *@@added V0.9.10 (2001-04-08) [lafaix]
     576     */
     577
     578    typedef struct _PEHEADER
     579    {
     580        // standard header
     581        ULONG     ulSignature;          // 00: 'P', 'E', 0, 0
     582        USHORT    usCPU;                // 04: CPU type
     583        USHORT    usObjCount;           // 06: number of object entries
     584        ULONG     ulTimeDateStamp;      // 08: store the time and date the
     585                                        //     file was created or modified
     586                                        //     by the linker
     587        ULONG     ulReserved1;          // 0c: reserved
     588        ULONG     ulReserved2;          // 10: reserved
     589        USHORT    usHeaderSize;         // 14: number of remaining bytes after
     590                                        //     usImageFlags
     591        USHORT    usImageFlags;         // 16: flags bits for the image
     592
     593        // optional header (always present in valid Win32 files)
     594        USHORT    usReserved3;          // 18: reserved
     595        USHORT    usLinkerMajor;        // 1a: linker major version number
     596        USHORT    usLinkerMinor;        // 1c: linker minor version number
     597        USHORT    usReserved4;          // 1e: reserved
     598        ULONG     ulReserved5;          // 20: reserved
     599        ULONG     ulReserved6;          // 24: reserved
     600        ULONG     ulEntryPointRVA;      // 28: entry point relative virtual address
     601        ULONG     ulReserved7;          // 2c: reserved
     602        ULONG     ulReserved8;          // 30: reserved
     603        ULONG     ulImageBase;          // 34:
     604        ULONG     ulObjectAlign;        // 38:
     605        ULONG     ulFileAlign;          // 3c:
     606        USHORT    usOSMajor;            // 40:
     607        USHORT    usOSMinor;            // 42:
     608        USHORT    usUserMajor;          // 44:
     609        USHORT    usUserMinor;          // 46:
     610        USHORT    usSubSystemMajor;     // 48:
     611        USHORT    usSubSystemMinor;     // 4a:
     612        ULONG     ulReserved9;          // 4c: reserved
     613        ULONG     ulImageSize;          // 50:
     614        ULONG     ulHeaderSize;         // 54:
     615        ULONG     ulFileChecksum;       // 58:
     616        USHORT    usSubSystem;          // 5c:
     617        USHORT    usDLLFlags;           // 5e:
     618        ULONG     ulStackReserveSize;   // 60:
     619        ULONG     ulStackCommitSize;    // 64:
     620        ULONG     ulHeapReserveSize;    // 68:
     621        ULONG     ulHeapCommitSize;     // 6c:
     622        ULONG     ulReserved10;         // 70: reserved
     623        ULONG     ulInterestingRVACount;// 74:
     624        ULONG     aulRVASize[1];        // 78: array of RVA/Size entries
     625    } PEHEADER, *PPEHEADER;
    559626
    560627    #pragma pack()
     
    651718        PLXHEADER           pLXHeader;
    652719        ULONG               cbLXHeader;
     720
     721        // Portable Executable (PE) header, if ulExeFormat == EXEFORMAT_PE
     722        PPEHEADER           pPEHeader;
     723        ULONG               cbPEHeader;
    653724
    654725        // module analysis (always set):
  • trunk/include/helpers/syssound.h

    r41 r59  
    7171                            PULONG pulVolume);
    7272
     73    VOID sndQueryMmpmIniPath(PSZ pszMMPM);
     74
    7375    HINI sndOpenMmpmIni(HAB hab);
    7476
  • trunk/src/helpers/dosh2.c

    r57 r59  
    810810 *@@changed V0.9.1 (2000-02-13) [umoeller]: fixed 32-bits flag
    811811 *@@changed V0.9.7 (2000-12-20) [lafaix]: fixed ulNewHeaderOfs
     812 *@@changed V0.9.10 (2001-04-08) [lafaix]: added PE support
    812813 *@@changed V0.9.10 (2001-04-08) [umoeller]: now setting ppExec only if NO_ERROR is returned
    813814 */
     
    945946                            else if (memcmp(achNewHeaderType, "PE", 2) == 0)
    946947                            {
     948                                PEHEADER PEHeader = {0};
     949
    947950                                pExec->ulExeFormat = EXEFORMAT_PE;
    948951                                pExec->ulOS = EXEOS_WIN32;
    949952                                pExec->f32Bits = TRUE;
    950953
    951                                 // can't parse this yet
     954                                // V0.9.10 (2001-04-08) [lafaix]
     955                                // read in standard PE header
     956                                if (!(arc = DosRead(hFile,
     957                                                    &PEHeader,
     958                                                    24,
     959                                                    &ulBytesRead)))
     960                                {
     961                                    // allocate PE header
     962                                    pExec->pPEHeader = (PPEHEADER)malloc(24 + PEHeader.usHeaderSize);
     963                                    if (!(pExec->pPEHeader))
     964                                        arc = ERROR_NOT_ENOUGH_MEMORY;
     965                                    else
     966                                    {
     967                                        // copy standard PE header
     968                                        memcpy(pExec->pPEHeader,
     969                                               &PEHeader,
     970                                               24);
     971
     972                                        // read in optional PE header
     973                                        if (!(arc = DosRead(hFile,
     974                                                            &(pExec->pPEHeader->usReserved3),
     975                                                            PEHeader.usHeaderSize,
     976                                                            &(pExec->cbPEHeader))))
     977                                            pExec->cbPEHeader += 24;
     978                                    }
     979                                }
    952980                            }
    953981                            else
     
    12431271 *@@changed V0.9.9 (2001-04-03) [umoeller]: added tons of error checking, changed prototype to return APIRET
    12441272 *@@changed V0.9.9 (2001-04-05) [lafaix]: rewritten error checking code
     1273 *@@changed V0.9.10 (2001-04-10) [lafaix]: added Win16 and Win386 support
     1274 *@@changed V0.9.10 (2001-04-13) [lafaix]: removed 127 characters limit
    12451275 */
    12461276
     
    12501280{
    12511281    if (    (pExec)
    1252          && (pExec->ulOS == EXEOS_OS2)
     1282         && (    (pExec->ulOS == EXEOS_OS2)
     1283              || (pExec->ulOS == EXEOS_WIN16)
     1284              || (pExec->ulOS == EXEOS_WIN386)
     1285            )
    12531286       )
    12541287    {
     
    12861319                    // reading the length of the module name
    12871320                    ENSURE_SAFE(DosRead(pExec->hfExe, &bLen, 1, &ulDummy));
    1288 
    1289                     // At most 127 bytes
    1290                     bLen &= 0x7F;
    12911321
    12921322                    // reading the module name
     
    13041334        else if (pExec->ulExeFormat == EXEFORMAT_NE)
    13051335        {
    1306             // 16-bit OS/2 executable:
     1336            // 16-bit executable:
    13071337            cModules = pExec->pNEHeader->usModuleTblEntries;
    13081338
     
    13451375
    13461376                    ENSURE_SAFE(DosRead(pExec->hfExe, &bLen, 1, &ulDummy));
    1347 
    1348                     bLen &= 0x7F;
    13491377
    13501378                    ENSURE_SAFE(DosRead(pExec->hfExe,
     
    16621690        ENSURE(DosRead(pExec->hfExe, &bType, 1, &ulDummy));
    16631691
    1664         for (i = 0; i < bCnt; i++)
     1692        if (bType)
    16651693        {
    1666             ENSURE(DosRead(pExec->hfExe,
    1667                            &bFlag,
    1668                            1,
    1669                            &ulDummy));
    1670 
    1671             if (bFlag & 0x01)
     1694            for (i = 0; i < bCnt; i++)
    16721695            {
    1673                 if (paFunctions)
     1696                ENSURE(DosRead(pExec->hfExe,
     1697                               &bFlag,
     1698                               1,
     1699                               &ulDummy));
     1700
     1701                if (bFlag & 0x01)
    16741702                {
    1675                     paFunctions[usCurrent].ulOrdinal = usOrdinal;
    1676                     paFunctions[usCurrent].ulType = 1; // 16-bit entry
    1677                     paFunctions[usCurrent].achFunctionName[0] = 0;
     1703                    if (paFunctions)
     1704                    {
     1705                        paFunctions[usCurrent].ulOrdinal = usOrdinal;
     1706                        paFunctions[usCurrent].ulType = 1; // 16-bit entry
     1707                        paFunctions[usCurrent].achFunctionName[0] = 0;
     1708                    }
     1709                    usCurrent++;
    16781710                }
    1679                 usCurrent++;
    1680             }
    1681 
    1682             usOrdinal++;
    1683 
    1684             if (bType == 0xFF)
    1685             {
    1686                 // moveable segment
    1687                 ENSURE(DosSetFilePtr(pExec->hfExe,
    1688                                      5,
    1689                                      FILE_CURRENT,
    1690                                      &ulDummy));
    1691             }
    1692             else
    1693             {
    1694                 // fixed segment
    1695                 ENSURE(DosSetFilePtr(pExec->hfExe,
    1696                                      2,
    1697                                      FILE_CURRENT,
    1698                                      &ulDummy));
    1699             }
    1700 
    1701         } // end for
     1711
     1712                usOrdinal++;
     1713
     1714                if (bType == 0xFF)
     1715                {
     1716                    // moveable segment
     1717                    ENSURE(DosSetFilePtr(pExec->hfExe,
     1718                                         5,
     1719                                         FILE_CURRENT,
     1720                                         &ulDummy));
     1721                }
     1722                else
     1723                {
     1724                    // fixed segment or constant (0xFE)
     1725                    ENSURE(DosSetFilePtr(pExec->hfExe,
     1726                                         2,
     1727                                         FILE_CURRENT,
     1728                                         &ulDummy));
     1729                }
     1730
     1731            } // end for
     1732        }
     1733        else
     1734            usOrdinal += bCnt;
    17021735    } // end while (TRUE)
    17031736
     
    18151848 *@@changed V0.9.9 (2001-04-03) [umoeller]: added tons of error checking, changed prototype to return APIRET
    18161849 *@@changed V0.9.9 (2001-04-05) [lafaix]: rewritten error checking code
     1850 *@@changed V0.9.10 (2001-04-10) [lafaix]: added Win16 and Win386 support
    18171851 */
    18181852
     
    18221856{
    18231857    if (    (pExec)
    1824          && (pExec->ulOS == EXEOS_OS2)
     1858         && (    (pExec->ulOS == EXEOS_OS2)
     1859              || (pExec->ulOS == EXEOS_WIN16)
     1860              || (pExec->ulOS == EXEOS_WIN386)
     1861            )
    18251862       )
    18261863    {
     
    18801917        else if (pExec->ulExeFormat == EXEFORMAT_NE)
    18811918        {
    1882             // It's a 16bit OS/2 executable
     1919            // it's a "new" segmented 16bit executable
    18831920
    18841921            // here too the number of exported entry points
     
    19802017 *@@added V0.9.7 (2000-12-18) [lafaix]
    19812018 *@@changed V0.9.9 (2001-04-03) [umoeller]: added tons of error checking, changed prototype to return APIRET
     2019 *@@changed V0.9.10 (2001-04-10) [lafaix]: added Win16 and Win386 support
    19822020 */
    19832021
     
    19872025{
    19882026    if (    (pExec)
    1989          && (pExec->ulOS == EXEOS_OS2)
     2027         && (    (pExec->ulOS == EXEOS_OS2)
     2028              || (pExec->ulOS == EXEOS_WIN16)
     2029              || (pExec->ulOS == EXEOS_WIN386)
     2030            )
    19902031       )
    19912032    {
     
    20822123        else if (pExec->ulExeFormat == EXEFORMAT_NE)
    20832124        {
    2084             // 16-bit OS/2 executable:
    2085             cResources = pExec->pNEHeader->usResSegmCount;
    2086 
    2087             if (cResources)
     2125            if (pExec->ulOS == EXEOS_OS2)
    20882126            {
    2089                 #pragma pack(1)     // V0.9.9 (2001-04-02) [umoeller]
    2090                 struct {unsigned short type; unsigned short name;} rti;
    2091                 struct new_seg                          /* New .EXE segment table entry */
     2127                // 16-bit OS/2 executable:
     2128                cResources = pExec->pNEHeader->usResSegmCount;
     2129
     2130                if (cResources)
    20922131                {
    2093                     unsigned short      ns_sector;      /* File sector of start of segment */
    2094                     unsigned short      ns_cbseg;       /* Number of bytes in file */
    2095                     unsigned short      ns_flags;       /* Attribute flags */
    2096                     unsigned short      ns_minalloc;    /* Minimum allocation in bytes */
    2097                 } ns;
    2098                 #pragma pack()
    2099 
    2100                 ULONG cb = sizeof(FSYSRESOURCE) * cResources;
    2101                 ULONG ulDummy;
    2102                 int i;
    2103 
    2104                 paResources = (PFSYSRESOURCE)malloc(cb);
    2105                 if (!paResources)
    2106                     ENSURE_FAIL(ERROR_NOT_ENOUGH_MEMORY);
    2107 
    2108                 memset(paResources, 0, cb);     // V0.9.9 (2001-04-03) [umoeller]
    2109 
    2110                 // we first read the resources IDs and types
    2111 
    2112                 ENSURE_SAFE(DosSetFilePtr(pExec->hfExe,
    2113                                           pExec->pNEHeader->usResTblOfs
    2114                                             + pExec->pDosExeHeader->ulNewHeaderOfs,
    2115                                           FILE_BEGIN,
    2116                                           &ulDummy));
    2117 
    2118                 for (i = 0; i < cResources; i++)
     2132                    #pragma pack(1)     // V0.9.9 (2001-04-02) [umoeller]
     2133                    struct {unsigned short type; unsigned short name;} rti;
     2134                    struct new_seg                          /* New .EXE segment table entry */
     2135                    {
     2136                        unsigned short      ns_sector;      /* File sector of start of segment */
     2137                        unsigned short      ns_cbseg;       /* Number of bytes in file */
     2138                        unsigned short      ns_flags;       /* Attribute flags */
     2139                        unsigned short      ns_minalloc;    /* Minimum allocation in bytes */
     2140                    } ns;
     2141                    #pragma pack()
     2142
     2143                    ULONG cb = sizeof(FSYSRESOURCE) * cResources;
     2144                    ULONG ulDummy;
     2145                    int i;
     2146
     2147                    paResources = (PFSYSRESOURCE)malloc(cb);
     2148                    if (!paResources)
     2149                        ENSURE_FAIL(ERROR_NOT_ENOUGH_MEMORY);
     2150
     2151                    memset(paResources, 0, cb);     // V0.9.9 (2001-04-03) [umoeller]
     2152
     2153                    // we first read the resources IDs and types
     2154
     2155                    ENSURE_SAFE(DosSetFilePtr(pExec->hfExe,
     2156                                              pExec->pNEHeader->usResTblOfs
     2157                                                + pExec->pDosExeHeader->ulNewHeaderOfs,
     2158                                              FILE_BEGIN,
     2159                                              &ulDummy));
     2160
     2161                    for (i = 0; i < cResources; i++)
     2162                    {
     2163                        ENSURE_SAFE(DosRead(pExec->hfExe, &rti, sizeof(rti), &ulDummy));
     2164
     2165                        paResources[i].ulID = rti.name;
     2166                        paResources[i].ulType = rti.type;
     2167                    }
     2168
     2169                    // we then read their sizes and flags
     2170
     2171                    for (i = 0; i < cResources; i++)
     2172                    {
     2173                        ENSURE_SAFE(DosSetFilePtr(pExec->hfExe,
     2174                                                  pExec->pDosExeHeader->ulNewHeaderOfs
     2175                                                    + pExec->pNEHeader->usSegTblOfs
     2176                                                    + (sizeof(ns)
     2177                                                    * (  pExec->pNEHeader->usSegTblEntries
     2178                                                       - pExec->pNEHeader->usResSegmCount
     2179                                                       + i)),
     2180                                                    FILE_BEGIN,
     2181                                                    &ulDummy));
     2182
     2183                        ENSURE_SAFE(DosRead(pExec->hfExe, &ns, sizeof(ns), &ulDummy));
     2184
     2185                        paResources[i].ulSize = ns.ns_cbseg;
     2186
     2187                        paResources[i].ulFlag  = (ns.ns_flags & OBJPRELOAD) ? RNPRELOAD : 0;
     2188                        paResources[i].ulFlag |= (ns.ns_flags & OBJSHARED) ? RNPURE : 0;
     2189                        paResources[i].ulFlag |= (ns.ns_flags & OBJDISCARD) ? RNMOVE : 0;
     2190                        paResources[i].ulFlag |= (ns.ns_flags & OBJDISCARD) ? 4096 : 0;
     2191                    }
     2192                } // end if (cResources)
     2193            }
     2194            else
     2195            {
     2196                // 16-bit Windows executable
     2197                USHORT usAlignShift;
     2198                ULONG  ulDummy;
     2199
     2200                ENSURE(DosSetFilePtr(pExec->hfExe,
     2201                                     pExec->pNEHeader->usResTblOfs
     2202                                       + pExec->pDosExeHeader->ulNewHeaderOfs,
     2203                                     FILE_BEGIN,
     2204                                     &ulDummy));
     2205
     2206                ENSURE(DosRead(pExec->hfExe,
     2207                               &usAlignShift,
     2208                               sizeof(usAlignShift),
     2209                               &ulDummy));
     2210
     2211                while (TRUE)
    21192212                {
    2120                     ENSURE_SAFE(DosRead(pExec->hfExe, &rti, sizeof(rti), &ulDummy));
    2121 
    2122                     paResources[i].ulID = rti.name;
    2123                     paResources[i].ulType = rti.type;
     2213                    USHORT usTypeID;
     2214                    USHORT usCount;
     2215
     2216                    ENSURE(DosRead(pExec->hfExe,
     2217                                   &usTypeID,
     2218                                   sizeof(usTypeID),
     2219                                   &ulDummy));
     2220
     2221                    if (usTypeID == 0)
     2222                        break;
     2223
     2224                    ENSURE(DosRead(pExec->hfExe,
     2225                                   &usCount,
     2226                                   sizeof(usCount),
     2227                                   &ulDummy));
     2228
     2229                    ENSURE(DosSetFilePtr(pExec->hfExe,
     2230                                         sizeof(ULONG),
     2231                                         FILE_CURRENT,
     2232                                         &ulDummy));
     2233
     2234                    cResources += usCount;
     2235
     2236                    // first pass, skip NAMEINFO table
     2237                    ENSURE(DosSetFilePtr(pExec->hfExe,
     2238                                         usCount*6*sizeof(USHORT),
     2239                                         FILE_CURRENT,
     2240                                         &ulDummy));
    21242241                }
    21252242
    2126                 // we then read their sizes and flags
    2127 
    2128                 for (i = 0; i < cResources; i++)
     2243                if (cResources)
    21292244                {
     2245                    USHORT usCurrent = 0;
     2246                    ULONG cb = sizeof(FSYSRESOURCE) * cResources;
     2247
     2248                    paResources = (PFSYSRESOURCE)malloc(cb);
     2249                    if (!paResources)
     2250                        ENSURE_FAIL(ERROR_NOT_ENOUGH_MEMORY);
     2251
     2252                    memset(paResources, 0, cb);
     2253
    21302254                    ENSURE_SAFE(DosSetFilePtr(pExec->hfExe,
    2131                                               pExec->pDosExeHeader->ulNewHeaderOfs
    2132                                                 + pExec->pNEHeader->usSegTblOfs
    2133                                                 + (sizeof(ns)
    2134                                                 * (  pExec->pNEHeader->usSegTblEntries
    2135                                                    - pExec->pNEHeader->usResSegmCount
    2136                                                    + i)),
    2137                                                 FILE_BEGIN,
     2255                                              pExec->pNEHeader->usResTblOfs
     2256                                                + pExec->pDosExeHeader->ulNewHeaderOfs,
     2257                                              FILE_BEGIN,
     2258                                              &ulDummy));
     2259
     2260                    ENSURE_SAFE(DosRead(pExec->hfExe,
     2261                                        &usAlignShift,
     2262                                        sizeof(usAlignShift),
     2263                                        &ulDummy));
     2264
     2265                    while (TRUE)
     2266                    {
     2267                        USHORT usTypeID;
     2268                        USHORT usCount;
     2269                        int i;
     2270
     2271                        ENSURE_SAFE(DosRead(pExec->hfExe,
     2272                                            &usTypeID,
     2273                                            sizeof(usTypeID),
     2274                                            &ulDummy));
     2275
     2276                        if (usTypeID == 0)
     2277                            break;
     2278
     2279                        ENSURE_SAFE(DosRead(pExec->hfExe,
     2280                                            &usCount,
     2281                                            sizeof(usCount),
     2282                                            &ulDummy));
     2283
     2284                        ENSURE_SAFE(DosSetFilePtr(pExec->hfExe,
     2285                                                  sizeof(ULONG),
     2286                                                  FILE_CURRENT,
     2287                                                  &ulDummy));
     2288
     2289                        // second pass, read NAMEINFO table
     2290                        for (i = 0; i < usCount; i++)
     2291                        {
     2292                            USHORT usLength,
     2293                                   usFlags,
     2294                                   usID;
     2295
     2296                            ENSURE_SAFE(DosSetFilePtr(pExec->hfExe,
     2297                                                      sizeof(USHORT),
     2298                                                      FILE_CURRENT,
     2299                                                      &ulDummy));
     2300
     2301                            ENSURE_SAFE(DosRead(pExec->hfExe,
     2302                                                &usLength,
     2303                                                sizeof(USHORT),
    21382304                                                &ulDummy));
    2139 
    2140                     ENSURE_SAFE(DosRead(pExec->hfExe, &ns, sizeof(ns), &ulDummy));
    2141 
    2142                     paResources[i].ulSize = ns.ns_cbseg;
    2143 
    2144                     paResources[i].ulFlag  = (ns.ns_flags & OBJPRELOAD) ? RNPRELOAD : 0;
    2145                     paResources[i].ulFlag |= (ns.ns_flags & OBJSHARED) ? RNPURE : 0;
    2146                     paResources[i].ulFlag |= (ns.ns_flags & OBJDISCARD) ? RNMOVE : 0;
    2147                     paResources[i].ulFlag |= (ns.ns_flags & OBJDISCARD) ? 4096 : 0;
     2305                            ENSURE_SAFE(DosRead(pExec->hfExe,
     2306                                                &usFlags,
     2307                                                sizeof(USHORT),
     2308                                                &ulDummy));
     2309                            ENSURE_SAFE(DosRead(pExec->hfExe,
     2310                                                &usID,
     2311                                                sizeof(USHORT),
     2312                                                &ulDummy));
     2313
     2314                            ENSURE_SAFE(DosSetFilePtr(pExec->hfExe,
     2315                                                      2*sizeof(USHORT),
     2316                                                      FILE_CURRENT,
     2317                                                      &ulDummy));
     2318
     2319                            // !!! strings ids and types not handled yet
     2320                            // !!! 15th bit is used to denotes strings
     2321                            // !!! offsets [lafaix]
     2322                            paResources[usCurrent].ulType = usTypeID ^ 0x8000;
     2323                            paResources[usCurrent].ulID = usID ^ 0x8000;
     2324                            paResources[usCurrent].ulSize = usLength << usAlignShift;
     2325                            paResources[usCurrent].ulFlag = usFlags & 0x70;
     2326
     2327                            usCurrent++;
     2328                        }
     2329                    }
    21482330                }
    2149             } // end if (cResources)
     2331            }
    21502332        } // end else if (pExec->ulExeFormat == EXEFORMAT_NE)
    21512333        else
  • trunk/src/helpers/procstat.c

    r57 r59  
    321321 *      system. If pfnwpCallback is NULL, only this number will be
    322322 *      returned, so you can use this as a process counter too.
     323 *
     324 *@@changed V0.9.10 (2001-04-16) [pr]: now using DosAllocMem
    323325 */
    324326
     
    326328{
    327329    ULONG ulrc = 0;
     330    PQPROCSTAT16 pps;
    328331    PQPROCESS16 pProcess;
    329332    PRCPROCESS prcp;
    330     PQPROCSTAT16 pps = (PQPROCSTAT16)malloc(0x8000);
    331     DosQProcStatus(pps, 0x8000);
    332 
    333     for ( pProcess = (PQPROCESS16)PTR(pps->ulProcesses, 0);
    334           pProcess->ulType != 3;
    335           pProcess = (PQPROCESS16)PTR(pProcess->ulThreadList,
    336                      pProcess->usThreads * sizeof(QTHREAD16))
    337         )
    338     {
    339         if (pfnwpCallback)
    340         {
    341             prcReport16(pProcess, &prcp);
    342             (*pfnwpCallback)(hwnd, ulMsg, mp1, &prcp);
    343         }
    344         ulrc++;
    345     }
    346 
    347     free(pps);
     333
     334    if (!DosAllocMem((PVOID*)&pps,
     335                     BUF_SIZE,
     336                     PAG_READ | PAG_WRITE | PAG_COMMIT | OBJ_TILE))
     337    {
     338        if (!DosQProcStatus(pps, BUF_SIZE))
     339            for ( pProcess = (PQPROCESS16)PTR(pps->ulProcesses, 0);
     340                  pProcess->ulType != 3;
     341                  pProcess = (PQPROCESS16)PTR(pProcess->ulThreadList,
     342                             pProcess->usThreads * sizeof(QTHREAD16))
     343                )
     344            {
     345                if (pfnwpCallback)
     346                {
     347                    prcReport16(pProcess, &prcp);
     348                    (*pfnwpCallback)(hwnd, ulMsg, mp1, &prcp);
     349                }
     350                ulrc++;
     351            }
     352
     353        DosFreeMem(pps);
     354    }
     355
    348356    return (ulrc);
    349357}
     
    542550 *
    543551 *@@added V0.9.1 (2000-02-12) [umoeller]
    544  *@@changed V0.9.3 (2000-05-01) [umoeller]: now using DosAllocMem
     552 *@@changed V0.9.3 (2000-05-01) [umoeller]: now using DosFreeMem
    545553 */
    546554
    547555VOID prc32FreeInfo(PQTOPLEVEL32 pInfo)
    548556{
    549     DosFreeMem(pInfo);;
     557    DosFreeMem(pInfo);
    550558}
    551559
  • trunk/src/helpers/syssound.c

    r21 r59  
    164164
    165165/*
     166 *@@ sndQueryMmpmIniPath:
     167 *      writes the full path of MMPM.INI into
     168 *      the specified buffer (e.g. C:\MMOS2\MMPM.INI).
     169 *
     170 *@@added V0.9.10 (2001-04-16) [umoeller]
     171 */
     172
     173VOID sndQueryMmpmIniPath(PSZ pszMMPM)       // out: fully q'fied MMPM.INI
     174{
     175    PSZ     pszMMPMPath = getenv("MMBASE"); // V0.9.6 (2000-10-16) [umoeller]
     176    if (pszMMPMPath)
     177    {
     178        // variable set:
     179        PSZ p;
     180
     181        strcpy(pszMMPM, pszMMPMPath); // V0.9.7 (2000-12-17) [umoeller]
     182
     183        // kill semicolon if present
     184        p = strchr(pszMMPM, ';');
     185        if (p)
     186           *p = 0;
     187
     188        strcat(pszMMPM, "\\MMPM.INI");
     189    }
     190    else
     191        // variable not set (shouldn't happen): try boot drive
     192        sprintf(pszMMPM, "%c:\\MMOS2\\MMPM.INI", doshQueryBootDrive());
     193}
     194
     195/*
    166196 *@@ sndOpenMmpmIni:
    167197 *      this opens \MMOS2\MMPM.INI on the
     
    183213    HINI    hini = NULLHANDLE;
    184214
    185     PSZ     pszMMPMPath = getenv("MMBASE"); // V0.9.6 (2000-10-16) [umoeller]
    186     if (pszMMPMPath)
    187     {
    188         // variable set:
    189         PSZ p;
    190 
    191         strcpy(szMMPM, pszMMPMPath); // V0.9.7 (2000-12-17) [umoeller]
    192 
    193         // kill semicolon if present
    194         p = strchr(szMMPM, ';');
    195         if (p)
    196            *p = 0;
    197 
    198         strcat(szMMPM, "\\MMPM.INI");
    199     }
    200     else
    201         // variable not set (shouldn't happen): try boot drive
    202         sprintf(szMMPM, "%c:\\MMOS2\\MMPM.INI", doshQueryBootDrive());
     215    sndQueryMmpmIniPath(szMMPM);
     216
    203217    hini = PrfOpenProfile(habDesktop, szMMPM);
    204218    return (hini);
  • trunk/src/helpers/winh.c

    r48 r59  
    38913891 *      user that all windows have been closed (which in fact might
    38923892 *      not be the case).
     3893 *
    38933894 *      This window's background color is set to the Desktop's
    38943895 *      (PM's one, not the WPS's one).
     3896 *
    38953897 *      Returns the HWND of this window.
    38963898 */
Note: See TracChangeset for help on using the changeset viewer.