Loading some decoder plugins from memory (feature request)

Started by suathd,

suathd

BASS_PluginLoad works fine when loading from DLL file on disk.

But in some cases I need to bundle Bass decoder plugins in my application.exe (as resource).

It will be good if Bass can load some plugins from memory.


P.S: Currently I'm saving DLL resource to disk and loading from file.
But some antiviruses blocks the application.

Ian @ un4seen

BASS_PluginLoad has a BASS_PLUGIN_PROC flag to add a plugin from memory instead of file. That's primarily intended for old iOS add-ons, which were static libraries, but it is also supported on other platforms and perhaps you can achieve what you want with it. You would provide the address of an add-on's "BASSplugin" symbol instead of its filename, but note you will first need to run the DLL's initialization code (including handling relocations/imports/etc).

suathd

Quote from: Ian @ un4seenBASS_PluginLoad has a BASS_PLUGIN_PROC flag to add a plugin from memory instead of file. That's primarily intended for old iOS add-ons, which were static libraries, but it is also supported on other platforms and perhaps you can achieve what you want with it. You would provide the address of an add-on's "BASSplugin" symbol instead of its filename, but note you will first need to run the DLL's initialization code (including handling relocations/imports/etc).

thank you very much. it works fine.

I'm sharing what I did for other users (source code in Delphi)

uses MemoryModule;


var
    hPluginAAC: HPLUGIN;
    memDllAAC:Pointer;
    ResStream: TResourceStream;
    dllSize:Int64;
    lib:Pointer;
    BASSplugin:pointer;
 

--- load dll ---

  ResStream := TResourceStream.Create(HInstance, 'AACH_LIB', RT_RCDATA);
  ResStream.Position := 0;
  dllSize := ResStream.Size;
  memDllAAC := GetMemory(dllSize);
  ResStream.Read(memDllAAC^, dllSize);
  ResStream.Free;
  lib := MemoryLoadLibary(memDllAAC);
  BASSplugin:=MemoryGetProcAddress(lib, 'BASSplugin');
  hPluginAAC:=BASS_PluginLoad(BASSPlugin,  BASS_PLUGIN_PROC);


--- free dll ---

if hPluginAAC <> 0 then BASS_PluginFree(hPluginAAC);
if memDllAAC <> Nil then FreeMem(memDllAAC);//11.08.2025


P.S:

I used https://github.com/Fr0sT-Brutal/Delphi_MemoryModule

I think MemoryModule could be implemented by BASS library.
memory address of loaded dll file (memDllAAC) could be send as 1st parameter to BASS_PluginLoad.

c source of MemoryModule is available at https://github.com/fancycode/MemoryModule



Ian @ un4seen

Good to see you've got it working already. I don't see it becoming a built-in option, but if anyone else wants to do the same thing then they can follow your instructions.