mirror of
https://github.com/tnodir/fort
synced 2024-11-15 04:27:09 +00:00
Driver: Fix provider temporary registering.
This commit is contained in:
parent
a3e6ce3e73
commit
990d3c8280
@ -18,7 +18,7 @@ end
|
||||
wipf.prov_unregister()
|
||||
|
||||
if persist then
|
||||
local _, err = wipf.prov_register(persist, boot)
|
||||
local _, err = wipf.prov_register(boot)
|
||||
if err then
|
||||
sys.stderr:write("Error: ", sys.strerror(err))
|
||||
sys.exit(false)
|
||||
|
@ -25,11 +25,12 @@ typedef struct wipf_conf_ref {
|
||||
} WIPF_CONF_REF, *PWIPF_CONF_REF;
|
||||
|
||||
typedef struct wipf_device {
|
||||
BOOL active : 1;
|
||||
BOOL prov_temporary : 1;
|
||||
|
||||
UINT32 connect4_id;
|
||||
UINT32 accept4_id;
|
||||
|
||||
BOOL active;
|
||||
|
||||
WIPF_BUFFER buffer;
|
||||
|
||||
PWIPF_CONF_REF volatile conf_ref;
|
||||
@ -382,6 +383,7 @@ wipf_driver_unload (PDRIVER_OBJECT driver)
|
||||
|
||||
wipf_buffer_close(&g_device->buffer);
|
||||
|
||||
if (g_device->prov_temporary)
|
||||
wipf_prov_unregister();
|
||||
|
||||
RtlInitUnicodeString(&device_link, DOS_DEVICE_NAME);
|
||||
@ -426,7 +428,12 @@ DriverEntry (PDRIVER_OBJECT driver, PUNICODE_STRING reg_path)
|
||||
|
||||
KeInitializeSpinLock(&g_device->conf_lock);
|
||||
|
||||
status = wipf_prov_register(FALSE, FALSE);
|
||||
// Register filters provider
|
||||
{
|
||||
BOOL is_temp = FALSE;
|
||||
status = wipf_prov_register(FALSE, FALSE, &is_temp);
|
||||
g_device->prov_temporary = is_temp;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -448,15 +448,14 @@ wipf_lua_conf_app_blocked (lua_State *L)
|
||||
}
|
||||
|
||||
/*
|
||||
* Arguments: persist (boolean), boot (boolean)
|
||||
* Arguments: boot (boolean)
|
||||
* Returns: boolean | nil, err_code
|
||||
*/
|
||||
static int
|
||||
wipf_lua_prov_register (lua_State *L)
|
||||
{
|
||||
const BOOL persist = lua_toboolean(L, 1);
|
||||
const BOOL boot = lua_toboolean(L, 2);
|
||||
const DWORD status = wipf_prov_register(persist, boot);
|
||||
const BOOL boot = lua_toboolean(L, 1);
|
||||
const DWORD status = wipf_prov_register(TRUE, boot, NULL);
|
||||
|
||||
if (!status) {
|
||||
lua_pushboolean(L, 1);
|
||||
|
@ -6,8 +6,6 @@ typedef struct wipf_prov_data {
|
||||
UINT32 boot : 1;
|
||||
} WIPF_PROV_DATA, *PWIPF_PROV_DATA;
|
||||
|
||||
static BOOL g_providerPersist = FALSE;
|
||||
|
||||
|
||||
static void
|
||||
wipf_prov_delete (HANDLE engine)
|
||||
@ -25,8 +23,7 @@ wipf_prov_unregister (void)
|
||||
{
|
||||
HANDLE engine;
|
||||
|
||||
if (g_providerPersist
|
||||
|| FwpmEngineOpen0(NULL, RPC_C_AUTHN_WINNT, NULL, NULL, &engine))
|
||||
if (FwpmEngineOpen0(NULL, RPC_C_AUTHN_WINNT, NULL, NULL, &engine))
|
||||
return;
|
||||
|
||||
wipf_prov_delete(engine);
|
||||
@ -35,7 +32,7 @@ wipf_prov_unregister (void)
|
||||
}
|
||||
|
||||
static DWORD
|
||||
wipf_prov_register (BOOL persist, BOOL boot)
|
||||
wipf_prov_register (BOOL persist, BOOL boot, BOOL *is_tempp)
|
||||
{
|
||||
FWPM_PROVIDER0 *old_provider, provider;
|
||||
FWPM_CALLOUT0 ocallout4, icallout4;
|
||||
@ -62,8 +59,6 @@ wipf_prov_register (BOOL persist, BOOL boot)
|
||||
|
||||
if (old_provider_data) {
|
||||
if (provider_data.persist) {
|
||||
g_providerPersist = TRUE;
|
||||
|
||||
if (provider_data.version == WIPF_VERSION)
|
||||
goto end_close;
|
||||
|
||||
@ -136,8 +131,11 @@ wipf_prov_register (BOOL persist, BOOL boot)
|
||||
|| (status = FwpmSubLayerAdd0(engine, &sublayer, NULL))
|
||||
|| (status = FwpmFilterAdd0(engine, &ofilter4, NULL, NULL))
|
||||
|| (status = FwpmFilterAdd0(engine, &ifilter4, NULL, NULL))
|
||||
|| (status = FwpmTransactionCommit0(engine)))
|
||||
|| (status = FwpmTransactionCommit0(engine))) {
|
||||
FwpmTransactionAbort0(engine);
|
||||
} else if (is_tempp) {
|
||||
*is_tempp = !persist;
|
||||
}
|
||||
|
||||
end_close:
|
||||
FwpmEngineClose0(engine);
|
||||
|
Loading…
Reference in New Issue
Block a user