Changeset 4073 for branches/GRACE/src/win32k/test
- Timestamp:
- Aug 23, 2000, 6:25:46 AM (25 years ago)
- Location:
- branches/GRACE/src/win32k/test
- Files:
-
- 2 edited
-
fake.c (modified) (8 diffs)
-
win32ktst.c (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/GRACE/src/win32k/test/fake.c
r4046 r4073 1 /* $Id: fake.c,v 1.1.4. 2 2000-08-19 14:37:21bird Exp $1 /* $Id: fake.c,v 1.1.4.3 2000-08-23 04:25:45 bird Exp $ 2 2 * 3 3 * Fake stubs for the ldr and kernel functions we imports or overloads. … … 60 60 * Pointer to the loader semaphore. 61 61 */ 62 static LONG lfakeLDRSem = 0; /* Used as a counter. */ 63 HKMTX fakeLDRSem = (HKMTX)&lfakeLDRSem; 62 KSEMMTX fakeLDRSem; 63 64 CHAR szBeginLibPath[1024]; 65 CHAR szEndLibPath[1024]; 66 CHAR szLibPath[1024]; 67 PSZ fakeLDRLibPath = &szLibPath[0]; 68 69 CHAR szldrpFileNameBuf[CCHMAXPATH]; 70 PSZ fakeldrpFileNameBuf = &szldrpFileNameBuf[0]; 64 71 65 72 static CHAR achHeaderBuffer[256]; /* Buffer to read exe header into. */ 66 73 PVOID pheaderbuf = &achHeaderBuffer[0]; 74 67 75 68 76 /* … … 112 120 VOID LDRCALL fakeldrUCaseString(PCHAR pachString, USHORT cchString); 113 121 ULONG LDRCALL fakeldrMTEValidatePtrs(PSMTE psmte, ULONG ulMaxAddr, ULONG off); 122 unsigned short getSlot(void); 123 124 125 126 /** 127 * Initiate workers (imported kernel functions / vars) 128 * @status partially implemented. 129 * @author knut st. osmundsen (knut.stange.osmundsen@pmsc.no) 130 */ 131 void workersinit(void) 132 { 133 APIRET rc; 134 135 /* 136 * Make code writable. 137 */ 138 DosSetMem(&CODE16START, &CODE16END - &CODE16START, PAG_WRITE | PAG_READ); 139 DosSetMem(&CODE32START, &CODE32END - &CODE32START, PAG_WRITE | PAG_READ); 140 141 /* 142 * Loader semaphore 143 */ 144 fakeKSEMInit((PKSEM)(void*)&fakeLDRSem, KSEM_MUTEX, KSEM_DEFAULT); 145 146 /* 147 * LIBPaths 148 */ 149 rc = DosQueryExtLIBPATH(szBeginLibPath, BEGIN_LIBPATH); 150 rc = DosQueryHeaderInfo(NULLHANDLE, 0, szLibPath, sizeof(szLibPath), QHINF_LIBPATH); 151 rc = DosQueryExtLIBPATH(szEndLibPath, END_LIBPATH); 152 153 rc = rc; 154 } 114 155 115 156 … … 169 210 if (pfl != NULL) 170 211 *pfl = 0; 212 rc = DosQueryPathInfo(pszFilename, FIL_QUERYFULLNAME, fakeldrpFileNameBuf, CCHMAXPATH); 213 rc = NO_ERROR; 171 214 } 172 215 … … 712 755 ULONG LDRCALL fakeLDRClearSem(void) 713 756 { 714 if (lfakeLDRSem == 0) 715 kprintf(("fakeLDRClearSem: lfakeLDRSem is 0 allready\n")); 716 else 717 lfakeLDRSem--; 718 719 printf("fakeLDRClearSem: usage count = %d, rc = %d\n", lfakeLDRSem, NO_ERROR); 720 721 return NO_ERROR; 757 return fakeKSEMReleaseMutex(&fakeLDRSem); 722 758 } 723 759 … … 730 766 * @remark 731 767 */ 732 ULONG KRNLCALL fakeKSEMRequestMutex(HKMTX hkmtx, ULONG ulTimeout) 733 { 734 (*(PLONG)hkmtx)++; 735 736 printf("fakeKSEMRequestMutex: hkmtx = %p, ulTimeout = 0x%x, usage count = %d, rc = %d\n", 737 hkmtx, ulTimeout, *(PLONG)hkmtx, NO_ERROR); 738 739 return NO_ERROR; 768 ULONG KRNLCALL fakeKSEMRequestMutex(HKSEMMTX hkmtx, ULONG ulTimeout) 769 { 770 unsigned short usSlot = getSlot(); 771 ULONG rc = NO_ERROR; 772 773 if (memcmp(&hkmtx->debug.ksem_achSignature[0], "KSEM", 4) != 0) 774 { 775 printf("fakeKSEMQueryMutex: hkmtx = %p, invalid signature (%.4s)\n", hkmtx, hkmtx->debug.ksem_achSignature); 776 return FALSE; 777 } 778 779 if (hkmtx->debug.ksem_Owner == 0) 780 { 781 hkmtx->debug.ksem_Owner = usSlot; 782 hkmtx->debug.ksem_cusNest = 1; 783 } 784 else if (hkmtx->debug.ksem_Owner == usSlot) 785 hkmtx->debug.ksem_cusNest++; 786 else 787 rc = ERROR_SEM_BUSY; 788 789 printf("fakeKSEMRequestMutex: hkmtx = %p, ulTimeout = 0x%x, owner = %d, usage count = %d, rc = %d\n", 790 hkmtx, ulTimeout, hkmtx->debug.ksem_cusNest, hkmtx->debug.ksem_Owner, ERROR_SEM_BUSY); 791 792 return rc; 740 793 } 741 794 … … 749 802 * @remark 750 803 */ 751 ULONG KRNLCALL fakeKSEMReleaseMutex(HKMTX hkmtx) 752 { 753 printf("fakeKSEMReleaseMutex: hkmtx = %p, usage count = %d, rc = %d\n", 754 hkmtx, *(PLONG)hkmtx, NO_ERROR); 755 756 if ((*(PLONG)hkmtx) == 0) 757 kprintf(("fakeKSEMReleaseMutex: sempahore is 0 allready\n")); 804 ULONG KRNLCALL fakeKSEMReleaseMutex(HKSEMMTX hkmtx) 805 { 806 unsigned int usSlot = getSlot(); 807 int rc = NO_ERROR; 808 809 if (memcmp(&hkmtx->debug.ksem_achSignature[0], "KSEM", 4) != 0) 810 { 811 printf("fakeKSEMQueryMutex: hkmtx = %p, invalid signature (%.4s)\n", hkmtx, hkmtx->debug.ksem_achSignature); 812 return FALSE; 813 } 814 815 if (hkmtx->debug.ksem_Owner == usSlot) 816 { 817 if (--hkmtx->debug.ksem_cusNest == 0) 818 hkmtx->debug.ksem_Owner = 0; 819 } 758 820 else 759 (*(PLONG)hkmtx)--; 760 761 return NO_ERROR; 762 } 763 821 rc = ERROR_NOT_OWNER; 822 823 printf("fakeKSEMReleaseMutex: hkmtx = %p, usage count = %d, owner = %d, rc = %d\n", 824 hkmtx, hkmtx->debug.ksem_cusNest, hkmtx->debug.ksem_Owner, rc); 825 826 return rc; 827 } 828 829 830 831 /** 832 * KSEMQueryMutex faker. 833 * @returns TRUE if owner or clear. Clear if *pcusNest is 0. 834 * FALSE if other owner. 835 * @param hkmtx Handle to kernel mutex. 836 * @param pcusNest Pointer to variable which is to receive the nesting count. 837 * (ie. the number of times we have taken this semaphore.) 838 * @status completely implemented. 839 * @author knut st. osmundsen (knut.stange.osmundsen@pmsc.no) 840 */ 841 BOOL KRNLCALL fakeKSEMQueryMutex(HKSEMMTX hkmtx, PUSHORT pcusNest) 842 { 843 unsigned int usSlot = getSlot(); 844 BOOL fRc = TRUE; 845 846 if (memcmp(&hkmtx->debug.ksem_achSignature[0], "KSEM", 4) != 0) 847 { 848 printf("fakeKSEMQueryMutex: hkmtx = %p, invalid signature (%.4s)\n", hkmtx, hkmtx->debug.ksem_achSignature); 849 return FALSE; 850 } 851 852 if (hkmtx->debug.ksem_Owner == 0) 853 { 854 if (pcusNest) 855 *pcusNest = 0; 856 fRc = FALSE; 857 } 858 else 859 { 860 fRc = (hkmtx->debug.ksem_Owner != usSlot); 861 if (pcusNest) 862 *pcusNest = hkmtx->debug.ksem_cusNest; 863 } 864 865 printf("fakeKSEMQueryMutex: hkmtx = %p, usage count = %d, owner = %d, *pcusNest = %d, rc = %d\n", 866 hkmtx, hkmtx->debug.ksem_cusNest, hkmtx->debug.ksem_Owner, pcusNest ? *pcusNest : -1, fRc); 867 868 return fRc; 869 } 870 871 872 /** 873 * KSEMInit faker. 874 * @param pksem Pointer to the semaphore struct to initiate. 875 * @param fulType Semaphore type. (only KSEM_MUTEX is supported) 876 * @param fulFlags Semaphore flags. (not validated) 877 * @status partially implemented. 878 * @author knut st. osmundsen (knut.stange.osmundsen@pmsc.no) 879 */ 880 VOID KRNLCALL fakeKSEMInit(PKSEM pksem, ULONG fulType, ULONG fulFlags) 881 { 882 if (fulType != KSEM_MUTEX) 883 { 884 printf("fakeKSEMInit: Invalid fulType parameter (%d).\n", fulType); 885 return; /*ERROR_INVALID_PARAMETER;*/ 886 } 887 888 memcpy(pksem->mtx.debug.ksem_achSignature, "KSEM", 4); 889 pksem->mtx.debug.ksem_bFlags = (char)fulFlags; 890 pksem->mtx.debug.ksem_bType = KSEM_MUTEX; 891 pksem->mtx.debug.ksem_cusNest = 0; 892 pksem->mtx.debug.ksem_cusPendingWriters = 0; 893 pksem->mtx.debug.ksem_Owner = 0; 894 895 printf("fakeKSEMInit: pksem=%p, fulType=%d, fulFlags=0x%x.\n", pksem, fulType, fulFlags); 896 } 897 898 899 /** 900 * Gets the thread slot number. 901 * @returns Thread slot number. 902 * @status completely implemented. 903 * @author knut st. osmundsen (knut.stange.osmundsen@pmsc.no) 904 */ 905 unsigned short getSlot(void) 906 { 907 PPIB ppib; 908 PTIB ptib; 909 BOOL f32Stack = ((int)&ppib > 0x10000); 910 911 if (!f32Stack) ThunkStack16To32(); 912 913 DosGetInfoBlocks(&ptib, &ppib); 914 915 if (!f32Stack) ThunkStack32To16(); 916 917 return (unsigned short)ptib->tib_ordinal; 918 } 764 919 765 920 … … 1586 1741 } 1587 1742 1743 1744 PMTE KRNLCALL fakeldrASMpMTEFromHandle(HMTE hMTE) 1745 { 1746 hMTE = hMTE; 1747 return NULL; 1748 } 1749 1750 ULONG LDRCALL fakeldrFindModule(PCHAR pachFilename, USHORT cchFilename, USHORT usClass, PPMTE ppMTE) 1751 { 1752 usClass = usClass; 1753 cchFilename = cchFilename; 1754 pachFilename = pachFilename; 1755 *ppMTE = NULL; 1756 return NO_ERROR; 1757 } 1758 1759 -
branches/GRACE/src/win32k/test/win32ktst.c
r4025 r4073 1 /* $Id: win32ktst.c,v 1.1.4. 4 2000-08-17 08:23:35bird Exp $1 /* $Id: win32ktst.c,v 1.1.4.5 2000-08-23 04:25:46 bird Exp $ 2 2 * 3 3 * Win32k test module. … … 55 55 56 56 57 58 59 57 60 /** @design Win32k Ring-3 Testing 58 61 * I'll try to make it possible to test parts or all the win32k code in ring-3. … … 136 139 * 7) Testing finished - thunk stack back to 32-bit. 137 140 */ 141 138 142 139 143 /******************************************************************************* … … 225 229 *******************************************************************************/ 226 230 extern BOOL fInited; /* malloc.c */ 227 const char * pszInternalRevision = "\r\nInternal revision 14.040_W4";228 231 int cObjectsFake = 14; 229 232 OTE aKrnlOTE[24]; … … 240 243 #define QS_MTE 0x0004 241 244 #endif 245 242 246 243 247 /******************************************************************************* … … 533 537 } 534 538 535 /**536 * Initiate workers (imported kernel functions / vars)537 * @status partially implemented.538 * @author knut st. osmundsen (knut.stange.osmundsen@pmsc.no)539 */540 void workersinit(void)541 {542 DosSetMem(&CODE16START, &CODE16END - &CODE16START, PAG_WRITE | PAG_READ);543 DosSetMem(&CODE32START, &CODE32END - &CODE32START, PAG_WRITE | PAG_READ);544 }545 546 539 547 540 /** … … 682 675 int rc = 1; 683 676 RP32INIT rpinit; 684 char * pszInitArgs = "-C1 -L:N -Verbose -Quiet -Elf:Yes -Pe:Mixed -Script:Yes -W4 -Heap:512000 -ResHeap:0256000 -HeapMax:4096000 -ResHeapMax:0x100000"; 677 char * pszInitArgs = "-C1 -L:E -Verbose -Quiet -Elf:Yes -Pe:Mixed -Script:Yes -W4 -Heap:512000 -ResHeap:0256000 -HeapMax:4096000 -ResHeapMax:0x100000"; 678 679 options.fLogging = TRUE; 685 680 686 681 /* $elf */ … … 705 700 opt.fPE = FLAGS_PE_MIXED; 706 701 opt.fQuiet = TRUE; 707 opt.fLogging = FALSE;702 opt.fLogging = TRUE; 708 703 opt.usCom = OUTPUT_COM1; 709 704 opt.ulInfoLevel = INFOLEVEL_INFOALL;
Note:
See TracChangeset
for help on using the changeset viewer.
