mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-07-17 15:48:08 +00:00
Issue #129 deobfuscation of ord/getTime
This commit is contained in:
@@ -17,6 +17,7 @@
|
||||
package com.jpexs.decompiler.flash.action.swf4;
|
||||
|
||||
import com.jpexs.decompiler.flash.action.Action;
|
||||
import com.jpexs.decompiler.flash.action.treemodel.GetTimeTreeItem;
|
||||
import com.jpexs.decompiler.flash.action.treemodel.SimpleActionTreeItem;
|
||||
import com.jpexs.decompiler.flash.graph.GraphTargetItem;
|
||||
import java.util.HashMap;
|
||||
@@ -36,6 +37,6 @@ public class ActionGetTime extends Action {
|
||||
|
||||
@Override
|
||||
public void translate(Stack<GraphTargetItem> stack, List<GraphTargetItem> output, java.util.HashMap<Integer, String> regNames, HashMap<String, GraphTargetItem> variables, HashMap<String, GraphTargetItem> functions) {
|
||||
stack.push(new SimpleActionTreeItem(this, "getTimer()"));
|
||||
stack.push(new GetTimeTreeItem(this));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,4 +40,38 @@ public class CharToAsciiTreeItem extends TreeItem {
|
||||
ret.addAll(value.getNeededSources());
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCompileTime() {
|
||||
if (value instanceof DirectValueTreeItem) {
|
||||
DirectValueTreeItem dv = (DirectValueTreeItem) value;
|
||||
if (dv.value instanceof String) {
|
||||
String s = (String) dv.value;
|
||||
if (s.length() > 0) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double toNumber() {
|
||||
if (value instanceof DirectValueTreeItem) {
|
||||
DirectValueTreeItem dv = (DirectValueTreeItem) value;
|
||||
if (dv.value instanceof String) {
|
||||
String s = (String) dv.value;
|
||||
if (s.length() > 0) {
|
||||
char c = s.charAt(0);
|
||||
return (int) c;
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean toBoolean() {
|
||||
return toNumber() != 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2013 JPEXS
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.jpexs.decompiler.flash.action.treemodel;
|
||||
|
||||
import com.jpexs.decompiler.flash.graph.GraphSourceItem;
|
||||
import java.util.Random;
|
||||
|
||||
public class GetTimeTreeItem extends TreeItem {
|
||||
|
||||
public GetTimeTreeItem(GraphSourceItem instruction) {
|
||||
super(instruction, PRECEDENCE_PRIMARY);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString(ConstantPool constants) {
|
||||
return hilight("getTimer()");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCompileTime() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double toNumber() {
|
||||
return new Random().nextInt(10000) + 1000;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean toBoolean() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user