Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@tjfontaine
Last active August 29, 2015 14:08
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 tjfontaine/754606eeb9b92943c074 to your computer and use it in GitHub Desktop.
Save tjfontaine/754606eeb9b92943c074 to your computer and use it in GitHub Desktop.
mdb node buffer pointer

For a given address, determine it is a Buffer (or use ::findjsobjects -c Buffer | ::findjsobjects to find a given buffer)

> 89f46b41::jsprint
{
    length: 11,
    parent: {
        length: 8192,
        used: 24,
    },
    offset: 8,
}

The parent and offset fields indicate this Buffer is a slice off a larger buffer, that doesn't change anything about how we're going to inspect it though.

::v8print that address

> 89f46b41::v8print
89f46b41 JSObject {
    89f46b41 JSReceiver {
        89f46b41 HeapObject < Object  {
            89f46b40 map = 8ec0a145 (Map)
        }
    }
    89f46b44 properties = 86a08081 (FixedArray)
    89f46b48 elements = 89f46bf5 (ExternalUnsignedByteArray)
}

Then ::v8print the address of elements that is the ExternalUnsignedByteArray -- note that this is the second number, the first is the offset of elements into the object, the second is the actual pointer to the ExternalUnsignedByteArray

> 89f46bf5::v8print
89f46bf5 ExternalUnsignedByteArray {
    89f46bf5 ExternalArray {
        89f46bf5 FixedArrayBase {
            89f46bf5 HeapObject < Object  {
                89f46bf4 map = 85d08591 (Map)
            }
            89f46bf8 length = 16 (SMI: value = 11)
        }
    }
}

The field immediately after length contains the pointer to the actual underlying C memory. This is 4 bytes (the size of the SMI it's representing)

> 89f46bf8+4/p
0x89f46bfc:     0x8de6810       

Notice we're adding 4 to the offset of length

If we take that address, we now have the actual memory location

> 0x8de6810/s
0x8de6810:      Hello World
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment