Jump to content

Search the Community

Showing results for tags 'library'.



More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • RuneLocus
    • News & Announcements
    • Information Booth
    • Website Support
    • Introductions
    • Chat
    • Forum Games
  • RuneScape Development
    • RSPS General
    • RuneScape Private Server (RS2)
    • RuneScape Private Server (503+)
    • RuneScape Private Server (EoC 742+)
  • Other
    • Digital Art
    • Gaming
    • Webdevelopment
    • Computers
  • Marketplace
    • RuneScape Market
    • RSPS Market
    • Others Market
    • Freelance Middleman Services
  • Super Secret Club's Topics

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Found 9 results

  1. Hi, I am currently developing a GUI version of my cache library on my own, see [URL="http://www.runelocus.com/forums/showthread.php?105217-Displee-s-Cache-Library"]Displee's Cache Library[/URL] for more Information. [SIZE=4][B]Features[/B][/SIZE] [list] [*]Coming soon... [/list] [spoiler=Old Media] [IMG]http://i.imgur.com/VsAMef3.png[/IMG] [IMG]http://i.imgur.com/sucAZXq.png[/IMG] [IMG]http://i.imgur.com/7soLCus.png[/IMG] [IMG]http://i.imgur.com/7hDif40.png[/IMG] [IMG]http://i.imgur.com/80oUwn2.png[/IMG] [IMG]http://i.imgur.com/VID0hM5.png[/IMG] [IMG]http://i.imgur.com/9uXXfJO.png[/IMG] [IMG]http://i.imgur.com/Zh6Y8sX.png[/IMG] [IMG]http://i.imgur.com/cEE8zIl.png[/IMG] [IMG]http://i.imgur.com/c12iNeK.png[/IMG] [IMG]http://i.imgur.com/sal7ujx.png[/IMG] [IMG]http://i.imgur.com/dPYpK4x.png[/IMG] [IMG]http://i.imgur.com/92NQODa.png[/IMG] [IMG]http://i.imgur.com/UXp1Lgy.png[/IMG] [IMG]http://i.imgur.com/6OdH1C3.png[/IMG] [/spoiler] [spoiler=New Media] [IMG]http://i.imgur.com/OUJXTyl.png[/IMG] [IMG]http://i.imgur.com/AzDg1zR.png[/IMG] [IMG]http://i.imgur.com/k1JngdN.png[/IMG] [IMG]http://i.imgur.com/ozdUYMY.png[/IMG] [IMG]http://i.imgur.com/83Coc7G.png[/IMG] [IMG]http://i.imgur.com/gOL2dAa.png[/IMG] [IMG]http://i.imgur.com/VVRXoth.png[/IMG] [IMG]http://i.imgur.com/qV3QmaJ.png[/IMG] [IMG]http://i.imgur.com/TdMm0v7.png[/IMG] [IMG]http://i.imgur.com/YkUUHGR.png[/IMG] [IMG]http://i.imgur.com/KqOom9p.png[/IMG] [/spoiler] [SIZE=4][B]Information[/B][/SIZE] There is some information you need to know before you can use and this application. [SIZE=3][B]Cross cache copying[/B][/SIZE] Yes, it is possible to copy indices and archives from one cache to another. You are just not able to copy multiple instances, like copying 2 archives or 2 indices at once. It is also not possible to copy a whole cache. [SIZE=3][B]Add a cache[/B][/SIZE] If you want to link a cache to this application, you must enter an alias (e.g "My 742 cache") to identify the cache. You also need to enter a revision, so the application knows what kind of cache it is using. [SIZE=3][B]Managing archives[/B][/SIZE] You ca always copy archives from an index to another, the only thing you can't do is copying an archive to the same place. You should use the clone button instead. After all, you can specify which files you want to copy from the archive. [SIZE=3][B]Overwrite and replace[/B][/SIZE] When you try to copy an index, archive or file, you have the option to overwrite the selected path, or to replace it. Below is explained what the difference between these functions are. In this example we will try to copy archive 538 from index 7 to index 8. The archive we have copied, archive 538, is containing 3 files: 0, 1 and 2. Index 8 is already containing an archive with the id 538, so we will overwrite/replace this archive. This archive is containing 6 files: 0, 1, 2, 3, 4 ,5. If we use the [B]overwrite[/B] option, it will add the files from the copied archive, to it's destination. The first 3 files in archive 538 from index 8, will be overwritten with the one's of the copied archive,files 3, 4 and 5 will still remain in the archive. If we use the [B]replace[/B] option, it will replace the whole archive with the copied one. This means that the files (3, 4 and 5) will [U][B]NOT[/B][/U] remain in archive 538 from index 8. If we want to copy an index, archive or file that already exists in the destination, you will be asked to overwrite/replace it, or you can assign it a new id. This id will be automatic generated. In this dialog you will also see what the id will be. Credits: Me
  2. [SIZE=4]Displee's Cache Library[/SIZE] I made this some months ago, and I am still working on it. It's a RuneScape2 cache library which supports the revisions between 561 and 743. See the github page for more information. [url]https://github.com/Displee/RS2-Cache-Library[/url] Note: I still need to update that github page because the information about the library is not complete yet. Note: If you come across any problems, please report them in the issue's section ([URL="https://github.com/Displee/RS2-Cache-Library/issues"]here[/URL]); Credits: Me Apache Ah64 (for XTEA (de/en)cryption.
  3. [CENTER][SIZE=5][B][color=#4094B3]RuneBeam[/color][/B] [/SIZE][/CENTER] [B][color=#4094B3]What is RuneBeam?[/color][/B] RuneBeam at it's core is much more than just the next generation of private server toplists. Using a unique algorithm, we assign each server a grade on a daily basis based on how users have rated the server in various aspects, taking into consideration the importance of each aspect. Then, we present the servers to you - the player - in a way which you can filter to find the perfect server - Filter by type, revision, even name. RuneBeam's not only a toplist though - in fact, the toplist is only a small part of it. [B][color=#4094B3]RuneBeam for Players[/color][/B] RuneBeam delivers the one thing that no single server owner could deliver: Unity. With RuneBeam, you'll be able to keep in touch with all of your private server friends either from the servers client[sup]#1[/sup], from the launcher, or from the RuneBeam app! This means that you never have to stay playing a server simply because you have friends on it, and also means that you don't have to consider where your friends are when deciding to play! We don't only unify communication, but we also provide a system so that rather than having a store balance on all of your servers (leading to wastage), you can have a single balance which can be spent across any combination of servers you choose. You also get to choose the amount you wish to upload to your account, so you're not forced to upload more than you need! On a more sinister note, one problem which affects most players is server security. Some servers use standard hashing algorithms which take only days to crack to protect your password, most don't. This means that if the server gets hacked, your password is vulnerable, and over 60% of people use a single password for all services. With RuneBeam, you can be confident that we're using our own algorithm to hash and secure your password in a way which cracking would be intractable. With this in mind, players who opt to use RuneBeam will be able to log into supporting servers without entering a username or password in the client. Our launcher silently generates a one-use token, and passes it to the client so that your login is secure and your account is even safe from malware. [B][color=#4094B3]RuneBeam for Owners[/color][/B] A problem faced by small server owners is that they can't afford to pay good web developers to provide them with reliable services such a store, voting rewards, account management panels, server statistics and more. Even then, there's no guarantee that the outcome will be safe and reliable. RuneBeam solves this problem. Out of the box, RuneBeam will provide server owners with a store which can be implemented in as little as 10 lines of code on the server, and automatically provides more features than most servers stores provide. Products can be configured to accept a monetary payment, a voting reward payment or both. Instantly upon purchase, the server is informed directly, and can then add the item to the players bank, inventory or whatever you want it to do. Not only is the solution easy to implement, but we will also provide you with a copy-paste solution for the most popular server bases - Project Insanity and RuneSource. All monetary purchases will credit your account with the value of the purchase (minus a 5% fee), which can be withdrawn at your convenience with your preferred payment method. We'll handle all disputes and billing issues, so there's nothing to worry about. As RuneBeam also allows players to manage accounts through us[sup]#1[/sup], we provide those players with integrated tools to perform account-related tasks. We also provide a staff management interface, allowing you (and optionally your staff) to manage players accounts, with access restriction. What's more is that your server will be assessed and listed on it's merits, not on how big your wallet is. Players will rate your server on numerous aspects, and then your servers ranking is determined based on the importance of each aspect. [B][color=#4094B3]RuneBeam Feature Summary[/color][/B] [LIST] [*]Management - Easy to use interface to manage your accounts across all servers.[sup]#1[/sup] and manage aspects of your server with our easy-to-use interface. [*]Security - Stop anybody from accessing all of your private server accounts using the widely available Google Authenticator. Nobody can access your account without physically stealing your mobile! Also you can be sure that your details are stored securely. [*]Unity - A single login to access all of your accounts.[sup]#1[/sup] Also, keep in touch with all your private server friends from anywhere[sup]#1[/sup] without revealing personal information. [*]Simplicity - Step-by-step instructions to implement features only previously available to the big servers! [*]Convenience - Feel like just setting back and pking? We've got a checkbox for that! Find the perfect server for you with our advanced filter options on our toplist, only available on RuneBeam[sup]#2[/sup]. Filter by name, type and revision. [*]Widely Accessible - Don't like logging in? No problem! We support Facebook, Twitter, Google+ and Windows Live sign-in services, which means that you can login with just a few clicks. [*]Two-way - Don't like us? Not a problem! Simply contact support and we will transfer all RuneBeam profiles to the server seamlessly, allowing players to login with their specified profile password. We'd even offer a refund if we weren't free! [/LIST] [B][color=#4094B3]What is RuneBeam?[/color][/B] [B][color=#4094B3]Follow Us[/color][/B] [url=https://twitter.com/runebeam]Twitter[/url] [url=https://www.facebook.com/runebeam]Facebook[/url] [url=https://plus.google.com/105770170104085711693]Google+[/url] [url=http://www.runebeam.com/]Our Website[/url] [sup]#1[/sup] - Feature subject to availability. Nearly all features of RuneBeam are completely optional, and if the server hasn't implemented it then it won't be available for that server. [sup]#2[/sup] - Accurate as of time of writing. [B][color=#4094B3]Confirmed Servers[/color][/B] [LIST] [*]OS PvP [*]Armadyl [*]PerfectionX [*]Vitality [*]Runique [*]GrinderScape [*]HydraScape [/LIST]
  4. [IMG]http://i49.tinypic.com/2ji2q1.jpg[/IMG] Hey Runelocus, I keep getting this error, I even reuploaded the first cache without added models and sprites and it still gave me the error :/
  5. any good 3D graphics library out there that uses objects? I tried using LWJGL but all the classes are static
  6. [CENTER][SIZE="5"]ASM Bytecode Library[/SIZE][/CENTER] This is a light guide to ASM aimed at beginner's. I haven't actually seen any guides to any bytecode library on here before, so I figured I'd add one. A quick preface, if you plan to use this guide you should have a fairly decent grasp on Java, you should also be able to adapt quite well, as ASM uses a fairly different style of code than you're probably used to seeing! I didn't use the visitor pattern for this tutorial because I didn't really want to throw anyone in at the deep end. To start off with I will clear up any confusion that you have with the thread title, the ASM I am talking about is the bytecode library, it's official website is [url=http://asm.ow2.org]ASM - Home Page[/url] Ok well I'd like to start off by giving some links which will make your life a whole lot easier! [URL="http://java.sun.com/docs/books/jvms/second_edition/html/VMSpecTOC.doc.html"]VM Spec[/URL] - Particularly sections 4 & 6. [URL="http://en.wikipedia.org/wiki/Visitor_pattern"]Visitor Pattern[/URL] - This will give you an insight into the visitor pattern which is used in ASM. Even though I didn't use it in this tutorial, if I do expand it, I will be using the visitor pattern in ASM, so it'd be good to have knowledge of that. [SIZE="4"]What can it be used for? (Relating to RuneScape)[/SIZE] - RuneScape bots. - Private Server bots. - Cheat clients. - Obfuscators. - Deobfuscators. - Much more. [SIZE="4"]What do I need?[/SIZE] - An IDE, I recommend [url=http://jetbrains.com/idea/]IntelliJ IDEA :: Best Java IDE to do more high-quality code in less time[/url] IntelliJ IDEA also has a user-developed ASM plugin [URL="http://plugins.intellij.net/plugin/?idea&id=5918"]ASM Plugin[/URL] However Eclipse, also has a plugin I believe. - A stable version of ASM found here [URL="http://forge.ow2.org/projects/asm/"]OW2 Forge[/URL] - The ability to adapt easily, like I mentioned in the preface this is a necessity. - Patience, if you don't get the hang of it straight away don't fret. Just keep trying. - An external bytecode viewer/editor I recommend [URL="http://www.cs.ioc.ee/~ando/jbe/"]JBE[/URL] [SIZE="5"]Let's get started[/SIZE] Well, to start with we will do some basic string searching, let's see if we can locate the string "Hello, World!". [code] public class HelloWorld { public static void main(String[] args) { System.out.println("Hello, World!"); } } [/code] That is the code we will be searching through, now at a bytecode level that main method looks like this: [code] 0 getstatic #2 <java/lang/System/out Ljava/io/PrintStream;> 3 ldc #3 <Hello, World!> 5 invokevirtual #4 <java/io/PrintStream/println(Ljava/lang/String;)V> 8 return [/code] Looks scary right? Don't worry it isn't! Now, you can see in the bytecode Hello, World! is an LDC instruction (see [URL="http://java.sun.com/docs/books/jvms/second_edition/html/Instructions2.doc8.html#ldc"]JVM Instruction LDC[/URL]) So we need to make a class to search that code and find the Hello, World text! firstly we need to start by creating an instance of the [URL="http://asm.ow2.org/asm33/javadoc/user/org/objectweb/asm/ClassReader.html"]ClassReader[/URL] class. Which takes an InputStream as a parameter, so we could easily just do: [code]ClassReader reader = new ClassReader(new FileInputStream("HelloWorld.class"));[/code] Next up we need a [URL="http://asm.ow2.org/asm33/javadoc/user/org/objectweb/asm/tree/ClassNode.html"]ClassNode[/URL] which basically just represents a class, which can be added to our code easily, BUT our ClassNode will have no effect until it is accepted by the ClassReader. So our code will look like this: [code]ClassReader reader = new ClassReader(new FileInputStream("HelloWorld.class")); ClassNode node = new ClassNode(); reader.accept(node,0); //This second parameter is for flags, not important yet. [/code] The ClassReader accepts the ClassNode to become our HelloWorld class, so we can then read everything we need to, to get our Hello, World! string! Next up we need to locate our main method, we could loop through all of the methods in the class to find it like so: [code] for(int i = 0; i < node.methods.size(); i++) { [URL="http://asm.ow2.org/asm33/javadoc/user/org/objectweb/asm/tree/MethodNode.html"]MethodNode[/URL] mn = (MethodNode) node.methods.get(i); if(mn.name.equals("main")) { System.out.println("Found our main method!"); } } [/code] So there! We found our main method, now we've got to find that LDC instruction, which again is fairly easy to find, now that we have our method, we could loop through all of the instructions in that method, like so: [code] for (AbstractInsnNode ain : mn.instructions.toArray()) { if (ain instanceof LdcInsnNode) { [URL="http://asm.ow2.org/asm33/javadoc/user/org/objectweb/asm/tree/LdcInsnNode.html"]LdcInsnNode[/URL] ldc = (LdcInsnNode) ain; if (ldc.cst.equals("Hello, World!")) { System.out.println("We found our string!"); } } } [/code] Basically the above code, loops through all of the instructions inside that method, it then checks to see if the instruction is an LDC instruction, if it is, we make sure it says Hello, World! and then we've found our string! Of course, since there is only 1 LDC instruction in that method, we don't need to check it's value. We could of course change the value of that string, and thanks to beauty of ASM, we don't need to manually tinker in the constant pool (refer to VM Spec link. As I believe you have to do in BCEL) as it will all be done for us! Even when inserting new instructions it is all done for us. Let's change our string to something else shall we? We could change it to a completely different instruction, for example let's put an integer in there as opposed to a string! [code] if (ldc.cst.equals("Hello, World!")) { mn.instructions.set(ldc, new [URL="http://asm.ow2.org/asm33/javadoc/user/org/objectweb/asm/tree/IntInsnNode.html"]IntInsnNode[/URL](Opcodes.SIPUSH, 50)); } [/code] SIPUSH pushes a short on to the stack it can be read about here [URL="http://java.sun.com/docs/books/jvms/second_edition/html/Instructions2.doc13.html#sipush"]JVM Instruction SIPUSH[/URL] Which in turn would then create this: [code] public static void main(String args[]) { System.out.println(50); } [/code] if however we just want to change the value of our LDC instruction (our string) we just do [code] if (ldc.cst.equals("Hello, World!")) { mn.instructions.set(ldc, new LdcInsnNode("World, Hello!")); } [/code] Which in turn would create this: [code] public static void main(String args[]) { System.out.println("World, Hello!"); } [/code] Basically that code changes the LDC instruction we just found, into a new one with a different value! However unless we write the modified class file, it won't have any effect. Thankfully ASM provides the [URL="http://asm.ow2.org/asm33/javadoc/user/org/objectweb/asm/ClassWriter.html"]ClassWriter[/URL] class. We can just re-write our code like so: [code] ClassWriter writer = new ClassWriter(ClassWriter.COMPUTE_MAXS); node.accept(writer); FileOutputStream fos = new FileOutputStream("HelloWorld.class"); fos.write(writer.toByteArray()); fos.close(); [/code] ClassWriter.COMPUTE_MAXS automatically calculates the stack size. Then if we open up our HelloWorld class in our bytecode viewer/editor (refer to JBE link) we will see that the LDC instruction value has been updated! [code] 0 getstatic #19 <java/lang/System/out Ljava/io/PrintStream;> 3 ldc #21 <World, Hello!> 5 invokevirtual #27 <java/io/PrintStream/println(Ljava/lang/String;)V> 8 return [/code] Or if we changed the string to an integer our bytecode would look like this: [code] 0 getstatic #19 <java/lang/System/out Ljava/io/PrintStream;> 3 sipush 50 6 invokevirtual #25 <java/io/PrintStream/println(Ljava/lang/String;)V> 9 return [/code] Woo, we just edited our first instruction! If we throw everything we just did together our code will look something like this: [code] import org.objectweb.asm.ClassReader; import org.objectweb.asm.ClassWriter; import org.objectweb.asm.tree.AbstractInsnNode; import org.objectweb.asm.tree.ClassNode; import org.objectweb.asm.tree.LdcInsnNode; import org.objectweb.asm.tree.MethodNode; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; public class UpdateHelloWorld { public static void main(String[] args) { try { ClassReader reader = new ClassReader(new FileInputStream("HelloWorld.class")); ClassNode node = new ClassNode(); reader.accept(node, 0); for (int i = 0; i < node.methods.size(); i++) { MethodNode mn = (MethodNode) node.methods.get(i); if (mn.name.equals("main")) { for (AbstractInsnNode ain : mn.instructions.toArray()) { if (ain instanceof LdcInsnNode) { LdcInsnNode ldc = (LdcInsnNode) ain; if (ldc.cst.equals("Hello, World!")) { mn.instructions.set(ldc, new LdcInsnNode("World, Hello!")); } } } } } ClassWriter writer = new ClassWriter(ClassWriter.COMPUTE_MAXS); node.accept(writer); FileOutputStream fos = new FileOutputStream("HelloWorld.class"); fos.write(writer.toByteArray()); fos.close(); } catch (IOException e) { e.printStackTrace(); } } } [/code] [SIZE="5"]Fields (UNFINISHED)[/SIZE] Okay for the guide to fields I will be using different sets of code. Here is the class we will be editing: [code] public class HelloWorldField { public static void main(String[] args) { int field = 5000; } } [/code] At a bytecode level that method looks like this: [code] 0 sipush 5000 3 istore_1 4 return [/code] We will start by setting the value of "field" to something else. [code] ClassReader reader = new ClassReader("HelloWorldField.class"); ClassNode node = new ClassNode(); reader.accept(node,0); [/code] then we need to loop through the methods to find the main method. [code] for(int i = 0; i < node.methods.size(); i++) { MethodNode mn = (MethodNode) node.methods.get(i); if(mn.name.equals("main")) { //Found } } [/code] then finally this code to find and replacethe SIPUSH instruction that sets the field value: [code] if(mn.name.equals("main")) { for(AbstractInsnNode ain : mn.instructions.toArray()) { if(ain instanceof IntInsnNode) { IntInsnNode iin = (IntInsnNode) ain; mn.instructions.set(iin, new IntInsnNode(Opcodes.SIPUSH, 200)); } } } [/code] Which will then give us this code [code] public static void main(String args[]) { int field = 200; } [/code] I will expand on this fields section later. [SIZE="5"]Method Creation[/SIZE] For this section you should use a plain class with just a main method added (no body). I used the same class I used from the fields section which is why some things are left over (you'll see when you read down) To begin with let's create a simple static method which will print hello world when it is called. Our method will be called printMe. You will need to start by setting up your ClassReader and your ClassNode, I won't add that code again as you guys should have got the hang of it by now. Now we create the method like so: [code] MethodNode mn = new MethodNode(Opcodes.ACC_PRIVATE + Opcodes.ACC_STATIC, "printMe", "()V", null, null); [/code] Basically ACC_PRIVATE + ACC_STATIC will make it a private static method, printMe is the name of the method "()V" is the standard descriptor for a void method with no arguments, then null for signature and null for exceptions, those aren't important right now. Now we have to add the System.out.println function to our new method to print what we would like! I'll do it line by line. [code] mn.instructions.add(new FieldInsnNode(Opcodes.GETSTATIC, "java/lang/System", "out", "Ljava/io/PrintStream;")); [/code] This gets the static field "out" from java/lang/System the type of the field is java/io/PrintStream. Next we have to send our LDC instruction before we call the method so it becomes the parameter of the method we're about to call. [code] mn.instructions.add(new LdcInsnNode("Hello People")); [/code] In bytecode the parameter is sent before the method, so that it gets read as a parameter of the method. [code] mn.instructions.add(new MethodInsnNode(Opcodes.INVOKEVIRTUAL, "java/io/PrintStream", "println", "(Ljava/lang/String;)V")); [/code] The above calles the println method from java/io/PrintStream with the "out" variable we just got, the "(Ljava/lang/String; )V" (added a space to prevent the wink smiley) part is the parameter of the println method. For information on INVOKEVIRTUAL see here [URL="http://java.sun.com/docs/books/jvms/second_edition/html/Instructions2.doc6.html#invokevirtual"]JVM Instruction INVOKEVIRTUAL[/URL] to put it blankly INVOKEVIRTUAL will call the method. Ok let's move on to calling our newly created method from the main method so it actually functions! So let's create a loop through all of our methods to find the main one, then we insert an INVOKESTATIC (for more info read [URL="http://java.sun.com/docs/books/jvms/second_edition/html/Instructions2.doc6.html#invokestatic"]INVOKESTATIC[/URL] basically it calls a static method) instruction to call our method, all together it looks like this: [code] for(int i = 0; i < node.methods.size(); i++) { MethodNode methodnode = (MethodNode) node.methods.get(i); if(methodnode.name.equals("main")) { methodnode.instructions.insert(new MethodInsnNode(Opcodes.INVOKESTATIC, node.name, "printMe", "()V")); } } [/code] our new bytecode looks like this (main method) [code] 0 invokestatic #16 <HelloWorldField/printMe()V> 3 sipush 5000 //from the Fields section 6 istore_1 //from the Fields section 7 return [/code] our bytecode for the printMe method [code] *0 getstatic #27 <java/lang/System/out Ljava/io/PrintStream;> *3 ldc #29 <Hello People> *5 invokevirtual #35 <java/io/PrintStream/println(Ljava/lang/String;)V> *8 sipush 500 11 ireturn [/code] our new java code looks like this [code] public static void main(String args[]) { printMe(); int field = 5000; // left over from fields section } private static void printMe() { System.out.println("Hello People"); } [/code] So now we've looked at methods with no return type, let's say we look into methods that do have a return type! This is a fairly easy thing to do if you were able to create a void method successfully. [code] MethodNode mn = new MethodNode(Opcodes.ACC_PRIVATE + Opcodes.ACC_STATIC, "printMe",[B][COLOR="Red"] "()I"[/COLOR][/B], null, null); mn.instructions.add(new FieldInsnNode(Opcodes.GETSTATIC, "java/lang/System", "out", "Ljava/io/PrintStream;")); mn.instructions.add(new LdcInsnNode("Hello People")); mn.instructions.add(new MethodInsnNode(Opcodes.INVOKEVIRTUAL, "java/io/PrintStream", "println", "(Ljava/lang/String;)V")); [COLOR="red"][B]mn.instructions.add(new IntInsnNode(Opcodes.SIPUSH, 500)); mn.instructions.add(new InsnNode(Opcodes.IRETURN));[/B][/COLOR] [/code] Above is the construction of the same "printMe" method from before, only now it is an Integer and returns the value 500. I highlighted the parts that were different, you may need to scroll across to see one of the changes. The bytecode of the new method looks like so: [code] 0 getstatic #27 <java/lang/System/out Ljava/io/PrintStream;> 3 ldc #29 <Hello People> 5 invokevirtual #35 <java/io/PrintStream/println(Ljava/lang/String;)V> 8 sipush 500 11 ireturn [/code] Altogether your code for inserting the printMe method as an Integer should look something like this: [code] import org.objectweb.asm.ClassReader; import org.objectweb.asm.ClassWriter; import org.objectweb.asm.Opcodes; import org.objectweb.asm.tree.*; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; public class UpdateHelloWorldMethod { public static void main(String[] args) { try { ClassReader reader = new ClassReader(new FileInputStream("HelloWorldField.class")); ClassNode node = new ClassNode(); reader.accept(node,0); MethodNode mn = new MethodNode(Opcodes.ACC_PRIVATE + Opcodes.ACC_STATIC, "printMe", "()I", null, null); mn.instructions.add(new FieldInsnNode(Opcodes.GETSTATIC, "java/lang/System", "out", "Ljava/io/PrintStream;")); mn.instructions.add(new LdcInsnNode("Hello People")); mn.instructions.add(new MethodInsnNode(Opcodes.INVOKEVIRTUAL, "java/io/PrintStream", "println", "(Ljava/lang/String;)V")); mn.instructions.add(new IntInsnNode(Opcodes.SIPUSH, 500)); mn.instructions.add(new InsnNode(Opcodes.IRETURN)); node.methods.add(mn); for(int i = 0; i < node.methods.size(); i++) { MethodNode methodnode = (MethodNode) node.methods.get(i); if(methodnode.name.equals("main")) { methodnode.instructions.insert(new MethodInsnNode(Opcodes.INVOKESTATIC, node.name, "printMe", "()V")); } } ClassWriter writer = new ClassWriter(ClassWriter.COMPUTE_MAXS); node.accept(writer); FileOutputStream fos = new FileOutputStream("HelloWorldField.class"); fos.write(writer.toByteArray()); fos.close(); } catch (IOException e) { e.printStackTrace(); } } } [/code] This covers a fair couple of subjects, however it is barely scratching the surface of what is really possible. I will be expanding this tutorial soon, I will try to go in to more depth, I will also use the visitor pattern, so that people can get used to seeing that too. I will try to attach some utility classes soon and show how they would be used, like a pattern searcher. Also as opposed to calling Opcodes.INSTRUCTION_NAME you'd be better implementing the Opcodes interface so you can just use them directly. Other things to note: I know this isn't the best way to use the API, however I feel it's the easiest way for new users, so I will demonstrate it that way. This code is not by any means an example of "good code" it wasn't intended to be, it was just intended to get the points I tried to make across. I tend to write quite quickly, so if you notice anything that isn't right with my grammar, please tell me, also if any of my terminology was incorrect please tell me so I can fix that too. If you have any further questions, I will be more than happy to answer them when I have chance. I may have rambled on a bit in some of my writing, some of it may be cluttered and might not make much sense, just tell me if it doesn't I'll fix it. There are also tutorials on the ASM website which will go into more detail than I did. If there any queries regarding my name (just in case) I couldn't think of anything else :-( There are tons of other instructions, so take a look at the VM Spec link at chapter 6. Thank you for reading. PS. This is old (sort of) I posted it on another community a while back, either way I'll get around to updating it to show usage of the visitor pattern and go into a lot more detail about bytecode and how to work with it. This is just some basics.
  7. [URL="https://github.com/FabianM/NodeLog"]https://github.com/FabianM/NodeLog [/URL]Rate/Hate
  8. It is pretty hard to find this nice piece of the site now day's unless you knew about this before the big site update that came along a few months back, the only way to find this is by google searching it. My suggestion with this is to have it placed either on the main page under [B]Main Page>Tools>Source Library [/B]and/or on the main Link header on top of our forums? This will encourage more people to submit their sources in a categorised manner. Once more thing, make the requirements so that only the best of each revision can have their server featured in this library. Thanks Link to Source Library [URL="http://www.runelocus.com/index.php?action=library"]http://www.runelocus.com/index.php?action=library [/URL]p.s If this is dead content, you should remove it fully (y)
  9. [center]Ever want to hack life? Or just know more in general? Like how many women the playboy king has slept with? How to hack your brain? Chemistry in 5 minutes? How to be an ass to others? How to get free things? Just wanna know more? Well download my information library. Ive collected these from /b/ and sorted them. This is pretty much every random tutorial, fact, or piece of knowledge in one. [code]http://www.megaupload.com/?d=27KPWUQB[/code] Here are a few examples- [spoiler=Examples][img]http://gyazo.com/9696a5603ff8fbce7b4051206cc88daa.png[/img] [img]http://gyazo.com/75ccc8fac30da2024288376a95ced7d6.png[/img] [img]http://gyazo.com/e9f908e7ed6578b63249ce8f69274637.png[/img] [img]http://gyazo.com/5fbed30de8d37ee92c06fb3887e3f0af.png[/img][/spoiler] [color="#FF0000"] Warning: Some graphic content[/color] [SIZE=4]Credits to 'Megan fox' on [url=www.se7ensins.com]Se7ensins[/url] Credits to Christopher on [url=www.runelocus.com]Runelocus[/url] for re-uploading the library (It had an unzipping problem) [/SIZE][/CENTER]
×