Пример #1
0
 public static extern IntPtr CreateICW(string lpszDriver, string lpszDevice, string lpszOutput, SafeMemoryHandle devmodePtr);
Пример #2
0
 public static extern int GetThreadId(SafeMemoryHandle hThread);
Пример #3
0
 public static extern bool GetPrinterW(SafeWinSpoolPrinterHandle printer, uint dwLevel, SafeMemoryHandle pPrinter, uint dwBuf, ref uint dwNeeded);
Пример #4
0
 public static extern bool GetExitCodeThread(SafeMemoryHandle hThread, out IntPtr lpExitCode);
Пример #5
0
 public static extern bool GetThreadContext(SafeMemoryHandle hThread, ref ThreadContext lpContext);
Пример #6
0
 public static extern bool WriteProcessMemory(SafeMemoryHandle hProcess, IntPtr lpBaseAddress, byte[] lpBuffer,
                                              int nSize, out int lpNumberOfBytesWritten);
Пример #7
0
 public static extern bool ReadProcessMemory(SafeMemoryHandle hProcess, IntPtr lpBaseAddress,
                                             [Out] byte[] lpBuffer, int dwSize, out int lpNumberOfBytesRead);
Пример #8
0
 internal static extern bool VirtualProtectEx(SafeMemoryHandle hProcess, IntPtr lpAddress, UIntPtr dwSize, uint flNewProtect, out uint lpflOldProtect);
Пример #9
0
 public static extern int NtQueryInformationProcess(SafeMemoryHandle processHandle,
                                                    ProcessInformationClass infoclass,
                                                    ref ProcessBasicInformation processinfo, int length, IntPtr bytesread);
Пример #10
0
 /// <summary>
 ///     Initializes a new instance of the <see cref="LocalProcessMemory" /> class.
 /// </summary>
 /// <param name="handle">The process.</param>
 public LocalProcessMemory(SafeMemoryHandle handle) : base(handle)
 {
 }
Пример #11
0
 /// <summary>
 ///     Initializes a new instance of the <see cref="ExternalProcessMemory" /> class.
 /// </summary>
 /// <param name="handle">The open handle to the process which contains the memory of interest.</param>
 public ExternalProcessMemory(SafeMemoryHandle handle) : base(handle)
 {
 }
Пример #12
0
 internal static extern bool VirtualFreeEx(SafeMemoryHandle hProcess, IntPtr dwAddress, int nSize,
     MemoryFreeType dwFreeType);
Пример #13
0
 internal static extern IntPtr VirtualAllocEx(SafeMemoryHandle hProcess, uint dwAddress, int nSize,
     MemoryAllocationType dwAllocationType, MemoryProtectionType dwProtect);
Пример #14
0
        /// <summary>
        ///     Retrieves information about a range of pages within the virtual address space of a specified process.
        /// </summary>
        /// <param name="processHandle">A handle to the process whose memory information is queried.</param>
        /// <param name="addressFrom">A pointer to the starting address of the region of pages to be queried.</param>
        /// <param name="addressTo">A pointer to the ending address of the region of pages to be queried.</param>
        /// <returns>A collection of <see cref="MemoryBasicInformation32" /> structures.</returns>
        public static IEnumerable <MemoryBasicInformation64> Query(SafeMemoryHandle processHandle, IntPtr addressFrom,
                                                                   IntPtr addressTo)
        {
            // Check if the handle is valid
            HandleManipulator.ValidateAsArgument(processHandle, "processHandle");

            // Convert the addresses to Int64
            var numberFrom = addressFrom.ToInt64();
            var numberTo   = addressTo.ToInt64();

            // The first address must be lower than the second
            if (numberFrom >= numberTo)
            {
                throw new ArgumentException("The starting address must be lower than the ending address.",
                                            "addressFrom");
            }

            // Create the variable storing the result of the call of VirtualQueryEx
            int ret;

            // Enumerate the memory pages
            do
            {
                // Allocate the structure to store information of memory
                var memoryInfo = new MemoryBasicInformation64();

                if (!Environment.Is64BitProcess)
                {
                    // Get the next memory page
                    ret = Kernel32.VirtualQueryEx(processHandle, new IntPtr(numberFrom), out memoryInfo,
                                                  MarshalType <MemoryBasicInformation64> .Size);
                }
                else
                {
                    // Allocate the structure to store information of memory
                    MemoryBasicInformation32 memoryInfo32;

                    // Get the next memory page
                    ret = Kernel32.VirtualQueryEx(processHandle, new IntPtr(numberFrom), out memoryInfo32,
                                                  MarshalType <MemoryBasicInformation32> .Size);

                    // Copy from the 32 bit struct to the 64 bit struct
                    memoryInfo.AllocationBase    = memoryInfo32.AllocationBase;
                    memoryInfo.AllocationProtect = memoryInfo32.AllocationProtect;
                    memoryInfo.BaseAddress       = memoryInfo32.BaseAddress;
                    memoryInfo.Protect           = memoryInfo32.Protect;
                    memoryInfo.RegionSize        = memoryInfo32.RegionSize;
                    memoryInfo.State             = memoryInfo32.State;
                    memoryInfo.Type = memoryInfo32.Type;
                }


                // Increment the starting address with the size of the page
                numberFrom += memoryInfo.RegionSize;

                // Return the memory page
                if (memoryInfo.State != MemoryStateFlags.Free)
                {
                    yield return(memoryInfo);
                }
            } while (numberFrom < numberTo && ret != 0);
        }
