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

Sources for V0.9.9, plus a couple of fixes.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/helpers/procstat.c

    r44 r57  
    8484 *
    8585 *@@added V0.9.3 (2000-05-05) [umoeller]
    86  */
    87 
    88 PQPROCSTAT16 prc16GetInfo(APIRET *parc)     // out: error, ptr can be NULL
     86 *@@changed V0.9.10 (2001-04-08) [umoeller]: this returned != NULL even though item was freed, fixed
     87 *@@changed V0.9.10 (2001-04-08) [umoeller]: now using DosAllocMem, raised bufsize, changed prototype
     88 */
     89
     90APIRET prc16GetInfo(PQPROCSTAT16 *ppps)     // out: error, ptr can be NULL
    8991{
    9092    APIRET arc = NO_ERROR;
    91     PQPROCSTAT16 pps = (PQPROCSTAT16)malloc(0x8000);
     93    PQPROCSTAT16 pps = NULL;
     94
     95    /* PQPROCSTAT16 pps = (PQPROCSTAT16)malloc(0x8000);
    9296    if (!pps)
    9397        arc = ERROR_NOT_ENOUGH_MEMORY;
    94     else
    95     {
    96         arc = DosQProcStatus(pps, 0x8000);
    97         if (arc != NO_ERROR)
    98             free(pps);
    99     }
    100 
    101     if (parc)
    102         *parc = arc;
    103 
    104     return (pps);
     98    else */
     99
     100    if (!ppps)
     101        return (ERROR_INVALID_PARAMETER);
     102
     103    // changed allocation V0.9.10 (2001-04-08) [umoeller]:
     104    // malloc didn't guarantee that the object did not
     105    // cross a 64K boundary, which could cause DosQProcStat
     106    // to fail...
     107    #define BUF_SIZE        0xFFFF          // raised from 0x8000
     108
     109    if (!(arc = DosAllocMem((VOID**)&pps,
     110                            BUF_SIZE,
     111                            PAG_READ | PAG_WRITE | PAG_COMMIT
     112                                | OBJ_TILE          // 16-bit compatible, ignored really
     113                           )))
     114    {
     115        if (arc = DosQProcStatus(pps, BUF_SIZE))
     116        {
     117            // error:
     118            DosFreeMem(pps);        // V0.9.10 (2001-04-08) [umoeller]
     119
     120            // and even worse, I forgot to set the return ptr
     121            // to NULL, so this was freed twice... I guess
     122            // this produced the crashes in WarpIN with the
     123            // KILLPROCESS attribute... V0.9.10 (2001-04-08) [umoeller]
     124            pps = NULL;
     125        }
     126    }
     127
     128    *ppps = pps;
     129
     130    return (arc);
    105131}
    106132
     
    110136 *
    111137 *@@added V0.9.3 (2000-05-05) [umoeller]
    112  */
    113 
    114 VOID prc16FreeInfo(PQPROCSTAT16 pInfo)
    115 {
    116     if (pInfo)
    117         free(pInfo);
     138 *@@changed V0.9.10 (2001-04-08) [umoeller]: now using DosFreeMem
     139 */
     140
     141APIRET prc16FreeInfo(PQPROCSTAT16 pInfo)
     142{
     143    if (!pInfo)
     144        return ERROR_INVALID_PARAMETER;
     145
     146    return DosFreeMem(pInfo);
    118147}
    119148
     
    476505 *@@added V0.9.1 (2000-02-12) [umoeller]
    477506 *@@changed V0.9.3 (2000-05-01) [umoeller]: now using DosAllocMem
     507 *@@changed V0.9.10 (2001-04-08) [umoeller]: fixed second QuerySysState param
    478508 */
    479509
    480510PQTOPLEVEL32 prc32GetInfo(APIRET *parc)     // out: error, ptr can be NULL
    481511{
    482     #define BUFSIZE 128000l
     512    #define BUFSIZE (256 * 1024) // 128000l
    483513    PCHAR pBuf = NULL; // (PCHAR)malloc(BUFSIZE);
    484514
     
    489519        if (pBuf)
    490520        {
    491             APIRET arc = DosQuerySysState(0x1f,
    492                                           0, 0, 0,
     521            APIRET arc = DosQuerySysState(QS32_SUPPORTED,
     522                                          QS32_SUPPORTED,       // this was missing
     523                                                                // V0.9.10 (2001-04-08) [umoeller]
     524                                          0, 0,
    493525                                          (PCHAR)pBuf,
    494526                                          BUFSIZE);
     
    528560{
    529561    PQPROCESS32 pProcThis = pInfo->pProcessData;
    530     while (pProcThis && pProcThis->rectype == 1)
     562    while (pProcThis && pProcThis->ulRecType == 1)
    531563    {
    532564        int i;
     
    561593    }
    562594
    563     if (pProcThis->rectype == 1)
     595    if (pProcThis->ulRecType == 1)
    564596        return (pProcThis);
    565597    else
     
    578610 */
    579611
    580 PQSEMA32 prc32FindSem16(PQTOPLEVEL32 pInfo,     // in: as returned by prc32GetInfo
     612PQS32SEM16 prc32FindSem16(PQTOPLEVEL32 pInfo,     // in: as returned by prc32GetInfo
    581613                          USHORT usSemID)       // in: as in QPROCESS32.pausSem16
    582614{
    583     PQSEM16STRUC32  pSemData = pInfo->pSem16Data;
    584     PQSEMA32        pSemThis = &pSemData->sema;
    585     ULONG           i = 0;
     615    PQS32SEM16HEAD      pSemHead = pInfo->pSem16Data;
     616    PQS32SEM16          // pSemThis = &pSemData->sema;
     617                        pSemThis = &pSemHead->Sem16Rec;
     618    ULONG               i = 0;
    586619
    587620    while (pSemThis)
    588621    {
    589         _Pmpf(("prc32FindSem16: found usIndex 0x%lX", pSemThis->usIndex));
    590         if (/* pSemThis->usIndex */ i == usSemID)
     622        if (i == usSemID)
    591623            return (pSemThis);
    592624
     
    610642 */
    611643
    612 PQSEM32STRUC32 prc32FindSem32(PQTOPLEVEL32 pInfo,     // in: as returned by prc32GetInfo
    613                               USHORT usSemID)         // in: as in QPROCESS32.pausSem16
     644PQS32SEM32 prc32FindSem32(PQTOPLEVEL32 pInfo,     // in: as returned by prc32GetInfo
     645                          USHORT usSemID)         // in: as in QPROCESS32.pausSem16
    614646{
    615647    // PQSEM32STRUC32  pSemThis = pInfo->pSem32Data;
     
    687719    PQFILEDATA32 pFile = pInfo->pFileData;
    688720    while (     (pFile)
    689              && (pFile->rectype == 8)  // this is necessary, we'll crash otherwise!!
     721             && (pFile->ulRecType == 8)  // this is necessary, we'll crash otherwise!!
    690722          )
    691723    {
    692             if (pFile->filedata->sfn == usFileID)
     724        ULONG ul;
     725        // for some reason, there is an array in the file struct,
     726        // so search the array for the SFN
     727        for (ul = 0;
     728             ul < pFile->ulCFiles;
     729             ul++)
     730        {
     731            if (pFile->paFiles[ul].usSFN == usFileID)
    693732                return (pFile);
     733        }
    694734
    695735        pFile = pFile->pNext;
Note: See TracChangeset for help on using the changeset viewer.