Skip to content

Instantly share code, notes, and snippets.

@jcmoore
Last active November 29, 2016 20:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jcmoore/5b4ca4af4f4c98c4e2095aca51d5f064 to your computer and use it in GitHub Desktop.
Save jcmoore/5b4ca4af4f4c98c4e2095aca51d5f064 to your computer and use it in GitHub Desktop.
v8peek -- exposes hidden class to an electron runtime

Check any obj.junK in the devtools console.


Added V(junK_string, "junK") to #define INTERNALIZED_STRING_LIST(V) in electron-repo/vendor/node/deps/v8/src/heap-symbols.h

Modified electron-repo/vendor/node/deps/v8/src/objects.cc:

MaybeHandle<Object> Object::GetProperty(LookupIterator* it) {
  for (; it->IsFound(); it->Next()) {
    switch (it->state()) {
      case LookupIterator::NOT_FOUND:
      case LookupIterator::TRANSITION:
        UNREACHABLE();
      case LookupIterator::JSPROXY: {
        bool was_found;
        MaybeHandle<Object> result =
            JSProxy::GetProperty(it->isolate(), it->GetHolder<JSProxy>(),
                                 it->GetName(), it->GetReceiver(), &was_found);
        if (!was_found) it->NotFound();
        return result;
      }
      case LookupIterator::INTERCEPTOR: {
        bool done;
        Handle<Object> result;
        ASSIGN_RETURN_ON_EXCEPTION(
            it->isolate(), result,
            JSObject::GetPropertyWithInterceptor(it, &done), Object);
        if (done) return result;
        break;
      }
      case LookupIterator::ACCESS_CHECK:
        if (it->HasAccess()) break;
        return JSObject::GetPropertyWithFailedAccessCheck(it);
      case LookupIterator::ACCESSOR:
        return GetPropertyWithAccessor(it);
      case LookupIterator::INTEGER_INDEXED_EXOTIC:
        return ReadAbsentProperty(it);
      case LookupIterator::DATA:
        return it->GetDataValue();
    }
  }
  if (it->GetName()->IsName() && it->GetReceiver()->IsJSReceiver()) {
    if (Handle<Name>::cast(it->GetName())->Equals(it->isolate()->heap()->junK_string())) {
      return Handle<Object>(Smi::FromInt(static_cast<int>((intptr_t)Handle<JSReceiver>::cast(it->GetReceiver())->map())), it->isolate());
    }
  }
  return ReadAbsentProperty(it);
}

Bootstrapped with electron-repo/script/bootstrap.py -v --build_libchromiumcontent

Compiled for release by electron-repo/script/build.py -c R

Distributed using ./script/create-dist.py

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment