diff --git a/README.md b/README.md index c53fa40..ec58ec2 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # BemaniPatcher -A tool to easily apply known hex edits to any DLL, with examples for Bemani games. +A tool to easily apply known hex edits to any binary, with examples for Bemani games. Should work on most modern browsers. -Live version hosted [on my website](http://mon.im/bemanipatcher/). \ No newline at end of file +Live version hosted [on my website](https://mon.im/bemanipatcher/). \ No newline at end of file diff --git a/ballerz.html b/ballerz.html index 93ded3d..f6680e4 100644 --- a/ballerz.html +++ b/ballerz.html @@ -10,8 +10,8 @@ diff --git a/beatstream1.html b/beatstream1.html index 7175b1e..0913aa2 100644 --- a/beatstream1.html +++ b/beatstream1.html @@ -10,8 +10,8 @@ diff --git a/beatstream2.html b/beatstream2.html index 546ed28..e1cda56 100644 --- a/beatstream2.html +++ b/beatstream2.html @@ -10,8 +10,8 @@ diff --git a/copula.html b/copula.html index 5e3ad6b..164012d 100644 --- a/copula.html +++ b/copula.html @@ -10,8 +10,8 @@ diff --git a/ddr2014.html b/ddr2014.html index 1db4613..19b1b92 100644 --- a/ddr2014.html +++ b/ddr2014.html @@ -10,7 +10,7 @@ diff --git a/gfdmv5.html b/gfdmv5.html index 9db88d9..f9165f6 100644 --- a/gfdmv5.html +++ b/gfdmv5.html @@ -10,16 +10,15 @@ diff --git a/gfdmv6.html b/gfdmv6.html index 1bf648b..8650f72 100644 --- a/gfdmv6.html +++ b/gfdmv6.html @@ -10,16 +10,15 @@ diff --git a/gfdmv7.html b/gfdmv7.html index a688455..9d170d7 100644 --- a/gfdmv7.html +++ b/gfdmv7.html @@ -10,16 +10,15 @@ diff --git a/gitadoraexchain.html b/gitadoraexchain.html index 9621320..12d82f3 100644 --- a/gitadoraexchain.html +++ b/gitadoraexchain.html @@ -10,14 +10,12 @@ diff --git a/gitadoramatixx.html b/gitadoramatixx.html index ae401e9..18c6f2d 100644 --- a/gitadoramatixx.html +++ b/gitadoramatixx.html @@ -10,8 +10,7 @@ diff --git a/gitadoraod.html b/gitadoraod.html index 556be69..bb307f1 100644 --- a/gitadoraod.html +++ b/gitadoraod.html @@ -10,7 +10,7 @@ diff --git a/js/dllpatcher.js b/js/dllpatcher.js index a1d83d1..29caa94 100644 --- a/js/dllpatcher.js +++ b/js/dllpatcher.js @@ -2,470 +2,12 @@ "use strict"; // form labels often need unique IDs - this can be used to generate some -window.DllPatcher_uniqueid = 0; +window.Patcher_uniqueid = 0; var createID = function() { - window.DllPatcher_uniqueid++; - return "dllpatch_" + window.DllPatcher_uniqueid; -} - -// Each unique kind of patch should have createUI, validatePatch, applyPatch, -// updateUI - -var StandardPatch = function(options) { - this.name = options.name; - this.patches = options.patches; - this.tooltip = options.tooltip; + window.Patcher_uniqueid++; + return "dllpatch_" + window.Patcher_uniqueid; }; -StandardPatch.prototype.createUI = function(parent) { - var id = createID(); - var label = this.name; - var patch = $('
', {'class' : 'patch'}); - this.checkbox = $('')[0]; - patch.append(this.checkbox); - patch.append(''); - if(this.tooltip) { - patch.append('
' + this.tooltip + '
'); - } - parent.append(patch); -}; - -StandardPatch.prototype.updateUI = function(file) { - this.checkbox.checked = this.checkPatchBytes(file) === "on"; -}; - -StandardPatch.prototype.validatePatch = function(file) { - var status = this.checkPatchBytes(file); - if(status === "on") { - console.log('"' + this.name + '"', "is enabled!"); - } else if(status === "off") { - console.log('"' + this.name + '"', "is disabled!"); - } else { - return '"' + this.name + '" is neither on nor off! Have you got the right dll?'; - } -}; - -StandardPatch.prototype.applyPatch = function(file) { - this.replaceAll(file, this.checkbox.checked); -}; - -StandardPatch.prototype.replaceAll = function(file, featureOn) { - for(var i = 0; i < this.patches.length; i++) { - replace(file, this.patches[i].offset, - featureOn? this.patches[i].on : this.patches[i].off); - } -} - -StandardPatch.prototype.checkPatchBytes = function(file) { - var patchStatus = ""; - for(var i = 0; i < this.patches.length; i++) { - var patch = this.patches[i]; - if(bytesMatch(file, patch.offset, patch.off)) { - if(patchStatus === "") { - patchStatus = "off"; - } else if(patchStatus != "off"){ - return "on/off mismatch within patch"; - } - } else if(bytesMatch(file, patch.offset, patch.on)) { - if(patchStatus === "") { - patchStatus = "on"; - } else if(patchStatus != "on"){ - return "on/off mismatch within patch"; - } - } else { - return "patch neither on nor off"; - } - } - return patchStatus; -} - -// Each unique kind of patch should have createUI, validatePatch, applyPatch, -// updateUI - -// The DEFAULT state is always the 1st element in the patches array -var UnionPatch = function(options) { - this.name = options.name; - this.offset = options.offset; - this.patches = options.patches; -}; - -UnionPatch.prototype.createUI = function(parent) { - this.radios = []; - var radio_id = createID(); - - var container = $("
", {"class": "patch-union"}); - container.append('' + this.name + ':'); - for(var i = 0; i < this.patches.length; i++) { - var patch = this.patches[i]; - var id = createID(); - var label = patch.name; - var patchDiv = $('
', {'class' : 'patch'}); - var radio = $('')[0]; - this.radios.push(radio); - - patchDiv.append(radio); - patchDiv.append(''); - if(patch.tooltip) { - patchDiv.append('
' + patch.tooltip + '
'); - } - container.append(patchDiv); - } - parent.append(container); -}; - -UnionPatch.prototype.updateUI = function(file) { - for(var i = 0; i < this.patches.length; i++) { - if(bytesMatch(file, this.offset, this.patches[i].patch)) { - this.radios[i].checked = true; - return; - } - } - // Default fallback - this.radios[0].checked = true; -}; - -UnionPatch.prototype.validatePatch = function(file) { - for(var i = 0; i < this.patches.length; i++) { - if(bytesMatch(file, this.offset, this.patches[i].patch)) { - console.log(this.name, "has", this.patches[i].name, "enabled"); - return; - } - } - return '"' + this.name + '" doesn\'t have a valid patch! Have you got the right dll?'; -}; - -UnionPatch.prototype.applyPatch = function(file) { - var patch = this.getSelected(); - replace(file, this.offset, patch.patch); -}; - -UnionPatch.prototype.getSelected = function() { - for(var i = 0; i < this.patches.length; i++) { - if(this.radios[i].checked) { - return this.patches[i]; - } - } - return null; -} - -var DllPatcherContainer = function (patchers) { - this.patchers = patchers; - this.createUI(); -}; - -DllPatcherContainer.prototype.getSupportedDLLs = function () { - var dlls = []; - for (var i = 0; i < this.patchers.length; i++) { - var name = this.patchers[i].filename + ".dll"; - if (dlls.indexOf(name) === -1) { - dlls.push(name); - } - } - return dlls; -}; - -DllPatcherContainer.prototype.getSupportedVersions = function () { - var descriptions = []; - for (var i = 0; i < this.patchers.length; i++) { - if ($.type(this.patchers[i].description) === "string") { - descriptions.push(this.patchers[i].description); - } - } - return descriptions; -}; - -DllPatcherContainer.prototype.createUI = function () { - var self = this; - var container = $("
", {"class": "patchContainer"}); - var header = this.getSupportedDLLs().join(", "); - container.html("

" + header + "

"); - - var supportedDlls = $("
    "); - var versions = this.getSupportedVersions(); - this.forceLoadTexts = []; - this.forceLoadButtons = []; - for (var i = 0; i < versions.length; i++) { - var listItem = $("
  • "); - $('').text(versions[i]).appendTo(listItem); - var matchPercent = $('').addClass('matchPercent'); - this.forceLoadTexts.push(matchPercent); - matchPercent.appendTo(listItem); - var forceButton = $('