Yes, something like that. That's a typical wrapper.
Originally, it had a d3d9.dll that got loaded by the game, probably because it has the same name as the actual Windows library. That means that the game would load the "fake" d3d9.dll and then that dll would call the proper library?
Yes and no. A DLL as such does not call functions in a program, it is just a PE image that is loaded into the address space of a process. However, a thread running the executable code in a DLL could certainly call functions in the program, presumed that you are able to determine the function's address and know what it does (and what parameter it takes, etc.).
So, with those methods one could load a dll, but how that dll would interact with the process? Can the dll call functions in the .exe?
Usually, it works the other way around. Normally, the injected DLL replaces some original functionality, and it's a thread from the original process that calls (without realizing) a function in the DLL.
The debugger would need to be compiled into the exe or its just another dll that can be injected?
A small program using CreateProcess, DebugActiveProcess, and WaitForDebugEvent to launch the "real" program.
Of course most non-trivial titles will take more or less sophisticated anti-debugger measures.
Also, note that you are almost certainly breaking the EULA (read as: using a good without permission, thus becoming a criminal in most countries) with that.
So, this guy comes ahead with a profiler, catches up the issue and codes in ASM a replacement for some critical functions in Skyrim's exe
That's all nice and good, but it's almost certainly a breach of EULA. Most probably nobody will care, but in the worst case that guy could find himself in a $50M tortious interference lawsuit.
It is highly unlikely that Skyrim for PC shipped as a debug build. The likely reason why the developers of Skyrim didn't do the same optimizations in the first place (you have to assume they're not complete idiots either!) is that performance was deemed "good enough" on the targeted hardware and that spending extra time on optimizing (and delaying the product) was therefore economically not viable.
Two years ago, one might have added "or maybe they didn't want to depend on SSE2 or have an extra code path", but this is unlikely now, seeing how no modern version of Windows works without SSE2 at all anyway.
Cant see the quote tags for some reason so I'm quoting the entire post.
Well. It actually appeared on the official Bethesda forums, and script extenders have been the norm for TES titles since long ago. No one complained about it. Beth is fairly lenient on that respect, as long as you're not porting content from their games (ie, Morrowind content to Skyrim) or porting content from their DLCs its all good.
That said, I'm inclined to believe the guys who made the injector since they seem to know a fair bit about the subject and they think it was just that some flags in the compiler hadn't been set up properly. And believe me, if a 2500K overclocked to 4Ghz was "good enough performance" for Beth developers, that doesn't speaks good of them either.
Even so, since part of the game did use SSE2, it didn't worked on old processors anyway. So it is likely, believe it or not, that someone screwed it up in the build process. Maybe some incremental compilation issue or something like that. You must assume they're humans too, it can happen.
Anyway, thanks a lot for the info. Now I'm out to break some EULAs! Nah I'm joking I'm still pretty clueless about C++, Windows API, threading and such. And I don't think there is a game out there that could benefit of my limited 8085 assembler knowledge anyway