Lines Matching defs:pDll
244 static void supR3HardenedFindOrLoadModule(PSUPHNTIMPDLL pDll)
247 uint32_t const cbName = (uint32_t)RTUtf16Len(pDll->pwszName) * sizeof(WCHAR);
260 pDll->pszName) == 0)
262 pDll->pbImageBase = (uint8_t *)pLdrEntry->DllBase;
270 if (!pDll->cImports)
271 pDll->pbImageBase = NULL; /* optional */
274 "Failed to locate %ls", pDll->pwszName);
276 HMODULE hmod = GetModuleHandleW(pDll->pwszName);
277 if (RT_UNLIKELY(!hmod && pDll->cImports))
279 "Failed to locate %ls", pDll->pwszName);
280 pDll->pbImageBase = (uint8_t *)hmod;
285 static void supR3HardenedParseModule(PSUPHNTIMPDLL pDll)
290 IMAGE_DOS_HEADER const *pMzHdr = (IMAGE_DOS_HEADER const *)pDll->pbImageBase;
298 "%ls: e_lfanew=%#x, expected a lower value", pDll->pwszName, offNtHdrs);
300 pDll->pNtHdrs = pNtHdrs = (PIMAGE_NT_HEADERS)&pDll->pbImageBase[offNtHdrs];
304 "%ls: Invalid PE signature: %#x", pDll->pwszName, pNtHdrs->Signature);
307 "%ls: Unexpected optional header size: %#x", pDll->pwszName, pNtHdrs->FileHeader.SizeOfOptionalHeader);
310 "%ls: Unexpected optional header magic: %#x", pDll->pwszName, pNtHdrs->OptionalHeader.Magic);
313 "%ls: Unexpected number of RVA and sizes: %#x", pDll->pwszName, pNtHdrs->OptionalHeader.NumberOfRvaAndSizes);
315 pDll->offNtHdrs = offNtHdrs;
316 pDll->offEndSectHdrs = offNtHdrs
319 pDll->cbImage = pNtHdrs->OptionalHeader.SizeOfImage;
326 || ExpDir.VirtualAddress < pDll->offEndSectHdrs
330 "%ls: Missing or invalid export directory: %#lx LB %#x", pDll->pwszName, ExpDir.VirtualAddress, ExpDir.Size);
331 pDll->offExportDir = ExpDir.VirtualAddress;
332 pDll->cbExportDir = ExpDir.Size;
334 IMAGE_EXPORT_DIRECTORY const *pExpDir = (IMAGE_EXPORT_DIRECTORY const *)&pDll->pbImageBase[ExpDir.VirtualAddress];
342 pDll->pwszName, pExpDir->NumberOfFunctions, pExpDir->NumberOfNames);
343 pDll->cNamedExports = pExpDir->NumberOfNames;
344 pDll->cExports = RT_MAX(pExpDir->NumberOfNames, pExpDir->NumberOfFunctions);
346 if ( pExpDir->AddressOfFunctions < pDll->offEndSectHdrs
348 || pExpDir->AddressOfFunctions + pDll->cExports * sizeof(uint32_t) > pNtHdrs->OptionalHeader.SizeOfImage)
350 "%ls: Bad AddressOfFunctions: %#x\n", pDll->pwszName, pExpDir->AddressOfFunctions);
351 pDll->paoffExports = (uint32_t const *)&pDll->pbImageBase[pExpDir->AddressOfFunctions];
353 if ( pExpDir->AddressOfNames < pDll->offEndSectHdrs
357 "%ls: Bad AddressOfNames: %#x\n", pDll->pwszName, pExpDir->AddressOfNames);
358 pDll->paoffNamedExports = (uint32_t const *)&pDll->pbImageBase[pExpDir->AddressOfNames];
360 if ( pExpDir->AddressOfNameOrdinals < pDll->offEndSectHdrs
364 "%ls: Bad AddressOfNameOrdinals: %#x\n", pDll->pwszName, pExpDir->AddressOfNameOrdinals);
365 pDll->pau16NameOrdinals = (uint16_t const *)&pDll->pbImageBase[pExpDir->AddressOfNameOrdinals];
369 static const char *supR3HardenedResolveImport(PSUPHNTIMPDLL pDll, PCSUPHNTIMPFUNC pImport, bool fReportErrors)
375 uint32_t iEnd = pDll->cNamedExports;
379 uint32_t offExpName = pDll->paoffNamedExports[iCur];
380 if (RT_UNLIKELY(offExpName < pDll->offEndSectHdrs || offExpName >= pDll->cbImage))
382 "%ls: Bad export name entry: %#x (iCur=%#x)", pDll->pwszName, offExpName, iCur);
384 const char *pszExpName = (const char *)&pDll->pbImageBase[offExpName];
392 uint16_t iExpOrdinal = pDll->pau16NameOrdinals[iCur];
393 if (iExpOrdinal < pDll->cExports)
395 uint32_t offExport = pDll->paoffExports[iExpOrdinal];
398 if (offExport >= pDll->cbImage)
399 pDll->cPatchedExports++;
401 if (offExport - pDll->offExportDir >= pDll->cbExportDir)
403 *pImport->ppfnImport = (PFNRT)&pDll->pbImageBase[offExport];
408 return (const char *)&pDll->pbImageBase[offExport];
412 pDll->pwszName, iExpOrdinal, pDll->cExports);
419 "%ls: Failed to resolve '%s'.", pDll->pwszName, pImport->pszName);
425 static void supR3HardenedDirectSyscall(PSUPHNTIMPDLL pDll, PCSUPHNTIMPFUNC pImport, PCSUPHNTIMPSYSCALL pSyscall,
438 int rc = RTLdrGetSymbolEx(pLdrEntry->hLdrMod, pbBits, (uintptr_t)pDll->pbImageBase, UINT32_MAX, pImport->pszName, &uValue);
442 "%s: RTLdrGetSymbolEx failed on %s: %Rrc", pDll->pszName, pImport->pszName, rc);
445 uintptr_t offSymbol = (uintptr_t)uValue - (uintptr_t)pDll->pbImageBase;
548 pDll->pwszName, pImport->pszName, &abCopy[0]);