Changeset 6296 for trunk/src


Ignore:
Timestamp:
Jul 10, 2001, 6:41:10 PM (24 years ago)
Author:
bird
Message:

Use PTDA not PID and allways take loader sem.

Location:
trunk/src/win32k
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/win32k/dev32/d32Win32kOpenClose.c

    r6215 r6296  
    1 /* $Id: d32Win32kOpenClose.c,v 1.1 2001-07-08 02:53:18 bird Exp $
     1/* $Id: d32Win32kOpenClose.c,v 1.2 2001-07-10 16:39:16 bird Exp $
    22 *
    33 * Open and Close handlers for the Win32k driver.
     
    1616#define INCL_NOPMAPI
    1717#define INCL_OS2KRNL_TK
     18#define INCL_OS2KRNL_SEM
     19#define INCL_OS2KRNL_LDR
    1820#define INCL_OS2KRNL_PTDA
    1921
     
    5254USHORT _loadds _Far32 _Pascal Win32kOpen(PRP32OPENCLOSE pRpOpen)
    5355{
    54     PPTD pptd = GetTaskData(0);
     56    APIRET  rc;
     57    PPTD    pptd;
     58
     59    /*
     60     * Take Loader semaphore as that currently protects everything in this driver...
     61     */
     62    rc = LDRRequestSem();
     63    if (rc != NO_ERROR)
     64    {
     65        kprintf(("Win32kOpen: LDRRequestSem failed with rc = %d\n", rc));
     66        //return rc;
     67    }
     68
     69    pptd = GetTaskData(0, TRUE);
    5570    if (pptd)
    5671        pptd->cUsage++;
    5772
    5873    pRpOpen = pRpOpen;
     74    LDRClearSem();
    5975    return STATUS_DONE;
    6076}
     
    7086USHORT _loadds _Far32 _Pascal Win32kClose(PRP32OPENCLOSE pRpClose)
    7187{
    72     PPTD pptd = GetTaskData(0);
     88    APIRET  rc;
     89    PPTD    pptd;
     90
     91    /*
     92     * Take Loader semaphore as that currently protects everything in this driver...
     93     */
     94    rc = LDRRequestSem();
     95    if (rc != NO_ERROR)
     96    {
     97        kprintf(("Win32kClose: LDRRequestSem failed with rc = %d\n", rc));
     98        //return rc;
     99    }
     100
     101    pptd = GetTaskData(0, FALSE);
    73102    if (pptd)
    74103    {
    75104        if (pptd->cUsage > 0)
    76         {
    77             APIRET  rc;
    78             if (    pptd->pszzOdin32Env != NULL
    79                 && (rc = D32Hlp_VMUnLock(&pptd->lockOdin32Env)) != NO_ERROR
    80                 )
    81             {
    82                 kprintf(("Win32kClose: VMUnLock failed with rc=%d\n", rc));
    83             }
    84105            pptd->cUsage--;
    85         }
    86106        if (pptd->cUsage == 0)
    87107            RemoveTaskData(0);
    88108    }
    89109    pRpClose = pRpClose;
     110
     111    LDRClearSem();
    90112    return STATUS_DONE;
    91113}
  • trunk/src/win32k/include/PerTaskW32kData.h

    r6221 r6296  
    1 /* $Id: PerTaskW32kData.h,v 1.1 2001-07-08 02:58:36 bird Exp $
     1/* $Id: PerTaskW32kData.h,v 1.2 2001-07-10 16:41:10 bird Exp $
    22 *
    33 * Per Task (Win32k) Data.
     
    2020    AVLNODECORE     core;
    2121    ULONG           cUsage;             /* Usage counter. */
    22     PID             pid;                /* Also in core.Key */
     22    PPTDA           pPTDA;              /* Also in core.Key */
    2323    PSZ             pszzOdin32Env;      /* Pointer to environment block. */
    2424    LOCKHANDLE      lockOdin32Env;      /* VMLock handle for the environment block. */
     
    2626
    2727
    28 PPTD _Optlink   GetTaskData(PID pid);
    29 void _Optlink   RemoveTaskData(PID pid);
     28PPTD _Optlink   GetTaskData(PPTDA pPTDA, BOOL fCreate);
     29void _Optlink   RemoveTaskData(PPTDA pPTDA);
    3030
    3131#endif
  • trunk/src/win32k/k32/k32SetEnvironment.cpp

    r6214 r6296  
    1 /* $Id: k32SetEnvironment.cpp,v 1.1 2001-07-08 02:52:11 bird Exp $
     1/* $Id: k32SetEnvironment.cpp,v 1.2 2001-07-10 16:39:17 bird Exp $
    22 *
    33 * k32SetEnvironment - Sets the Odin32 environment for a process.
     
    1515#define INCL_DOSERRORS
    1616#define INCL_OS2KRNL_TK
     17#define INCL_OS2KRNL_PTDA
    1718#define INCL_OS2KRNL_SEM
    1819#define INCL_OS2KRNL_LDR
     
    2425*******************************************************************************/
    2526#include <os2.h>
     27#include <memory.h>
    2628#include "devSegDf.h"                   /* Win32k segment definitions. */
    2729#include "OS2Krnl.h"
     
    5658    PPTD    pptd;
    5759
    58 
    5960    /*
    6061     * Validate pid a little bit...
     
    6364    {
    6465        kprintf(("k32SetEnvironment: invalid pid=%x\n", pid));
     66        return ERROR_INVALID_PARAMETER;
     67    }
     68
     69    if (pid != 0)
     70    {
     71        kprintf(("k32SetEnvironment: currently only supported for current pid. pid=%x\n", pid));
    6572        return ERROR_INVALID_PARAMETER;
    6673    }
     
    8188     * Get Per Task Data and try set next environment pointer.
    8289     */
    83     pptd = GetTaskData(pid);
     90    pptd = GetTaskData(ptdaGetCur(), TRUE);
    8491    if (pptd)
    8592    {
    86         if (pptd->cUsage != 0 && pptd->pszzOdin32Env)
     93        if (*(PULONG)&pptd->lockOdin32Env)
     94        {
    8795            D32Hlp_VMUnLock(&pptd->lockOdin32Env);
     96            memset(&pptd->lockOdin32Env, 0, sizeof(pptd->lockOdin32Env));
     97        }
    8898        pptd->pszzOdin32Env = NULL;
    8999        if (pptd->cUsage != 0 && pszzEnvironment != NULL && cchEnvironment != 0)
    90100        {
    91             /*
    92              * Currently we're limited to the current process.
    93              */
    94             if (pid != 0 || GetTaskData(0) != pptd)
    95             {
    96                 kprintf(("k32SetEnvironment: not current process (pid=%d)\n", pid));
    97                 LDRClearSem();
    98                 return ERROR_INVALID_PARAMETER;
    99             }
    100 
    101 
    102101            /*
    103102             * Lock the memory (so we don't block or trap during environment searchs).
     
    110109            {
    111110                kprintf(("k32SetEnvironment: VMLock2 failed with rc=%d\n", rc));
     111                memset(&pptd->lockOdin32Env, 0, sizeof(pptd->lockOdin32Env));
    112112            }
    113113        }
  • trunk/src/win32k/misc/PerTaskW32kData.c

    r6230 r6296  
    1 /* $Id: PerTaskW32kData.c,v 1.1 2001-07-08 03:09:03 bird Exp $
     1/* $Id: PerTaskW32kData.c,v 1.2 2001-07-10 16:39:19 bird Exp $
    22 *
    33 * Per Task (Win32k) Data.
     
    1717#define INCL_OS2KRNL_VM                 /* OS2KRNL: Virtual Memory Management */
    1818#define INCL_OS2KRNL_TK                 /* OS2KRNL: Task Stuff */
     19#define INCL_OS2KRNL_PTDA
    1920
    2021/*******************************************************************************
     
    5253 * If it doesn't exist we'll allocate a new one.
    5354 * @returns Pointer to task data structure.
    54  * @param   pid     Process id. 0 means current pid.
     55 *          Might be NULL (see fCreate).
     56 * @param   pPTDA   Pointer to PTDA for the task.
     57 * @param   fCreate TRUE:  Create structure if not found.
     58 *                  FALSE: Return NULL if not found.
    5559 * @status  completely implemented.
    5660 * @author  knut st. osmundsen (kosmunds@csc.no)
    57  * @remark  Do we need a Get function which doesn't make a node if no data was found?
    5861 */
    59 PPTD    GetTaskData(PID pid)
     62PPTD    GetTaskData(PPTDA pPTDA, BOOL fCreate)
    6063{
    6164    PPTD    pptd;
    62     if (pid == 0)
    63         pid = InternalGetPid();
    64     pptd = (PPTD)(void*)AVLGet(&pPTDTree, pid);
    65     if (!pptd)
     65    if (pPTDA == 0)
     66        pPTDA = ptdaGetCur();
     67    pptd = (PPTD)(void*)AVLGet(&pPTDTree, (AVLKEY)pPTDA);
     68    if (!pptd && fCreate)
    6669    {
    6770        pptd = rmalloc(sizeof(*pptd));
     
    7275        }
    7376        memset(pptd, 0, sizeof(*pptd));
    74         pptd->core.Key = pid;
     77        pptd->core.Key = (AVLKEY)pPTDA;
    7578        AVLInsert(&pPTDTree, &pptd->core);
    7679    }
     
    8184/**
    8285 * Remove the give process id.
    83  * @param   pid     Process id to remove. 0 means current pid.
     86 * @param   pPTDA   Pointer to PTDA for the task.
    8487 * @status  completely implemented.
    8588 * @author  knut st. osmundsen (kosmunds@csc.no)
    8689 */
    87 void    RemoveTaskData(PID pid)
     90void    RemoveTaskData(PPTDA pPTDA)
    8891{
    8992    PPTD  pptd;
    90     if (pid == 0)
    91         pid = InternalGetPid();
    92     pptd = (PPTD)(void*)AVLRemove(&pPTDTree, pid);
     93    if (pPTDA == 0)
     94        pPTDA = ptdaGetCur();
     95    pptd = (PPTD)(void*)AVLRemove(&pPTDTree, (AVLKEY)pPTDA);
    9396    if (pptd)
    9497    {
    9598        /* perhaps free data here... */
     99        if (*(PULONG)(void*)&pptd->lockOdin32Env)
     100        {
     101            D32Hlp_VMUnLock(&pptd->lockOdin32Env);
     102            memset(&pptd->lockOdin32Env, 0, sizeof(pptd->lockOdin32Env));
     103        }
     104        pptd->pszzOdin32Env = NULL;
    96105        rfree(pptd);
    97106    }
  • trunk/src/win32k/pe2lx/pe2lx.cpp

    r6267 r6296  
    1 /* $Id: pe2lx.cpp,v 1.30 2001-07-09 12:56:53 bird Exp $
     1/* $Id: pe2lx.cpp,v 1.31 2001-07-10 16:39:18 bird Exp $
    22 *
    33 * Pe2Lx class implementation. Ring 0 and Ring 3
     
    17661766            case FINDDLL_PATH:
    17671767            {
    1768                 PPTD    pptd = GetTaskData(0);
     1768                PPTD    pptd = GetTaskData(NULL, FALSE);
    17691769                pszPath = NULL;
    17701770                if (pptd)
Note: See TracChangeset for help on using the changeset viewer.