Hello,
I have been programming in C# and i know kinda C++ but very simply.i have seen source code for dota 2 camera hack for C#.
Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
using System.Runtime.InteropServices;

namespace dotacamzoom
{
    class Program
    {
        #region pinvoke crap
        [DllImport("kernel32.dll")]
        static extern IntPtr LoadLibraryEx(string fileName, IntPtr file, LoadLibraryFlags flags);
        [DllImport("kernel32", CharSet = CharSet.Ansi, ExactSpelling = true, SetLastError = true)]
        static extern IntPtr GetProcAddress(IntPtr module, string procName);
        [DllImport("kernel32.dll", SetLastError = true)]
        static extern bool ReadProcessMemory(
          IntPtr hProcess,
          IntPtr lpBaseAddress,
          [Out] byte[] lpBuffer,
          int dwSize,
          out int lpNumberOfBytesRead
         );
        [DllImport("kernel32.dll", SetLastError = true)]
        static extern bool WriteProcessMemory(IntPtr hProcess, IntPtr lpBaseAddress, byte[] lpBuffer, int nSize, out int lpNumberOfBytesWritten);

        [Flags]
        enum LoadLibraryFlags : uint
        {     
             DONT_RESOLVE_DLL_REFERENCES = 0x00000001,
             LOAD_IGNORE_CODE_AUTHZ_LEVEL = 0x00000010,
             LOAD_LIBRARY_AS_DATAFILE = 0x00000002,
             LOAD_LIBRARY_AS_DATAFILE_EXCLUSIVE = 0x00000040,
             LOAD_LIBRARY_AS_IMAGE_RESOURCE = 0x00000020,
             LOAD_WITH_ALTERED_SEARCH_PATH = 0x00000008
        }
        #endregion

        static void Main(string[] args)
        {
            try
            {
                Console.WriteLine("dota_camera_distance unlocker, by rolle3k");

                Process dota = Process.GetProcesses().Where(x => x.ProcessName == "dota").FirstOrDefault();

                if (dota == default(Process))
                {
                    throw new Exception("dota.exe not found");
                }

                ProcessModule vstdlib = null;

                foreach (ProcessModule p in dota.Modules)
                {
                    if (p.ModuleName == "vstdlib.dll")
                    {
                        vstdlib = p;
                        break;
                    }
                }

                if (vstdlib == null)
                {
                    throw new Exception("vstdlib not found");
                }

                IntPtr vstdlibDll = LoadLibraryEx(vstdlib.FileName, IntPtr.Zero, LoadLibraryFlags.DONT_RESOLVE_DLL_REFERENCES);

                if (vstdlibDll == IntPtr.Zero)
                {
                    throw new Exception("couldnt load vstdlibDll");
                }

                IntPtr createInterfaceFn = GetProcAddress(vstdlibDll, "CreateInterface");

                if (createInterfaceFn == IntPtr.Zero)
                {
                    throw new Exception("createInterfaceFn not found");
                }

                IntPtr interfaces = createInterfaceFn;
                interfaces = IntPtr.Add(interfaces, 5);
                interfaces = IntPtr.Add(interfaces, Marshal.ReadInt32(interfaces) + 4);
                interfaces = IntPtr.Add(interfaces, 6);

                interfaces = new IntPtr(Marshal.ReadInt32(interfaces) - vstdlibDll.ToInt32());

                IntPtr vstdlibInterface = ReadIntPtr(dota, IntPtr.Add(interfaces, vstdlib.BaseAddress.ToInt32()));

                IntPtr engineCVar = IntPtr.Zero;

                while (vstdlibInterface != IntPtr.Zero)
                {
                    string interfaceName = ReadString(dota, ReadIntPtr(dota, IntPtr.Add(vstdlibInterface, 0x04)));

                    if (interfaceName == "VEngineCvar007")
                    {
                        engineCVar = ReadIntPtr(dota, IntPtr.Add(ReadIntPtr(dota, vstdlibInterface), 1));
                        break;
                    }

                    vstdlibInterface = ReadIntPtr(dota, IntPtr.Add(vstdlibInterface, 0x08));
                }

                if (engineCVar == IntPtr.Zero)
                {
                    throw new Exception("Couldnt find VEngineCvar007");
                }

                IntPtr cvar = ReadIntPtr(dota, IntPtr.Add(engineCVar, 0x34));
                cvar = IntPtr.Add(cvar, 0xC3 * 4);
                cvar = ReadIntPtr(dota, cvar);

                while (cvar != IntPtr.Zero)
                {
                    if (ReadInt(dota, cvar) == 0x0000D2C3)
                    {
                        cvar = ReadIntPtr(dota, IntPtr.Add(cvar, 0x04));
                        break;
                    }

                    cvar = ReadIntPtr(dota, IntPtr.Add(cvar, 0x0C));
                }

                if (cvar == IntPtr.Zero)
                {
                    throw new Exception("Cvar not found!");
                }

                WriteInt(dota, IntPtr.Add(cvar, 0x14), 0x08);
                Console.WriteLine("dota_camera_distance cvar has been unlocked!");
                Console.ReadKey();
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                Console.ReadKey();
            }
        }

