You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Some variable definitions have type information, but don't produce a type name useful for future definitions, examples:
129
129
@@ -158,17 +158,17 @@ typedef int (MyFunc)(int ac, char **av); // type int ()(int, char **), name:MyFu
158
158
159
159
```
160
160
161
-
_How does Binary Ninja decide when to use a typelibrary (.bntl) file?_
161
+
### How does Binary Ninja decide when to use a typelibrary (.bntl) file?
162
162
163
163
Type Libraries are loaded when the corresponding library is imported by a BinaryView. (i.e. if an exe imports `ntdll.dll`, binja will look in the bv's platform for type libraries named ntdll.bntl and load the first one it finds)
164
164
165
-
_What's the difference between a named type and a named object?_
165
+
### What's the difference between a named type and a named object?
166
166
167
167
A named typeis a typewith a name that can identify it. For example, `color`is the name of type`enum {RED=0, ORANGE=1, YELLOW=2, ...}`.
168
168
169
169
A named objectis the name of an external/imported symbol for which the type library has type information. For example, `MessageBoxA`is the name of a function whose typeis`int ()(HWND, LPCSTR, LPCSTR, UINT)`.
170
170
171
-
_How do I find what type of type a typeobjectis? How many are there?_
171
+
### How do I find what type of type a type object is? How many are there?
172
172
173
173
I've seen "types of types", "sorts of types", "kinds of types", "classes of types" used to differentiate the varieties of possible types, and there are probably more. Binary Ninja uses "class", example:
174
174
@@ -183,26 +183,26 @@ Compare this to LLDB, which also uses the term "class", and currently has 19 of
183
183
184
184
Compare this to GDB, which uses the term "type code"and has 25 of them.
185
185
186
-
_Where are function parameter names stored?_
186
+
### Where are function parameter names stored?
187
187
188
188
While technically not part of the type, having names of function parameters is very useful and can thus be optionally stored in a type.
189
189
190
190
Function types (types with`.type_class == FunctionTypeClass`) have a `.parameters` attribute, a list of [`FunctionParameter`](https://api.binary.ninja/binaryninja.types-module.html#binaryninja.types.FunctionParameter) objects. When those objects have `.name==''` you get the bare bones function types like `int ()(int, char **)`. When those objects have their `.name` populated you get the more meaningful `int ()(int argc, char **argv)`.
_Why doesn't the types view show the types imported from type libraries?_
205
+
### Why doesn't the types view show the types imported from type libraries?
206
206
207
207
Because the type libraries added to a binary view only makes their type information _available_ for use. The types view will show a typefrom a type library only after it is used (on demand).
208
208
@@ -215,7 +215,7 @@ Try this experiment:
215
215
-set the type of some data to `struct Rectangle` (using `y`in linear view or via any other method described above)
216
216
-`bv.types`is extended, and the types view shows `struct Rectangle`in the auto types
217
217
218
-
_What's a named type reference?_
218
+
### What's a named type reference?
219
219
220
220
Named Type References are a way to refer to a type by name without having its declaration immediately available.
221
221
@@ -254,7 +254,7 @@ This makes sense! Now go to types view and `define struct Point { int x; int y;
254
254
255
255
You should repeat the experiment using `struct Rectangle`and see that you're allowed to create variables with type containing _pointers_ to unresolved type references.
256
256
257
-
_How are types represented?_
257
+
### How are types represented?
258
258
259
259
By a hierarchy of objects from [api/python/types.py](https://github.com/Vector35/binaryninja-api/blob/dev/python/types.py) referencing one another. The "glue"objectis [`binaryninja.types.Type`](https://api.binary.ninja/binaryninja.types-module.html#binaryninja.types.Type) and depending on the complexity of the type it represents (stored in its `.type_class` attribute), it could have an attribute with more information. For instance, if the `binaryninja.types.Type` has `.type_class == FunctionTypeClass` then its `.parameters` attribute is a list of [`binaryninja.types.FunctionParameter`](https://api.binary.ninja/binaryninja.types-module.html#binaryninja.types.FunctionParameter). See [typelib_dump.py](https://github.com/Vector35/binaryninja-api/blob/dev/python/examples/typelib_dump.py) for how this can work.
260
260
@@ -277,7 +277,7 @@ Type class=Structure
277
277
278
278
Here is the representation of `typeint ()(int, int)` named `MyFunctionType`from [typelib_create.py](https://github.com/Vector35/binaryninja-api/blob/dev/python/examples/typelib_create.py):
279
279
280
-
_When do named objects get used?_
280
+
### When do named objects get used?
281
281
282
282
When a binary is loaded and its external symbols is processed, the symbol names are searched against the named objects fromtype libraries. If there is a match, it obeys the typefrom the type library. Upon success, you'll see a message like:
0 commit comments