MCPcopy Create free account
hub / github.com/HoShiMin/Kernel-Bridge / Call

Method Call

Kernel-Bridge/Kernel-Bridge/LoadableModules.cpp:100–145  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

98 }
99
100 NTSTATUS Call(PVOID hModule, ULONG CtlCode, OPTIONAL PVOID Argument = NULL) {
101 if (!hModule) return STATUS_INVALID_PARAMETER;
102
103 NTSTATUS Status = STATUS_NOT_FOUND;
104
105 MODULE_INFO* TargetModule = NULL;
106
107 Lock.Lock();
108 if (Modules.IsEmpty()) {
109 Lock.Unlock();
110 return STATUS_NOT_FOUND;
111 }
112
113 for (auto& Module : Modules) {
114 if (Module.hModule != hModule) continue;
115
116 if (Module.Unloading) {
117 Status = STATUS_NOT_FOUND;
118 break;
119 }
120
121 if (!Module.OnDeviceControl) {
122 Status = STATUS_NOT_IMPLEMENTED;
123 break;
124 }
125
126 // Referencing module:
127 if (Module.Refcount.Get() == 0)
128 KeClearEvent(Module.CompletionEvent);
129 Module.Refcount++;
130
131 TargetModule = &Module;
132 break;
133 }
134 Lock.Unlock();
135
136 if (!TargetModule) return Status;
137
138 Status = TargetModule->OnDeviceControl(CtlCode, Argument);
139
140 TargetModule->Refcount--;
141 if (TargetModule->Refcount.Get() == 0)
142 KeSetEvent(TargetModule->CompletionEvent, LOW_REALTIME_PRIORITY, FALSE);
143
144 return Status;
145 }
146
147 NTSTATUS Unload(PVOID hModule) {
148 if (!hModule) return STATUS_INVALID_PARAMETER;

Callers 1

CallModuleFunction · 0.80

Calls 4

IsEmptyMethod · 0.80
LockMethod · 0.45
UnlockMethod · 0.45
GetMethod · 0.45

Tested by

no test coverage detected