From 3c5bc7ef3c65e851436a754426defb5d8eab7826 Mon Sep 17 00:00:00 2001 From: Bryan Roe Date: Wed, 19 Oct 2022 23:28:13 -0700 Subject: [PATCH] Updated 'sysnative' workaround for 32 bit agent on 64 bit windows, to include description explaining what is going on. --- agents/meshcore.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/agents/meshcore.js b/agents/meshcore.js index b8cb47c26e..d2fca767a7 100644 --- a/agents/meshcore.js +++ b/agents/meshcore.js @@ -47,6 +47,10 @@ var MESHRIGHT_NODESKTOP = 65536; var pendingSetClip = false; // This is a temporary hack to prevent multiple setclips at the same time to stop the agent from crashing. +// +// This is a helper function used by the 32 bit Windows Agent, when running on 64 bit windows. It will check if the agent is already patched for this +// and will use this helper if it is not. This helper will inject 'sysnative' into the results when calling readdirSync() on %windir%. +// function __readdirSync_fix(path) { var sysnative = false; @@ -59,15 +63,16 @@ function __readdirSync_fix(path) if (process.platform == 'win32' && require('_GenericMarshal').PointerSize == 4 && require('os').arch() == 'x64') { - if(require('fs').readdirSync.version == null) + if (require('fs').readdirSync.version == null) { + // + // 32 Bit Windows Agent on 64 bit Windows has not been patched for sysnative issue, so lets use our own solution + // require('fs').__readdirSync_old = require('fs').readdirSync; require('fs').readdirSync = __readdirSync_fix; } } - - function bcdOK() { if (process.platform != 'win32') { return (false); } if (require('os').arch() == 'x64') {