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

Function KbLoadAsDriver

User-Bridge/API/User-Bridge.cpp:28–63  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

26namespace KbLoader
27{
28 BOOL WINAPI KbLoadAsDriver(LPCWSTR DriverPath)
29 {
30 // Check whether the Kernel-Bridge is already loaded:
31 if (hDriver != INVALID_HANDLE_VALUE) return TRUE;
32 hDriver = OpenDevice(KbDeviceName);
33 if (hDriver != INVALID_HANDLE_VALUE) {
34 ULONG DriverApiVersion = KbGetDriverApiVersion();
35 if (KbGetUserApiVersion() == DriverApiVersion) return TRUE;
36
37 ULONG HandlesCount = 0;
38 if (!KbGetHandlesCount(&HandlesCount) || HandlesCount > 1) {
39 CloseHandle(hDriver);
40 hDriver = INVALID_HANDLE_VALUE;
41 return FALSE;
42 }
43
44 CloseHandle(hDriver);
45 hDriver = INVALID_HANDLE_VALUE;
46 }
47
48 // Removing tails from previous installation:
49 DeleteDriver(KbDriverName);
50
51 // Installing driver:
52 BOOL Status = InstallDriver(DriverPath, KbDriverName);
53 if (!Status) return FALSE;
54
55 // Obtaining it's handle:
56 hDriver = OpenDevice(KbDeviceName);
57 if (hDriver == INVALID_HANDLE_VALUE) {
58 DeleteDriver(KbDriverName);
59 return FALSE;
60 }
61
62 return TRUE;
63 }
64
65 BOOL WINAPI KbLoadAsFilter(
66 LPCWSTR DriverPath,

Callers

nothing calls this directly

Calls 6

OpenDeviceFunction · 0.85
KbGetUserApiVersionFunction · 0.85
DeleteDriverFunction · 0.85
InstallDriverFunction · 0.85
KbGetDriverApiVersionFunction · 0.70
KbGetHandlesCountFunction · 0.70

Tested by

no test coverage detected