Solved [C++ DLL Injection] Getting the starting point of my process

Hexui Undetected CSGO Cheats Sinkicheat PUBG Cheat

Shadoninja

Newbie
Dank Tier Donator
Apr 24, 2013
36
214
0
This is the code Fleep uses to access the starting point of Assault Cube.

C++:
MyProcess[0].MainModule.BaseAddress.ToInt32() + 0x000E4E08;
He needs this information because the enemy base pointer is referenced from the start of the program, instead of a simple static address.

I am working on a hack in C++ and I am curious if I should be going about this in a similar fashion. My current code is a derivative of Fleep's dll tutorial which means (I think) that my dll does not know where the start of the program is. Any hints?
 

Rake

I'm not your friend
Administrator
Jan 21, 2014
12,508
78,998
2,419
C#:
using System;
using System.Diagnostics;
using System.Runtime.InteropServices;

namespace RakeCSharp
{
    internal class RakeCSMem
    {
        [DllImport("kernel32.dll")]
        private static extern IntPtr OpenProcess(uint processAccess, bool bInheritHandle, int processId);

        [DllImport("kernel32.dll", SetLastError = true)]
        private static extern bool ReadProcessMemory(IntPtr hProcess, IntPtr lpBaseAddress, [Out] byte[] lpBuffer, int dwSize, out IntPtr lpNumberOfBytesRead);

        public static IntPtr FindDMAAddy(IntPtr hProc, IntPtr ptr, int[] offsets)
        {
            var buffer = new byte[IntPtr.Size];
            foreach (int i in offsets)
            {
                ReadProcessMemory(hProc, ptr, buffer, buffer.Length, out var read);

                ptr = (IntPtr.Size == 4)
                ? IntPtr.Add(new IntPtr(BitConverter.ToInt32(buffer, 0)), i)
                : ptr = IntPtr.Add(new IntPtr(BitConverter.ToInt64(buffer, 0)), i);
            }
            return ptr;
        }

        public static IntPtr GetModuleBaseAddress(Process proc, string modName)
        {
            IntPtr addr = IntPtr.Zero;

            foreach (ProcessModule m in proc.Modules)
            {
                if (m.ModuleName == modName)
                {
                        addr = m.BaseAddress;
                        break;
                }
            }
                return addr;
        }

        private static void Main(string[] args)
        {
            Process process;

            process = Process.GetProcessesByName("ac_client")[0];

            var hProc = OpenProcess(0x001F0FFF, false, process.Id);

            var modBase = GetModuleBaseAddress(process, "ac_client.exe");

            var addr = FindDMAAddy(hProc, (IntPtr)0x50f4f4, new int[] { 0x374, 0x14, 0 });

            Console.WriteLine("0x" + addr.ToString("X"));
        }
    }
}
 
Last edited:

till0sch

Respected Hacker
Dank Tier VIP
Dank Tier Donator
Oct 14, 2012
1,104
12,593
51
This is the code Fleep uses to access the starting point of Assault Cube.

C++:
MyProcess[0].MainModule.BaseAddress.ToInt32() + 0x000E4E08;
He needs this information because the enemy base pointer is referenced from the start of the program, instead of a simple static address.

I am working on a hack in C++ and I am curious if I should be going about this in a similar fashion. My current code is a derivative of Fleep's dll tutorial which means (I think) that my dll does not know where the start of the program is. Any hints?
Retrieving the base address is no necessary at all since AssaultCube's baseaddress is always 400000 (default). You only need to add 0xE4E08 to 0x400000 (=40E4E08)
 

Shadoninja

Newbie
Dank Tier Donator
Apr 24, 2013
36
214
0
Retrieving the base address is no necessary at all since AssaultCube's baseaddress is always 400000 (default). You only need to add 0xE4E08 to 0x400000 (=40E4E08)
I would much rather learn methods that I can apply to all games for future projects! But I did not make that connection so thank you.

C++:
DWORD base = (DWORD)GetModuleHandle("program.exe");
Looks solid. I will give it a try when I am at my computer.
 
Attention! Before you post:

Read the How to Ask Questions Guide
99% of questions are answered in the Beginner's Guide, do it before asking a question.

No Hack Requests. Post in the correct section.  Search the forum first. Read the rules.

How to make a good post:

  • Fill out the form correctly
  • Tell us the game name & coding language
  • Post everything we need to know to help you
  • Ask specific questions, be descriptive
  • Post errors, line numbers & screenshots
  • Post code snippets using code tags
  • If it's a large project, zip it up and attach it

If you do not comply, your post may be deleted.  We want to help, please make a good post and we will do our best to help you.

Community Mods