Esempio n. 1
0
        /// <summary>
        /// Assembles mnemonics and injects resulting bytecode into given process.
        /// </summary>
        /// <param name="hProcess">Handle to the process into which code will be injected.</param>
        /// <param name="dwAddress">Address at which code will be injected.</param>
        /// <param name="szAssembly">Assembly mnemonics to be assembled and injected.</param>
        /// <returns>Returns true on success, false on failure.</returns>
        public static bool InjectCode(IntPtr hProcess, uint dwAddress, string szAssembly)
        {
            byte[] bBytecode;

            if (hProcess == IntPtr.Zero || szAssembly.Length == 0 || dwAddress == 0)
            {
                return(false);
            }

            try
            {
                bBytecode = ManagedFasm.Assemble(szAssembly);
            }
            catch (
                Exception ex
                )
            {
                                #if DEBUG
                Console.WriteLine(ex.Message);
                                #endif

                return(false);
            }

            return(SMemory.WriteBytes(hProcess, dwAddress, bBytecode, bBytecode.Length));
        }
Esempio n. 2
0
 /// <summary>
 /// Writes a value to another process' memory.
 /// </summary>
 /// <param name="dwAddress">Address at which value will be written.</param>
 /// <param name="Value">Value that will be written to memory.</param>
 /// <param name="nSize">Number of bytes to be written.</param>
 /// <returns>Returns true on success, false on failure.</returns>
 public bool WriteBytes(uint dwAddress, byte[] Value, int nSize)
 {
     return(SMemory.WriteBytes(this.m_hProcess, dwAddress, Value, nSize));
 }