-
Notifications
You must be signed in to change notification settings - Fork 0
/
sysmem.php
2134 lines (2109 loc) · 98.5 KB
/
sysmem.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<style>
.xreg-filtered{
color: black !important;
}
</style>
<div id='sysmem'>
<iframe name='dlframe' id='dlframe' src='blank.php' class='dl-frame ui-helper-hidden'></iframe>
<h2 align='right' class='tab-header'>System Manager <span class='header-tiny-text'>v1.3.1</span></h2>
<div id='treecontainer' class='fm-container'>
<table id='fmbox' class='window' style='min-height:600px !important;height:600px !important;'>
<tbody class=''>
<tr class='window-header ui-widget-header'>
<th class='logoptions window-header ui-widget-header '><div class='dir-table'><span class='dir-left header-normal-text'>CFW Compatible PS3: <span class='fmm-compat'><span id='cfwcompat'></span></span></span><span class='dir-center header-normal-text'></span><span id='spanmode' class='dir-right-fixed' title='Disabling SM Strict Mode is very risky.Patching checks & restrictions are disabled when SM Strict Mode is off.Use at your own risk!!!'><div class='switch-wrapper pointer' tabindex='0'><input type='checkbox' name='mode' id='admode' value='true' checked='true' ></div></span></div></th>
</tr>
<tr class='window-content-top ui-widget-content'>
<td align='justify' class='window-content-top ui-widget-content'>
<div id='fTree' class='fm-tree ui-widget-content with-y-scrollbar' style='min-height:550px !important;height:550px !important;'></div>
</td>
</tr>
<tr class='pl window-bottom-small'>
<td align='justify' class='window-bottom-small'>
<div class='sizer height-5px'>XXX</div>
</td>
</tr>
</tbody>
</table>
<br>
</div>
</div>
<script>
jQuery('.refresh-fm').removeClass('ui-state-disabled').addClass('ui-state-disabled');
var ft1 =null;
dl_object=null;
if(!helper.sm){
helper.sm = new sysmem();
}
if(!helper.worker['fmm']){
helper.worker['fmm'] = new workerThread('BGTOOLSET_WKR_FMM');
}
function initPatchData(){
helper.deletePatchData = function(){
var fpstr = helper.heap.store(helper.fm_tmpfile_path,true);
var fpstat = helper.heap.store(0x80);
if(stdc.stat(fpstr,fpstat)===0){
if(stdc.unlink(fpstr)===0){
Logger.info('SM: Deleted temporary patch file '+helper.fm_tmpfile_path);
}
else{
Logger.error('SM: Temporary patch file '+helper.fm_tmpfile_path+' deletion error');
}
}
helper.heap.free([fpstr,fpstat]);
};
helper.existPatchData = function(){
var fpstr = helper.heap.store(helper.fm_tmpfile_path,true);
var fpstat = helper.heap.store(0x80);
var exists = false;
if(stdc.stat(fpstr,fpstat)===0){
exists = true;
}
helper.heap.free([fpstr,fpstat]);
return exists;
};
helper.savePatchData=function(){
if(jQuery('#fTree').jstree(true).get_node('flashbk').children.length>0){
if(helper.sha256_loadedros === getSHA256hash(helper.rosBuffer.offset+0x30, helper.patchfile_size)){
var fp = new fileObject(helper.fm_tmpfile_path,helper.fs_flag_create_rw);
if(fp.save({'offset':helper.rosBuffer.offset+0x30,'size':helper.rosBuffer.size-0x30},helper.patchfile_size,null,null)!==0){
Logger.warn('Patch Data could not be saved to file');
}
fp.close();
}
}
};
helper.loadPatchData=function(){
if(jQuery('#fTree').jstree(true).get_node('flashbk').children.length>0){
if(helper.sha256_loadedros !== getSHA256hash(helper.rosBuffer.offset+0x30, helper.patchfile_size)){
var fp = new fileObject(helper.fm_tmpfile_path,helper.fs_flag_readonly);
if(fp.size()===helper.patchfile_size){
if(fp.load(helper.patchfile_size,{'offset':helper.rosBuffer.offset+0x30,'size':helper.rosBuffer.size-0x30},null,null)!==0){
Logger.error('Patch Data could not be restored from file');
removePatch();
}
else if(helper.sha256_loadedros !== getSHA256hash(helper.rosBuffer.offset+0x30, helper.patchfile_size)){
Logger.error('Patch Data could not be restored from file');
removePatch();
}
else{
helper.deletePatchData();
}
fp.close();
}
else{
Logger.error('Patch Data could not be restored from file');
removePatch();
}
}
else{
helper.deletePatchData();
}
}
else{
helper.deletePatchData();
}
};
helper.deletePatchData();
}
var removePatch = function(){
var jQftree = jQuery('#fTree').jstree(true);
var _node = jQftree.get_node('flashbk');
var children = _node ? _node.children : [];
if(children.length>0){
jQftree.delete_node(children);
}
helper.sha256_loadedros='';
helper.rosBuffer={'offset':0,'size':0};
if(dl_object){dl_object=null;}
if(helper.deletePatchData){
helper.deletePatchData();
}
//buf_po={'offset':0,'size':0};
};
//function updatePD(o,st){
// pbfm1.updateProgressDialog(o,st);
//}
//function updateBuffer(b){
//ldiag.addPatchInfo(b);
// helper.rosBuffer=b;
//}
function prepPatchFile(buf_po){
var _nor = so.is_nor();
helper.memory.upokes(buf_po.offset,helper.patch_ros_fragment_start);
if(!_nor){
helper.memory.upokes(buf_po.offset,getActiveNandROS(so));
}
helper.memory.upokes(buf_po.offset+helper.patchfile_size+0x30,_nor ? helper.patch_ros_fragment_end1:helper.patch_ros_fragment_end2);
}
function validatePatchFile(filename,silent){
//alert('validatePatchFile');
Logger.info('getSHA256hash 0x'+(helper.rosBuffer.offset+0x30).toString(16));
helper.sha256_loadedros = getSHA256hash(helper.rosBuffer.offset+0x30, helper.patchfile_size);
if(dl_object){dl_object.sha256 = helper.sha256_loadedros;}
if(!silent){pbfm1.ulog('SHA256 Extraction Complete');}
Logger.info('Patch File '+filename+' SHA256 checksum: '+helper.sha256_loadedros);
if(!silent){pbfm1.ulog('Patch validation operations complete');}
if(helper.sha256_loadedros!==helper.nofsm_hash){
if(dl_object){toast('Patch Download Error','warning',5);}
Logger.warn('Custom patch file detected.');
//alert('Custom patch file detected');
return 1;
}
else{
Logger.info('official patch file detected.');
//alert('official patch file detected');
return 0;
}
}
function updateValidationGUI(start,filename){
var jQftree = jQuery('#fTree').jstree(true);
if(!jQftree.is_disabled('flashbk')){
jQftree.create_node('flashbk',{'id' : 'rosbk', 'type' : 'ros', 'text' : 'ROS' });
jQftree.create_node('rosbk',{'id' : 'infobk', 'type' : 'info', 'text' : 'SHA256: '+helper.sha256_loadedros });
jQftree.open_node('rosbk');
jQftree.open_node('flashbk');
}
setTimeout(function(){
helper.sp.playOK();
pbfm1.updateProgressDialog({'dlabel':'Idle','glabel':'Patch File \''+filename+'\' loaded & validated','dvalue':100,'gvalue':100,'istatus':'success-image'},start);
},250);
}
function updateNoValidationGUI(start,filename){
helper.sp.playNG();
pbfm1.updateProgressDialog({'glabel':'Loading Operations failed','dlabel':'File validation error','dvalue':100,'gvalue':100,'istatus':'error-image'},start);
Logger.info('Invalid Patch File '+filename);
}
function xRegTableCleanup(){
Logger.info('XRegTable cleanup');
var nfo = jQuery('#xr_kinfo');
if(nfo.html().length>nfo.text().length){
//jQuery('.xreg-value').off('focusin focusout change');
jQuery('tr.xreg-setting').contextMenu('destroy');
jQuery('div.xr-list-container').contextMenu('destroy');
}
var ell = jQuery('i.ellipsis');
if(ell.length>0){
ell.contextMenu('destroy');
}
jQuery('#xreg_table').mCustomScrollbar('destroy');
helper.xregistry.xdestroyList(xRegSettings.xlist.list);
helper.xregistry.xclose();
xRegSettings = null;
}
function dl_cancel(){
helper.swf.cancelDownload();
dl_object=null;
helper.sp.playNG();
}
function processXRegistryTable(){
var xkfilter='*',xdfilter='*';
if(xRegSettings.active.length===0){
jQuery('#xreg_table').html('<div>xRegistry Data Extraction Errors</div>');
}
else{
jQuery.each(xRegSettings.inactive,function(k,ktem){ // to add the list of keys to display for each directory
if(ktem.setting.indexOf('/setting/system/hddSerial')<0 || ktem.setting.indexOf('/setting/np/env')<0 || ktem.setting.indexOf('/setting/wboard/baseUri')<0){
Logger.info('xRegSettings inactive: '+ktem.setting);
}
});
var tjson = [{ 'id' : 'xtree_setting', 'parent' : '#', 'text' : 'setting'}];
jQuery.each(xRegSettings.directory,function(i,item){ // building tree with directory array
jQuery.each(xRegSettings.directory,function(j,jtem){
if(item.setting+jtem.setting.substr(jtem.setting.lastIndexOf('/')) === jtem.setting){
var a_attr = {'data-xrf':[],'title':jtem.setting};
jQuery.each(xRegSettings.active,function(k,ktem){ // to add the list of keys to display for each directory
if(jtem.setting+ktem.setting.substr(ktem.setting.lastIndexOf('/')) === ktem.setting){
a_attr['data-xrf'].push({'setting':ktem.setting,'pointer':ktem.pointer,'active':true});
}
});
jQuery.each(xRegSettings.inactive,function(k,ktem){ // to add the list of keys to display for each directory
if(jtem.setting+ktem.setting.substr(ktem.setting.lastIndexOf('/')) === ktem.setting){
a_attr['data-xrf'].push({'setting':ktem.setting,'pointer':ktem.pointer,'active':false});
}
});
tjson.push({ 'id' : 'xtree'+jtem.setting.replace(/([/])/g,'_'), 'icon' : 'jstree-folder', 'parent' : 'xtree'+item.setting.replace(/([/])/g,'_'), 'text' : jtem.setting.substr(jtem.setting.lastIndexOf('/')+1), 'a_attr' : a_attr});
}
});
});
var xr_asc = true;
var jst_xr = jQuery('#xr_ktree');
jst_xr.jstree({
'core' : {
'data' : tjson,
'multiple' : false
},
'plugins' : [ 'unique', 'search', 'sort', 'changed' ],//, 'state'
'themes':{
'dots': true,
'icons': true
},
'sort' : function(a, b) {
if(xr_asc){
return (this.get_node(a).text > this.get_node(b).text) ? 1 : -1;
}
else{
return (this.get_node(b).text > this.get_node(a).text) ? 1 : -1;
}
}
});
jst_xr.on('search.jstree', function (e, data) {
if(data.nodes.length===0){
alert('No matches for '+data.str);
}
else{
if(!xdfilter.length && xdfilter.ellipsis){
jQuery('#'+xdfilter.ellipsis).after('<span style=\'display:inline-block;height:12px;\'><i class=\'fa fa-search xd-filter-icon\' title=\'Filter Pattern: \''+data.str+'\'\' aria-hidden=\'true\' style=\'font-size:11px;padding-left:10px;\'></i><span>');
jQuery('.xd-filter-icon').on('click',function(e){
var xdfi = jQuery('.xd-filter-icon');
xdfi.off('click');
data.instance.clear_search();
xdfilter='*';
xdfi.remove();
});
}
jQuery.each(data.res,function(ri,ritem){
jQuery.each(data.instance.get_node(ritem).children_d, function(i,item){
console.log(item);
data.instance.show_node(item,false);
});
});
}
var nd = jQuery('#currentxnode').val();
try{
if(!data.instance.is_hidden(nd)){
data.instance.select_node(nd);
}
else{
data.instance.deselect_all();
jQuery('#xr_kinfo').html('Select a setting folder in the tree to display keys');
}
}
catch(e){
data.instance.deselect_all();
jQuery('#xr_kinfo').html('Select a setting folder in the tree to display keys');
}
});
function redraw_ellipsis(){
jQuery.each(jQuery('#xreg_table').find('a.jstree-anchor'), function(_idx,_el){
_el=jQuery(_el);
if(!_el.next().hasClass('fa-ellipsis-v')){
_el.after('<i id=\'ellipsis_icon_'+_idx.toString()+'\' class=\'fa fa-ellipsis-v ellipsis\' aria-hidden=\'true\' style=\'font-size:14px;padding:6px 5px 0 5px;\'></i>');
}
return false; // add ellipsis context menu to first tree item only
});
}
jst_xr.on('clear_search.jstree', function (e, data) {
console.log('clear_search.jstree');
console.log(xdfilter);
//xdfilter='*';
});
jst_xr.on('redraw.jstree', function (e, data) {
redraw_ellipsis();
});
jst_xr.on('after_open.jstree', function (e, data) {
//alert('after_open.jstree');
redraw_ellipsis();
});
jst_xr.on('ready.jstree', function (e, data) {
alert('ready.jstree');
redraw_ellipsis();
// jQuery('.scb-xr1').mCustomScrollbar({
// axis:'xy',
// theme: (Cookies.get('style')==='eggplant') ? 'light-thick' : 'dark-thick',
// //theme: 'light-thick',
// advanced:{
// updateOnContentResize: true,
// updateOnImageLoad: true
// },
// keyboard: {enable:false},
// mouseWheel: {enable:false}
// });
jQuery('.scb-xr2').mCustomScrollbar({
axis:'y',
theme: (Cookies.get('style')==='eggplant') ? 'light-thick' : 'dark-thick',
//theme: 'light-thick',
advanced:{
updateOnContentResize: true,
updateOnImageLoad: true
},
keyboard: {enable:false},
mouseWheel: {enable:false}
});
});
jst_xr.on('select_node.jstree', function (e, data) {
//alert(data.node.id);
jQuery('.preloader-diag').removeClass('ui-helper-hidden');
jQuery('#currentxnode').val(data.node.id);
setTimeout(function() {
var htbl = '<div style=\'height:100%;min-width:355px;width:100%;border:0;\'>No xRegistry keys in '+data.node.a_attr['title']+'</div>';
//show the values for keys found in a_attr
if(data.node.a_attr['data-xrf'] && data.node.a_attr['data-xrf'].length>0){
htbl = '<div class=\'xr-list-container\' style=\'height:100%;border:0;\'><table class=\'xr-list\' style=\'max-width:345px;width:100%;border:0;\'><thead class=\'ui-widget-header\' style=\'height:20px;border:0;\'><tr class=\'\'><th class=\'headerSortDown\' style=\'height:20px !important;max-height:20px !important;min-height:20px !important;width:40%!important;\'>Key</th><th class=\'headerSortDown\' style=\'height:20px !important;max-height:20px !important;min-height:20px !important;width:100px!important;\'>Type</th><th class=\'\' style=\'height:20px !important;max-height:20px !important;min-height:20px !important;width:50%!important;\'>Value</th></tr></thead><tbody style=\'padding-top:4px;padding-bottom:4px;\'>';
jQuery.each(data.node.a_attr['data-xrf'],function(xri,xritem){
if(!xritem.pointer || xritem.pointer<0x20000000 || xritem.pointer>0x2FFFFFFC){
alert('Error invalid pointer');
return true;
}
var obj = helper.xregistry.xget(xritem);
//use helper.xregistry to get the value & the type of the key (0:bool, 1: integer, 2: string)
var _tr = 'xstr_'+xri.toString();
if(obj){
if(obj.error===0){
var valdisp = obj.type===0 ? '0x'+obj.value.toString(16):obj.value;
var _disabled = xritem.active ? '' : ' ui-state-disabled';
htbl += '<tr id=\''+_tr+'\' style=\'border:1px;height:20px !important;max-height:20px !important;\' class=\'xreg-setting ui-widget-content no-background-image\' title=\''+xritem.setting+'\' data-xs=\'{"setting":"'+xritem.setting+'","value":"0x'+obj.value.toString(16)+'","type":"'+obj.type+'","row":"'+_tr+'","id":"'+xritem.setting.replace(/([/])/g,'_')+'"}\'><td align=\'justify\' class=\'ui-widget-content no-background-image\' style=\'border:0;padding:5px;height:20px;max-height:20px;max-width:50%;width:50%;text-align:left!important;\'>'+xritem.setting.substr(xritem.setting.lastIndexOf('/')+1)+'</td><td align=\'justify\' class=\'ui-widget-content no-background-image\' style=\'border:0;padding:5px;max-width:100px;width:100px;height:20px;max-height:20px;text-align:center!important;\'>'+obj.type+'</td><td align=\'justify\' class=\'ui-widget-content no-background-image\' style=\'border:0;padding:1px 5px 5px 5px;height:20px;max-height:20px;max-width:100%;width:100%;text-align:right!important;\'><input id=\''+xritem.setting.replace(/([/])/g,'_')+'\' class=\'ui-corner-all xr-value'+_disabled+'\' type=\'text\' value=\''+valdisp+'\' readonly/></td></tr>';
}
else{
htbl += '<tr id=\''+_tr+'\' style=\'border:1px;height:20px !important;max-height:20px !important;\' class=\'ui-widget-content no-background-image\' title=\''+xritem.setting+'\'><td align=\'justify\' class=\'ui-widget-content no-background-image\' style=\'border:0;padding:5px;height:20px;max-height:20px;max-width:50%;width:50%;text-align:left!important;\'>'+xritem.setting.substr(xritem.setting.lastIndexOf('/')+1)+'</td><td align=\'justify\' class=\'ui-widget-content no-background-image\' style=\'border:0;padding:5px;max-width:100px;width:100px;height:20px;max-height:20px;text-align:center!important;\'> - </td><td align=\'justify\' class=\'ui-widget-content no-background-image\' style=\'border:0;padding:1px 5px 5px 5px;height:20px;max-height:20px;max-width:100%;width:100%;text-align:right!important;\'><span>Data Extraction Error: 0x'+obj.error.toString(16)+'</span></td></tr>';
}
}
});
htbl += '</tbody></table></div>';
}
jQuery('#xr_kinfo').html(htbl);
jQuery('table.xr-list').tablesorter({
theme: 'jui',
widgets : ['uitheme'],
emptyTo: 'bottom',
//widgetOptions: {uitheme : 'jui'}, // this is now optional in v2.7, it is overridden by the theme option
sortList: [[0,0],[1,0]] // sort on the first column and second column in ascending order
});
jQuery('table.xr-list thead th:eq(5)').data('sorter', false);
jQuery('#xr_cpath').text('/'+data.instance.get_fullpath(data.node));
jQuery('.preloader-diag').removeClass('ui-helper-hidden').addClass('ui-helper-hidden');
}, 0);
return true;
});
function xregfilter(e){
e.preventDefault();
e.stopPropagation();
e.stopImmediatePropagation();
var nval = jQuery.trim(e.target.value);
var trset = jQuery('tr.xreg-setting');
if(nval===xkfilter){return;}
if(nval!=='*' && nval!==''){
jQuery.each(trset,function(ixs,xtem){
var xsr = jQuery(xtem);
var stg = JSON.parse(xsr.attr('data-xs')).setting;
stg = stg.substr(stg.lastIndexOf('/')+1);
if(stg.indexOf(nval)<0){
jQuery.each(xsr.children('td'),function(ixc,ctem){
ctem=jQuery(ctem);
if(ctem.hasClass('xreg-filtered')){
ctem.remove('xreg-filtered');
}
});
if(!xsr.hasClass('ui-helper-hidden')){
xsr.addClass('ui-helper-hidden');
}
}
else{
if(xsr.hasClass('ui-helper-hidden')){
xsr.removeClass('ui-helper-hidden');
}
jQuery.each(xsr.children('td'),function(ixc,ctem){
ctem=jQuery(ctem);
if(!ctem.hasClass('xreg-filtered')){
ctem.addClass('xreg-filtered');
}
});
}
});
jQuery(e.target).parent().parent().parent().find('li.context-menu-disabled').not('.context-menu-input').removeClass('context-menu-disabled cm-disabled').addClass('cm-disabled');
xkfilter=nval;
}
else{
trset.removeClass('ui-helper-hidden');
trset.find('td').removeClass('xreg-filtered');
jQuery(e.target).parent().parent().parent().find('li.cm-disabled').not('.context-menu-input').removeClass('context-menu-disabled cm-disabled').addClass('context-menu-disabled');
xkfilter='*';
}
}
jQuery.contextMenu({
selector: 'i.ellipsis',
trigger: 'left',
delay: 200,
build: function(jQtrigger, e) {
e.preventDefault();
e.stopPropagation();
e.stopImmediatePropagation();
var xtree = jst_xr.jstree(true);
console.log('in cm');
console.log(xdfilter);
return {
callback: function(key, options) {
switch(key){
case 'sortX':
xr_asc = !xr_asc;
xtree.refresh();
var icn = jQuery(this).find('i');
if(icn.hasClass('fa-sort-alpha-desc')){
icn.removeClass('fa-sort-alpha-desc').addClass('fa-sort-alpha-asc');
}
else if(icn.hasClass('fa-sort-alpha-asc')){
icn.removeClass('fa-sort-alpha-asc').addClass('fa-sort-alpha-desc');
}
if(xdfilter!=='*' && !xdfilter.length){
xtree.deselect_all();
xtree.search(xdfilter.pattern,true,true,xdfilter.parent,false);
}
break;
case 'clearfilterX':
//jQuery('input[name=\'context-menu-input-ipt_filter\']').val('*');
xtree.clear_search();
xdfilter='*';
break;
default:
break;
}
},
items: {
'sortX': {
name: xr_asc === false ? 'Sort xRegistry Directories A-Z':'Sort xRegistry Directories Z-A',
icon: function(jQel, key, item){ return xr_asc === false ? 'context-menu-icon context-menu-icon--fa fa fa-sort-alpha-asc':'context-menu-icon context-menu-icon--fa fa fa-sort-alpha-desc'; },
disabled: function(){ return false; }
},
'filterkeymenu': {
name: 'Filter xRegistry Directory',
icon: function(jQel, key, item){ return 'context-menu-icon context-menu-icon--fa fa fa-search'; },
disabled: function(){ return xtree.get_node(jQtrigger[0].parentElement.id).children.length<=0 ? true:false; },
items: {
'ipt_filter': {
name: 'Filter Pattern',
type:'text',
value: xdfilter.length ? xdfilter: xdfilter.dir===xtree.get_fullpath(xtree.get_node(jQtrigger[0].parentElement.id)) ? xdfilter.pattern : '*',
events: {
focusin: function(e) {
e.preventDefault();
e.stopPropagation();
e.stopImmediatePropagation();
},
focusout: function(e) {
if(e.target.value===''){
e.target.value='*';
xtree.clear_search();
xdfilter='*';
}
},
click:function(e){
e.preventDefault();
e.stopPropagation();
e.stopImmediatePropagation();
e.target.focus();
},
keyup: function(e) {
if(e.target.value.length>0){
if(e.target.value!=='*'){
xdfilter={"dir":xtree.get_fullpath(xtree.get_node(jQtrigger[0].parentElement.id)), "parent":jQtrigger[0].parentElement.id,"pattern":e.target.value, "ellipsis":jQtrigger[0].id};
jQuery(e.target).parent().parent().parent().find('li.context-menu-disabled').not('.context-menu-input').removeClass('context-menu-disabled cm-disabled').addClass('cm-disabled');
console.log('keyup cm search');
console.log('Searching jQtrigger[0].parentElement.id '+jQtrigger[0].parentElement.id);
xtree.search(e.target.value,true,true,jQtrigger[0].parentElement.id,false);
}
else{
jQuery(e.target).parent().parent().parent().find('li.cm-disabled').not('.context-menu-input').removeClass('context-menu-disabled cm-disabled').addClass('context-menu-disabled');
console.log('keyup cm clear_search');
xtree.clear_search();
xdfilter='*';
}
}
console.log('keyup cm out');
console.log(xdfilter);
jQuery(document).tooltip();
}
},
disabled: function(){ return false; }
},
'clearfilterX': {
name: 'Clear Filter',
icon: function(jQel, key, item){ return 'context-menu-icon context-menu-icon--fa fa fa-remove'; },
disabled: function(){ return xdfilter==='*'? true:false; }
}
}
}
}
};
}
});
jQuery.contextMenu({
selector: 'div.xr-list-container',//#xr_kinfo
trigger: 'left',
delay: 50,
autoHide: true,
build: function(jQtrigger, e) {
e.preventDefault();
e.stopPropagation();
e.stopImmediatePropagation();
return {
callback: function(key, options) {
switch(key){
case 'clearfilterXK':
var trset = jQuery('tr.xreg-setting');
trset.removeClass('ui-helper-hidden');
trset.find('td').removeClass('xreg-filtered');
xkfilter='*';
break;
default:
break;
}
},
items: {
'filterkeymenu': {
name: 'Filter xRegistry Keys',
icon: function(jQel, key, item){ return 'context-menu-icon context-menu-icon--fa fa fa-search'; },
items: {
'ipt_filterk': {
name: 'Filter Key Pattern',
type:'text',
value: xkfilter,
events: {
focusin: function(e) {
e.preventDefault();
e.stopPropagation();
e.stopImmediatePropagation();
},
focusout: function(e) {
if(e.target.value===''){
e.target.value='*';
xkfilter='*';
}
},
keyup: function(e) {
xregfilter(e);
jQuery(document).tooltip();
}
},
disabled: function(){ return false; }
},
'clearfilterXK': {
name: 'Clear Key Filter',
icon: function(jQel, key, item){ return 'context-menu-icon context-menu-icon--fa fa fa-remove'; },
disabled: function(){ return xkfilter.length>0 && xkfilter!=='*' ? false:true; }
}
}
}
}
};
}
});
jQuery.contextMenu({
selector: 'tr.xreg-setting',
trigger: 'left',
delay: 50,
autoHide: true,
build: function(jQtrigger, e) {
e.preventDefault();
e.stopPropagation();
e.stopImmediatePropagation();
var xs = JSON.parse(jQtrigger.attr('data-xs'));
var sltype=['boolean','integer','string'];
if(!xs){
alert('error');
}
else{
alert('type: '+sltype[xs.type]);
alert('value: '+xs.value);
}
var inpt = jQuery('#'+xs.id);
var trw = jQuery('#'+xs.row);
var xroot = '/setting/';
var xKey = {'setting':xs.setting,'type':sltype[xs.type],'value':xs.value};
var xtree = jst_xr.jstree(true);
return {
callback: function(key, options) {
switch(key){
case 'delX':
function confirmDelete(){
setTimeout(function(){
//var xdret = helper.xregistry.xdelete(xs.setting);
var xdret = 0;
if(xdret===0){
inpt.off();
trw.remove();
//we need to remove the reference in the tree data too
var node = xtree.get_node(jQuery('#currentxnode').val());
var new_attr = {'data-xrf':[],'title':node.a_attr['title']};
jQuery.each(node.a_attr['data-xrf'],function(xri,xritem){
if(xritem.setting!==xs.setting){
new_attr['data-xrf'].push(xritem);
}
});
node.a_attr=new_attr;
toast('NOT YET IMPLEMENTED - Deleted xRegistry key '+xs.setting,'notice',5);
}
else{
toast('NOT YET IMPLEMENTED - Error 0x'+xdret.toString(16)+' deleting xRegistry key '+xs.setting,'error',5);
}
},250);
}
confirmDialog('Deleting this registry item is allowed because you disabled Strict Mode. Proceeding with the deletion could be risky, you have been warned. Are you sure you want to continue?','Delete xRegistry Item Confirmation',confirmDelete,null,null,null,{'txt':'dg-text2','conf':'dg-confirm2'});
break;
case 'editX':
function confirmEdit(){
setTimeout(function(){
//var xeret = helper.xregistry.xset(xs.setting);
var xeret = 0;
if(xeret===0){
xtree.deselect_all();
jQuery('#xr_kinfo').html('Refreshing data');
xtree.select_node(xtree.get_node(jQuery('#currentxnode').val()));
toast('NOT YET IMPLEMENTED - Edited xRegistry key '+xs.setting,'notice',5);
// edit row cell or reload tree item by deselect then selecting node
}
else{
toast('NOT YET IMPLEMENTED - Error 0x'+xeret.toString(16)+' deleting xRegistry key '+xs.setting,'error',5);
}
},250);
}
confirmDialog('Editing this registry item is allowed because you disabled Strict Mode. Proceeding with the edition could be risky, you have been warned. Are you sure you want to continue?','Edit xRegistry Item Confirmation',confirmEdit,null,null,null,{'txt':'dg-text2','conf':'dg-confirm2'});
break;
case 'clearfilterXK':
//alert('clearfilterXK');
var trset = jQuery('tr.xreg-setting');
trset.removeClass('ui-helper-hidden');
trset.find('td').removeClass('xreg-filtered');
xkfilter='*';
break;
default:
break;
}
},
items: {
'delX': {
name: 'Delete xRegistry Item',
icon: function(jQel, key, item){ return 'context-menu-icon context-menu-icon--fa fa fa-minus'; },
disabled: function(){ return helper.fm_usermode === 0 ? true:false; }
},
'editkeymenu': {
name: 'Edit xRegistry Key',
icon: function(jQel, key, item){ return 'context-menu-icon context-menu-icon--fa fa fa-edit'; },
disabled: function(){ return helper.fm_usermode === 0 ? true:false; },
items: {
'ipt_setting': {
name: 'Setting',
type:'text',
value: xs.setting,
disabled: function(){ setTimeout(function(){var o = jQuery('input[name=\'context-menu-input-ipt_setting\']');o.attr('disabled',true);o.attr('title',o.val());jQuery(document).tooltip();},250);return false; }
},
'ipt_value': {
name: 'Value',
type:'text',
value: xs.value,
events: {
focusin: function(e) {
e.preventDefault();
e.stopPropagation();
e.stopImmediatePropagation();
//if(xKey.type==='integer' && e.target.value==='0'){
// e.target.value = '';
//}
},
focusout: function(e) {
//alert('focusout');
var isval_valid=false;
if(e.target.value===''){
if(xKey.type==='integer'){
if(xKey.value===''){
xKey.value=0;
}
e.target.value = '0x'+xKey.value.toString(16).toUpperCase();
isval_valid=true;
}
else if(xKey.type==='boolean'){
xKey.value=0;
e.target.value = xKey.value.toString();
isval_valid=true;
}
else if(xKey.type==='string'){
e.target.value = xKey.value;
isval_valid=true;
}
}
else{
if(xKey.type==='integer'){ // not 64bit compliant (xset/xadd are not 64bit compliant, it looks like the exports only use 32 bit integer params according to RE)
//alert('test focusout');
var nval = parseInt(e.target.value,16);
if(nval!==xKey.value){
if((isNaN(nval) && e.target.value.toUpperCase()!==nval.toString(16).toUpperCase()) || nval>0xFFFFFFFF){
//alert('test no focusout');
}
else{
xKey.value= nval;
//alert('test in focusout');
e.target.value = '0x'+xKey.value.toString(16).toUpperCase();
isval_valid=true;
}
}
}
else if(xKey.type==='string'){
xKey.value = e.target.value;
isval_valid=true;
}
else if(xKey.type==='boolean'){
if(e.target.value==='0' || e.target.value==='1'){
xKey.value = parseInt(e.target.value);
isval_valid=true;
}
}
}
var cval = xKey.value;
if(xKey.type==='boolean'){
cval = xKey.value.toString(16);
}
else if(xKey.type==='integer'){
cval = '0x'+ xKey.value.toString(16);
}
//need to test this cval comp with xs.value...
//if(isval_valid && !(xKey.type===sltype[xs.type] && cval===xs.value)){
if(isval_valid && cval!==xs.value){
jQuery(e.target).parent().parent().parent().find('li.context-menu-disabled').not('.context-menu-input').removeClass('context-menu-disabled cm-disabled').addClass('cm-disabled');
}
else{
jQuery(e.target).parent().parent().parent().find('li.cm-disabled').not('.context-menu-input').removeClass('context-menu-disabled cm-disabled').addClass('context-menu-disabled');
}
},
keyup: function(e) {
var isval_valid=false;
if(e.target.value!=='' ){
if(xKey.type==='integer'){ // not 64bit compliant (xset/xadd are not 64bit compliant, it looks like the exports only use 32 bit integer params according to RE)
var cva = e.target.value.indexOf('0x')===0 ? e.target.value : '0x'+e.target.value;
if(cva==='0x'){
cva = '0x0';
}
var nval = parseInt(cva,16);
if(nval!==xKey.value || e.target.value==='0x' || parseInt(e.target.value,16)===0){
if((isNaN(nval) && cva.toUpperCase().substr(2)!==nval.toString(16).toUpperCase()) || nval>0xFFFFFFFF){
xKey.value= 0;
}
else{
xKey.value= nval;
if(e.target.value!=='0x'){
e.target.value = '0x'+xKey.value.toString(16).toUpperCase();
isval_valid=true;
}
}
}
}
else if(xKey.type==='string'){
xKey.value = e.target.value;
isval_valid=true;
}
else if(xKey.type==='boolean'){
if(parseInt(e.target.value)===0 || parseInt(e.target.value)===1){
xKey.value = parseInt(e.target.value);
isval_valid=true;
}
}
}
else{
if(xKey.type==='string'){
isval_valid=true;
}
}
if(isval_valid){
if(xKey.type==='string'){
if(xKey.value!==xs.value){
jQuery(e.target).parent().parent().parent().find('li.context-menu-disabled').not('.context-menu-input').removeClass('context-menu-disabled cm-disabled').addClass('cm-disabled');
}
else{
jQuery(e.target).parent().parent().parent().find('li.cm-disabled').not('.context-menu-input').removeClass('context-menu-disabled cm-disabled').addClass('context-menu-disabled');
}
}
else if(xKey.type==='integer'){
if('0x'+xKey.value.toString(16)!==xs.value){
jQuery(e.target).parent().parent().parent().find('li.context-menu-disabled').not('.context-menu-input').removeClass('context-menu-disabled cm-disabled').addClass('cm-disabled');
}
else{
jQuery(e.target).parent().parent().parent().find('li.cm-disabled').not('.context-menu-input').removeClass('context-menu-disabled cm-disabled').addClass('context-menu-disabled');
}
}
else if(xKey.type==='boolean'){
if(xKey.value!==parseInt(xs.value,16)){
jQuery(e.target).parent().parent().parent().find('li.context-menu-disabled').not('.context-menu-input').removeClass('context-menu-disabled cm-disabled').addClass('cm-disabled');
}
else{
jQuery(e.target).parent().parent().parent().find('li.cm-disabled').not('.context-menu-input').removeClass('context-menu-disabled cm-disabled').addClass('context-menu-disabled');
}
}
}
else{
jQuery(e.target).parent().parent().parent().find('li.cm-disabled').not('.context-menu-input').removeClass('context-menu-disabled cm-disabled').addClass('context-menu-disabled');
}
jQuery(document).tooltip();
}
},
disabled: function(){ return helper.fm_usermode === 0 ? true:false; }
},
'sel_type': {
name: 'Type',
type: 'select',
options: sltype,
selected: xs.type,
events: {
focusin: function(e) {
e.preventDefault();
e.stopPropagation();
e.stopImmediatePropagation();
//if(xKey.type==='integer' && e.target.value==='0'){
// e.target.value = '';
//}
},
change: function(e) {
xKey.type = sltype[e.target.selectedIndex];
console.log(xKey.type);
if(xKey.type==='boolean'){
var cvl = parseInt(xKey.value,16);
xKey.value = isNaN(cvl) ? 0 : cvl > 1 ? 1 : cvl;
jQuery('input[name=\'context-menu-input-ipt_value\']').val(xKey.value.toString());
}
else if(xKey.type==='integer'){
var cvl = parseInt(xKey.value,16);
xKey.value = isNaN(cvl) ? 0 : cvl > 0xFFFFFFFF ? 0xFFFFFFFF : cvl;
jQuery('input[name=\'context-menu-input-ipt_value\']').val('0x'+xKey.value.toString(16).toUpperCase());
}
else{
if(typeof xKey.value!=='string'){
xKey.value = xKey.value.toString(16);
jQuery('input[name=\'context-menu-input-ipt_value\']').val(xKey.value);
}
}
if((xKey.type==='boolean' && xKey.value>1) || (xKey.type==='boolean' && xKey.value<0) || (xKey.type==='boolean' && xKey.type===sltype[xs.type] && xKey.value===parseInt(xs.value,16)) || (xKey.type==='integer' && isNaN(xKey.value))){
jQuery(e.target).parent().parent().parent().find('li.cm-disabled').not('.context-menu-input').removeClass('context-menu-disabled cm-disabled').addClass('context-menu-disabled');
}
else if((xKey.type==='string' && xKey.type===sltype[xs.type] && xKey.value===xs.value) || (xKey.type!=='string' && xKey.type===sltype[xs.type] && xKey.value.toString(16)===xs.value)){
jQuery(e.target).parent().parent().parent().find('li.cm-disabled').not('.context-menu-input').removeClass('context-menu-disabled cm-disabled').addClass('context-menu-disabled');
}
else{
jQuery(e.target).parent().parent().parent().find('li.context-menu-disabled').not('.context-menu-input').removeClass('context-menu-disabled cm-disabled').addClass('cm-disabled');
}
}
},
disabled: function(){ return helper.fm_usermode === 0 ? true:false; }
},
'editX': {
name: 'Edit xRegistry Key',
icon: function(jQel, key, item){ return 'context-menu-icon context-menu-icon--fa fa fa-edit'; },
disabled: function(){ return true; }
}
}
},
'filterkeymenu': {
name: 'Filter xRegistry Keys',
icon: function(jQel, key, item){ return 'context-menu-icon context-menu-icon--fa fa fa-search'; },
items: {
'ipt_filterk': {
name: 'Filter Key Pattern',
type:'text',
value: xkfilter,
events: {
focusin: function(e) {
e.preventDefault();
e.stopPropagation();
e.stopImmediatePropagation();
},
focusout: function(e) {
if(e.target.value===''){
e.target.value='*';
xkfilter='*';
}
},
keyup: function(e) {
xregfilter(e);
if(helper.fm_usermode !== 0){
var list = jQuery(e.target).parent().parent().parent().parent().parent().children();
if(trw.hasClass('ui-helper-hidden')){
jQuery(list[0]).removeClass('context-menu-disabled').addClass('context-menu-disabled');
jQuery(list[1]).removeClass('context-menu-disabled').addClass('context-menu-disabled');
}
else {
jQuery(list[0]).removeClass('context-menu-disabled');
jQuery(list[1]).removeClass('context-menu-disabled');
}
}
jQuery(document).tooltip();
}
},
disabled: function(){ return false; }
},
'clearfilterXK': {
name: 'Clear Key Filter',
icon: function(jQel, key, item){ return 'context-menu-icon context-menu-icon--fa fa fa-remove'; },
disabled: function(){ return xkfilter.length>0 && xkfilter!=='*' ? false:true; }
}
}
}
}
};
}
});
}
}
var so =null;
jQuery('.preloader').removeClass('ui-helper-hidden');
jQuery('#admode').switchButton({
labels_placement: 'left',
//checked: true,
clear: false,
on_label: 'SM Strict Mode ON ',
off_label: 'SM Strict Mode OFF',
on_callback: function (){
jQuery(document).tooltip('disable');
helper.fm_usermode = 0;
jQuery(document).tooltip('enable');
},
off_callback: function(){
jQuery(document).tooltip('disable');
function confirmMode(){
helper.fm_usermode = 1;
jQuery(document).tooltip('enable');
}
confirmDialog('YOU SHOULD NEVER TURN SM Strict Mode OFF!!!<br><br>Only advanced users & developers should ever consider using SM with strict mode off.You have been warned.','Are you sure you want to continue?',confirmMode,null,function(ck){jQuery('#admode').switchButton('option','checked', ck);jQuery(document).tooltip('enable');},true);
}
});
var fTree = function(close_toast){
var jQtree = jQuery('.fm-tree');
so = so ? so : new storageObject();
var mv = getMinVer();
if(mv.error!==0){
Logger.error('The minimum applicable firmware version could not be extracted - Error 0x'+mv.error);
toast('The minimum applicable firmware version could not be extracted. Please reboot & try again.','error',5);
return;
}
helper.minver = mv.version;
var cfwminver = parseFloat(helper.minver)<3.60;
var metldr = getMtldrVersion(so);
function metldr_err(){
Logger.error('The minimum applicable firmware version does not match the metldr version');
Logger.warn('If the IDPS of your console is spoofed, the minimum applicable firmware version calculated by the system is no longer reliable');
toast('A discrepancy possibly caused by IDPS spoofing was detected in the minimum applicable firmware version returned by the system.','warning',5);
helper.minver += ' !';
}
if(metldr === 'metldr.2' && cfwminver){
metldr_err();
}
else if(metldr === 'metldr' && !cfwminver){
metldr_err();
}
var cfw_compat = metldr!=='metldr.2';
var compat = jQuery('#cfwcompat');