fix: globalyse js function & correct bugs

This commit is contained in:
root 2022-08-17 14:13:07 +02:00
parent 9bfdcc2254
commit c701f9e1be
3 changed files with 73 additions and 227 deletions

View File

@ -9,6 +9,7 @@
<script src="../dist/keystone.min.js"></script>
<script src="../dist/jquery-2.2.0.min.js"></script>
<script src="../dist/download.js"></script>
<script src="../dist/divers.js"></script>
<link rel="stylesheet" href="../dist/tuicss.min.css">
</head>
@ -303,40 +304,6 @@ function format_callback()
dumpall(zones);
}
function check(parent,child)
{
$(parent).find("span:not(.red-168-text)").html("&nbsp;");
$(parent).find("span:not(.red-168-text)").each(function() {
if (this.id==child.id)
{
$(this).html("√");
modify=$(parent).attr("tomodify");
if (modify!==undefined)
{
add=$(parent).attr("toadd");
if (add===undefined)
add="";
text="&nbsp;"+add+$(child).parent().text().replace(/[^a-z0-9:]/gi,'')+"&nbsp;";
$("#"+modify).find("span.tui-fieldset-text").html(text);
variable=add.toLowerCase().replace(/[^a-z0-9]/gi,'');
eval(variable+"='"+child.id+"';");
afunction=add.toLowerCase().replace(/[^a-z0-9]/gi,'');
eval("if (typeof "+afunction+"_callback === 'function') { "+afunction+"_callback() }");
}
}
})
}
function closemodal()
{
$("#modal").css("visibility","hidden");
}
function showmodal()
{
$("#modal").css("visibility","visible");
}
function setFilename(name){
$("#filename").html(name);
filename=name;
@ -393,30 +360,6 @@ function realopen(file)
}
};
function hexQword(value) {
value = value < 0 ? (value + 0x10000000000000000) : (value);
var str = '0000000000000000' + value.toString(16).toUpperCase();
return str.slice(-16);
};
function hexDword(value) {
value = value < 0 ? (value + 0x100000000) : (value);
var str = '00000000' + value.toString(16).toUpperCase();
return str.slice(-8);
};
function hexWord(value) {
value = value < 0 ? (value + 0x10000) : (value);
var str = '0000' + value.toString(16).toUpperCase();
return str.slice(-4);
};
function hexByte(value) {
value = value < 0 ? (value + 0x100) : (value);
var str = '00' + value.toString(16).toUpperCase();
return str.slice(-2);
};
function makebin(allzones)
{
var output = [];
@ -580,17 +523,6 @@ function showresult(text)
$("#results").find("div").html(text);
}
function toHex(hexa,code)
{
if (code==16)
result=hexWord(hexa);
else if (code==32)
result=hexDword(hexa);
else
result=hexQword(hexa);
return result;
}
function assemble(zone)
{
if (zone.code==16)

View File

@ -11,6 +11,7 @@
<script src="../dist/unicorn.min.js"></script>
<script src="../dist/jquery-2.2.0.min.js"></script>
<script src="../dist/download.js"></script>
<script src="../dist/divers.js"></script>
<link rel="stylesheet" href="../dist/tuicss.min.css">
</head>
@ -158,7 +159,7 @@
<ul>
<li>
<a onclick="javascript:check(this.parentElement.parentElement.parentElement,this.children[0])">
<span id="ds00"></span> DS:0x0
<span id="ds00">&nbsp;span> DS:0x0
</a>
</li>
<li>
@ -178,7 +179,7 @@
</li>
<li>
<a onclick="javascript:check(this.parentElement.parentElement.parentElement,this.children[0])">
<span id="csip">&nbsp;</span> CS:IP
<span id="csip"></span> CS:IP
</a>
</li>
<li>
@ -322,7 +323,7 @@
<div id="mem1" class="tui-window tui-no-shadow" style="height:20%;width:520px">
<fieldset class="tui-fieldset" style="height:100%">
<span class="tui-fieldset-text right" style="margin-bottom: -5px;">&nbsp;CS:IP&nbsp;</span>
<span class="tui-fieldset-text right" style="margin-bottom: -5px;">&nbsp;Zone:CS:IP&nbsp;</span>
<legend class="center">Memory explorer 1</legend>
<div class="" style="overflow: scroll;height:100%;width:100%"></div>
</fieldset>
@ -350,160 +351,5 @@
</div>
</body>
<script>
function closemodal()
{
$("#modal").css("visibility","hidden");
}
function showmodal()
{
$("#modal").css("visibility","visible");
}
function setFilename(name){
$("#filename").html(name);
filename=name;
}
function check(parent,child)
{
$(parent).find("span:not(.red-168-text)").html("&nbsp;");
$(parent).find("span:not(.red-168-text)").each(function() {
if (this.id==child.id)
{
$(this).html("√");
modify=$(parent).attr("tomodify");
if (modify!==undefined)
{
add=$(parent).attr("toadd");
if (add===undefined)
add="";
text="&nbsp;"+add+$(child).parent().text().replace(/[^a-z0-9:]/gi,'')+"&nbsp;";
$("#"+modify).find("span.tui-fieldset-text").html(text);
variable=add.toLowerCase().replace(/[^a-z0-9]/gi,'');
eval(variable+"='"+child.id+"';");
afunction=add.toLowerCase().replace(/[^a-z0-9]/gi,'');
eval("if (typeof "+afunction+"_callback === 'function') { "+afunction+"_callback() }");
}
}
})
}
function hexQword(value) {
value = value < 0 ? (value + 0x10000000000000000) : (value);
var str = '0000000000000000' + value.toString(16).toUpperCase();
return str.slice(-16);
};
function hexDword(value) {
value = value < 0 ? (value + 0x100000000) : (value);
var str = '00000000' + value.toString(16).toUpperCase();
return str.slice(-8);
};
function hexWord(value) {
value = value < 0 ? (value + 0x10000) : (value);
var str = '0000' + value.toString(16).toUpperCase();
return str.slice(-4);
};
function hexByte(value) {
value = value < 0 ? (value + 0x100) : (value);
var str = '00' + value.toString(16).toUpperCase();
return str.slice(-2);
};
function makebin(allzones)
{
var output = [];
for (const zone of allzones)
output.push(...zone.asm);
return new Uint8Array(output);
}
function dump(zone) {
var mcLen = zone.asm.length;
if (type=="binary")
var output = '<tr>';
else
var output = '';
switch (type) {
case 'binary':
var address=zone.offset;
for (var offset = 0; offset < mcLen; offset += 16) {
output += "<td>"+toHex(address,zone.code)+"</td><td>";
var ascii='';
for (var i = offset; i < offset + 16 && i < mcLen; i++) {
if (zone.asm[i]>31)
ascii += String.fromCharCode(zone.asm[i]);
else
ascii += '.';
output += hexByte(zone.asm[i]) + " ";
}
output += "</td><td>"+ascii+"</td></tr>";
address+=16;
}
break;
case 'array':
output += "const uint8_t "+zone.title+"[] = {\n";
for (var offset = 0; offset < mcLen; offset += 8) {
output += " ";
for (var i = offset; i < offset + 8 && i < mcLen; i++) {
output += "0x" + hexByte(zone.asm[i]) + ", ";
}
output = output.substring(0, output.length - 1);
output += "\n";
}
output = output.substring(0, output.length - 2);
output += "\n};\n";
break;
case 'string':
output += "const char* "+zone.title+" =\n";
for (var offset = 0; offset < mcLen; offset += 16) {
output += " \"";
for (var i = offset; i < offset + 16 && i < mcLen; i++) {
output += "\\x" + hexByte(zone.asm[i]);
}
output += "\"\n";
}
output = output.substring(0, output.length - 1);
output += ";\n";
break;
}
return output;
}
function showzones(zones)
{
table='<table class="tui-table striped-purple"><thead><tr><th>Id</th><th>Title</th><th>Offset</th><th>Size</th><th>Type</th><th>Compiled</th></tr></thead>';
for (const zone of zones)
table+="<tr><td align='right'>"+zone.id+"</td><td align='left'>"+zone.title+"</td><td align='right'>"+zone.realoffset+"</td><td align='right'>"+zone.asm.length+"</td><td align='right'>"+zone.code+"</td><td align='right'>"+(zone.asm.length>0)+"</td></tr>";
table+="</table>"
$("#result2").html(table);
}
function showstatus(text)
{
$("#status").html($("#status").html()+text+"<br>");
$("#status").scrollTop($("#status")[0].scrollHeight);
}
function showresult(text)
{
$("#result").html(text);
}
function toHex(hexa,code)
{
if (code==16)
result=hexWord(hexa);
else if (code==32)
result=hexDword(hexa);
else
result=hexQword(hexa);
return result;
}
</script>
</html>

68
dist/divers.js vendored Normal file
View File

@ -0,0 +1,68 @@
function check(parent,child)
{
$(parent).find("span:not(.red-168-text)").html("&nbsp;");
$(parent).find("span:not(.red-168-text)").each(function() {
if (this.id==child.id)
{
$(this).html("√");
modify=$(parent).attr("tomodify");
if (modify!==undefined)
{
add=$(parent).attr("toadd");
if (add===undefined)
add="";
text="&nbsp;"+add+$(child).parent().text().replace(/[^a-z0-9:]/gi,'')+"&nbsp;";
$("#"+modify).find("span.tui-fieldset-text").html(text);
variable=add.toLowerCase().replace(/[^a-z0-9]/gi,'');
eval(variable+"='"+child.id+"';");
afunction=add.toLowerCase().replace(/[^a-z0-9]/gi,'');
eval("if (typeof "+afunction+"_callback === 'function') { "+afunction+"_callback() }");
}
}
})
}
function closemodal()
{
$("#modal").css("visibility","hidden");
}
function showmodal()
{
$("#modal").css("visibility","visible");
}
function hexQword(value) {
value = value < 0 ? (value + 0x10000000000000000) : (value);
var str = '0000000000000000' + value.toString(16).toUpperCase();
return str.slice(-16);
};
function hexDword(value) {
value = value < 0 ? (value + 0x100000000) : (value);
var str = '00000000' + value.toString(16).toUpperCase();
return str.slice(-8);
};
function hexWord(value) {
value = value < 0 ? (value + 0x10000) : (value);
var str = '0000' + value.toString(16).toUpperCase();
return str.slice(-4);
};
function hexByte(value) {
value = value < 0 ? (value + 0x100) : (value);
var str = '00' + value.toString(16).toUpperCase();
return str.slice(-2);
};
function toHex(hexa,code)
{
if (code==16)
result=hexWord(hexa);
else if (code==32)
result=hexDword(hexa);
else
result=hexQword(hexa);
return result;
}