Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: core sourcecode (Read 3449 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

core sourcecode

each plugin is a DLL file, we can dump it by dumpbin.exe, this is the result:
Code: [Select]
Dump of file foo_xxx.dll

File Type: DLL

 Section contains the following exports for foo_xxx.dll

          0 characteristics
   40A189FA time date stamp Wed May 12 10:20:42 2004
       0.00 version
          1 ordinal base
          1 number of functions
          1 number of names

   ordinal hint RVA      name

         1    0 00009AF8 foobar2000_get_interface


and in component_client.cpp
Code: [Select]
extern "C"
{
    __declspec(dllexport) foobar2000_client * _cdecl foobar2000_get_interface(foobar2000_api * p_api,HINSTANCE hIns)
    {
#ifdef _DEBUG
 selftest();
#endif
 cfg_var::config_on_app_init();
 g_hIns = hIns;
 g_api = p_api;

 return &g_client;
    }
}


so, "foobar2000_get_interface" is the unique interface between plugin and the foobar client (core).  foosion also has told me about this, 

how does foobar_client get foobar_client point via foobar2000_get_interface,
example, we can get foobar2000_get_interface this way (I'm not very sure about these codes, just my test codes,  ):
Code: [Select]
typedef foobar2000_client* (*get_interface)(foobar2000_api* p_api , HINSTANCE hinst );

int main(int argc, char* argv[])
{
 HINSTANCE h_xxx;
 
 get_interface my_fb_getinterface;
 h_xxx=LoadLibrary(
   "F:\\FOO_SDK\\foobar2000\\foo_xxx\\Release\\foo_xxx.dll"   // file name of module
   );
 
 if (NULL == h_xxx)
   return 0;

 my_fb_getinterface = (get_interface)GetProcAddress(h_xxx, "foobar2000_get_interface");


FreeLibrary(h_xxx);
return 1;
}


we knew that:
in foobar2000 SDK,  foobar2000_api is a pure interface, like this:
Code: [Select]
class NOVTABLE foobar2000_api
{
...
}

shall I derive a class from it and instance it?

the function params are :
foobar2000_client* my_fb_getinterface(foobar2000_api* p_api , HINSTANCE hinst )

if I want to get the pointer of foobar2000_client, how to invoke the interface "foobar2000_get_interface"  ?
Is foobar2000_client  a pointer to core?

AND, after get the pointer of foobar2000_client,
we can see each plugin's soucecode, it must have these declaration:
Code: [Select]
static service_factory_single_t<menu_item,components_menu_item_xxx> foo1;
static service_factory_single_t<componentversion,version_xxx> foo2;
...


in service.cpp
Code: [Select]
service_base * service_factory_base::enum_create(const GUID &g,int n)
{
    assert(core_api::are_services_available());
    return g_api->service_enum_create(g,n);
}


seems that we can create a service via g_api and a GUID.



Could  Anyone show me the example sourcecode in foobar client?
just about:
1. get a pointer to plugin, communicated with the plugin
2. create an "unkown" object (derived from a common service, but implemented in a plugin's sourcecode)
3. organize the service object,  some for GUI, like menu, user interface; and some for preference dialog, and so on , you should have known that so many classes derived from "service_base", you can show me 2 or more examples, thanks!

if you want to reply this post, explain clearly, please! you know, I'm studying "Design Patterns" (by GoF), what a  mess in my brain 

I want to get some examples and application about" Design Patterns",  obviously , foobar is a good concrete model.

Serious PS: I am just interested in the Design Patterns of foobar2000, not hacking it.

Last: forgiving me the poor English....  , but I think you can read my mind, if you really good at Design Pattern & foobar2000.
Good good study, day day up, :)
[span style=\'color:red\']The superman is the meaning of the earth.
Let your will say: the superman shall be the meaning of the earth![/span]