diff --git a/lib/type.js b/lib/type.js
index <HASH>..<HASH> 100644
--- a/lib/type.js
+++ b/lib/type.js
@@ -114,7 +114,11 @@ function Type (type) {
     if ('CString' == type.name) {
       rtn = type.ffi_type = bindings.FFI_TYPES.pointer
     } else {
-      rtn = type.ffi_type = bindings.FFI_TYPES[type.name]
+      var cur = type
+      while (!rtn && cur) {
+        rtn = cur.ffi_type = bindings.FFI_TYPES[cur.name]
+        cur = Object.getPrototypeOf(cur)
+      }
     }
   }
 
diff --git a/test/types.js b/test/types.js
index <HASH>..<HASH> 100644
--- a/test/types.js
+++ b/test/types.js
@@ -33,6 +33,15 @@ describe('types', function () {
       assert(Buffer.isBuffer(ffi_type))
     })
 
+    it('should match a valid `ffi_type` for `ulong` without a cached value', function () {
+      // simulate a ref type without a "ffi_type" property set
+      var type = Object.create(ref.types.ulong)
+      type.ffi_type = undefined
+
+      var ffi_type = ffi.ffiType(type)
+      assert(Buffer.isBuffer(ffi_type))
+    })
+
   })
 
 })
type: recurse up the prototype chain to type to find the `ffi_type` to use

Makes the "long" and "ulong" types work.