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