Forenote: This is how I learned, if anything can be simplified/if I did it wrong, leave a post explaining why and how I need to fix the issue. Thanks.
Table of ContentsAwhile ago, I looked into fooling with Java injection on oldschool. I didn't get too far, but I did manage to do some things.
- Introduction
- Setting up your class
- Preparing the loader
- Final Notes
Introduction
By the end of this tutorial, you should be able to load the gamepack, and display it as an applet. No actual injection is being done here, we're just setting on up.
I'll be using Intellij throughout this tutorial, so the pictures may be a little off.
You also need a basic understanding of Java to complete this tutorial.
Well, let's get too it.
Setting up your class
You'll want to make a new project by clicking File>New Project.
If you did that, it should look like this:
Just click okay on the next window.
You'll be presented a window like so(Large Image):
Expand your project so it looks like so:
Now, right click on the src, and make new package.
Name it something like com.bot
You're almost set now... but wait,you need ASM!
Lucky for you, I prepared a download of the all extensive ASM jar, found here.
After you put that in a safe place, click: CTRL+Shift+Alt+S
A box like this will appear:
Click the Modules tab on the left, and inside that, click Dependencies, so it looks like
You'll then want to click the green plus(+) sign at the right of that window, and select Jar or Directories.
Navigate to your ASM-All-4.1.jar you downloaded earlier, and select it.
You will now want to export it by selecting the little tick box.
Click apply, then okay.
We are now prepared to code!
Preparing your loader
For your benefit, all the code will be screen shotted, so you can not copy and paste. This will force you to write out all code within the tutorials.
Alright, here we go. Another note, I will explain what the code does after I post it. So don't worry if you don't understand it at first, just type it, and all will be clear.
This is your first code you need to write down.
It searches a pattern(Which we will get to later) for a field. It then runs it through a Matcher to check for matches, then assigns group 1 and 2 (Name of parameter, and value) to a map.
You can read about Maps here
Next, we add a new method. Copy this out
What this does is it opens a URL connection, and then adds request properties, stuff that a browser would have. It opens a DataInputStream, and returns the HTML of the webpage.
Near the top of the code, under the imports, change public class main{ to:
Then add this code to the bottom:
This code sets up our class to start the game applet, by setting up the appletstub, all it does.
Your next code is:
This code downloads the info from the website, and downloads the gamepack to your PC, allowing for further editing.
This next part is the nitty gritty.
Alright, here we go.
What this does, it makes a new JFrame, (Replace "NKN's Oldschool Loader" with w/e you want.")
It then adds a new label, which has a picture so the user has something "nice" to look at when it's loading.
String str gets the HTML source of the runescape page we're going to be loading from. This is how we will parse everything.
The next line starts a pattern, looking for the location of the gamepack. The code states, if a match is found, do this
We initialize a new AppletStub with Main stub = new Main(); (Remember, Main implements AppletStub?)
This sets up the stub. Don't worry about the pattern, it's in Regex if you REALLY want to know.
We then download the gamepack, and save it.
We set the stubs' codebase and document base to the jar file location, and load the java parameters (Like max and min memory, ect.)
We then load the classes, and cast an Applet to it, loading the client class inside the gamepack.jar file.
We set the stub, and the size, start the applet, and add it to the JFrame, before making the label invisible and making the applet show!
Viola, loading the game should be done... it's not working when you click play? Did you forget to add it to execute?!
Run back to the top, and try this code on for size:
Click run, you should end up with something like:
for the loader, and
for the game!
Final Thoughts
I know this isn't the best detailed tutorial, but I tried my best. Some things can be made simpler, if you have any ideas, leave a post. Try not to flame me with them though, as this is how I learned it. Well, if you made it this far, congrats! You made a loader!