AuthorMessage
Lord_Zero
Ametuar
Posts: 122

Code:
         3. Plugins
   Plugins are Dynamic Link Libraries (DLL) that can be written in any programming language. If a plugin exports specific functions, they will be called by hub when a specific event occures. A plugin can call functions from hub when needed, it must first get their addresses using the GetFunction procedure (address of GetFunction is passed as the parameter of InitPlugin).

In C++ getting functions can be done with a procedure that calls GetFunction from hub and stores function addresses like this:
Code:

asm{
   push   offset _GetVersion
   call   GetFunction
   mov   GetVersion,eax
   push   offset _NickFromId
   call   GetFunction
   mov   NickFromId,eax
   push   offset _SendTo
   call   GetFunction
   mov   SendTo,eax
   ...
}

Plugins that need many functions can use a loop to get all functions like this:
Code:

   asm{
      push   esi
      push   edi
      push   ecx
      lea   esi,namepointertable
      lea   edi,functionpointertable
      mov   ecx,numberoffunctions
   }
label1:   asm{
      push   ecx
      lodsd
      push   eax
      call   GetFunction
      pop   ecx
      stosd
      loop   label2
      pop   ecx
      pop   edi
      pop   esi
   }

where:
namepointertable = pointer to a table of pointers to function names
functionpointertable = pointer to a table that will receive pointers to functions
numberoffunctions = number of needed functions