Hello
Please advise. I making DLL, and need to set an exportfunction that redirects to another function. In VC this is
LIBRARY dinput8
EXPORTS
DirectInput8Create = ProxyDirectInput8Create @1
But how to do it into Pelles? Its dont accept .def files, in code I only can set
__declspec(dllexport,naked) int ProxyDirectInput8Create()
not redirect
Hello,
Not sure if this example is what you are looking for but it forwards functions to another DLL.
.386
.model flat,stdcall
option casemap:none
include \masm32\include\windows.inc
include \masm32\include\kernel32.inc
include fwdfuncs.inc
includelib \masm32\lib\kernel32.lib
includelib fwdfuncs.lib
.data
message db 'Hello from the forwarded function',0
.code
start:
invoke Cls ; forwarded to Console.ClearScreen
invoke szUpper,ADDR message
invoke ConOut,ADDR message ; forwarded to Console.StdOut
invoke ExitProcess,0
END start
Functions called from fwdfuncs.dll are forwarded to console.dll
Thank you Vortex
With PEView you see this:
TimoVJL
yes, but I don't build some secret soft. I want to build proxy-dll for DirectX
In a your first message you show an alias case, not forwanding.
Luckily Vortex helped you, as he had a crystal ball :biggrin:
Quoteshow an alias case, not forwanding.
Hrm... what difference?
alias make alias name for symbol in same module
forward make name for symbol to forward to other module
Thank you Timo
But since you're here. How do I do this in Pelles C? VS knows .def files, PellesC not?
The aliases in module defintion files are problematic. Here is an example :
.def file :
LIBRARY ConsFuncs
EXPORTS
"_cls@0"=_ClearScreen@0
"_WriteConsole@4"=_StdOut@4
StrLen
locate
The new names are decorated in the DLL :
\PellesC\bin\podump.exe /exports ConsFuncs.dll
Dump of ConsFuncs.dll
ordinal hint address name
1 0 1000100C StrLen
2 1 1000106D _WriteConsole@4
3 2 100010A3 _cls@0
4 3 10001044 locate
Quick example calling the functions :
.386
.model flat, stdcall
option casemap :none
ExitProcess PROTO :DWORD
includelib \PellesC\lib\Win\kernel32.lib
includelib ConsFuncs.lib
cls PROTO
WriteConsole PROTO :DWORD
StrLen PROTO :DWORD
locate PROTO :DWORD,:DWORD
.data
message db 'Hello world!',13,10
db 'This is a console application.',13,10,0
.code
start:
invoke StrLen,ADDR message ; just for testing
invoke cls
invoke WriteConsole,ADDR message
invoke ExitProcess,0
END start
A better solution is to recreate the import library and avoid the mangled names in the DLL.
ConsFuncs.def :
LIBRARY ConsFuncs
EXPORTS
"cls"=_ClearScreen@0
"WriteConsole"=_StdOut@4
StrLen
locate
ConsFuncs2.def :
LIBRARY ConsFuncs
EXPORTS
"_cls@0"
"_WriteConsole@4"
"_StrLen@4"
"_locate@8"
Building the project :
\PellesC\bin\poasm /AIA32 ConsFuncs.asm
\PellesC\bin\polink /SUBSYSTEM:WINDOWS /DLL /DEF:ConsFuncs.def ConsFuncs.obj
\PellesC\bin\polib /MACHINE:x86 /DEF:ConsFuncs2.def /OUT:ConsFuncs.lib
\PellesC\bin\poasm /AIA32 Demo.asm
\PellesC\bin\polink /SUBSYSTEM:CONSOLE Demo.obj
\PellesC\bin\podump.exe /exports ConsFuncs.dll
Dump of ConsFuncs.dll
ordinal hint address name
1 0 1000100C StrLen
2 1 1000106D WriteConsole
3 2 100010A3 cls
4 3 10001044 locate
Hi morgot,
Reading the manual of Pelles C :
Quote/EXPORT option (POLINK)
Syntax:
/EXPORT:name [=internal-name] [,@ordinal [,NONAME]] [,DATA]
Description:
The /EXPORT option specifies a symbol to be exported from the linked executable. Symbols are normally exported from dynamic libraries, but programs may export symbols too.
The name argument specifies the name of the exported symbol. This is the externally visible name. The file exporting the symbol may optionally use a different internal name, specified by the internal-name argument. From version 5.0, a forward reference to another dynamic library may be created using the syntax libraryname.symbolname for internal-name. For example, mybeep=kernel32.Beep@8 will export the symbol mybeep, but point to the Beep function in kernel32.dll.
Thank you Vortex! :thumbsup: :azn: