[fpc-pascal] windows.GetProcAddress() vs DynLibs.GetProcAddress()

Ewald ewald at yellowcouch.org
Tue Jan 14 00:05:22 CET 2014


On 13 Jan 2014, at 23:06, Fred van Stappen wrote:

> The SoundTouch.dll uses index to call the procedures.
> 
> Like that :
>  [Ordinal/Name Pointer]
>     [   0] soundtouch_clear 
>     [   1] soundtouch_createInstance 
>     [   2] soundtouch_destroyInstance
> 

That explains why it works in windows probably, there you can specify an index to go with your exported procedures IIRC. I don't know if this is possible though on *nix.

Have a look at http://msdn.microsoft.com/en-us/library/windows/desktop/ms683212(v=vs.85).aspx ; there it says that if you pass in a pointer with  value where the high order word is zero, it is interpreted as an ordinal value. The same does not apply to the dynlibs version.


> >> try `GetProcAddress(LibHandle,  'soundtouch_clear');
> 
> I have try that, but it does not work...`
> 

What is the result of the call (GetProcAddress)? nil? if so then try to find the names of the symbols defined in the shared object (nm comes to mind).

Now, for the windows version, I don't know what underlying mechanism dynlibs uses under windows, so I'm afraid I can't really comment on that platform, except that you could try a similar approach as on linux (use symbol names instead of indices). OTOH it could (?) be that the the compiler inserts code to typecast PChar(1) to a string, which could result in an access violation (try `var a: string; a:= pchar(1);` to try it out ;-) ).

--
Ewald

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20140114/d3cdb473/attachment.html>


More information about the fpc-pascal mailing list