This is a phantom DLL case on Windows 7 – funny bug in c:\WINDOWS\system32\spreview.exe.
When it starts it loads wdscore.dll library, but it does it incorrectly, and as a result it tries to load C:\WINDOWS\system32\spreview.exewdscore.dll file first.
So, if you place such library on a system, anytime spreview is launched, the spreview.exewdscore.dll DLL will be loaded. It’s also a Lolbin, of cuz.
The bad news – it’s used very rarely as it’s related to Service Pack installation. The better news — since spreview.exe is a part of a OS and signed, you could add it to any startup location and it will load that funnily-named DLL when it starts.
Turns out this key has a twin brother, called AeDebugProtected.
When the WerpGetDebugger function is called, it calls NtQueryInformationProcess to retrieve a basic information about the process. If the process’s basic info data at position 28 (32-bit!) returns a dword value that if masked with 1 is non-zero then AeDebugProtected key is used…
Okay, this is confusing… Let’s step back.
The traditional way of calling NtQueryInformationProcesswith ProcessBasicInformation class is typically delivered using a ‘classic’ definition of _PROCESS_BASIC_INFORMATION structure being:
In both cases the size of a structure is 24 bytes (32-bit system!). When I looked at the code of WerpGetDebugger I was surprised to see that some calls to NtQueryInformationProcess / ProcessBasicInformation rely on a structure that is 32 bytes long!
Okay, so now we know there is some extra information provided by NtQueryInformationProcess to WerpGetDebugger function and that data determines which debug key is being used. Since this ntdll function is simply passed to kernel, I went to look at the code of NtQueryInformationProcess inside ntoskrnl.exe. I quickly discovered that the function does indeed expect a structure that is either 24 or 32 bytes long. Cool.
Continuing my analysis I noticed that the the field at the position 28 is filled in with a result of a call to a function called PsIsProtectedProcess. Protected processes [DOC warning] is a technology described in the past, so not a biggie. And the fact this is what is being checked by the function is of course something we should have expected, given the name used by the Registry Key I mentioned earlier, however… at least we can confirm this with our code analysis…
And here we are with a few conclusive bits:
NtQueryInformationProcess / ProcessBasicInformation may use 2 different structure versions!
The field at offset 28 (32-bit!) tells us if the process is protected or not. Depending on this, different AeDebug Registry key will be used to launch debugger when the app crashes.