Updated 'sysnative' workaround for 32 bit agent on 64 bit windows, to include description explaining what is going on.
Bryan Roe committed
Oct 19, 2022 at 23:28 UTC
3c5bc7ef3c65e851436a754426defb5d8eab7826
1 file changed
+8
-3
agents/meshcore.js
+8
-3
@@ -47,6 +47,10 @@ var MESHRIGHT_NODESKTOP = 65536;
47
48
var pendingSetClip = false; // This is a temporary hack to prevent multiple setclips at the same time to stop the agent from crashing.
49
50
+//
51
+// 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
52
+// and will use this helper if it is not. This helper will inject 'sysnative' into the results when calling readdirSync() on %windir%.
53
+//
54
function __readdirSync_fix(path)
55
{
56
var sysnative = false;
@@ -59,15 +63,16 @@ function __readdirSync_fix(path)
63
64
if (process.platform == 'win32' && require('_GenericMarshal').PointerSize == 4 && require('os').arch() == 'x64')
65
{
62
- if(require('fs').readdirSync.version == null)
66
+ if (require('fs').readdirSync.version == null)
67
{
68
+ //
69
+ // 32 Bit Windows Agent on 64 bit Windows has not been patched for sysnative issue, so lets use our own solution
70
+ //
71
require('fs').__readdirSync_old = require('fs').readdirSync;
72
require('fs').readdirSync = __readdirSync_fix;
73
}
74
}
75
69
-
70
-
76
function bcdOK() {
77
if (process.platform != 'win32') { return (false); }
78
if (require('os').arch() == 'x64') {