Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unload feature + bug fixes #4

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion KsDumperClient/Driver/DriverInterface.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

namespace KsDumperClient.Driver
{
public class DriverInterface
public class DriverInterface : IDisposable
{
private readonly IntPtr driverHandle;

Expand Down Expand Up @@ -106,5 +106,25 @@ public bool CopyVirtualMemory(int targetProcessId, IntPtr targetAddress, IntPtr
}
return false;
}

public bool UnloadDriver()
{
if (driverHandle != WinApi.INVALID_HANDLE_VALUE)
{
return WinApi.DeviceIoControl(driverHandle, IO_UNLOAD_DRIVER, IntPtr.Zero, 0, IntPtr.Zero, 0, IntPtr.Zero, IntPtr.Zero);
}
return false;
}

public void Dispose()
{
WinApi.CloseHandle(driverHandle);
}

~DriverInterface()
{
WinApi.CloseHandle(driverHandle);
}

}
}
2 changes: 2 additions & 0 deletions KsDumperClient/Driver/Operations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ public static class Operations

public static readonly uint IO_COPY_MEMORY = CTL_CODE(FILE_DEVICE_UNKNOWN, 0x1725, METHOD_BUFFERED, FILE_ANY_ACCESS);

public static readonly uint IO_UNLOAD_DRIVER = CTL_CODE(FILE_DEVICE_UNKNOWN, 0x1726, METHOD_BUFFERED, FILE_ANY_ACCESS);

[StructLayout(LayoutKind.Sequential)]
public struct KERNEL_PROCESS_LIST_OPERATION
{
Expand Down
489 changes: 250 additions & 239 deletions KsDumperClient/Dumper.Designer.cs

Large diffs are not rendered by default.

20 changes: 19 additions & 1 deletion KsDumperClient/Dumper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,24 @@ private void openInExplorerToolStripMenuItem_Click(object sender, EventArgs e)
{
ProcessSummary targetProcess = processList.SelectedItems[0].Tag as ProcessSummary;
Process.Start("explorer.exe", Path.GetDirectoryName(targetProcess.MainModuleFileName));
}
}

private void unloadDriverBtn_Click(object sender, EventArgs e)
{
var result = MessageBox.Show("Are you sure?", "Driver unload", MessageBoxButtons.YesNo);
if (result == DialogResult.Yes)
{
bool unloadResult = driver.UnloadDriver();
if (unloadResult)
{
MessageBox.Show("Unload good");
}
else
{
MessageBox.Show("Unload failed");

}
}
}
}
}
Loading