Skip to content
This repository was archived by the owner on Apr 7, 2021. It is now read-only.

Commit

Permalink
Phase 2 - Patch Support Extension.
Browse files Browse the repository at this point in the history
i. Added Move Cash Shop Icon patch
ii. Added few sanity checks in several patches
  • Loading branch information
Neo-Mind committed Oct 2, 2015
1 parent 51f2a8b commit 02ee0c7
Show file tree
Hide file tree
Showing 12 changed files with 146 additions and 18 deletions.
2 changes: 1 addition & 1 deletion Patches/ChangeItemInfo.qs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ function ChangeItemInfo() {
//Step 2a - Get the new filename from user
var myfile = exe.getUserInput("$newItemInfo", XTYPE_STRING, "String input - maximum 28 characters including folder name/", "Enter the new ItemInfo path (should be relative to RO folder)", "System/iteminfo.lub", 1, 28);
if (myfile === "System/iteminfo.lub")
return "Patch Cancelled";
return "Patch Cancelled - New value is same as old";

//Step 2b - Allocate space for the new name
var free = exe.findZeros(myfile.length);
Expand Down
32 changes: 22 additions & 10 deletions Patches/ChatColor.qs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ function ChatColorGuild() {
return "Failed in Step 1";

//Step 2a - Get new color from user
exe.getUserInput("$guildChatColor", XTYPE_COLOR, "Color input", "Select the new Guild Chat Color", 0x00B4FFB4);
var color = exe.getUserInput("$guildChatColor", XTYPE_COLOR, "Color input", "Select the new Guild Chat Color", 0x00B4FFB4);
if (color === 0x00B4FFB4)
return "Patch Cancelled - New Color is same as old";

//Step 2b - Replace with new color
exe.replace(offset + code.hexlength() - 4, "$guildChatColor", PTYPE_STRING);
Expand Down Expand Up @@ -52,7 +54,9 @@ function ChatColorGM() {
return "Failed in Step 1 - Yellow not found";

//Step 2a - Get the new color from user
exe.getUserInput("$gmChatColor", XTYPE_COLOR, "Color input", "Select the new GM Chat Color", 0x0000FFFF);
var color = exe.getUserInput("$gmChatColor", XTYPE_COLOR, "Color input", "Select the new GM Chat Color", 0x0000FFFF);
if (color === 0x0000FFFF)
return "Patch Cancelled - New Color is same as old";

//Step 2b - Replace all the colors with new color
exe.replace(offset1 + 1, "$gmChatColor", PTYPE_STRING);
Expand Down Expand Up @@ -84,8 +88,10 @@ function ChatColorPlayerSelf() {//N.B. - Check if it holds good for old client.
return "Failed in Step 1 - Green not found";

//Step 2a - Get the new color from user
exe.getUserInput("$yourChatColor", XTYPE_COLOR, "Color input", "Select the new Self Chat Color", 0x0000FF00);

var color = exe.getUserInput("$yourChatColor", XTYPE_COLOR, "Color input", "Select the new Self Chat Color", 0x0000FF00);
if (color === 0x0000FF00)
return "Patch Cancelled - New Color is same as old";

//Step 2b - Replace with new color
exe.replace(offset + 1, "$yourChatColor", PTYPE_STRING);

Expand All @@ -109,8 +115,10 @@ function ChatColorPlayerOther() {
return "Failed in Step 1";

//Step 2a - Get the new color from user
exe.getUserInput("$otherChatColor", XTYPE_COLOR, "Color input", "Select the new Other Player Chat Color", 0x00FFFFFF);

var color = exe.getUserInput("$otherChatColor", XTYPE_COLOR, "Color input", "Select the new Other Player Chat Color", 0x00FFFFFF);
if (color === 0x00FFFFFF)
return "Patch Cancelled - New Color is same as old";

//Step 2b - Replace with new color
exe.replace(offset + code.hexlength() - 4, "$otherChatColor", PTYPE_STRING);

Expand Down Expand Up @@ -140,8 +148,10 @@ function ChatColorPartySelf() {
return "Failed in Step 1";

//Step 2a - Get the new color from user
exe.getUserInput("$yourpartyChatColor", XTYPE_COLOR, "Color input", "Select the new Self Party Chat Color", 0x0000C8FF);

var color = exe.getUserInput("$yourpartyChatColor", XTYPE_COLOR, "Color input", "Select the new Self Party Chat Color", 0x0000C8FF);
if (color === 0x0000C8FF)
return "Patch Cancelled - New Color is same as old";

//Step 2b - Replace with new color
exe.replace(offset + code.hexlength() - 4, "$yourpartyChatColor", PTYPE_STRING);

Expand Down Expand Up @@ -171,8 +181,10 @@ function ChatColorPartyOther() {
return "Failed in Step 1";

//Step 2a - Get the new color from user
exe.getUserInput("$otherpartyChatColor", XTYPE_COLOR, "Color input", "Select the new Others Party Chat Color", 0x0000C8FF);

var color = exe.getUserInput("$otherpartyChatColor", XTYPE_COLOR, "Color input", "Select the new Others Party Chat Color", 0x00C8C8FF);
if (color === 0x00C8C8FF)
return "Patch Cancelled - New Color is same as old";

//Step 2b - Replace with new color
exe.replace(offset + code.hexlength() - 4, "$otherpartyChatColor", PTYPE_STRING);

Expand Down
4 changes: 3 additions & 1 deletion Patches/ChatLimit.qs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,9 @@ function ChatLimit(option) {

if (option === 1) {
//Step 2a - Get new value from user
exe.getUserInput("$allowChatFlood", XTYPE_BYTE, "Number Input", "Enter new chat limit (0-127, default is 2):", 2, 0, 127);
var flood = exe.getUserInput("$allowChatFlood", XTYPE_BYTE, "Number Input", "Enter new chat limit (0-127, default is 2):", 2, 0, 127);
if (flood === 2)
return "Patch Cancelled - New value is same as old";

//Step 2b - Replace 02 with new value
exe.replace(offset, "$allowChatFlood", PTYPE_STRING);
Expand Down
2 changes: 1 addition & 1 deletion Patches/CustomWindowTitle.qs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ function CustomWindowTitle() {
//Step 1b - Get the new Title from User
var title = exe.getUserInput("$customWindowTitle", XTYPE_STRING, "String Input - maximum 60 characters", "Enter the new window Title", "Ragnarok", 1, 60);
if (title.trim() === "Ragnarok")
return false;
return "Patch Cancelled - New Title is same as old";

//Step 1c - Overwrite URL with the new Title
exe.replace(strOff, "$customWindowTitle", PTYPE_STRING);
Expand Down
2 changes: 1 addition & 1 deletion Patches/ExtendedNpcBox.qs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ function ExtendNpcBox() {
//Step 2a - Get new value from user
var value = exe.getUserInput("$npcBoxLength", XTYPE_DWORD, "Number Input", "Enter new NPC Dialog box length (2052 - 4096)", 0x804, 0x804, 0x1000);
if (value === 0x804)
return false;
return "Patch Cancelled - New value is same as old";

//Step 2b - Change the Stack Allocation with new values
exe.replaceDWord(offset + 2, value + stackSub - 0x804);//Change x in SUB ESP, x
Expand Down
2 changes: 2 additions & 0 deletions Patches/IncreaseScreenshotQuality.qs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ function IncreaseScreenshotQuality() {

//Step 2a - Get new quality value from user
var newvalue = exe.getUserInput("$uQuality", XTYPE_BYTE, "Number Input", "Enter the new quality factor (0-100)", 50, 0, 100);
if (newvalue === 50)
return "Patch Cancelled - New value is same as old";

//Step 2b - Get the jquality offset = DIBChannels + 60
if (fpEnb)
Expand Down
2 changes: 1 addition & 1 deletion Patches/IncreaseViewID.qs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ function IncreaseViewID() {
//Step 2a - Get the new limit from user
var newValue = exe.getUserInput("$newValue", XTYPE_DWORD, "Number input", "Enter the new Max Headgear View ID", oldValue, oldValue, 32000);//32000 could prove fatal.
if (newValue === oldValue)
return false;
return "Patch Cancelled - New value is same as old";

//Step 2b - Find all occurrences of the old limit with the user specified value
var offsets = exe.findAll(oldValue.packToHex(4), PTYPE_HEX, false, "", offset - 0xA0, offset + 0x50);
Expand Down
108 changes: 108 additions & 0 deletions Patches/MoveCashShopIcon.qs
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
//##########################################################################
//# Purpose: Modify the coordinates send as argument to UIWindow::UIWindow #
//# for Cash Shop Button to the user specified ones #
//##########################################################################

function MoveCashShopIcon() {

//Step 1a - Find the XCoord calculation pattern
var code =
" 81 EA BB 00 00 00" //SUB EDX, 0BB
+ " 52" //PUSH EDX
;
var tgtReg = 2;
var offset = exe.findCode(code, PTYPE_HEX, true, "\xAB");

if (offset === -1) {
code = code.replace("81 EA", "2D").replace("52", "50");//change EDX to EAX
tgtReg = 0;
offset = exe.findCode(code, PTYPE_HEX, true, "\xAB");
}

if (offset === -1)
return "Failed in Step 1 - Coord calculation missing";

//Step 1b - Accomodate for extra bytes by NOPing those
if (tgtReg === 2) {//EDX
exe.replace(offset, "90", PTYPE_HEX);
offset++;
}

//Step 1c - Find the pattern where the Screen Size is picked up (Width is at 0x24, Height is at 0x28) - We need the address of g_ScreenStats
code =
" 8B 0D AB AB AB 00" //MOV ECX, DWORD PTR DS:[g_ScreenStats]
+ " 8B" //MOV reg32_A, DWORD PTR DS:[reg32_B+const]
;

var offset2 = exe.find(code, PTYPE_HEX, true, "\xAB", offset-0x18, offset);

if (offset2 === -1) {
code = code.replace("8B 0D", "A1");
offset2 = exe.find(code, PTYPE_HEX, true, "\xAB", offset-0x18, offset);
}

if (offset2 === -1)
return "Failed in Step 1 - Screen Size retrieval missing";

//Step 1d - Extract the g_ScreenStats
var g_ScreenStats = exe.fetchHex(offset2 + code.hexlength() - 5, 4);

//Step 2a - Get User Coords
var xCoord = exe.getUserInput("$cashShopX", XTYPE_WORD, "Number Input", "Enter new X coordinate:", -0xBB, -0xFFFF, 0xFFFF);
var yCoord = exe.getUserInput("$cashShopY", XTYPE_WORD, "Number Input", "Enter new Y coordinate:", 0x10, -0xFFFF, 0xFFFF);

if (xCoord === -0xBB && yCoord === 0x10)
return "Patch Cancelled - New coordinate is same as old";

//Step 2b - Prep code to insert based on the sign of each coordinate (negative values are relative to width and height respectively)
code = "";

if (yCoord < 0) {
code +=
" 8B 0D" + g_ScreenStats //MOV ECX, DWORD PTR DS:[g_ScreenStats]
+ " 8B 49 28" //MOV ECX, DWORD PTR DS:[ECX+28]
+ " 81 E9" + (-yCoord).packToHex(4) //SUB ECX, -yCoord
;
}
else {
code += " B9" + yCoord.packToHex(4) //MOV ECX, yCoord
}

code += " 89 4C 24 04"; //MOV DWORD PTR DS:[ESP+4], ECX

if (xCoord < 0) {
code +=
" 8B 0D" + g_ScreenStats //MOV ECX, DWORD PTR DS:[g_ScreenStats]
+ " 8B 49 24" //MOV ECX, DWORD PTR DS:[ECX+24]
+ " 81 E9" + (-xCoord).packToHex(4) //SUB ECX, -xCoord
;
}
else {
code += " B9" + xCoord.packToHex(4) //MOV ECX, xCoord
}

code +=
" 89" + (0xC8 | tgtReg).packToHex(1) //MOV tgtReg, ECX
+ " C3" //RETN
;

//Step 2c - Allocate space for it
var free = exe.findZeros(code.hexlength());
if (free === -1)
return "Failed in Step 2 - Not enough free space";

//Step 3a - Insert the code
exe.insert(free, code.hexlength(), code, PTYPE_HEX);

//Step 3b - Change the 0xBB subtraction with a call to our code
exe.replace(offset, "E8" + (exe.Raw2Rva(free) - exe.Raw2Rva(offset + 5)).packToHex(4), PTYPE_HEX);

return true;
}

//=====================================================//
// Only Enable for Clients that actually have the icon //
//=====================================================//
function MoveCashShopIcon_() {
return (exe.findString("NC_CashShop", RAW) !== -1);
}
2 changes: 2 additions & 0 deletions Patches/ResizeFont.qs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ function ResizeFont() {

//Step 2c - Get the new Font height
var newHeight = exe.getUserInput("$newFontHgt", XTYPE_BYTE, "Number Input", "Enter the new Font Height(1-127) - snaps to closest valid value", 10, 1, 127);
if (newHeight === 10)
return "Patch Cancelled - New value is same as old";

//Step 2d - Fill in the Blanks
code = ReplaceVarHex(code, 1, freeRva + 4);
Expand Down
2 changes: 1 addition & 1 deletion Patches/UseCustomFont.qs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ function UseCustomFont() {

// Step 2a - Get the Font name from user
var newFont = exe.getUserInput("$newFont", XTYPE_FONT, 'Font input', 'Select the new Font Family', "Arial");

// Step 2b - Get its address if its already existing
var free = exe.findString(newFont, RAW);

Expand Down
4 changes: 3 additions & 1 deletion Patches/_patchlist.qs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ registerGroup( 9, "PacketEncryptionKeys", false);

registerGroup(10, "LoginMode", true);

registerGroup(11, "CashShop", true);

//#########################################################################################################################################################
//# #
//# FORMAT for registering patch : registerPatch(patch id, functionName, patch Name, category, group id, author, description, recommended [true/false] ); #
Expand Down Expand Up @@ -203,7 +205,7 @@ registerPatch( 76, "EnforceOfficialLoginBackground", "Enforce Official Login Bac

registerPatch( 77, "EnableCustom3DBones", "Enable Custom 3D Bones", "Data", 0, "Ai4rei/AN", "Enables the use of custom 3D monsters (Granny) by lifting Hard-coded ID limit", false);

//78 is Unused - to be filled
registerPatch( 78, "MoveCashShopIcon", "Move Cash Shop Icon", "UI", 11, "Neo", "Move the Cash Shop icon to user specified co-ordinates. Positive values are relative to left and top, Negative values are relative to right and bottom", false);

registerPatch( 79, "SharedBodyPalettesV2", "Shared Body Palettes Type2", "UI", 6, "Ai4rei/AN, Neo", "Makes the client use a single cloth palette set (body_%d.pal) for all job classes both genders", false);

Expand Down
2 changes: 1 addition & 1 deletion lastcommit.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2015-09-29 01:29:50 GMT+0530
2015-10-02 09:32:52 GMT+0530

0 comments on commit 02ee0c7

Please sign in to comment.