mirror of
https://github.com/skillbert/rsmv.git
synced 2025-12-23 21:47:48 -05:00
fix subtype detection for local vars
This commit is contained in:
@@ -974,7 +974,15 @@ export function varArgtype(stringconst: string | unknown, lastintconst: number |
|
||||
}
|
||||
|
||||
export function setRawOpcodeStackDiff(consts: StackConstants | null, calli: ClientscriptObfuscation, node: RawOpcodeNode) {
|
||||
if (node.opinfo.id == namedClientScriptOps.dbrow_getfield) {
|
||||
if (branchInstructionsInt.includes(node.opinfo.id)) {
|
||||
//make sure that left and right side are same type
|
||||
let uuid = typeuuids.int++;
|
||||
node.knownStackDiff = StackInOut.fromExact([uuid, uuid], []);
|
||||
} else if (branchInstructionsLong.includes(node.opinfo.id)) {
|
||||
//make sure that left and right side are same type
|
||||
let uuid = typeuuids.long++;
|
||||
node.knownStackDiff = StackInOut.fromExact([uuid, uuid], []);
|
||||
} else if (node.opinfo.id == namedClientScriptOps.dbrow_getfield) {
|
||||
//args are rowid,tablefield,subrow
|
||||
let tablefield = consts?.values.at(-2);
|
||||
if (typeof tablefield == "number") {
|
||||
|
||||
@@ -301,6 +301,7 @@ addWriter(RawOpcodeNode, (node, ctx) => {
|
||||
let gettypecast = (subt: PrimitiveType) => {
|
||||
if (exacttype == -1) { return ""; }
|
||||
if (exacttype == subtypes.int || exacttype == subtypes.string || exacttype == subtypes.long) { return ""; }
|
||||
if (exacttype == subtypes.unknown_int || exacttype == subtypes.unknown_string || exacttype == subtypes.unknown_long) { return ""; }
|
||||
return ` as ${subtypeToTs(exacttype)}`;
|
||||
}
|
||||
if (typeof node.op.imm_obj == "string") {
|
||||
|
||||
@@ -188,10 +188,11 @@ class CombinedExactStack {
|
||||
depfunc = getPositionalDep;
|
||||
}
|
||||
|
||||
if (stackinout.exactin) {
|
||||
for (let i = stackinout.exactin.int.length - 1; i >= 0; i--) { this.ctx.entangle(knownDependency(stackinout.exactin.int[i]), this.intstack.pop()); }
|
||||
for (let i = stackinout.exactin.long.length - 1; i >= 0; i--) { this.ctx.entangle(knownDependency(stackinout.exactin.long[i]), this.longstack.pop()); }
|
||||
for (let i = stackinout.exactin.string.length - 1; i >= 0; i--) { this.ctx.entangle(knownDependency(stackinout.exactin.string[i]), this.stringstack.pop()); }
|
||||
if (node.knownStackDiff?.exactin) {
|
||||
let exact = node.knownStackDiff.exactin;
|
||||
for (let i = exact.int.length - 1; i >= 0; i--) { this.ctx.entangle(knownDependency(exact.int[i]), this.intstack.pop()); }
|
||||
for (let i = exact.long.length - 1; i >= 0; i--) { this.ctx.entangle(knownDependency(exact.long[i]), this.longstack.pop()); }
|
||||
for (let i = exact.string.length - 1; i >= 0; i--) { this.ctx.entangle(knownDependency(exact.string[i]), this.stringstack.pop()); }
|
||||
} else {
|
||||
let stackin = stackinout.in;
|
||||
//need to do inputs in correct order because of vararg
|
||||
@@ -218,10 +219,11 @@ class CombinedExactStack {
|
||||
}
|
||||
}
|
||||
|
||||
if (stackinout.exactout) {
|
||||
for (let i = 0; i < stackinout.exactout.int.length; i++) { this.intstack.push(knownDependency(stackinout.exactout.int[i])); }
|
||||
for (let i = 0; i < stackinout.exactout.long.length; i++) { this.longstack.push(knownDependency(stackinout.exactout.long[i])); }
|
||||
for (let i = 0; i < stackinout.exactout.string.length; i++) { this.stringstack.push(knownDependency(stackinout.exactout.string[i])); }
|
||||
if (node.knownStackDiff?.exactout) {
|
||||
let exact = node.knownStackDiff.exactout;
|
||||
for (let i = 0; i < exact.int.length; i++) { this.intstack.push(knownDependency(exact.int[i])); }
|
||||
for (let i = 0; i < exact.long.length; i++) { this.longstack.push(knownDependency(exact.long[i])); }
|
||||
for (let i = 0; i < exact.string.length; i++) { this.stringstack.push(knownDependency(exact.string[i])); }
|
||||
} else {
|
||||
//only ensure order per primitive type
|
||||
let totalout = stackinout.out.getStackdiff();
|
||||
|
||||
Reference in New Issue
Block a user