Beispiel #1
0
        private bool WriteProcessMemory(IntPtr Pointer, byte[] BytesToWrite)
        {
            IntPtr nBytes;

            return(NativeImport.WriteProcessMemory(LoadedProcess.Handle, Pointer, BytesToWrite,
                                                   BytesToWrite.Length, out nBytes));
        }
Beispiel #2
0
        private IntPtr CallMethod(IntPtr ptr, IntPtr arg)
        {
            IntPtr hThreadId;
            var    hThread = NativeImport.CreateRemoteThread(LoadedProcess.Handle, IntPtr.Zero, 0,
                                                             ptr, arg, 0, out hThreadId);

            return(hThread);
        }
Beispiel #3
0
        internal void LoadAndCallMethod(string Library, string MethodName)
        {
            PerformValidationCheck(Library);

            var LoadedLibraryPTR            = Load(Library);
            var LibraryToLoadCurrentProcPTR = NativeImport.LoadLibrary(Library);
            var PTRToMethod = NativeImport.GetProcAddress(LibraryToLoadCurrentProcPTR, MethodName);

            CallMethod(PTRToMethod, IntPtr.Zero);
        }
Beispiel #4
0
        private int CallLoadLibraryA(IntPtr PointerToArg)
        {
            IntPtr hThreadId;
            var    hThread = NativeImport.CreateRemoteThread(LoadedProcess.Handle, IntPtr.Zero, 0, LoadLibraryPTR, PointerToArg, 0, out hThreadId);

            NativeImport.WaitForSingleObject(hThread, unchecked ((uint)-1));
            uint exitCode;

            NativeImport.GetExitCodeThread(hThread, out exitCode);
            return((int)exitCode);
        }
Beispiel #5
0
        internal Loader(string ProcessName)
        {
            try { LoadedProcess = Process.GetProcessesByName(ProcessName).First(); }
            catch (Exception)
            {
                Console.WriteLine($"Could Not Find Process: {ProcessName}");
                Console.Read();
                Environment.Exit(0);
            }

            Kernel32PTR    = NativeImport.LoadLibrary("kernel32");
            LoadLibraryPTR = NativeImport.GetProcAddress(Kernel32PTR, "LoadLibraryA");
        }
Beispiel #6
0
        private bool IsLoadedProcessX64()
        {
            if (!Environment.Is64BitOperatingSystem)
            {
                return(false);
            }

            bool isWow64;

            if (!NativeImport.IsWow64Process(LoadedProcess.Handle, out isWow64))
            {
                isWow64 = false;
            }

            return(!isWow64);
        }
Beispiel #7
0
 private IntPtr VirtualAllocEx(int size)
 {
     return(NativeImport.VirtualAllocEx(LoadedProcess.Handle, IntPtr.Zero, (IntPtr)size,
                                        Enums.AllocationType.Commit | Enums.AllocationType.Reserve,
                                        Enums.MemoryProtection.ExecuteReadWrite));
 }