Changeset 2832 for trunk/src/win32k
- Timestamp:
- Feb 20, 2000, 5:27:24 AM (26 years ago)
- Location:
- trunk/src/win32k
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/win32k/Makefile
r2823 r2832 1 1 ################################################################################ 2 # $Id: Makefile,v 1.2 4 2000-02-18 19:27:28bird Exp $2 # $Id: Makefile,v 1.25 2000-02-20 04:27:22 bird Exp $ 3 3 # 4 4 # Copyright 1998-1999 knut st. osmundsen … … 56 56 CFLAGS16 = $(CFLAGS16) -Zi -Od 57 57 CPPFLAGS = $(CPPFLAGS) -O- -Ti+ 58 LFLAGS = $(LFLAGS) /NOEXEPACK /DEBUG 58 LFLAGS = $(LFLAGS) /NOEXEPACK /DEBUG /NODEBUG 59 59 ASFLAGS = $(ASFLAGS) -Od+ 60 60 CDEFINES = $(CDEFINES) -DDEBUG -
trunk/src/win32k/dev16/d16strat.c
r2799 r2832 1 /* $Id: d16strat.c,v 1. 4 2000-02-15 23:39:18bird Exp $1 /* $Id: d16strat.c,v 1.5 2000-02-20 04:27:22 bird Exp $ 2 2 * 3 3 * d16strat.c - 16-bit strategy routine, device headers, device_helper (ptr) … … 153 153 case D16_IOCTL_VERIFYPROCTAB: 154 154 if (fInitTime) 155 return CallVerify ProcTab32();155 return CallVerifyImportTab32(); 156 156 break; 157 157 } -
trunk/src/win32k/dev16/probkrnl.c
r2831 r2832 1 /* $Id: probkrnl.c,v 1.1 1 2000-02-19 23:51:59bird Exp $1 /* $Id: probkrnl.c,v 1.12 2000-02-20 04:27:23 bird Exp $ 2 2 * 3 3 * Description: Autoprobes the os2krnl file and os2krnl[*].sym files. … … 89 89 */ 90 90 IMPORTKRNLSYM aImportTab[NBR_OF_KRNLIMPORTS] = 91 {/* iFound cchName offObject usSel */92 /* iObject achName ulAddress fType*/93 {FALSE, -1, 8, "_ldrRead", -1, -1, -1, EPT_PROC32}, /* 0 */94 {FALSE, -1, 8, "_ldrOpen", -1, -1, -1, EPT_PROC32}, /* 1 */95 {FALSE, -1, 9, "_ldrClose", -1, -1, -1, EPT_PROC32}, /* 2 */96 {FALSE, -1, 12, "_LDRQAppType", -1, -1, -1, EPT_PROCIMPORT32}, /* 3 */ /* to be removed? */97 {FALSE, -1, 20, "_ldrEnum32bitRelRecs", -1, -1, -1, EPT_PROC32}, /* 4 */98 {FALSE, -1, 10, "_IOSftOpen", -1, -1, -1, EPT_PROCIMPORT32}, /* 5 */99 {FALSE, -1, 11, "_IOSftClose", -1, -1, -1, EPT_PROCIMPORT32}, /* 6 */100 {FALSE, -1, 15, "_IOSftTransPath", -1, -1, -1, EPT_PROCIMPORT32}, /* 7 */101 {FALSE, -1, 12, "_IOSftReadAt", -1, -1, -1, EPT_PROCIMPORT32}, /* 8 */102 {FALSE, -1, 13, "_IOSftWriteAt", -1, -1, -1, EPT_PROCIMPORT32}, /* 9 */103 {FALSE, -1, 12, "_SftFileSize", -1, -1, -1, EPT_PROCIMPORT32}, /* 10 */104 {FALSE, -1, 11, "_VMAllocMem", -1, -1, -1, EPT_PROCIMPORT32}, /* 11 */105 {FALSE, -1, 11, "_VMGetOwner", -1, -1, -1, EPT_PROCIMPORT32}, /* 12 */106 {FALSE, -1, 11, "g_tkExecPgm", -1, -1, -1, EPT_PROC32}, /* 13 */107 {FALSE, -1, 11, "f_FuStrLenZ", -1, -1, -1, EPT_PROCIMPORT16}, /* 14 */108 {FALSE, -1, 8, "f_FuBuff", -1, -1, -1, EPT_PROCIMPORT16} /* 15 */91 {/* iFound cchName offObject usSel fType */ 92 /* iObject achName ulAddress cProlog */ 93 {FALSE, -1, 8, "_ldrRead", -1, -1, -1, -1, EPT_PROC32}, /* 0 */ 94 {FALSE, -1, 8, "_ldrOpen", -1, -1, -1, -1, EPT_PROC32}, /* 1 */ 95 {FALSE, -1, 9, "_ldrClose", -1, -1, -1, -1, EPT_PROC32}, /* 2 */ 96 {FALSE, -1, 12, "_LDRQAppType", -1, -1, -1, -1, EPT_PROCIMPORT32}, /* 3 */ /* to be removed? */ 97 {FALSE, -1, 20, "_ldrEnum32bitRelRecs", -1, -1, -1, -1, EPT_PROC32}, /* 4 */ 98 {FALSE, -1, 10, "_IOSftOpen", -1, -1, -1, -1, EPT_PROCIMPORT32}, /* 5 */ 99 {FALSE, -1, 11, "_IOSftClose", -1, -1, -1, -1, EPT_PROCIMPORT32}, /* 6 */ 100 {FALSE, -1, 15, "_IOSftTransPath", -1, -1, -1, -1, EPT_PROCIMPORT32}, /* 7 */ 101 {FALSE, -1, 12, "_IOSftReadAt", -1, -1, -1, -1, EPT_PROCIMPORT32}, /* 8 */ 102 {FALSE, -1, 13, "_IOSftWriteAt", -1, -1, -1, -1, EPT_PROCIMPORT32}, /* 9 */ 103 {FALSE, -1, 12, "_SftFileSize", -1, -1, -1, -1, EPT_PROCIMPORT32}, /* 10 */ 104 {FALSE, -1, 11, "_VMAllocMem", -1, -1, -1, -1, EPT_PROCIMPORT32}, /* 11 */ 105 {FALSE, -1, 11, "_VMGetOwner", -1, -1, -1, -1, EPT_PROCIMPORT32}, /* 12 */ 106 {FALSE, -1, 11, "g_tkExecPgm", -1, -1, -1, -1, EPT_PROC32}, /* 13 */ 107 {FALSE, -1, 11, "f_FuStrLenZ", -1, -1, -1, -1, EPT_PROCIMPORT16}, /* 14 */ 108 {FALSE, -1, 8, "f_FuBuff", -1, -1, -1, -1, EPT_PROCIMPORT16} /* 15 */ 109 109 /* {FALSE, -1, 11, "", -1, -1, -1, EPT_PROCIMPORT16} */ /* 16 */ 110 110 }; … … 157 157 * Internal Functions * 158 158 *******************************************************************************/ 159 static void kmemcpy(char *p1, const char *p2, int len); 160 static int kstrcmp(const char *p1, const char *p2); 161 static char *kstrstr(const char *psz1, const char *psz2); 162 static int kstrncmp(const char *p1, const char *p2, int len); 163 static int kstrlen(const char *p); 164 static HFILE fopen(char * filename, char * ignored); 165 static int fread(void * pBuffer, USHORT i1, USHORT i2, HFILE hfile); 166 static int fseek(HFILE hfile, signed long off, int org); 159 static HFILE fopen(const char * pszFilename, const char * pszIgnored); 160 static int fread(void * pvBuffer, USHORT cbBlock, USHORT cBlock, HFILE hFile); 161 static int fseek(HFILE hfile, signed long off, int iOrg); 167 162 static unsigned long fsize(HFILE hFile); 168 static void puts(char *psz); 169 static int kargncpy(char *pszTarget, const char *pszArg, unsigned cchMaxlen); 170 171 static int VerifyPrologs(void); 172 static int ProbeSymFile(char *pszFilename); 173 static int VerifyKernelVer(void); 174 static int ReadOS2Krnl(char *filename); 175 static int ReadOS2Krnl2(HFILE krnl, unsigned long cbKrnl); 176 static int GetKernelOTEs(void); 177 178 static void ShowDecNumber(unsigned long n); 179 static void ShowHexNumber(unsigned long int n); 180 static void ShowResult(int rc, int iSym); 163 static void puts(char *psz); 164 165 static void kmemcpy(char *psz1, const char *psz2, int cch); 166 static char * kstrstr(const char *psz1, const char *psz2); 167 static int kstrcmp(const char *psz1, const char *psz2); 168 static int kstrncmp(const char *psz1, const char *psz2, int cch); 169 static int kstrlen(const char *psz); 170 static int kargncpy(char *pszTarget, const char *pszArg, unsigned cchMaxlen); 171 172 static int VerifyPrologs(void); 173 static int ProbeSymFile(char *pszFilename); 174 static int VerifyKernelVer(void); 175 static int ReadOS2Krnl(char *pszFilename); 176 static int ReadOS2Krnl2(HFILE hKrnl, unsigned long cbKrnl); 177 static int GetKernelOTEs(void); 178 179 static void ShowDecNumber(unsigned long ul); 180 static void ShowHexNumber(unsigned long ul); 181 static void ShowResult(int rc, int iSym); 181 182 182 183 … … 189 190 /** 190 191 * Quick implementation of fopen. 191 * @param filename name of file to open (sz)192 * @param ignored whatever - it is ignored192 * @param pszFilename name of file to open (sz) 193 * @param pszIgnored whatever - it is ignored 193 194 * @return Handle to file. (not pointer to a FILE stream as in C-library) 194 195 * @remark binary and readonly is assumed! 195 196 */ 196 static HFILE fopen(c har * filename, char * ignored)197 static HFILE fopen(const char * pszFilename, const char * pszIgnored) 197 198 { 198 199 HFILE hFile = 0; … … 201 202 202 203 rc = DosOpen( 203 filename, 204 &hFile, 205 &Action, 206 0, 207 FILE_NORMAL, 208 OPEN_ACTION_FAIL_IF_NEW | OPEN_ACTION_OPEN_IF_EXISTS, 209 OPEN_SHARE_DENYNONE + OPEN_ACCESS_READONLY, 210 NULL 211 ); 212 213 ignored = ignored; 204 (char*)pszFilename, 205 &hFile, 206 &Action, 207 0, 208 FILE_NORMAL, 209 OPEN_ACTION_FAIL_IF_NEW | OPEN_ACTION_OPEN_IF_EXISTS, 210 OPEN_SHARE_DENYNONE + OPEN_ACCESS_READONLY, 211 NULL); 212 213 pszIgnored = pszIgnored; 214 214 return hFile; 215 215 } … … 219 219 * fread emulation 220 220 * @returns Number of blocks read. 221 * @param p Buffer Buffer to read into222 * @param i1 blocksize223 * @param i2 block count224 * @param hFile Handle to file (HFILE)225 */ 226 static int fread(void * p Buffer, USHORT cbBlock, USHORT cBlock, HFILE hFile)221 * @param pvBuffer Buffer to read into 222 * @param cbBlock Blocksize 223 * @param cBlock Block count 224 * @param hFile Handle to file (HFILE) 225 */ 226 static int fread(void * pvBuffer, USHORT cbBlock, USHORT cBlock, HFILE hFile) 227 227 { 228 228 USHORT ulRead; 229 229 USHORT rc; 230 230 231 rc = DosRead(hFile, p Buffer, (USHORT)(cbBlock*cBlock), &ulRead);231 rc = DosRead(hFile, pvBuffer, (USHORT)(cbBlock*cBlock), &ulRead); 232 232 if (rc == 0) 233 233 rc = (USHORT)cBlock; … … 246 246 * @param org origin 247 247 */ 248 static int fseek(HFILE hFile, signed long off, int org) 249 { 250 USHORT rc; 251 ULONG ole; 252 253 rc = DosChgFilePtr(hFile, off, org, &ole); 254 255 return rc; 248 static int fseek(HFILE hFile, signed long off, int iOrg) 249 { 250 ULONG ul; 251 return (int)DosChgFilePtr(hFile, off, iOrg, &ul); 256 252 } 257 253 … … 285 281 /** 286 282 * kmemcpy - memory copy - slow! 287 * @param p1 target 288 * @param p2 source 289 * @param len length 290 */ 291 static void kmemcpy(char * p1, const char * p2, int len) 292 { 293 while (len != 0) 294 { 295 *p1 = *p2; 296 p1++; 297 p2++; 298 len--; 299 } 300 } 301 302 #if 0 /* not in use */ 303 /** 304 * kstrcmp - String compare 305 * @returns 0 - equal else !0 306 * @param p1 String 1 307 * @param p2 String 2 308 */ 309 static int kstrcmp(const char * p1, const char * p2) 310 { 311 while (*p1 == *p2 && *p1 != '\0' && *p2 != '\0') 312 { 313 p1++; 314 p2++; 315 } 316 return *p1 - *p2; 317 } 318 #endif 319 283 * @param psz1 target 284 * @param psz2 source 285 * @param cch length 286 */ 287 static void kmemcpy(char *psz1, const char *psz2, int cch) 288 { 289 while (cch-- != 0) 290 *psz1++ = *psz2++; 291 } 320 292 321 293 … … 347 319 348 320 321 #if 0 /* not in use */ 322 /** 323 * kstrcmp - String compare 324 * @returns 0 - equal else !0 325 * @param psz1 String 1 326 * @param psz2 String 2 327 */ 328 static int kstrcmp(const char *psz1, const char *psz2); 329 { 330 while (*psz1 == *psz2 && *psz1 != '\0' && *psz2 != '\0') 331 { 332 psz1++; 333 psz2++; 334 } 335 return *psz1 - *psz2; 336 } 337 #endif 338 339 349 340 350 341 /** 351 342 * kstrncmp - String 'n' compare. 352 * @returns353 343 * @returns 0 - equal else !0 354 344 * @param p1 String 1 … … 356 346 * @param len length 357 347 */ 358 static int kstrncmp(const char * p1, const char * p2, int len)348 static int kstrncmp(register const char *psz1, register const char *psz2, int cch) 359 349 { 360 350 int i = 0; 361 while (i < len && *p1 == *p2 && *p1 != '\0' && *p2 != '\0')362 { 363 p 1++;364 p 2++;351 while (i < cch && *psz1 == *psz2 && *psz1 != '\0' && *psz2 != '\0') 352 { 353 psz1++; 354 psz2++; 365 355 i++; 366 356 } 367 357 368 return i - len;358 return i - cch; 369 359 } 370 360 … … 377 367 * @author knut st. osmundsen 378 368 */ 379 static int kstrlen( const char * psz)380 { 381 int cch = 0;382 while ( psz[cch]!= '\0')369 static int kstrlen(register const char * psz) 370 { 371 register int cch = 0; 372 while (*psz++ != '\0') 383 373 cch++; 384 374 return cch; … … 508 498 return -50; 509 499 } 500 dprintf(("\nSuccessfully opened symbolfile: %s\n", pszFilename)); 510 501 511 502 … … 525 516 dprintf(("*Module name: %s\n", achBuffer)); 526 517 dprintf(("*Segments: %d\n*MaxSymbolLength: %d\n", MapDef.cSegs, MapDef.cbMaxSym)); 527 dprintf(("*ppNextMap: 0x%x\n \n", MapDef.ppNextMap ));518 dprintf(("*ppNextMap: 0x%x\n", MapDef.ppNextMap )); 528 519 529 520 … … 765 756 * @returns 0 on success. 766 757 * errorcodes on failure. (-1 >= rc >= -14) 767 * @param hKrnl 768 * @param 769 * @equiv 770 * @time 771 * @sketch 772 * @status 758 * @param hKrnl Handle to the kernel file. 759 * @param cbKrnl Size of the kernel file. 773 760 * @author knut st. osmundsen 774 * @remark775 761 */ 776 762 static int ReadOS2Krnl2(HFILE hKrnl, unsigned long cbKrnl) … … 784 770 785 771 /* find bldlevel string - "@#IBM:14.020#@ IBM OS/2 Kernel - 14.020F" */ 786 cbKrnl = fsize(hKrnl);787 772 if (fseek(hKrnl, 0, SEEK_SET)) 788 773 return -2; -
trunk/src/win32k/dev32/d32init.c
r2831 r2832 1 /* $Id: d32init.c,v 1.1 1 2000-02-19 23:51:59bird Exp $1 /* $Id: d32init.c,v 1.12 2000-02-20 04:27:23 bird Exp $ 2 2 * 3 3 * d32init.c - 32-bits init routines. … … 14 14 #define MAXSIZE_PROLOG 0x10 /* Note that this must be synced with */ 15 15 /* the one used in calltab.asm. */ 16 #define static 16 #define static /* just to make all symbols visible in the kernel debugger. */ 17 17 18 18 19 #define INCL_DOSERRORS 19 20 #define INCL_NOPMAPI 20 21 #define LDR_INCL_INITONLY 21 22 22 23 23 /******************************************************************************* … … 44 44 *******************************************************************************/ 45 45 static ULONG readnum(const char *pszNum); 46 static int interpretFunctionProlog(char *p, BOOL fOverload); 47 static int procInit(void); 46 static signed char interpretFunctionProlog32(char *pach, BOOL fOverload); 47 static signed char interpretFunctionProlog16(char *pach, BOOL fOverload); 48 static int ImportTabInit(void); 48 49 49 50 … … 291 292 /* functionoverrides */ 292 293 if (!options.fNoLoader) 293 if ( procInit() != NO_ERROR)294 if (ImportTabInit() != NO_ERROR) 294 295 return STATUS_DONE | STERR | ERROR_I24_QUIET_INIT_FAIL; 295 296 … … 338 339 339 340 return i > 0 ? ulRet : ~0UL; 340 }341 342 343 /**344 * Verifies the aImportTab.345 * @returns 0 if ok. !0 if not ok.346 * @remark Called from IOCtl.347 */348 USHORT _loadds _Far32 _Pascal VerifyProcTab32(void)349 {350 int i;351 int cb;352 353 /* verify */354 for (i = 0; i < NBR_OF_KRNLIMPORTS; i++)355 {356 /* verify that it is found */357 if (!_aImportTab[i].fFound)358 {359 kprintf(("VerifyProcTab32: procedure no.%d was not found!\n", i));360 return STATUS_DONE | STERR | 1;361 }362 363 /* verify read/writeable. - FIXME */364 if (_aImportTab[i].ulAddress < 0xffe00000UL)365 {366 kprintf(("VerifyProcTab32: procedure no.%d has an invlalid address, %#08x!\n",367 i, _aImportTab[i].ulAddress));368 return STATUS_DONE | STERR | 2;369 }370 371 switch (_aImportTab[i].fType)372 {373 case EPT_PROC:374 case EPT_PROCIMPORT:375 /* verify known function prolog. */376 if ((cb = interpretFunctionProlog((char*)_aImportTab[i].ulAddress, _aImportTab[i].fType == EPT_PROC))377 <= 0 && cb + 5 >= MAXSIZE_PROLOG)378 {379 kprintf(("VerifyProcTab32: verify failed for procedure no.%d\n",i));380 return STATUS_DONE | STERR | 3;381 }382 break;383 384 default:385 kprintf(("VerifyProcTab32: only EPT_PROC is implemented\n",i));386 return STATUS_DONE | STERR | 4;387 }388 }389 390 return STATUS_DONE;391 341 } 392 342 … … 446 396 447 397 /** 448 * Interpret function prolog to find where to jmp back.398 * 32-bit! Interpret function prolog to find where to jmp back. 449 399 * @returns Length of prolog need to be copied - which is also the offset of 450 400 * where the jmp instr should be placed. … … 454 404 * FALSE: Function is to be imported. 455 405 */ 456 static int interpretFunctionProlog(char *pach, BOOL fOverload)406 static signed char interpretFunctionProlog32(char *pach, BOOL fOverload) 457 407 { 458 int rc;408 int cb; 459 409 460 410 /* … … 471 421 { 472 422 if (pach[2] == 0xec) 473 rc= 3;423 cb = 3; 474 424 else 475 rc= 1;476 while ( rc< 5)425 cb = 1; 426 while (cb < 5) 477 427 { 478 428 /* … … 481 431 * There will never be any doubt when something goes wrong! 482 432 */ 483 switch(pach[ rc])433 switch(pach[cb]) 484 434 { 485 435 case 0x33: /* xor (ldrClose, ldrOpen) */ 486 rc+=2;436 cb +=2; 487 437 break; 488 438 case 0x8b: 489 if (pach[ rc+1] == 0x0d)490 rc+= 6;439 if (pach[cb+1] == 0x0d) 440 cb += 6; 491 441 else 492 rc+= 2; /*????!*/442 cb += 2; /*????!*/ 493 443 break; 494 444 case 0x8d: /* lea (ldrRead) */ 495 rc+= 3;445 cb += 3; 496 446 break; 497 447 case 0x83: /* sub (LDRQAppType) */ 498 rc+= 3;448 cb += 3; 499 449 break; 500 450 default: 501 kprintf(("interpretFunctionProlog: unknown instruction 0x%x\n", pach[ rc]));451 kprintf(("interpretFunctionProlog: unknown instruction 0x%x\n", pach[cb])); 502 452 return 0; 503 453 } … … 506 456 else if (pach[0] == 0x55 && pach[1] == 0xa1) /* ldrEnum32bitRelRecs on WS4eB */ 507 457 { 508 rc= 1 + 5;458 cb = 1 + 5; 509 459 } 510 460 else … … 512 462 /* special case for IOSftReadAt and IOSftWriteAt */ 513 463 if (fOverload == FALSE && pach[0] == 0xB8 && (pach[5] == 0xEB || pach[5] == 0x55)) 514 rc= 5;464 cb = 5; 515 465 else 516 rc= 0;466 cb = 0; 517 467 } 518 468 519 return rc;469 return (signed char)cb; 520 470 } 521 471 472 473 /** 474 * 16-bit! Interpret function prolog to find where to jmp back. 475 * @returns Length of prolog need to be copied - which is also the offset of 476 * where the jmp instr should be placed. 477 * On error it returns 0. 478 * @param pach Pointer to prolog. 479 * @param fOverload TRUE: Function is to be overloaded. 480 * FALSE: Function is to be imported. 481 */ 482 static signed char interpretFunctionProlog16(char *pach, BOOL fOverload) 483 { 484 int cb; 485 486 /* 487 * Check for the well known prolog (the only that is supported now) 488 * which is: 489 * push 2 490 */ 491 if (*pach == 0x6A) /* push 2 (don't check for the 2) */ 492 { 493 BOOL fForce; 494 cb = 0; 495 while (cb < 8 || fForce) 496 { 497 fForce = FALSE; 498 switch (*pach) 499 { 500 case 0x50: /* push ax */ 501 case 0x51: /* push cx */ 502 case 0x52: /* push dx */ 503 case 0x53: /* push bx */ 504 case 0x54: /* push sp */ 505 case 0x55: /* push bp */ 506 case 0x56: /* push si */ 507 case 0x57: /* push di */ 508 break; 509 510 case 0x2e: /* cs segment override */ 511 case 0x36: /* ss segment override */ 512 case 0x3e: /* ds segment override */ 513 case 0x26: /* es segment override */ 514 case 0x64: /* fs segment override */ 515 case 0x65: /* gs segment override */ 516 fForce = TRUE; 517 break; 518 519 case 0x6a: /* push <byte> */ 520 pach++; 521 cb++; 522 break; 523 524 case 0x68: /* push <word> */ 525 pach += 2; 526 cb += 2; 527 break; 528 529 case 0x8b: /* mov /r */ 530 if ((pach[1] & 0xc0) == 10 /* ex. mov ax,bp+1114h */ 531 || ((pach[1] & 0xc0) == 0 && (pach[1] & 0xc0) == 6)) /* ex. mov bp,0ff23h */ 532 { /* 16-bit displacement */ 533 pach += 3; 534 cb += 3; 535 } 536 else 537 if ((pach[1] & 0xc0) == 0x40) /* ex. mov ax,[si]+4fh */ 538 { /* 8-bit displacement */ 539 pach += 2; 540 cb += 2; 541 } 542 else 543 { /* no displacement (only /r byte) */ 544 pach++; 545 cb++; 546 } 547 break; 548 549 default: 550 kprintf(("interpretFunctionProlog: unknown instruction 0x%x 0x%x 0x%x\n", pach[0], pach[1], pach[2])); 551 return 0; 552 } 553 pach++; 554 cb++; 555 } 556 } 557 558 fOverload = fOverload; 559 return (signed char)cb; 560 } 561 562 563 /** 564 * Verifies the aImportTab. 565 * @returns 0 if ok. !0 if not ok. 566 * @remark Called from IOCtl. 567 * WARNING! VerifyImporTab32 is called before the initroutine! 568 */ 569 USHORT _loadds _Far32 _Pascal VerifyImportTab32(void) 570 { 571 int i; 572 int cb; 573 int cbmin; 574 575 /* VerifyImporTab32 is called before the initroutine! */ 576 pulTKSSBase32 = (PULONG)_TKSSBase16; 577 578 /* verify */ 579 for (i = 0; i < NBR_OF_KRNLIMPORTS; i++) 580 { 581 /* verify that it is found */ 582 if (!_aImportTab[i].fFound) 583 { 584 kprintf(("VerifyImportTab32: procedure no.%d was not found!\n", i)); 585 return STATUS_DONE | STERR | 1; 586 } 587 588 /* verify read/writeable. - FIXME */ 589 if (_aImportTab[i].ulAddress < 0xffe00000UL) 590 { 591 kprintf(("VerifyImportTab32: procedure no.%d has an invlalid address, %#08x!\n", 592 i, _aImportTab[i].ulAddress)); 593 return STATUS_DONE | STERR | 2; 594 } 595 596 switch (_aImportTab[i].fType & ~EPT_BIT_MASK) 597 { 598 case EPT_PROC: 599 case EPT_PROCIMPORT: 600 /* 601 * Verify known function prolog. 602 */ 603 if (_aImportTab[i].fType & EPT_32BIT) 604 { 605 cb = interpretFunctionProlog32((char*)_aImportTab[i].ulAddress, _aImportTab[i].fType == EPT_PROC32); 606 cbmin = 5; 607 } 608 else 609 { 610 cb = interpretFunctionProlog16((char*)_aImportTab[i].ulAddress, _aImportTab[i].fType == EPT_PROC16); 611 cbmin = 8; 612 } 613 614 /* 615 * Check result of the function prolog interpretations. 616 */ 617 if (cb <= 0 && cb + cbmin >= MAXSIZE_PROLOG) 618 { /* failed, too small or too large. */ 619 kprintf(("VerifyImportTab32: verify failed for procedure no.%d (cd=%d)\n", i, cb)); 620 return STATUS_DONE | STERR | 3; 621 } 622 break; 623 624 case EPT_VARIMPORT: 625 /* do nothing! */ 626 break; 627 628 default: 629 kprintf(("VerifyImportTab32: only EPT_PROC is implemented\n",i)); 630 return STATUS_DONE | STERR | 4; 631 } 632 } 633 634 return STATUS_DONE; 635 } 522 636 523 637 … … 526 640 * @returns NO_ERROR on success. !0 on error. 527 641 */ 528 static int procInit(void)642 static int importTabInit(void) 529 643 { 644 /* This table must be updated with the overloading functions. */ 645 static unsigned auFuncs[NBR_OF_KRNLIMPORTS] = 646 { 647 (unsigned)myldrRead, 648 (unsigned)myldrOpen, 649 (unsigned)myldrClose, 650 0,//(unsigned)myLDRQAppType, 651 (unsigned)myldrEnum32bitRelRecs, 652 0, 653 0, 654 0, 655 0, 656 0, 657 0, 658 0, 659 0, 660 (unsigned)&mytkExecPgm, 661 0, 662 0 663 }; 664 530 665 int i; 531 666 int cb; 667 532 668 533 669 /* … … 536 672 for (i = 0; i < NBR_OF_KRNLIMPORTS; i++) 537 673 { 538 if (_aImportTab[i].fType != EPT_PROC && _aImportTab[i].fType != EPT_PROCIMPORT) 539 { 540 kprintf(("procInit: EPT_VAR is not supported. (procedure no.%d, cb=%d)\n", i, cb)); 541 return 1; 542 } 543 cb = interpretFunctionProlog((char*)_aImportTab[i].ulAddress, _aImportTab[i].fType == EPT_PROC); 674 /* EPT_VARIMPORTs are skipped */ 675 if ((_aImportTab[i].fType & ~EPT_BIT_MASK) == EPT_VARIMPORT) 676 continue; 677 678 if (_aImportTab[i].fType & EPT_32BIT) 679 cb = interpretFunctionProlog32((char*)_aImportTab[i].ulAddress, _aImportTab[i].fType == EPT_PROC32); 680 else 681 cb = interpretFunctionProlog16((char*)_aImportTab[i].ulAddress, _aImportTab[i].fType == EPT_PROC16); 544 682 if (cb <= 0 || cb + 5 >= MAXSIZE_PROLOG) 545 683 { 546 kprintf((" procInit: verify failed for procedure no.%d, cb=%d\n", i, cb));684 kprintf(("ImportTabInit: verify failed for procedure no.%d, cb=%d\n", i, cb)); 547 685 return 1; 548 686 } … … 556 694 switch (_aImportTab[i].fType) 557 695 { 558 case EPT_PROC: 696 /* 697 * 32-bit procedure overload. 698 * The overloading procedure is found in the auFuncs table (at the same index 699 * as the overloaded procedure has in aImportTab). 700 * The overloaded procedure is called by issuing a call to the callTab entry. 701 */ 702 case EPT_PROC32: 559 703 { 560 cb = interpretFunctionProlog((char*)_aImportTab[i].ulAddress, TRUE);704 cb = _aImportTab[i].cbProlog = interpretFunctionProlog32((char*)_aImportTab[i].ulAddress, TRUE); 561 705 if (cb > 0 && cb + 5 < MAXSIZE_PROLOG) 562 706 { 563 static unsigned auFuncs[NBR_OF_KRNLIMPORTS] = /* This table must be updated with the overloading functions. */ 564 { 565 (unsigned)myldrRead, 566 (unsigned)myldrOpen, 567 (unsigned)myldrClose, 568 0,//(unsigned)myLDRQAppType, 569 (unsigned)myldrEnum32bitRelRecs, 570 0, 571 0, 572 0, 573 0, 574 0, 575 0, 576 0, 577 0, 578 (unsigned)&mytkExecPgm 579 }; 580 581 /* copy function prolog */ 707 /* 708 * Copy function prolog which will be overwritten by the jmp to calltabl. 709 */ 582 710 memcpy(callTab[i], (void*)_aImportTab[i].ulAddress, (size_t)cb); 583 711 584 /* jump from calltab to original function */ 712 /* 713 * Make jump instruction which jumps from calltab to original function. 714 * 0xE9 <four bytes displacement> 715 * Note: the displacement is relative to the next instruction 716 */ 585 717 callTab[i][cb] = 0xE9; /* jmp */ 586 *(unsigned*)(void*)&callTab[i][cb+1] = _aImportTab[i].ulAddress + cb - (unsigned)&callTab[i][cb+5]; 587 588 589 /* jump from original function to my function - an cli(?) could be needed here */ 718 *(unsigned long*)(void*)&callTab[i][cb+1] = _aImportTab[i].ulAddress + cb - (unsigned long)&callTab[i][cb+5]; 719 720 /* 721 * Jump from original function to my function - an cli(?) could be needed here 722 */ 590 723 *(char*)_aImportTab[i].ulAddress = 0xE9; /* jmp */ 591 *(unsigned *)(_aImportTab[i].ulAddress + 1) = auFuncs[i] - (_aImportTab[i].ulAddress + 5);724 *(unsigned long*)(_aImportTab[i].ulAddress + 1) = auFuncs[i] - (_aImportTab[i].ulAddress + 5); 592 725 } 593 726 else 594 727 { /* !fatal! - this could never happen really... */ 595 kprintf((" procInit: FATAL verify failed for procedure no.%d when rehooking it!\n",i));728 kprintf(("ImportTabInit: FATAL verify failed for procedure no.%d when rehooking it!\n",i)); 596 729 Int3(); /* ipe - later! */ 597 730 return 1; … … 600 733 } 601 734 602 case EPT_PROCIMPORT: 735 736 /* 737 * 16-bit procedure overload. 738 * Currently disabled due to expected problems when calltab is a 32-bit segment. 739 */ 740 case EPT_PROC16: 603 741 { 604 cb = interpretFunctionProlog((char*)_aImportTab[i].ulAddress, FALSE); 742 kprintf(("ImportTabInit: Overloading 16-bit procedures are not supported yet!!! Calltable in 32-bit segment!\n", i)); 743 Int3(); 744 745 cb = _aImportTab[i].cbProlog = interpretFunctionProlog16((char*)_aImportTab[i].ulAddress, TRUE); 746 if (cb > 0 && cb + 8 < MAXSIZE_PROLOG) /* a 16:32 jump must be prefixed with 66h in a 16-bit segment */ 747 { 748 /* 749 * Copy function prolog which is to be overwritten. 750 */ 751 memcpy(callTab[i], (void*)_aImportTab[i].ulAddress, (size_t)cb); 752 753 /* 754 * Create far jump from calltab to original function. 755 * 0xEA <four byte target address> <two byte target selector> 756 */ 757 callTab[i][cb] = 0xEA; /* jmp far ptr */ 758 *(unsigned long*)(void*)&callTab[i][cb+1] = _aImportTab[i].offObject; 759 *(unsigned short*)(void*)&callTab[i][cb+5] = _aImportTab[i].usSel; 760 761 /* 762 * jump from original function to my function - an cli(?) could be needed here 763 * 0x66 0xEA <four byte target address> <two byte target selector> 764 */ 765 *(char*)(_aImportTab[i].ulAddress ) = 0x66; /* operandsize prefix */ 766 *(char*)(_aImportTab[i].ulAddress + 1) = 0xEA; /* jmp far ptr */ 767 *(unsigned long*)(_aImportTab[i].ulAddress + 2) = auFuncs[i]; /* FIXME? */ 768 *(unsigned short*)(_aImportTab[i].ulAddress + 6) = _R0FlatCS16; /* FIXME */ 769 } 770 else 771 { /* !fatal! - this could never happen really... */ 772 kprintf(("ImportTabInit: FATAL verify failed for procedure no.%d when rehooking it!\n",i)); 773 Int3(); /* ipe - later! */ 774 return 1; 775 } 776 break; 777 } 778 779 780 /* 781 * 32-bit imported procedure 782 * This is called by issuing a near call to the callTab entry. 783 */ 784 case EPT_PROCIMPORT32: 785 { 786 cb = _aImportTab[i].cbProlog = interpretFunctionProlog32((char*)_aImportTab[i].ulAddress, FALSE); 605 787 if (cb > 0 && cb + 5 < MAXSIZE_PROLOG) 606 788 { 607 /* jump from calltab to original function */ 789 /* 790 * Make jump instruction which jumps from calltab to original function. 791 * 0xE9 <four bytes displacement> 792 * Note: the displacement is relative to the next instruction 793 */ 608 794 callTab[i][0] = 0xE9; /* jmp */ 609 795 *(unsigned*)(void*)&callTab[i][1] = _aImportTab[i].ulAddress - (unsigned)&callTab[i][cb+5]; 610 796 } 611 797 else 612 { /* !fatal! - this could never happen really... */613 kprintf((" procInit: FATAL verify failed for procedure no.%d when importing it!\n",i));798 { /* !fatal! - this should never really happen... */ 799 kprintf(("ImportTabInit: FATAL verify failed for procedure no.%d when importing it!\n",i)); 614 800 Int3(); /* ipe - later! */ 615 801 return 1; … … 618 804 } 619 805 806 807 /* 808 * 16-bit imported procedure. 809 * This is called by issuing a far call to the calltab entry. 810 */ 811 case EPT_PROCIMPORT16: 812 { 813 cb = _aImportTab[i].cbProlog = interpretFunctionProlog16((char*)_aImportTab[i].ulAddress, FALSE); 814 if (cb > 0 && cb + 8 < MAXSIZE_PROLOG) 815 { 816 /* 817 * Create far jump from calltab to original function. 818 * 0xEA <four byte target address> <two byte target selector> 819 */ 820 callTab[i][0] = 0xEA; /* jmp far ptr */ 821 *(unsigned long*)(void*)&callTab[i][1] = _aImportTab[i].offObject; 822 *(unsigned short*)(void*)&callTab[i][5] = _aImportTab[i].usSel; 823 } 824 else 825 { /* !fatal! - this should never really happen... */ 826 kprintf(("ImportTabInit: FATAL verify failed for procedure no.%d when importing it!\n",i)); 827 Int3(); /* ipe - later! */ 828 return 1; 829 } 830 break; 831 } 832 833 834 /* 835 * 16/32-bit importe variable. 836 * This is used by accessing the 32-bit flat address in the callTab. 837 * callTab-entry + 4 holds the offset of the variable into the object. 838 * callTab-entry + 8 holds the selector for the object. (These two fields is the 16:32-bit pointer to the variable.) 839 * callTab-entry + a holds the 16-bit offset for the variable. 840 * callTab-entry + c holds the selector for the object. (These two fiels is the 16:16-bit pointer to the variable.) 841 */ 842 case EPT_VARIMPORT32: 843 case EPT_VARIMPORT16: 844 *(unsigned long*)(void*)&callTab[i][0] = _aImportTab[i].ulAddress; 845 *(unsigned long*)(void*)&callTab[i][4] = _aImportTab[i].offObject; 846 *(unsigned short*)(void*)&callTab[i][8] = _aImportTab[i].usSel; 847 *(unsigned short*)(void*)&callTab[i][0xa] = (unsigned short)_aImportTab[i].offObject; 848 *(unsigned short*)(void*)&callTab[i][0xc] = _aImportTab[i].usSel; 849 break; 850 620 851 default: 621 kprintf((" procInit: EPT_VAR is not supported. (procedure no.%d, cb=%d)\n", i, cb));852 kprintf(("ImportTabInit: unsupported type. (procedure no.%d, cb=%d)\n", i, cb)); 622 853 Int3(); /* ipe - later! */ 623 854 return 1; -
trunk/src/win32k/dev32/devlast.asm
r1467 r2832 1 ; $Id: devlast.asm,v 1. 2 1999-10-27 02:02:54bird Exp $1 ; $Id: devlast.asm,v 1.3 2000-02-20 04:27:23 bird Exp $ 2 2 ; 3 3 ; DevLast - the object file termintating the resident part of the objects. … … 31 31 public CONST32_ROEND 32 32 public _CallR0Init32 33 public _CallVerify ProcTab3233 public _CallVerifyImportTab32 34 34 35 35 … … 52 52 53 53 extrn R0INIT32:FAR 54 extrn VERIFY PROCTAB32:FAR54 extrn VERIFYIMPORTTAB32:FAR 55 55 56 56 CODE16 segment … … 76 76 77 77 ;; 78 ; Thunk procedure for Verify ProcTab32.79 ; @cproto USHORT NEAR CallVerify ProcTab32(void);80 ; @returns Same as Verify ProcTab32.78 ; Thunk procedure for VerifyImportTab32. 79 ; @cproto USHORT NEAR CallVerifyImportTab32(void); 80 ; @returns Same as VerifyImportTab32. 81 81 ; @status completely implemented. 82 82 ; @author knut st. osmundsen 83 _CallVerify ProcTab32 PROC NEAR83 _CallVerifyImportTab32 PROC NEAR 84 84 ASSUME CS:CODE16 85 85 push ds 86 call far ptr FLAT:VERIFY PROCTAB3286 call far ptr FLAT:VERIFYIMPORTTAB32 87 87 pop ds 88 88 retn 89 _CallVerify ProcTab32 ENDP89 _CallVerifyImportTab32 ENDP 90 90 91 91 CODE16 ends -
trunk/src/win32k/include/dev16.h
r2831 r2832 1 /* $Id: dev16.h,v 1. 5 2000-02-19 23:52:00bird Exp $1 /* $Id: dev16.h,v 1.6 2000-02-20 04:27:23 bird Exp $ 2 2 * dev16 - 16-bit specific. Should not be used in 32-bit C/C++. 3 3 * … … 112 112 USHORT NEAR CallR0Init32(LIN pRpInit); 113 113 USHORT NEAR CallGetOTEs32(ULONG addressOTEBuf); 114 USHORT NEAR CallVerify ProcTab32(void);114 USHORT NEAR CallVerifyImportTab32(void); 115 115 USHORT NEAR CallElfIOCtl(LIN pRpIOCtl); 116 116 USHORT NEAR CallWin32kIOCtl(LIN pRpIOCtl); -
trunk/src/win32k/include/dev32.h
r2799 r2832 1 /* $Id: dev32.h,v 1. 5 2000-02-15 23:39:19bird Exp $1 /* $Id: dev32.h,v 1.6 2000-02-20 04:27:23 bird Exp $ 2 2 * 3 3 * dev32 - header file for 32-bit part of the driver. … … 57 57 USHORT _loadds _Far32 _Pascal R0Init32(RP32INIT *pRpInit); 58 58 USHORT _loadds _Far32 _Pascal GetOTEs32(PKRNLOBJTABLE pOTEBuf); 59 USHORT _loadds _Far32 _Pascal Verify ProcTab32(void);59 USHORT _loadds _Far32 _Pascal VerifyImportTab32(void); 60 60 USHORT _loadds _Far32 _Pascal ElfIOCtl(PRP32GENIOCTL pRpIOCtl); 61 61 USHORT _loadds _Far32 _Pascal Win32kIOCtl(PRP32GENIOCTL pRpIOCtl); -
trunk/src/win32k/include/probkrnl.h
r2831 r2832 1 /* $Id: probkrnl.h,v 1. 8 2000-02-19 23:52:00bird Exp $1 /* $Id: probkrnl.h,v 1.9 2000-02-20 04:27:24 bird Exp $ 2 2 * 3 3 * Include file for ProbKrnl. … … 34 34 #define EPT_PROC32 (EPT_PROC | EPT_32BIT) 35 35 #define EPT_PROCIMPORT32 (EPT_PROCIMPORT | EPT_32BIT) 36 #define EPT_VARIMPORT32 (EPT_VARIMPORT | EPT_32BIT) 36 37 37 38 /* 16bit types */ 38 39 #define EPT_PROC16 (EPT_PROC | EPT_16BIT) /* no implemented yet! */ 39 40 #define EPT_PROCIMPORT16 (EPT_PROCIMPORT | EPT_16BIT) /* far proc in calltab with a far jmp. */ 41 #define EPT_VARIMPORT16 (EPT_VARIMPORT | EPT_16BIT) 40 42 41 43 … … 53 55 unsigned long int ulAddress; /* 32-bit flat address */ 54 56 unsigned short int usSel; /* Select of the object */ 57 unsigned char cbProlog; /* Size of the prolog needing to be exchanged */ 55 58 unsigned char fType; /* Entry-Point Type Flags */ 56 59 } IMPORTKRNLSYM; -
trunk/src/win32k/ldr/calltab.asm
r2831 r2832 1 ; $Id: calltab.asm,v 1. 7 2000-02-19 23:52:00bird Exp $1 ; $Id: calltab.asm,v 1.8 2000-02-20 04:27:24 bird Exp $ 2 2 ; 3 3 ; callTab - Call back again table - table with entry for each function which is overrided. … … 35 35 public _VMGetOwner@8 36 36 public g_tkExecPgm 37 public f_FuStrLenZ 38 public f_FuBuff 37 39 38 40 … … 112 114 g_tkExecPgm ENDP 113 115 116 117 f_FuStrLenZ PROC FAR 118 db MAXSIZE_PROLOG dup(0cch) 119 f_FuStrLenZ ENDP 120 121 f_FuBuff PROC FAR 122 db MAXSIZE_PROLOG dup(0cch) 123 f_FuBuff ENDP 124 114 125 CALLTAB ENDS 115 126
Note:
See TracChangeset
for help on using the changeset viewer.