generic tag panel: binary editor now can edit byte[]

This commit is contained in:
honfika@gmail.com
2015-08-03 08:32:54 +02:00
parent 47152b3a13
commit 586111ea8a
5 changed files with 1301 additions and 1260 deletions

View File

@@ -23,6 +23,8 @@ import com.jpexs.decompiler.flash.types.BasicType;
import com.jpexs.decompiler.flash.types.annotations.SWFType;
import com.jpexs.helpers.ByteArrayRange;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
*
@@ -72,6 +74,10 @@ public class DebugIDTag extends Tag {
*/
@Override
public void getData(SWFOutputStream sos) throws IOException {
if (debugId.length != 16) {
Logger.getLogger(DebugIDTag.class.getName()).log(Level.WARNING, "DebugID should be 16 bytes");
}
sos.write(debugId);
}
}

View File

@@ -25,6 +25,8 @@ import com.jpexs.decompiler.flash.types.annotations.Reserved;
import com.jpexs.decompiler.flash.types.annotations.SWFType;
import com.jpexs.helpers.ByteArrayRange;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
* Enable flash profiling information
@@ -71,6 +73,10 @@ public class EnableTelemetryTag extends Tag {
public final void readData(SWFInputStream sis, ByteArrayRange data, int level, boolean parallel, boolean skipUnusualTags, boolean lazy) throws IOException {
reserved = (int) sis.readUB(16, "reserved");
if (sis.available() > 0) {
if (passwordHash.length != 32) {
Logger.getLogger(EnableTelemetryTag.class.getName()).log(Level.WARNING, "PasswordHash should be 32 bytes");
}
passwordHash = sis.readBytesEx(32, "passwordHash");
}
}

View File

@@ -41,6 +41,10 @@ public class ReflectionTools {
}
public static Object getValue(Object obj, Field field, int index) throws IllegalArgumentException, IllegalAccessException {
if (index == -1) {
return getValue(obj, field);
}
if (getFieldSubSize(obj, field) <= index) {
return null;
}
@@ -87,6 +91,11 @@ public class ReflectionTools {
@SuppressWarnings("unchecked")
public static void setValue(Object obj, Field field, int index, Object newValue) throws IllegalArgumentException, IllegalAccessException {
if (index == -1) {
setValue(obj, field, newValue);
return;
}
Object value = field.get(obj);
if (needsIndex(field) && index >= getFieldSubSize(obj, field)) { //outofbounds, ignore
return;