ARTICLE AD BOX
I'm trying to create a DLL proxy based on many similar projects online. I am aware of the multitude of posts about DLL proxying on this site and others, but few are recent and I am unable to reproduce the correct answers.
I am using .local redirection and testing with version.dll as many others have, but I've also tried proxying wininet.dll with the same results. I already have the .local redirection working, but I can't seem to find a good way to import "passthrough" functions from the original library in Visual Studio 2022. All of my attempts have started with a freshly created DLL project in Visual Studio 2022. I'm trying to keep this as brief as possible without removing important information. Here's what I've tried:
Using #pragma like so:
#pragma comment(linker, "/export:GetFileVersionInfoA=\"C:\\Windows\\System32\\version.GetFileVersionInfoA\"")This is simple copy-paste from this GitHub. This compiles, but Dependency Walker claims that it cannot find c:\windows\system32\VERSION when I open the target application with it. The path to VERSION is has a yellow icon, and is missing the .DLL that other properly-resolving DLLs have. Starting the target application generates code 0xc000007b. I'm not sure if I'm supposed to include the .DLL extension here, and I'm not sure how to do that without that getting confused with the target function name (since adding the dot is ambiguous). I've also played around with the capitalization, which also does not help.
I've tried adding .dll like this post, and trying variations with and without the ,@1 at the end, but still nothing works.Using a DEF file. First, I copied the DEF file from the above github README. I went into Project -> version Properties -> Linker -> Input and added the module definition file, then finally added the version.lib file to the project by right-clicking on the project and using the Add -> Existing Item dialog, then navigating to the lib file. This compiled again, but I encountered the same errors in Dependency Walker and when starting the application.
Using LoadLibrary and inline assembly jumps like this code in a different GitHub repo. (also shown in this StackOverflow This produces two notable errors: '__declspec(identifier)' is not a recognized extended attribute and nonstandard extension used: '__asm' keyword not supported on this architecture. From what I'm reading, inline assembly just isn't supported on the 64-bit microsoft compiler. I'm not aware of any viable native-C alternative to include a single jump instruction.
I've tried assuming the compiler will optimize this code to a jmp instruction by defining a dummy wrapper function, but this is doesn't generate the desired instruction, and doesn't work in practiceCopy-paste from the original header. I can copy the function definition out of the header along with all of the required typedefs and write a new function and/or proxy to a function pointer, but this is a massive amount of unnecessary code where a single jmp instruction would suffice.
I haven't tried it, but I could rename the original DLL and import that natively. This is something I'd also like to avoid because I'm creating unnecessary copies of a file.
Since I cannot get others' code to build, I'm assuming I'm either setting something up wrong, or this older code is not compatible with new compilers. Can any of the first three approaches be made to work in 2026?
