Click here to Skip to main content
15,867,308 members
Articles / Programming Languages / MASM

ProxiFy - Automatic Proxy DLL Generation

Rate me:
Please Sign up or sign in to vote.
5.00/5 (6 votes)
28 Mar 2017CPOL4 min read 33.2K   1.5K   15   10
Automated proxy DLL generation with 64 and 32 bit DLL support

Introduction

ProxiFy allows the user to quickly create a proxy DLL that uses either 64 bit or 32 bit DLLs. It generated the necessary ASM code to make the DLL work in both architectures. It also doesn't make use of dumpbin to generate the exports for the DLL. So there are no additional steps than just selecting the DLL you want to make a proxy of.

I made this project quite quickly and have found it useful for myself, and figured someone else might find it helpful.

Background

I used to create my proxy DLLs using "wrappit" by but found that it doesn't support 64 bit architecture DLLs and it was a bit slow for my taste in terms of how many steps were needed to create a DLL (sometimes, I would have to create several, and using dumpbin to generate the exports was a bit of an annoyance).

I use the same technique of using a jmp to jump to the exported address, and it's heavily inspired by wrappit.

Compiling ProxiFy

To compile ProxiFy, make sure you include the following libs:

  • Imagehlp.lib
  • dbghelp.lib

and set the Character Set to "Use Multi-Byte Character Set".

Using ProxiFy

Using ProxiFy is very easy, the idea behind it was to shorten the amount of steps needed to create a proxy DLL.

All you need to do is run ProxiFy.exe and you will be prompted to select a .dll file.

Step 1

Image 1

Once the DLL has been selected, you will receive a messagebox saying either "32 bit file" or "64 bit file". The only purpose of this messagebox is to let the user know what architecture of DLL they just created a proxy of. I found this somewhat useful, but you can remove it if you want in the source, it has no other purpose.

Step 2

Image 2

Result

ProxiFy will create 3 files if it's a 64 bit DLL, and 2 files if it's a 32 bit DLL. I will go over how to create a proxy DLL project below, I am using Visual Studio 2015 for this example.

Step 1

First create a DLL project, I won't go over how to do this as there are several great articles on this topic.

Step 2

Once you have done that, add the .cpp file and the .def file to the project. Make sure to go into the linker settings and setting the .def file as the Module Definition File. You find this option under Properties -> Linker -> Input.

If the project is a 32 bit project, make sure to set the project as Win32 (or x86). Then you are done.

Additional Steps for 64 bit DLLs

Step 1

If you have a 64 bit DLL, a .asm file was created alongside the .cpp and .def files. Before you add this to the project, you should right click the project -> Build Dependencies -> Build Customizations... and then check ".masm". This will allow the .asm file to work correctly.

Image 3

Step 2

Now add the .asm file to the project as well. I'm not sure if the correct settings are set automatically, so to double check, right click it and go to properties. And under "General -> Item Type", make sure it's set to: Microsoft Macro Assembler.

Image 4

PS

As this is a proxy DLL, it needs the original DLL in the same folder. ProxiFy assumes that you will have the original DLL with an underscore after the name. So steam_api64.dll will instead become steam_api64_.dll.
This can be changed either in ProxiFy or you can just change the LoadLibrary call in the resulting CPP file.

Points of Interest

The project does NOT work with DLLs that are using ordinals for their exports. This can be done but so far I have not had any problems not using ordinals for the exports. It's discouraged in general from what I can tell, so I haven't included it as I haven't needed it yet.

I have only tested ProxiFy on Windows 7, 64 bit.

History

  • 2017-03-28: Original post
  • 2017-03-29: Updated bug in the generation of 32 bit dlls

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Sweden Sweden
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
QuestionVS 2019 properties to solve build errors (Solved) Pin
Shrout121-Nov-19 7:40
Shrout121-Nov-19 7:40 
The author mentions that the project properties have to be changed. This is how you change them in VS 2019 to be able to compile the project successfully.

Open the project properties and goto the following locations:
Properties > Linker > Input > Additional Dependencies
Add "imagehlp.lib" and "dbghelp.lib"
Delimit these with semi-colons ";"
And
Project -> Properties -> Advanced -> Character Set option to Use Multi-Byte Character Set

QuestionNice, but some fatal bugs Pin
big__bang7-Jun-18 4:28
big__bang7-Jun-18 4:28 
QuestionCan't Build, it says "Unresolved external symbol RunASM" Pin
mockba.the.borg14-Dec-17 4:47
mockba.the.borg14-Dec-17 4:47 
AnswerRe: Can't Build, it says "Unresolved external symbol RunASM" Pin
KulaGGin20-Jul-23 9:52
KulaGGin20-Jul-23 9:52 
QuestionLink to Wrappit Pin
Rick York28-Mar-17 6:26
mveRick York28-Mar-17 6:26 
AnswerRe: Link to Wrappit Pin
Kristoffer Blasiak28-Mar-17 7:39
Kristoffer Blasiak28-Mar-17 7:39 
GeneralRe: Link to Wrappit Pin
Rick York28-Mar-17 10:41
mveRick York28-Mar-17 10:41 
BugDownload link not working Pin
Bryian Tan28-Mar-17 3:11
professionalBryian Tan28-Mar-17 3:11 
GeneralRe: Download link not working Pin
Kristoffer Blasiak28-Mar-17 3:21
Kristoffer Blasiak28-Mar-17 3:21 
GeneralRe: Download link not working Pin
Bryian Tan28-Mar-17 3:23
professionalBryian Tan28-Mar-17 3:23 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.