-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathminimal_main.cpp
More file actions
83 lines (69 loc) · 2.73 KB
/
Copy pathminimal_main.cpp
File metadata and controls
83 lines (69 loc) · 2.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#include <windows.h>
#include <string>
#define FOOBAR2000_CLIENT_VERSION 80
// Forward declarations
class foobar2000_api {};
class stream_writer {};
class stream_reader {};
class abort_callback {};
typedef unsigned int t_uint32;
typedef void* pservice_factory_base;
// Minimal service factory (EXACTLY like the working version)
struct service_factory_base {
static service_factory_base* __internal__list;
service_factory_base* m_next;
service_factory_base() : m_next(__internal__list) { __internal__list = this; }
};
service_factory_base* service_factory_base::__internal__list = nullptr;
// Dummy service to satisfy foobar2000's requirement (EXACTLY like working version)
class dummy_service {
public:
virtual ~dummy_service() {}
};
class dummy_service_impl : public dummy_service {
public:
dummy_service_impl() {
// Empty constructor to test if MessageBox is causing the crash
}
};
// Service factory for dummy service (EXACTLY like working version)
class dummy_service_factory : public service_factory_base {
dummy_service_impl m_service;
public:
dummy_service_impl* get_service() { return &m_service; }
};
static dummy_service_factory g_dummy_factory;
// foobar2000_client implementation (EXACTLY like working version)
class foobar2000_client {
public:
virtual t_uint32 get_version() = 0;
virtual pservice_factory_base get_service_list() = 0;
virtual void get_config(stream_writer * p_stream, abort_callback & p_abort) = 0;
virtual void set_config(stream_reader * p_stream, abort_callback & p_abort) = 0;
virtual void set_library_path(const char * path, const char * name) = 0;
virtual void services_init(bool val) = 0;
virtual bool is_debug() = 0;
};
class foobar2000_client_impl : public foobar2000_client {
public:
t_uint32 get_version() override { return FOOBAR2000_CLIENT_VERSION; }
pservice_factory_base get_service_list() override {
return service_factory_base::__internal__list;
}
void get_config(stream_writer * p_stream, abort_callback & p_abort) override {}
void set_config(stream_reader * p_stream, abort_callback & p_abort) override {}
void set_library_path(const char * path, const char * name) override {}
void services_init(bool val) override {
// Services are initialized automatically when the component loads
}
bool is_debug() override { return false; }
};
static foobar2000_client_impl g_client;
extern "C" {
__declspec(dllexport) foobar2000_client* _cdecl foobar2000_get_interface(foobar2000_api* p_api, HINSTANCE hIns) {
return &g_client;
}
}
BOOL APIENTRY DllMain(HMODULE hModule, DWORD dwReason, LPVOID lpReserved) {
return TRUE;
}