mirror of
https://github.com/vxcontrol/soldr-modules.git
synced 2026-07-18 18:44:30 -04:00
fix: declaration of winapi constants in proc_terminator module
This commit is contained in:
@@ -5,9 +5,10 @@ local cjson = require("cjson.safe")
|
||||
local luapath = require("path")
|
||||
local process_api = require("process_api")
|
||||
local lk32
|
||||
local win_const = {}
|
||||
if ffi.os == "Windows" then
|
||||
lk32 = require("waffi.windows.kernel32")
|
||||
lk32.STILL_ALIVE = 259
|
||||
win_const.STILL_ALIVE = 259
|
||||
else
|
||||
ffi.cdef[[
|
||||
typedef uint32_t pid_t;
|
||||
@@ -338,7 +339,7 @@ if ffi.os == "Windows" then
|
||||
elseif lk32.GetExitCodeProcess(proc_handle, exitCode) ~= 0 then
|
||||
__log.debugf("exit code from requested kill process: %d", tonumber(exitCode[0]))
|
||||
|
||||
if tonumber(exitCode[0]) ~= lk32.STILL_ALIVE then
|
||||
if tonumber(exitCode[0]) ~= win_const.STILL_ALIVE then
|
||||
action_data.data.result = true
|
||||
action_data.data.reason = "already terminating"
|
||||
push_event("pt_" .. object_type .. "_process_killed_successful", action_name, action_data)
|
||||
|
||||
@@ -4,10 +4,11 @@ local ffi = require("ffi")
|
||||
local lfs = require("lfs")
|
||||
local luapath = require("path")
|
||||
local lk32
|
||||
local win_const = {}
|
||||
if ffi.os == "Windows" then
|
||||
lk32 = require("waffi.windows.kernel32")
|
||||
lk32.TH32CS_SNAPPROCESS = 0x00000002
|
||||
lk32.SYNCHRONIZE = 0x00100000
|
||||
win_const.TH32CS_SNAPPROCESS = 0x00000002
|
||||
win_const.SYNCHRONIZE = 0x00100000
|
||||
else
|
||||
ffi.cdef[[
|
||||
typedef uint32_t pid_t;
|
||||
@@ -53,7 +54,7 @@ if ffi.os == "Windows" then
|
||||
|
||||
local proc_entry = ffi.new("PROCESSENTRY32[1]")
|
||||
proc_entry[0].dwSize = ffi.sizeof("PROCESSENTRY32")
|
||||
local snap_handle = lk32.CreateToolhelp32Snapshot(lk32.TH32CS_SNAPPROCESS, 0)
|
||||
local snap_handle = lk32.CreateToolhelp32Snapshot(win_const.TH32CS_SNAPPROCESS, 0)
|
||||
|
||||
if (lk32.Process32First(snap_handle, proc_entry[0]) == 1) then
|
||||
while (lk32.Process32Next(snap_handle, proc_entry[0]) == 1) do
|
||||
@@ -85,7 +86,7 @@ if ffi.os == "Windows" then
|
||||
|
||||
function api.windows.get_process_handle(pid)
|
||||
local handle = lk32.OpenProcess(bit.bor(lk32.PROCESS_QUERY_LIMITED_INFORMATION, lk32.PROCESS_TERMINATE,
|
||||
lk32.PROCESS_VM_READ, lk32.SYNCHRONIZE
|
||||
lk32.PROCESS_VM_READ, win_const.SYNCHRONIZE
|
||||
), false, pid)
|
||||
if handle == ffi.NULL then
|
||||
return nil, api.windows.get_last_error()
|
||||
|
||||
Reference in New Issue
Block a user