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 


C# Memory Library
Goto page Previous  1, 2, 3  Next
 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
DaHandy
Newbie cheater
Reputation: 0

Joined: 03 Nov 2007
Posts: 18

PostPosted: Fri Apr 15, 2011 3:26 pm    Post subject: Reply with quote

Looks nice but I can't add the dll file to references. I get this error:
Code:
The referenced component 'MemoryEditor' could not be found.


I'm using Visual Studio 2008 and the dll file is on my desktop. I have never tried to add references before. What am I doing wrong?
Back to top
View user's profile Send private message
KryziK
Expert Cheater
Reputation: 3

Joined: 16 Aug 2009
Posts: 199

PostPosted: Fri Apr 15, 2011 4:41 pm    Post subject: Reply with quote

Hmm, that's strange. Never had any problems like that before.

Could it have to do with this?
Back to top
View user's profile Send private message
Sneazy
How do I cheat?
Reputation: 0

Joined: 06 Dec 2011
Posts: 2
Location: Side bedroom

PostPosted: Tue Dec 06, 2011 4:01 pm    Post subject: Reply with quote

I found this very helpful, but I did run into a calculation error.

I think it was at line 636 under the CalculatePointer method. The code reads:
Code:
if (Convert.ToInt16(bBytes[i]) < 10)

When it should be:
Code:
if (Convert.ToInt16(bBytes[i]) < 16)

Otherwise memory addresses will be truncated.

Hope someone finds this useful.
Back to top
View user's profile Send private message
KryziK
Expert Cheater
Reputation: 3

Joined: 16 Aug 2009
Posts: 199

PostPosted: Tue Dec 06, 2011 6:02 pm    Post subject: Reply with quote

Sneazy wrote:
I found this very helpful, but I did run into a calculation error.

I think it was at line 636 under the CalculatePointer method. The code reads:
Code:
if (Convert.ToInt16(bBytes[i]) < 10)

When it should be:
Code:
if (Convert.ToInt16(bBytes[i]) < 16)

Otherwise memory addresses will be truncated.

Hope someone finds this useful.


Actually, it should be < 17, to include 16. Thanks for catching that, I had it fixed in my newer version, never fixed it in this one.
Back to top
View user's profile Send private message
Sneazy
How do I cheat?
Reputation: 0

Joined: 06 Dec 2011
Posts: 2
Location: Side bedroom

PostPosted: Wed Dec 07, 2011 12:35 pm    Post subject: Reply with quote

KryziK wrote:
Sneazy wrote:
I found this very helpful, but I did run into a calculation error.

I think it was at line 636 under the CalculatePointer method. The code reads:
Code:
if (Convert.ToInt16(bBytes[i]) < 10)

When it should be:
Code:
if (Convert.ToInt16(bBytes[i]) < 16)

Otherwise memory addresses will be truncated.

Hope someone finds this useful.


Actually, it should be < 17, to include 16. Thanks for catching that, I had it fixed in my newer version, never fixed it in this one.


Is that to account for 00? Where is your newer version, have you made any other changes?
Back to top
View user's profile Send private message
KryziK
Expert Cheater
Reputation: 3

Joined: 16 Aug 2009
Posts: 199

PostPosted: Wed Dec 07, 2011 6:06 pm    Post subject: Reply with quote

This system accounts for 0-F, padding it with a 0 so you always get an address of length 8.

The newer version is still being developed (on and off) and is not quite ready for release. It has been completely rewritten and contains code-breaking changes compared to the previous version. I will try to release it, but I've been thinking that for a year. I pick it up, lose interest, come back to it, etc, so there are no guarantees that it will be released.
Back to top
View user's profile Send private message
Inzann
Cheater
Reputation: 0

Joined: 03 Jan 2007
Posts: 34

PostPosted: Mon Jan 21, 2013 3:16 pm    Post subject: Reply with quote

Hello I've been trying to use this to learn from your code but I have some problems. Is there any way to contact you KryziK? I am not allowed to PM it seems and I wouldn't want to wreck this topic with all of my questions.
Back to top
View user's profile Send private message
Screitor
Cheater
Reputation: 1

