Skip to content

Commit 74606e3

Browse files
committed
Trying new implementation.
1 parent 8c9b72b commit 74606e3

File tree

2 files changed

+18
-18
lines changed

2 files changed

+18
-18
lines changed

CMakeLists.txt

+4-4
Original file line numberDiff line numberDiff line change
@@ -82,15 +82,15 @@ FetchContent_MakeAvailable(PLTHook)
8282
set(PLTHook_INCLUDE_DIR "${PLTHook_SOURCE_DIR}")
8383

8484
if(APPLE)
85-
set(PLTHOOK_SOURCE "${PLTHook_SOURCE_DIR}/plthook_osx.c")
85+
set(PLTHook_SOURCE "${PLTHook_SOURCE_DIR}/plthook_osx.c")
8686
elseif(WIN32 OR MINGW)
87-
set(PLTHOOK_SOURCE "${PLTHook_SOURCE_DIR}/plthook_win32.c")
87+
set(PLTHook_SOURCE "${PLTHook_SOURCE_DIR}/plthook_win32.c")
8888
else()
89-
set(PLTHOOK_SOURCE "${PLTHook_SOURCE_DIR}/plthook_elf.c")
89+
set(PLTHook_SOURCE "${PLTHook_SOURCE_DIR}/plthook_elf.c")
9090
endif()
9191

9292
# MetaCall Library
93-
add_library(metacall SHARED source/metacall.c ${PLTHOOK_SOURCE})
93+
add_library(metacall SHARED source/metacall.c ${PLTHook_SOURCE})
9494
target_include_directories(metacall PRIVATE ${PLTHook_INCLUDE_DIR})
9595
target_link_libraries(metacall ${CMAKE_DL_LIBS})
9696

source/metacall.c

+14-14
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,9 @@ int load_normal_executable() {
9393
}
9494

9595
int load_node_dynamic(void) {
96-
#ifndef WIN32
96+
// #ifndef WIN32
9797
plthook_t *plthook_node_loader;
98-
#endif
98+
// #endif
9999
dyn_handle_t libnode, node_loader;
100100

101101
printf("METACALL load from node compiled dynamically to libnode\n");
@@ -133,7 +133,7 @@ int load_node_dynamic(void) {
133133
// assert(dyn_sym(libnode, "string_function2", (void (**)(void))&string_fp2) == 0);
134134

135135
// Patch the node_loader
136-
#ifdef WIN32
136+
/*#ifdef WIN32
137137
{
138138
HMODULE lib = node_loader;
139139
PIMAGE_DOS_HEADER dos = (PIMAGE_DOS_HEADER)lib;
@@ -166,7 +166,7 @@ int load_node_dynamic(void) {
166166
dload++;
167167
}
168168
}
169-
#else
169+
#else*/
170170
{
171171
if (plthook_open_by_handle(&plthook_node_loader, node_loader) != 0) {
172172
printf("plthook_open error: %s\n", plthook_error());
@@ -203,27 +203,27 @@ int load_node_dynamic(void) {
203203
// We should have a hash map of all the symbols of each library dependency of node_loader
204204
}
205205
}
206-
#endif
206+
// #endif
207207

208208
// Execute the code
209209
char *str = node_loader_fp();
210210
printf("NODE DYNAMIC executing string_function from: %s\n", str);
211211
assert(strcmp(str, "node-dynamic") == 0);
212212

213213
// Destroy everything
214-
#ifndef WIN32
214+
// #ifndef WIN32
215215
plthook_close(plthook_node_loader);
216-
#endif
216+
// #endif
217217
dyn_close(node_loader);
218218
dyn_close(libnode);
219219

220220
return 0;
221221
}
222222

223223
int load_node_static(char *(*string_function_static)(void)) {
224-
#ifndef WIN32
224+
// #ifndef WIN32
225225
plthook_t *plthook_node_loader;
226-
#endif
226+
// #endif
227227
dyn_handle_t current_process, node_loader;
228228

229229
// TODO: In theory we should test linking against libmetacall.a, but I think there won't be
@@ -270,7 +270,7 @@ int load_node_static(char *(*string_function_static)(void)) {
270270
// assert(dyn_sym(current_process, "string_function2", (void (**)(void))&string_fp2) == 0);
271271

272272
// Patch the node_loader
273-
#ifdef WIN32
273+
/*#ifdef WIN32
274274
{
275275
HMODULE lib = node_loader;
276276
PIMAGE_DOS_HEADER dos = (PIMAGE_DOS_HEADER)lib;
@@ -303,7 +303,7 @@ int load_node_static(char *(*string_function_static)(void)) {
303303
dload++;
304304
}
305305
}
306-
#else
306+
#else*/
307307
{
308308
if (plthook_open_by_handle(&plthook_node_loader, node_loader) != 0) {
309309
printf("plthook_open error: %s\n", plthook_error());
@@ -340,17 +340,17 @@ int load_node_static(char *(*string_function_static)(void)) {
340340
// We should have a hash map of all the symbols of each library dependency of node_loader
341341
}
342342
}
343-
#endif
343+
// #endif
344344

345345
// Execute the code
346346
char *str = node_loader_fp();
347347
printf("NODE STATIC executing string_function from: %s\n", str);
348348
assert(strcmp(str, "node-static") == 0);
349349

350350
// Destroy everything
351-
#ifndef WIN32
351+
// #ifndef WIN32
352352
plthook_close(plthook_node_loader);
353-
#endif
353+
// #endif
354354
dyn_close(node_loader);
355355

356356
return 0;

0 commit comments

Comments
 (0)