mirror of
https://github.com/tnodir/fort
synced 2024-11-15 04:15:22 +00:00
Conf: Add version and data offset.
This commit is contained in:
parent
e43cec4d49
commit
6575b1a927
@ -6,6 +6,15 @@ local sys = require"sys"
|
||||
|
||||
local persist, boot
|
||||
|
||||
if #arg == 0 then
|
||||
print[[
|
||||
Usage: luajit.exe scripts/provider.lua <arguments>
|
||||
Argumets:
|
||||
persist ... Register provider, otherwise unregister
|
||||
boot ...... Block access to network when WIPF is not running
|
||||
]]
|
||||
end
|
||||
|
||||
-- Process arguments
|
||||
for _, v in ipairs(arg) do
|
||||
if v == "persist" then
|
||||
|
@ -333,7 +333,7 @@ wipf_device_control (PDEVICE_OBJECT device, PIRP irp)
|
||||
const PWIPF_CONF conf = irp->AssociatedIrp.SystemBuffer;
|
||||
const ULONG len = irp_stack->Parameters.DeviceIoControl.InputBufferLength;
|
||||
|
||||
if (len > WIPF_CONF_SIZE_MIN) {
|
||||
if (len > WIPF_CONF_DATA_OFF) {
|
||||
PWIPF_CONF_REF conf_ref = wipf_conf_ref_new(conf, len);
|
||||
|
||||
if (conf_ref == NULL) {
|
||||
|
@ -192,7 +192,7 @@ wipf_lua_conf_buffer_size (lua_State *L)
|
||||
|| apps_len > WIPF_CONF_APPS_LEN_MAX)
|
||||
return 0;
|
||||
|
||||
lua_pushinteger(L, WIPF_CONF_SIZE_MIN
|
||||
lua_pushinteger(L, WIPF_CONF_DATA_OFF
|
||||
+ (ip_include_n + ip_exclude_n) * 2 * sizeof(UINT32)
|
||||
+ (groups_n + apps_n) * sizeof(UINT32)
|
||||
+ groups_len + apps_len
|
||||
@ -267,7 +267,7 @@ wipf_lua_conf_write (lua_State *L)
|
||||
groups_off = data_offset;
|
||||
wipf_lua_conf_write_strtable(L, 18, groups_n, &data); /* groups */
|
||||
|
||||
conf_size = WIPF_CONF_SIZE_MIN + data_offset;
|
||||
conf_size = WIPF_CONF_DATA_OFF + data_offset;
|
||||
#undef data_offset
|
||||
|
||||
conf->ip_include_all = ip_include_all;
|
||||
@ -276,6 +276,9 @@ wipf_lua_conf_write (lua_State *L)
|
||||
conf->app_block_all = app_block_all;
|
||||
conf->app_allow_all = app_allow_all;
|
||||
|
||||
conf->conf_version = WIPF_CONF_VERSION;
|
||||
conf->data_off = WIPF_CONF_DATA_OFF;
|
||||
|
||||
conf->ip_include_n = ip_include_n;
|
||||
conf->ip_exclude_n = ip_exclude_n;
|
||||
|
||||
@ -363,7 +366,7 @@ static int
|
||||
wipf_lua_conf_read (lua_State *L)
|
||||
{
|
||||
const PWIPF_CONF conf = lua_touserdata(L, 1);
|
||||
const char *data = (const char *) &conf->data;
|
||||
const char *data = (const char *) conf + conf->data_off;
|
||||
|
||||
if (!conf) return 0;
|
||||
|
||||
@ -409,7 +412,7 @@ wipf_lua_conf_ip_inrange (lua_State *L)
|
||||
const PWIPF_CONF conf = lua_touserdata(L, 1);
|
||||
const UINT32 ip = (UINT32) lua_tonumber(L, 2);
|
||||
const BOOL included = lua_toboolean(L, 3);
|
||||
const char *data = (const char *) &conf->data;
|
||||
const char *data = (const char *) conf + conf->data_off;
|
||||
|
||||
const UINT32 count = included ? conf->ip_include_n : conf->ip_exclude_n;
|
||||
const UINT32 from_off = included ? conf->ip_from_include_off : conf->ip_from_exclude_off;
|
||||
|
@ -36,7 +36,7 @@ wipf_conf_ip_inrange (UINT32 ip, UINT32 count,
|
||||
static BOOL
|
||||
wipf_conf_ip_included (const PWIPF_CONF conf, UINT32 remote_ip)
|
||||
{
|
||||
const char *data = (const char *) &conf->data;
|
||||
const char *data = (const char *) conf + conf->data_off;
|
||||
|
||||
const BOOL ip_included = conf->ip_include_all ? TRUE
|
||||
: wipf_conf_ip_inrange(remote_ip, conf->ip_include_n,
|
||||
@ -115,7 +115,7 @@ static BOOL
|
||||
wipf_conf_app_blocked (const PWIPF_CONF conf,
|
||||
UINT32 path_len, const char *path, BOOL *notify)
|
||||
{
|
||||
const char *data = (const char *) &conf->data;
|
||||
const char *data = (const char *) conf + conf->data_off;
|
||||
const int app_index = wipf_conf_app_index(path_len, path, conf->apps_n,
|
||||
(const UINT32 *) (data + conf->apps_off));
|
||||
const UINT32 *apps_perms = (const UINT32 *) (data + conf->apps_perms_off);
|
||||
|
@ -7,7 +7,10 @@ typedef struct wipf_conf {
|
||||
UINT32 app_log_blocked : 1;
|
||||
UINT32 app_block_all : 1;
|
||||
UINT32 app_allow_all : 1;
|
||||
UINT32 group_bits : 10;
|
||||
UINT32 group_bits : 16;
|
||||
|
||||
UINT16 conf_version;
|
||||
UINT16 data_off;
|
||||
|
||||
UINT16 ip_include_n;
|
||||
UINT16 ip_exclude_n;
|
||||
@ -31,7 +34,8 @@ typedef struct wipf_conf {
|
||||
UCHAR data[4];
|
||||
} WIPF_CONF, *PWIPF_CONF;
|
||||
|
||||
#define WIPF_CONF_SIZE_MIN offsetof(WIPF_CONF, data)
|
||||
#define WIPF_CONF_VERSION 1
|
||||
#define WIPF_CONF_DATA_OFF offsetof(WIPF_CONF, data)
|
||||
#define WIPF_CONF_IP_MAX (1 * 1024 * 1024)
|
||||
#define WIPF_CONF_GROUP_MAX 16
|
||||
#define WIPF_CONF_GROUP_NAME_MAX 256
|
||||
|
@ -158,8 +158,8 @@ do
|
||||
assert(not wipf.conf_ip_inrange(conf_bin, sock.inet_pton("193.0.0.0", true)))
|
||||
|
||||
assert(wipf.conf_app_blocked(conf_bin, util_fs.path_to_dospath[[System]]))
|
||||
assert(not wipf.conf_app_blocked(conf_bin, util_fs.path_to_dospath[[C:\Programs\Skype\Phone\Skype.exe]]))
|
||||
assert(not wipf.conf_app_blocked(conf_bin, util_fs.path_to_dospath[[C:\Utils\Dev\Git\bin\git.exe]]))
|
||||
assert(not wipf.conf_app_blocked(conf_bin, util_fs.path_to_dospath[[C:\programs\skype\phone\skype.exe]]))
|
||||
assert(not wipf.conf_app_blocked(conf_bin, util_fs.path_to_dospath[[C:\utils\dev\git\bin\git.exe]]))
|
||||
|
||||
print("OK")
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user