forked from jruby/jruby-launcher
-
Notifications
You must be signed in to change notification settings - Fork 0
/
nbexecloader.h
43 lines (35 loc) · 1.06 KB
/
nbexecloader.h
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
#ifndef _NBEXECLOADER_H
#define _NBEXECLOADER_H
#include "utilsfuncs.h"
#define HELP_MSG ""
class NBExecLoader {
typedef int (*StartPlatform)(int argc, char *argv[], const char *help, const char *name);
public:
NBExecLoader()
: hLib(0) {
}
~NBExecLoader() {
if (hLib) {
FreeLibrary(hLib);
}
}
int start(const char *path, int argc, char *argv[], const char *name) {
if (!hLib) {
hLib = LoadLibrary(path);
if (!hLib) {
logErr(true, true, "Cannot load \"%s\".", path);
return -1;
}
}
StartPlatform startPlatform = (StartPlatform) GetProcAddress(hLib, "startPlatform");
if (!startPlatform) {
logErr(true, true, "Cannot start platform, failed to find startPlatform() in %s", path);
return -1;
}
logMsg("Starting platform... \n\tBinary name is: %s\n", name);
return startPlatform(argc, argv, HELP_MSG, name);
}
private:
HMODULE hLib;
};
#endif /* _NBEXECLOADER_H */