Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Load DLL from memory unit - how use?

Tags:

memory

dll

delphi

I've found a unit with functions that allow to Load a DLL directly from memory, but I don't know how can I use it..

This is the unit: http://www.delphibasics.info/home/delphibasicssnippets/udllfrommem-loadadllfrommemory

I know that the function is:

function memLoadLibrary(FileBase : Pointer) : Pointer;

But I don't know how can I use it, what is the FileBase that I need to define, etc.

Can anyone help-me?

like image 733
paulohr Avatar asked Jun 20 '26 20:06

paulohr


1 Answers

You simply need to put the DLL into memory and pass to memLoadLibrary the pointer to the location of the DLL in memory.

For example, from a resource:

hRes := LoadResource(HInstance, 'MYRESNAME');
if hres=0 then
  RaiseLastOSError;
BaseAddress := LockResource(hRes);
if BaseAddress=nil then
  RaiseLastOSError;
lib := memLoadLibrary(BaseAddress);
.....
like image 93
David Heffernan Avatar answered Jun 23 '26 11:06

David Heffernan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!