        private static int ReadInt(Process proc, IntPtr offset)
        {
            byte[] buf = new byte[4];
            int r;
            ReadProcessMemory(proc.Handle, offset, buf, 4, out r);
            return BitConverter.ToInt32(buf, 0);
        }

        private static IntPtr ReadIntPtr(Process proc, IntPtr offset)
        {
            return new IntPtr(ReadInt(proc, offset));
        }

        private static string ReadString(Process proc, IntPtr offset)
        {
            byte[] buf = new byte[128];
            int r;
            ReadProcessMemory(proc.Handle, offset, buf, 128, out r);

            int endIndex = 0;

            for (int i = 0; i < buf.Length; i++)
            {
                if (buf[i] == '\0')
                {
                    endIndex = i;
                    break;
                }
            }

            return ASCIIEncoding.ASCII.GetString(buf, 0, endIndex);
        }

        private static void WriteInt(Process proc, IntPtr offset, int value)
        {
            byte[] buf = BitConverter.GetBytes(value);
            int w;
            WriteProcessMemory(proc.Handle, offset, buf, buf.Length, out w);
        }
    }
}

Anyone can give me a hand what does it mean this kind of code. Most likely how to find those things by cheatengine or other program.



Code:
       
               IntPtr interfaces = createInterfaceFn;
                interfaces = IntPtr.Add(interfaces, 5);
                interfaces = IntPtr.Add(interfaces, Marshal.ReadInt32(interfaces) + 4);
                interfaces = IntPtr.Add(interfaces, 6);

                interfaces = new IntPtr(Marshal.ReadInt32(interfaces) - vstdlibDll.ToInt32());

                IntPtr vstdlibInterface = ReadIntPtr(dota, IntPtr.Add(interfaces, vstdlib.BaseAddress.ToInt32()));

                IntPtr engineCVar = IntPtr.Zero;

                while (vstdlibInterface != IntPtr.Zero)
                {
                    string interfaceName = ReadString(dota, ReadIntPtr(dota, IntPtr.Add(vstdlibInterface, 0x04)));

                    if (interfaceName == "VEngineCvar007")
                    {
                        engineCVar = ReadIntPtr(dota, IntPtr.Add(ReadIntPtr(dota, vstdlibInterface), 1));
                        break;
                    }

                    vstdlibInterface = ReadIntPtr(dota, IntPtr.Add(vstdlibInterface, 0x08));
                }

                if (engineCVar == IntPtr.Zero)
                {
                    throw new Exception("Couldnt find VEngineCvar007");
                }

                IntPtr cvar = ReadIntPtr(dota, IntPtr.Add(engineCVar, 0x34));
                cvar = IntPtr.Add(cvar, 0xC3 * 4);
                cvar = ReadIntPtr(dota, cvar);

                while (cvar != IntPtr.Zero)
                {
                    if (ReadInt(dota, cvar) == 0x0000D2C3)
                    {
                        cvar = ReadIntPtr(dota, IntPtr.Add(cvar, 0x04));
                        break;
                    }

                    cvar = ReadIntPtr(dota, IntPtr.Add(cvar, 0x0C));
                }

                if (cvar == IntPtr.Zero)
                {
                    throw new Exception("Cvar not found!");
                }

                WriteInt(dota, IntPtr.Add(cvar, 0x14), 0x08);
                Console.WriteLine("dota_camera_distance cvar has been unlocked!");
                Console.ReadKey();