NASM Forum > Using NASM

How do I define a function alias for an imported function?

(1/3) > >>

ben321:
If a function is defined in a DLL file under the name abcd1234, and I want it defined in my program under the name abcd, how do I do that?

I tried this in the EXTERN line, like this:

--- Code: ---EXTERN abcd "abcd1234"
--- End code ---

But that didn't work. Is there a way to accomplish this?

Frank Kotler:
Hi ben321,


--- Code: ---%define abcd abcd1234
extern abcd1234

section .text
call abcd
...

--- End code ---

Does  this not work?

Best,
Frank

ben321:

--- Quote from: Frank Kotler on August 01, 2019, 04:06:46 AM ---Hi ben321,


--- Code: ---%define abcd abcd1234
extern abcd1234

section .text
call abcd
...

--- End code ---

Does  this not work?

Best,
Frank

--- End quote ---

I want to create a proxy DLL for game hacking/cheating (imagine having unlimited rocket ammo in GTA5). The game calls certain functions in a DLL file, and I want to trick it to using my DLL instead of the one supplied with the game, so my DLL must have the same name as the original DLL (and of course the original DLL will be renamed), and the names of the functions must also be the same as the names of the functions that the game is expecting.

My plan is to make the functions I want to hook, directly in my program, but the remaining functions must be forwarded to the correct DLL (a renamed copy of the original DLL).

So for example, I need to be able to do this:

--- Code: ---%define abcd abcd1234
extern abcd1234

section .text
export abcd1234
abcd1234:
     jmp abcd

--- End code ---

You see the problem with that? NASM will see the function name abcd1234 being external, in the top of the code, but see the function name abcd1234 lower in the code as an internal function with the same name. The will create an error.

I need to tell the assembler, "I want you to reference an external function called abcd1234, but within this .asm file it shall be called abcd, and NOT be called abcd1234". Is there a way to do that in nasm?

And you know what would be even better than that? Using the official DLL Forwarding functionality that Windows recognizes. This functionality allows a DLL file to contain an Exported function from a different DLL. That is, there is an entry in the DLL's export table, which actually points to a function in a different DLL. Is NASM capable of creating an object file which uses contains this functionality, such that when the object file is processed by a linker that it will actually create the correct forwarding entry in the export table?

ben321:
Does nobody here know how to use the DLL forwarder capabilities of a DLL file?

debs3759:

--- Quote from: ben321 on August 01, 2019, 07:00:42 PM ---Does nobody here know how to use the DLL forwarder capabilities of a DLL file?

--- End quote ---

Somebody might, but this is not a very active forum, and we don't claim to be experts in any operating system, only to processor specific code. If you are patient, someone may be able to help.

Navigation

[0] Message Index

[#] Next page

Go to full version