本文整理汇总了C#中ProcessAccessFlags类的典型用法代码示例。如果您正苦于以下问题:C# ProcessAccessFlags类的具体用法?C# ProcessAccessFlags怎么用?C# ProcessAccessFlags使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ProcessAccessFlags类属于命名空间,在下文中一共展示了ProcessAccessFlags类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: OpenProcess
public static extern IntPtr OpenProcess(
ProcessAccessFlags processAccess,
bool bInheritHandle,
int processId);
开发者ID:endjin,项目名称:CucumberJS.TestAdapter,代码行数:4,代码来源:ProcessExtensions.cs
示例2: OpenProcess
/// <summary>
/// Opens an existing local process object.
/// </summary>
/// <param name="access"></param>
/// <param name="inheritHandle"></param>
/// <param name="processId"></param>
/// <returns></returns>
public static IntPtr OpenProcess(ProcessAccessFlags access, bool inheritHandle, uint processId)
{
IntPtr handle = UnmanagedOpenProcess(access, inheritHandle, processId);
if (handle == null)
{
throw new Win32Exception();
}
return handle;
}
开发者ID:PersonalityPi,项目名称:DarkToolKit,代码行数:16,代码来源:Kernel32.cs
示例3: OpenProcess
internal static IntPtr OpenProcess(ProcessAccessFlags dwDesiredAcess, bool bInheritHandle, int dwProcessId)
{
IntPtr p = NativeMethods.Internal.OpenProcess(dwDesiredAcess, bInheritHandle, dwProcessId);
if (p == IntPtr.Zero)
{
int errorCoder = Marshal.GetLastWin32Error();
if (errorCoder != 0)
throw new Win32Exception(errorCoder);
}
return p;
}
开发者ID:308465570,项目名称:FFXIV-Zodiac-Glass,代码行数:14,代码来源:NativeMethods.cs
示例4: LoadProcessInfoNative
// Reads native process info from a 64/32-bit process in the case where the target architecture
// of this process is the same as that of the target process.
private bool LoadProcessInfoNative(SafeProcessHandle handle, ProcessAccessFlags flags) {
ProcessBasicInformation basicInfo = new ProcessBasicInformation();
int size;
int status = NativeMethods.NtQueryInformationProcess(
handle,
ProcessInfoClass.BasicInformation,
ref basicInfo,
MarshalUtility.UnmanagedStructSize<ProcessBasicInformation>(),
out size);
_parentProcessId = basicInfo.ParentProcessId.ToInt32();
// If we can't load the ProcessBasicInfo, then we can't really do anything.
if (status != NtStatus.Success || basicInfo.PebBaseAddress == IntPtr.Zero)
return false;
if (flags.HasFlag(ProcessAccessFlags.VmRead)) {
// Follows a pointer from the PROCESS_BASIC_INFORMATION structure in the target process's
// address space to read the PEB.
Peb peb = MarshalUtility.ReadUnmanagedStructFromProcess<Peb>(
handle,
basicInfo.PebBaseAddress);
_isBeingDebugged = peb.IsBeingDebugged;
if (peb.ProcessParameters != IntPtr.Zero) {
// Follows a pointer from the PEB structure in the target process's address space to read
// the RTL_USER_PROCESS_PARAMS.
RtlUserProcessParameters processParameters = new RtlUserProcessParameters();
processParameters = MarshalUtility.ReadUnmanagedStructFromProcess<RtlUserProcessParameters>(
handle,
peb.ProcessParameters);
_commandLine = MarshalUtility.ReadStringUniFromProcess(
handle,
processParameters.CommandLine.Buffer,
processParameters.CommandLine.Length / 2);
}
}
return true;
}
开发者ID:mbbill,项目名称:vs-chromium,代码行数:42,代码来源:NtProcess.cs
示例5: OpenProcessHandle
private SafeProcessHandle OpenProcessHandle(out ProcessAccessFlags flags)
{
// Try to open a handle to the process with the highest level of privilege, but if we can't
// do that then fallback to requesting access with a lower privilege level.
flags = ProcessAccessFlags.QueryInformation | ProcessAccessFlags.VmRead;
SafeProcessHandle handle;
handle = NativeMethods.OpenProcess(flags, false, _processId);
if (!handle.IsInvalid)
return handle;
flags = ProcessAccessFlags.QueryLimitedInformation;
handle = NativeMethods.OpenProcess(flags, false, _processId);
if (handle.IsInvalid)
flags = ProcessAccessFlags.None;
return handle;
}
开发者ID:kleopatra999,项目名称:vs-chromium,代码行数:16,代码来源:NtProcess.cs
示例6: LoadProcessInfoWow64
// Reads native process info from a 64-bit process in the case where this function is executing
// in a 32-bit process.
private bool LoadProcessInfoWow64(SafeProcessHandle handle, ProcessAccessFlags flags)
{
ulong pebSize = (ulong)MarshalUtility.UnmanagedStructSize<PebWow64>();
ulong processParamsSize =
(ulong)MarshalUtility.UnmanagedStructSize<RtlUserProcessParametersWow64>();
// Read PROCESS_BASIC_INFORMATION up to and including the pointer to PEB structure.
int processInfoSize =
MarshalUtility.UnmanagedStructSize<ProcessBasicInformationWow64>();
ProcessBasicInformationWow64 pbi = new ProcessBasicInformationWow64();
int result = NativeMethods.NtWow64QueryInformationProcess64(
handle,
ProcessInfoClass.BasicInformation,
ref pbi,
processInfoSize,
out processInfoSize);
if (result != 0)
return false;
_parentProcessId = (int)pbi.ParentProcessId;
Debug.Assert((int)pbi.UniqueProcessId == _processId);
if (flags.HasFlag(ProcessAccessFlags.VmRead)) {
IntPtr pebBuffer = IntPtr.Zero;
IntPtr processParametersBuffer = IntPtr.Zero;
IntPtr commandLineBuffer = IntPtr.Zero;
try {
pebBuffer = Marshal.AllocHGlobal((int)pebSize);
// Read PEB up to and including the pointer to RTL_USER_PROCESS_PARAMETERS
// structure.
result = NativeMethods.NtWow64ReadVirtualMemory64(
handle,
pbi.PebBaseAddress,
pebBuffer,
pebSize,
out pebSize);
if (result != 0)
return false;
PebWow64 peb = (PebWow64)Marshal.PtrToStructure(pebBuffer, typeof(PebWow64));
_isBeingDebugged = peb.IsBeingDebugged;
processParametersBuffer = Marshal.AllocHGlobal((int)processParamsSize);
result = NativeMethods.NtWow64ReadVirtualMemory64(
handle,
peb.ProcessParameters,
processParametersBuffer,
processParamsSize,
out processParamsSize);
if (result != 0)
return false;
RtlUserProcessParametersWow64 processParameters = (RtlUserProcessParametersWow64)
Marshal.PtrToStructure(
processParametersBuffer,
typeof(RtlUserProcessParametersWow64));
ulong commandLineBufferSize = (ulong)processParameters.CommandLine.MaximumLength;
commandLineBuffer = Marshal.AllocHGlobal((int)commandLineBufferSize);
result = NativeMethods.NtWow64ReadVirtualMemory64(
handle,
processParameters.CommandLine.Buffer,
commandLineBuffer,
commandLineBufferSize,
out commandLineBufferSize);
if (result != 0)
return false;
_commandLine = Marshal.PtrToStringUni(commandLineBuffer);
} finally {
if (pebBuffer != IntPtr.Zero)
Marshal.FreeHGlobal(pebBuffer);
if (commandLineBuffer != IntPtr.Zero)
Marshal.FreeHGlobal(commandLineBuffer);
if (processParametersBuffer != IntPtr.Zero)
Marshal.FreeHGlobal(processParametersBuffer);
}
}
return true;
}
开发者ID:kleopatra999,项目名称:vs-chromium,代码行数:80,代码来源:NtProcess.cs
示例7: OpenProcessHandle
public static SafeProcessHandle OpenProcessHandle(ProcessAccessFlags desiredAccess, bool inheritHandle, int processId)
{
var handle = OpenProcess(desiredAccess, inheritHandle, processId);
var error = GetLastError();
if (handle == IntPtr.Zero)
throw new Exception(String.Format(
"Failed to open process: Error {0:x8}", error
));
return new SafeProcessHandle(handle);
}
开发者ID:sq,项目名称:PETools,代码行数:12,代码来源:Win32.cs
示例8: OpenProcess
private static extern IntPtr OpenProcess(ProcessAccessFlags desiredAccess,
[MarshalAs(UnmanagedType.Bool)] bool inheritHandle, int processId);
开发者ID:jasonpang,项目名称:Starcraft2Hook,代码行数:2,代码来源:ProcessExtensions.cs
示例9: OpenProcess
public static extern IntPtr OpenProcess(ProcessAccessFlags dwDesiredAccess, bool bInheritHandle,
int dwProcessId);
开发者ID:jdstroy,项目名称:windows-ssh-server,代码行数:2,代码来源:WinApi.cs
示例10: OpenProcess
internal static extern SafeProcessHandle OpenProcess(ProcessAccessFlags dwDesiredAccess, bool bInheritHandle, int dwProcessID);
开发者ID:hfenigma,项目名称:d3adventure,代码行数:1,代码来源:Imports.cs
示例11: VirtualProtectEx
private static extern bool VirtualProtectEx(IntPtr hProcess, IntPtr lpAddress, IntPtr dwSize,
ProcessAccessFlags flNewProtect, out uint lpflOldProtect);
开发者ID:arthur-conde,项目名称:ffxivlib,代码行数:2,代码来源:SigScanner.cs
示例12: OpenProcess
public static extern SafeProcessHandle OpenProcess(ProcessAccessFlags processAccess, bool bInheritHandle, int processId);
开发者ID:xyandro,项目名称:NeoEdit,代码行数:1,代码来源:Win32.cs
示例13: OpenHandle
/// <summary>
/// Opens a handle to a process
/// </summary>
/// <param name="id">ID of the process</param>
/// <param name="flags">ProcessAccessFlags to use</param>
/// <returns>A handle to the process</returns>
public SafeMemoryHandle OpenHandle(ProcessAccessFlags flags)
{
return NativeMethods.OpenProcess(flags, false, _process.Id);
}
开发者ID:aganonki,项目名称:HackTools,代码行数:10,代码来源:Memory.cs
示例14: OpenProcess
internal static extern IntPtr OpenProcess(ProcessAccessFlags desiredAccess, bool inheritHandle, int processId);
开发者ID:ewrogers,项目名称:SleepHunter4,代码行数:1,代码来源:NativeMethods.cs
示例15: SetPrivilege
public static extern bool SetPrivilege(HANDLE token, ProcessAccessFlags Privilege, bool EnablePrivilege);
开发者ID:Pavel-Durov,项目名称:Win-Handles-Querier,代码行数:1,代码来源:Kernel32.cs
示例16: OpenProcess
public static extern SafeMemoryHandle OpenProcess(ProcessAccessFlags dwDesiredAccess,
[MarshalAs(UnmanagedType.Bool)] bool bInheritHandle, int dwProcessId);
开发者ID:jasteph,项目名称:MemorySharp,代码行数:2,代码来源:NativeMethods.cs
示例17: UnmanagedOpenProcess
private static extern IntPtr UnmanagedOpenProcess(ProcessAccessFlags dwDesiredAccess, bool bInheritHandle, uint dwProcessId);
开发者ID:PersonalityPi,项目名称:DarkToolKit,代码行数:1,代码来源:Kernel32.cs
示例18: OpenProcess
private static IntPtr OpenProcess(Process proc, ProcessAccessFlags flags) => OpenProcess(flags, false, proc.Id);
开发者ID:OxideMod,项目名称:OxideNative,代码行数:1,代码来源:ManagedShell.cs
示例19: OpenProcess
public static IntPtr OpenProcess(Process process, ProcessAccessFlags flags)
{
return OpenProcess(flags, false, process.Id);
}
开发者ID:hunkiller,项目名称:PoeHud,代码行数:4,代码来源:WinApi.cs
示例20: OpenProcessHandle
public static AutoDispose<IntPtr> OpenProcessHandle(ProcessAccessFlags processAccess, bool bInheritHandle, uint processId)
{
var handle = OpenProcess(processAccess, bInheritHandle, processId);
if (handle == IntPtr.Zero || handle == INVALID_HANDLE_VALUE)
{
return null;
}
return new AutoDispose<IntPtr>(handle, (target) => CloseHandle(target));
}
开发者ID:FineRedMist,项目名称:memhack,代码行数:9,代码来源:Interop.cs
注:本文中的ProcessAccessFlags类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论