20int main(
int argc,
char *argv[])
26 HMODULE hRuntime = LoadLibraryA(
"phasorrt.dll");
29 MessageBoxA(
nullptr,
"Could not load phasorrt.dll",
30 (std::string(moduleName) +
" | Phasor Application - Error").c_str(), MB_OK | MB_ICONERROR);
31 std::filesystem::remove(tempFile);
36 typedef int(CALLBACK * ExecFunc)(
void *,
const unsigned char[], size_t,
const char *, int,
const char **);
37 ExecFunc execFunc = (ExecFunc)GetProcAddress(hRuntime,
"exec");
40 MessageBoxA(
nullptr,
"Could not find exec function in DLL",
41 (std::string(moduleName) +
" | Phasor Application - Error").c_str(), MB_OK | MB_ICONERROR);
42 FreeLibrary(hRuntime);
43 std::filesystem::remove(tempFile);
49 execFunc(
nullptr, embeddedBytecode, embeddedBytecodeSize, moduleName.c_str(), argc, (
const char **)argv);
52 FreeLibrary(hRuntime);
55 void *hRuntime = dlopen(
"libphasorrt.so", RTLD_LAZY);
58 std::cerr <<
"Error: Could not load libphasorrt.so: " << dlerror() <<
"\n";
59 std::filesystem::remove(tempFile);
64 typedef int (*ExecFunc)(
void *,
const unsigned char[], size_t,
const char *, int,
const char **);
65 ExecFunc execFunc = (ExecFunc)dlsym(hRuntime,
"exec");
68 std::cerr <<
"Error: Could not find exec function in library\n";
70 std::filesystem::remove(tempFile);
76 execFunc(
nullptr, embeddedBytecode, embeddedBytecodeSize, moduleName.c_str(), argc, (
const char **)argv);
84 catch (
const std::exception &e)
86 std::cerr <<
"Runtime Error: " << e.what() <<
"\n";