mirror of
https://github.com/sehugg/8bitworkshop.git
synced 2024-11-29 14:51:17 +00:00
174 lines
1.2 MiB
JavaScript
174 lines
1.2 MiB
JavaScript
|
var MCapstone = function(MCapstone) {
|
||
|
MCapstone = MCapstone || {};
|
||
|
var Module = MCapstone;
|
||
|
|
||
|
var Module;if(!Module)Module=(typeof MCapstone!=="undefined"?MCapstone:null)||{};var moduleOverrides={};for(var key in Module){if(Module.hasOwnProperty(key)){moduleOverrides[key]=Module[key]}}var ENVIRONMENT_IS_WEB=false;var ENVIRONMENT_IS_WORKER=false;var ENVIRONMENT_IS_NODE=false;var ENVIRONMENT_IS_SHELL=false;if(Module["ENVIRONMENT"]){if(Module["ENVIRONMENT"]==="WEB"){ENVIRONMENT_IS_WEB=true}else if(Module["ENVIRONMENT"]==="WORKER"){ENVIRONMENT_IS_WORKER=true}else if(Module["ENVIRONMENT"]==="NODE"){ENVIRONMENT_IS_NODE=true}else if(Module["ENVIRONMENT"]==="SHELL"){ENVIRONMENT_IS_SHELL=true}else{throw new Error("The provided Module['ENVIRONMENT'] value is not valid. It must be one of: WEB|WORKER|NODE|SHELL.")}}else{ENVIRONMENT_IS_WEB=typeof window==="object";ENVIRONMENT_IS_WORKER=typeof importScripts==="function";ENVIRONMENT_IS_NODE=typeof process==="object"&&typeof require==="function"&&!ENVIRONMENT_IS_WEB&&!ENVIRONMENT_IS_WORKER;ENVIRONMENT_IS_SHELL=!ENVIRONMENT_IS_WEB&&!ENVIRONMENT_IS_NODE&&!ENVIRONMENT_IS_WORKER}if(ENVIRONMENT_IS_NODE){if(!Module["print"])Module["print"]=console.log;if(!Module["printErr"])Module["printErr"]=console.warn;var nodeFS;var nodePath;Module["read"]=function read(filename,binary){if(!nodeFS)nodeFS=require("fs");if(!nodePath)nodePath=require("path");filename=nodePath["normalize"](filename);var ret=nodeFS["readFileSync"](filename);return binary?ret:ret.toString()};Module["readBinary"]=function readBinary(filename){var ret=Module["read"](filename,true);if(!ret.buffer){ret=new Uint8Array(ret)}assert(ret.buffer);return ret};Module["load"]=function load(f){globalEval(read(f))};if(!Module["thisProgram"]){if(process["argv"].length>1){Module["thisProgram"]=process["argv"][1].replace(/\\/g,"/")}else{Module["thisProgram"]="unknown-program"}}Module["arguments"]=process["argv"].slice(2);if(typeof module!=="undefined"){module["exports"]=Module}process["on"]("uncaughtException",(function(ex){if(!(ex instanceof ExitStatus)){throw ex}}));Module["inspect"]=(function(){return"[Emscripten Module object]"})}else if(ENVIRONMENT_IS_SHELL){if(!Module["print"])Module["print"]=print;if(typeof printErr!="undefined")Module["printErr"]=printErr;if(typeof read!="undefined"){Module["read"]=read}else{Module["read"]=function read(){throw"no read() available"}}Module["readBinary"]=function readBinary(f){if(typeof readbuffer==="function"){return new Uint8Array(readbuffer(f))}var data=read(f,"binary");assert(typeof data==="object");return data};if(typeof scriptArgs!="undefined"){Module["arguments"]=scriptArgs}else if(typeof arguments!="undefined"){Module["arguments"]=arguments}}else if(ENVIRONMENT_IS_WEB||ENVIRONMENT_IS_WORKER){Module["read"]=function read(url){var xhr=new XMLHttpRequest;xhr.open("GET",url,false);xhr.send(null);return xhr.responseText};Module["readAsync"]=function readAsync(url,onload,onerror){var xhr=new XMLHttpRequest;xhr.open("GET",url,true);xhr.responseType="arraybuffer";xhr.onload=function xhr_onload(){if(xhr.status==200||xhr.status==0&&xhr.response){onload(xhr.response)}else{onerror()}};xhr.onerror=onerror;xhr.send(null)};if(typeof arguments!="undefined"){Module["arguments"]=arguments}if(typeof console!=="undefined"){if(!Module["print"])Module["print"]=function print(x){console.log(x)};if(!Module["printErr"])Module["printErr"]=function printErr(x){console.warn(x)}}else{var TRY_USE_DUMP=false;if(!Module["print"])Module["print"]=TRY_USE_DUMP&&typeof dump!=="undefined"?(function(x){dump(x)}):(function(x){})}if(ENVIRONMENT_IS_WORKER){Module["load"]=importScripts}if(typeof Module["setWindowTitle"]==="undefined"){Module["setWindowTitle"]=(function(title){document.title=title})}}else{throw"Unknown runtime environment. Where are we?"}function globalEval(x){eval.call(null,x)}if(!Module["load"]&&Module["read"]){Module["load"]=function load(f){globalEval(Module["read"](f))}}if(!Module["print"]){Module["print"]=(function(){})}if(!Module["printErr"]){Module["printErr"]=Module["print"]}if(!Module["arguments"]){Module["arguments"]=[]}if(!Module["thisProgram"]){Module["thisProgram"]="./this.program"}Module.print=Modul
|
||
|
var asm=(function(global,env,buffer) {
|
||
|
"use asm";var a=new global.Int8Array(buffer);var b=new global.Int16Array(buffer);var c=new global.Int32Array(buffer);var d=new global.Uint8Array(buffer);var e=new global.Uint16Array(buffer);var f=new global.Uint32Array(buffer);var g=new global.Float32Array(buffer);var h=new global.Float64Array(buffer);var i=env.STACKTOP|0;var j=env.STACK_MAX|0;var k=env.DYNAMICTOP_PTR|0;var l=env.tempDoublePtr|0;var m=env.ABORT|0;var n=env.cttz_i8|0;var o=0;var p=0;var q=0;var r=0;var s=global.NaN,t=global.Infinity;var u=0,v=0,w=0,x=0,y=0.0,z=0,A=0,B=0,C=0.0;var D=0;var E=global.Math.floor;var F=global.Math.abs;var G=global.Math.sqrt;var H=global.Math.pow;var I=global.Math.cos;var J=global.Math.sin;var K=global.Math.tan;var L=global.Math.acos;var M=global.Math.asin;var N=global.Math.atan;var O=global.Math.atan2;var P=global.Math.exp;var Q=global.Math.log;var R=global.Math.ceil;var S=global.Math.imul;var T=global.Math.min;var U=global.Math.max;var V=global.Math.clz32;var W=env.abort;var X=env.assert;var Y=env.enlargeMemory;var Z=env.getTotalMemory;var _=env.abortOnCannotGrowMemory;var $=env.invoke_iiii;var aa=env.invoke_vi;var ba=env.invoke_ii;var ca=env.invoke_viii;var da=env.invoke_iiiiiiiii;var ea=env.invoke_iiiii;var fa=env.invoke_iii;var ga=env.invoke_viiii;var ha=env._pthread_cleanup_pop;var ia=env.___lock;var ja=env._abort;var ka=env.___setErrNo;var la=env.___syscall6;var ma=env.___syscall140;var na=env._pthread_cleanup_push;var oa=env._emscripten_memcpy_big;var pa=env.___syscall54;var qa=env.___unlock;var ra=env.___syscall146;var sa=0.0;
|
||
|
// EMSCRIPTEN_START_FUNCS
|
||
|
function Jc(b,e,f){b=b|0;e=e|0;f=f|0;var j=0,k=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0,T=0,U=0,V=0,W=0,X=0,Y=0,Z=0,_=0,$=0,aa=0,ba=0,ca=0,da=0,ea=0,fa=0,ga=0,ha=0,ia=0,ja=0,ka=0,la=0,ma=0,na=0,oa=0,pa=0,qa=0,ra=0,sa=0,ta=0,ua=0,wa=0,xa=0,ya=0,za=0,Aa=0,Ba=0,Ca=0,Da=0,Ea=0,Fa=0,Ga=0,Ha=0,Ia=0,Ja=0,Ka=0,La=0,Ma=0,Na=0,Oa=0,Pa=0,Qa=0,Ra=0,Sa=0,Ta=0,Ua=0,Wa=0,Ya=0,Za=0,$a=0,bb=0,db=0,eb=0,fb=0,gb=0,hb=0,ib=0,jb=0,kb=0,lb=0,mb=0,ob=0,pb=0,sb=0,tb=0,ub=0,vb=0,wb=0,xb=0,yb=0,zb=0,Ab=0,Bb=0,Cb=0,Db=0,Eb=0,Fb=0,Gb=0,Hb=0,Ib=0,Jb=0,Kb=0,Lb=0,Mb=0,Nb=0,Ob=0,Pb=0,Qb=0,Rb=0,Sb=0,Tb=0,Ub=0,Vb=0,Wb=0,Xb=0,Yb=0,Zb=0,_b=0,$b=0,ac=0,bc=0,cc=0,dc=0,ec=0,fc=0,gc=0,hc=0,ic=0,jc=0,kc=0,lc=0,mc=0,nc=0;nc=i;i=i+1216|0;mc=nc+1200|0;lc=nc+1192|0;kc=nc+1184|0;jc=nc+1176|0;Xb=nc+1168|0;Wb=nc+1160|0;ic=nc+1152|0;hc=nc+1144|0;Vb=nc+1136|0;Ub=nc+1128|0;Tb=nc+1120|0;Sb=nc+1112|0;Rb=nc+1104|0;Qb=nc+1096|0;Pb=nc+1088|0;Ob=nc+1080|0;Hb=nc+1072|0;Gb=nc+1064|0;Nb=nc+1056|0;Mb=nc+1048|0;Fb=nc+1040|0;Eb=nc+1032|0;Db=nc+1024|0;Cb=nc+1016|0;Bb=nc+1008|0;ac=nc+1e3|0;Ab=nc+992|0;zb=nc+984|0;yb=nc+976|0;xb=nc+968|0;wb=nc+960|0;$b=nc+952|0;_b=nc+944|0;vb=nc+936|0;ub=nc+928|0;tb=nc+920|0;sb=nc+912|0;cc=nc+904|0;bc=nc+896|0;Zb=nc+888|0;Yb=nc+880|0;pb=nc+872|0;Lb=nc+864|0;Kb=nc+856|0;ec=nc+848|0;dc=nc+840|0;Jb=nc+832|0;Ib=nc+824|0;ob=nc+816|0;mb=nc+808|0;Za=nc+800|0;Ya=nc+792|0;bb=nc+784|0;$a=nc+776|0;gc=nc+768|0;fc=nc+760|0;lb=nc+752|0;kb=nc+744|0;hb=nc+736|0;gb=nc+728|0;Wa=nc+720|0;Ua=nc+712|0;Ta=nc+704|0;Sa=nc+696|0;fb=nc+688|0;eb=nc+680|0;Ra=nc+672|0;Qa=nc+664|0;ib=nc+656|0;db=nc+648|0;Pa=nc+640|0;za=nc+632|0;ya=nc+624|0;xa=nc+616|0;wa=nc+608|0;Ma=nc+600|0;La=nc+592|0;Ga=nc+584|0;Fa=nc+576|0;ua=nc+568|0;ta=nc+560|0;sa=nc+552|0;ra=nc+544|0;qa=nc+536|0;pa=nc+528|0;Oa=nc+520|0;Na=nc+512|0;Ka=nc+504|0;Ja=nc+496|0;Ea=nc+488|0;Da=nc+480|0;oa=nc+472|0;na=nc+464|0;Ia=nc+456|0;Ha=nc+448|0;Ca=nc+440|0;Ba=nc+432|0;ma=nc+424|0;la=nc+416|0;ka=nc+408|0;ja=nc+400|0;ia=nc+392|0;ha=nc+384|0;ga=nc+376|0;fa=nc+368|0;ea=nc+360|0;da=nc+352|0;Aa=nc+344|0;ca=nc+336|0;Y=nc+328|0;X=nc+320|0;W=nc+312|0;V=nc+304|0;U=nc+296|0;T=nc+288|0;S=nc+280|0;aa=nc+272|0;ba=nc+264|0;$=nc+256|0;_=nc+248|0;Z=nc+240|0;P=nc+232|0;O=nc+224|0;N=nc+216|0;L=nc+208|0;J=nc+200|0;M=nc+192|0;K=nc+184|0;I=nc+176|0;H=nc+168|0;G=nc+160|0;F=nc+152|0;E=nc+144|0;C=nc+136|0;B=nc+128|0;A=nc+120|0;z=nc+112|0;y=nc+104|0;x=nc+96|0;w=nc+88|0;v=nc+80|0;u=nc+72|0;t=nc+64|0;s=nc+56|0;r=nc+48|0;q=nc+40|0;p=nc+32|0;o=nc+24|0;n=nc+16|0;m=nc+8|0;k=nc;R=c[160216+((Va(b)|0)<<2)>>2]|0;jb=c[171376+((Va(b)|0)<<2)>>2]|0;qb(e,351917+(R&4095)+-1|0);a:do switch(R>>>12&31){case 28:{if(ab(Xa(b,1)|0)|0?(qb(e,351891),c[(c[b+800>>2]|0)+64>>2]|0):0)a[(c[(c[b+784>>2]|0)+228>>2]|0)+72>>0]=1;break}case 1:{if(ab(Xa(b,5)|0)|0?(qb(e,351891),c[(c[b+800>>2]|0)+64>>2]|0):0)a[(c[(c[b+784>>2]|0)+228>>2]|0)+72>>0]=1;k=cb(Xa(b,3)|0)|0;do switch(k|0){case 15:{qb(e,351840);if(!(c[(c[b+800>>2]|0)+64>>2]|0))break a;c[(c[(c[b+784>>2]|0)+228>>2]|0)+68>>2]=0;break a}case 14:break;case 0:{j=351885;Q=22;break}case 1:{j=351882;Q=22;break}case 2:{j=351879;Q=22;break}case 3:{j=351876;Q=22;break}case 4:{j=351873;Q=22;break}case 5:{j=351870;Q=22;break}case 6:{j=351867;Q=22;break}case 7:{j=351864;Q=22;break}case 8:{j=351861;Q=22;break}case 9:{j=351858;Q=22;break}case 10:{j=351855;Q=22;break}case 11:{j=351852;Q=22;break}case 12:{j=351849;Q=22;break}case 13:{j=351846;Q=22;break}default:{j=362381;Q=22}}while(0);if((Q|0)==22)qb(e,j);if(c[(c[b+800>>2]|0)+64>>2]|0)c[(c[(c[b+784>>2]|0)+228>>2]|0)+68>>2]=k+1;break}case 2:{if(ab(Xa(b,6)|0)|0?(qb(e,351891),c[(c[b+800>>2]|0)+64>>2]|0):0)a[(c[(c[b+784>>2]|0)+228>>2]|0)+72>>0]=1;k=cb(Xa(b,4)|0)|0;do switch(k|0){case 15:{qb(e,351840);if(!(c[(c[b+800>>2]|0)+64>>2]|0))break a;c[(c[(c[b+784>>2]|0)+228>>2]|0)+68>>2]=0;break a}case 14:break;case 0:{j=351885;Q=45;break}case 1:{j=351882;Q=45;break}case 2:{j=351879;Q=45;break}case 3:{j=351876;Q=45;break}case 4:{j=351873;Q=45;break}case 5:{j=351870;Q=45;break}case 6:{j=351867;Q=45;break}case 7:{j=351864;Q=45;
|
||
|
function Ba(a){a=a|0;var b=0;b=i;i=i+a|0;i=i+15&-16;return b|0}function Ca(){return i|0}function Da(a){a=a|0;i=a}function Ea(a,b){a=a|0;b=b|0;i=a;j=b}function Fa(a,b){a=a|0;b=b|0;if(!o){o=a;p=b}}function Ga(a){a=a|0;D=a}function Ha(){return D|0}function Ia(b,d,e){b=b|0;d=d|0;e=e|0;var f=0,g=0;if(!((c[33470]|0)!=0&(c[33471]|0)!=0&(c[33472]|0)!=0&(c[33473]|0)!=0&(c[33474]|0)!=0)){g=8;return g|0}if(!(a[362380]|0)){vd();a[362380]=1}if(b>>>0<8?(f=361736+(b<<2)|0,c[f>>2]|0):0){g=za[c[33471]&7](1,104)|0;if(!g){g=1;return g|0}c[g+48>>2]=0;c[g>>2]=b;c[g+4>>2]=d;a[g+24>>0]=d>>>31;c[g+64>>2]=0;c[g+88>>2]=301798;b=va[c[f>>2]&7](g)|0;if(!b){c[e>>2]=g;g=0;return g|0}else{ua[c[33473]&3](g);c[e>>2]=0;g=b;return g|0}}c[e>>2]=0;g=2;return g|0}function Ja(a){a=a|0;var b=0,d=0,e=0;b=c[a>>2]|0;if(!b){a=4;return a|0}d=b;e=c[d+12>>2]|0;if(e|0)ua[c[33473]&3](e);ua[c[33473]&3](c[d+76>>2]|0);d=b;b=d;e=b+104|0;do{c[b>>2]=0;b=b+4|0}while((b|0)<(e|0));ua[c[33473]&3](d);c[a>>2]=0;a=0;return a|0}function Ka(b,d,e){b=b|0;d=d|0;e=e|0;var f=0;if(!(a[362380]|0)){vd();a[362380]=1}if((d|0)==4){f=e;c[33470]=c[e>>2];c[33471]=c[f+4>>2];c[33472]=c[f+8>>2];c[33473]=c[f+12>>2];c[33474]=c[f+16>>2];f=0;return f|0}f=b;if(!b){f=4;return f|0}switch(d|0){case 2:{c[f+64>>2]=e;f=0;return f|0}case 5:{e=(e|0)==3;a[f+84>>0]=e&1;if(!e){f=0;return f|0}d=f+85|0;if(a[d>>0]|0){f=0;return f|0}switch(c[f>>2]|0){case 0:{b=((c[f+4>>2]&16)>>>3^2)+2<<24>>24;break}case 5:case 4:case 2:case 1:{b=4;break}case 6:{b=2;break}case 3:{b=1;break}case 7:{b=2;break}default:b=-1}a[d>>0]=b;f=0;return f|0}case 6:{if(!e){f=0;return f|0}f=f+88|0;c[f>>2]=c[e>>2];c[f+4>>2]=c[e+4>>2];c[f+8>>2]=c[e+8>>2];f=0;return f|0}default:{f=ta[c[361768+(c[f>>2]<<2)>>2]&7](f,d,e)|0;return f|0}}return 0}function La(f,g,h,j,k,l,m){f=f|0;g=g|0;h=h|0;j=j|0;k=k|0;l=l|0;m=m|0;var n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,T=0,U=0,V=0,W=0,X=0,Y=0,Z=0,_=0,$=0,aa=0;aa=i;i=i+1360|0;Y=aa+824|0;X=aa+816|0;U=aa;V=aa+1344|0;W=aa+828|0;Z=f;if(!f){m=0;i=aa;return m|0}$=Z+48|0;c[$>>2]=0;if(!(c[Z>>2]|0))c[Z+60>>2]=0;C=(l|0)!=0;p=(l+-1|0)>>>0<32?l:32;r=p*232|0;o=va[c[33470]&7](r)|0;if(!o){c[$>>2]=1;m=0;i=aa;return m|0}if(h){E=U+800|0;F=U+792|0;G=Z+64|0;H=U+784|0;I=Z+16|0;J=Z+20|0;K=Z+40|0;L=U+8|0;M=Z+8|0;N=Z+12|0;O=Z+44|0;P=Z+84|0;Q=Z+92|0;R=Z+88|0;T=Z+96|0;A=g;B=h;n=o;x=o;o=0;q=0;y=j;z=k;while(1){Qa(U);c[E>>2]=Z;w=F;c[w>>2]=y;c[w+4>>2]=z;if(!(c[G>>2]|0))c[x+228>>2]=0;else c[x+228>>2]=va[c[33470]&7](1528)|0;c[H>>2]=x;u=x+8|0;w=u;c[w>>2]=y;c[w+4>>2]=z;if(xa[c[I>>2]&3](f,A,B,U,V,y,z,c[J>>2]|0)|0){pb(W);b[(c[H>>2]|0)+16>>1]=b[V>>1]|0;wa[c[K>>2]&3](Z,x,c[L>>2]|0);wa[c[M>>2]&3](U,W,c[N>>2]|0);s=c[O>>2]|0;w=x+16|0;t=b[w>>1]|0;v=(t&65535)>16?16:t;u=v&65535;ue(x+18|0,A+(t&65535)+(0-u)|0,u|0)|0;b[w>>1]=v;if(Wa(U)|0)c[x>>2]=Wa(U)|0;if(s|0)Aa[s&1](f,x,W,U);s=W;u=x+34|0;a:while(1){t=a[s>>0]|0;switch(t<<24>>24){case 9:case 32:case 0:break a;case 124:{a[s>>0]=32;t=32;break}default:{}}a[u>>0]=t;s=s+1|0;u=u+1|0}a[u>>0]=0;if(!(t<<24>>24))a[x+66>>0]=0;else{b:while(1){s=s+1|0;switch(a[s>>0]|0){case 9:case 32:break;default:break b}}Yd(x+66|0,s,159)|0;a[x+225>>0]=0}s=e[V>>1]|0}else{if(c[G>>2]|0)ua[c[33473]&3](c[x+228>>2]|0);s=b[P>>1]|0;if(!((s&255)<<24>>24))break;s=(s&65535)>>>8&65535;if(s>>>0>B>>>0)break;t=c[Q>>2]|0;if(t){s=ke(y|0,z|0,j|0,k|0)|0;s=ya[t&1](g,h,s,c[T>>2]|0)|0;if(!(s>>>0<=B>>>0&(s|0)!=0))break}c[x>>2]=0;t=u;c[t>>2]=y;c[t+4>>2]=z;b[x+16>>1]=s;ue(x+18|0,A|0,s|0)|0;Yd(x+34|0,c[R>>2]|0,31)|0;t=x+66|0;c:do if(s){c[X>>2]=d[A>>0];t=ub(t,160,301804,X)|0;if((s|0)!=1){v=1;w=x+66+t|0;t=160-t|0;while(1){c[Y>>2]=d[A+v>>0];u=ub(w,t,301811,Y)|0;if((u|0)<0|u>>>0>(t+-1|0)>>>0)break c;v=v+1|0;if(v>>>0>=s>>>0)break;else{w=w+u|0;t=t-u|0}}}}else a[t>>0]=0;while(0);c[x+228>>2]=0}o=o+1|0;q=q+1|0;if(C&(q|0)==(l|0)){q=l;break}if((o|0)==(p|0)){p=(p<<3>>>0)/5|0;r=(p*232|0)+r|0;t=za[c[33472]&7](n,r)|0;if(!t){_=41;break}n=t;o=0;t=t+(q*232|0)|0}else t=x+232|0;B=B-s|0;y=le(s|0,0,y|0,z|0)|0;if(!B)break;else{A=A+s|0;x=t;z=D}}if((_|0)==41){if(!((c[G>>2]|0)==0|(q|0)==0)){o=0;p=n;while(1){ua[c[33473
|
||
|
function mc(a,c){a=a|0;c=c|0;var d=0,f=0,g=0;d=c>>>12&15|c>>>18&16;f=c&15;g=(c>>>5&1)+1|0;fb(a,e[199750+(d<<1)>>1]|0);fb(a,e[199750+((d+g&31)<<1)>>1]|0);fb(a,e[199750+(((g<<1)+d&31)<<1)>>1]|0);d=(f|0)!=15;c=b[199718+((c>>>16&15)<<1)>>1]|0;if(d)fb(a,c&65535);fb(a,c&65535);hb(a,0,0);if((f|0)==13){fb(a,0);return 3}if(!d)return 3;fb(a,e[199718+(f<<1)>>1]|0);return 3}function nc(a,c){a=a|0;c=c|0;var d=0,f=0,g=0,h=0,i=0,j=0;h=c>>>12&15|c>>>18&16;i=c>>>16&15;j=c&15;d=c>>>6;g=(c>>>5&1)+1|0;c=c>>>4&1;switch(d&3){case 3:{if(!c){j=0;return j|0}else f=16;break}case 2:{f=c<<3;break}default:f=4<<(d&3)&0-c}fb(a,e[199750+(h<<1)>>1]|0);fb(a,e[199750+((h+g&31)<<1)>>1]|0);fb(a,e[199750+(((g<<1)+h&31)<<1)>>1]|0);fb(a,e[199750+(((g*3|0)+h&31)<<1)>>1]|0);d=(j|0)!=15;c=b[199718+(i<<1)>>1]|0;if(d)fb(a,c&65535);fb(a,c&65535);hb(a,f,0);if((j|0)==13){fb(a,0);j=3;return j|0}if(!d){j=3;return j|0}fb(a,e[199718+(j<<1)>>1]|0);j=3;return j|0}function oc(a,b){a=a|0;b=b|0;if((Va(a)|0)==2689){b=b&65535;b=e[199718+((b>>>4&8|b&7)<<1)>>1]|0;fb(a,b);fb(a,12);fb(a,b);return 3}if((Va(a)|0)!=2693)return 3;fb(a,12);fb(a,12);fb(a,e[199718+(((b&65535)>>>3&15)<<1)>>1]|0);return 3}function pc(a,b){a=a|0;b=b|0;var c=0,d=0,f=0,g=0,h=0,i=0;c=b>>>12&15;d=b>>>8&15;f=b>>>16&15;h=b&255;g=b>>>15&256;if(!(b>>>24&1^1|b>>>21&1))b=3;else b=(f|0)==(c|0)|(f|0)==(d|0)?1:3;i=e[199718+(f<<1)>>1]|0;fb(a,i);fb(a,e[199718+(c<<1)>>1]|0);fb(a,e[199718+(d<<1)>>1]|0);b=(d|2|0)==15|((c|2|0)==15|(f|2|0)==15)?1:b;fb(a,i);if(!(g|h)){hb(a,-2147483648,-1);return b|0}else{i=((g|0)==0?0-h|0:h)<<2;hb(a,i,((i|0)<0)<<31>>31);return b|0}return 0}function qc(a,b){a=a|0;b=b|0;var c=0,d=0,f=0,g=0,h=0,i=0;c=b>>>12&15;d=b>>>8&15;f=b>>>16&15;h=b&255;g=b>>>15&256;if(!(b>>>24&1^1|b>>>21&1))b=3;else b=(f|0)==(c|0)|(f|0)==(d|0)?1:3;fb(a,e[199718+(c<<1)>>1]|0);fb(a,e[199718+(d<<1)>>1]|0);i=e[199718+(f<<1)>>1]|0;fb(a,i);b=(f|2|0)==15|((d|2|0)==15|((c|0)==(d|0)|(c|2|0)==15))?1:b;fb(a,i);if(!(g|h)){hb(a,-2147483648,-1);return b|0}else{i=((g|0)==0?0-h|0:h)<<2;hb(a,i,((i|0)<0)<<31>>31);return b|0}return 0}function rc(a,b){a=a|0;b=b|0;var c=0,d=0;if(b&3072|0){d=b&127|128;c=b>>>7;hb(a,d>>>(c&31)|d<<(0-c&31),0);return}c=b&255;switch(b>>>8&3){case 0:{hb(a,c,0);return}case 1:{hb(a,c<<16|c,0);return}case 2:{hb(a,c<<8|b<<24,0);return}case 3:{hb(a,c|b<<24|c<<16|c<<8,0);return}default:{}}}function sc(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,f=0,g=0;e=b>>>9&3;f=b>>>5&7;g=b&31;if((e|0)==1){a=0;return a|0}c=(b&256|0)!=0;if(c&(e|0)!=0){Ta(a,2321);hb(a,e,0);hb(a,f,0);hb(a,g,0);a=3;return a|0}d=(e|0)==0;if(!(c|d)){Ta(a,2320);hb(a,e,0);hb(a,f,0);a=(g|0)==0?3:1;return a|0}if(c&d){Ta(a,2319);hb(a,g,0);return ((f|0)==0?3:1)|0}b=b&255;if(b>>>0>4){a=0;return a|0}Ta(a,2337);hb(a,b,0);a=3;return a|0}function tc(a,b){a=a|0;b=b|0;var c=0;c=b>>>22&15;if((c|1|0)==15){switch(b>>>4&268435455|0){case 255588596:{Ta(a,2333);break}case 255588597:{Ta(a,2332);break}case 255588598:{Ta(a,2338);break}default:{c=0;return c|0}}hb(a,b&15,0);c=3;return c|0}b=(b<<1&4094|b<<8&524288|b<<5&262144|b>>>4&258048|b>>>6&1048576)<<11>>11;hb(a,b,((b|0)<0)<<31>>31);if((c|0)==15){c=0;return c|0}b=(c|0)==14;if(b&(Va(a)|0)==2712){c=0;return c|0}hb(a,c,0);if(b){fb(a,0);c=3;return c|0}else{fb(a,3);c=3;return c|0}return 0}function uc(a,c){a=a|0;c=c|0;var d=0,f=0,g=0,h=0;f=c>>>12&15;g=c>>>16&15;h=c&255;d=c>>>1&256;if((g|0)!=15){if(!(c&1048576)){c=b[199718+(g<<1)>>1]|0;fb(a,c&65535);fb(a,e[199718+(f<<1)>>1]|0)}else{fb(a,e[199718+(f<<1)>>1]|0);c=b[199718+(g<<1)>>1]|0;fb(a,c&65535)}Va(a)|0;switch(Va(a)|0){case 2613:case 2599:case 2620:case 2401:case 2393:case 2385:case 2370:case 2409:{d=256;break}default:{}}fb(a,c&65535);g=(d|h|0)==0;h=(d|0)==0?0-h|0:h;hb(a,g?-2147483648:h,g?-1:((h|0)<0)<<31>>31);h=3;return h|0}a:do switch(Va(a)|0){case 2410:case 2411:{Ta(a,2414);break}case 2371:case 2372:{Ta(a,2375);break}case 2386:case 2387:{Ta(a,2390);break}case 2394:case 2395:if((f|0)==15){Ta(a,2483);break a}else{Ta(a,2398);break a}case 2402:case 2403:{Ta(a,2406);break}default:{h=0;return h|0}}while(0);h=zc(a,c)|0;return h|0}function vc(a,b){a=a|0;b=b|0;var c=0,d=0;c=b>>>12&15;d=b>>>16&15;if((d|0)!=1
|
||
|
function Ld(e,f,g,j,k){e=e|0;f=f|0;g=g|0;j=j|0;k=k|0;var m=0,n=0,o=0,p=0,q=0.0,r=0,s=0,t=0,u=0,v=0.0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,T=0,U=0,V=0,W=0,X=0,Y=0,Z=0,_=0,$=0,aa=0,ba=0,ca=0,da=0,ea=0,fa=0,ga=0,ha=0,ia=0,ja=0;ja=i;i=i+624|0;fa=ja+24|0;ga=ja+16|0;ha=ja+588|0;Y=ja+576|0;ia=ja;T=ja+536|0;N=ja+8|0;O=ja+528|0;P=(e|0)!=0;Q=T+40|0;R=Q;T=T+39|0;U=N+4|0;V=ha;W=0-V|0;X=Y+12|0;Y=Y+11|0;Z=X;_=Z-V|0;$=-2-V|0;aa=Z+2|0;ba=fa+288|0;ca=ha+9|0;da=ca;ea=ha+8|0;n=0;m=0;s=0;a:while(1){do if((m|0)>-1)if((n|0)>(2147483647-m|0)){c[(Dd()|0)>>2]=75;m=-1;break}else{m=n+m|0;break}while(0);n=a[f>>0]|0;if(!(n<<24>>24)){M=243;break}else o=f;b:while(1){switch(n<<24>>24){case 37:{n=o;M=9;break b}case 0:{n=o;break b}default:{}}n=o+1|0;o=n;n=a[n>>0]|0}c:do if((M|0)==9)while(1){M=0;if((a[o+1>>0]|0)!=37)break c;n=n+1|0;o=o+2|0;if((a[o>>0]|0)==37)M=9;else break}while(0);n=n-f|0;if(P?(c[e>>2]&32|0)==0:0)Nd(f,n,e)|0;if(n|0){f=o;continue}r=o+1|0;p=a[r>>0]|0;n=(p<<24>>24)+-48|0;if(n>>>0<10){u=(a[o+2>>0]|0)==36;r=u?o+3|0:r;w=u?n:-1;u=u?1:s;n=a[r>>0]|0}else{w=-1;u=s;n=p}o=(n<<24>>24)+-32|0;d:do if(o>>>0<32){p=0;do{if(!(1<<o&75913))break d;p=1<<(n<<24>>24)+-32|p;r=r+1|0;n=a[r>>0]|0;o=(n<<24>>24)+-32|0}while(o>>>0<32)}else p=0;while(0);do if(n<<24>>24!=42){o=(n<<24>>24)+-48|0;if(o>>>0<10){s=0;do{s=(s*10|0)+o|0;r=r+1|0;n=a[r>>0]|0;o=(n<<24>>24)+-48|0}while(o>>>0<10);if((s|0)<0){m=-1;break a}else L=u}else{s=0;L=u}}else{t=r+1|0;n=a[t>>0]|0;o=(n<<24>>24)+-48|0;if(o>>>0<10?(a[r+2>>0]|0)==36:0){c[k+(o<<2)>>2]=10;n=c[j+((a[t>>0]|0)+-48<<3)>>2]|0;o=1;t=r+3|0}else{if(u|0){m=-1;break a}if(!P){s=0;L=0;r=t;break}o=(c[g>>2]|0)+(4-1)&~(4-1);n=c[o>>2]|0;c[g>>2]=o+4;o=0}L=(n|0)<0;s=L?0-n|0:n;p=L?p|8192:p;L=o;r=t;n=a[t>>0]|0}while(0);e:do if(n<<24>>24==46){n=r+1|0;o=a[n>>0]|0;if(o<<24>>24!=42){r=(o<<24>>24)+-48|0;if(r>>>0<10)o=0;else{x=0;break}while(1){o=(o*10|0)+r|0;n=n+1|0;r=(a[n>>0]|0)+-48|0;if(r>>>0>=10){x=o;break e}}}n=r+2|0;o=(a[n>>0]|0)+-48|0;if(o>>>0<10?(a[r+3>>0]|0)==36:0){c[k+(o<<2)>>2]=10;x=c[j+((a[n>>0]|0)+-48<<3)>>2]|0;n=r+4|0;break}if(L|0){m=-1;break a}if(P){K=(c[g>>2]|0)+(4-1)&~(4-1);x=c[K>>2]|0;c[g>>2]=K+4}else x=0}else{x=-1;n=r}while(0);u=0;while(1){o=(a[n>>0]|0)+-65|0;if(o>>>0>57){m=-1;break a}K=n+1|0;o=a[359305+(u*58|0)+o>>0]|0;r=o&255;if((r+-1|0)>>>0<8){u=r;n=K}else break}if(!(o<<24>>24)){m=-1;break}t=(w|0)>-1;do if(o<<24>>24==19)if(t){m=-1;break a}else M=51;else{if(t){c[k+(w<<2)>>2]=r;I=j+(w<<3)|0;J=c[I+4>>2]|0;M=ia;c[M>>2]=c[I>>2];c[M+4>>2]=J;M=51;break}if(!P){m=0;break a}Od(ia,r,g)}while(0);if((M|0)==51?(M=0,!P):0){n=0;s=L;f=K;continue}F=a[n>>0]|0;F=(u|0)!=0&(F&15|0)==3?F&-33:F;t=p&-65537;J=(p&8192|0)==0?p:t;f:do switch(F|0){case 110:switch((u&255)<<24>>24){case 0:{c[c[ia>>2]>>2]=m;n=0;s=L;f=K;continue a}case 1:{c[c[ia>>2]>>2]=m;n=0;s=L;f=K;continue a}case 2:{n=c[ia>>2]|0;c[n>>2]=m;c[n+4>>2]=((m|0)<0)<<31>>31;n=0;s=L;f=K;continue a}case 3:{b[c[ia>>2]>>1]=m;n=0;s=L;f=K;continue a}case 4:{a[c[ia>>2]>>0]=m;n=0;s=L;f=K;continue a}case 6:{c[c[ia>>2]>>2]=m;n=0;s=L;f=K;continue a}case 7:{n=c[ia>>2]|0;c[n>>2]=m;c[n+4>>2]=((m|0)<0)<<31>>31;n=0;s=L;f=K;continue a}default:{n=0;s=L;f=K;continue a}}case 112:{t=120;u=x>>>0>8?x:8;n=J|8;M=63;break}case 88:case 120:{t=F;u=x;n=J;M=63;break}case 111:{o=ia;n=c[o>>2]|0;o=c[o+4>>2]|0;if((n|0)==0&(o|0)==0)f=Q;else{f=Q;do{f=f+-1|0;a[f>>0]=n&7|48;n=ne(n|0,o|0,3)|0;o=D}while(!((n|0)==0&(o|0)==0))}if(!(J&8)){o=0;p=359785;r=x;n=J;M=76}else{r=R-f|0;o=0;p=359785;r=(x|0)>(r|0)?x:r+1|0;n=J;M=76}break}case 105:case 100:{f=ia;n=c[f>>2]|0;f=c[f+4>>2]|0;if((f|0)<0){n=ke(0,0,n|0,f|0)|0;f=D;o=ia;c[o>>2]=n;c[o+4>>2]=f;o=1;p=359785;M=75;break f}if(!(J&2048)){p=J&1;o=p;p=(p|0)==0?359785:359787;M=75}else{o=1;p=359786;M=75}break}case 117:{f=ia;o=0;p=359785;n=c[f>>2]|0;f=c[f+4>>2]|0;M=75;break}case 99:{a[T>>0]=c[ia>>2];f=T;w=0;u=359785;o=Q;n=1;break}case 109:{n=Qd(c[(Dd()|0)>>2]|0)|0;M=81;break}case 115:{n=c[ia>>2]|0;n=n|0?n:359795;M=81;break}case 67:{c[N>>2]=c[ia>>2];c[U>>2]=0;c[ia>>2]=N;t=-1;o=N;M=85;break}case 83:{n=c[ia>>2]|0;if(!x){Rd(e,32,s,0,J);n=0;M=96}else{t=x;o=n;M=85}break}case 65
|
||
|
|
||
|
// EMSCRIPTEN_END_FUNCS
|
||
|
var ta=[Ee,Ad,Bd,Xd,xd,Ed,Ee,Ee];var ua=[Fe,ee,yd,Fd];var va=[Ge,de,zd,Gc,Fc,wd,Ge,Ge];var wa=[He,Ic,qd,He];var xa=[Ie,xb,Dc,Ie];var ya=[Je,Jd];var za=[Ke,fe,ge,od,pd,rd,sd,Ke];var Aa=[Le,Hc];return{_cs_insn_name:Oa,_llvm_cttz_i32:pe,_bitshift64Lshr:ne,_bitshift64Shl:oe,_fflush:$d,_memset:me,_sbrk:te,_memcpy:ue,___uremdi3:re,_i64Subtract:ke,___udivmoddi4:qe,_i64Add:le,_pthread_self:ve,_cs_disasm:La,_free:ee,___udivdi3:se,_cs_option:Ka,___errno_location:Dd,_cs_reg_name:Na,_cs_close:Ja,_cs_open:Ia,_cs_free:Ma,_malloc:de,runPostSets:je,stackAlloc:Ba,stackSave:Ca,stackRestore:Da,establishStackSpace:Ea,setThrew:Fa,setTempRet0:Ga,getTempRet0:Ha,dynCall_iiii:we,dynCall_vi:xe,dynCall_ii:ye,dynCall_viii:ze,dynCall_iiiiiiiii:Ae,dynCall_iiiii:Be,dynCall_iii:Ce,dynCall_viiii:De}})
|
||
|
|
||
|
|
||
|
// EMSCRIPTEN_END_ASM
|
||
|
(Module.asmGlobalArg,Module.asmLibraryArg,buffer);var _cs_insn_name=Module["_cs_insn_name"]=asm["_cs_insn_name"];var _llvm_cttz_i32=Module["_llvm_cttz_i32"]=asm["_llvm_cttz_i32"];var _bitshift64Lshr=Module["_bitshift64Lshr"]=asm["_bitshift64Lshr"];var _bitshift64Shl=Module["_bitshift64Shl"]=asm["_bitshift64Shl"];var _fflush=Module["_fflush"]=asm["_fflush"];var _memset=Module["_memset"]=asm["_memset"];var _sbrk=Module["_sbrk"]=asm["_sbrk"];var _memcpy=Module["_memcpy"]=asm["_memcpy"];var ___uremdi3=Module["___uremdi3"]=asm["___uremdi3"];var _i64Subtract=Module["_i64Subtract"]=asm["_i64Subtract"];var ___udivmoddi4=Module["___udivmoddi4"]=asm["___udivmoddi4"];var _i64Add=Module["_i64Add"]=asm["_i64Add"];var _pthread_self=Module["_pthread_self"]=asm["_pthread_self"];var _cs_disasm=Module["_cs_disasm"]=asm["_cs_disasm"];var _free=Module["_free"]=asm["_free"];var ___udivdi3=Module["___udivdi3"]=asm["___udivdi3"];var _cs_option=Module["_cs_option"]=asm["_cs_option"];var ___errno_location=Module["___errno_location"]=asm["___errno_location"];var _cs_reg_name=Module["_cs_reg_name"]=asm["_cs_reg_name"];var runPostSets=Module["runPostSets"]=asm["runPostSets"];var _cs_close=Module["_cs_close"]=asm["_cs_close"];var _cs_open=Module["_cs_open"]=asm["_cs_open"];var _cs_free=Module["_cs_free"]=asm["_cs_free"];var _malloc=Module["_malloc"]=asm["_malloc"];var dynCall_iiii=Module["dynCall_iiii"]=asm["dynCall_iiii"];var dynCall_vi=Module["dynCall_vi"]=asm["dynCall_vi"];var dynCall_ii=Module["dynCall_ii"]=asm["dynCall_ii"];var dynCall_viii=Module["dynCall_viii"]=asm["dynCall_viii"];var dynCall_iiiiiiiii=Module["dynCall_iiiiiiiii"]=asm["dynCall_iiiiiiiii"];var dynCall_iiiii=Module["dynCall_iiiii"]=asm["dynCall_iiiii"];var dynCall_iii=Module["dynCall_iii"]=asm["dynCall_iii"];var dynCall_viiii=Module["dynCall_viiii"]=asm["dynCall_viiii"];Runtime.stackAlloc=asm["stackAlloc"];Runtime.stackSave=asm["stackSave"];Runtime.stackRestore=asm["stackRestore"];Runtime.establishStackSpace=asm["establishStackSpace"];Runtime.setTempRet0=asm["setTempRet0"];Runtime.getTempRet0=asm["getTempRet0"];function ExitStatus(status){this.name="ExitStatus";this.message="Program terminated with exit("+status+")";this.status=status}ExitStatus.prototype=new Error;ExitStatus.prototype.constructor=ExitStatus;var initialStackTop;var preloadStartTime=null;var calledMain=false;dependenciesFulfilled=function runCaller(){if(!Module["calledRun"])run();if(!Module["calledRun"])dependenciesFulfilled=runCaller};Module["callMain"]=Module.callMain=function callMain(args){args=args||[];ensureInitRuntime();var argc=args.length+1;function pad(){for(var i=0;i<4-1;i++){argv.push(0)}}var argv=[allocate(intArrayFromString(Module["thisProgram"]),"i8",ALLOC_NORMAL)];pad();for(var i=0;i<argc-1;i=i+1){argv.push(allocate(intArrayFromString(args[i]),"i8",ALLOC_NORMAL));pad()}argv.push(0);argv=allocate(argv,"i32",ALLOC_NORMAL);try{var ret=Module["_main"](argc,argv,0);exit(ret,true)}catch(e){if(e instanceof ExitStatus){return}else if(e=="SimulateInfiniteLoop"){Module["noExitRuntime"]=true;return}else{if(e&&typeof e==="object"&&e.stack)Module.printErr("exception thrown: "+[e,e.stack]);throw e}}finally{calledMain=true}};function run(args){args=args||Module["arguments"];if(preloadStartTime===null)preloadStartTime=Date.now();if(runDependencies>0){return}preRun();if(runDependencies>0)return;if(Module["calledRun"])return;function doRun(){if(Module["calledRun"])return;Module["calledRun"]=true;if(ABORT)return;ensureInitRuntime();preMain();if(Module["onRuntimeInitialized"])Module["onRuntimeInitialized"]();if(Module["_main"]&&shouldRunNow)Module["callMain"](args);postRun()}if(Module["setStatus"]){Module["setStatus"]("Running...");setTimeout((function(){setTimeout((function(){Module["setStatus"]("")}),1);doRun()}),1)}else{doRun()}}Module["run"]=Module.run=run;function exit(status,implicit){if(implicit&&Module["noExitRuntime"]){return}if(Module["noExitRuntime"]){}else{ABORT=true;EXITSTATUS=status;STACKTOP=initialStackTop;exitRuntime();if(Module["onExit"])Module["onExit"](status)}if(ENVIRONMENT_IS_NODE){process["exit
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
return MCapstone;
|
||
|
};
|
||
|
|
||
|
/**
|
||
|
* (c) 2014-2017 Capstone.JS
|
||
|
* Wrapper made by Alexandro Sanchez Bach.
|
||
|
*/
|
||
|
|
||
|
// Emscripten demodularize
|
||
|
var MCapstone = new MCapstone();
|
||
|
|
||
|
var cs = {
|
||
|
// Return codes
|
||
|
ERR_OK: 0, // No error: everything was fine
|
||
|
ERR_MEM: 1, // Out-Of-Memory error: cs_open(), cs_disasm(), cs_disasm_iter()
|
||
|
ERR_ARCH: 2, // Unsupported architecture: cs_open()
|
||
|
ERR_HANDLE: 3, // Invalid handle: cs_op_count(), cs_op_index()
|
||
|
ERR_CSH: 4, // Invalid csh argument: cs_close(), cs_errno(), cs_option()
|
||
|
ERR_MODE: 5, // Invalid/unsupported mode: cs_open()
|
||
|
ERR_OPTION: 6, // Invalid/unsupported option: cs_option()
|
||
|
ERR_DETAIL: 7, // Information is unavailable because detail option is OFF
|
||
|
ERR_MEMSETUP: 8, // Dynamic memory management uninitialized (see OPT_MEM)
|
||
|
ERR_VERSION: 9, // Unsupported version (bindings)
|
||
|
ERR_DIET: 10, // Access irrelevant data in "diet" engine
|
||
|
ERR_SKIPDATA: 11, // Access irrelevant data for "data" instruction in SKIPDATA mode
|
||
|
ERR_X86_ATT: 12, // X86 AT&T syntax is unsupported (opt-out at compile time)
|
||
|
ERR_X86_INTEL: 13, // X86 Intel syntax is unsupported (opt-out at compile time)
|
||
|
|
||
|
// Architectures
|
||
|
ARCH_ARM: 0, // ARM architecture (including Thumb, Thumb-2)
|
||
|
ARCH_ARM64: 1, // ARM-64, also called AArch64
|
||
|
ARCH_MIPS: 2, // Mips architecture
|
||
|
ARCH_X86: 3, // X86 architecture (including x86 & x86-64)
|
||
|
ARCH_PPC: 4, // PowerPC architecture
|
||
|
ARCH_SPARC: 5, // Sparc architecture
|
||
|
ARCH_SYSZ: 6, // SystemZ architecture
|
||
|
ARCH_XCORE: 7, // XCore architecture
|
||
|
ARCH_MAX: 8,
|
||
|
ARCH_ALL: 0xFFFF,
|
||
|
|
||
|
// Modes
|
||
|
MODE_LITTLE_ENDIAN: 0, // Little-Endian mode (default mode)
|
||
|
MODE_ARM: 0, // 32-bit ARM
|
||
|
MODE_16: 1 << 1, // 16-bit mode (X86)
|
||
|
MODE_32: 1 << 2, // 32-bit mode (X86)
|
||
|
MODE_64: 1 << 3, // 64-bit mode (X86, PPC)
|
||
|
MODE_THUMB: 1 << 4, // ARM's Thumb mode, including Thumb-2
|
||
|
MODE_MCLASS: 1 << 5, // ARM's Cortex-M series
|
||
|
MODE_V8: 1 << 6, // ARMv8 A32 encodings for ARM
|
||
|
MODE_MICRO: 1 << 4, // MicroMips mode (MIPS)
|
||
|
MODE_MIPS3: 1 << 5, // Mips III ISA
|
||
|
MODE_MIPS32R6: 1 << 6, // Mips32r6 ISA
|
||
|
MODE_MIPSGP64: 1 << 7, // General Purpose Registers are 64-bit wide (MIPS)
|
||
|
MODE_V9: 1 << 4, // SparcV9 mode (Sparc)
|
||
|
MODE_BIG_ENDIAN: 1 << 31, // Big-Endian mode
|
||
|
MODE_MIPS32: 1 << 2, // Mips32 ISA (Mips)
|
||
|
MODE_MIPS64: 1 << 3, // Mips64 ISA (Mips)
|
||
|
|
||
|
/**
|
||
|
* Instruction object
|
||
|
*/
|
||
|
Instruction: function (pointer) {
|
||
|
// Instruction ID
|
||
|
this.id = MCapstone.getValue(pointer, 'i32');
|
||
|
|
||
|
// Address (EIP) of this instruction
|
||
|
this.address = MCapstone.getValue(pointer + 8, 'i64');
|
||
|
|
||
|
// Size of this instruction
|
||
|
this.size = MCapstone.getValue(pointer + 16, 'i16');
|
||
|
|
||
|
// Machine bytes of this instruction (length indicated by @size above)
|
||
|
this.bytes = [];
|
||
|
for (var i = 0; i < this.size; i++) {
|
||
|
var byteValue = MCapstone.getValue(pointer + 18 + i, 'i8');
|
||
|
if (byteValue < 0) {
|
||
|
byteValue = 256 + byteValue;
|
||
|
}
|
||
|
this.bytes.push(byteValue);
|
||
|
}
|
||
|
|
||
|
// ASCII representation of instruction mnemonic
|
||
|
this.mnemonic = MCapstone.Pointer_stringify(pointer + 34);
|
||
|
|
||
|
// ASCII representation of instruction operands
|
||
|
this.op_str = MCapstone.Pointer_stringify(pointer + 66);
|
||
|
},
|
||
|
|
||
|
/**
|
||
|
* Capstone object
|
||
|
*/
|
||
|
Capstone: function (arch, mode) {
|
||
|
this.arch = arch;
|
||
|
this.mode = mode;
|
||
|
this.handle_ptr = MCapstone._malloc(4);
|
||
|
|
||
|
// Destructor
|
||
|
this.delete = function () {
|
||
|
MCapstone._free(this.handle_ptr);
|
||
|
}
|
||
|
|
||
|
// Disassemble
|
||
|
this.disasm = function (buffer, addr, max) {
|
||
|
var handle = MCapstone.getValue(this.handle_ptr, 'i32');
|
||
|
|
||
|
// Allocate buffer and copy data
|
||
|
var buffer_ptr = MCapstone._malloc(buffer.length);
|
||
|
var buffer_heap = new Uint8Array(MCapstone.HEAPU8.buffer, buffer_ptr, buffer.length);
|
||
|
buffer_heap.set(new Uint8Array(buffer));
|
||
|
|
||
|
// Pointer to the instruction array
|
||
|
var insn_ptr_ptr = MCapstone._malloc(4);
|
||
|
|
||
|
var count = MCapstone.ccall('cs_disasm', 'number',
|
||
|
['number', 'pointer', 'number', 'number', 'number', 'pointer'],
|
||
|
[handle, buffer_heap.byteOffset, buffer_heap.length, addr, 0, max || 0, insn_ptr_ptr]
|
||
|
);
|
||
|
|
||
|
// Dereference intruction array
|
||
|
var insn_ptr = MCapstone.getValue(insn_ptr_ptr, 'i32');
|
||
|
var insn_size = 232;
|
||
|
var instructions = [];
|
||
|
|
||
|
// Save instructions
|
||
|
for (var i = 0; i < count; i++) {
|
||
|
instructions.push(new cs.Instruction(insn_ptr + i * insn_size));
|
||
|
}
|
||
|
|
||
|
var count = MCapstone.ccall('cs_free', 'void',
|
||
|
['pointer', 'number'],
|
||
|
[insn_ptr, count]
|
||
|
);
|
||
|
|
||
|
MCapstone._free(insn_ptr_ptr);
|
||
|
MCapstone._free(buffer_ptr);
|
||
|
return instructions;
|
||
|
};
|
||
|
|
||
|
// Constructor
|
||
|
var ret = MCapstone.ccall('cs_open', 'number',
|
||
|
['number', 'number', 'pointer'],
|
||
|
[this.arch, this.mode, this.handle_ptr]
|
||
|
);
|
||
|
|
||
|
if (ret != cs.ERR_OK) {
|
||
|
console.error('Capstone.js: Function cs_open failed with code %d.', ret);
|
||
|
}
|
||
|
},
|
||
|
};
|