The Windows KnownDlls Directory is a directory of commonly used system DLLs that the Windows loader leverages to optimize the application startup process.
This approach saves memory by reducing the need to map each required DLL from disk.
The KnowDLLs directory location is:
\KnownDlls\
Inspecting KnownDLLs
Using SysInternalsWinObj we can inspect the KnownDLLs directory.
(1.8 MB)Run now from .
Retrieving Ntdll.dll from KnownDlls
To retrieve DLL's mapped in the KnowDlls directory requires a handle. Two functions are required:
NtOpenSection to obtain the section handle for ntdll.dll. (OpenFileMapping Always fails with ERROR_BAD_PATHNAME, this is it's NTAPI equivalant.).
MapViewOfFile to map ntdll.dll to memory.
View Calling NTAPI Directly for help
// getting the handle of ntdll.dll from KnownDlls
STATUS = pNtOpenSection(&hSection, SECTION_MAP_READ, &ObjAtr);
if (STATUS != 0x00) {
printf("[!] NtOpenSection Failed With Error : 0x%0.8X \n", STATUS);
goto _EndOfFunc;
}
Code
The code only includes reading KnownDLL into a buffer, the function for copying memory over can be found above in previous pages.