Skip to content

Commit dc21a6c

Browse files
committed
Added Load/Unload driver.
1 parent 1ec51ea commit dc21a6c

2 files changed

Lines changed: 32 additions & 0 deletions

File tree

NtApiDotNet/NtSystemInfo.cs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -840,6 +840,28 @@ public static void DisplayString(string text)
840840
DisplayString(text, true);
841841
}
842842

843+
/// <summary>
844+
/// Load a driver.
845+
/// </summary>
846+
/// <param name="driver_service_name">The name of the driver service.</param>
847+
/// <param name="throw_on_error">True to throw on error.</param>
848+
/// <returns>The NT status code.</returns>
849+
public static NtStatus LoadDriver(string driver_service_name, bool throw_on_error = true)
850+
{
851+
return NtSystemCalls.NtLoadDriver(new UnicodeString(driver_service_name)).ToNtException(throw_on_error);
852+
}
853+
854+
/// <summary>
855+
/// Unload a driver.
856+
/// </summary>
857+
/// <param name="driver_service_name">The name of the driver service.</param>
858+
/// <param name="throw_on_error">True to throw on error.</param>
859+
/// <returns>The NT status code.</returns>
860+
public static NtStatus UnloadDriver(string driver_service_name, bool throw_on_error = true)
861+
{
862+
return NtSystemCalls.NtUnloadDriver(new UnicodeString(driver_service_name)).ToNtException(throw_on_error);
863+
}
864+
843865
#endregion
844866

845867
#region Static Properties

NtApiDotNet/NtSystemInfoNative.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,16 @@ public static extern NtStatus NtSetSystemEnvironmentValueEx([In] UnicodeString V
8585

8686
[DllImport("ntdll.dll")]
8787
public static extern NtStatus NtDisplayString([In] UnicodeString Text);
88+
89+
[DllImport("ntdll.dll")]
90+
public static extern NtStatus NtLoadDriver(
91+
[In] UnicodeString DriverServiceName
92+
);
93+
94+
[DllImport("ntdll.dll")]
95+
public static extern NtStatus NtUnloadDriver(
96+
[In] UnicodeString DriverServiceName
97+
);
8898
}
8999

90100
public static partial class NtRtl

0 commit comments

Comments
 (0)