Debian Codegraph @

components/decoder/winamp/dllinterface.cpp

raw symbols SCIP
1 /* BoCA - BonkEnc Component Architecture
2 * Copyright (C) 2007-2017 Robert Kausch <[email protected]>
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation, either version 2 of
7 * the License, or (at your option) any later version.
8 *
9 * THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
10 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
11 * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. */
12
13 #include "dllinterface.h"
14
15 Array<DynamicLoader *, Void *> winamp_in_plugins;
16 Array<In_Module *, Void *> winamp_in_modules;
17
18 Bool LoadWinampDLLs()
19 {
20 MoveFileA(GUI::Application::GetApplicationDirectory().Append("plugins\\plugins.ini"), GUI::Application::GetApplicationDirectory().Append("freac.ini"));
21
22 Directory directory = GUI::Application::GetApplicationDirectory().Append("plugins\\");
23 const Array<File> &in_dlls = directory.GetFilesByPattern("in_*.dll");
24
25 for (Int i = 0; i < in_dlls.Length(); i++)
26 {
27 DynamicLoader *dll = new DynamicLoader(in_dlls.GetNth(i));
28
29 if (dll == NIL) continue;
30
31 /* Get winampGetInModule2 function address.
32 */
33 In_Module *(*proc)() = (In_Module *(*)()) dll->GetFunctionAddress("winampGetInModule2");
34
35 if (proc == NIL) { Object::DeleteObject(dll); continue; }
36
37 /* Get input module description.
38 */
39 In_Module *module = proc();
40
41 if (module->version != IN_VER &&
42 module->version != IN_VER_OLD) { Object::DeleteObject(dll); continue; }
43
44 /* Add module to list.
45 */
46 winamp_in_plugins.Add(dll);
47 winamp_in_modules.Add(module);
48
49 module->hDllInstance = (HINSTANCE) dll->GetSystemModuleHandle();
50 module->hMainWindow = NULL;
51 module->Init();
52 }
53
54 return True;
55 }
56
57 Void FreeWinampDLLs()
58 {
59 for (Int i = 0; i < winamp_in_plugins.Length(); i++)
60 {
61 winamp_in_modules.GetNth(i)->Quit();
62
63 Object::DeleteObject(winamp_in_plugins.GetNth(i));
64 }
65
66 winamp_in_plugins.RemoveAll();
67 winamp_in_modules.RemoveAll();
68
69 MoveFileA(GUI::Application::GetApplicationDirectory().Append("freac.ini"), GUI::Application::GetApplicationDirectory().Append("plugins\\plugins.ini"));
70 }