Пример #15
0
 internal static extern IntPtr VirtualAllocEx(SafeMemoryHandle hProcess, uint dwAddress, int nSize,
                                              MemoryAllocationType dwAllocationType, MemoryProtectionType dwProtect);
Пример #16
0
 public static extern uint NtQueryInformationThread(SafeMemoryHandle hwnd, uint infoclass,
                                                    ref ThreadBasicInformation threadinfo, int length, IntPtr bytesread);
Пример #17
0
 private static extern unsafe bool ReadProcessMemory(SafeMemoryHandle hProcess, IntPtr lpBaseAddress,
     void* lpBuffer, int dwSize, out int lpNumberOfBytesRead);
Пример #18
0
 public static bool Free(SafeMemoryHandle handle, IntPtr address)
 {
     return(NativeMethods.VirtualFreeEx(handle, address, 0, MemoryReleaseFlags.Release));
 }
Пример #19
0
 public static extern bool SetThreadContext(SafeMemoryHandle hThread,
                                            [MarshalAs(UnmanagedType.Struct)] ref ThreadContext lpContext);
Пример #20
0
 public static extern int SuspendThread(SafeMemoryHandle hThread);
Пример #21
0
 public static extern int ResumeThread(SafeMemoryHandle hThread);
Пример #22
0
 public static extern bool TerminateThread(SafeMemoryHandle hThread, int dwExitCode);
Пример #23
0
 public static extern int GetProcessId(SafeMemoryHandle hProcess);
Пример #24
0
 public static extern IntPtr VirtualAllocEx(SafeMemoryHandle hProcess, IntPtr lpAddress, int dwSize,
                                            MemoryAllocationFlags flAllocationType, MemoryProtectionFlags flProtect);
Пример #25
0
 public static extern bool GetThreadSelectorEntry(SafeMemoryHandle hThread, int dwSelector,
                                                  out LdtEntry lpSelectorEntry);
Пример #26
0
 public static extern bool VirtualFreeEx(SafeMemoryHandle hProcess, IntPtr lpAddress, int dwSize,
                                         MemoryReleaseFlags dwFreeType);
Пример #27
0
 public static extern SafeMemoryHandle CreateRemoteThread(SafeMemoryHandle hProcess, IntPtr lpThreadAttributes,
                                                          int dwStackSize, IntPtr lpStartAddress,
                                                          IntPtr lpParameter, ThreadCreationFlags dwCreationFlags, out int lpThreadId);
Пример #28
0
 public static extern bool VirtualProtectEx(SafeMemoryHandle hProcess, IntPtr lpAddress, int dwSize,
                                            MemoryProtectionFlags flNewProtect, out MemoryProtectionFlags lpflOldProtect);
Пример #29
0
 public static extern uint DeviceCapabilitiesW(string pDevice, string pPort, DeviceCapability fwCapabilities, SafeMemoryHandle pOutput, SafeMemoryHandle pDevMode);
Пример #30
0
 public static extern int VirtualQueryEx(SafeMemoryHandle hProcess, IntPtr lpAddress,
                                         out MemoryBasicInformation lpBuffer, int dwLength);
Пример #31
0
 public static extern uint CreateStreamOnHGlobal(SafeMemoryHandle hGlobal, bool fDeleteOnRelease, out IStream ppstm);
Пример #32
0
 public static extern WaitValues WaitForSingleObject(SafeMemoryHandle hHandle, uint dwMilliseconds);
Пример #33
0
 internal static extern bool VirtualFreeEx(SafeMemoryHandle hProcess, IntPtr dwAddress, int nSize,
                                           MemoryFreeType dwFreeType);
Пример #34
0
 private static unsafe void PerfTestKnownSpellsRPMDirect(SafeMemoryHandle processHandle, IntPtr imgbase)
 {
     int numRead;
     int numSpells = 0;
     ReadProcessMemory(processHandle, imgbase + (int) LocalPlayerNumKnownSpells, &numSpells, 4, out numRead);
 }