From 2f57fd27b4cc0f06bd1c16b9b5493692173d8fa7 Mon Sep 17 00:00:00 2001 From: ste Date: Thu, 31 May 2018 10:24:34 +0100 Subject: [PATCH 1/4] GPII-3066: Stop crashing by using ref() correctly --- .../node_modules/windowMessages/src/windowMessages.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/gpii/node_modules/windowMessages/src/windowMessages.js b/gpii/node_modules/windowMessages/src/windowMessages.js index bbfb08c1b..50ce2d4a9 100644 --- a/gpii/node_modules/windowMessages/src/windowMessages.js +++ b/gpii/node_modules/windowMessages/src/windowMessages.js @@ -17,7 +17,7 @@ "use strict"; -var fluid = require("infusion"), +var fluid = require("gpii-universal"), ffi = require("ffi"); var gpii = fluid.registerNamespace("gpii"); @@ -149,13 +149,14 @@ gpii.windows.messages.messagePump = function (that) { var loop = function () { // sizeof(MSG) = 48 on 64-bit, 28 on 32-bit. - var msg = new Buffer(process.arch === "x64" ? 48 : 28); + var msg = new Buffer(process.arch === "x64" ? 48 : 28).ref(); // Unable to use GetMessage because it blocks, and can't call via .async because it needs to be in the same // thread as the window. - while (gpii.windows.user32.PeekMessageW(msg.ref(), 0, 0, 0, 1)) { - gpii.windows.user32.TranslateMessage(msg.ref()); - gpii.windows.user32.DispatchMessageW(msg.ref()); + while (gpii.windows.user32.PeekMessageW(msg + , 0, 0, 0, 1)) { + gpii.windows.user32.TranslateMessage(msg); + gpii.windows.user32.DispatchMessageW(msg); } if (that.messageWindow) { From a7a9766995ae8f38014903c949df92e81ba6275e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20Jaramago=20Fern=C3=A1ndez?= Date: Thu, 31 May 2018 15:12:50 +0200 Subject: [PATCH 2/4] GPII-3066: Used new Buffer API for memory initialization and removed ref() use in buffer type --- gpii/node_modules/windowMessages/src/windowMessages.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/gpii/node_modules/windowMessages/src/windowMessages.js b/gpii/node_modules/windowMessages/src/windowMessages.js index 50ce2d4a9..4d65801db 100644 --- a/gpii/node_modules/windowMessages/src/windowMessages.js +++ b/gpii/node_modules/windowMessages/src/windowMessages.js @@ -149,12 +149,11 @@ gpii.windows.messages.messagePump = function (that) { var loop = function () { // sizeof(MSG) = 48 on 64-bit, 28 on 32-bit. - var msg = new Buffer(process.arch === "x64" ? 48 : 28).ref(); + var msg = Buffer.alloc(process.arch === "x64" ? 48 : 28); // Unable to use GetMessage because it blocks, and can't call via .async because it needs to be in the same // thread as the window. - while (gpii.windows.user32.PeekMessageW(msg - , 0, 0, 0, 1)) { + while (gpii.windows.user32.PeekMessageW(msg, 0, 0, 0, 1)) { gpii.windows.user32.TranslateMessage(msg); gpii.windows.user32.DispatchMessageW(msg); } From 7c18a23be43b6e0bd3b3c3c4ad7a10d57531a358 Mon Sep 17 00:00:00 2001 From: ste Date: Tue, 5 Jun 2018 10:51:01 +0100 Subject: [PATCH 3/4] Making GPII crash --- index.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/index.js b/index.js index 4d55d0d74..0607b75b3 100644 --- a/index.js +++ b/index.js @@ -26,6 +26,15 @@ fluid.contextAware.makeChecks({ }); require("./gpii/node_modules/WindowsUtilities/WindowsUtilities.js"); + +// Not for production: +var gpii = fluid.registerNamespace("gpii"); +console.log("Crashing"); +// Crash by invoking a null callback. +gpii.windows.user32.EnumWindows(Buffer.alloc(0) ,0); +console.log("Crash failed"); + + require("./gpii/node_modules/processHandling/processHandling.js"); require("./gpii/node_modules/displaySettingsHandler"); require("./gpii/node_modules/registrySettingsHandler"); From 0b5b7f6b8bcf7de89f8ba030479e277f52536a1b Mon Sep 17 00:00:00 2001 From: ste Date: Tue, 5 Jun 2018 13:00:02 +0100 Subject: [PATCH 4/4] Not crashing GPII --- index.js | 9 --------- 1 file changed, 9 deletions(-) diff --git a/index.js b/index.js index 0607b75b3..4d55d0d74 100644 --- a/index.js +++ b/index.js @@ -26,15 +26,6 @@ fluid.contextAware.makeChecks({ }); require("./gpii/node_modules/WindowsUtilities/WindowsUtilities.js"); - -// Not for production: -var gpii = fluid.registerNamespace("gpii"); -console.log("Crashing"); -// Crash by invoking a null callback. -gpii.windows.user32.EnumWindows(Buffer.alloc(0) ,0); -console.log("Crash failed"); - - require("./gpii/node_modules/processHandling/processHandling.js"); require("./gpii/node_modules/displaySettingsHandler"); require("./gpii/node_modules/registrySettingsHandler");