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 


[Help] Problem with C# code

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

Joined: 17 May 2018
Posts: 5

PostPosted: Mon Jun 11, 2018 8:26 am    Post subject: [Help] Problem with C# code Reply with quote

Hi guys,


I have a problem with my trainer, it works perfectly, but when i close the game before the trainer, my trainer crash.


Error VS :
Code:
Only part of a ReadProcessMemory or WriteProcessMemory request was completed


Visual Studio tells me that the error is from "foreach"

Code in my trainer:
Code:
       
protected ProcessModule FindModule(string name)
        {
            if (string.IsNullOrEmpty(name))
                throw new ArgumentNullException("name");
            foreach (ProcessModule module in process.Modules)
            {
                if (module.ModuleName.ToLower() == name.ToLower())
                    return module;
            }
            return null;
        }


I specify that the code when i write in the memory is in a timer.

I hope you can help me.
Back to top
View user's profile Send private message
FreeER
Grandmaster Cheater Supreme
Reputation: 53

Joined: 09 Aug 2013
Posts: 1091

PostPosted: Mon Jun 11, 2018 9:03 am    Post subject: Reply with quote

Try Catch or whatever C# uses to stop a thrown exception? presumably you'd only need it for the module.ModuleName portion... and when you did catch an exception you'd just continue the loop (in case it happened to be some other program).....
Back to top
View user's profile Send private message
v78z
How do I cheat?
Reputation: 0

Joined: 17 May 2018
Posts: 5

PostPosted: Mon Jun 11, 2018 12:57 pm    Post subject: Reply with quote

FreeER wrote:
Try Catch or whatever C# uses to stop a thrown exception? presumably you'd only need it for the module.ModuleName portion... and when you did catch an exception you'd just continue the loop (in case it happened to be some other program).....


Try and catch was the good solution, thx for helping me 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 Discussions 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