Changeset 2838 for trunk/src/win32k/ldr
- Timestamp:
- Feb 21, 2000, 10:24:02 AM (26 years ago)
- Location:
- trunk/src/win32k/ldr
- Files:
-
- 3 edited
-
calltab.asm (modified) (2 diffs)
-
myldrOpen.cpp (modified) (8 diffs)
-
mytkExecPgm.asm (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/win32k/ldr/calltab.asm
r2836 r2838 1 ; $Id: calltab.asm,v 1. 9 2000-02-21 04:45:47bird Exp $1 ; $Id: calltab.asm,v 1.10 2000-02-21 09:24:01 bird Exp $ 2 2 ; 3 3 ; callTab - Call back again table - table with entry for each function which is overrided. … … 119 119 f_FuStrLenZ ENDP 120 120 121 f_FuStrLen PROC FAR 122 db MAXSIZE_PROLOG dup(0cch) 123 f_FuStrLen ENDP 124 121 125 f_FuBuff PROC FAR 122 126 db MAXSIZE_PROLOG dup(0cch) -
trunk/src/win32k/ldr/myldrOpen.cpp
r2837 r2838 1 /* $Id: myldrOpen.cpp,v 1. 9 2000-02-21 05:00:52bird Exp $1 /* $Id: myldrOpen.cpp,v 1.10 2000-02-21 09:24:01 bird Exp $ 2 2 * 3 3 * myldrOpen - ldrOpen. … … 43 43 #include "myExecPgm.h" 44 44 45 /******************************************************************************* 46 * Global Variables * 47 *******************************************************************************/ 48 extern BOOL fQAppType; /* From LDRQAppType */ 45 49 46 50 /******************************************************************************* … … 98 102 * Try get the filesize 99 103 */ 100 /*101 104 rc = SftFileSize(*phFile, (PULONG)SSToDS(&cbFile)); 102 105 if (rc != NO_ERROR) 103 106 { 104 107 kprintf(("ldrOpen: SftFileSize failed with rc=%d\n", rc)); 105 */106 108 cbFile = (unsigned)~0; 107 /* 108 } */ 109 } 109 110 110 111 /* … … 235 236 } 236 237 } 237 238 } 239 240 /* 241 * Only unreconized files and readerror passes this point! 242 * 243 * * Fileformats with lower priority should reside here. * 244 * 245 */ 246 247 /* 248 * If the initial readoperation failed try to read a smaller amount, in case it is a small script... 249 * 4 bytes is a small amount isn't it? 250 */ 251 if (rc != NO_ERROR) 252 { 253 kprintf(("ldrOpen: first ldrread failed with rc=%d. tries to read 4 byte.\n", rc)); 254 cchRead = 4; 255 if ((rc = ldrRead(*phFile, 0UL, pach, 0UL, cchRead, NULL)) != NO_ERROR) 256 kprintf(("ldrOpen: second ldrread failed with rc=%d.\n ", rc)); 257 } 258 259 /* 260 * Now we'll try again, UNIX styled script? 261 */ 262 if (rc == NO_ERROR && *pach == '#' && pach[1] == '!') 263 { 238 264 /* 239 * Only unreconized files and readerror passes this point!240 * 241 * * Fileformats with lower priority should reside here. *242 * 265 * UNIX styled script? 266 * FIXME! Must be more than 64 bytes long? 267 * No options! 268 * Firstline < 64 bytes! 243 269 */ 244 245 /* 246 * If the initial readoperation failed try to read a smaller amount, in case it is a small script... 247 * 4 bytes is a small amount isn't it? 248 */ 249 if (rc != NO_ERROR) 270 kprintf(("ldrOpen: unix script?\n")); 271 cchRead = min(cbFile, 256); 272 rc = ldrRead(*phFile, 0UL, pach, 0UL, cchRead, NULL); 273 if (rc == NO_ERROR) 250 274 { 251 kprintf(("ldrOpen: first ldrread failed with rc=%d. tries to read 4 byte.\n", rc)); 252 cchRead = 4; 253 if ((rc = ldrRead(*phFile, 0UL, pach, 0UL, cchRead, NULL)) != NO_ERROR) 254 kprintf(("ldrOpen: second ldrread failed with rc=%d.\n ", rc)); 255 } 256 257 /* 258 * Now we'll try again, UNIX styled script? 259 */ 260 if (rc == NO_ERROR && *pach == '#' && pach[1] == '!') 261 { 275 char *pszStart = pach+2; 276 kprintf(("ldrOpen: script debug 1\n")); 277 278 /* Make sure we don't read to much... */ 279 pszBuffer[cchRead] = '\0'; 280 262 281 /* 263 * UNIX styled script? 264 * FIXME! Must be more than 64 bytes long? 265 * No options! 266 * Firstline < 64 bytes! 282 * Skip blanks 267 283 */ 268 kprintf(("ldrOpen: unix script?\n")); 269 270 cchRead = min(cbFile, 256); 271 rc = ldrRead(*phFile, 0UL, pach, 0UL, cchRead, NULL); 272 if (rc != NO_ERROR) 284 pszStart = pszBuffer + 2; /* skips the "#!" stuff. */ 285 while (*pszStart != '\0' && (*pszStart == ' ' || *pszStart == '\t')) 286 pszStart++; 287 kprintf(("ldrOpen: script debug 2\n")); 288 289 /* anything left on the line? */ 290 if (*pszStart != '\0' && *pszStart != '\r' && *pszStart != '\n') 273 291 { 274 char *pszStart = pach+2; 275 kprintf(("ldrOpen: script debug 1\n")); 276 277 /* Make sure we don't read to much... */ 278 pszBuffer[cchRead] = '\0'; 292 char * pszEnd; /* Pointer to the end of the string(s) when the next step is finished. */ 293 unsigned cchToAdd = 1; /* Chars to add */ 294 BOOL fFirst = TRUE; /* Set if a '\0' has not been set yet. 295 * If this is clear, there are one or more parameters after the interpreter name. */ 279 296 280 297 /* 281 * Skip blanks 282 */ 283 pszStart = pszBuffer + 2; /* skips the "#!" stuff. */ 284 while (*pszStart != '\0' && (*pszStart == ' ' || *pszStart == '\t')) 285 pszStart++; 286 kprintf(("ldrOpen: script debug 2\n")); 287 288 /* anything left on the line? */ 289 if (*pszStart != '\0' && *pszStart != '\r' && *pszStart != '\n') 298 * find linesize and make parameters ready for copying 299 */ 300 pszEnd = pszStart; 301 kprintf(("ldrOpen: script debug 3\n")); 302 while (*pszEnd != '\0' && *pszEnd != '\r' && *pszEnd != '\n') 290 303 { 291 char * pszEnd; /* Pointer to the end of the string(s) when the next step is finished. */ 292 //char * pszFirstArg; /* Pointer to the first argument, the one after the interpreter name. */ 293 unsigned cchToAdd = 1; /* Chars to add */ 294 int f = TRUE; /* flag which tells me if I have just closed the last argument. */ 295 /* 296 * find linesize and make parameters ready for copying 297 */ 298 pszEnd = pszStart; 299 kprintf(("ldrOpen: script debug 3\n")); 300 //pszFirstArg = NULL; 301 while (*pszEnd != '\0' && *pszEnd != '\r' && *pszEnd != '\n') 304 if (fFirst && (*pszEnd == ' ' || *pszEnd == '\t')) 302 305 { 303 if (f) 304 { 305 f = FALSE; 306 //if (pszFirstArg != NULL) pszFirstArg = pszEnd + 1; 307 } 308 else if (!f && (*pszEnd == ' ' || *pszEnd == '\t')) 309 { 310 *pszEnd = '\0'; 311 f = TRUE; 312 } 313 314 /* next */ 315 pszEnd++; 316 cchToAdd++; 306 *pszEnd = '\0'; 307 fFirst = FALSE; 308 if (pszEnd[1] == '\0' || pszEnd[1] == '\r' || pszEnd[1] == '\n') 309 fFirst = TRUE; 317 310 } 318 *pszEnd = '\0'; 319 kprintf(("ldrOpen: script debug 4\n")); 320 311 312 /* next */ 313 pszEnd++; 314 cchToAdd++; 315 } 316 *pszEnd = '\0'; 317 kprintf(("ldrOpen: script debug 4\n")); 318 319 /* 320 * If ldrQueryApp type we don't have any ExecPgm buffer we need to mess with. 321 * We'll simply try open the the interpreter. 322 */ 323 if (fQAppType) 324 { 325 rc = ldrClose(*phFile); 326 rc = ldrOpen(phFile, pszStart, param3); /* FIXME, recusion! check that name not equal! Use flags to prevent race? */ 327 } 328 else 329 { 321 330 /* 322 331 * Find the ExecPgm buffer. … … 326 335 if (pBuffer != NULL) 327 336 { 328 unsigned cchArguments = getArgsLength(pBuffer->achArgs); 329 kprintf(("ldrOpen: debug1\n"));337 unsigned cchArguments = getArgsLength(pBuffer->achArgs); /* minus the first argument. */ 338 unsigned cchScriptnameDelta = strlen(pBuffer->szFilename) - strlen(pBuffer->achArgs); /* scriptname size difference. */ 330 339 331 340 kprintf(("ldrOpen: script debug 6\n")); … … 334 343 * Is there enough space in the struct? 335 344 */ 336 if (cchArguments + cchToAdd < sizeof(pBuffer->achArgs))345 if (cchArguments + cchToAdd + cchScriptnameDelta < sizeof(pBuffer->achArgs)) 337 346 { 338 347 kprintf(("ldrOpen: script debug 7\n")); … … 344 353 if (rc == NO_ERROR) 345 354 { 346 kprintf(("ldrOpen: scri tpdebug 8\n"));355 kprintf(("ldrOpen: script debug 8\n")); 347 356 /* Make space for the addition arguments. */ 348 memmove(&pBuffer->achArgs[cchToAdd], &pBuffer->achArgs[0], cchArguments); 349 memcpy(&pBuffer->achArgs[0], pszBuffer, cchToAdd); 350 kprintf(("ldrOpen: script debug 9\n")); 357 #ifdef DEBUG 358 char *psz = &pBuffer->achArgs[0]; 359 int i = 0; 360 while (*psz != '\0') 361 { 362 kprintf(("Arg %d: %s\n", i++, psz)); 363 psz += 1 + strlen(psz); 364 } 365 #endif 366 memmove(&pBuffer->achArgs[cchToAdd + cchScriptnameDelta], 367 &pBuffer->achArgs[0], cchArguments); 368 369 /* 370 * Copy the arguments. 371 */ 372 kprintf(("ldrOpen: script debug 8\n")); 373 memcpy(&pBuffer->achArgs[0], pszStart, cchToAdd); /* Interpreter with arguments */ 374 if (!fFirst) 375 pBuffer->achArgs[cchToAdd - 1] = ' '; 376 strcpy(&pBuffer->achArgs[cchToAdd], pszFilename); /* Scriptname */ 377 kprintf(("ldrOpen: script debug a\n")); 378 379 #ifdef DEBUG 380 psz = &pBuffer->achArgs[0]; 381 i = 0; 382 while (*psz != '\0') 383 { 384 kprintf(("Arg %d: %s\n", i++, psz)); 385 psz += 1 + strlen(psz); 386 } 387 #endif 351 388 } 352 389 else … … 365 402 } 366 403 } 367 else368 {369 kprintf(("ldrOpen: no interpereter on the first line.\n"));370 rc = ERROR_BAD_EXE_FORMAT; /*?*/371 }372 404 } 373 405 else 374 406 { 375 kprintf(("ldrOpen: read of min(cbFile, 256) = %d failed, rc = %d\n", cchRead, rc)); 407 kprintf(("ldrOpen: no interpereter on the first line.\n")); 408 rc = ERROR_BAD_EXE_FORMAT; /*?*/ 376 409 } 377 } /* else inn other formats here. */ 378 } 379 else 380 { 381 kprintf(("ldrOpen: ldrRead failed with rc=%d when reading DosHdr.\n", rc)); 382 rc = NO_ERROR; 383 } 410 } 411 else 412 { 413 kprintf(("ldrOpen: read of min(cbFile, 256) = %d failed, rc = %d\n", cchRead, rc)); 414 } 415 } /* else inn other formats here. */ 384 416 rfree(pszBuffer); 385 417 } -
trunk/src/win32k/ldr/mytkExecPgm.asm
r2837 r2838 1 ; $Id: mytkExecPgm.asm,v 1. 4 2000-02-21 05:00:53bird Exp $1 ; $Id: mytkExecPgm.asm,v 1.5 2000-02-21 09:24:01 bird Exp $ 2 2 ; 3 3 ; mytkExecPgm - tkExecPgm overload … … 23 23 extrn ReleaseBuffer:PROC 24 24 extrn QueryBufferSegmentOffset:PROC 25 extrn f_FuStrLenZ 26 extrn f_FuBuff 25 26 ; Scans strings until empy-string is reached. 27 ; input: bx:di 28 ; uses: nearly all (save bp) 29 ; return: cx size - CF clear 30 ; ax error- CF set 31 extrn f_FuStrLenZ:PROC 32 33 ; Stringlength 34 ; input: bx:di 35 ; uses: nearly all (save bp) 36 ; return: cx size - CF clear 37 ; ax error- CF set 38 extrn f_FuStrLen:PROC 39 40 ;memcpy 41 ;input: bx:si pointer to source 42 ; es:di pointer to target 43 ; cx count of bytes to copy 44 ;uses: nearly all (save bp) 45 ;return: success CF clear 46 ; failure CF set 47 extrn f_FuBuff:PROC 27 48 28 49 ; … … 81 102 push edi 82 103 83 IF 084 ; ; Check if this overloading has anything too say, after all it is using some stack space!85 ; jmp mytkExecPgm_CalltkExecPgm_X186 ENDIF87 88 104 ; parameter validations 89 105 mov ax, ds ; pointer to filename … … 91 107 jb mytkExecPgm_CalltkExecPgm_X1 92 108 93 ; This test is currently disabled. We'll pass on an empty string if the argument pointer is NULL. 94 ; Hopefully an empty string is treated equally to an NULL pointer. 95 ; cmp di, 4 96 ; jl mytkExecPgm_CalltkExecPgm_X1 97 109 ; 98 110 ; filename length 111 ; 99 112 mov ax, ds 100 113 mov es, ax 101 xor eax, eax 102 movzx edi, dx ; es:di is now filename address (ds:dx). 103 mov ecx, 0ffffffffh 104 cld 105 repne scasb 106 not ecx 114 pushad 115 mov bx, ds 116 mov di, dx ; es:di is now filename address (ds:dx). 117 push cs ; Problem calling far into the calltab segement. 118 call near ptr FLAT:f_FuStrLen 119 movzx ecx, cx 120 mov [ebp+cchFilename], ecx 121 popad 122 jc mytkExecPgm_CalltkExecPgm_X1; If the FuStrLen call failed we bail out! 107 123 108 124 ; 109 125 ; if filename length is more that CCHMAXPATH then we don't do anything!. 110 126 ; 127 mov ecx, [ebp+cchFilename] 111 128 cmp ecx, 260 112 129 jae mytkExecPgm_CalltkExecPgm_X1; length >= 260 113 mov [ebp+cchFilename], ecx114 130 115 131 ; … … 122 138 cmp di, 4 ; The argument might me a invalid pointer... 123 139 jb mytkExecPgm_CalltkExecPgm_1 124 mov es, di 125 movzx edi, si ; es:edi is now args address (di:si), eax is still 0126 dec ecx127 cld128 mytkExecPgm_CalltkExecPgm_loop: ; loop true all ASCIIZ strings 129 repne scasb ; scans forwards until '\0' is read. es:edi is pointing at the char after the '\0'.130 cmp byte ptr es:[edi], 0 ; is this char '\0' ? stop looping : loop once more;131 jnz mytkExecPgm_CalltkExecPgm_loop132 dec ecx ; update count - count terminating zero too133 not ecx140 141 pushad 142 mov bx, di ; 143 mov di, si ; bx:di -> arguments 144 push cs ; Problem calling far into the calltab segement. 145 call near ptr FLAT:f_FuStrLenZ 146 movzx ecx, cx 147 mov [ebp+cchArgs], ecx 148 popad 149 jc mytkExecPgm_CalltkExecPgm_X1 134 150 135 151 mytkExecPgm_CalltkExecPgm_1: 136 mov [ebp+cchArgs], ecx152 mov ecx, [ebp+cchArgs] 137 153 add ecx, [ebp+cchFilename] ; filename 138 154 add ecx, 3 + 260 ; 260 = new argument from a scrip file or something. … … 162 178 ; Copy filename to pBuffer. 163 179 ; 164 push esi 165 mov edi, eax ; es:di pBuffer 166 movzx esi, dx ; ds:si Filename pointer (input ds:dx) 180 pushad 181 mov di, ax ; es:di pBuffer 182 mov si, dx 183 mov bx, ds ; bx:si Filename pointer (input ds:dx) 167 184 mov ecx, [ebp+cchFilename] 168 cld 169 rep movsb 185 push cs ; Problem calling far into the calltab segement. 186 call near ptr FLAT:f_FuBuff 187 popad 188 jc mytkExecPgm_CalltkExecPgm_X2 170 189 171 190 ; 172 191 ; Copy Args to pBuffer + 261 173 192 ; 174 ; stack: esi, edi, es, ds, ecx, eax 175 pop esi 193 ; stack: edi, es, ds, ecx, eax 176 194 pop edi 177 195 push edi 178 push esi179 196 add eax, 261 ; we'll use eax in the branch 180 197 cmp di, 4 181 198 jb mytkExecPgm_CalltkExecPgm_2 182 and esi, 00000ffffh ; remove high part of the register 183 mov ds, di ; ds:si -> arguments 184 mov edi, eax ; es:di -> pBuffer + 261 199 pushad 185 200 mov ecx, [ebp+cchArgs] 186 cld 187 rep movsb 201 mov bx, di ; ds:si -> arguments 202 push cs ; Problem calling far into the calltab segement. 203 call near ptr FLAT:f_FuBuff 204 popad 205 jc mytkExecPgm_CalltkExecPgm_X2 188 206 jmp mytkExecPgm_CalltkExecPgm_3 189 207 190 208 mytkExecPgm_CalltkExecPgm_2: 191 mov byteptr es:[eax], 0 ; Terminate the empty string!209 mov word ptr es:[eax], 0 ; Terminate the empty string! 192 210 193 211 ; … … 206 224 ; Restore variables pushed on the stack 207 225 ; 208 ; stack: esi, edi, es, ds, ecx, eax 209 pop esi 226 ; stack: edi, es, ds, ecx, eax 210 227 pop edi 211 228 pop es … … 234 251 ; Call g_tkExecPgm 235 252 ; 236 push cs 253 push cs ; Problem calling far into the calltab segement. 237 254 call near ptr FLAT:g_tkExecPgm 238 255 pushfd
Note:
See TracChangeset
for help on using the changeset viewer.
