Changeset 3834 for branches/Grace/src


Ignore:
Timestamp:
Jul 17, 2000, 12:43:41 AM (25 years ago)
Author:
bird
Message:

Checkin of current code in the Grace brance for backup purpose.

Location:
branches/Grace/src/win32k
Files:
15 edited

Legend:

Unmodified
Added
Removed
  • branches/Grace/src/win32k/dev32/d32hlp.asm

    r1535 r3834  
    1 ; $Id: d32hlp.asm,v 1.3 1999-10-31 23:57:02 bird Exp $
     1; $Id: d32hlp.asm,v 1.3.4.1 2000-07-16 22:43:25 bird Exp $
    22;
    33; d32hlp - 32-bit Device Driver Helper Function.
     
    3434; extrns
    3535;
    36 extrn _Device_Help:dword
     36    extrn _Device_Help:dword
    3737
    3838;CODE32 segment
     
    4242
    4343;PVOID  D32HLPCALL D32Hlp_VirtToLin(ULONG  ulPtr16); /* eax */
     44; Sideeffect: edx holds the error code on error.
    4445D32Hlp_VirtToLin proc near
    4546    push    esi
     
    5152Thunk32_VirtToLin::
    5253    jnc     Finished
     54    mov     edx, eax
    5355    xor     eax, eax
    5456
     
    6163;PVOID  D32HLPCALL D32Hlp_VirtToLin2(USHORT usSelector, /*  ax */
    6264;                                    ULONG  ulOffset);  /* edx */
     65; Sideeffect: edx holds the error code on error.
    6366D32Hlp_VirtToLin2 proc near
    6467    push    esi
     
    6972Thunk32_VirtToLin2::
    7073    jnc     Finished
     74    mov     edx, eax
    7175    xor     eax, eax
    7276
  • branches/Grace/src/win32k/include/ModuleBase.h

    r2925 r3834  
    1 /* $Id: ModuleBase.h,v 1.3 2000-02-27 02:16:43 bird Exp $
     1/* $Id: ModuleBase.h,v 1.3.4.1 2000-07-16 22:43:26 bird Exp $
    22 *
    33 * ModuleBase - Declaration of the Basic module class.
    44 *
    5  * Copyright (c) 1999 knut st. osmundsen
     5 * Copyright (c) 1999-2000 knut st. osmundsen
    66 *
    77 * Project Odin Software License can be found in LICENSE.TXT
    88 *
    99 */
    10 #ifndef _MODULEBASE_H_
    11 #define _MODULEBASE_H_
     10#ifndef _modulebase_h_
     11#define _modulebase_h_
    1212
    1313
     
    7373 *           RING0: Map this to ldrRead with 0UL as flFlags.
    7474 *           RING3: Implementes this function as a static function, ReadAt.
    75  *  ReadAtF: Same as ReadAt but two extra parameters; an additional flag and a pointer to an MTE.
    76  *           Used in the read method.
     75 *  ReadAtF: Same as ReadAt but two extra parameters; an additional far pointer to the buffer and
     76 *           a MTE pointer. Used in the read method.
    7777 *           RING0: Map directly to ldrRead.
    7878 *           RING3: Map to ReadAt, ignoring the two extra parameters.
     
    8181    #define ReadAt(hFile, ulOffset, pvBuffer, cbToRead) \
    8282        ldrRead(hFile, ulOffset, pvBuffer, 0UL, cbToRead, NULL)
    83     #define ReadAtF(hFile, ulOffset, pvBuffer, cbToRead, flFlags, pMTE) \
    84         ldrRead(hFile, ulOffset, pvBuffer, flFlags, cbToRead, pMTE)
     83    #define ReadAtF(hFile, ulOffset, pvBuffer, fpBuffer, cbToRead, pMTE) \
     84        ldrRead(hFile, ulOffset, pvBuffer, fpBuffer, cbToRead, pMTE)
    8585#else
    86     #define ReadAtF(hFile, ulOffset, pvBuffer, cbToRead, flFlags, pMTE) \
     86    #define ReadAtF(hFile, ulOffset, pvBuffer, fpBuffer, cbToRead, pMTE) \
    8787        ReadAt(hFile, ulOffset, pvBuffer, cbToRead)
    8888#endif
     
    9696#endif
    9797
    98 
     98/*
     99 * Make sure that pLdrLv is defined.
     100 */
     101#if !defined(RING0) && !defined(_ldrCalls_h_)
     102typedef struct ldrlv_s  ldrlv_t;
     103#endif
    99104
    100105/**
     
    112117    /** @cat Public Main methods */
    113118    virtual ULONG  init(PCSZ pszFilename);
    114     virtual ULONG  read(ULONG offLXFile, PVOID pvBuffer, ULONG cbToRead, ULONG flFlags, PMTE pMTE) = 0;
     119    virtual ULONG  read(ULONG offLXFile, PVOID pvBuffer, ULONG fpBuffer, ULONG cbToRead, PMTE pMTE) = 0;
    115120    virtual ULONG  applyFixups(PMTE pMTE, ULONG iObject, ULONG iPageTable, PVOID pvPage,
    116121                               ULONG ulPageAddress, PVOID pvPTDA); /*(ldrEnum32bitRelRecs)*/
     122    virtual ULONG  openPath(PCHAR pachModname, USHORT cchModname, ldrlv_t *pLdrLv, PULONG pfl); /*(ldrOpenPath)*/
    117123    #ifndef RING0
    118124    virtual ULONG  writeFile(PCSZ pszLXFilename);
  • branches/Grace/src/win32k/include/OS2Krnl.h

    r2799 r3834  
    1 /* $Id: OS2Krnl.h,v 1.7 2000-02-15 23:39:19 bird Exp $
     1/* $Id: OS2Krnl.h,v 1.7.4.1 2000-07-16 22:43:27 bird Exp $
    22 *
    33 * OS/2 kernel structures, typedefs and macros.
     
    153153} MTE,*PMTE,**PPMTE;
    154154
     155typedef USHORT HMTE, *PHMTE;
     156typedef USHORT HPTDA, *PHPTDA;
    155157
    156158
     
    235237    #define INCL_OS2KRNL_IO
    236238    #define INCL_OS2KRNL_VM
     239    #define INCL_OS2KRNL_SEM
     240    #define INCL_OS2KRNL_TK
     241    #define INCL_OS2KRNL_PTDA
     242    #define INCL_OS2KRNL_TCB
    237243#endif
    238244
     
    245251#endif
    246252
    247 #endif
     253#ifdef INCL_OS2KRNL_SEM
     254    #include <OS2KSEM.h>
     255#endif
     256
     257#ifdef INCL_OS2KRNL_TK
     258    #include <OS2KTK.h>
     259#endif
     260
     261#ifdef INCL_OS2KRNL_PTDA
     262    #include <OS2KPTDA.h>
     263#endif
     264
     265#ifdef INCL_OS2KRNL_TCB
     266    #include <OS2KTCB.h>
     267#endif
     268
     269#endif
  • branches/Grace/src/win32k/include/dev1632.h

    r3321 r3834  
    1 /* $Id: dev1632.h,v 1.5 2000-04-05 18:40:41 bird Exp $
     1/* $Id: dev1632.h,v 1.5.4.1 2000-07-16 22:43:28 bird Exp $
    22 * dev1632.h - Common header file for 16-bit and 32-bit C
    33 *
     
    5050typedef struct _KRNLINFO
    5151{
     52    unsigned long   ulBuild;
     53    unsigned short  fKernel;
    5254    unsigned char   cObjects;
    53     unsigned char   fDebug;
    54     unsigned char   fchType;             /* TYPE_SMP, TYPE_UNI, TYPE_W4 */
    55     unsigned short  usBuild;
     55    unsigned char   chPadding;
    5656    OTE             aObjects[MAXKRNLOBJECTS];
    5757} KRNLINFO, FAR * PKRNLINFO;
  • branches/Grace/src/win32k/include/dev32.h

    r2898 r3834  
    1 /* $Id: dev32.h,v 1.8 2000-02-25 18:15:04 bird Exp $
     1/* $Id: dev32.h,v 1.8.4.1 2000-07-16 22:43:28 bird Exp $
    22 *
    33 * dev32 - header file for 32-bit part of the driver.
     
    6464PMTE _System GetOS2KrnlMTE(void); /* (devfirst.asm) */
    6565#endif
     66
     67/*
     68 * D32init Errors
     69 */
     70#define ERROR_D32_GETOS2KRNL_FAILED         0x01
     71#define ERROR_D32_NO_SWAPMTE                0x02
     72#define ERROR_D32_TOO_MANY_OBJECTS          0x03
     73#define ERROR_D32_NO_OBJECT_TABLE           0x04
     74#define ERROR_D32_BUILD_INFO_NOT_FOUND      0x05
     75#define ERROR_D32_INVALID_BUILD             0x06
     76#define ERROR_D32_PROC_NOT_FOUND            0x10
     77#define ERROR_D32_INVALID_OBJ_OR_ADDR       0x11
     78#define ERROR_D32_INVALID_ADDRESS           0x12
     79#define ERROR_D32_TOO_INVALID_PROLOG        0x13
     80#define ERROR_D32_NOT_IMPLEMENTED           0x14
     81#define ERROR_D32_VERIFY_FAILED             0x20
    6682
    6783
  • branches/Grace/src/win32k/include/devSegDf.inc

    r2838 r3834  
    1 ; $Id: devSegDf.inc,v 1.5 2000-02-21 09:24:00 bird Exp $
     1; $Id: devSegDf.inc,v 1.5.4.1 2000-07-16 22:43:28 bird Exp $
    22;
    33; Segment definitions for win32k.sys.
     
    3333
    3434;DGROUP group BSS32, DATA32
    35 DGROUP group BSS32, DATA32, CONST32_RO, _VFT, EH_DATA
     35DGROUP group CALLTAB, BSS32, DATA32, CONST32_RO, _VFT, c_common, DDE4_DATA32, CTOR_DTOR1, CTOR_DTOR2, CTOR_DTOR3, EH_DATA
    3636
    3737DATA32  segment dword public 'DATA' use32
     
    4141c_common ends
    4242
     43DDE4_DATA32  segment dword public 'DATA' use32
     44DDE4_DATA32 ends
     45
    4346BSS32 segment dword public 'BSS' use32
    4447BSS32 ends
    4548
     49CTOR_DTOR1 segment dword public 'DATA' use32
     50CTOR_DTOR1 ends
     51
     52CTOR_DTOR2 segment dword public 'DATA' use32
     53CTOR_DTOR2 ends
     54
     55CTOR_DTOR3 segment dword public 'DATA' use32
     56CTOR_DTOR3 ends
    4657
    4758;CONSTGROUP group CONST32_RO, _VFT, EH_DATA
  • branches/Grace/src/win32k/include/log.h

    r2898 r3834  
    1 /* $Id: log.h,v 1.4 2000-02-25 18:15:04 bird Exp $
     1/* $Id: log.h,v 1.4.4.1 2000-07-16 22:43:30 bird Exp $
    22 *
    33 * log - C-style logging - kprintf.
     
    3232#define dprintf kprintf
    3333#if defined(DEBUG) && !defined(NOLOGGING)
    34     #ifndef INCL_16
     34    #ifdef INCL_16
     35        /* 16-bit */
     36        #include "vprntf16.h"
     37        #define kprintf(a)          printf16 a
     38        #define printf this function is not used in 16-bit code! Use printf16!
     39    #else
    3540        /* 32-bit */
    3641        #include <stdarg.h>
    3742        #include "vprintf.h"
    3843        #define kprintf(a)          printf a
    39     #else
    40         /* 16-bit */
    41         #include "vprntf16.h"
    42         #define kprintf(a)          printf16 a
    4344    #endif
    4445#else
    45     #define kprintf(a)              (void)0
     46    #define kprintf(a)              ((void)0)
    4647#endif
    4748
  • branches/Grace/src/win32k/include/macros.h

    r3485 r3834  
    1 /* $Id: macros.h,v 1.2 2000-05-03 10:46:07 bird Exp $
     1/* $Id: macros.h,v 1.2.4.1 2000-07-16 22:43:31 bird Exp $
    22 *
    33 * Common macros for Win32k/Elf.
     
    2424#define ALIGN(a, alignment) (((a) + (alignment - 1UL)) & ~(alignment - 1UL))
    2525
     26/*
     27 * Not referenced parameter warning fix.
     28 */
     29#define NOREF(a) (a=a)
    2630
    2731/*
  • branches/Grace/src/win32k/ldr/calltab.asm

    r3411 r3834  
    1 ; $Id: calltab.asm,v 1.12 2000-04-17 01:56:49 bird Exp $
    2 ;
    3 ; callTab - Call back again table - table with entry for each function which is overrided.
    4 ;           It holds the part of the prolog which was replaced by a jmp instruction.
    5 ;
    6 ; Copyright (c) 1998-1999 knut st. osmundsen
     1; $Id: calltab.asm,v 1.12.4.1 2000-07-16 22:43:34 bird Exp $
     2;
     3; callTab - Call back again table - table with entry for each function or
     4;           variable which is overrided.
     5;           It holds the part of the prolog which was replaced by the jmp
     6;           instruction (overridden functions).
     7;
     8; Copyright (c) 1998-2000 knut st. osmundsen
    79;
    810; Project Odin Software License can be found in LICENSE.TXT
     
    3840    public _f_FuBuff
    3941
     42    public _VMObjHandleInfo@12
     43    public _ldrOpenPath@16
     44    public _LDRClearSem@0
     45    public _KSEMRequestMutex@8
     46
     47    public pLDRSem
     48    public LDRSem_offObject
     49    public _fpLDRSem
     50    public LDRSem_sel
     51
     52    public _TKSuBuff@16
     53    public _TKFuBuff@16
     54    public _TKFuBufLen@20
     55    public _ldrValidateMteHandle@4
     56
     57    public ppTCBCur
     58    public pTCBCur_offObject
     59    public _fppTCBCur
     60    public pTCBCur_sel
     61
     62    public ppPTDACur
     63    public pPTDACur_offObject
     64    public _fppPTDACur
     65    public pPTDACur_sel
     66
     67    public pptda_start
     68    public ptda_start_offObject
     69    public _fpptda_start
     70    public ptda_start_sel
     71
     72    public pptda_environ
     73    public ptda_environ_offObject
     74    public _fpptda_environ
     75    public ptda_environ_sel
     76
     77
    4078
    4179;
     
    4785
    4886CALLTAB segment
    49     assume cs:CALLTAB, ds:flat, ss:nothing
     87    ;assume cs:CALLTAB, ds:flat, ss:nothing
     88    assume ds:flat, ss:nothing
    5089;
    5190; callTab is an array of evt. function prologs with a jump to the real function.
     
    5695;
    5796callTab:
     97
     98; 0
    5899_ldrRead@24 PROC NEAR
    59100    db MAXSIZE_PROLOG dup(0cch)
    60101_ldrRead@24 ENDP
    61102
     103; 1
    62104_ldrOpen@12 PROC NEAR
    63105    db MAXSIZE_PROLOG dup(0cch)
    64106_ldrOpen@12 ENDP
    65107
     108; 2
    66109_ldrClose@4 PROC NEAR
    67110    db MAXSIZE_PROLOG dup(0cch)
    68111_ldrClose@4 ENDP
    69112
     113; 3
    70114_LDRQAppType@8 PROC NEAR
    71115    db MAXSIZE_PROLOG dup(0cch)
    72116_LDRQAppType@8 ENDP
    73117
     118; 4
    74119_ldrEnum32bitRelRecs@24 PROC NEAR
    75120    db MAXSIZE_PROLOG dup(0cch)
    76121_ldrEnum32bitRelRecs@24 ENDP
    77122
    78 
     123; 5
    79124_IOSftOpen@20 PROC NEAR
    80125    db MAXSIZE_PROLOG dup(0cch)
    81126_IOSftOpen@20 ENDP
    82127
     128; 6
    83129_IOSftClose@4 PROC NEAR
    84130    db MAXSIZE_PROLOG dup(0cch)
    85131_IOSftClose@4 ENDP
    86132
     133; 7
    87134_IOSftTransPath@4 PROC NEAR
    88135    db MAXSIZE_PROLOG dup(0cch)
    89136_IOSftTransPath@4 ENDP
    90137
     138; 8
    91139_IOSftReadAt@20 PROC NEAR
    92140    db MAXSIZE_PROLOG dup(0cch)
    93141_IOSftReadAt@20 ENDP
    94142
     143; 9
    95144_IOSftWriteAt@20 PROC NEAR
    96145    db MAXSIZE_PROLOG dup(0cch)
    97146_IOSftWriteAt@20 ENDP
    98147
     148; 10
    99149_SftFileSize@8 PROC NEAR
    100150    db MAXSIZE_PROLOG dup(0cch)
    101151_SftFileSize@8 ENDP
    102152
    103 
     153; 11
    104154_VMAllocMem@36 PROC NEAR
    105155    db MAXSIZE_PROLOG dup(0cch)
    106156_VMAllocMem@36 ENDP
    107157
     158; 12
    108159_VMGetOwner@8 PROC NEAR
    109160    db MAXSIZE_PROLOG dup(0cch)
    110161_VMGetOwner@8 ENDP
    111162
     163; 13
    112164_g_tkExecPgm PROC NEAR
    113165    db MAXSIZE_PROLOG dup(0cch)
    114166_g_tkExecPgm ENDP
    115167
    116 
     168; 14
    117169_f_FuStrLenZ PROC FAR
    118170    db MAXSIZE_PROLOG dup(0cch)
    119171_f_FuStrLenZ ENDP
    120172
     173; 15
    121174_f_FuStrLen PROC FAR
    122175    db MAXSIZE_PROLOG dup(0cch)
    123176_f_FuStrLen ENDP
    124177
     178; 16
    125179_f_FuBuff PROC FAR
    126180    db MAXSIZE_PROLOG dup(0cch)
    127181_f_FuBuff ENDP
    128182
     183; 17
    129184_VMObjHandleInfo@12 PROC NEAR
    130185    db MAXSIZE_PROLOG dup(0cch)
    131186_VMObjHandleInfo@12 ENDP
    132187
     188; 18
     189_ldrOpenPath@16 PROC NEAR
     190    db MAXSIZE_PROLOG dup(0cch)
     191_ldrOpenPath@16 ENDP
     192
     193; 19
     194_LDRClearSem@0 PROC NEAR
     195    db MAXSIZE_PROLOG dup(0cch)
     196_LDRClearSem@0 ENDP
     197
     198; 20
     199_KSEMRequestMutex@8 PROC NEAR
     200    db MAXSIZE_PROLOG dup(0cch)
     201_KSEMRequestMutex@8 ENDP
     202
     203; 21
     204pLDRSem          dd  0
     205LDRSem_offObject dd  0
     206_fpLDRSem        dd  0
     207LDRSem_sel       dw  0
     208    db (MAXSIZE_PROLOG - 14) dup(0cch)
     209
     210; 22
     211_TKSuBuff@16 PROC NEAR
     212    db MAXSIZE_PROLOG dup(0cch)
     213_TKSuBuff@16 ENDP
     214
     215; 23
     216_TKFuBuff@16 PROC NEAR
     217    db MAXSIZE_PROLOG dup(0cch)
     218_TKFuBuff@16 ENDP
     219
     220; 24
     221_TKFuBufLen@20 PROC NEAR
     222    db MAXSIZE_PROLOG dup(0cch)
     223_TKFuBufLen@20 ENDP
     224
     225;25
     226_ldrValidateMteHandle@4 PROC NEAR
     227    db MAXSIZE_PROLOG dup(0cch)
     228_ldrValidateMteHandle@4 ENDP
     229
     230; 26
     231ppTCBCur           dd  0
     232pTCBCur_offObject  dd  0
     233_fppTCBCur         dd  0
     234pTCBCur_sel        dw  0
     235    db (MAXSIZE_PROLOG - 14) dup(0cch)
     236
     237; 27
     238ppPTDACur          dd  0
     239pPTDACur_offObject dd  0
     240_fppPTDACur        dd  0
     241pPTDACur_sel       dw  0
     242    db (MAXSIZE_PROLOG - 14) dup(0cch)
     243
     244; 28
     245pptda_start          dd  0
     246ptda_start_offObject dd  0
     247_fpptda_start        dd  0
     248ptda_start_sel       dw  0
     249    db (MAXSIZE_PROLOG - 14) dup(0cch)
     250
     251; 29
     252pptda_environ          dd  0
     253ptda_environ_offObject dd  0
     254_fpptda_environ        dd  0
     255ptda_environ_sel       dw  0
     256    db (MAXSIZE_PROLOG - 14) dup(0cch)
     257
     258
     259
     260
     261
    133262CALLTAB ENDS
    134263
  • branches/Grace/src/win32k/ldr/myLDRQAppType.cpp

    r2501 r3834  
    1 /* $Id: myLDRQAppType.cpp,v 1.3 2000-01-22 18:21:02 bird Exp $
     1/* $Id: myLDRQAppType.cpp,v 1.3.4.1 2000-07-16 22:43:35 bird Exp $
    22 *
    33 * _myLDRQAppType - _LDRQAppType overload.
     
    1515#define INCL_NOPMAPI
    1616
     17#define INCL_OS2KRNL_SEM
     18
    1719/*******************************************************************************
    1820*   Header Files                                                               *
     
    2123
    2224#include "OS2Krnl.h"
     25#include "avl.h"
     26#include "ldr.h"
    2327#include "ldrCalls.h"
    2428#include "log.h"
    2529
    26 BOOL fQAppType = FALSE;
    2730
    2831/**
    29  * LDRQAppType - Loader Query Application Type.
    30  * We set a flag while we're executing this function. Just to speed up processing.
    31  * If a PE file is queried, a dummy LX header is presented.
     32 * LDRQAppType - Loader Query Application Type - DosQueryAppType worker.
     33 *
     34 * We overrides this be able to determin if a convertion is only for a
     35 * LDRQAppType call.
     36 *
     37 * isLdrStateQAppType() returns TRUE when this procedure is on the stack.
     38 *
    3239 * @returns   return code.
    3340 * @param     p1
     
    3845    APIRET rc;
    3946
    40     kprintf(("_LDRQAppType: entry\n"));
    41     fQAppType = 1;
     47    kprintf(("myLDRQAppType: entry\n"));
     48
     49    rc = LDRGetSem();
     50    if (rc != NO_ERROR)
     51    {
     52        kprintf(("myLDRQAppType: failed to get loader semaphore.\n"));
     53        return rc;
     54    }
     55
     56    ASSERT_LdrStateUnknown("myLDRQAppType")
     57    setLdrStateQAppType();
    4258
    4359    rc = LDRQAppType(p1, p2);
    4460
    45     fQAppType = 0;
    46     kprintf(("_LDRQAppType: exit\n"));
     61    ASSERT_LdrStateQAppType("myLDRQAppType")
     62    setLdrStateUnknown();
     63
     64    LDRClearSem();
     65    kprintf(("myLDRQAppType: exit\n"));
    4766
    4867    return rc;
  • branches/Grace/src/win32k/ldr/myldrClose.cpp

    r2501 r3834  
    1 /* $Id: myldrClose.cpp,v 1.5 2000-01-22 18:21:02 bird Exp $
     1/* $Id: myldrClose.cpp,v 1.5.4.1 2000-07-16 22:43:35 bird Exp $
    22 *
    33 * myldrClose - ldrClose
     
    2424
    2525#include "log.h"
     26#include "avl.h"
    2627#include <peexe.h>
    2728#include <exe386.h>
    2829#include "OS2Krnl.h"
    29 #include "avl.h"
    30 #include "ModuleBase.h"
    3130#include "ldr.h"
    3231#include "ldrCalls.h"
     32#include "ModuleBase.h"
    3333
    3434
     
    4242{
    4343    /* closes handle */
    44     kprintf(("ldrClose: hFile = %.4x\n", hFile));
     44    kprintf(("myldrClose: hFile = %.4x\n", hFile));
    4545    if (GetState(hFile) == HSTATE_OUR)
    4646    {
     
    5252            pMod->Data.pModule->dumpVirtualLxFile();
    5353        else
    54             kprintf(("ldrClose: getModuleBySFN failed!!!"));
     54            kprintf(("myldrClose: getModuleBySFN failed!!!"));
    5555        #endif
    5656
    5757        rc = removeModule(hFile);
    5858        if (rc != NO_ERROR)
    59             kprintf(("ldrClose: removeModule retured rc=%d\n", rc));
     59            kprintf(("myldrClose: removeModule retured rc=%d\n", rc));
    6060
    6161        #pragma info(notrd)
  • branches/Grace/src/win32k/ldr/mytkExecPgm.asm

    r2872 r3834  
    1 ; $Id: mytkExecPgm.asm,v 1.10 2000-02-23 16:53:04 bird Exp $
     1; $Id: mytkExecPgm.asm,v 1.10.4.1 2000-07-16 22:43:38 bird Exp $
    22;
    33; mytkExecPgm - tkExecPgm overload
     
    1010
    1111;
     12;   Defined Constants And Macros
     13;
     14CCHFILENAME     EQU 261                 ; The size of the filename buffer
     15CCHARGUMENTS    EQU 1536                ; The size of the argument buffer
     16CCHMAXPATH      EQU CCHFILENAME - 1     ; Max path length
     17
     18;
    1219;   Include files
    1320;
    1421    include devsegdf.inc
    1522
     23
    1624;
    1725;   Imported Functions
    1826;
    1927    extrn  _g_tkExecPgm:PROC
    20     extrn  AcquireBuffer:PROC
    21     extrn  ReleaseBuffer:PROC
    22     extrn  QueryBufferSegmentOffset:PROC
    2328
    2429    ; Scans strings until empy-string is reached.
     
    4550    extrn  _f_FuBuff:PROC
    4651
     52
     53    ; 32-bit memcpy. (see OS2KTK.h)
     54    extrn _TKFuBuff@16:PROC
     55
     56
     57    ;
     58    ; LDR semaphore
     59    ;
     60    extrn  pLDRSem:DWORD
     61    extrn  _KSEMRequestMutex@8:PROC
     62    extrn  _LDRClearSem@0:PROC
     63
     64    ;
     65    ; Loader State
     66    ;
     67    extrn ulLDRState:DWORD
     68
     69    ;
     70    ; Pointer to current executable module.
     71    ;
     72    extrn pExeModule:DWORD
     73
     74    ;
     75    ; DevHlp32
     76    ;
     77    extrn D32Hlp_VirtToLin:PROC
     78
     79
    4780;
    4881;   Exported symbols
    4982;
    5083    public mytkExecPgm
    51 
     84    public tkExecPgmCopyEnv
     85
     86    public fTkExecPgm
     87    public achTkExecPgmFilename
     88    public achTkExecPgmArguments
     89
     90
     91
     92;
     93; Global data
     94;
     95
     96; Filename and arguments buffers + environment pointer
     97; from the tkExecPgm call.
     98;
     99; This data is only valid at isLdrStateExecPgm time
     100; (and you'll have to be behind the loader semaphore of course!)
     101DATA16 SEGMENT
     102fTkExecPgm              db 0            ; 0 - achTkExecPgmFilename and achTkExecPgmArguments is INVALID
     103                                        ; 1 - achTkExecPgmFilename and achTkExecPgmArguments is VALID.
     104achTkExecPgmFilename    db CCHFILENAME dup (0)  ; The filename  passed in to tkExecPgm if (fTkExec is TRUE)
     105achTkExecPgmArguments   db CCHARGUMENTS dup (0) ; The arguments passed in to tkExecPgm if (fTkExec is TRUE)
     106fpachTkExecPgmEnv       dd 0            ; Far pointer to environment passed in to tkExecPgm.
     107                                        ; Valid at isLdrStateExecPgm time.
     108                                        ; NOTE! User data, don't touch it directly!
     109DATA16 ENDS
    52110
    53111
    54112CODE32 SEGMENT
    55 
    56113;;
    57 ;
     114; New implementation.
    58115; @returns   same as tkExecPgm: eax, edx and carry flag
    59116; @param     ax     Exec flag
     
    65122;            may modify later if this is a UNIX shellscript or
    66123;            a PE-file started by pe.exe.
    67 ; @status
     124; @status    completely implemented.
    68125; @author    knut st. osmundsen (knut.stange.osmundsen@pmsc.no)
    69 ; @remark
    70 ;
    71 ;   The buffer we are using is a C struct as follows.
    72 ;   struct Buffer
    73 ;   {
    74 ;       char szFilename[261];  /* offset 0   */
    75 ;       char achArg[1536-261]; /* offset 261 */
    76 ;   };
     126;
    77127;
    78128mytkExecPgm PROC FAR
    79 pBuffer     = dword ptr -04h
    80 SegBuffer   = -08h
    81 OffBuffer   = -0Ch
    82 cchFilename = dword ptr -10h
    83 cchArgs     = dword ptr -14h
    84 ;usExecFlag  = -18h
    85 ;SegFilename = -1ch
    86 ;OffFilename = -1eh
    87 ;SegEnv      = -20h
    88 ;OffEnv      = -22h
    89 ;SegArg      = -24h
    90 ;OffArg      = -26h
    91 
    92     ASSUME CS:CODE32, DS:NOTHING, SS:NOTHING
    93 ;    int     3
    94     push    ebp
    95     mov     ebp, esp
    96     lea     esp, [ebp + cchArgs]
    97 
    98     push    eax
    99     push    ecx
    100     push    ds
    101     push    es
    102     push    edi
    103 
    104     ; parameter validations
    105     mov     ax, ds                      ; pointer to filename
    106     cmp     ax, 4
    107     jb      mytkExecPgm_CalltkExecPgm_X1
    108 
    109     ;
    110     ; filename length
    111     ;
    112     mov     ax, ds
    113     mov     es, ax
    114     pushad
    115     push    es
    116     push    ds
    117     mov     bx, ds
    118     mov     di, dx                      ; es:di is now filename address (ds:dx).
    119     push    cs                          ; Problem calling far into the calltab segement.
    120     call    near ptr FLAT:_f_FuStrLen
    121     movzx   ecx, cx
    122     mov     [ebp+cchFilename], ecx
    123     pop     ds
    124     pop     es
    125     popad
    126     jc      mytkExecPgm_CalltkExecPgm_X1; If the FuStrLen call failed we bail out!
    127 
    128     ;
    129     ; if filename length is more that CCHMAXPATH then we don't do anything!.
    130     ;
    131     cmp     [ebp+cchFilename], 260
    132     jae     mytkExecPgm_CalltkExecPgm_X1; length >= 260
    133 
    134     ;
    135     ; args length
    136     ; Note: the arguments are a series of ASCIIZs ended by an empty string (ie. '\0').
    137     ;
    138     pop     edi
    139     push    edi
    140     xor     ecx, ecx
    141     cmp     di, 4                       ; The argument might me a invalid pointer...
    142     jb      mytkExecPgm_CalltkExecPgm_1
    143 
    144     pushad
    145     push    es
    146     push    ds
    147     mov     bx, di                      ;
    148     mov     di, si                      ; bx:di -> arguments
    149     push    cs                          ; Problem calling far into the calltab segement.
    150     call    near ptr FLAT:_f_FuStrLenZ
    151     movzx   ecx, cx
    152     mov     [ebp+cchArgs], ecx
    153     pop     ds
    154     pop     es
    155     popad
    156     jc      mytkExecPgm_CalltkExecPgm_X1
    157 
    158 mytkExecPgm_CalltkExecPgm_1:
    159     mov     ecx, [ebp+cchArgs]
    160     add     ecx, [ebp+cchFilename]      ; filename
    161     add     ecx, 3 + 260                ;  260 = new argument from a scrip file or something.
    162                                         ;    3 = two '\0's and a space after added argument.
    163     cmp     ecx, 1536                   ; 1536 = Buffersize.  FIXME! Define this!!!
    164     jae     mytkExecPgm_CalltkExecPgm_X1; jmp if argument + file + new file > buffer size
    165 
    166     ;
    167     ; Aquire a buffer
    168     ;
    169     call    AcquireBuffer
    170     or      eax, eax
    171     jz      mytkExecPgm_CalltkExecPgm_X1; Failed to get buffer.
    172     mov     [ebp+pBuffer], eax
    173 
    174     ;
    175     ; Get Segment and offset for the buffer
    176     ;
    177     call    QueryBufferSegmentOffset
    178     mov     cx, es
    179     mov     [ebp+OffBuffer], ax
    180     mov     [ebp+SegBuffer], es
    181     test    eax, 000570000h
    182     jnz     mytkExecPgm_CalltkExecPgm_X2
    183 
    184     ;
    185     ; Copy filename to pBuffer.
    186     ;
    187     pushad
    188     push    es
    189     push    ds
    190     mov     di, ax                      ; es:di  pBuffer
    191     mov     si, dx
    192     mov     bx, ds                      ; bx:si  Filename pointer (input ds:dx)
    193     mov     ecx, [ebp+cchFilename]
    194     push    cs                          ; Problem calling far into the calltab segement.
    195     call    near ptr FLAT:_f_FuBuff
    196     pop     ds
    197     pop     es
    198     popad
    199     jc      mytkExecPgm_CalltkExecPgm_X2
    200 
    201     ;
    202     ; Copy Args to pBuffer + 261
    203     ;
    204     ; stack: edi, es, ds, ecx, eax
    205     pop     edi
    206     push    edi
    207     add     eax, 261                    ; we'll use eax in the branch
    208     cmp     di, 4
    209     jb      mytkExecPgm_CalltkExecPgm_2
    210     pushad
    211     push    es
    212     push    ds
    213     mov     ecx, [ebp+cchArgs]
    214     mov     bx, di                      ; ds:si -> arguments
    215     mov     di, ax                      ; es:di -> buffer + 261
    216     push    cs                          ; Problem calling far into the calltab segement.
    217     call    near ptr FLAT:_f_FuBuff
    218     pop     ds
    219     pop     es
    220     popad
    221     jc      mytkExecPgm_CalltkExecPgm_X2
    222     jmp     mytkExecPgm_CalltkExecPgm_3
    223 
    224 mytkExecPgm_CalltkExecPgm_2:
    225     mov     word ptr es:[eax], 0        ; Terminate the empty string!
    226 
    227     ;
    228     ; Restore variables pushed on the stack
    229     ;
    230     ; stack: edi, es, ds, ecx, eax
    231 mytkExecPgm_CalltkExecPgm_3:
    232     pop     edi
    233     pop     es
    234     pop     ds
    235     pop     ecx
    236     pop     eax
    237 
    238     ;
    239     ; Set new input parameters (call _g_tkExecPgm)
    240     ;
    241     ; ds:dx is to become SegBuffer:OffBuffer
    242     ; di:si is to become SegBuffer:OffBuffer+261
    243     ;
    244     ; The some of the old values are stored on the stack (for the time being)
    245     push    ds
    246     push    edi
    247     push    esi
    248 
    249     mov     di, [ebp+SegBuffer]
    250     mov     ds, di
    251     mov     si, [ebp+OffBuffer]
    252     mov     dx, si                      ; ds:dx  SegBuffer:OffBuffer
    253     add     si, 261                     ; di:si  SegBuffer:OffBuffer+261
    254 
    255     ;
    256     ; Call _g_tkExecPgm
    257     ;
    258     push    cs                          ; Problem calling far into the calltab segement.
    259     call    near ptr FLAT:_g_tkExecPgm
    260     pushfd
    261 
    262     ;
    263     ; Release buffer
    264     ;
    265     push    eax
    266     mov     eax, [ebp + pBuffer]
    267     call    ReleaseBuffer
    268     mov     [ebp + pBuffer], 0
    269     pop     eax
    270 
    271     ;
    272     ; Return
    273     ;
    274     popfd
    275     pop     esi
    276     pop     edi
    277     pop     ds
    278     leave
    279     retf
    280 
    281 mytkExecPgm_CalltkExecPgm_X2:
    282     ;
    283     ; Release buffer
    284     ;
    285     mov     eax, [ebp + pBuffer]
    286     call    ReleaseBuffer
    287     mov     [ebp + pBuffer], 0
    288 
    289 mytkExecPgm_CalltkExecPgm_X1:
    290     pop     edi
    291     pop     es
    292     pop     ds
    293     pop     ecx
    294     pop     eax
    295 
    296 mytkExecPgm_CalltkExecPgm:
    297     push    cs
    298     call    near ptr FLAT:_g_tkExecPgm
    299     leave
    300     retf
    301 mytkExecPgm ENDP
    302 
    303 
    304 
    305 CODE32 ENDS
    306 
    307 if 0 ; alternate implementation.
    308 mytkExecPgm PROC FAR
    309 pBuffer     = dword ptr -04h
    310 SegBuffer   = -08h
    311 OffBuffer   = -0Ch
    312 cchFilename = -10h
    313 cchArgs     = -14h
    314 usExecFlag  = -18h
    315 SegFilename = -1ch
    316 OffFilename = -1eh
    317 SegEnv      = -20h
    318 OffEnv      = -22h
    319 SegArg      = -24h
    320 OffArg      = -26h
     129cchFilename = -4h
     130cchArgs     = -08h
     131usExecFlag  = -0ch
     132SegFilename = -10h
     133OffFilename = -12h
     134SegEnv      = -14h
     135OffEnv      = -16h
     136SegArg      = -18h
     137OffArg      = -1ah
    321138
    322139    ASSUME CS:CODE32, DS:NOTHING, SS:NOTHING
     
    325142    lea     esp, [ebp + OffArg]
    326143
    327     ; save input parameters
     144    ;
     145    ; Save input parameters
     146    ;
    328147    mov     [ebp + usExecFlag], ax
    329148    mov     ax, es
     
    332151    mov     [ebp + SegArg], di
    333152    mov     [ebp + OffArg], si
    334     mov     ax, ds
    335     mov     [ebp + SegFilename], ax
     153    mov     bx, ds
     154    mov     [ebp + SegFilename], bx
    336155    mov     [ebp + OffFilename], dx
    337156
    338     ; parameter validations
    339     cmp     ax, 4                       ; pointer to filename
    340     jb      mytkExecPgm_CalltkExecPgm_X1
    341 
    342     ;
    343     ; filename length
    344     ;
    345     mov     bx, ax
     157    ;
     158    ; Parameter validations - if any of these fail we'll just pass on to
     159    ; the real tkExecPgm without setting up any buffers stuff.
     160    ; 1) validate the file pointer.
     161    ; 2) validate the file name length < 260
     162    ; 3) validate that the arguments aren't larger than the buffer.
     163    ;
     164
     165    ; Validate filename pointer
     166    ;
     167    cmp     bx, 4                       ; pointer to filename
     168    jb      tkepgm_backout
     169
     170    ; Validate filename length
     171    ;
    346172    mov     di, dx                      ; bx:di is now filename address
    347173    push    cs                          ; Problem calling far into the calltab segement.
    348174    call    near ptr FLAT:_f_FuStrLen
    349     jc      mytkExecPgm_CalltkExecPgm_X1; If the FuStrLen call failed we bail out!
    350 
    351     ;
     175    jc      tkepgm_backout              ; If the FuStrLen call failed we bail out!
     176
    352177    ; if filename length is more that CCHMAXPATH then we don't do anything!.
    353     ;
    354     cmp     cx, 260
    355     jae     mytkExecPgm_CalltkExecPgm_X1; length >= 260
    356     mov     [ebp+cchFilename], cx
     178    cmp     cx, CCHMAXPATH
     179    jae     tkepgm_backout              ; length >= CCHMAXPATH
     180    mov     [ebp + cchFilename], cx
    357181
    358182    ;
     
    360184    ; Note: the arguments are a series of ASCIIZs ended by an empty string (ie. '\0').
    361185    ;
    362     mov     bx, [ebp+SegArg]
     186    xor     cx, cx                      ; Set length to zero.
     187    mov     bx, [ebp + SegArg]
    363188    cmp     bx, 4                       ; The argument might me an NULL pointer
    364     xor     cx, cx
    365     jb      mytkExecPgm_CalltkExecPgm_1
    366 
    367     mov     di, [ebp+OffArg]            ; bx:di -> arguments
     189    jb      tkepgm1
     190
     191    mov     di, [ebp + OffArg]          ; bx:di -> arguments
    368192    push    cs                          ; Problem calling far into the calltab segement.
    369193    call    near ptr FLAT:_f_FuStrLenZ
    370     mov     [ebp+cchArgs], cx
    371     jc      mytkExecPgm_CalltkExecPgm_X1
    372 
    373 mytkExecPgm_CalltkExecPgm_1:
    374     add     cx, [ebp+cchFilename]       ; filename length
    375     add     cx, 3 + 260                 ;  260 = new argument from a scrip file or something.
     194    jc      tkepgm_backout
     195
     196tkepgm1:
     197    mov     [ebp + cchArgs], cx
     198    add     cx, [ebp + cchFilename]     ; filename length
     199    add     cx, 3 + 260                 ;  260 = additional arguments from a script file or something.
    376200                                        ;    3 = two '\0's and a space after added argument.
    377     cmp     ecx, 1536                   ; 1536 = Buffersize.  FIXME! Define this!!!
    378     jae     mytkExecPgm_CalltkExecPgm_X1; jmp if argument + file + new file > buffer size
    379 
    380     ;
    381     ; Aquire a buffer
    382     ;
    383     call    AcquireBuffer
    384     mov     [ebp+pBuffer], eax
    385     or      eax, eax
    386     jz      mytkExecPgm_CalltkExecPgm_X1; Failed to get buffer.
    387 
    388     ;
    389     ; Get Segment and offset for the buffer
    390     ;
    391     call    QueryBufferSegmentOffset
    392     mov     cx, es
    393     mov     [ebp+OffBuffer], ax
    394     mov     [ebp+SegBuffer], es
    395     test    eax, 000570000h
    396     jnz     mytkExecPgm_CalltkExecPgm_X2
    397 
    398     ;
    399     ; Copy filename to pBuffer.
    400     ;
    401     mov     di, ax                      ; es:di  pBuffer
    402     mov     si, dx
    403     mov     bx, ds                      ; bx:si  Filename pointer (input ds:dx)
    404     mov     cx, [ebp+cchFilename]       ; cx = length of area to copy
     201    cmp     ecx, CCHARGUMENTS           ; argument Buffersize.
     202    jae     tkepgm_backout              ; jmp if argument + file + additional arguments >= buffer size
     203
     204
     205    ;
     206    ; Aquire the OS/2 loader semaphore
     207    ;   Since parameters looks good, we're ready for getting the loader semaphore.
     208    ;   We use the loader semaphore to serialize access to the win32k.sys loader
     209    ;   subsystem.
     210    ;   Before we can get the loader semaphore, we'll need to set ds and es to
     211    ;   flat R0 context.
     212    ;   The loader semaphore is later requested by the original tkExecPgm so
     213    ;   this shouldn't break anything.
     214    ;
     215    mov     ax, seg FLAT:DATA32
     216    mov     ds, ax
     217    mov     es, ax
     218    ASSUME  DS:FLAT, ES:FLAT
     219
     220    mov     eax, pLDRSem                ; Load pointer to pLDRSem
     221    or      eax, eax                    ; Check NULL pointer.
     222    je      tkepgm_backout              ; BACKOUT on NULL pointer. (paranoia)
     223
     224    push    0ffffffffh                  ; Wait indefinitely.
     225    push    dword ptr [eax]             ; LDRSem handle.
     226    call    near ptr FLAT:_KSEMRequestMutex@8
     227    or      eax, eax                    ; Check if failed.
     228    jnz     tkepgm_backout              ; Backout on failure.
     229
     230
     231    ;
     232    ; From here on we won't backout to the tkepgm_backout lable but
     233    ; the tkepgm_backout2 lable. (This will restore the parameters
     234    ; and jump in at the call to tkExecPgm behind the Loader Sem.)
     235    ;
     236
     237
     238    ;
     239    ; Set global data:
     240    ;   Zeros pointer to exemodule to NULL (a bit paranoia).
     241    ;   Mark global data valid.
     242    ;   Store Environment pointer.
     243    ;   Set loader state.
     244    ;
     245    mov     pExeModule, 0               ; Sets the exemodule pointer to NULL.
     246    mov     fTkExecPgm, 1               ; Optimistic, mark the global data valid.
     247    mov     eax, [ebp + OffEnv]         ; Environment FAR pointer.
     248    mov     fpachTkExecPgmEnv, eax      ; Store the Environment pointer. This will
     249                                        ; later permit us to get the passed in
     250                                        ; environment in for ex. ldrOpenPath.
     251    mov     ulLDRState, 1               ; Set the loader state to LDRSTATE_TKEXECPGM!
     252    ASSUME  DS:NOTHING, ES:NOTHING
     253
     254
     255    ;
     256    ; Copy filename to achBuffer.
     257    ;
     258    mov     di, seg achTkExecPgmFilename
     259    mov     es, di
     260    mov     edi, offset achTkExecPgmFilename
     261                                        ; es:(e)di -> &achTkExecPgmFilename[0]
     262    mov     si, [ebp + OffFilename]
     263    mov     bx, [ebp + SegFilename]     ; bx:si  Filename pointer (input ds:dx)
     264    ASSUME DS:NOTHING
     265    mov     cx, [ebp + cchFilename]     ; cx = length of area to copy
    405266    push    cs                          ; Problem calling far into the calltab segement.
    406267    call    near ptr FLAT:_f_FuBuff
    407     jc      mytkExecPgm_CalltkExecPgm_X2
    408 
    409     ;
    410     ; Copy Args to pBuffer + 261
    411     ;
    412     mov     si, [ebp+SegArg]
    413     cmp     si, 4
    414     jb      mytkExecPgm_CalltkExecPgm_2
    415     mov     ds, si
    416     mov     si, [ebp+OffArg]            ; ds:si -> arguments
    417     mov     di, [ebp+SegBuffer]
     268    jc      tkepgm_backout2             ; In case of error back (quite unlikely).
     269
     270
     271    ;
     272    ; Copy Args to achTkExecPgmArguments
     273    ;
     274    mov     di, seg achTkExecPgmArguments
    418275    mov     es, di
    419     mov     di, [ebp+OffBuffer]
    420     add     di, 261                     ; es:di -> buffer + 261
    421     mov     cx, [ebp+cchArgs]           ; cx = length of area to copy
     276    mov     edi, offset achTkExecPgmArguments
     277                                        ; es:(e)di -> &achTkExecPgmArguments[0]
     278    mov     word ptr es:[edi], 0        ; Terminate the argument string in case
     279                                        ; there aren't any arguments.('\0\0')
     280                                        ; (We're just about to find that out.)
     281    mov     bx, [ebp + SegArg]
     282    cmp     bx, 4                       ; Is the argument pointer a null-pointer?
     283    jb      tkepgm_setup_parms          ; Skip copy if null pointer.
     284                                        ; Argument string is '\0\0'.
     285    mov     si, [ebp + OffArg]          ; bx:si -> arguments
     286    mov     cx, [ebp + cchArgs]         ; cx = length of area to copy
    422287    push    cs                          ; Problem calling far into the calltab segement.
    423288    call    near ptr FLAT:_f_FuBuff
    424     jc      mytkExecPgm_CalltkExecPgm_X2
    425     jmp     mytkExecPgm_CalltkExecPgm_3
    426 
    427 mytkExecPgm_CalltkExecPgm_2:
    428     mov     word ptr es:[eax], 0        ; Terminate the empty string!
    429 
    430     ;
    431     ; Set new input parameters (call _g_tkExecPgm)
    432     ;
    433     ; ds:dx is to become SegBuffer:OffBuffer
    434     ; di:si is to become SegBuffer:OffBuffer+261
    435     ;
    436 mytkExecPgm_CalltkExecPgm_3:
    437     mov     di, [ebp+SegBuffer]
    438     mov     ds, di
    439     mov     si, [ebp+OffBuffer]
    440     mov     dx, si                      ; ds:dx  SegBuffer:OffBuffer
    441     add     si, 261                     ; di:si  SegBuffer:OffBuffer+261
    442     mov     bx, [ebp+SegEnv]
     289    jc      tkepgm_backout2             ; In case of error back (quite unlikely).
     290
     291
     292    ;
     293    ; Setup new input parameters (call _g_tkExecPgm)
     294    ;
     295    ; ds:dx is to become &achTkExecPgmFilename[0]
     296    ; di:si is to become &achTkExecPgmArguments[0]
     297    ;
     298tkepgm_setup_parms:
     299    mov     ax, [ebp + usExecFlag]
     300    mov     di, seg achTkExecPgmArguments
     301    mov     esi, offset achTkExecPgmArguments ; di:si  &achTkExecPgmArguments[0]
     302    mov     ds, di                            ; Assumes same segment (which of course is true).
     303    mov     edx, offset achTkExecPgmFilename  ; ds:dx  &achTkExecPgmFilename[0]
     304    mov     bx, [ebp + SegEnv]
    443305    mov     es, bx
    444     mov     bx, [ebp+SegEnv]
     306    mov     bx, [ebp + OffEnv]                ; es:bx  Environment
     307
    445308
    446309    ;
    447310    ; Call _g_tkExecPgm
    448311    ;
     312tkepgm_callbehind:
    449313    push    cs                          ; Problem calling far into the calltab segement.
    450314    call    near ptr FLAT:_g_tkExecPgm
     
    452316
    453317    ;
    454     ; Release buffer
    455     ;
    456     push    eax
    457     mov     eax, [ebp + pBuffer]
    458     call    ReleaseBuffer
    459     mov     [ebp + pBuffer], 0
    460     pop     eax
    461 
    462     ;
    463     ; Return
    464     ;
    465     push    [ebp + SegFilename]
     318    ; Clear loader semaphore.
     319    ;
     320    push    eax                         ; preserve result.
     321    push    ecx                         ; preserve ecx just in case
     322    push    edx                         ; preserve edx just in case
     323    mov     ax, seg FLAT:DATA32
     324    mov     ds, ax
     325    mov     es, ax
     326    ASSUME  ds:FLAT, es:FLAT
     327    call    near ptr FLAT:_LDRClearSem@0
     328    pop     edx                         ; restore edx
     329    pop     ecx                         ; restore ecx
     330    pop     eax                         ; restore result.
     331
     332    ;
     333    ; Clear loader state, current exe module and tkExecPgm global data flag.
     334    ;
     335    mov     ulLDRState, 0               ; Clears loaderstate. (LDRSTATE_UNKNOWN)
     336    mov     pExeModule, 0               ; Sets the exemodule pointer to NULL.
     337    mov     fTkExecPgm, 0               ; Marks global data invalid.
     338
     339    ;
     340    ; Restore ds and es (probably unecessary but...) and Return
     341    ;
     342    push    dword ptr [ebp + SegFilename]
    466343    pop     ds
    467     push    [ebp + SegEnv]
     344    push    dword ptr [ebp + SegEnv]
    468345    pop     es
    469346    popfd
     
    471348    retf
    472349
    473 mytkExecPgm_CalltkExecPgm_X2:
    474     ;
    475     ; Release buffer
    476     ;
    477     mov     eax, [ebp + pBuffer]
    478     call    ReleaseBuffer
    479     mov     [ebp + pBuffer], 0
    480 
    481 mytkExecPgm_CalltkExecPgm_X1:
    482     pop     ds
     350
     351;
     352; This is a backout were tkExecPgm probably will backout and we're
     353; allready behind the loader semaphore.
     354;
     355tkepgm_backout2:
     356    ;
     357    ; Set Flat context and invalidate buffer.
     358    ;
     359    mov     ax, seg FLAT:DATA32
     360    mov     ds, ax
     361    ASSUME ds:FLAT
     362    mov     fTkExecPgm, 0               ; Marks global data invalid.
     363
     364    ;
     365    ; Restore parameters. and call the original tkExecPgm
     366    ;
     367    mov     ax, [ebp + usExecFlag]
     368    mov     dx, [ebp + SegFilename]
     369    mov     ds, dx
     370    mov     dx, [ebp + OffFilename]
     371    mov     bx, [ebp + SegEnv]
     372    mov     es, bx
     373    mov     bx, [ebp + OffEnv]
     374    mov     di, [ebp + SegArg]
     375    mov     si, [ebp + OffArg]
     376    jmp     tkepgm_callbehind
     377
     378
     379;
     380; This is a backout were tkExecPgm too is exspected to back out.
     381;
     382tkepgm_backout:
     383    ;
     384    ; Restore parameters. and call the original tkExecPgm
     385    ;
     386    mov     ax, [ebp + usExecFlag]
     387    mov     dx, [ebp + SegFilename]
     388    mov     ds, dx
     389    mov     dx, [ebp + OffFilename]
     390    mov     bx, [ebp + SegEnv]
     391    mov     es, bx
     392    mov     bx, [ebp + OffEnv]
     393    mov     di, [ebp + SegArg]
     394    mov     si, [ebp + OffArg]
    483395
    484396mytkExecPgm_CalltkExecPgm:
    485     push    cs
     397    push    cs                          ; Problem calling far into the calltab segement.
    486398    call    near ptr FLAT:_g_tkExecPgm
    487399    leave
     
    489401mytkExecPgm ENDP
    490402
     403
     404
     405;;
     406; Function which copies the environment data passed into tkExecPgm
     407; to a given buffer.
     408; @cproto    ULONG _Optlink tkExecPgmCopyEnv(char *pachBuffer, unsigned cchBuffer);
     409; @returns   OS/2 return code - NO_ERROR on success.
     410;            0 on error or no data.
     411; @param     pachBuffer     Pointer to buffer which the environment data is
     412;                           to be copied to.
     413;                           (eax)
     414; @param     cchBuffer      Size of the buffer.
     415;                           (edx)
     416; @uses      eax, edx, ecx
     417; @sketch
     418; @status
     419; @author    knut st. osmundsen (knut.stange.osmundsen@pmsc.no)
     420; @remark
     421tkExecPgmCopyEnv PROC NEAR
     422cchEnv  = -04h
     423    ASSUME ds:FLAT, es:FLAT, ss:NOTHING
     424    push    ebp
     425    mov     ebp, esp
     426    lea     esp, [ebp + cchEnv]
     427
     428    push    ebx
     429    mov     ebx, eax                    ; ebx now holds the buffer pointer.
     430
     431    ;
     432    ; Call tkExecPgmEnvLength to get length and check that pointer is valid.
     433    ;
     434    push    edx
     435    call    tkExecPgmEnvLength
     436    pop     ecx                         ; ecx now holds the buffer length.
     437
     438    cmp     eax, 0
     439    ja      tkepce_ok1
     440    mov     eax, 232                    ; ERROR_NO_DATA
     441    jmp     tkepce_ret                  ; Fail if no data or any other error.
     442
     443tkepce_ok1:
     444    cmp     eax, ecx                    ; (ecx is the buffer size.)
     445    jbe     tkepce_ok2                  ; Fail if buffer too small.
     446    mov     eax, 111                    ; ERROR_BUFFER_OVERFLOW
     447    jmp     tkepce_ret
     448
     449tkepce_ok2:
     450    mov     [ebp + cchEnv], eax         ; Save environment length.
     451
     452
     453    ;
     454    ; Thunk the environment 16-bit far pointer to 32-bit.
     455    ;
     456    mov     eax, fpachTkExecPgmEnv
     457    call    D32Hlp_VirtToLin
     458    or      eax, eax                    ; check if thunking were successful.
     459    jnz     tkepce_ok3                  ; Jump if success.
     460    mov     eax, edx                    ; A special feature for D32Hlp_VirtToLin is that edx
     461                                        ; have the error code in case on failure.
     462    jmp tkepce_ret
     463
     464tkepce_ok3:
     465    ;
     466    ; Copy the environment data.
     467    ;
     468    push    3                           ; Fatal if error.
     469    push    dword ptr [ebp + cchEnv]    ; Number of bytes to copy
     470    push    eax                         ; Source buffer pointer. (user)
     471    push    ebx                         ; Target buffer pointer.
     472    call    near ptr FLAT:_TKFuBuff@16
     473
     474tkepce_ret:
     475    pop     ebx
     476    leave
     477    ret
     478tkExecPgmCopyEnv ENDP
     479
     480
     481
     482;;
     483; This function gets the length of the tkExecPgm environment data.
     484; @cproto    ULONG _Optlink tkExecPgmEnvLength(void);
     485; @returns   Environment data length in bytes.
     486; @uses      eax, edx, ecx
     487; @sketch
     488; @status
     489; @author    knut st. osmundsen (knut.stange.osmundsen@pmsc.no)
     490; @remark
     491tkExecPgmEnvLength PROC NEAR
     492    ASSUME ds:FLAT, es:FLAT, ss:NOTHING
     493    push    ebp
     494    mov     ebp, esp
     495
     496    ;
     497    ; Push register which needs to be presered.
     498    ;
     499    push    es
     500    push    ds
     501    push    esi
     502    push    edi
     503    push    ebx
     504
     505
     506    ;
     507    ; Check that the data is valid.
     508    ;
     509    cmp     ulLDRState, 1               ; LDRSTATE_TKEXECPGM
     510    jnz     tkepel_err_ret
     511
     512
     513    ;
     514    ; Check if the environment pointer is NULL.
     515    ;
     516    mov     ebx, fpachTkExecPgmEnv
     517    ror     ebx, 16
     518    cmp     bx, 4
     519    jb      tkepel_err_ret
     520
     521
     522tkepel1:
     523    ;
     524    ; Get the environment length
     525    ;
     526    mov     edi, ebx
     527    ror     edi, 16                     ; bx:di -> [fpachTkExecPgmEnv]
     528    xor     ecx, ecx
     529    push    cs                          ; Problem calling far into the calltab segement.
     530    call    near ptr FLAT:_f_FuStrLenZ
     531    jc      tkepel_err_ret
     532    movzx   eax, cx
     533    jmp     tkepel_ret
     534
     535
     536; Failure
     537tkepel_err_ret:
     538    xor     eax, eax
     539
     540
     541; Return
     542tkepel_ret:
     543    pop     ebx                         ; restore registers
     544    pop     edi
     545    pop     esi
     546    pop     ds
     547    pop     es
     548    leave
     549    ret
     550tkExecPgmEnvLength ENDP
     551
     552
     553
     554
     555
    491556CODE32 ENDS
    492 endif
    493557
    494558
  • branches/Grace/src/win32k/libconv.c

    r1678 r3834  
    1 /* $Id: libconv.c,v 1.2 1999-11-10 01:45:29 bird Exp $
     1/* $Id: libconv.c,v 1.2.4.1 2000-07-16 22:43:19 bird Exp $
    22 *
    33 * Very simple OMF/LIB dumper.
     
    174174                "TEXT",     "CODE16",
    175175                "_TEXT",    "CODE16",
     176                "_IOSEG",   "CODE16",
     177                "IOSEG_CODE", "CODE",
    176178                "DATA",     "FAR_DATA",
    177179                "_DATA",    "DATA16",
  • branches/Grace/src/win32k/misc/buffer.asm

    r2838 r3834  
    1 ; $Id: buffer.asm,v 1.5 2000-02-21 09:24:02 bird Exp $
    2 ;
    3 ; Simple resident buffer for use when overloading tkExecPgm.
     1; $Id: buffer.asm,v 1.5.4.1 2000-07-16 22:43:39 bird Exp $
     2;
     3; Simple resident buffer for use when overloading tkExecPgm - obsolete!
    44;
    55; Copyright (c) 2000 knut st. osmundsen
     
    1313;   Defined Constants And Macros
    1414;
    15 NBR_BUFFERS     EQU 20
     15NBR_BUFFERS     EQU 2
    1616BUFFER_SIZE     EQU 1536
    1717
  • branches/Grace/src/win32k/misc/malloc.c

    r2511 r3834  
    1 /* $Id: malloc.c,v 1.6 2000-01-24 18:19:00 bird Exp $
     1/* $Id: malloc.c,v 1.6.4.1 2000-07-16 22:43:40 bird Exp $
    22 *
    33 * Common Heap - this forwards to the swappable heap!
     
    2828*  Global data
    2929******************************************************************************/
    30 #ifndef RING0
     30#if !defined(RING0) || defined(R3TST)
    3131    char           fInited;       /* init flag */
    3232#endif
     
    5353    if (rc != 0)
    5454        return rc;
    55     #ifdef RING3
     55    #if !defined(RING0) || defined(R3TST)
    5656        fInited = TRUE;
    5757    #endif
     
    6969void * malloc(unsigned cbSize)
    7070{
     71    #ifdef R3TST
     72    if (!fInited)
     73    {
     74        PVOID pv;
     75        if (!DosAllocMem(&pv, cbSize, PAG_WRITE | PAG_READ | PAG_COMMIT)) /* no SSToDS! */
     76            return pv;
     77        else
     78            return NULL;
     79    }
     80    #endif
    7181    return smalloc(cbSize);
    7282}
     
    8191void *realloc(void *pv, unsigned cbNew)
    8292{
     93    #ifdef R3TST
     94    if (!fInited)
     95        Int3();
     96    #endif
    8397    return srealloc(pv, cbNew);
    8498}
     
    91105void free(void *pv)
    92106{
     107    #ifdef R3TST
     108    if (!fInited) /* controlled leak! */
     109       return;
     110    #endif
    93111    sfree(pv);
    94112}
     
    154172
    155173
     174
    156175#if !defined(RING0) && defined(__IBMC__)
    157176
     
    162181int _rmem_init(void)
    163182{
    164     int rc = heapInit(CB_RES_INIT, CB_RES_MAX, CB_SWP_INIT, CB_SWP_MAX);
     183    int rc;
     184    rc = heapInit(CB_RES_INIT, CB_RES_MAX, CB_SWP_INIT, CB_SWP_MAX);
    165185    return rc;
    166186}
Note: See TracChangeset for help on using the changeset viewer.