summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYuri Benditovich <yuri.benditovich@daynix.com>2020-01-02 15:01:38 +0200
committerYan Vugenfirer <yan@daynix.com>2020-01-02 21:47:41 +0200
commit14dd054ae3b332337a652c34ee57b681e710ccbd (patch)
treed78f7e2a222ae222e4d731a35050a1fac70fdcb5
parent427b3f010640d7991f248df07ecabc515d9fadc9 (diff)
driver: extend ModifyOne template
Add optional process id parameter to the template arguments. If process id is provided, the entry will be additionally checked for match of owner process id saved in the redirection object and caller process id. Signed-off-by: Yuri Benditovich <yuri.benditovich@daynix.com>
-rw-r--r--UsbDk/UsbDkUtil.h12
1 files changed, 10 insertions, 2 deletions
diff --git a/UsbDk/UsbDkUtil.h b/UsbDk/UsbDkUtil.h
index 11c114b..ff599ea 100644
--- a/UsbDk/UsbDkUtil.h
+++ b/UsbDk/UsbDkUtil.h
@@ -411,10 +411,18 @@ public:
}
template <typename TEntryId, typename TModifier>
- bool ModifyOne(TEntryId *Id, TModifier ModifierFunc)
+ bool ModifyOne(TEntryId *Id, TModifier ModifierFunc, ULONG process = 0)
{
CLockedContext<TAccessStrategy> LockedContext(*this);
- return !m_Objects.ForEachIf([Id](TEntryType *ExistingEntry) { return *ExistingEntry == *Id; },
+ return !m_Objects.ForEachIf([Id,process](TEntryType *ExistingEntry)
+ {
+ bool match = *ExistingEntry == *Id;
+ if (process && match)
+ {
+ match = ExistingEntry->MatchProcess(process);
+ }
+ return match;
+ },
[&ModifierFunc](TEntryType *Entry) { ModifierFunc(Entry); return false; });
}