Click to See Complete Forum and Search --> : A noob queston


Replingham
December 15th, 2009, 06:49 AM
I'm new to C# so I expect to be pilloried. I have a question which may seem stupid to some, but here it is anyway. At college we're working on a project and what we're trying to do is to overwrite a method in a Pc game somehow by loading a dll with the new method to overwrite it. Is there anyway to do that in C#. We're using Microsoft Visual C# and net framework. What we want to do ideally is to have our script load up when the original game loads and then to have the method in our script replace the one in the game.

thanks.

nelo
December 15th, 2009, 07:59 AM
If you are looking to change what happens when a specific method in the game is called the simple answer is no. However if you know that that method does what it does by calling some other library or assembly then you can replace that library or assembly with yours in principle. In practice this is generally not a good thing to do unless the system was designed to allow that. If the game wasn't designed to enable you to do that you would potentially be tampering with the functionality of the game. There may be some legal implications of doing that. The developers of the game might have put in some code access security themselves so that it can only call methods in libraries that it trusts.

Why do you want to do this thing in particular? Perhaps you can think of a different project.

Replingham
December 15th, 2009, 09:01 AM
No we're not intending to anything with our modification (it's just as a project to improve our coding abilites at college) so that's not an issue. What we're trying to do is make the program use our method in our dll instead of its own one.

mariocatch
December 15th, 2009, 09:41 AM
You can't inject your logic into a binary without modifying the binary itself. There's no way to do this with what you're trying to do.

nelo
December 15th, 2009, 09:57 AM
If I were you I would go back to my tutor/teacher at the college. He'll several other ideas about what you could do. I know you don't intend to do anything with the modification but you will find that it violates the agreement between you and the vendors of the game. I'm pretty sure they would not want you to modify their game in that way. What you should be looking to do is find ways of extending the functionality of the game without changing the game's dlls and executables. Like I said earlier not every application has been designed to enable this to be done by the end users. Applications such as Microsoft Outlook or Excel allow you to extend them by developing your own add-ins. Same goes for Firefox and I'm sure there are many others. But basically they've created a way for you to plug in your component and have them call it. It generally has to be by design otherwise you are changing the application in a way that the authors did not intend.

Arjay
December 15th, 2009, 10:53 AM
Are we to add hacking to the list of things kids learn in college nowadays?

nelo
December 15th, 2009, 11:18 AM
Are we to add hacking to the list of things kids learn in college nowadays?
:)

I tried very hard not to use the work 'hacking' in my previous posts on the subject...but I guess we should call a spade a spade.