- Timestamp:
- Jan 21, 2001, 8:52:46 AM (25 years ago)
- Location:
- trunk/src/win32k
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/win32k/api/api.cpp
r4996 r4998 1 /* $Id: api.cpp,v 1. 2 2001-01-20 23:51:06 bird Exp $1 /* $Id: api.cpp,v 1.3 2001-01-21 07:52:46 bird Exp $ 2 2 * 3 3 * API Overload Init and Helper Function. … … 14 14 #define INCL_DOSERRORS 15 15 #define INCL_NOPMAPI 16 #define INCL_OS2KRNL_SEM 17 #define INCL_OS2KRNL_PTDA 18 #define INCL_OS2KRNL_IO 16 #define INCL_OS2KRNL_ALL 19 17 20 18 … … 35 33 #include "log.h" 36 34 #include "OS2Krnl.h" 35 #include "ldrCalls.h" 37 36 #include "dev32.h" 38 37 #include "api.h" 39 38 #include "options.h" 39 #include "locks.h" 40 40 41 41 … … 64 64 * Global Variables * 65 65 *******************************************************************************/ 66 APIDATAENTRY aApiData[API_ MAX];/* Array of api info. */66 APIDATAENTRY aApiData[API_CENTRIES]; /* Array of api info. */ 67 67 PSZ pszFile; /* Pointer to entire file mapping. */ 68 RWLOCK ApiInfoRWLock; /* Read/Write lock for api data. */ 68 69 69 70 … … 76 77 int apiInterpretApiNo(PSZ pszSection); 77 78 void apiFreeApiData(PAPIDATAENTRY paNewApiData); 78 79 79 void apiSortApiData(PAPIDATAENTRY paApiData); 80 void apiSortMaskArray(PMASKARRAY pMasks); 81 BOOL apiFindNameInMaskArray(PSZ pszName, PMASKARRAY pMasks); 82 APIRET apiGetProccessName(PSZ pszName); 83 APIRET apiGetModuleName(PSZ pszName, USHORT usCS, ULONG ulEIP); 80 84 81 85 … … 197 201 { 198 202 int iApi = apiInterpretApiNo(pszLine); 199 if (iApi >= 0 && iApi < API_ MAX)203 if (iApi >= 0 && iApi < API_CENTRIES) 200 204 { 201 205 PMASKARRAY pMaskArray = &paNewApiData[iApi].ModuleExc; … … 271 275 if (rc == NO_ERROR) 272 276 { 273 /* add spin lock */ 277 apiSortApiData(paNewApiData); 278 RWLockAcquireWrite(&ApiInfoRWLock); 274 279 apiFreeApiData(&aApiData[0]); 275 280 memcpy(&aApiData[0], paNewApiData, sizeof(aApiData)); 276 /* remove spin lock */281 RWLockReleaseWrite(&ApiInfoRWLock); 277 282 } 278 283 else … … 391 396 /** 392 397 * Frees internal data in a api data structure. 393 * @param pa NewApiDataPointer to api data table.398 * @param paApiData Pointer to api data table. 394 399 * @sketch Loop thru all api entries and free mask array pointers. 395 400 * @status Completely implemented. … … 397 402 * @remark Any serialization is not my problem. 398 403 */ 399 void apiFreeApiData(PAPIDATAENTRY pa NewApiData)404 void apiFreeApiData(PAPIDATAENTRY paApiData) 400 405 { 401 406 int i; 402 407 403 for (i = 0; i < API_MAX; i++) 404 { 405 if (paNewApiData[i].ProcessInc.cMasks) 406 rfree(paNewApiData[i].ProcessInc.papszMasks); 407 if (paNewApiData[i].ProcessExc.cMasks) 408 rfree(paNewApiData[i].ProcessExc.papszMasks); 409 if (paNewApiData[i].ModuleInc.cMasks) 410 rfree(paNewApiData[i].ModuleInc.papszMasks); 411 if (paNewApiData[i].ModuleExc.cMasks) 412 rfree(paNewApiData[i].ModuleExc.papszMasks); 413 } 414 } 415 416 417 408 for (i = 0; i < API_CENTRIES; i++) 409 { 410 if (paApiData[i].ProcessInc.cMasks) 411 rfree(paApiData[i].ProcessInc.papszMasks); 412 if (paApiData[i].ProcessExc.cMasks) 413 rfree(paApiData[i].ProcessExc.papszMasks); 414 if (paApiData[i].ModuleInc.cMasks) 415 rfree(paApiData[i].ModuleInc.papszMasks); 416 if (paApiData[i].ModuleExc.cMasks) 417 rfree(paApiData[i].ModuleExc.papszMasks); 418 } 419 } 420 421 422 /** 423 * Sort the entire api data structure. 424 * @param paApiData Pointer to api data to sort. 425 * @sketch Loop thru all entries and sort all four mask arrays. 426 * @status completely implemented. 427 * @author knut st. osmundsen (knut.stange.osmundsen@mynd.no) 428 * @remark See apiSortMaskArray. 429 */ 430 void apiSortApiData(PAPIDATAENTRY paApiData) 431 { 432 int i; 433 434 for (i = 0; i < API_CENTRIES; i++) 435 { 436 apiSortMaskArray(&paApiData[i].ProcessInc); 437 apiSortMaskArray(&paApiData[i].ProcessExc); 438 apiSortMaskArray(&paApiData[i].ModuleInc); 439 apiSortMaskArray(&paApiData[i].ModuleExc); 440 } 441 } 442 443 444 /** 445 * Sorts the content of an mask array. 446 * Duplicates are removed. 447 * @param pMasks Pointer to a mask array structure. 448 * @sketch Use bouble sort. 449 * @status partially implemented. 450 * @author knut st. osmundsen (knut.stange.osmundsen@mynd.no) 451 * @remark Duplicate submasks aren't tested for. 452 * example: "DOSCALL1.DLL" is equal to "DOS*" 453 */ 454 void apiSortMaskArray(PMASKARRAY pMasks) 455 { 456 int i; 457 PSZ pszTmp; 458 459 do 460 { 461 for (i = 1, pszTmp = NULL; i < pMasks->cMasks; i++) 462 { 463 int iDiff = strcmp(pMasks->papszMasks[i], pMasks->papszMasks[i-1]); 464 if (iDiff == 0) 465 { /* remove entry */ 466 memmove(&pMasks->papszMasks[i], &pMasks->papszMasks[i+1], 467 (pMasks->cMasks - i - 1) * sizeof(pMasks->papszMasks[0])); 468 i--; 469 } 470 else if (iDiff < 0) 471 { /* Swap entries. */ 472 PSZ pszTmp = pMasks->papszMasks[i]; 473 pMasks->papszMasks[i] = pMasks->papszMasks[i-1]; 474 pMasks->papszMasks[i-1] = pszTmp; 475 } 476 } 477 } while (pszTmp != NULL); 478 } 479 480 481 /** 482 * Searches a mask array if there is any match for the given name. 483 * @returns TRUE if found. 484 * FALSE if not found. 485 * @param pszName Pointer to name. 486 * @param pMasks Pointer to mask array. 487 * @sketch 488 * @status 489 * @author knut st. osmundsen (knut.stange.osmundsen@mynd.no) 490 * @remark 491 */ 492 BOOL apiFindNameInMaskArray(PSZ pszName, PMASKARRAY pMasks) 493 { 494 return FALSE; 495 } 496 497 498 /** 499 * Get the current process executable name. 500 * @returns OS/2 return code. 501 * @param pszName Pointer to output name buffer. 502 * @sketch Get current ptda. 503 * Get module handle (hmte) from current ptda. 504 * Get pmte and smte from the hmte. 505 * Check if there is any path (full filename). 506 * Parse out filename+ext from full filename and copy it to pszName. 507 * return. 508 * @status completely implemented. 509 * @author knut st. osmundsen (knut.stange.osmundsen@mynd.no) 510 */ 511 APIRET apiGetProccessName(PSZ pszName) 512 { 513 PPTDA pPTDA = ptdaGetCur(); 514 if (pPTDA) 515 { 516 HMTE hmte = ptdaGet_ptda_module(pPTDA); 517 if (hmte) 518 { 519 PMTE pmte = ldrASMpMTEFromHandle(hmte); 520 PSMTE psmte; 521 if ( pmte 522 && (psmte = pmte->mte_swapmte) 523 && psmte->smte_path 524 && *psmte->smte_path) 525 { 526 /* 527 * Get executable name from swap mte. 528 * We parse out the filename+ext and copies it to the output buffer. 529 */ 530 PCHAR psz; 531 PCHAR pszExt; 532 ldrGetFileName2(psmte->smte_path, (PCHAR*)SSToDS(&psz), (PCHAR*)SSToDS(&pszExt)); 533 if (!psz) psz = psmte->smte_path; 534 strcpy(pszName, psz); 535 return NO_ERROR; 536 } 537 else 538 kprintf(("apiGetProcessName: failed to get pmte(0x%08x) from hmte(0x%04x) or no path.\n", pmte, hmte)); 539 } 540 else 541 kprintf(("apiGetProcessName: This PTDA has no module handle. (pptda=0x%08x, hptda=0x%04)\n", pPTDA, ptdaGet_ptda_handle(pPTDA))); 542 } 543 else 544 kprintf(("apiGetProcessName: No current PTDA!\n")); 545 546 return ERROR_INVALID_PARAMETER; 547 } 548 549 /** 550 * Gets the module name from a given CS:EIP pair. 551 * @returns OS/2 return code. 552 * @param pszName Output buffer. 553 * @param usCS CS (code segment). 554 * @param ulEIP EIP (Extended Instruction Pointer). 555 * @sketch Get hmte from cs:eip. 556 * Get pmte and smte from the hmte. 557 * Check if there is any path (full filename). 558 * Parse out filename+ext from full filename and copy it to pszName. 559 * return. 560 * @status completely implemented. 561 * @author knut st. osmundsen (knut.stange.osmundsen@mynd.no) 562 */ 563 APIRET apiGetModuleName(PSZ pszName, USHORT usCS, ULONG ulEIP) 564 { 565 HMTE hmte = VMGetOwner(usCS, ulEIP); 566 if (hmte) 567 { 568 PMTE pmte = ldrASMpMTEFromHandle(hmte); 569 PSMTE psmte; 570 if ( pmte 571 && (psmte = pmte->mte_swapmte) 572 && psmte->smte_path 573 && *psmte->smte_path) 574 { 575 /* 576 * Get executable name from swap mte. 577 * We parse out the filename+ext and copies it to the output buffer. 578 */ 579 PCHAR psz; 580 PCHAR pszExt; 581 ldrGetFileName2(psmte->smte_path, (PCHAR*)SSToDS(&psz), (PCHAR*)SSToDS(&pszExt)); 582 if (!psz) psz = psmte->smte_path; 583 strcpy(pszName, psz); 584 return NO_ERROR; 585 } 586 else 587 kprintf(("apiGetModuleName: failed to get pmte(0x%08x) from hmte(0x%04x) or no path.\n", pmte, hmte)); 588 } 589 else 590 kprintf(("apiGetModuleName: failed to get hmte from cs=%04x eip=%08x\n", usCS, ulEIP)); 591 592 /* 593 * We failed. 594 */ 595 return ERROR_INVALID_PARAMETER; 596 } 597 598 599 600 /** 601 * Checks if an api enhancement is enabled for this process or/and module. 602 * Exclusion lists rulez over inclusion. 603 * Excluded processes rulez over included modules. 604 * @returns TRUE (!0) if it's enabled. 605 * FALSE (0) if it's disabled. 606 * @param iApi Api data id/index. 607 * @param usCS CS of the API caller. 608 * @param ulEIP EIP of the API caller. 609 * @sketch 610 * @status 611 * @author knut st. osmundsen (knut.stange.osmundsen@mynd.no) 612 * @remark 613 */ 418 614 BOOL _Optlink APIQueryEnabled(int iApi, USHORT usCS, LONG ulEIP) 419 615 { … … 427 623 428 624 /* 429 * Aquire read lock - TODO.430 */ 431 625 * Aquire read lock. 626 */ 627 RWLockAcquireRead(&ApiInfoRWLock); 432 628 433 629 /* … … 435 631 * Check if entry is enabled. 436 632 */ 437 pEntry = &aApiInfo[iApi]; 633 BOOL fRet = FALSE; 634 pEntry = &aApiData[iApi]; 438 635 if (pEntry->fEnabled) 439 636 { 440 637 CHAR szName[CCHMAXPATH]; 441 442 } 443 else 444 fRet = FALSE; 445 446 447 /* 448 * Release read lock - TODO. 449 */ 450 638 PSZ pszName = (PSZ)SSToDS(&szName[0]); 639 640 if (pEntry->ProcessExc.cMasks > 0 || pEntry->ProcessInc.cMasks > 0) 641 { 642 if (!apiGetProccessName(pszName)) 643 { /* TODO - fix this priority - it's probably wrong */ 644 if (pEntry->ProcessExc.cMasks) 645 fRet = !apiFindNameInMaskArray(pszName, &pEntry->ProcessExc); 646 else if (pEntry->ProcessInc.cMasks) 647 fRet = apiFindNameInMaskArray(pszName, &pEntry->ProcessInc); 648 } 649 } 650 651 if ( !pEntry->ProcessExc.cMasks 652 && !fRet 653 && (pEntry->ModuleExc.cMasks > 0 || pEntry->ModuleInc.cMasks > 0)) 654 { 655 if (!apiGetModuleName(pszName, usCS, ulEIP)) 656 { /* TODO - fix this priority - it's probably wrong */ 657 if (pEntry->ModuleExc.cMasks) 658 fRet = !apiFindNameInMaskArray(pszName, &pEntry->ModuleExc); 659 else if (pEntry->ProcessInc.cMasks) 660 fRet = apiFindNameInMaskArray(pszName, &pEntry->ModuleInc); 661 } 662 } 663 } 664 665 666 /* 667 * Release read lock. 668 */ 669 RWLockReleaseRead(&ApiInfoRWLock); 451 670 452 671 return fRet; -
trunk/src/win32k/api/myVR32AllocMem.asm
r4981 r4998 1 ; $Id: myVR32AllocMem.asm,v 1. 2 2001-01-20 15:48:54bird Exp $1 ; $Id: myVR32AllocMem.asm,v 1.3 2001-01-21 07:52:46 bird Exp $ 2 2 ; 3 3 ; VR32AllocMem over loader which adds the OBJ_ANY flag. … … 23 23 ; 24 24 include devsegdf.inc 25 include api.inc 25 26 include bsememf.inc 26 27 ifndef OBJ_ANY … … 38 39 ; Externs 39 40 ; 40 extrn apiApplyChange:PROC ; system call?41 extrn APIQueryEnabled:PROC 41 42 extrn _VR32AllocMem@50:PROC 42 43 … … 58 59 ; It was not - check if we're to set it for this calling module. 59 60 ; 61 movzx ecx, word ptr [esp + SEF_CS] 62 mov edx, dword ptr [esp + SEF_EIP] 60 63 push eax 61 push dword ptr [esp + SEF_CS]62 push dword ptr [esp + SEF_EIP]63 push 164 call apiApplyChange65 64 sub esp, 0ch 65 mov eax, API_DOSALLOCMEM_ANY_OBJ 66 call APIQueryEnabled 67 add esp, 0ch 66 68 test eax, eax 67 69 pop eax -
trunk/src/win32k/include/api.h
r4996 r4998 1 /* $Id: api.h,v 1. 2 2001-01-20 23:49:54bird Exp $1 /* $Id: api.h,v 1.3 2001-01-21 07:52:46 bird Exp $ 2 2 * 3 3 * API Overload Init and Helper Function - public header. … … 8 8 * 9 9 */ 10 /*NOINC*/ 10 11 #ifndef _API_H_ 11 12 #define _API_H_ 13 /*INC*/ 12 14 13 15 … … 17 19 #define API_DOSALLOCMEM_ANY_OBJ 0 18 20 #define API_DOSALLOCSHAREDMEM_ANY_OBJ 1 19 #define API_MAX 2 21 #define API_MAX API_DOSALLOCSHAREDMEM_ANY_OBJ 22 #define API_CENTRIES (API_MAX + 1) 20 23 24 /*NOINC*/ 25 APIRET _Optlink APIInit(void); 26 BOOL _Optlink APIQueryEnabled(int iApi, USHORT usCS, LONG ulEIP); 27 /*INC*/ 21 28 22 void _Optlink APIInit(void); 23 BOOL _Optlink APIQueryEnabled(int iApi, USHORT usCS, LONG ulEIP); 24 25 26 29 /*NOINC*/ 27 30 #endif 31 /*INC*/
Note:
See TracChangeset
for help on using the changeset viewer.