Changeset 9191 for trunk/src


Ignore:
Timestamp:
Sep 2, 2002, 4:58:01 AM (23 years ago)
Author:
bird
Message:

Latest stuff.

Location:
trunk/src/win32k/kKrnlLib/tools/pmdfrexx
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/win32k/kKrnlLib/tools/pmdfrexx/pm.cmd

    r9189 r9191  
    3737    when (sCmd = 'pmsemdump') then
    3838        return pmsemDump(sArgs);
     39    when (sCmd = 'pmsemdumpall') then
     40        return PmsemDumpAll(sArgs);
    3941
    4042    /*
     
    199201
    200202/**
    201  * Check if any of the PM sems are taken or have bogus state.
     203 * Dump a number of pm/gre sems.
    202204 * @returns 0 on success. -1 on error.
    203205 */
     
    214216    if (sMem <> '') then
    215217    do
    216         /* loop thru them all listing the taken/bogus ones */
    217218        do i = 0 to cCount - 1
    218219            call pmsemDump1 memCopy(i * pmsemSize(), pmsemSize(), sMem);
     220        end
     221    end
     222    else
     223        say 'error: failed to read semaphore table.';
     224return -1;
     225
     226
     227/**
     228 * Dumps all PM/GRE sems
     229 * @returns 0 on success. -1 on error.
     230 */
     231PmsemDumpAll: procedure expose(sGlobals)
     232    /* read memory and do the dump */
     233    sMem = dfReadMem('pmsemaphores', 35 * pmsemSize())
     234    if (sMem <> '') then
     235    do
     236        do i = 0 to 34
     237            call pmsemDump1 memCopy(i * pmsemSize(), pmsemSize(), sMem),, i;
    219238        end
    220239    end
     
    317336wndStyle:           procedure expose(sGlobals); parse arg sMem;      return memDword(x2d('18'), sMem);
    318337wndId:              procedure expose(sGlobals); parse arg sMem;      return memDword(x2d('1c'), sMem);
     338wndReserved0:       procedure expose(sGlobals); parse arg sMem;      return memDword(x2d('20'), sMem);
     339wndReserved1:       procedure expose(sGlobals); parse arg sMem;      return memDword(x2d('24'), sMem);
    319340wndMsgQueue:        procedure expose(sGlobals); parse arg sMem;      return memDword(x2d('28'), sMem);
    320341wndHWND:            procedure expose(sGlobals); parse arg sMem;      return memDword(x2d('2c'), sMem);
     
    343364    say '       ulStyle:' d2x(wndStyle(sMem),8);
    344365    say '            id:' d2x(wndId(sMem),8);
     366    say '     Reserved0:' d2x(wndReserved0(sMem),8);
     367    say '     Reserved1:' d2x(wndReserved1(sMem),8);
    345368    say '   pmqMsgQueue:' d2x(wndMsgQueue(sMem),8);
    346369    say '          hwnd:' d2x(wndHWND(sMem),8);
     
    353376    say '   ppresParams:' d2x(wndPresParams(sMem),8);
    354377    say '     pwndFocus:' d2x(wndFocus(sMem),8);
    355     say '         ulWPS:' d2x(wndWPSULong(sMem),8);
     378    say '         ulWPS:' d2x(wndWPSULong(sMem),8) '('dfNear('%'d2x(wndWPSULong(sMem),8))')'
    356379    say '     pInstData:' d2x(wndInstData(sMem),8);
    357380    say '            ??:' d2x(memDword(x2d('54'), sMem),8);
     
    11131136    if (rc = 0 & asOut.0 > 0) then
    11141137    do
    1115         parse var asOut.1 .' 'sRet;
    1116         return strip(sRet);
     1138        if (pos('symbols found', asOut.1) <= 0) then
     1139        do
     1140            parse var asOut.1 .' 'sRet;
     1141            return strip(sRet);
     1142        end
    11171143    end
    11181144return '';
     
    12021228return -1;
    12031229
     1230
    12041231/**
    12051232 * Gets the blockId of a process from the dumpformatter.
     
    12141241    do
    12151242        /* *000b# blk fd436190 pmshell */
    1216         asOut.0 = strip(asOut.0);
    1217         parse var asOut.0 .' 'sState' 'sBlockId' 'sProcName
     1243        asOut.2 = strip(asOut.2);
     1244        parse var asOut.2 .' 'sState' 'sBlockId' 'sProcName
    12181245        sBlockId = strip(sBlockId)      /* needed??? */
    1219         if (strip(sBlockId) <> '') then
     1246        if (sBlockId <> '') then
    12201247            return sBlockId;
    12211248    end
    12221249return '0';
     1250
     1251
     1252/**
     1253 * Gets the PTDA of a process.
     1254 * @param   sSlot   Slot or special chars '*' and '#'.
     1255 * @return  Hex pointer to the PTDA.
     1256 */
     1257dfProcPTDA: procedure expose(sGlobals)
     1258parse arg iSlot
     1259    Address df 'CMD' 'asOut' '.p' iSlot;
     1260    if (rc = 0 & asOut.0 > 0) then
     1261    do
     1262        /*  0074  0033 0000 0033 0002 blk 0500 f88e6000 fe62d220 f9a0b7e8 1e9c 12 muglrqst
     1263         *  000a  0001 0000 0000 000a blk 081e f8812000 ffdba880 f99f7840 1e94 00 *jitdaem
     1264         * *000b# 001d 0001 001d 0001 blk 0500 f8814000 fe6270a0 f99f7b44 1e9c 01 pmshell
     1265         */
     1266        i = 2;
     1267        asOut.i = translate(left(asOut.i, 10), '  ', '#*') || substr(asOut.i, 11);
     1268        parse var asOut.i . . . . . . . hxTSD hxPTDA hxPCB . . .;
     1269        hxPTDA = strip(hxPTDA)      /* needed??? */
     1270        if (hxPTDA <> '') then
     1271            return hxPTDA;
     1272    end
     1273return '0';
     1274
    12231275
    12241276/**
  • trunk/src/win32k/kKrnlLib/tools/pmdfrexx/sem.cmd

    r9190 r9191  
    3939
    4040    /*
    41      * Windows Structures.
     41     * Sem32
    4242     */
    43     when (sCmd = 'wnddump') then
    44         return wndDump(sArgs);
    45 
    46     /*
    47      * Window handles.
    48      */
    49     when (sCmd = 'hwnd') then
    50         return hwnd2PWND(sArgs);
    51 
    52     /*
    53      * PM stuff
    54      */
    55     when (sCMD = 'pmstatus') then
    56         return PmStatus(sArgs);
     43    when (sCmd = 'sem32check') then
     44        return Sem32Check(sArgs);
     45
    5746
    5847    /*
     
    168157    /* lookup the index */
    169158    iIdx = hsemGetIndex(iHandle);
     159    ulSem = 0;
    170160    if (hsemIsPrivate(iHandle)) then
    171161    do  /* private sem lookup */
    172         ulSem = 0;
     162        ulPTDA = dfProcPTDA('#');
     163        if (dfReadDword('%'ulPTDA '+ (%ulPrTotUsed - %ptda_start)') > iIdx) then
     164            ulSem  = dfReadDword('%(dw(%'ulPTDA '+ (%pPrSemTbl - %ptda_start))+'d2x(iIdx*4)')');
     165        else
     166            say 'error-Hsem2psem: Invalid semaphore index. ('sHSEM')'
    173167    end
    174168    else
     
    192186    if (ulSem > 0) then
    193187    do
    194         Address df 'CMD' 'asOut' '.d sem32 %'||d2x(ulSem);
    195         do i = 1 to asOut.0; say asOut.i; end
     188        rc = sem32Dump1Ext(ulSem);
     189        return 0;
     190    end
     191return -1;
     192
     193
     194/**
     195 * Dumps a sem32 structure.
     196 * @param   ulAddr  Decimal address of the sem32 structure.
     197 */
     198sem32Dump1Ext: procedure expose(sGlobals)
     199parse arg ulAddr
     200
     201    Address df 'CMD' 'asOut' '.d sem32 %'||d2x(ulAddr);
     202
     203    do i = 1 to asOut.0;
     204        if (pos('ADDR:', translate(asOut.i)) > 0) then
     205        do
     206            sAddr = strip(substr(asOut.i, pos(':', asOut.i) + 1))
     207            if (x2d(sAddr) > 0) then
     208                asOut.i = asOut.i '('dfNear(sAddr)')';
     209        end
     210        if (pos(':', asOut.i) > 0) then
     211            say asOut.i;
    196212    end
    197213return 0;
     214
     215
     216/**
     217 * Reads a sem32 structure.
     218 * @param   ulAddr  Decimal address of the sem32 structure.
     219 */
     220sem32Read: procedure expose(sGlobals)
     221parse arg ulAddr
     222    sSem = '';
     223    Address df 'CMD' 'asOut' '.d sem32 %'||d2x(ulAddr);
     224    do i = 1 to asOut.0;
     225        asOut.i = strip(translate(asOut.i, '=', ': '||'0d0a'x));
     226        j = pos(' ', asOut.i);
     227        do while (j > 0)
     228            asOut.i = substr(asOut.i, 1, j-1) || substr(asOut.i, j+1);
     229            j = pos(' ', asOut.i);
     230        end
     231        if (pos('=', asOut.i) > 0) then
     232        do
     233            sSem = sSem||';'asOut.i;
     234        end
     235    end
     236    /*say 'dbg-sem32Read:' sSem;*/
     237return sSem;
     238
     239/* access methods */
     240sem32IsEvent:       procedure expose(sGlobals); parse arg sSem;     return pos('Event;', sSem) > 0;
     241sem32IsMutex:       procedure expose(sGlobals); parse arg sSem;     return pos('Mutex;', sSem) > 0;
     242sem32IsPrivate:     procedure expose(sGlobals); parse arg sSem;     return pos('Private', sSem) > 0;
     243sem32IsShared:      procedure expose(sGlobals); parse arg sSem;     return pos('Shared', sSem) > 0;
     244sem32Flags:         procedure expose(sGlobals); parse arg sSem;
     245i = pos('Flags', sSem); if (i > 0) then     return substr(sSem, pos('=', sSem, i)+1, 4);
     246return '';
     247sem32CreateAddr:    procedure expose(sGlobals); parse arg sSem;
     248i = pos('CreateAddr', sSem); if (i > 0) then     return substr(sSem, pos('=', sSem, i)+1, 4);
     249return '';
     250sem32CallerAddr:    procedure expose(sGlobals); parse arg sSem;
     251i = pos('CallerAddr', sSem); if (i > 0) then     return substr(sSem, pos('=', sSem, i)+1, 4);
     252return '';
     253sem32MuxQ:          procedure expose(sGlobals); parse arg sSem;
     254i = pos('pMuxQ', sSem); if (i > 0) then         return substr(sSem, pos('=', sSem, i)+1, 4);
     255return '';
     256sem32OpenCt:        procedure expose(sGlobals); parse arg sSem;
     257i = pos('OpenCount', sSem); if (i > 0) then     return substr(sSem, pos('=', sSem, i)+1, 4);
     258return '00';
     259
     260sem32mtxIsOwned:    procedure expose(sGlobals); parse arg sSem; return sem32mtxOwner(sSem) <> '0000';
     261sem32mtxOwner:      procedure expose(sGlobals); parse arg sSem;
     262i = pos('Owner', sSem);     if (i > 0) then     return substr(sSem, pos('=', sSem, i)+1, 4);
     263return '00';
     264sem32mtxRequestCt:  procedure expose(sGlobals); parse arg sSem;
     265i = pos('RequestCt', sSem); if (i > 0) then     return substr(sSem, pos('=', sSem, i)+1, 4);
     266return '00';
     267sem32mtxRequesterCt:procedure expose(sGlobals); parse arg sSem;
     268i = pos('RequesterCt', sSem);if (i > 0) then    return substr(sSem, pos('=', sSem, i)+1, 4);
     269return '00';
     270
     271sem32evtIsPosted:   procedure expose(sGlobals); parse arg sSem; return sem32Flags(sSem) = 'Posted';
     272sem32evtIsReset:    procedure expose(sGlobals); parse arg sSem; return sem32Flags(sSem) = 'Reset';
     273sem32evtPostCount:  procedure expose(sGlobals); parse arg sSem;
     274i = pos('PostCount', sSem); if (i > 0) then     return substr(sSem, pos('=', sSem, i)+1, 4);
     275return '';
     276
     277
     278/**
     279 * Display all the sems which this process is holding.
     280 * Only private sems are implemented currently.
     281 */
     282Sem32Check: procedure  expose(sGlobals)
     283    ulPTDA = dfProcPTDA('#');
     284
     285    cPr = dfReadDWord('%'ulPTDA '+ (ulPrTotUsed-ptda_start)');
     286    if (cPr > 0) then
     287    do
     288        sPrTabMem = dfReadMem('%(dw(%'ulPTDA '+(pPrSemTbl-ptda_start)))', cPr*4);
     289        if (sPrTabMem <> '') then
     290        do
     291            do i = 0 to cPr - 1
     292                if (i // 20 = 0) then
     293                    say 'info:' right(i-0,length(cPr)) 'of' cPr 'private sems processed...'
     294                ulSem = memDword(i*4, sPrTabMem);
     295                if (ulSem >= '10000'x) then
     296                do
     297                    sSem = sem32Read(ulSem);
     298                    if (sSem <> '') then
     299                    do
     300                        fOk = 1;
     301                        if (sem32IsMutex(sSem)) then
     302                        do /* mutex*/
     303                            if (sem32mtxIsOwned(sSem)) then
     304                                fOk = 0;
     305                        end
     306                        else if (sem32IsEvent(sSem)) then
     307                        do  /* event */
     308                            if (sem32evtIsReset(sSem)) then
     309                                fOk = 0;
     310                        end
     311                        else fOk = 0;
     312                        if (\fOk) then
     313                            call sem32Dump1Ext ulSem;
     314                    end
     315                end
     316            end
     317        end
     318        else
     319            say 'error-Sem32Check: failed to read private sem table.'
     320    end
     321
     322return 0;
     323
    198324
    199325
     
    321447 *          -1 on error.
    322448 */
    323 dfReadDWord: procedure expose(sGlobals)
     449dfReadDword: procedure expose(sGlobals)
    324450parse arg sAddr
    325451    sMem = dfReadMem(sAddr, 4);
     
    340466    if (rc = 0 & asOut.0 > 0) then
    341467    do
    342         parse var asOut.1 .' 'sRet;
    343         return strip(sRet);
     468        if (pos('symbols found', asOut.1) <= 0) then
     469        do
     470            parse var asOut.1 .' 'sRet;
     471            return strip(sRet);
     472        end
    344473    end
    345474return '';
     
    429558return -1;
    430559
     560
    431561/**
    432562 * Gets the blockId of a process from the dumpformatter.
     
    441571    do
    442572        /* *000b# blk fd436190 pmshell */
    443         asOut.0 = strip(asOut.0);
    444         parse var asOut.0 .' 'sState' 'sBlockId' 'sProcName
     573        asOut.2 = strip(asOut.2);
     574        parse var asOut.2 .' 'sState' 'sBlockId' 'sProcName
    445575        sBlockId = strip(sBlockId)      /* needed??? */
    446         if (strip(sBlockId) <> '') then
     576        if (sBlockId <> '') then
    447577            return sBlockId;
    448578    end
    449579return '0';
     580
     581
     582/**
     583 * Gets the PTDA of a process.
     584 * @param   sSlot   Slot or special chars '*' and '#'.
     585 * @return  Hex pointer to the PTDA.
     586 */
     587dfProcPTDA: procedure expose(sGlobals)
     588parse arg iSlot
     589    Address df 'CMD' 'asOut' '.p' iSlot;
     590    if (rc = 0 & asOut.0 > 0) then
     591    do
     592        /*  0074  0033 0000 0033 0002 blk 0500 f88e6000 fe62d220 f9a0b7e8 1e9c 12 muglrqst
     593         *  000a  0001 0000 0000 000a blk 081e f8812000 ffdba880 f99f7840 1e94 00 *jitdaem
     594         * *000b# 001d 0001 001d 0001 blk 0500 f8814000 fe6270a0 f99f7b44 1e9c 01 pmshell
     595         */
     596        i = 2;
     597        asOut.i = translate(left(asOut.i, 10), '  ', '#*') || substr(asOut.i, 11);
     598        parse var asOut.i . . . . . . . hxTSD hxPTDA hxPCB . . .;
     599        hxPTDA = strip(hxPTDA)      /* needed??? */
     600        if (hxPTDA <> '') then
     601            return hxPTDA;
     602    end
     603return '0';
     604
    450605
    451606/**
Note: See TracChangeset for help on using the changeset viewer.