SilabGarza - RS Private Server  
Home Forum Play Register Store Market Highscores Mark Forums Read
Go Back   SilabGarza - RS Private Server > SilGar Media > Computers > Programming
Reload this Page Runescape Widget Script System


Runescape Widget Script System
Old
  (#1 (permalink))
Sinisoul is Offline
Senior Member
image
 
Sinisoul's Avatar
 
Posts: 230
Cookies Given: 1
Cookies Received: 16
Time Online: 9 d 15 h 40 m
   
Default Runescape Widget Script System - 05-07-2012, 02:01 PM

In any modern Runescape client 414+, there is a widget script system used in dynamic handling. here is a dumper I wrote and a little output script example. It follows the normal schematics for a bytecodeish system.

Code:
package org.runetekk.cs;

import java.io.BufferedWriter;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileWriter;
import java.io.IOException;
import java.io.RandomAccessFile;
import java.nio.ByteBuffer;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import org.evelus.fs.FileIndex;
import org.evelus.fs.archives.FileContainer;
import org.evelus.fs.tables.IndexTable;

/**
 * Dump.java
 * @version 1.0.0
 * @author RuneTekk Development (SiniSoul)
 */
public final class Dump {
    
    /**
     * The instruction name map. 
     */
    private static Map<Integer, String> INSN_NAMES;
    
    /**
     * The script names map.
     */
    private static Map<Integer, String> SCRIPT_NAMES;
    
    /**
     * The starting point for the program.
     * @param args The command line arguments.
     */
    public static void main(String[] args) {
        args = new String[] { "./bin/files/cs634", "./bin/files/dat634", "./bin/files/t634", "./bin/scripts/" };
        System.out.println("Dump::CScript > Written By SiniSoul");
        RandomAccessFile indexFile, dataFile, tableFile;
        try {
            indexFile = new RandomAccessFile(args[0], "r");
            dataFile = new RandomAccessFile(args[1], "r");
            tableFile = new RandomAccessFile(args[2], "r");
        } catch(FileNotFoundException ex) {
            throw new RuntimeException("Failed to find the index and data files"
                                     + " to dump the client scripts...");
        }
        FileIndex tableIndex = new FileIndex(255, tableFile, dataFile);
        FileIndex fileIndex = new FileIndex(12, indexFile, dataFile);
        FileContainer tableContainer = new FileContainer(); 
        try {
            tableIndex.read(tableContainer, 12);
        } catch(IOException ex) {
            throw new RuntimeException("Failed to read the table container file "
                                     + "from the table index...");
        }
        IndexTable indexTable;
        try {
            indexTable = new IndexTable(tableContainer);
        } catch(IOException ex) {
            throw new RuntimeException("Failed to parse the script index table...");
        }
        System.out.println("Preparing to dump "+indexTable.getAmountEntries()+" scripts...");
        ClientScript[] scripts = new ClientScript[indexTable.getAmountEntries()];
        FileContainer scriptFile;
        for(int i = 0; i < indexTable.getAmountEntries(); i++) {
            scriptFile = new FileContainer();
            try {
                ClientScript script = new ClientScript();
                fileIndex.read(scriptFile, i);  
                ByteBuffer buffer = ByteBuffer.wrap(scriptFile.unpack());
                buffer.position(buffer.limit() - 2);
                int length = buffer.getShort();
                int footerOffset = buffer.limit() - length - 12 - 2;
                buffer.position(footerOffset);
                int operandSize = buffer.getInt();
                script.intArgCount = buffer.getShort();
                script.strArgCount = buffer.getShort();
                script.intStkCount = buffer.getShort();
                script.strStkCount = buffer.getShort();
                int jumpCount = buffer.get();
                if(jumpCount > 0) {
                    script.jumpTables = new HashMap[jumpCount];
                    for(int j = 0; j < jumpCount; j++) {
                        int size = buffer.getShort();
                        script.jumpTables[j] = new HashMap<Integer, Integer>(size);
                        while(size-- > 0) {
                            int index = buffer.getInt();
                            int value = buffer.getInt();
                            script.jumpTables[j].put(index, value);
                        }
                    }
                }
                buffer.position(0);
                script.name = getString(buffer);
                script.insnOpcodes = new int[operandSize];
                script.insnOperands = new int[operandSize];
                script.strOperands = new String[operandSize];
                int offset = 0;
                while(buffer.position() < footerOffset) {
                    int opcode = buffer.getShort();
                    if(opcode == 3) {
                        script.strOperands[offset] = getString(buffer).intern();
                    } else if(opcode >= 100|| opcode == 21 || opcode == 38 || opcode == 39)
                        script.insnOperands[offset] = buffer.get();
                    else
                        script.insnOperands[offset] = buffer.getInt();
                    script.insnOpcodes[offset++] = opcode;
                }
                scripts[i] = script;
            } catch(IOException ex) {
                throw new RuntimeException("Failed to read script "+i+"...");
            }
        }  
        System.out.println("Clearing out the files in the dump directory...");
        for(File f : new File(args[3]).listFiles()) {
            f.delete();
        }
        System.out.println("Dumping the scripts to text files...");
        BufferedWriter writer;
        for(int i = 0; i < scripts.length; i++) {
            ClientScript script = scripts[i];
            try {
                String scriptName = SCRIPT_NAMES.get(i);
                writer = new BufferedWriter(new FileWriter(args[3] + (scriptName == null ? i : scriptName) + ".txt"));
                writer.write("================================================\n");
                writer.write("      Client Script "+i+" Dumped by SiniSoul    \n");
                writer.write("      Instruction Size: "+script.insnOpcodes.length+"\n");
                writer.write("      Integer Arguments: "+script.intArgCount+" \n");
                writer.write("      String  Arguments: "+script.strArgCount+" \n");
                writer.write("================================================\n\n");
                writer.write("================================================\n");
                writer.write("                 Instructions                   \n");
                writer.write("================================================\n\n");               
                for(int j = 0; j < script.insnOpcodes.length; j++) {
                    int insnOpcode = script.insnOpcodes[j];
                    String name = INSN_NAMES.get(insnOpcode);
                    writer.write("Offset: "+j+", ");
                    if(name != null)
                        writer.write(name + " ");
                    else
                        if(insnOpcode > 99)           
                            writer.write("Unref Method: "+insnOpcode);
                        else
                            writer.write("Unref Opcode: "+insnOpcode);
                    Object operand = insnOpcode == 3 ? script.strOperands[j] : script.insnOperands[j];
                    if(name != null && name.equals("CALL")) {
                        scriptName = SCRIPT_NAMES.get((Integer) operand);
                        if(scriptName != null) {
                            writer.write(", Script: " + scriptName + "\n");
                            continue;
                        }
                    }
                    writer.write(", Operand: " + operand + "\n");
                }
                if(script.jumpTables != null) {
                    for(int j = 0; j < script.jumpTables.length; j++) {
                        writer.write("\n================================================\n");
                        writer.write("                Switch Table "+j+"                \n");
                        writer.write("================================================\n\n");
                        Map<Integer, Integer> map = script.jumpTables[j];
                        Set<Integer> keys = map.keySet();
                        for(int key : keys) {
                            writer.write("Key: "+key+", Value: "+map.get(key)+"\n");
                        }
                    }
                }
                writer.flush();
                writer.close();
            } catch(IOException ex) {
                throw new RuntimeException("Failed to dump script "+i+"...");
            }            
        }
    }
    
    /**
     * 
     * @param buffer
     * @return 
     */
    private static String getString(ByteBuffer buffer) {
        String str = "";
        int c = 0;
        while((c = buffer.get()) != 0)
            str += (char) c;
        return str;
    }
    
    static {
        INSN_NAMES = new HashMap<Integer, String>();
        INSN_NAMES.put(0, "PUSHI");
        INSN_NAMES.put(1, "GETRAWCONFIG");
        INSN_NAMES.put(2, "PUTRAWCONFIG");
        INSN_NAMES.put(3, "PUSHS");
        INSN_NAMES.put(6, "GOTO");
        INSN_NAMES.put(7, "IFNE");
        INSN_NAMES.put(8, "IFEQ");
        INSN_NAMES.put(9, "IFLT");
        INSN_NAMES.put(10, "IFGT");
        INSN_NAMES.put(21, "RETURN");
        INSN_NAMES.put(25, "GETSETTING");
        INSN_NAMES.put(27, "PUTSETTING");
        INSN_NAMES.put(31, "IFLTEQ");
        INSN_NAMES.put(32, "IFGTEQ");
        INSN_NAMES.put(33, "LOADINT");
        INSN_NAMES.put(34, "STOREINT");
        INSN_NAMES.put(35, "LOADSTR");
        INSN_NAMES.put(36, "STORESTR");
        INSN_NAMES.put(37, "CONCAT");
        INSN_NAMES.put(38, "POPI");
        INSN_NAMES.put(39, "POPS");
        INSN_NAMES.put(40, "CALL");
        INSN_NAMES.put(42, "LOADGINT");
        INSN_NAMES.put(43, "STOREGINT");
        INSN_NAMES.put(44, "NEWARRAY");
        INSN_NAMES.put(45, "AASTORE");
        INSN_NAMES.put(46, "AALOAD");
        INSN_NAMES.put(47, "LOADGSTR");
        INSN_NAMES.put(48, "STOREGSTR");
        INSN_NAMES.put(51, "SWITCH");
        INSN_NAMES.put(100, "createChildWidget");
        INSN_NAMES.put(102, "destroyChildrenWidgets");
        INSN_NAMES.put(200, "setCurrentWidgetChild");
        INSN_NAMES.put(201, "setCurrentWidget");
        INSN_NAMES.put(2101, "setWidgetTextColor");
        INSN_NAMES.put(2112, "setWidgetText");
        for(int i = 0; i <= 30; i++)
            INSN_NAMES.put(2400 + i, "setInterfaceDefinitionScriptParams"+i);
        INSN_NAMES.put(1300, "setChildInterfaceText");
        INSN_NAMES.put(2105, "changeWidgetId");
        INSN_NAMES.put(3300, "getLogicCycle");
        INSN_NAMES.put(3318, "getConnectionPortOffset");
        INSN_NAMES.put(3321, "getRunEnergy");
        INSN_NAMES.put(3340, "getWindowActive");
        INSN_NAMES.put(4000, "IADD");
        INSN_NAMES.put(4001, "ISUB");
        INSN_NAMES.put(4002, "IMUL");
        INSN_NAMES.put(4003, "IDIV");
        INSN_NAMES.put(4004, "getRandom");
        INSN_NAMES.put(4005, "getRandom2");
        INSN_NAMES.put(4008, "toggleBit");
        INSN_NAMES.put(4009, "untoggleBit");
        INSN_NAMES.put(4010, "isBitToggled");
        INSN_NAMES.put(4011, "IMOD");
        INSN_NAMES.put(4012, "IPOW");
        INSN_NAMES.put(4014, "IAND");
        INSN_NAMES.put(4015, "IOR");
        INSN_NAMES.put(4100, "concatIntAndStr");
        INSN_NAMES.put(4101, "concatStrings");
        INSN_NAMES.put(4102, "concatStrAndIntRadix");
        INSN_NAMES.put(4103, "toLowerCase");
        INSN_NAMES.put(4104, "getTimeToString");
        INSN_NAMES.put(4106, "integerToString");
        INSN_NAMES.put(4112, "concatStrAndChar");
        INSN_NAMES.put(4117, "getStringLength");
        INSN_NAMES.put(4119, "discludeTagsInString");
        INSN_NAMES.put(4120, "indexOfCharInString");
        INSN_NAMES.put(4121, "indexOfStrInString");
        INSN_NAMES.put(4122, "charInStringToLower");
        INSN_NAMES.put(4123, "charInStringToUpper");
        INSN_NAMES.put(5420, "doesntAllowFileOperations");
        INSN_NAMES.put(5002, "putOutgoingMessagePacket");
        INSN_NAMES.put(5004, "getMessageType");
        INSN_NAMES.put(5600, "setUsernamePassword");
        INSN_NAMES.put(5615, "doLogin");
        INSN_NAMES.put(5620, "isPreferenceStrNull");
        INSN_NAMES.put(5622, "getPreferenceStr");
        INSN_NAMES.put(5623, "isSSKStrNull");    
        INSN_NAMES.put(5624, "getSSK");  
        INSN_NAMES.put(6204, "getZoom");
        INSN_NAMES.put(6302, "getCalendarTime");
        INSN_NAMES.put(6303, "getCurrentYear");
        INSN_NAMES.put(6501, "getFirstLobbyWorld");
        INSN_NAMES.put(6502, "getNextLobbyWorld");
        INSN_NAMES.put(6506, "getLobbyWorldFromId");
        
        SCRIPT_NAMES = new HashMap<Integer, String>();
        SCRIPT_NAMES.put(44, "ChangeWidgetId");
        SCRIPT_NAMES.put(45, "UpdateWidgetTextColor");
        SCRIPT_NAMES.put(1219, "ToggleWidget");
        SCRIPT_NAMES.put(1220, "ToggleWidget$");
        SCRIPT_NAMES.put(2924, "UpdateButtonWidget");
        SCRIPT_NAMES.put(2925, "UpdateButtonWidget$");
    }
}
Code:
package org.runetekk.cs;

import java.util.Map;

/**
 * ClientScript.java
 * @version 1.0.0
 * @author RuneTekk Development (SiniSoul)
 */
public final class ClientScript {
    String name;
    int intArgCount;
    int strArgCount;
    int intStkCount;
    int strStkCount;
    Map<Integer, Integer>[] jumpTables;
    int[] insnOpcodes;
    int[] insnOperands;
    String[] strOperands;
}
Code:
================================================
      Client Script 1720 Dumped by SiniSoul    
      Instruction Size: 42
      Integer Arguments: 1 
      String  Arguments: 0 
================================================

================================================
                 Instructions                   
================================================

Offset: 0, PUSHI , Operand: 0
Offset: 1, STOREINT , Operand: 0
Offset: 2, LOADINT , Operand: 0
Offset: 3, PUSHI , Operand: 1
Offset: 4, IADD , Operand: 0
Offset: 5, STOREINT , Operand: 0
Offset: 6, LOADINT , Operand: 0
Offset: 7, PUSHI , Operand: 1
Offset: 8, IADD , Operand: 0
Offset: 9, STOREINT , Operand: 0
Offset: 10, LOADINT , Operand: 0
Offset: 11, PUSHI , Operand: 1
Offset: 12, IADD , Operand: 0
Offset: 13, STOREINT , Operand: 0
Offset: 14, LOADINT , Operand: 0
Offset: 15, PUSHI , Operand: 1
Offset: 16, IADD , Operand: 0
Offset: 17, STOREINT , Operand: 0
Offset: 18, LOADINT , Operand: 0
Offset: 19, PUSHI , Operand: 1
Offset: 20, IADD , Operand: 0
Offset: 21, STOREINT , Operand: 0
Offset: 22, LOADINT , Operand: 0
Offset: 23, PUSHI , Operand: 1
Offset: 24, IADD , Operand: 0
Offset: 25, STOREINT , Operand: 0
Offset: 26, LOADINT , Operand: 0
Offset: 27, PUSHI , Operand: 1
Offset: 28, IADD , Operand: 0
Offset: 29, STOREINT , Operand: 0
Offset: 30, LOADINT , Operand: 0
Offset: 31, PUSHI , Operand: 1
Offset: 32, IADD , Operand: 0
Offset: 33, STOREINT , Operand: 0
Offset: 34, LOADINT , Operand: 0
Offset: 35, PUSHI , Operand: 1
Offset: 36, IADD , Operand: 0
Offset: 37, STOREINT , Operand: 0
Offset: 38, LOADINT , Operand: 0
Offset: 39, RETURN , Operand: 0
Offset: 40, PUSHI , Operand: 0
Offset: 41, RETURN , Operand: 0
Code:
================================================
      Client Script 2404 Dumped by SiniSoul    
      Instruction Size: 5
      Integer Arguments: 2 
      String  Arguments: 0 
================================================

================================================
                 Instructions                   
================================================

Offset: 0, LOADINT , Operand: 0
Offset: 1, LOADINT , Operand: 1
Offset: 2, PUSHS , Operand: Level 5 Agility
Offset: 3, CALL , Operand: 2010
Offset: 4, RETURN , Operand: 0


Wunderbar.
  
Old
  (#2 (permalink))
gonna try ingame. ;c
image
 
LateNightWithZeep&Wingzz's Avatar
 
Posts: 665
Cookies Given: 121
Cookies Received: 5
Time Online: 16 d 4 h 58 m
   
Default 05-07-2012, 07:54 PM

Inglesh pl0x.

Question though.. what does the widget script system actually do?


Main/Pure: Wingzz
Skiller: Im Argo
  
Old
  (#3 (permalink))
Sinisoul is Offline
Senior Member
image
 
Sinisoul's Avatar
 
Posts: 230
Cookies Given: 1
Cookies Received: 16
Time Online: 9 d 15 h 40 m
   
Default 05-07-2012, 09:04 PM

Quote:
Originally Posted by LateNightWithZeep&Wingzz View Post
Inglesh pl0x.

Question though.. what does the widget script system actually do?
The widget script system changes text colors, text, background colors, etc for a widget. It's the main backbone of everything you see in game that isn't a model.


Wunderbar.
  
Old
  (#4 (permalink))
iPod is Offline
~That's it?~
image
 
iPod's Avatar
 
Posts: 1,678
Cookies Given: 631
Cookies Received: 171
Time Online: 37 d 6 m
Clan: W.I.N
   
Default 05-07-2012, 10:01 PM

don't get it lol. What would that thing change? what's the importance of it to runescape nowadays?


If you give a fuck what people think, you're not going to get anywhere



  
adsense code2.3
Closed Thread

Bookmarks

Runescape Widget Script System

Programming




Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
adsense2.6
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -7. The time now is 12:00 AM.





Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2017, vBulletin Solutions, Inc.