Exemplo n.º 1
0
 public static extern IntPtr CreateICW(string lpszDriver, string lpszDevice, string lpszOutput, SafeMemoryHandle devmodePtr);
Exemplo n.º 2
0
 public static extern int GetThreadId(SafeMemoryHandle hThread);
Exemplo n.º 3
0
 public static extern bool GetPrinterW(SafeWinSpoolPrinterHandle printer, uint dwLevel, SafeMemoryHandle pPrinter, uint dwBuf, ref uint dwNeeded);
Exemplo n.º 4
0
 public static extern bool GetExitCodeThread(SafeMemoryHandle hThread, out IntPtr lpExitCode);
Exemplo n.º 5
0
 public static extern bool GetThreadContext(SafeMemoryHandle hThread, ref ThreadContext lpContext);
Exemplo n.º 6
0
 public static extern bool WriteProcessMemory(SafeMemoryHandle hProcess, IntPtr lpBaseAddress, byte[] lpBuffer,
                                              int nSize, out int lpNumberOfBytesWritten);
Exemplo n.º 7
0
 public static extern bool ReadProcessMemory(SafeMemoryHandle hProcess, IntPtr lpBaseAddress,
                                             [Out] byte[] lpBuffer, int dwSize, out int lpNumberOfBytesRead);
Exemplo n.º 8
0
 internal static extern bool VirtualProtectEx(SafeMemoryHandle hProcess, IntPtr lpAddress, UIntPtr dwSize, uint flNewProtect, out uint lpflOldProtect);
Exemplo n.º 9
0
 public static extern int NtQueryInformationProcess(SafeMemoryHandle processHandle,
                                                    ProcessInformationClass infoclass,
                                                    ref ProcessBasicInformation processinfo, int length, IntPtr bytesread);
Exemplo n.º 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)
 {
 }
Exemplo n.º 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)
 {
 }
Exemplo n.º 12
0
 internal static extern bool VirtualFreeEx(SafeMemoryHandle hProcess, IntPtr dwAddress, int nSize,
     MemoryFreeType dwFreeType);
Exemplo n.º 13
0
 internal static extern IntPtr VirtualAllocEx(SafeMemoryHandle hProcess, uint dwAddress, int nSize,
     MemoryAllocationType dwAllocationType, MemoryProtectionType dwProtect);
Exemplo n.º 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);
        }
Exemplo n.º 15
0
 internal static extern IntPtr VirtualAllocEx(SafeMemoryHandle hProcess, uint dwAddress, int nSize,
                                              MemoryAllocationType dwAllocationType, MemoryProtectionType dwProtect);
Exemplo n.º 16
0
 public static extern uint NtQueryInformationThread(SafeMemoryHandle hwnd, uint infoclass,
                                                    ref ThreadBasicInformation threadinfo, int length, IntPtr bytesread);
Exemplo n.º 17
0
 private static extern unsafe bool ReadProcessMemory(SafeMemoryHandle hProcess, IntPtr lpBaseAddress,
     void* lpBuffer, int dwSize, out int lpNumberOfBytesRead);
Exemplo n.º 18
0
 public static bool Free(SafeMemoryHandle handle, IntPtr address)
 {
     return(NativeMethods.VirtualFreeEx(handle, address, 0, MemoryReleaseFlags.Release));
 }
Exemplo n.º 19
0
 public static extern bool SetThreadContext(SafeMemoryHandle hThread,
                                            [MarshalAs(UnmanagedType.Struct)] ref ThreadContext lpContext);
Exemplo n.º 20
0
 public static extern int SuspendThread(SafeMemoryHandle hThread);
Exemplo n.º 21
0
 public static extern int ResumeThread(SafeMemoryHandle hThread);
Exemplo n.º 22
0
 public static extern bool TerminateThread(SafeMemoryHandle hThread, int dwExitCode);
Exemplo n.º 23
0
 public static extern int GetProcessId(SafeMemoryHandle hProcess);
Exemplo n.º 24
0
 public static extern IntPtr VirtualAllocEx(SafeMemoryHandle hProcess, IntPtr lpAddress, int dwSize,
                                            MemoryAllocationFlags flAllocationType, MemoryProtectionFlags flProtect);
Exemplo n.º 25
0
 public static extern bool GetThreadSelectorEntry(SafeMemoryHandle hThread, int dwSelector,
                                                  out LdtEntry lpSelectorEntry);
Exemplo n.º 26
0
 public static extern bool VirtualFreeEx(SafeMemoryHandle hProcess, IntPtr lpAddress, int dwSize,
                                         MemoryReleaseFlags dwFreeType);
Exemplo n.º 27
0
 public static extern SafeMemoryHandle CreateRemoteThread(SafeMemoryHandle hProcess, IntPtr lpThreadAttributes,
                                                          int dwStackSize, IntPtr lpStartAddress,
                                                          IntPtr lpParameter, ThreadCreationFlags dwCreationFlags, out int lpThreadId);
Exemplo n.º 28
0
 public static extern bool VirtualProtectEx(SafeMemoryHandle hProcess, IntPtr lpAddress, int dwSize,
                                            MemoryProtectionFlags flNewProtect, out MemoryProtectionFlags lpflOldProtect);
Exemplo n.º 29
0
 public static extern uint DeviceCapabilitiesW(string pDevice, string pPort, DeviceCapability fwCapabilities, SafeMemoryHandle pOutput, SafeMemoryHandle pDevMode);
Exemplo n.º 30
0
 public static extern int VirtualQueryEx(SafeMemoryHandle hProcess, IntPtr lpAddress,
                                         out MemoryBasicInformation lpBuffer, int dwLength);
Exemplo n.º 31
0
 public static extern uint CreateStreamOnHGlobal(SafeMemoryHandle hGlobal, bool fDeleteOnRelease, out IStream ppstm);
Exemplo n.º 32
0
 public static extern WaitValues WaitForSingleObject(SafeMemoryHandle hHandle, uint dwMilliseconds);
Exemplo n.º 33
0
 internal static extern bool VirtualFreeEx(SafeMemoryHandle hProcess, IntPtr dwAddress, int nSize,
                                           MemoryFreeType dwFreeType);
Exemplo n.º 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);
 }