Skip to content

Commit

Permalink
implement read/write/compare operations for extended rules
Browse files Browse the repository at this point in the history
This commit adds implementation of registry operation for
extended rules in user-mode. Kernel driver still recognizes
all the entries as default ones (it ignores the Type value).

Signed-off-by: Yuri Benditovich <yuri.benditovich@daynix.com>
  • Loading branch information
ybendito authored and YanVugenfirer committed Apr 15, 2019
1 parent fe0a2ca commit 12f71a3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions UsbDk/HideRulesRegPublic.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#define USBDK_HIDE_RULE_PID TEXT("PID")
#define USBDK_HIDE_RULE_BCD TEXT("BCD")
#define USBDK_HIDE_RULE_CLASS TEXT("Class")
#define USBDK_HIDE_RULE_TYPE TEXT("Type")

#define USBDK_HIDE_RULES_PATH TEXT("SYSTEM\\CurrentControlSet\\Services\\") \
USBDK_DRIVER_NAME TEXT("\\") \
Expand Down
5 changes: 4 additions & 1 deletion UsbDkHelper/RuleManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ static bool operator == (const USB_DK_HIDE_RULE& r1, const USB_DK_HIDE_RULE& r2)
(r1.PID == r2.PID) &&
(r1.BCD == r2.BCD) &&
(r1.Class == r2.Class) &&
(r1.Hide == r2.Hide);
(r1.Hide == r2.Hide) &&
(r1.Type == r2.Type);
}

DWORD CRulesManager::ReadDword(LPCTSTR RuleName, LPCTSTR ValueName) const
Expand Down Expand Up @@ -53,6 +54,7 @@ ULONG64 CRulesManager::ReadBool(LPCTSTR RuleName, LPCTSTR ValueName) const

void CRulesManager::ReadRule(LPCTSTR RuleName, USB_DK_HIDE_RULE &Rule) const
{
Rule.Type = ReadDword(RuleName, USBDK_HIDE_RULE_TYPE);
Rule.Hide = ReadBool(RuleName, USBDK_HIDE_RULE_SHOULD_HIDE);
Rule.VID = ReadDwordMask(RuleName, USBDK_HIDE_RULE_VID);
Rule.PID = ReadDwordMask(RuleName, USBDK_HIDE_RULE_PID);
Expand Down Expand Up @@ -106,6 +108,7 @@ void CRulesManager::AddRule(const USB_DK_HIDE_RULE &Rule)
throw UsbDkRuleManagerException(TEXT("Failed to create rule key"), ERROR_FUNCTION_FAILED);
}

WriteDword(RuleName, USBDK_HIDE_RULE_TYPE, static_cast<ULONG>(Rule.Type));
WriteDword(RuleName, USBDK_HIDE_RULE_SHOULD_HIDE, static_cast<ULONG>(Rule.Hide));
WriteDword(RuleName, USBDK_HIDE_RULE_VID, static_cast<ULONG>(Rule.VID));
WriteDword(RuleName, USBDK_HIDE_RULE_PID, static_cast<ULONG>(Rule.PID));
Expand Down

0 comments on commit 12f71a3

Please sign in to comment.