Ignore:
Timestamp:
Aug 23, 2000, 6:25:46 AM (25 years ago)
Author:
bird
Message:

Added missing fakefunctions. Corrections of some bugs.
TestKernels.cmd runs fine.

Location:
branches/GRACE/src/win32k/test
Files:
2 edited

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:21 bird Exp $
     1/* $Id: fake.c,v 1.1.4.3 2000-08-23 04:25:45 bird Exp $
    22 *
    33 * Fake stubs for the ldr and kernel functions we imports or overloads.
     
    6060 * Pointer to the loader semaphore.
    6161 */
    62 static LONG     lfakeLDRSem = 0;        /* Used as a counter. */
    63 HKMTX           fakeLDRSem = (HKMTX)&lfakeLDRSem;
     62KSEMMTX         fakeLDRSem;
     63
     64CHAR            szBeginLibPath[1024];
     65CHAR            szEndLibPath[1024];
     66CHAR            szLibPath[1024];
     67PSZ             fakeLDRLibPath = &szLibPath[0];
     68
     69CHAR            szldrpFileNameBuf[CCHMAXPATH];
     70PSZ             fakeldrpFileNameBuf = &szldrpFileNameBuf[0];
    6471
    6572static CHAR     achHeaderBuffer[256];   /* Buffer to read exe header into. */
    6673PVOID           pheaderbuf = &achHeaderBuffer[0];
     74
    6775
    6876/*
     
    112120VOID  LDRCALL   fakeldrUCaseString(PCHAR pachString, USHORT cchString);
    113121ULONG LDRCALL   fakeldrMTEValidatePtrs(PSMTE psmte, ULONG ulMaxAddr, ULONG off);
     122unsigned 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 */
     131void  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}
    114155
    115156
     
    169210        if (pfl != NULL)
    170211            *pfl = 0;
     212        rc = DosQueryPathInfo(pszFilename, FIL_QUERYFULLNAME, fakeldrpFileNameBuf, CCHMAXPATH);
     213        rc = NO_ERROR;
    171214    }
    172215
     
    712755ULONG LDRCALL fakeLDRClearSem(void)
    713756{
    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);
    722758}
    723759
     
    730766 * @remark
    731767 */
    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;
     768ULONG 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;
    740793}
    741794
     
    749802 * @remark
    750803 */
    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"));
     804ULONG 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    }
    758820    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 */
     841BOOL 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 */
     880VOID  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 */
     905unsigned 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}
    764919
    765920
     
    15861741}
    15871742
     1743
     1744PMTE KRNLCALL fakeldrASMpMTEFromHandle(HMTE  hMTE)
     1745{
     1746    hMTE = hMTE;
     1747    return NULL;
     1748}
     1749
     1750ULONG 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:35 bird Exp $
     1/* $Id: win32ktst.c,v 1.1.4.5 2000-08-23 04:25:46 bird Exp $
    22 *
    33 * Win32k test module.
     
    5555
    5656
     57
     58
     59
    5760/** @design Win32k Ring-3 Testing
    5861 * I'll try to make it possible to test parts or all the win32k code in ring-3.
     
    136139 *      7) Testing finished - thunk stack back to 32-bit.
    137140 */
     141
    138142
    139143/*******************************************************************************
     
    225229*******************************************************************************/
    226230extern BOOL     fInited;                /* malloc.c */
    227 const char *    pszInternalRevision = "\r\nInternal revision 14.040_W4";
    228231int             cObjectsFake = 14;
    229232OTE             aKrnlOTE[24];
     
    240243    #define QS_MTE         0x0004
    241244#endif
     245
    242246
    243247/*******************************************************************************
     
    533537}
    534538
    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 
    546539
    547540/**
     
    682675    int         rc = 1;
    683676    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;
    685680
    686681    /* $elf */
     
    705700            opt.fPE             = FLAGS_PE_MIXED;
    706701            opt.fQuiet          = TRUE;
    707             opt.fLogging        = FALSE;
     702            opt.fLogging        = TRUE;
    708703            opt.usCom           = OUTPUT_COM1;
    709704            opt.ulInfoLevel     = INFOLEVEL_INFOALL;
Note: See TracChangeset for help on using the changeset viewer.