gigaman wrote:Well, sure - I rather meant what library was that, if you specified the full path, etc.
I tried with my custom inject.dll which was in the same folder as the .exe, and I tried with msvcrt.dll which was in 32-bit system32 folder. Both loaded without errors (i.e. I got valid module handle). I specified just the filename.ext as you should always do, because hard-coding any paths is evil.
gigaman wrote:And yes, TC uses LoadLibrary() to load plugins - which is actually wrong in my opinion; I'd find LoadLibraryEx(.., .., LOAD_WITH_ALTERED_SEARCH_PATH) better, because you wouldn't have to install 3rd party libraries, needed for TC plugins, directly into TC directory.
You don't have to put them into TC directory anyway and there is really no need to use altered search path. You can put those DLLs in system folder and they will be found.
gigaman wrote:When the redirection is enabled (which is the default), all access to Windows\System32 folder goes to Windows\SysWOW64 instead - the folder which holds the 32bit versions of the DLLs.
You are mixing things, API name is Wow64DisableWow64
FsRedirection(). Fs stands for filesystem. So just the filesystem API can be affected by this -- CreateFile(), whatever works with
file HANDLEs.
gigaman wrote:So, I was trying to say that when the redirection is disabled (so the subsequent access goes to the real Windows\System32 folder with the 64bit versions of the DLLs) and the executed code (not aware of Win64) uses this path to load a DLLs, it will actually try to load a 64bit library - which is not possible.
gigaman, I believe you don't have correct info on this.
First, LoadLibrary() is exported from KERNEL32.DLL. When you start a 32-bit process, it gets \WINDOWS\SYSWOW64\KERNEL32.DLL mapped in its address space regardless of the redirection state because real 64-bit KERNEL32.DLL could not be mapped anyway -- it requires 64-bit types as arguments.
Second, once the KERNEL32.DLL is mapped into process address space, it is not unmapped until the process exits.
From those two points one simple logical consequence can be drawn -- when you call LoadLibrary() you are
always calling 32-bit version which will surely try (and succeed in) loading of 32-bit DLLs.
GetSystemDirectory() is obsolete and should not be used anymore if at all possible. LoadLibrary() searches system directory even without you adding it to the file path.
If in doubt, you should check
Dynamic-Link Library Search Order.
If for some reason LoadLibrary() can't find a DLL, you can explicitly specify additional search path using SetDllDirectory() and from that point on you will have alternate search order which is listed
here under Remarks section.
Anyway, why are we wasting time on discussion when Christian could compile new TC version just with Wow64DisableWow64FsRedirection() call at the start and email it to me for testing? You can tell me which plugins you suspect to fail and I will test them and report here so he will know whether he can safely implement my suggestion or not. Of course, if he wants to. I am available with my XP x64 for testing.