Joined: 26 Nov 2012
Posts: 33
Location: Venezuela

PostPosted: Mon Jan 21, 2013 3:31 pm    Post subject: Reply with quote

Inzann wrote:
Hello I've been trying to use this to learn from your code but I have some problems. Is there any way to contact you KryziK? I am not allowed to PM it seems and I wouldn't want to wreck this topic with all of my questions.


Ask your questions in the forum.

_________________
Everybody lies.
Back to top
View user's profile Send private message Yahoo Messenger MSN Messenger
KryziK
Expert Cheater
Reputation: 3

Joined: 16 Aug 2009
Posts: 199

PostPosted: Mon Jan 21, 2013 5:27 pm    Post subject: Reply with quote

Feel free to ask questions specific to C#, but not specific to my code, on the forums! I also do have Skype if you need more personal help. Let me know.
Back to top
View user's profile Send private message
Screitor
Cheater
Reputation: 1

Joined: 26 Nov 2012
Posts: 33
Location: Venezuela

PostPosted: Tue Jan 22, 2013 12:44 am    Post subject: Reply with quote

KryziK wrote:
Feel free to ask questions specific to C#, but not specific to my code, on the forums! I also do have Skype if you need more personal help. Let me know.


Any doubt that he has will be resolved in the forum. I doubt very much that you're the only one able to resolve them.

_________________
Everybody lies.
Back to top
View user's profile Send private message Yahoo Messenger MSN Messenger
KryziK
Expert Cheater
Reputation: 3

Joined: 16 Aug 2009
Posts: 199

PostPosted: Tue Jan 22, 2013 1:06 am    Post subject: Reply with quote

Screitor wrote:
KryziK wrote:
Feel free to ask questions specific to C#, but not specific to my code, on the forums! I also do have Skype if you need more personal help. Let me know.


Any doubt that he has will be resolved in the forum. I doubt very much that you're the only one able to resolve them.


I doubt that I'm the only one able to resolve them as well. I was just offering him personal help if he had a more specific question about my code, or if he wanted more than would be offered as help on this forum. I really don't see why you thought you had to reply to what I said.
Back to top
View user's profile Send private message
Screitor
Cheater
Reputation: 1

Joined: 26 Nov 2012
Posts: 33
Location: Venezuela

PostPosted: Tue Jan 22, 2013 4:42 am    Post subject: Reply with quote

KryziK wrote:
Screitor wrote:
KryziK wrote:
Feel free to ask questions specific to C#, but not specific to my code, on the forums! I also do have Skype if you need more personal help. Let me know.


Any doubt that he has will be resolved in the forum. I doubt very much that you're the only one able to resolve them.


I doubt that I'm the only one able to resolve them as well. I was just offering him personal help if he had a more specific question about my code, or if he wanted more than would be offered as help on this forum. I really don't see why you thought you had to reply to what I said.


You've answered yourself.

I did it because for some reason there are forums: answer questions, etc ...

This conversation is becoming banal.

_________________
Everybody lies.
Back to top
View user's profile Send private message Yahoo Messenger MSN Messenger
Inzann
Cheater
Reputation: 0

Joined: 03 Jan 2007
Posts: 34

PostPosted: Wed Jan 23, 2013 6:40 am    Post subject: Reply with quote

Well as I am using your code I felt it would be better to ask you as I am using the functions you have made. First I would like to say that I just started learning C#. I am a bit lost as of how to read from the memory more then once after it has attached to the other process.

I have put my own code inside the same part where it opens the other process, but that just happens once after "binject" is pressed. So it reads all the pointers and prints them to my variables that one time, I can't figure out how to move just the MemoryRead part of the code to a timer. I'm pretty confused and probably over complicating things. ^^

