QuestionC# Unlimited Ammo Hack (CSS)

Posts 111 of 11 · Page 1 of 1
C# Unlimited Ammo Hack (CSS)
Hello, I'm currently writing my own unlimited ammo hack for CSS and I've located the right memory address using cheat engine (it even works when I edit it in there) but my program keeps closing out on my and it's not really giving me ammo, so I hope any of you can help me on my quest to make my first hack work. Here's the code:

Code:
namespace CSSUnlimitedAmmo
{
    class Program
    {
        static void Main(string[] args)
        {
            CheckAmmo();
        }

        static void FillAmmo()
        {
            var cssProc = (from Process p in Process.GetProcesses() where p.MainWindowTitle.Contains("Counter-Strike Source") select p.Id).FirstOrDefault();
            BlackMagic css = new BlackMagic();
            css.OpenProcessAndThread(cssProc);
            IntPtr BaseCSS = css.MainModule.BaseAddress;
            css.WriteInt((uint)BaseCSS + 0xCA1654, 10);
            Console.WriteLine("Maxed out ammo!");
        }

        static void CheckAmmo()
        {
            var cssProc = (from Process p in Process.GetProcesses() where p.MainWindowTitle.Contains("Counter-Strike Source") select p.Id).FirstOrDefault();
            BlackMagic css = new BlackMagic();
            css.OpenProcessAndThread(cssProc);
            IntPtr BaseCSS = css.MainModule.BaseAddress;
            uint Ammo = css.ReadUInt((uint)BaseCSS + 0xCA1654);
            if (Ammo <= 10)
            {
                FillAmmo();
            }
            else
            {
                Console.WriteLine("We need no ammo, checking again!");
                CheckAmmo();
            }
        }
    }
}
css.OpenProcessAndThread(cssProc);

I think that's the problem. When/where do you .CloseProcessAndThread()? Nowhere?

I assume with this library you only have to "OpenProcessAndThread" once.
Quote Originally Posted by abuckau907 View Post
css.OpenProcessAndThread(cssProc);

I think that's the problem. When/where do you .CloseProcessAndThread()? Nowhere?

I assume with this library you only have to "OpenProcessAndThread" once.
This libary seems not to have the CloseProcessAndThread() :-(. Also it seems that it doesn't matter from other examples that I've seen, I know that it would optimize the program a great deal by doing Open once but sadly I don't know how to transfer those variables trough functions. :-(
The problem is that it's a dynamic hex-code and I can't seem to get it static or to use the same every time, I have no idea why. It works fine when I change the value to the correct one but whenever I restart the game the hex-code has changed. The thing I really need help with is what hex-value to input and how to get a static one.

I tried something like this for a wallhack:
but with no luck... anyone have any idea why?
Sorry, I'm trying to catch up. Have you coded before?

Please explain in a little more detail.

The picture, you're writing to hl2.mainmod + 17E1

that is the "hex" that keeps changing? "0x17E1"? So you mean "the location of the game code changes". ?

-IF the "game code" has a certain pattern to it (ie. always uses the same instructions, in the same order), then...
you can "search" for the game code instead of using hl2.mainmod.base+17**
I call this "FindPattern()" - I think it's called "aob" here at mpgh, and maybe "SearchPattern" or something. BM probably has it.

IntPtr _gameCodeLocation = css.FindPattern("0x01, 0x02, 0x00, 0x00 ** ** ** ** ** "); // not the actual pattern
css.WriteByte(_gameCodeLocation,2); // + small offset if pattern starts before/after the actual game instruction

But if you don't know the language very well, you're going to have a hard time with the basics: like how to define the patterns in your code.

Did, you mean to call .WriteUInt? It's replacing 4 bytes, not just 1. The 00's right after the blue line. .WriteByte()?
I'm sorry that I totally misdirected you there, I should explain.

The thing I do here is getting the address of drawothermodels by typing r_drawothermodels 1, then scan for one then r_drawothermodels 2000 and next scan, then look into the memory and read that the STATIC address for this is Hl2.exe+17E1. This is the value that I need to edit and it's 4 byes, so my guess would be to do
Code:
css.WriteByte((uint)BaseCSS + 0x17E1, 0020);
(also 0200 failed) but that wouldn't work so I tried something different which was
Code:
css.WriteByte((uint)BaseCSS + 0x17E1, 2);
no luck either. also tried with .WriteUInt 2.

The reason it was changing was because the procces ID was changing so it was a mistake on my end. I don't know what's causing all these problem. I updated the code a bit so here it is:

Code:
static void WallhackActivate()
        {
            BlackMagic css = new BlackMagic();
            Process[] Processes = Process.GetProcessesByName("hl2.exe");
            if (css.OpenProcessAndThread(SProcess.GetProcessFromProcessName("hl2.exe")))
            {
                Console.WriteLine("Wallhack Actiavted!");
                Console.ReadLine();
                IntPtr BaseCSS = css.MainModule.BaseAddress;
                css.WriteUInt((uint)BaseCSS + 0x17E1, 2);
            }
            else
            {
                Console.WriteLine("Can't find procces hl2.exe!");
                Console.ReadLine();
            }
        }
Changed to wallhack because I was kind of stuck on the unlimited ammo thing.

To answer your first question; yes, I have. This is my 2nd hack for a game. My first one was for the MMORPG "World of Warcraft". It was a simple bot which would collect items for you to sell and gain "gold".
If you add me on skype, I'll try to help: having a conversation in this forum is slow/hard.
If you want. Same username for skype as here.
Quote Originally Posted by abuckau907 View Post
If you add me on skype, I'll try to help: having a conversation in this forum is slow/hard.
If you want. Same username for skype as here.
I'll do it whenever I get to my Pc thanks. :-)
If the minion actually cared about this section this thread would've already been moved to the correct section.
You're added, mate.
DOws it Work now?

---------- Post added at 10:50 AM ---------- Previous post was at 10:45 AM ----------

Does it work?
Posts 111 of 11 · Page 1 of 1

Post a Reply

Similar Threads

Tags for this Thread

None

Need help?