diff options
Diffstat (limited to 'tools/win/ChromeDebug/LowLevel/NativeMethods.cs')
-rw-r--r-- | tools/win/ChromeDebug/LowLevel/NativeMethods.cs | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/tools/win/ChromeDebug/LowLevel/NativeMethods.cs b/tools/win/ChromeDebug/LowLevel/NativeMethods.cs new file mode 100644 index 0000000..4fb46fd --- /dev/null +++ b/tools/win/ChromeDebug/LowLevel/NativeMethods.cs @@ -0,0 +1,65 @@ +// Copyright 2013 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +using Microsoft.Win32.SafeHandles; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Runtime.InteropServices; +using System.Text; +using System.Threading.Tasks; + +namespace ChromeDebug.LowLevel { + public static class NativeMethods { + [DllImport("kernel32.dll", SetLastError = true)] + [return: MarshalAs(UnmanagedType.Bool)] + public static extern bool ReadProcessMemory(IntPtr hProcess, + IntPtr lpBaseAddress, + IntPtr lpBuffer, + int dwSize, + out int lpNumberOfBytesRead); + + [DllImport("ntdll.dll", SetLastError = true)] + public static extern LowLevelTypes.NTSTATUS NtQueryInformationProcess( + IntPtr hProcess, + LowLevelTypes.PROCESSINFOCLASS pic, + ref LowLevelTypes.PROCESS_BASIC_INFORMATION pbi, + int cb, + out int pSize); + + [DllImport("shell32.dll", SetLastError = true)] + public static extern IntPtr CommandLineToArgvW( + [MarshalAs(UnmanagedType.LPWStr)] string lpCmdLine, + out int pNumArgs); + + [DllImport("kernel32.dll", SetLastError = true)] + public static extern IntPtr LocalFree(IntPtr hMem); + + [DllImport("kernel32.dll", SetLastError = true)] + public static extern IntPtr OpenProcess( + LowLevelTypes.ProcessAccessFlags dwDesiredAccess, + [MarshalAs(UnmanagedType.Bool)] bool bInheritHandle, + int dwProcessId); + + [DllImport("kernel32.dll", SetLastError = true, CallingConvention = CallingConvention.StdCall, + CharSet = CharSet.Unicode)] + public static extern uint QueryFullProcessImageName( + IntPtr hProcess, + [MarshalAs(UnmanagedType.U4)] LowLevelTypes.ProcessQueryImageNameMode flags, + [Out] StringBuilder lpImageName, ref int size); + + [DllImport("kernel32.dll", SetLastError = true)] + [return: MarshalAs(UnmanagedType.Bool)] + public static extern bool CloseHandle(IntPtr hObject); + + [DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Unicode)] + public static extern SafeFileHandle CreateFile(string lpFileName, + LowLevelTypes.FileAccessFlags dwDesiredAccess, + LowLevelTypes.FileShareFlags dwShareMode, + IntPtr lpSecurityAttributes, + LowLevelTypes.FileCreationDisposition dwDisp, + LowLevelTypes.FileFlagsAndAttributes dwFlags, + IntPtr hTemplateFile); + } +} |