- Timestamp:
- Sep 1, 2002, 4:28:46 PM (23 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/win32k/kKrnlLib/tools/pmdfrexx/pm.cmd
r9182 r9187 12 12 * Globals 13 13 */ 14 sGlobals = ''; 14 sGlobals = 'ulHandleTable sGlobals'; 15 ulHandleTable = 0; 16 17 18 /* 19 * Args 20 */ 21 parse arg sCmd sArgs 22 sCmd = lowercase(sCmd); 23 sArg = lowercase(sArgs); 24 say ''; 15 25 16 26 /* 17 27 * Operation 18 28 */ 19 parse arg sCmd sArgs20 21 29 select 22 when (sCmd = 'checksems') then 30 /* 31 * pmsems 32 */ 33 when (sCmd = 'pmsemcheck') then 23 34 return pmsemCheck(sArgs); 24 /* 25 when (sCmd = '') then 26 return 27 */ 35 when (sCmd = 'pmsemdump') then 36 return pmsemDump(sArgs); 37 38 /* 39 * Windows Structures. 40 */ 41 when (sCmd = 'wnddump') then 42 return wndDump(sArgs); 43 44 /* 45 * Window handles. 46 */ 47 when (sCmd = 'hwnd') then 48 return hwnd2PWND(sArgs); 49 50 /* 51 * Generic dump 52 */ 53 when (sCmd = 'dump' | sCmd = '.d') then 54 do 55 parse var sArgs sStruct sDumperArgs 56 select 57 when (sStruct = 'mq') then 58 return MqDump(sDumperArgs); 59 when (sStruct = 'wnd') then 60 return WndDump(sDumperArgs); 61 when (sStruct = 'pmsem') then 62 return pmsemDump(sDumperArgs); 63 64 otherwise 65 say 'syntax error: no or invalid structure name.'; 66 return syntax(sArgs); 67 end 68 end 69 70 71 /* 72 * Help and syntax error. 73 */ 28 74 when (sCmd = '?' | sCmd = 'help' | sCmd = '-?' | sCmd = '/?' | sCmd = '-h' | sCmd = '/h' | sCmd = '--help') then 29 75 return syntax(sArgs); … … 46 92 return -1; 47 93 48 49 50 /** 51 * Check if any of the PM sems are taken or have bogus state. 52 * @returns 0 on success. -1 on error. 53 */ 54 pmsemCheck: procedure 55 sMem = dfReadMem('pmsemaphores', 35*8*4) 56 if (sMem <> '') then 57 do 58 /* loop thru them all listing the taken/bogus ones */ 59 cDumps = 0; 60 say 'info: checking pm/gre sems' 61 do iSem = 0 to 34 62 rc = pmsemValidate(iSem, sMem); 63 if (rc <> 1) then 64 do 65 if (cDumps = 0) then say ''; 66 cDumps = cDumps + 1; 67 if rc = 0 then sMsg = 'Taken'; 68 else sMsg = 'Bogus'; 69 call pmsemDump memCopy(iSem * 32, 32, sMem), sMsg, iSem; 70 end 71 end 72 if (cDumps = 0) then 73 say 'info: pm/gre sems are all free and ok.' 74 else 75 say 'info: 'cDumps 'semaphores was taken or bogus.'; 76 end 77 else 78 say 'error: failed to read semaphore table.'; 79 return -1; 80 94 /* Procedure which we signals on user syntax errors. */ 95 synatxerror: 96 say 'syntax error!' 97 call syntax; 98 return -1; 99 100 101 102 /* 103 * PMSEMS/GRESEMS 104 * PMSEMS/GRESEMS 105 * PMSEMS/GRESEMS 106 * PMSEMS/GRESEMS 107 * PMSEMS/GRESEMS 108 * PMSEMS/GRESEMS 109 * PMSEMS/GRESEMS 110 * PMSEMS/GRESEMS 111 * PMSEMS/GRESEMS 112 */ 81 113 /* access functions */ 82 pmsemIdent: procedure; parse arg iSem, sMem; return memString(iSem * 32,7,1, sMem); 83 pmsem386: procedure; parse arg iSem, sMem; return memByte( iSem * 32 + 7, sMem); 84 pmsemTid: procedure; parse arg iSem, sMem; return memWord( iSem * 32 + 8, sMem); 85 pmsemPid: procedure; parse arg iSem, sMem; return memWord( iSem * 32 + 10, sMem); 86 pmsemPTid: procedure; parse arg iSem, sMem; return memDWord(iSem * 32 + 8, sMem); 87 pmsemNested: procedure; parse arg iSem, sMem; return memDword(iSem * 32 + 12, sMem); 88 pmsemWaiting: procedure; parse arg iSem, sMem; return memDword(iSem * 32 + 16, sMem); 89 pmsemUseCount:procedure; parse arg iSem, sMem; return memDword(iSem * 32 + 20, sMem);/*debug*/ 90 pmsemHEV: procedure; parse arg iSem, sMem; return memDword(iSem * 32 + 24, sMem); 91 pmsemCallAddr:procedure; parse arg iSem, sMem; return memDword(iSem * 32 + 28, sMem);/*debug*/ 114 pmsemSize: procedure expose(sGlobals); return 32; 115 pmsemIdent: procedure expose(sGlobals); parse arg iSem, sMem; return memString(iSem * 32, 7, 1, sMem); 116 pmsem386: procedure expose(sGlobals); parse arg iSem, sMem; return memByte( iSem * 32 + 7, sMem); 117 pmsemPid: procedure expose(sGlobals); parse arg iSem, sMem; return memWord( iSem * 32 + 8, sMem); 118 pmsemTid: procedure expose(sGlobals); parse arg iSem, sMem; return memWord( iSem * 32 + 10, sMem); 119 pmsemPTid: procedure expose(sGlobals); parse arg iSem, sMem; return memDWord(iSem * 32 + 8, sMem); 120 pmsemNested: procedure expose(sGlobals); parse arg iSem, sMem; return memDword(iSem * 32 + 12, sMem); 121 pmsemWaiting: procedure expose(sGlobals); parse arg iSem, sMem; return memDword(iSem * 32 + 16, sMem); 122 pmsemUseCount: procedure expose(sGlobals); parse arg iSem, sMem; return memDword(iSem * 32 + 20, sMem);/*debug*/ 123 pmsemHEV: procedure expose(sGlobals); parse arg iSem, sMem; return memDword(iSem * 32 + 24, sMem); 124 pmsemCallAddr: procedure expose(sGlobals); parse arg iSem, sMem; return memDword(iSem * 32 + 28, sMem);/*debug*/ 92 125 93 126 … … 98 131 * @param iSem The sem we're dumping. (optional) 99 132 */ 100 pmsemDump : procedure;133 pmsemDump1: procedure expose(sGlobals) 101 134 parse arg sSemMem, sMsg, iSem 102 135 if (iSem <> '') then … … 116 149 117 150 151 152 153 154 /** 155 * Check if any of the PM sems are taken or have bogus state. 156 * @returns 0 on success. -1 on error. 157 */ 158 PmsemCheck: procedure expose(sGlobals) 159 sMem = dfReadMem('pmsemaphores', 35 * pmsemSize()) 160 if (sMem <> '') then 161 do 162 /* loop thru them all listing the taken/bogus ones */ 163 cDumps = 0; 164 say 'info: checking pm/gre sems' 165 do iSem = 0 to 34 166 rc = pmsemValidate(iSem, sMem); 167 if (rc <> 1) then 168 do 169 if (cDumps = 0) then say ''; 170 cDumps = cDumps + 1; 171 if rc = 0 then sMsg = 'Taken'; 172 else sMsg = 'Bogus'; 173 call pmsemDump1 memCopy(iSem * pmsemSize(), pmsemSize(), sMem), sMsg, iSem; 174 end 175 end 176 if (cDumps = 0) then 177 say 'info: pm/gre sems are all free and ok.' 178 else 179 say 'info: 'cDumps 'semaphores was taken or bogus.'; 180 end 181 else 182 say 'error: failed to read semaphore table.'; 183 return -1; 184 185 186 /** 187 * Check if any of the PM sems are taken or have bogus state. 188 * @returns 0 on success. -1 on error. 189 */ 190 PmsemDump: procedure expose(sGlobals) 191 parse arg sAddr cCount 192 /* defaults and param validation */ 193 if (cCount = '' | datatype(cCount) <> 'NUM') then 194 cCount = 1; 195 if (sAddr = '') then 196 signal SyntaxError 197 198 /* read memory and do the dump */ 199 sMem = dfReadMem(sAddr, cCount * pmsemSize()) 200 if (sMem <> '') then 201 do 202 /* loop thru them all listing the taken/bogus ones */ 203 do i = 0 to cCount - 1 204 call pmsemDump1 memCopy(i * pmsemSize(), pmsemSize(), sMem); 205 end 206 end 207 else 208 say 'error: failed to read semaphore table.'; 209 return -1; 210 211 118 212 /** 119 213 * Checks a give PM sem is free and not bogus. … … 125 219 * (If no array use iSem=0) 126 220 */ 127 pmsemValidate: procedure 221 pmsemValidate: procedure expose(sGlobals) 128 222 parse arg iSem, sMem 129 223 if (pmsemPTid(iSem, sMem) <> 0) then … … 138 232 139 233 140 141 234 /** 142 235 * Gives us the name of the pmsem at a given index. … … 144 237 * @param i Index 145 238 */ 146 pmsemGetName: procedure ;239 pmsemGetName: procedure expose(sGlobals) 147 240 parse arg i 148 241 select … … 186 279 return 'Unknown-'i; 187 280 281 282 188 283 /* 189 * COMMON 190 * COMMON 191 * COMMON 192 * COMMON 193 * COMMON 194 * COMMON 284 * WINDOW STRUCTURE (WND) 285 * WINDOW STRUCTURE (WND) 286 * WINDOW STRUCTURE (WND) 287 * WINDOW STRUCTURE (WND) 288 * WINDOW STRUCTURE (WND) 289 * WINDOW STRUCTURE (WND) 290 * WINDOW STRUCTURE (WND) 291 * WINDOW STRUCTURE (WND) 292 * WINDOW STRUCTURE (WND) 293 * WINDOW STRUCTURE (WND) 294 */ 295 /* size and access functions */ 296 wndSize: procedure expose(sGlobals); return 144; /* guesswork! */ 297 298 wndNext: procedure expose(sGlobals); parse arg sMem; return memDword(x2d('00'), sMem); 299 wndParent: procedure expose(sGlobals); parse arg sMem; return memDword(x2d('04'), sMem); 300 wndChild: procedure expose(sGlobals); parse arg sMem; return memDword(x2d('08'), sMem); 301 wndOwner: procedure expose(sGlobals); parse arg sMem; return memDword(x2d('0c'), sMem); 302 wndRecs: procedure expose(sGlobals); parse arg iWord,sMem;return memWord( x2d('10') + iWord*2, sMem); 303 wndStyle: procedure expose(sGlobals); parse arg sMem; return memDword(x2d('18'), sMem); 304 wndId: procedure expose(sGlobals); parse arg sMem; return memDword(x2d('1c'), sMem); 305 wndMsgQueue: procedure expose(sGlobals); parse arg sMem; return memDword(x2d('28'), sMem); 306 wndHWND: procedure expose(sGlobals); parse arg sMem; return memDword(x2d('2c'), sMem); 307 wndModel: procedure expose(sGlobals); parse arg sMem; return memDword(x2d('30'), sMem); 308 wndProc: procedure expose(sGlobals); parse arg sMem; return memDword(x2d('34'), sMem); 309 wndThunkProc: procedure expose(sGlobals); parse arg sMem; return memDword(x2d('38'), sMem); 310 wndPresParams: procedure expose(sGlobals); parse arg sMem; return memDword(x2d('40'), sMem); 311 wndFocus: procedure expose(sGlobals); parse arg sMem; return memDword(x2d('44'), sMem); 312 wndWPSULong: procedure expose(sGlobals); parse arg sMem; return memDword(x2d('48'), sMem); 313 wndInstData: procedure expose(sGlobals); parse arg sMem; return memDword(x2d('50'), sMem); 314 wndOpen32: procedure expose(sGlobals); parse arg sMem; return memDword(x2d('58'), sMem); 315 /* 316 wndWord: procedure expose(sGlobals); parse arg iWord,sMem;return memDword(96 + iWord*4, sMem); 317 */ 318 /** dump one wnd structure */ 319 wndDump1: procedure expose(sGlobals) 320 parse arg sMem, sMsg 321 if (sMsg <> '') then 322 say sMsg 323 say ' pwndNext:' d2x(wndNext(sMem),8); 324 say ' pwndParent:' d2x(wndParent(sMem),8); 325 say ' pwndChild:' d2x(wndChild(sMem),8); 326 say ' pwndOwner:' d2x(wndOwner(sMem),8); 327 say ' rcsWindow: xl='wndRecs(0, sMem)',yl='wndRecs(1, sMem), 328 'xr='wndRecs(2, sMem)',yr='wndRecs(3, sMem) '(decimal)' 329 say ' ulStyle:' d2x(wndStyle(sMem),8); 330 say ' id:' d2x(wndId(sMem),8); 331 say ' pmqMsgQueue:' d2x(wndMsgQueue(sMem),8); 332 say ' hwnd:' d2x(wndHWND(sMem),8); 333 say ' fModel16bit:' d2x(wndModel(sMem),8); 334 say ' pfnWinProc:' d2x(wndProc(sMem),8) '('dfNear('%'d2x(wndProc(sMem),8))')' 335 if (wndThunkProc(sMem) = 0) then 336 say ' pfnThunkProc:' d2x(wndThunkProc(sMem),8) 337 else 338 say ' pfnThunkProc:' d2x(wndThunkProc(sMem),8) ' ('dfNear('%'d2x(wndThunkProc(sMem),8))')' 339 say ' ppresParams:' d2x(wndPresParams(sMem),8); 340 say ' pwndFocus:' d2x(wndFocus(sMem),8); 341 say ' ulWPS:' d2x(wndWPSULong(sMem),8); 342 say ' pInstData:' d2x(wndInstData(sMem),8); 343 say ' ??:' d2x(memDword(x2d('54'), sMem),8); 344 say ' pOpen32:' d2x(wndOpen32(sMem),8); 345 /* This aint right! 346 i = 0; 347 do while (i < 12) 348 say ' aulWin['d2x(i,2)'-'d2x(i+3,2)']: '||, 349 d2x(wndWord(i+0, sMem), 8) d2x(wndWord(i+1, sMem), 8), 350 d2x(wndWord(i+2, sMem), 8) d2x(wndWord(i+3, sMem), 8) 351 i = i + 4; 352 end 353 */ 354 return 0; 355 356 357 /** 358 * Dump window structures. 359 */ 360 WndDump: procedure expose(sGlobals) 361 parse arg sAddr cCount 362 /*defaults and param validation */ 363 if (cCount = '' | datatype(cCount) <> 'NUM') then 364 cCount = 1; 365 if (sAddr = '') then 366 signal SyntaxError 367 if (hwndIsHandle(sAddr)) then 368 do 369 ulPWND = hwnd2PWND(sAddr); 370 if (ulPWND > 0) then 371 sAddr = '%'d2x(ulPWND); 372 end 373 374 /* read memory */ 375 sMem = dfReadMem(sAddr, cCount * wndSize()) 376 if (sMem <> '') then 377 do 378 /* loop thru them all listing the taken/bogus ones */ 379 do i = 0 to cCount - 1 380 call wndDump1 memCopy(i * wndSize(), wndSize(), sMem); 381 end 382 end 383 else 384 say 'error: failed to read window structure at '''sAddr'''.'; 385 return 0; 386 387 388 389 390 /* 391 * WINDOW HANDLE (HWND) 392 * WINDOW HANDLE (HWND) 393 * WINDOW HANDLE (HWND) 394 * WINDOW HANDLE (HWND) 395 * WINDOW HANDLE (HWND) 396 * WINDOW HANDLE (HWND) 397 * WINDOW HANDLE (HWND) 398 * WINDOW HANDLE (HWND) 399 */ 400 hwnd2PWND: procedure expose(sGlobals) 401 parse arg sHwnd sDummy 402 ulIndex = x2d(right(sHwnd, 4)); 403 ulBase = hwndpHandleTable(); 404 if (ulBase = 0) then 405 return 0; 406 407 ulHandleEntry = ulBase + ulIndex * 8 + 32; 408 return dfReadDword('%'d2x(ulHandleEntry, 8), 4); 409 410 411 /** 412 * Checks if a value is a hwnd. 413 * @returns true/false. 414 * @param sValue Value in question. 415 */ 416 hwndIsHandle: procedure expose(sGlobals) 417 parse arg sValue sDummy 418 419 /* Paranoid check if this is a number or hex value or whatever*/ 420 sValue = strip(sValue); 421 if (sValue = '') then 422 return 0; 423 if (datatype(sValue) <> 'NUM') then 424 do /* assumes kind of hexx */ 425 sValue = translate(sValue); 426 if (left(sValue, 2) = '0X') then 427 sValue = substr(sValue, 3); 428 if (right(sValue,1) = 'H') then 429 sValue = substr(sValue, 1, length(sValue) - 1); 430 if (sValue = '') then 431 return 0; 432 if (strip(translate(sValue, '', '123456767ABCDEF')) <> '') then 433 return 0; 434 ulValue = x2d(sValue); 435 end 436 else 437 do /* check if decimal value, if not try hex */ 438 if (sValue >= x2d('80000001') & sValue < x2d('8000ffff')) then 439 return 1; 440 ulValue = x2d(sValue); 441 end 442 443 /* Check for valid handle range. */ 444 return ulValue >= x2d('80000001') & ulValue < x2d('8000ffff'); 445 446 447 /** 448 * Gets the pointer to the handle table. 449 */ 450 hwndpHandleTable: procedure expose(sGlobals) 451 if (ulHandleTable > 0) then 452 return ulHandleTable; 453 454 ulHandleTable = dfReadDword('pHandleTable', 4); 455 if (ulHandleTable > 0) then 456 return ulHandleTable 457 say 'error-hwndpHandleTable: failed to read pHandleTable'; 458 return 0; 459 460 461 462 /* 463 * MESSAGE QUEUE STRUCTURE (MQ) 464 * MESSAGE QUEUE STRUCTURE (MQ) 465 * MESSAGE QUEUE STRUCTURE (MQ) 466 * MESSAGE QUEUE STRUCTURE (MQ) 467 * MESSAGE QUEUE STRUCTURE (MQ) 468 * MESSAGE QUEUE STRUCTURE (MQ) 469 * MESSAGE QUEUE STRUCTURE (MQ) 470 * MESSAGE QUEUE STRUCTURE (MQ) 471 * MESSAGE QUEUE STRUCTURE (MQ) 472 */ 473 mqSize: procedure expose(sGlobals); return x2d('b0'); 474 mqNext: procedure expose(sGlobals); parse arg sMem; return memDword(x2d('00'), sMem); 475 mqEntrySize: procedure expose(sGlobals); parse arg sMem; return memWord(x2d('04'), sMem); 476 /*mqQueue: procedure expose(sGlobals); parse arg sMem; return memWord(x2d('06'), sMem);*/ 477 mqMessages: procedure expose(sGlobals); parse arg sMem; return memDword(x2d('08'), sMem); 478 /* ?? */ 479 mqMaxMessages: procedure expose(sGlobals); parse arg sMem; return memDword(x2d('0c'), sMem); 480 mqTid: procedure expose(sGlobals); parse arg sMem; return memDword(x2d('18'), sMem); 481 mqPid: procedure expose(sGlobals); parse arg sMem; return memDword(x2d('1c'), sMem); 482 mqFirstMsg: procedure expose(sGlobals); parse arg sMem; return memDword(x2d('20'), sMem); 483 mqLastMsg: procedure expose(sGlobals); parse arg sMem; return memDword(x2d('24'), sMem); 484 mqSGid: procedure expose(sGlobals); parse arg sMem; return memWord(x2d('28'), sMem); 485 mqHev: procedure expose(sGlobals); parse arg sMem; return memDword(x2d('2c'), sMem); 486 mqSent: procedure expose(sGlobals); parse arg sMem; return memDword(x2d('3c'), sMem); 487 mqCurrent: procedure expose(sGlobals); parse arg sMem; return memDword(x2d('40'), sMem); 488 489 mqBadPwnd: procedure expose(sGlobals); parse arg sMem; return memDword(x2d('68'), sMem); 490 mqBadQueue: procedure expose(sGlobals); parse arg sMem; return memByte(x2d('6c'), sMem); 491 mqCountTimers: procedure expose(sGlobals); parse arg sMem; return memByte(x2d('6d'), sMem); 492 mqHeap: procedure expose(sGlobals); parse arg sMem; return memDword(x2d('70'), sMem); 493 mqHAccel: procedure expose(sGlobals); parse arg sMem; return memDword(x2d('74'), sMem); 494 495 mqShutdown: procedure expose(sGlobals); parse arg sMem; return memDword(x2d('90'), sMem); 496 497 mqRcvdSMSList: procedure expose(sGlobals); parse arg sMem; return memDword(x2d('98'), sMem); 498 mqSlot: procedure expose(sGlobals); parse arg sMem; return memDword(x2d('a0'), sMem); 499 500 /** dump one mq structure */ 501 mqDump1: procedure expose(sGlobals) 502 parse arg sMem; 503 say ' pmqNext:' d2x(mqNext(sMem), 8); 504 say ' cbEntry:' d2x(mqEntrySize(sMem), 8); 505 say ' cMessages:' d2x(mqMessages(sMem), 8); 506 say 'cMaxMessages:' d2x(mqMaxMessages(sMem), 8); 507 say ' Tid:' d2x(mqTid(sMem), 8); 508 say ' Pid:' d2x(mqPid(sMem), 8); 509 say 'psmsFirstMsg:' d2x(mqFirstMsg(sMem), 8); 510 say ' psmsLastMsg:' d2x(mqLastMsg(sMem), 8); 511 say ' SGId:' d2x(mqSGid(sMem), 8); 512 say ' hev:' d2x(mqHev(sMem), 8); 513 say ' psmsSent:' d2x(mqSent(sMem), 8); 514 say ' psmsCurrent:' d2x(mqCurrent(sMem), 8); 515 say ' pwndBad:' d2x(mqBadPWND(sMem), 8); 516 say ' fBadQueue:' d2x(mqBadQueue(sMem), 2); 517 say ' cTimers:' d2x(mqCountTimers(sMem), 2); 518 say ' pHeap:' d2x(mqHeap(sMem), 8); 519 say ' HACCEL:' d2x(mqHAccel(sMem), 8); 520 say ' fchShutdown:' d2x(mqShutdown(sMem), 2); 521 say ' RcvdSMSList:' d2x(mqRcvdSMSList(sMem), 8); 522 say ' Slot:' d2x(mqSlot(sMem), 4); 523 return 0; 524 525 526 /** 527 * Message queue dumper. 528 * @param sAddr Address expression of a MQ struct, or a window 529 * which message queue you wanna dump. 530 * @returns 0 531 */ 532 mqDump: procedure expose(sGlobals) 533 parse arg sAddr cCount 534 /*defaults and param validation */ 535 if (cCount = '' | datatype(cCount) <> 'NUM') then 536 cCount = 1; 537 if (sAddr = '') then 538 signal SyntaxError 539 540 /* 541 * The user might have passed in an window handle. 542 * If so we'll dump it's queue. 543 */ 544 if (hwndIsHandle(sAddr)) then 545 do /* input is a hwnd, we will try dump it's queue */ 546 ulPWND = hwnd2PWND(sAddr); 547 if (ulPWND > 0) then 548 do 549 sMem = dfReadMem('%'d2x(ulPWND), wndSize()); 550 if (sMem <> '') then 551 do 552 ulMQ = wndMsgQueue(sMem); 553 if (ulMq > 0) then 554 sAddr = '%'d2x(ulPWND); 555 end 556 drop sMem; 557 end 558 end 559 560 /* read memory */ 561 sMem = dfReadMem(sAddr, cCount * mqSize()) 562 if (sMem <> '') then 563 do 564 /* loop thru them all listing the taken/bogus ones */ 565 do i = 0 to cCount - 1 566 call mqDump1 memCopy(i * mqSize(), mqSize(), sMem); 567 end 568 end 569 else 570 say 'error: failed to read window structure at '''sAddr'''.'; 571 return 0; 572 573 574 575 576 /* 577 * PMDF WORKERS 578 * PMDF WORKERS 579 * PMDF WORKERS 580 * PMDF WORKERS 581 * PMDF WORKERS 582 * PMDF WORKERS 583 * PMDF WORKERS 584 * PMDF WORKERS 585 * PMDF WORKERS 586 * PMDF WORKERS 587 * PMDF WORKERS 588 * PMDF WORKERS 195 589 */ 196 590 … … 203 597 * @returns The memory we have read. (internal format!) 204 598 */ 205 dfReadMem: procedure 599 dfReadMem: procedure expose(sGlobals) 206 600 parse arg sStartExpr, cbLength 207 601 … … 209 603 if ((cbLength // 4) = 0) then 210 604 do /* optimized read */ 211 say 'df: dd' sStartExpr 'L'cbLength/4'T'605 /*say 'dbg-df: dd' sStartExpr 'L'cbLength/4'T'*/ 212 606 Address df 'CMD' 'asOut' 'dd' sStartExpr 'L'cbLength/4'T' 213 say 'df: rc='rc' asOut.0='asOut.0;607 /*say 'dbg-df: rc='rc' asOut.0='asOut.0;*/ 214 608 if (rc = 0) then 215 609 do … … 232 626 end 233 627 end 234 return d2x(j,8)||sMem; 628 if (j <> 0) then 629 return d2x(j,8)||sMem; 235 630 end 236 631 … … 238 633 else 239 634 do /* slower (more output) byte by byte read */ 240 say 'df: db' sStartExpr 'L'cbLength'T'635 /*say 'dbg-df: db' sStartExpr 'L'cbLength'T'*/ 241 636 Address df 'CMD' 'asOut' 'db' sStartExpr 'L'cbLength'T' 242 say 'df: rc='rc' asOut.0='asOut.0;637 /*say 'dbg-df: rc='rc' asOut.0='asOut.0;*/ 243 638 if (rc = 0) then 244 639 do … … 261 656 end 262 657 end 263 return right(d2x(j), 8, '0')||sMem; 264 end 658 if (j <> 0) then 659 return d2x(j,8)||sMem; 660 end 661 end 662 return ''; 663 664 665 /** 666 * Reads a DWord at a given address. 667 * @param sAddr Address expression. 668 * @return The value of the dword at given address. 669 * -1 on error. 670 */ 671 dfReadByte: procedure expose(sGlobals) 672 parse arg sAddr 673 sMem = dfReadMem(sAddr, 4); 674 if (sMem <> '') then 675 return memByte(0, sMem); 676 return -1; 677 678 679 /** 680 * Reads a Word at a given address. 681 * @param sAddr Address expression. 682 * @return The value of the dword at given address. 683 * -1 on error. 684 */ 685 dfReadWord: procedure expose(sGlobals) 686 parse arg sAddr 687 sMem = dfReadMem(sAddr, W); 688 if (sMem <> '') then 689 return memWord(0, sMem); 690 return -1; 691 692 693 /** 694 * Reads a DWord at a given address. 695 * @param sAddr Address expression. 696 * @return The value of the dword at given address. 697 * -1 on error. 698 */ 699 dfReadDWord: procedure expose(sGlobals) 700 parse arg sAddr 701 sMem = dfReadMem(sAddr, 4); 702 if (sMem <> '') then 703 return memDword(0, sMem); 704 return -1; 705 706 707 /** 708 * Get near symbol. 709 * @param sAddr Address expression. 710 * @return Near output. 711 * '' on error. 712 */ 713 dfNear: procedure expose(sGlobals) 714 parse arg sAddr 715 Address df 'CMD' 'asOut' 'ln' sAddr 716 if (rc = 0 & asOut.0 > 0) then 717 do 718 parse var asOut.1 .' 'sRet; 719 return strip(sRet); 265 720 end 266 721 return ''; … … 271 726 * @param iIndex Byte offset into the array. 272 727 */ 273 memByte: procedure 728 memByte: procedure expose(sGlobals) 274 729 parse arg iIndex, sMem 275 730 cb = memSize(sMem); … … 278 733 return x2d(substr(sMem, (iIndex * 2) + 9 + 0, 2)); 279 734 end 280 say 'error-memByte: access out of range. '735 say 'error-memByte: access out of range. cb='cb ' iIndex='iIndex; 281 736 return -1; 282 737 … … 286 741 * @param iIndex Byte offset into the array. 287 742 */ 288 memWord: procedure 743 memWord: procedure expose(sGlobals) 289 744 parse arg iIndex, sMem 290 745 cb = memSize(sMem); … … 294 749 substr(sMem, (iIndex * 2) + 9 + 0, 2)); 295 750 end 296 say 'error-memWord: access out of range. '751 say 'error-memWord: access out of range. cb='cb ' iIndex='iIndex; 297 752 return -1; 298 753 … … 304 759 * @remark note problems with signed! 305 760 */ 306 memDword: procedure 761 memDword: procedure expose(sGlobals) 307 762 parse arg iIndex, sMem 308 763 cb = memSize(sMem); … … 315 770 substr(sMem, iIndex + 0, 2)); 316 771 end 317 say 'error-memDword: access out of range. '772 say 'error-memDword: access out of range. cb='cb ' iIndex='iIndex; 318 773 return -1; 319 774 … … 328 783 * Default is to fetch cchLength if cchLength is specifed. 329 784 */ 330 memString: procedure 785 memString: procedure expose(sGlobals) 331 786 parse arg iIndex, cchLength, fStoppAtNull, sMem 332 787 cb = memSize(sMem); … … 353 808 return sStr; 354 809 end 355 say 'error-memWord: access out of range. '810 say 'error-memWord: access out of range. cb='cb ' cbLength='cbLength; 356 811 return ''; 357 812 … … 364 819 * @paran sMem Memory block. 365 820 */ 366 memDumpByte: procedure 821 memDumpByte: procedure expose(sGlobals) 367 822 parse arg iIndex, cbLength, sMem 368 823 cb = memSize(sMem); … … 401 856 return 0; 402 857 end 403 say 'error-memDumpByte: access out of range. '858 say 'error-memDumpByte: access out of range. cb='cb 'iIndex='iIndex 'cbLength='cbLength; 404 859 return -1; 405 860 … … 412 867 * @paran sMem Memory block. 413 868 */ 414 memDumpWord: procedure 869 memDumpWord: procedure expose(sGlobals) 415 870 parse arg iIndex, cbLength, sMem 416 871 cb = memSize(sMem); … … 435 890 return 0; 436 891 end 437 say 'error-memDumpWord: access out of range. '892 say 'error-memDumpWord: access out of range. cb='cb ' cbLength='cbLength; 438 893 return -1; 439 894 … … 446 901 * @paran sMem Memory block. 447 902 */ 448 memDumpDword: procedure 903 memDumpDword: procedure expose(sGlobals) 449 904 parse arg iIndex, cbLength, sMem 450 905 cb = memSize(sMem); … … 469 924 return 0; 470 925 end 471 say 'error-memDumpDword: access out of range. '926 say 'error-memDumpDword: access out of range. cb='cb ' cbLength='cbLength; 472 927 return -1; 473 928 … … 479 934 * @param sMem Source block. 480 935 */ 481 memCopy: procedure ;936 memCopy: procedure expose(sGlobals) 482 937 parse arg iIndex, cbLength, sMem 483 938 cb = memSize(sMem); … … 485 940 do 486 941 sCopy = d2x(cbLength,8)||substr(sMem, 9 + iIndex * 2, cbLength * 2); 487 say 'dbg-memCopy: 'left(sCopy,8);488 942 return sCopy 489 943 end 490 say 'error-memCopy: access out of range. ';944 say 'error-memCopy: access out of range. cb='cb ' cbLength='cbLength; 491 945 return -1; 492 946 … … 496 950 * @param sMem The memory block in question. 497 951 */ 498 memSize: procedure ;952 memSize: procedure expose(sGlobals) 499 953 parse arg sMem 500 954 /* debug assertions - start - comment out when stable! */ … … 517 971 exit(16); 518 972 973 974 /** 975 * Lowercases a string. 976 * @param sString String to fold down. 977 * @returns Lowercase version of sString. 978 */ 979 lowercase: procedure expose(sGlobals) 980 parse arg sString 981 return translate(sString,, 982 'abcdefghijklmnopqrstuvwxyz',, 983 'ABCDEFGHIJKLMNOPQRSTUVWXYZ');
Note:
See TracChangeset
for help on using the changeset viewer.