If I moved the open process part as well to a timer then it would just open the process every time the timer ticks and that sounds very bad. (Is it bad to open a new handle? I'm just assuming it is)I tried putting it all into a timer and it seems to work but as said I'm not certain this is the way to do it since it will run OpenProcess over and over. I'd just like it to check for the updated values from the pointer when it ticks, not repeat the whole open thing. Does this make any sense at all?

Once again I apologize but I am doing my best to learn from this. I really do wish you can help me and please add me to skype since its a bit quicker then the forums. id: danneost

the code

I want to be able to write/read to memory elsewhere then inside this code.
Code:

        public void binject_Click(object sender, EventArgs e)
        {

            Memory oMemory = new Memory();
            if (oMemory.OpenProcess("testingapp"))
            {
                MessageBox.Show("Injected into testingapp");
                ushort manapointer = oMemory.ReadShort(0x60F6E0B8, new int[] { 0 });
                ushort healthpointer = oMemory.ReadShort(0x60F6E0B8, new int[] { 4 });
                Variables.HealthD = Convert.ToDecimal(healthpointer);
                Variables.ManaD = Convert.ToDecimal(manapointer);
            }
            else
            {
                MessageBox.Show("testingapp was not found!");
            }
        }




I would like to be able to do something like this

Code:

        private void timer1_Tick(object sender, EventArgs e)
        {
                ushort manapointer = oMemory.ReadShort(0x60F6E0B8, new int[] { 0 });
                ushort healthpointer = oMemory.ReadShort(0x60F6E0B8, new int[] { 4 });
                labelhp.Text = healthpointer.ToString();
                labelmp.Text = manapointer.ToString();

            }
Back to top
View user's profile Send private message
KryziK
Expert Cheater
Reputation: 3

Joined: 16 Aug 2009
Posts: 199

PostPosted: Wed Jan 23, 2013 12:14 pm    Post subject: This post has 1 review(s) Reply with quote

Don't be fooled by the function in my library called OpenProcess. If you look at the source code for the library, you can see that the OpenProcess function does not call the Kernel32 function, OpenProcess. Therefore, we are not opening a new handle. C# already has the process handles, and my function simply selects one.

So, it is safe to use OpenProcess in your timer or in other places. It may perhaps slow your program down a tiny bit, but if used correctly there should be no noticeable impact.

The other solution would be to create a Memory object outside of your functions. Then, in FormLoad, or wherever you want, you could simply open it once. In the timer, you would reference the same object to read/write memory.

Another thing you could do to help your execution speed and to save memory is to move your integer offset arrays outside of the loop as well. Simply create them once, giving them a variable name, and use them in your function. That way, you won't be creating it over and over.
Back to top
View user's profile Send private message
Inzann
Cheater
Reputation: 0

Joined: 03 Jan 2007
Posts: 34

PostPosted: Wed Jan 23, 2013 3:10 pm    Post subject: Reply with quote

KryziK wrote:
Don't be fooled by the function in my library called OpenProcess. If you look at the source code for the library, you can see that the OpenProcess function does not call the Kernel32 function, OpenProcess. Therefore, we are not opening a new handle. C# already has the process handles, and my function simply selects one.

So, it is safe to use OpenProcess in your timer or in other places. It may perhaps slow your program down a tiny bit, but if used correctly there should be no noticeable impact.

The other solution would be to create a Memory object outside of your functions. Then, in FormLoad, or wherever you want, you could simply open it once. In the timer, you would reference the same object to read/write memory.

Another thing you could do to help your execution speed and to save memory is to move your integer offset arrays outside of the loop as well. Simply create them once, giving them a variable name, and use them in your function. That way, you won't be creating it over and over.


Oh I see! I should have studied it a bit more. I don't understand your other solution. Do you mean something like?
Code:
    public class MemoryCode
    {
        public static void testmemory(object sender, EventArgs e)
        {
        Memory oMemory = new Memory();
        oMemory.OpenProcess("testingapp");
    }
    }

How could I move the offsets outside?

Edit: Problem solved thanks to Kryzik! Smile
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
Goto page Previous  1, 2, 3  Next
Page 2 of 3

 
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