Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Search Value In And Get The Memory Addres :(

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
ETneedHelp
How do I cheat?
Reputation: 0

Joined: 17 May 2012
Posts: 9

PostPosted: Thu May 17, 2012 5:28 pm    Post subject: Search Value In And Get The Memory Addres :( Reply with quote

Hello,
my english is bad - but:

i make program in vb.net
the main subject is:
Search Value In Another Process And Get The Memory Addres of the value
the problem:
i look for this thing in all the internet, Evil or Very Mad Evil or Very Mad Mad
and i have no Solution
so, some one can give me example of code that Get The Memory Addres of the value
search value like CE >> return Memory Addres
I prefer that the example to be in VB.NET
if it c# or c or c++ it fine
but i need Explanation where to put my
"value to search for in the process"
and where to put my:
"process name"


If anyone here can do that,
I would be more grateful
Very important project Smile
Back to top
View user's profile Send private message
vnlagrla
Cheater
Reputation: 0

Joined: 10 Apr 2011
Posts: 33

PostPosted: Thu May 17, 2012 9:54 pm    Post subject: Reply with quote

Can you read memory? if so set up a loop and search the range you want to scan for the value like this. This is not vb it's c# if you know what your doing it should be easily convertable, might be slow though never really tried it. also if you can make lists in vb you might want to add the returned adress to a list in case there are many adresses that might get returned.

Code:

public int search(int baseadress, int length, int val)
{
    // baseadress = adress to start search
    // length = length to search
    // val = value your searching for

    for (int i = 0; i < length; i++)
        {
            if ((ReadInt(baseadress + (i)) == val)
            {
                return baseadress+i;
            }
        }
}

sorry but idk how to get process and handle in vb. Maybe wiccaan can help?
Back to top
View user's profile Send private message
NotReallySureWhatGoesHere
Expert Cheater
Reputation: -1

Joined: 20 Feb 2012
Posts: 110

PostPosted: Thu May 17, 2012 10:24 pm    Post subject: Reply with quote

vnlagrla wrote:
Can you read memory? if so set up a loop and search the range you want to scan for the value like this. This is not vb it's c# if you know what your doing it should be easily convertable, might be slow though never really tried it. also if you can make lists in vb you might want to add the returned adress to a list in case there are many adresses that might get returned.

Code:

public int search(int baseadress, int length, int val)
{
    // baseadress = adress to start search
    // length = length to search
    // val = value your searching for

    for (int i = 0; i < length; i++)
        {
            if ((ReadInt(baseadress + (i)) == val)
            {
                return baseadress+i;
            }
        }
}

sorry but idk how to get process and handle in vb. Maybe wiccaan can help?


I believe it's Process.Handle or Process.MainWindowHandle - not 100% sure though.

I don't program in C# (I like Java) so sorry if that's incorrect.
Back to top
View user's profile Send private message
ETneedHelp
How do I cheat?
Reputation: 0

Joined: 17 May 2012
Posts: 9

PostPosted: Fri May 18, 2012 4:50 am    Post subject: Reply with quote

vnlagrla wrote:
Can you read memory? if so set up a loop and search the range you want to scan for the value like this. This is not vb it's c# if you know what your doing it should be easily convertable, might be slow though never really tried it. also if you can make lists in vb you might want to add the returned adress to a list in case there are many adresses that might get returned.

Code:

public int search(int baseadress, int length, int val)
{
    // baseadress = adress to start search
    // length = length to search
    // val = value your searching for

    for (int i = 0; i < length; i++)
        {
            if ((ReadInt(baseadress + (i)) == val)
            {
                return baseadress+i;
            }
        }
}


sorry but idk how to get process and handle in vb. Maybe wiccaan can help?

First of all thanks everyone
The second thing that can help me very much(the code)
ReadInt is like readprocessmemory?
One last thing:
i need library for it?
lenght - what i need to put there?

If you have a full code that works I'll be glad if you post it Smile

EDIT:
Error 1 The name 'ReadInt' does not exist in the current context

Sad [/b]


Last edited by ETneedHelp on Fri May 18, 2012 5:26 am; edited 1 time in total
Back to top
View user's profile Send private message
Pingo
Grandmaster Cheater
Reputation: 8

Joined: 12 Jul 2007
Posts: 571

PostPosted: Fri May 18, 2012 5:05 am    Post subject: Reply with quote

No ReadInt is just a function he created to read 4 bytes, he probably just overlooked that when posting the code.
You'l need to create one, very simple to do.

Also if you know the address ends in 0,4,8,C you could change this line
Code:
for (int i = 0; i < length; i++)

to
Code:
for (int i = 0; i < length; i += 4)

That will increase the scan speed x4

Lots of examples on how to read memory on this forum. Just search for it.

_________________
Back to top
View user's profile Send private message
ETneedHelp
How do I cheat?
Reputation: 0

Joined: 17 May 2012
Posts: 9

PostPosted: Fri May 18, 2012 5:36 am    Post subject: Reply with quote

Pingo wrote:
No ReadInt is just a function he created to read 4 bytes, he probably just overlooked that when posting the code.
You'l need to create one, very simple to do.

Also if you know the address ends in 0,4,8,C you could change this line
Code:
for (int i = 0; i < length; i++)

to
Code:
for (int i = 0; i < length; i += 4)

That will increase the scan speed x4

Lots of examples on how to read memory on this forum. Just search for it.

bro
I tried everything and still did not work for me
you can make my code better? Smile

Code:

public int search(int baseadress, int length, int val)
{
    // baseadress = adress to start search
    // length = length to search
    // val = value your searching for

    for (int i = 0; i < length; i++)
        {
            if ((ReadInt(baseadress + (i)) == val))
            {
                return baseadress+i;
            }
        }
}


        private void button1_Click(object sender, EventArgs e)
        {

            System.Diagnostics.Process[] processes = System.Diagnostics.Process.GetProcessesByName("plugin-container");
            int baseaddr = processes[0].MainModule.BaseAddress.ToInt32();
            int res = search(baseaddr, 100, 15035990);
            listBox1.Items.Add(res);

        }

Mad
First time that I tired from searching Evil or Very Mad

Error 1 The name 'ReadInt' does not exist in the current context
Back to top
View user's profile Send private message
Pingo
Grandmaster Cheater
Reputation: 8

Joined: 12 Jul 2007
Posts: 571

PostPosted: Fri May 18, 2012 6:50 am    Post subject: Reply with quote

I told you you need to create a ReadInt function. Heres a simple example having everything in one go with a ReadInt built into it.
Code:
    public List<int> Search(string ProcessName, int _Length, int Value)
    {
        Process[] P = Process.GetProcessesByName(ProcessName);
        List<int> tmp = new List<int>();
        if (P.Length < 0) return tmp;

        byte[] buff = new byte[4];
        int Address = P[0].MainModule.BaseAddress.ToInt32();
        for (int i = 0; i < _Length; i++)
        {
            ReadProcessMemory(P[0].Handle, Address + i, buff, 4, 0);
            if (BitConverter.ToInt32(buff, 0) == Value)
            {
                tmp.Add(Address + i);
            }
        }
        return tmp;
    }

I never tested the code for errors but here is two ways to use it with your listbox.
List the addresses in decimel format
Code:
listBox1.DataSource = Search("plugin-container", 0x100, 15035990);

or in hex format
Code:
            foreach (int i in Search("plugin-container", 0x100, 15035990))
            {
                listBox1.Items.Add(i.ToString("X"));
            }

_________________
Back to top
View user's profile Send private message
ETneedHelp
How do I cheat?
Reputation: 0

Joined: 17 May 2012
Posts: 9

PostPosted: Fri May 18, 2012 6:55 am    Post subject: Reply with quote

Pingo wrote:
I told you you need to create a ReadInt function. Heres a simple example having everything in one go with a ReadInt built into it.
Code:
    public List<int> Search(string ProcessName, int _Length, int Value)
    {
        Process[] P = Process.GetProcessesByName(ProcessName);
        List<int> tmp = new List<int>();
        if (P.Length < 0) return tmp;

        byte[] buff = new byte[4];
        int Address = P[0].MainModule.BaseAddress.ToInt32();
        for (int i = 0; i < _Length; i++)
        {
            ReadProcessMemory(P[0].Handle, Address + i, buff, 4, 0);
            if (BitConverter.ToInt32(buff, 0) == Value)
            {
                tmp.Add(Address + i);
            }
        }
        return tmp;
    }

I never tested the code for errors but here is two ways to use it with your listbox.
List the addresses in decimel format
Code:
listBox1.DataSource = Search("plugin-container", 0x100, 15035990);

or in hex format
Code:
            foreach (int i in Search("plugin-container", 0x100, 15035990))
            {
                listBox1.Items.Add(i.ToString("X"));
            }

Thank you! Smile
Process[] P = Process.GetProcessesByName(ProcessName);
He did not recognize me that line
What libary to import?
edit:
i import the lib
and he not recornize:
Code:

ReadProcessMemory(P[0].Handle, Address + i, buff, 4, 0);
Back to top
View user's profile Send private message
Pingo
Grandmaster Cheater
Reputation: 8

Joined: 12 Jul 2007
Posts: 571

PostPosted: Fri May 18, 2012 4:01 pm    Post subject: Reply with quote

DUDE! System Diagnostics
You really need to do some reading.
http://msdn.microsoft.com/en-us/library/system.diagnostics.process.aspx

You're using system diagnostics in your own code. You should know this already.

_________________
Back to top
View user's profile Send private message
atom0s
Moderator
Reputation: 205

Joined: 25 Jan 2006
Posts: 8587
Location: 127.0.0.1

PostPosted: Tue May 22, 2012 5:20 am    Post subject: Reply with quote

Spamming ReadProcessMemory is extremely inefficient. You should be reading blocks of memory at a time and then scanning what you've read after. You'll have a lot better performance doing it that way.
_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
Pingo
Grandmaster Cheater
Reputation: 8

Joined: 12 Jul 2007
Posts: 571

PostPosted: Wed May 23, 2012 12:16 pm    Post subject: Reply with quote

Wiccaan wrote:
Spamming ReadProcessMemory is extremely inefficient. You should be reading blocks of memory at a time and then scanning what you've read after. You'll have a lot better performance doing it that way.

Thats how i do it, reading blocks. His original code scanned by byte so i just went with it.

_________________
Back to top
View user's profile Send private message
NotReallySureWhatGoesHere
Expert Cheater
Reputation: -1

Joined: 20 Feb 2012
Posts: 110

PostPosted: Wed May 23, 2012 11:08 pm    Post subject: Reply with quote

Wiccaan wrote:
Spamming ReadProcessMemory is extremely inefficient. You should be reading blocks of memory at a time and then scanning what you've read after. You'll have a lot better performance doing it that way.


Can you please give a simple sample of this. I'd like to learn the C# language more, but mainly I'd like to get in to this gaming stuff. Sorry for it though, so thank you.
Back to top
View user's profile Send private message
atom0s
Moderator
Reputation: 205

Joined: 25 Jan 2006
Posts: 8587
Location: 127.0.0.1

PostPosted: Mon May 28, 2012 7:52 am    Post subject: Reply with quote

It's Just Josh wrote:
Wiccaan wrote:
Spamming ReadProcessMemory is extremely inefficient. You should be reading blocks of memory at a time and then scanning what you've read after. You'll have a lot better performance doing it that way.


Can you please give a simple sample of this. I'd like to learn the C# language more, but mainly I'd like to get in to this gaming stuff. Sorry for it though, so thank you.


Use VirtualQueryEx to read the memory information and loop through the pages to know their start address and size, as well as protection(s). Then use ReadProcessMemory to read each page. (Check the return of RPM to see if it the read was too big and adjust as needed, etc.)

_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
NotReallySureWhatGoesHere
Expert Cheater
Reputation: -1

Joined: 20 Feb 2012
Posts: 110

PostPosted: Mon May 28, 2012 9:03 am    Post subject: Reply with quote

Wiccaan wrote:
It's Just Josh wrote:
Wiccaan wrote:
Spamming ReadProcessMemory is extremely inefficient. You should be reading blocks of memory at a time and then scanning what you've read after. You'll have a lot better performance doing it that way.


Can you please give a simple sample of this. I'd like to learn the C# language more, but mainly I'd like to get in to this gaming stuff. Sorry for it though, so thank you.


Use VirtualQueryEx to read the memory information and loop through the pages to know their start address and size, as well as protection(s). Then use ReadProcessMemory to read each page. (Check the return of RPM to see if it the read was too big and adjust as needed, etc.)


Lol guess I need to do some Google'ing :p Thanks for the tips!
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites