diff options
author | Yuri Benditovich <yuri.benditovich@daynix.com> | 2019-03-14 11:20:33 +0200 |
---|---|---|
committer | Yan Vugenfirer <yan@daynix.com> | 2019-04-15 11:19:13 +0300 |
commit | fe0a2ca00568d93cee7e144e0b5e5d537985b50b (patch) | |
tree | ec384150a397481a1535e7555c5321194e673c4f | |
parent | 3652e2a34d92bb91df6c09aba1f0f34304b1c733 (diff) |
extend Hider API by adding extended hide rules
Added:
UsbDk_AddExtendedHideRule
UsbDk_AddExtendedPersistentHideRule
UsbDk_DeleteExtendedPersistentHideRule
All existing APIs continue working as before.
Signed-off-by: Yuri Benditovich <yuri.benditovich@daynix.com>
-rw-r--r-- | UsbDkHelper/UsbDkHelper.cpp | 18 | ||||
-rw-r--r-- | UsbDkHelper/UsbDkHelperHider.h | 67 |
2 files changed, 80 insertions, 5 deletions
diff --git a/UsbDkHelper/UsbDkHelper.cpp b/UsbDkHelper/UsbDkHelper.cpp index 1121562..d4a9dbd 100644 --- a/UsbDkHelper/UsbDkHelper.cpp +++ b/UsbDkHelper/UsbDkHelper.cpp @@ -380,14 +380,24 @@ InstallResult ModifyPersistentHideRules(const USB_DK_HIDE_RULE &Rule, } } -DLL InstallResult UsbDk_AddPersistentHideRule(PUSB_DK_HIDE_RULE_PUBLIC PublicRule) +DLL InstallResult UsbDk_AddExtendedPersistentHideRule(PUSB_DK_HIDE_RULE_PUBLIC PublicRule, ULONG Type) { - USB_DK_HIDE_RULE Rule(PublicRule); + USB_DK_HIDE_RULE Rule(PublicRule, Type); return ModifyPersistentHideRules(Rule, &CRulesManager::AddRule); } -DLL InstallResult UsbDk_DeletePersistentHideRule(PUSB_DK_HIDE_RULE_PUBLIC PublicRule) +DLL InstallResult UsbDk_AddPersistentHideRule(PUSB_DK_HIDE_RULE_PUBLIC PublicRule) +{ + return UsbDk_AddExtendedPersistentHideRule(PublicRule, USBDK_HIDER_RULE_DEFAULT); +} + +DLL InstallResult UsbDk_DeleteExtendedPersistentHideRule(PUSB_DK_HIDE_RULE_PUBLIC PublicRule, ULONG Type) { - USB_DK_HIDE_RULE Rule(PublicRule); + USB_DK_HIDE_RULE Rule(PublicRule, Type); return ModifyPersistentHideRules(Rule, &CRulesManager::DeleteRule); } + +DLL InstallResult UsbDk_DeletePersistentHideRule(PUSB_DK_HIDE_RULE_PUBLIC PublicRule) +{ + return UsbDk_DeleteExtendedPersistentHideRule(PublicRule, USBDK_HIDER_RULE_DEFAULT); +} diff --git a/UsbDkHelper/UsbDkHelperHider.h b/UsbDkHelper/UsbDkHelperHider.h index 98df11d..ca05bce 100644 --- a/UsbDkHelper/UsbDkHelperHider.h +++ b/UsbDkHelper/UsbDkHelperHider.h @@ -81,6 +81,28 @@ extern "C" { */ DLL BOOL UsbDk_AddHideRule(HANDLE HiderHandle, PUSB_DK_HIDE_RULE_PUBLIC Rule); + /* Add extended rule for detaching USB devices from OS stack. + * The rule definition is the same as for UsbDk_AddHideRule + * + * Processing of the rule depend on exact Type parameter + * For existing extended rules see Documentation/Hider.txt + * + * @params + * IN - HiderHandle Handle to UsbDk driver + * - Rule - pointer to hide rule + * - Type - type of the rule + * OUT - None + * + * @return + * TRUE if function succeeds + * + * @note + * Hide rule stays until HiderHandle is closed, client process exits or + * UsbDk_ClearHideRules() called + * + */ + DLL BOOL UsbDk_AddExtendedHideRule(HANDLE HiderHandle, PUSB_DK_HIDE_RULE_PUBLIC Rule, ULONG Type); + /* Clear all hider rules * * @params @@ -129,7 +151,31 @@ extern "C" { */ DLL InstallResult UsbDk_AddPersistentHideRule(PUSB_DK_HIDE_RULE_PUBLIC Rule); - /* Delete specific persistent hide rule + /* Add extended rule for detaching USB devices from OS stack persistently. + * The rule definition is the same as for UsbDk_AddPersistentHideRule + * + * Processing of the rule depend on exact Type parameter + * For existing extended rules see Documentation/Hider.txt + * + * @params + * IN - Rule - pointer to hide rule + * - Type - type of the rule + * OUT - None + * + * @return + * Rule installation status + * + * @note + * 1. Persistent rule stays until explicitly deleted by + * UsbDk_DeletePersistentHideRule() + * 2. This API requires administrative privileges + * 3. For already attached devices the rule will be applied after + * device re-plug or system reboot. + * + */ + DLL InstallResult UsbDk_AddExtendedPersistentHideRule(PUSB_DK_HIDE_RULE_PUBLIC Rule, ULONG Type); + + /* Delete specific persistent hide rule (rule type is default) * * @params * IN - Rule - pointer to hide rule @@ -146,6 +192,25 @@ extern "C" { * */ DLL InstallResult UsbDk_DeletePersistentHideRule(PUSB_DK_HIDE_RULE_PUBLIC Rule); + + /* Delete specific persistent hide rule + * + * @params + * IN - Rule - pointer to hide rule + * - Type - type of the rule + * OUT - None + * + * @return + * Rule removal status + * + * @note + * 1. This API requires administrative privileges + * 2. For already attached devices the rule will be applied after + * device re-plug or system reboot. + * + */ + DLL InstallResult UsbDk_DeleteExtendedPersistentHideRule(PUSB_DK_HIDE_RULE_PUBLIC Rule, ULONG Type); + #ifdef __cplusplus } #endif |