All files / root/gpii/node_modules/spiSettingsHandler/src SpiChildProcess.js

81.82% Statements 9/11
50% Branches 1/2
100% Functions 0/0
81.82% Lines 9/11
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44                                        2x     2x 2x 2x     2x       2x 2x     2x           2x  
/*
 * SPI Child Process.
 * This is executed by gpii.windows.spi.callProblematicSpi, in order to invoke certain problematic SET calls to
 * SystemParametersInfo in a separate process. The exit code is the return value of the function.
 *
 * Copyright 2016 Raising the Floor - International
 *
 * Licensed under the New BSD license. You may not use this file except in
 * compliance with this License.
 *
 * The research leading to these results has received funding from the European Union's
 * Seventh Framework Programme (FP7/2007-2013)
 * under grant agreement no. 289016.
 *
 * You may obtain a copy of the License at
 * https://github.com/GPII/universal/blob/master/LICENSE.txt
 */
 
"use strict";
 
var ffi = require("ffi");
 
// 1 if uiParam is a literal number, otherwise it's a block of data.
var pvParamPrimitive = process.env.GPII_SPI_PVPARAM_PRIMITIVE === "1";
var action = process.env.GPII_SPI_ACTION;
var uiParam = process.env.GPII_SPI_UIPARAM;
 
var pvParam, type;
Iif (pvParamPrimitive) {
    type = "uint32";
    pvParam = process.env.GPII_SPI_PVPARAM;
} else {
    type = "void*";
    pvParam = new Buffer(process.env.GPII_SPI_PVPARAM, "hex");
}
 
var user32 = ffi.Library("user32", {
    "SystemParametersInfoW": [
        "int32", ["uint32", "uint32", type, "uint32"]
    ]
});
 
return user32.SystemParametersInfoW(action, uiParam, pvParam, 0);