I have a library (apl) which is loading an External Function from GDI32.DLL. The library is doing it wrong, but I cannot change the library. I would like to load the External Function with the correct parameters, but I get a Duplicate symbol error.
Is there a way to "overwrite" the external Function without changing the library?
Thanks in advance Max
- Founder/Site Admin
- Posts: 2928
- Joined: 24 Feb 2017, 09:12
- Location: Gouda, The Netherlands
Why can the library function not be changed? If the function is wrong, I would expect that fixing it would be best.
As for your question:
Exported Functions can be defined two ways:
1) Function name exactly matches the name as defined by the DLL. The ordinal number must be 0 (zero)
2) Any function name is allowed but the ordinal number must match.
The easiest and IMHO the most "safe" way is option 1. Here, when you compile your project, TD will load the DLL at compile time and check whether the function name you provided is present in the DLL.
This makes you sure that the function you call is actually present.
The second option is to use the ordinal number and choose your function name as you like.
TD will not check the function name at compile time and "assumes" the function having the declared parameters etc is present.
Danger is that if you provide the wrong ordinal number, you will get crashes at runtime.
(so I opt for option 1).
Below a screenshot of the same function (gdi32.dll, LineTo) defined using ordinal 0 (exact function name) and 2 custom names.
I recommend to use a tool to find out the ordinal number to choose: DLL Export Viewer
Who is online
Users browsing this forum: [Ccbot] and 0 guests