Jump to content

Photo

Help with changing Hex value


  • Please log in to reply
3 replies to this topic

#1 Shadowdragon Posted 16 July 2014 - 11:20 AM

Shadowdragon

    Soldier

  • Members
  • Pip
  • 3 posts

Hello all i do not know if this forum is still active but if it is can someone please help me. my code example is bellow

static void Plants_Vs_Zombies(int hex, int off)
        {
            try
            {
                var PlantsVsZombies = new MemorySharp(ApplicationFinder.FromProcessName("popcapgame1").First());
                if (PlantsVsZombies.IsRunning)
                {
                    var Hex_Main = PlantsVsZombies.Read<IntPtr>(new IntPtr(hex), false);
                    var offsets = new[] { off };
                    foreach (var offset in offsets)
                    {
                        Hex_Main = PlantsVsZombies[Hex_Main + offset, false].Read<IntPtr>(); // false is here to avoid rebasing

                        Console.WriteLine("Sun: "+Hex_Main);
                        Console.ReadLine();
                        Console.Clear();
                        
                        Plants_Vs_Zombies(0x0018FA04, 0x5578);
                    }

                }
                else
                {
                    Console.BackgroundColor = ConsoleColor.Red;
                    Console.WriteLine("Sorry but the Application popcapgame1 can not be found, please run Plants Vs. Zombies to start it!.");
                    Console.ReadLine();
                }
            }

This code works in giving me the value of sun in Plants Vs Zombies but i cant figure out how to edit the sun value using the Static Address and Offset i found using cheat engine what i want the program to do is each time it goes through the loop it adds 100 Sun to the game, i know the address works because it displays the sun in the console but i can not figure out how to edit it.


  • Back to top
  • Report

#2 ZenLulz Posted 16 July 2014 - 11:30 PM

ZenLulz

    Lead Developer

  • Administrators
  • 67 posts
  • LocationSwitzerland

Hello Shadowdragon and welcome on the board !

Hex_Main = PlantsVsZombies[Hex_Main + offset, false].Read<IntPtr>();

This line comes from your code sample. It basically creates a new instance of the class RemotePointer and reads a value as an IntPtr.

It exists other methods in the class RemotePointer, notably Write(...), enabling you to write any value in this location.

 

Here is an example of code that writes the numeric value 100 into your location.

 

PlantsVsZombies[Hex_Main + offset, false].Write(100);

 

Hope it helps.

 

Cheers,

ZenLulz


ZenLulz

  • Back to top
  • Report

#3 Shadowdragon Posted 17 July 2014 - 11:33 AM

Shadowdragon

    Soldier

  • Members
  • Pip
  • 3 posts

Sorry i am un sure what i have done wrong it gives me this error

 

"An unhandled exception of type 'System.ComponentModel.Win32Exception' occurred in MemorySharp.dll


Edited by Shadowdragon, 17 July 2014 - 11:42 AM.

  • Back to top
  • Report

#4 Shadowdragon Posted 17 July 2014 - 01:53 PM

Shadowdragon

    Soldier

  • Members
  • Pip
  • 3 posts

Wait No sorry i figured out my problem thanks for the example code man really helped!


  • Back to top
  • Report




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users