Пример #1
0
  protected Value marshalObjectToNative(
      Function fn,
      MarshalerMethod marshalerMethod,
      MarshaledArg marshaledArg,
      Type nativeType,
      Value env,
      Value object,
      long flags) {

    Invokestatic invokestatic = marshalerMethod.getInvokeStatic(sootMethod.getDeclaringClass());
    trampolines.add(invokestatic);
    Value handle = call(fn, invokestatic.getFunctionRef(), env, object, new IntegerConstant(flags));

    Variable nativeValue = fn.newVariable(nativeType);
    if (nativeType instanceof StructureType || nativeType instanceof ArrayType) {
      Variable tmp = fn.newVariable(new PointerType(nativeType));
      fn.add(new Inttoptr(tmp, handle, tmp.getType()));
      fn.add(new Load(nativeValue, tmp.ref()));
    } else {
      fn.add(new Inttoptr(nativeValue, handle, nativeType));
    }

    if (marshaledArg != null) {
      marshaledArg.handle = handle;
      marshaledArg.object = object;
    }

    return nativeValue.ref();
  }
Пример #2
0
  protected Value marshalNativeToObject(
      Function fn,
      MarshalerMethod marshalerMethod,
      MarshaledArg marshaledArg,
      Value env,
      String valueClassName,
      Value nativeValue,
      long flags) {

    if (nativeValue.getType() instanceof StructureType) {
      nativeValue = createStackCopy(fn, nativeValue);
    }

    Invokestatic invokestatic = marshalerMethod.getInvokeStatic(sootMethod.getDeclaringClass());
    trampolines.add(invokestatic);

    Value valueClass = ldcClass(fn, valueClassName, env);

    Variable handle = fn.newVariable(I64);
    fn.add(new Ptrtoint(handle, nativeValue, I64));

    Value object =
        call(
            fn,
            invokestatic.getFunctionRef(),
            env,
            valueClass,
            handle.ref(),
            new IntegerConstant(flags));

    if (marshaledArg != null) {
      marshaledArg.handle = handle.ref();
      marshaledArg.object = object;
    }

    return object;
  }