28int main(
int argc,
char *argv[],
char *envp[])
37 HMODULE hRuntime = LoadLibraryA(
"phasorrt.dll");
40 MessageBoxA(
nullptr,
"Could not load phasorrt.dll",
41 (std::string(moduleName) +
" | Phasor Application - Error").c_str(), MB_OK | MB_ICONERROR);
42 std::filesystem::remove(tempFile);
47 typedef void(CALLBACK * ExecFunc)(
const unsigned char[], size_t,
const char *,
const void *);
48 ExecFunc execFunc = (ExecFunc)GetProcAddress(hRuntime,
"exec");
51 MessageBoxA(
nullptr,
"Could not find exec function in DLL",
52 (std::string(moduleName) +
" | Phasor Application - Error").c_str(), MB_OK | MB_ICONERROR);
53 FreeLibrary(hRuntime);
54 std::filesystem::remove(tempFile);
59 execFunc(embeddedBytecode, embeddedBytecodeSize, moduleName.c_str(),
nullptr);
63 FreeLibrary(hRuntime);
66 void *hRuntime = dlopen(
"libphasorrt.so", RTLD_LAZY);
69 std::cerr <<
"Error: Could not load libphasorrt.so: " << dlerror() <<
"\n";
70 std::filesystem::remove(tempFile);
75 typedef void (*ExecFunc)(
const char *, size_t,
const char *,
const void *);
76 ExecFunc execFunc = (ExecFunc)dlsym(hRuntime,
"exec");
79 std::cerr <<
"Error: Could not find exec function in library\n";
81 std::filesystem::remove(tempFile);
86 execFunc(tempFile.c_str(), tempFile.size(), moduleName.c_str(),
nullptr);
94 std::filesystem::remove(tempFile);
96 catch (
const std::exception &e)
98 std::cerr <<
"Runtime Error: " << e.what() <<
"\n";
99 if (!tempFile.empty())
101 std::filesystem::remove(tempFile);