Changeset 6192 for trunk/src/win32k/ldr/myldrFindModule.cpp
- Timestamp:
- Jul 7, 2001, 6:39:11 AM (24 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/win32k/ldr/myldrFindModule.cpp
r5086 r6192 1 /* $Id: myldrFindModule.cpp,v 1. 2 2001-02-10 11:11:46bird Exp $1 /* $Id: myldrFindModule.cpp,v 1.3 2001-07-07 04:39:11 bird Exp $ 2 2 * 3 3 * ldrFindModule - ldrFindModule replacement with support for long DLL names … … 48 48 extern PPMTE pspecific_l; 49 49 50 /******************************************************************************* 51 * Internal Functions * 52 *******************************************************************************/ 53 int mymemicmp(void *pv1, void *pv2, unsigned int cch); 54 50 55 51 56 /** … … 56 61 * 57 62 * @returns NO_ERROR on success. 63 * If not found we'll still return NO_ERROR, but *ppMTE is NULL. 58 64 * OS/2 errorcode on error. 59 65 * @param pachFilename Pointer to module filename. … … 73 79 ULONG LDRCALL myldrFindModule(PCHAR pachFilename, USHORT cchFilename, USHORT usClass, PPMTE ppMTE) 74 80 { 81 /* 82 * Log. 83 */ 84 kprintf(("myldrFindModule: fn=%.*s len=%d class=0x%02x ppMTE=0x%08x\n", cchFilename, pachFilename, cchFilename, usClass, ppMTE)); 85 75 86 /* Check if this feature is enabled */ 76 87 if (isDllFixesDisabled()) … … 78 89 #ifdef DEBUG 79 90 APIRET rc = ldrFindModule(pachFilename, cchFilename, usClass, ppMTE); 80 kprintf(("ldrFindModule: fn=%.*s len=%d class=0x%02x ppMTE=0x%08x rc=%d (original)\n", cchFilename, pachFilename, cchFilename, usClass, ppMTE, rc)); 91 if (rc == NO_ERROR && *ppMTE == NULL) 92 kprintf(("myldrFindModule: Not Found\n")); 93 else 94 kprintf((usClass == CLASS_GLOBAL 95 ? "myldrFindModule: Found pmte=0x%08x hmte=0x%04x modname=%.8s path=%s (GLOBAL)\n" 96 : "myldrFindModule: Found pmte=0x%08x hmte=0x%04x modname=%.8s path=%s (%x)\n", 97 *ppMTE, (*ppMTE)->mte_handle, (*ppMTE)->mte_modname, 98 (*ppMTE)->mte_swapmte->smte_path, (*ppMTE)->mte_flags1 & CLASS_MASK)); 81 99 return rc; 82 100 #else … … 105 123 int cchExt; /* Length of the extention part of pachFilename. (not dot!) */ 106 124 int cchName8; /* Length of modname in MTE. */ 125 int fDllExt = FALSE; /* Set if we have a .DLL extention. */ 107 126 108 127 /* … … 123 142 } 124 143 125 /*126 * Log.127 */128 kprintf(("myldrFindModule: fn=%.*s len=%d class=0x%02x ppMTE=0x%08x\n", cchFilename, pachFilename, cchFilename, usClass, ppMTE));129 144 130 145 /* … … 194 209 pachExt = "DLL"; 195 210 cchExt = 3; 211 fDllExt = TRUE; 196 212 } 197 213 else 198 214 { 199 215 cchName = pachExt - pachName; 216 cchExt = cchFilename - cchName - 1; 217 if ( cchExt == 3 && !memcmp(pachExt, ".DLL", 4) 218 || cchName < 8 && !memcmp(pachExt, ".DLL", min(3, cchExt)) 219 ) 220 fDllExt = TRUE; 200 221 pachExt++; 201 cchExt = cchFilename - cchName - 1; 202 } 203 204 cchName8 = cchName > 8 ? 8 : cchName; 222 } 223 224 if (fDllExt) 225 cchName8 = cchName > 8 ? 8 : cchName; 226 else 227 cchName8 = cchFilename > 8 ? 8 : cchFilename; 205 228 206 229 #ifdef DEBUG … … 264 287 */ 265 288 if (usClass == CLASS_GLOBAL) 266 { /* 289 { 290 #if 0 /* fault code... Search for DBE.DLL may hit DBEQ.DLL.. */ 291 /* 267 292 * DLLs, match name only: 268 293 * Check the module name from the resident MTE. … … 292 317 ) 293 318 ) 319 #else 320 BOOL fFound; /* Flag which is set if this mte match the name we're searching for. */ 321 322 if (cchName <= 8 && fDllExt) 323 { /* 324 * Compatability code. 325 * Well only near compatible. If the internalname contains .DLL we will be able 326 * to find a few modules which OS2 normally won't find. Disable the latest check 327 * to make us 100% compatible. 328 */ 329 fFound = !memcmp(pmte->mte_modname, pachFilename, cchName) 330 && ( cchName == 8 331 || pmte->mte_modname[cchName] == '\0' 332 || !memcmp(&pmte->mte_modname[cchName], ".DLL", min(5, 8 - cchName)) /* extra feature */ 333 ); 334 } 335 else 336 { /* 337 * Extention code. 338 * There is a part of the name in the mte_modname. Check that first to eliminate 339 * the next step where we access swappable code. 340 * fDllExt: 341 * These may or may not include the .DLL extention in the internal name. 342 * !fDllExt: 343 * These should contain the entire name in the internal name. 344 * If no filename extension, then the internal name should end with a '.'. 345 * NB! We have an issue of casesensitivity here... (ARG!!!) 346 * That make this stuff a bit more expensive... 347 * Possible fix is to use the filename, or to require an uppercased internal name... 348 */ 349 fFound = !memcmp(pmte->mte_modname, pachFilename, cchName8); 350 if (fFound) 351 { 352 PCHAR pachResName; /* Pointer to the internal name - resname.0 */ 353 pachResName = (PCHAR)pmte->mte_swapmte->smte_restab; 354 if ((char*)pachResName < (char*)0x10000) 355 { 356 kprintf(("myldrFindModule: Holy Hand Grenade! there aint any resident names for this mte (0x%x)\n", pmte)); 357 pachResName = "\0"; 358 } 359 if (fDllExt) 360 fFound = ( *pachResName == cchName 361 || ( *pachResName == cchName + 4 362 && !mymemicmp(&pachResName[1+cchName], ".DLL", 4) 363 ) 364 ) 365 && !mymemicmp(pachResName + 1, pachFilename, cchName); 366 else 367 fFound = *pachResName == cchName + cchExt + 1 368 && !mymemicmp(pachResName+1, pachFilename, cchName + cchExt + 1); 369 } 370 } 371 372 if (fFound) 373 #endif 294 374 { 295 375 *ppMTE = pmte; 296 376 kprintf(("myldrFindModule: Found pmte=0x%08x hmte=0x%04x modname=%.8s path=%s (GLOBAL)\n", 297 pmte, pmte->mte_handle, pmte->mte_modname, p SMTE->smte_path));377 pmte, pmte->mte_handle, pmte->mte_modname, pmte->mte_swapmte->smte_path)); 298 378 return NO_ERROR; 299 379 } … … 306 386 */ 307 387 PSMTE pSMTE = pmte->mte_swapmte; 308 if ( ( cchName8 == 0 /* This is 0 if we should not check the mte_modname. */309 || !memcmp(pmte->mte_modname, pachName, cchName8)310 )388 if ( ( cchName8 == 0 /* This is 0 if we should not check the mte_modname. */ 389 || !memcmp(pmte->mte_modname, pachName, cchName8) 390 ) 311 391 && pSMTE->smte_pathlen == cchFilename - 1 312 392 && !memcmp(pSMTE->smte_path, pachFilename, cchFilename) /* checks the '\0' too. */ … … 330 410 } 331 411 412 413 414 /** 415 * This function is needed since pv1 might be a mixed case name. 416 * @returns same as memcmp. 417 * @param pv1 Pointer to resident name or part of that. Might be mixed cased. 418 This is uppercased. 419 * @param pv2 Pointer to name. ASSUMES Uppercase. 420 * @param cch Length 421 * @remark 422 */ 423 int mymemicmp(void *pv1, void *pv2, unsigned int cch) 424 { 425 #if 0 /* safe code which doesn't modify the resident name... */ 426 if (!memcmp(pv1, pv2, cch)) 427 return 0; 428 char *pach = (char*)SSToDS(alloca(cch)); 429 memcpy(pach, pv2, cch); 430 ldrUCaseString(pach, cch); 431 return memcmp(pv1, pach, cch); 432 #else 433 if (!memcmp(pv1, pv2, cch)) 434 return 0; 435 ldrUCaseString((PCHAR)pv1, cch); 436 return memcmp(pv1, pv2, cch); 437 #endif 438 }
Note:
See TracChangeset
for help on using the changeset viewer.