1
0
mirror of https://github.com/Ylianst/MeshAgent synced 2025-12-20 10:13:17 +00:00

Updated service restart on Windows, when called from self.

This commit is contained in:
Bryan Roe
2021-02-07 15:26:53 -08:00
parent 66e489c49c
commit 43c5f2d1b5
4 changed files with 34 additions and 8 deletions

View File

@@ -14,6 +14,8 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
const SYNCHRONIZE = 0x00100000;
function invalid()
{
@@ -152,6 +154,25 @@ function getLibc()
return (libc);
}
function win_getProcessHandle(pid)
{
try
{
if(!this.kernel32)
{
this.kernel32 = require('_GenericMarshal').CreateNativeProxy('kernel32.dll');
this.kernel32.CreateMethod('OpenProcess');
}
return (this.kernel32.OpenProcess(SYNCHRONIZE, 0, pid));
}
catch(e)
{
return (null);
}
}
switch (process.platform)
{
case 'linux':
@@ -161,4 +182,9 @@ switch (process.platform)
default:
module.exports = { getOpenDescriptors: invalid, closeDescriptors: invalid };
break;
}
if (process.platform == 'win32')
{
module.exports.getProcessHandle = win_getProcessHandle;
}