Changeset 3834 for branches/Grace/src
- Timestamp:
- Jul 17, 2000, 12:43:41 AM (25 years ago)
- 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:02bird Exp $1 ; $Id: d32hlp.asm,v 1.3.4.1 2000-07-16 22:43:25 bird Exp $ 2 2 ; 3 3 ; d32hlp - 32-bit Device Driver Helper Function. … … 34 34 ; extrns 35 35 ; 36 extrn _Device_Help:dword36 extrn _Device_Help:dword 37 37 38 38 ;CODE32 segment … … 42 42 43 43 ;PVOID D32HLPCALL D32Hlp_VirtToLin(ULONG ulPtr16); /* eax */ 44 ; Sideeffect: edx holds the error code on error. 44 45 D32Hlp_VirtToLin proc near 45 46 push esi … … 51 52 Thunk32_VirtToLin:: 52 53 jnc Finished 54 mov edx, eax 53 55 xor eax, eax 54 56 … … 61 63 ;PVOID D32HLPCALL D32Hlp_VirtToLin2(USHORT usSelector, /* ax */ 62 64 ; ULONG ulOffset); /* edx */ 65 ; Sideeffect: edx holds the error code on error. 63 66 D32Hlp_VirtToLin2 proc near 64 67 push esi … … 69 72 Thunk32_VirtToLin2:: 70 73 jnc Finished 74 mov edx, eax 71 75 xor eax, eax 72 76 -
branches/Grace/src/win32k/include/ModuleBase.h
r2925 r3834 1 /* $Id: ModuleBase.h,v 1.3 2000-02-27 02:16:43bird Exp $1 /* $Id: ModuleBase.h,v 1.3.4.1 2000-07-16 22:43:26 bird Exp $ 2 2 * 3 3 * ModuleBase - Declaration of the Basic module class. 4 4 * 5 * Copyright (c) 1999 knut st. osmundsen5 * Copyright (c) 1999-2000 knut st. osmundsen 6 6 * 7 7 * Project Odin Software License can be found in LICENSE.TXT 8 8 * 9 9 */ 10 #ifndef _ MODULEBASE_H_11 #define _ MODULEBASE_H_10 #ifndef _modulebase_h_ 11 #define _modulebase_h_ 12 12 13 13 … … 73 73 * RING0: Map this to ldrRead with 0UL as flFlags. 74 74 * RING3: Implementes this function as a static function, ReadAt. 75 * ReadAtF: Same as ReadAt but two extra parameters; an additional f lag 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. 77 77 * RING0: Map directly to ldrRead. 78 78 * RING3: Map to ReadAt, ignoring the two extra parameters. … … 81 81 #define ReadAt(hFile, ulOffset, pvBuffer, cbToRead) \ 82 82 ldrRead(hFile, ulOffset, pvBuffer, 0UL, cbToRead, NULL) 83 #define ReadAtF(hFile, ulOffset, pvBuffer, cbToRead, flFlags, pMTE) \84 ldrRead(hFile, ulOffset, pvBuffer, f lFlags, cbToRead, pMTE)83 #define ReadAtF(hFile, ulOffset, pvBuffer, fpBuffer, cbToRead, pMTE) \ 84 ldrRead(hFile, ulOffset, pvBuffer, fpBuffer, cbToRead, pMTE) 85 85 #else 86 #define ReadAtF(hFile, ulOffset, pvBuffer, cbToRead, flFlags, pMTE) \86 #define ReadAtF(hFile, ulOffset, pvBuffer, fpBuffer, cbToRead, pMTE) \ 87 87 ReadAt(hFile, ulOffset, pvBuffer, cbToRead) 88 88 #endif … … 96 96 #endif 97 97 98 98 /* 99 * Make sure that pLdrLv is defined. 100 */ 101 #if !defined(RING0) && !defined(_ldrCalls_h_) 102 typedef struct ldrlv_s ldrlv_t; 103 #endif 99 104 100 105 /** … … 112 117 /** @cat Public Main methods */ 113 118 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; 115 120 virtual ULONG applyFixups(PMTE pMTE, ULONG iObject, ULONG iPageTable, PVOID pvPage, 116 121 ULONG ulPageAddress, PVOID pvPTDA); /*(ldrEnum32bitRelRecs)*/ 122 virtual ULONG openPath(PCHAR pachModname, USHORT cchModname, ldrlv_t *pLdrLv, PULONG pfl); /*(ldrOpenPath)*/ 117 123 #ifndef RING0 118 124 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:19bird Exp $1 /* $Id: OS2Krnl.h,v 1.7.4.1 2000-07-16 22:43:27 bird Exp $ 2 2 * 3 3 * OS/2 kernel structures, typedefs and macros. … … 153 153 } MTE,*PMTE,**PPMTE; 154 154 155 typedef USHORT HMTE, *PHMTE; 156 typedef USHORT HPTDA, *PHPTDA; 155 157 156 158 … … 235 237 #define INCL_OS2KRNL_IO 236 238 #define INCL_OS2KRNL_VM 239 #define INCL_OS2KRNL_SEM 240 #define INCL_OS2KRNL_TK 241 #define INCL_OS2KRNL_PTDA 242 #define INCL_OS2KRNL_TCB 237 243 #endif 238 244 … … 245 251 #endif 246 252 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:41bird Exp $1 /* $Id: dev1632.h,v 1.5.4.1 2000-07-16 22:43:28 bird Exp $ 2 2 * dev1632.h - Common header file for 16-bit and 32-bit C 3 3 * … … 50 50 typedef struct _KRNLINFO 51 51 { 52 unsigned long ulBuild; 53 unsigned short fKernel; 52 54 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; 56 56 OTE aObjects[MAXKRNLOBJECTS]; 57 57 } KRNLINFO, FAR * PKRNLINFO; -
branches/Grace/src/win32k/include/dev32.h
r2898 r3834 1 /* $Id: dev32.h,v 1.8 2000-02-25 18:15:04bird Exp $1 /* $Id: dev32.h,v 1.8.4.1 2000-07-16 22:43:28 bird Exp $ 2 2 * 3 3 * dev32 - header file for 32-bit part of the driver. … … 64 64 PMTE _System GetOS2KrnlMTE(void); /* (devfirst.asm) */ 65 65 #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 66 82 67 83 -
branches/Grace/src/win32k/include/devSegDf.inc
r2838 r3834 1 ; $Id: devSegDf.inc,v 1.5 2000-02-21 09:24:00bird Exp $1 ; $Id: devSegDf.inc,v 1.5.4.1 2000-07-16 22:43:28 bird Exp $ 2 2 ; 3 3 ; Segment definitions for win32k.sys. … … 33 33 34 34 ;DGROUP group BSS32, DATA32 35 DGROUP group BSS32, DATA32, CONST32_RO, _VFT, EH_DATA35 DGROUP group CALLTAB, BSS32, DATA32, CONST32_RO, _VFT, c_common, DDE4_DATA32, CTOR_DTOR1, CTOR_DTOR2, CTOR_DTOR3, EH_DATA 36 36 37 37 DATA32 segment dword public 'DATA' use32 … … 41 41 c_common ends 42 42 43 DDE4_DATA32 segment dword public 'DATA' use32 44 DDE4_DATA32 ends 45 43 46 BSS32 segment dword public 'BSS' use32 44 47 BSS32 ends 45 48 49 CTOR_DTOR1 segment dword public 'DATA' use32 50 CTOR_DTOR1 ends 51 52 CTOR_DTOR2 segment dword public 'DATA' use32 53 CTOR_DTOR2 ends 54 55 CTOR_DTOR3 segment dword public 'DATA' use32 56 CTOR_DTOR3 ends 46 57 47 58 ;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:04bird Exp $1 /* $Id: log.h,v 1.4.4.1 2000-07-16 22:43:30 bird Exp $ 2 2 * 3 3 * log - C-style logging - kprintf. … … 32 32 #define dprintf kprintf 33 33 #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 35 40 /* 32-bit */ 36 41 #include <stdarg.h> 37 42 #include "vprintf.h" 38 43 #define kprintf(a) printf a 39 #else40 /* 16-bit */41 #include "vprntf16.h"42 #define kprintf(a) printf16 a43 44 #endif 44 45 #else 45 #define kprintf(a) ( void)046 #define kprintf(a) ((void)0) 46 47 #endif 47 48 -
branches/Grace/src/win32k/include/macros.h
r3485 r3834 1 /* $Id: macros.h,v 1.2 2000-05-03 10:46:07bird Exp $1 /* $Id: macros.h,v 1.2.4.1 2000-07-16 22:43:31 bird Exp $ 2 2 * 3 3 * Common macros for Win32k/Elf. … … 24 24 #define ALIGN(a, alignment) (((a) + (alignment - 1UL)) & ~(alignment - 1UL)) 25 25 26 /* 27 * Not referenced parameter warning fix. 28 */ 29 #define NOREF(a) (a=a) 26 30 27 31 /* -
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 7 9 ; 8 10 ; Project Odin Software License can be found in LICENSE.TXT … … 38 40 public _f_FuBuff 39 41 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 40 78 41 79 ; … … 47 85 48 86 CALLTAB segment 49 assume cs:CALLTAB, ds:flat, ss:nothing 87 ;assume cs:CALLTAB, ds:flat, ss:nothing 88 assume ds:flat, ss:nothing 50 89 ; 51 90 ; callTab is an array of evt. function prologs with a jump to the real function. … … 56 95 ; 57 96 callTab: 97 98 ; 0 58 99 _ldrRead@24 PROC NEAR 59 100 db MAXSIZE_PROLOG dup(0cch) 60 101 _ldrRead@24 ENDP 61 102 103 ; 1 62 104 _ldrOpen@12 PROC NEAR 63 105 db MAXSIZE_PROLOG dup(0cch) 64 106 _ldrOpen@12 ENDP 65 107 108 ; 2 66 109 _ldrClose@4 PROC NEAR 67 110 db MAXSIZE_PROLOG dup(0cch) 68 111 _ldrClose@4 ENDP 69 112 113 ; 3 70 114 _LDRQAppType@8 PROC NEAR 71 115 db MAXSIZE_PROLOG dup(0cch) 72 116 _LDRQAppType@8 ENDP 73 117 118 ; 4 74 119 _ldrEnum32bitRelRecs@24 PROC NEAR 75 120 db MAXSIZE_PROLOG dup(0cch) 76 121 _ldrEnum32bitRelRecs@24 ENDP 77 122 78 123 ; 5 79 124 _IOSftOpen@20 PROC NEAR 80 125 db MAXSIZE_PROLOG dup(0cch) 81 126 _IOSftOpen@20 ENDP 82 127 128 ; 6 83 129 _IOSftClose@4 PROC NEAR 84 130 db MAXSIZE_PROLOG dup(0cch) 85 131 _IOSftClose@4 ENDP 86 132 133 ; 7 87 134 _IOSftTransPath@4 PROC NEAR 88 135 db MAXSIZE_PROLOG dup(0cch) 89 136 _IOSftTransPath@4 ENDP 90 137 138 ; 8 91 139 _IOSftReadAt@20 PROC NEAR 92 140 db MAXSIZE_PROLOG dup(0cch) 93 141 _IOSftReadAt@20 ENDP 94 142 143 ; 9 95 144 _IOSftWriteAt@20 PROC NEAR 96 145 db MAXSIZE_PROLOG dup(0cch) 97 146 _IOSftWriteAt@20 ENDP 98 147 148 ; 10 99 149 _SftFileSize@8 PROC NEAR 100 150 db MAXSIZE_PROLOG dup(0cch) 101 151 _SftFileSize@8 ENDP 102 152 103 153 ; 11 104 154 _VMAllocMem@36 PROC NEAR 105 155 db MAXSIZE_PROLOG dup(0cch) 106 156 _VMAllocMem@36 ENDP 107 157 158 ; 12 108 159 _VMGetOwner@8 PROC NEAR 109 160 db MAXSIZE_PROLOG dup(0cch) 110 161 _VMGetOwner@8 ENDP 111 162 163 ; 13 112 164 _g_tkExecPgm PROC NEAR 113 165 db MAXSIZE_PROLOG dup(0cch) 114 166 _g_tkExecPgm ENDP 115 167 116 168 ; 14 117 169 _f_FuStrLenZ PROC FAR 118 170 db MAXSIZE_PROLOG dup(0cch) 119 171 _f_FuStrLenZ ENDP 120 172 173 ; 15 121 174 _f_FuStrLen PROC FAR 122 175 db MAXSIZE_PROLOG dup(0cch) 123 176 _f_FuStrLen ENDP 124 177 178 ; 16 125 179 _f_FuBuff PROC FAR 126 180 db MAXSIZE_PROLOG dup(0cch) 127 181 _f_FuBuff ENDP 128 182 183 ; 17 129 184 _VMObjHandleInfo@12 PROC NEAR 130 185 db MAXSIZE_PROLOG dup(0cch) 131 186 _VMObjHandleInfo@12 ENDP 132 187 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 204 pLDRSem dd 0 205 LDRSem_offObject dd 0 206 _fpLDRSem dd 0 207 LDRSem_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 231 ppTCBCur dd 0 232 pTCBCur_offObject dd 0 233 _fppTCBCur dd 0 234 pTCBCur_sel dw 0 235 db (MAXSIZE_PROLOG - 14) dup(0cch) 236 237 ; 27 238 ppPTDACur dd 0 239 pPTDACur_offObject dd 0 240 _fppPTDACur dd 0 241 pPTDACur_sel dw 0 242 db (MAXSIZE_PROLOG - 14) dup(0cch) 243 244 ; 28 245 pptda_start dd 0 246 ptda_start_offObject dd 0 247 _fpptda_start dd 0 248 ptda_start_sel dw 0 249 db (MAXSIZE_PROLOG - 14) dup(0cch) 250 251 ; 29 252 pptda_environ dd 0 253 ptda_environ_offObject dd 0 254 _fpptda_environ dd 0 255 ptda_environ_sel dw 0 256 db (MAXSIZE_PROLOG - 14) dup(0cch) 257 258 259 260 261 133 262 CALLTAB ENDS 134 263 -
branches/Grace/src/win32k/ldr/myLDRQAppType.cpp
r2501 r3834 1 /* $Id: myLDRQAppType.cpp,v 1.3 2000-01-22 18:21:02bird Exp $1 /* $Id: myLDRQAppType.cpp,v 1.3.4.1 2000-07-16 22:43:35 bird Exp $ 2 2 * 3 3 * _myLDRQAppType - _LDRQAppType overload. … … 15 15 #define INCL_NOPMAPI 16 16 17 #define INCL_OS2KRNL_SEM 18 17 19 /******************************************************************************* 18 20 * Header Files * … … 21 23 22 24 #include "OS2Krnl.h" 25 #include "avl.h" 26 #include "ldr.h" 23 27 #include "ldrCalls.h" 24 28 #include "log.h" 25 29 26 BOOL fQAppType = FALSE;27 30 28 31 /** 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 * 32 39 * @returns return code. 33 40 * @param p1 … … 38 45 APIRET rc; 39 46 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(); 42 58 43 59 rc = LDRQAppType(p1, p2); 44 60 45 fQAppType = 0; 46 kprintf(("_LDRQAppType: exit\n")); 61 ASSERT_LdrStateQAppType("myLDRQAppType") 62 setLdrStateUnknown(); 63 64 LDRClearSem(); 65 kprintf(("myLDRQAppType: exit\n")); 47 66 48 67 return rc; -
branches/Grace/src/win32k/ldr/myldrClose.cpp
r2501 r3834 1 /* $Id: myldrClose.cpp,v 1.5 2000-01-22 18:21:02bird Exp $1 /* $Id: myldrClose.cpp,v 1.5.4.1 2000-07-16 22:43:35 bird Exp $ 2 2 * 3 3 * myldrClose - ldrClose … … 24 24 25 25 #include "log.h" 26 #include "avl.h" 26 27 #include <peexe.h> 27 28 #include <exe386.h> 28 29 #include "OS2Krnl.h" 29 #include "avl.h"30 #include "ModuleBase.h"31 30 #include "ldr.h" 32 31 #include "ldrCalls.h" 32 #include "ModuleBase.h" 33 33 34 34 … … 42 42 { 43 43 /* closes handle */ 44 kprintf((" ldrClose: hFile = %.4x\n", hFile));44 kprintf(("myldrClose: hFile = %.4x\n", hFile)); 45 45 if (GetState(hFile) == HSTATE_OUR) 46 46 { … … 52 52 pMod->Data.pModule->dumpVirtualLxFile(); 53 53 else 54 kprintf((" ldrClose: getModuleBySFN failed!!!"));54 kprintf(("myldrClose: getModuleBySFN failed!!!")); 55 55 #endif 56 56 57 57 rc = removeModule(hFile); 58 58 if (rc != NO_ERROR) 59 kprintf((" ldrClose: removeModule retured rc=%d\n", rc));59 kprintf(("myldrClose: removeModule retured rc=%d\n", rc)); 60 60 61 61 #pragma info(notrd) -
branches/Grace/src/win32k/ldr/mytkExecPgm.asm
r2872 r3834 1 ; $Id: mytkExecPgm.asm,v 1.10 2000-02-23 16:53:04bird Exp $1 ; $Id: mytkExecPgm.asm,v 1.10.4.1 2000-07-16 22:43:38 bird Exp $ 2 2 ; 3 3 ; mytkExecPgm - tkExecPgm overload … … 10 10 11 11 ; 12 ; Defined Constants And Macros 13 ; 14 CCHFILENAME EQU 261 ; The size of the filename buffer 15 CCHARGUMENTS EQU 1536 ; The size of the argument buffer 16 CCHMAXPATH EQU CCHFILENAME - 1 ; Max path length 17 18 ; 12 19 ; Include files 13 20 ; 14 21 include devsegdf.inc 15 22 23 16 24 ; 17 25 ; Imported Functions 18 26 ; 19 27 extrn _g_tkExecPgm:PROC 20 extrn AcquireBuffer:PROC21 extrn ReleaseBuffer:PROC22 extrn QueryBufferSegmentOffset:PROC23 28 24 29 ; Scans strings until empy-string is reached. … … 45 50 extrn _f_FuBuff:PROC 46 51 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 47 80 ; 48 81 ; Exported symbols 49 82 ; 50 83 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!) 101 DATA16 SEGMENT 102 fTkExecPgm db 0 ; 0 - achTkExecPgmFilename and achTkExecPgmArguments is INVALID 103 ; 1 - achTkExecPgmFilename and achTkExecPgmArguments is VALID. 104 achTkExecPgmFilename db CCHFILENAME dup (0) ; The filename passed in to tkExecPgm if (fTkExec is TRUE) 105 achTkExecPgmArguments db CCHARGUMENTS dup (0) ; The arguments passed in to tkExecPgm if (fTkExec is TRUE) 106 fpachTkExecPgmEnv dd 0 ; Far pointer to environment passed in to tkExecPgm. 107 ; Valid at isLdrStateExecPgm time. 108 ; NOTE! User data, don't touch it directly! 109 DATA16 ENDS 52 110 53 111 54 112 CODE32 SEGMENT 55 56 113 ;; 57 ; 114 ; New implementation. 58 115 ; @returns same as tkExecPgm: eax, edx and carry flag 59 116 ; @param ax Exec flag … … 65 122 ; may modify later if this is a UNIX shellscript or 66 123 ; a PE-file started by pe.exe. 67 ; @status 124 ; @status completely implemented. 68 125 ; @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 ; 77 127 ; 78 128 mytkExecPgm 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 129 cchFilename = -4h 130 cchArgs = -08h 131 usExecFlag = -0ch 132 SegFilename = -10h 133 OffFilename = -12h 134 SegEnv = -14h 135 OffEnv = -16h 136 SegArg = -18h 137 OffArg = -1ah 321 138 322 139 ASSUME CS:CODE32, DS:NOTHING, SS:NOTHING … … 325 142 lea esp, [ebp + OffArg] 326 143 327 ; save input parameters 144 ; 145 ; Save input parameters 146 ; 328 147 mov [ebp + usExecFlag], ax 329 148 mov ax, es … … 332 151 mov [ebp + SegArg], di 333 152 mov [ebp + OffArg], si 334 mov ax, ds335 mov [ebp + SegFilename], ax153 mov bx, ds 154 mov [ebp + SegFilename], bx 336 155 mov [ebp + OffFilename], dx 337 156 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 ; 346 172 mov di, dx ; bx:di is now filename address 347 173 push cs ; Problem calling far into the calltab segement. 348 174 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 352 177 ; 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 357 181 358 182 ; … … 360 184 ; Note: the arguments are a series of ASCIIZs ended by an empty string (ie. '\0'). 361 185 ; 362 mov bx, [ebp+SegArg] 186 xor cx, cx ; Set length to zero. 187 mov bx, [ebp + SegArg] 363 188 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 368 192 push cs ; Problem calling far into the calltab segement. 369 193 call near ptr FLAT:_f_FuStrLenZ 370 mov [ebp+cchArgs], cx371 jc mytkExecPgm_CalltkExecPgm_X1 372 373 mytkExecPgm_CalltkExecPgm_1: 374 add cx, [ebp +cchFilename]; filename length375 add cx, 3 + 260 ; 260 = new argument from a scripfile or something.194 jc tkepgm_backout 195 196 tkepgm1: 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. 376 200 ; 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 405 266 push cs ; Problem calling far into the calltab segement. 406 267 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 418 275 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 422 287 push cs ; Problem calling far into the calltab segement. 423 288 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 ; 298 tkepgm_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] 443 305 mov es, bx 444 mov bx, [ebp+SegEnv] 306 mov bx, [ebp + OffEnv] ; es:bx Environment 307 445 308 446 309 ; 447 310 ; Call _g_tkExecPgm 448 311 ; 312 tkepgm_callbehind: 449 313 push cs ; Problem calling far into the calltab segement. 450 314 call near ptr FLAT:_g_tkExecPgm … … 452 316 453 317 ; 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] 466 343 pop ds 467 push [ebp + SegEnv]344 push dword ptr [ebp + SegEnv] 468 345 pop es 469 346 popfd … … 471 348 retf 472 349 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 ; 355 tkepgm_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 ; 382 tkepgm_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] 483 395 484 396 mytkExecPgm_CalltkExecPgm: 485 push cs 397 push cs ; Problem calling far into the calltab segement. 486 398 call near ptr FLAT:_g_tkExecPgm 487 399 leave … … 489 401 mytkExecPgm ENDP 490 402 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 421 tkExecPgmCopyEnv PROC NEAR 422 cchEnv = -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 443 tkepce_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 449 tkepce_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 464 tkepce_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 474 tkepce_ret: 475 pop ebx 476 leave 477 ret 478 tkExecPgmCopyEnv 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 491 tkExecPgmEnvLength 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 522 tkepel1: 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 537 tkepel_err_ret: 538 xor eax, eax 539 540 541 ; Return 542 tkepel_ret: 543 pop ebx ; restore registers 544 pop edi 545 pop esi 546 pop ds 547 pop es 548 leave 549 ret 550 tkExecPgmEnvLength ENDP 551 552 553 554 555 491 556 CODE32 ENDS 492 endif493 557 494 558 -
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 $ 2 2 * 3 3 * Very simple OMF/LIB dumper. … … 174 174 "TEXT", "CODE16", 175 175 "_TEXT", "CODE16", 176 "_IOSEG", "CODE16", 177 "IOSEG_CODE", "CODE", 176 178 "DATA", "FAR_DATA", 177 179 "_DATA", "DATA16", -
branches/Grace/src/win32k/misc/buffer.asm
r2838 r3834 1 ; $Id: buffer.asm,v 1.5 2000-02-21 09:24:02bird 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! 4 4 ; 5 5 ; Copyright (c) 2000 knut st. osmundsen … … 13 13 ; Defined Constants And Macros 14 14 ; 15 NBR_BUFFERS EQU 2 015 NBR_BUFFERS EQU 2 16 16 BUFFER_SIZE EQU 1536 17 17 -
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 $ 2 2 * 3 3 * Common Heap - this forwards to the swappable heap! … … 28 28 * Global data 29 29 ******************************************************************************/ 30 #if ndef RING030 #if !defined(RING0) || defined(R3TST) 31 31 char fInited; /* init flag */ 32 32 #endif … … 53 53 if (rc != 0) 54 54 return rc; 55 #if def RING355 #if !defined(RING0) || defined(R3TST) 56 56 fInited = TRUE; 57 57 #endif … … 69 69 void * malloc(unsigned cbSize) 70 70 { 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 71 81 return smalloc(cbSize); 72 82 } … … 81 91 void *realloc(void *pv, unsigned cbNew) 82 92 { 93 #ifdef R3TST 94 if (!fInited) 95 Int3(); 96 #endif 83 97 return srealloc(pv, cbNew); 84 98 } … … 91 105 void free(void *pv) 92 106 { 107 #ifdef R3TST 108 if (!fInited) /* controlled leak! */ 109 return; 110 #endif 93 111 sfree(pv); 94 112 } … … 154 172 155 173 174 156 175 #if !defined(RING0) && defined(__IBMC__) 157 176 … … 162 181 int _rmem_init(void) 163 182 { 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); 165 185 return rc; 166 186 }
Note:
See TracChangeset
for help on using the changeset viewer.