mirror of
https://github.com/Ylianst/MeshAgent
synced 2025-12-20 10:13:17 +00:00
fix
This commit is contained in:
@@ -260,7 +260,7 @@ void ILibDuktape_ScriptContainer_GetEmbeddedJS_Raw(char *exePath, char **script,
|
||||
int integratedJavaScriptLen = 0;
|
||||
FILE* tmpFile = NULL;
|
||||
|
||||
fopen_s(&tmpFile, exePath, "rb");
|
||||
_wfopen_s(&tmpFile, ILibUTF8ToWide(exePath, -1), L"rb");
|
||||
if (tmpFile != NULL)
|
||||
{
|
||||
// Read the PE Headers, to determine where to look for the Embedded JS
|
||||
@@ -338,7 +338,7 @@ void ILibDuktape_ScriptContainer_CheckEmbeddedEx(char *exePath, char **script, i
|
||||
{
|
||||
i = sprintf_s(g_AgentCrashID, sizeof(g_AgentCrashID), "%s_", exePath);
|
||||
sprintf_s(ILibScratchPad, sizeof(ILibScratchPad), "%s.exe", exePath);
|
||||
fopen_s(&tmpFile, ILibScratchPad, "rb");
|
||||
_wfopen_s(&tmpFile, ILibUTF8ToWide(ILibScratchPad, -1), L"rb");
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -373,7 +373,7 @@ void ILibDuktape_ScriptContainer_CheckEmbeddedEx(char *exePath, char **script, i
|
||||
}
|
||||
|
||||
#ifdef WIN32
|
||||
fopen_s(&tmpFile, exePath, "rb");
|
||||
_wfopen_s(&tmpFile, ILibUTF8ToWide(exePath, -1), L"rb");
|
||||
#else
|
||||
tmpFile = fopen(exePath, "rb");
|
||||
#endif
|
||||
@@ -3144,6 +3144,7 @@ void ILibDuktape_ScriptContainer_StdErrSink_MicrostackThread(void *chain, void *
|
||||
int bufferLen = ((int*)buffer)[0];
|
||||
void *ptr;
|
||||
int i;
|
||||
duk_context *ctx = master->ctx;
|
||||
|
||||
if (ILibDuktape_ScriptContainer_DecodeJSON(master->ctx, buffer+4, bufferLen-4) == 0)
|
||||
{
|
||||
@@ -3160,7 +3161,7 @@ void ILibDuktape_ScriptContainer_StdErrSink_MicrostackThread(void *chain, void *
|
||||
duk_push_string(master->ctx, json); // [emit][this][data][str]
|
||||
duk_json_decode(master->ctx, -1); // [emit][this][data][json]
|
||||
if (duk_pcall_method(master->ctx, 2) != 0) { ILibDuktape_Process_UncaughtExceptionEx(master->ctx, "ScriptContainer.OnData(): "); }
|
||||
duk_pop(master->ctx);
|
||||
duk_pop(ctx);
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -3181,7 +3182,7 @@ void ILibDuktape_ScriptContainer_StdErrSink_MicrostackThread(void *chain, void *
|
||||
ILibDuktape_EventEmitter_SetupEmit(master->ctx, master->emitter->object, "error"); // [emit][this][error]
|
||||
duk_get_prop_string(master->ctx, -4, "error"); // [emit][this][error][errorObj]
|
||||
if (duk_pcall_method(master->ctx, 2) != 0) { ILibDuktape_Process_UncaughtExceptionEx(master->ctx, "ScriptContainer_OnError_Dispatch(): "); }
|
||||
duk_pop(master->ctx); // ...
|
||||
duk_pop(ctx); // ...
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -3193,7 +3194,7 @@ void ILibDuktape_ScriptContainer_StdErrSink_MicrostackThread(void *chain, void *
|
||||
duk_push_false(master->ctx); // [func][this][false]
|
||||
duk_get_prop_string(master->ctx, -4, "error"); // [func][this][false][error]
|
||||
if (duk_pcall_method(master->ctx, 2) != 0) { ILibDuktape_Process_UncaughtExceptionEx(master->ctx, "ScriptContainer_OnError_Dispatch(): "); }
|
||||
duk_pop(master->ctx); // ...
|
||||
duk_pop(ctx); // ...
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3215,7 +3216,7 @@ void ILibDuktape_ScriptContainer_StdErrSink_MicrostackThread(void *chain, void *
|
||||
duk_push_undefined(master->ctx); // [func][this][true][undefined]
|
||||
}
|
||||
if (duk_pcall_method(master->ctx, 2) != 0) { ILibDuktape_Process_UncaughtExceptionEx(master->ctx, "ScriptContainer_OnExec_Dispatch(): "); }
|
||||
duk_pop(master->ctx); // ...
|
||||
duk_pop(ctx); // ...
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -3223,11 +3224,14 @@ void ILibDuktape_ScriptContainer_StdErrSink_MicrostackThread(void *chain, void *
|
||||
default:
|
||||
break;
|
||||
}
|
||||
duk_pop(master->ctx); // ...
|
||||
duk_pop(ctx); // ...
|
||||
}
|
||||
|
||||
#ifdef WIN32
|
||||
if (master->child != NULL) { ILibProcessPipe_Pipe_Resume(ILibProcessPipe_Process_GetStdErr(master->child)); }
|
||||
if (ILibMemory_CanaryOK(master))
|
||||
{
|
||||
if (master->child != NULL) { ILibProcessPipe_Pipe_Resume(ILibProcessPipe_Process_GetStdErr(master->child)); }
|
||||
}
|
||||
#endif
|
||||
}
|
||||
void ILibDuktape_ScriptContainer_StdErrSink(ILibProcessPipe_Process sender, char *buffer, int bufferLen, int* bytesConsumed, void* user)
|
||||
|
||||
@@ -1287,7 +1287,7 @@ void ILibduktape_fs_watch_appleWorker(void *obj)
|
||||
duk_ret_t ILibDuktape_fs_watch(duk_context *ctx)
|
||||
{
|
||||
#ifdef WIN32
|
||||
char *path = (char*)duk_require_string(ctx, 0);
|
||||
WCHAR *path = (WCHAR*)ILibDuktape_String_AsWide(ctx, 0, NULL);
|
||||
#else
|
||||
char *path = ILibDuktape_fs_fixLinuxPath((char*)duk_require_string(ctx, 0));
|
||||
#endif
|
||||
@@ -1408,7 +1408,7 @@ duk_ret_t ILibDuktape_fs_watch(duk_context *ctx)
|
||||
|
||||
#if defined(WIN32)
|
||||
if ((data->overlapped.hEvent = CreateEvent(NULL, TRUE, FALSE, NULL)) == NULL) { return(ILibDuktape_Error(ctx, "Could not create handle")); }
|
||||
data->h = CreateFile(path, FILE_LIST_DIRECTORY, FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS | FILE_FLAG_OVERLAPPED, NULL);
|
||||
data->h = CreateFileW(path, FILE_LIST_DIRECTORY, FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS | FILE_FLAG_OVERLAPPED, NULL);
|
||||
if (data->h == INVALID_HANDLE_VALUE) { return(ILibDuktape_Error(ctx, "fs.watch(): Invalid Path or Access Denied")); }
|
||||
|
||||
if (ReadDirectoryChangesW(data->h, data->results, sizeof(data->results), recursive, FILE_NOTIFY_CHANGE_FILE_NAME | FILE_NOTIFY_CHANGE_DIR_NAME | FILE_NOTIFY_CHANGE_CREATION | FILE_NOTIFY_CHANGE_SIZE | FILE_NOTIFY_CHANGE_LAST_WRITE | FILE_NOTIFY_CHANGE_LAST_ACCESS, NULL, &(data->overlapped), NULL) == 0)
|
||||
|
||||
Reference in New Issue
Block a user