20int main(
int argc,
char *argv[])
29 HMODULE hRuntime = LoadLibraryA(
"phasorrt.dll");
32 MessageBoxA(
nullptr,
"Could not load phasorrt.dll",
33 (std::string(moduleName) +
" | Phasor Application - Error").c_str(), MB_OK | MB_ICONERROR);
34 std::filesystem::remove(tempFile);
39 typedef void(CALLBACK * ExecFunc)(
const unsigned char[], size_t,
const char *,
const void *);
40 ExecFunc execFunc = (ExecFunc)GetProcAddress(hRuntime,
"exec");
43 MessageBoxA(
nullptr,
"Could not find exec function in DLL",
44 (std::string(moduleName) +
" | Phasor Application - Error").c_str(), MB_OK | MB_ICONERROR);
45 FreeLibrary(hRuntime);
46 std::filesystem::remove(tempFile);
51 execFunc(embeddedBytecode, embeddedBytecodeSize, moduleName.c_str(),
nullptr);
55 FreeLibrary(hRuntime);
58 void *hRuntime = dlopen(
"libphasorrt.so", RTLD_LAZY);
61 std::cerr <<
"Error: Could not load libphasorrt.so: " << dlerror() <<
"\n";
62 std::filesystem::remove(tempFile);
67 typedef void (*ExecFunc)(
const char *, size_t,
const char *,
const void *);
68 ExecFunc execFunc = (ExecFunc)dlsym(hRuntime,
"exec");
71 std::cerr <<
"Error: Could not find exec function in library\n";
73 std::filesystem::remove(tempFile);
78 execFunc(tempFile.c_str(), tempFile.size(), moduleName.c_str(),
nullptr);
86 std::filesystem::remove(tempFile);
88 catch (
const std::exception &e)
90 std::cerr <<
"Runtime Error: " << e.what() <<
"\n";
91 if (!tempFile.empty())
93 std::filesystem::remove(tempFile);