@@ -332,57 +332,57 @@ static wchar_t* lastslash(wchar_t* s, int len) {
332
332
return nullptr ;
333
333
}
334
334
335
- static bool ShouldBlockBasedOnBlockInfo (const DllBlockInfo* info,
335
+ static bool ShouldBlockBasedOnBlockInfo (const DllBlockInfo& info,
336
336
const char * dllName, PWCHAR filePath,
337
337
wchar_t * fname,
338
338
unsigned long long * fVersion ) {
339
339
#ifdef DEBUG_very_verbose
340
340
printf_stderr (" LdrLoadDll: info->mName: '%s'\n " , info->mName );
341
341
#endif
342
342
343
- if (info-> mFlags & DllBlockInfo::REDIRECT_TO_NOOP_ENTRYPOINT) {
343
+ if (info. mFlags & DllBlockInfo::REDIRECT_TO_NOOP_ENTRYPOINT) {
344
344
printf_stderr (
345
345
" LdrLoadDll: "
346
346
" Ignoring the REDIRECT_TO_NOOP_ENTRYPOINT flag\n " );
347
347
}
348
348
349
- if ((info-> mFlags & DllBlockInfo::BLOCK_WIN8_AND_OLDER) &&
349
+ if ((info. mFlags & DllBlockInfo::BLOCK_WIN8_AND_OLDER) &&
350
350
IsWin8Point1OrLater ()) {
351
351
return false ;
352
352
}
353
353
354
- if ((info-> mFlags & DllBlockInfo::BLOCK_WIN7_AND_OLDER) && IsWin8OrLater ()) {
354
+ if ((info. mFlags & DllBlockInfo::BLOCK_WIN7_AND_OLDER) && IsWin8OrLater ()) {
355
355
return false ;
356
356
}
357
357
358
- if ((info-> mFlags & DllBlockInfo::CHILD_PROCESSES_ONLY) &&
358
+ if ((info. mFlags & DllBlockInfo::CHILD_PROCESSES_ONLY) &&
359
359
!(sInitFlags & eDllBlocklistInitFlagIsChildProcess)) {
360
360
return false ;
361
361
}
362
362
363
- if ((info-> mFlags & DllBlockInfo::UTILITY_PROCESSES_ONLY) &&
363
+ if ((info. mFlags & DllBlockInfo::UTILITY_PROCESSES_ONLY) &&
364
364
!(sInitFlags & eDllBlocklistInitFlagIsUtilityProcess)) {
365
365
return false ;
366
366
}
367
367
368
- if ((info-> mFlags & DllBlockInfo::SOCKET_PROCESSES_ONLY) &&
368
+ if ((info. mFlags & DllBlockInfo::SOCKET_PROCESSES_ONLY) &&
369
369
!(sInitFlags & eDllBlocklistInitFlagIsSocketProcess)) {
370
370
return false ;
371
371
}
372
372
373
- if ((info-> mFlags & DllBlockInfo::GPU_PROCESSES_ONLY) &&
373
+ if ((info. mFlags & DllBlockInfo::GPU_PROCESSES_ONLY) &&
374
374
!(sInitFlags & eDllBlocklistInitFlagIsGPUProcess)) {
375
375
return false ;
376
376
}
377
377
378
- if ((info-> mFlags & DllBlockInfo::BROWSER_PROCESS_ONLY) &&
378
+ if ((info. mFlags & DllBlockInfo::BROWSER_PROCESS_ONLY) &&
379
379
(sInitFlags & eDllBlocklistInitFlagIsChildProcess)) {
380
380
return false ;
381
381
}
382
382
383
383
*fVersion = DllBlockInfo::ALL_VERSIONS;
384
384
385
- if (info-> mMaxVersion != DllBlockInfo::ALL_VERSIONS) {
385
+ if (info. mMaxVersion != DllBlockInfo::ALL_VERSIONS) {
386
386
ReentrancySentinel sentinel (dllName);
387
387
if (sentinel.BailOut ()) {
388
388
return false ;
@@ -398,24 +398,35 @@ static bool ShouldBlockBasedOnBlockInfo(const DllBlockInfo* info,
398
398
return true ;
399
399
}
400
400
401
- if (info-> mFlags & DllBlockInfo::USE_TIMESTAMP) {
401
+ if (info. mFlags & DllBlockInfo::USE_TIMESTAMP) {
402
402
*fVersion = GetTimestamp (full_fname.get ());
403
- if (*fVersion > info-> mMaxVersion ) {
403
+ if (*fVersion > info. mMaxVersion ) {
404
404
return false ;
405
405
}
406
406
} else {
407
407
LauncherResult<ModuleVersion> version =
408
408
GetModuleVersion (full_fname.get ());
409
409
410
410
if (version.isOk ()) {
411
- return info-> IsVersionBlocked (version.unwrap ());
411
+ return info. IsVersionBlocked (version.unwrap ());
412
412
}
413
413
}
414
414
}
415
415
416
416
return true ;
417
417
}
418
418
419
+ struct CaseSensitiveStringComparator {
420
+ explicit CaseSensitiveStringComparator (const char * aTarget)
421
+ : mTarget(aTarget) {}
422
+
423
+ int operator ()(const DllBlockInfo& aVal) const {
424
+ return strcmp (mTarget , aVal.mName );
425
+ }
426
+
427
+ const char * mTarget ;
428
+ };
429
+
419
430
static NTSTATUS NTAPI patched_LdrLoadDll (PWCHAR filePath, PULONG flags,
420
431
PUNICODE_STRING moduleFileName,
421
432
PHANDLE handle) {
@@ -509,21 +520,26 @@ static NTSTATUS NTAPI patched_LdrLoadDll(PWCHAR filePath, PULONG flags,
509
520
510
521
511
522
DECLARE_POINTER_TO_FIRST_DLL_BLOCKLIST_ENTRY (info);
512
- while (info->mName ) {
513
- if (strcmp (info->mName , dllName) == 0 ) {
523
+ DECLARE_DLL_BLOCKLIST_NUM_ENTRIES (infoNumEntries);
524
+ CaseSensitiveStringComparator comp (dllName);
525
+ size_t match = LowerBound (info, 0 , infoNumEntries, comp);
526
+ if (match != infoNumEntries) {
527
+
528
+
529
+
530
+ while (match < infoNumEntries && (comp (info[match]) == 0 )) {
514
531
unsigned long long fVersion ;
515
- if (ShouldBlockBasedOnBlockInfo (info, dllName, filePath, fname,
532
+ if (ShouldBlockBasedOnBlockInfo (info[match] , dllName, filePath, fname,
516
533
&fVersion )) {
517
534
printf_stderr (
518
535
" LdrLoadDll: Blocking load of '%s' -- see "
519
536
" http://www.mozilla.com/en-US/blocklist/\n " ,
520
537
dllName);
521
- DllBlockSet::Add (info-> mName , fVersion );
538
+ DllBlockSet::Add (info[match]. mName , fVersion );
522
539
return STATUS_DLL_NOT_FOUND;
523
540
}
541
+ ++match;
524
542
}
525
-
526
- info++;
527
543
}
528
544
}
529
545
0 commit comments