diff options
| author | Rusty Wagner <rusty@vector35.com> | 2016-04-05 23:01:17 -0400 |
|---|---|---|
| committer | Rusty Wagner <rusty@vector35.com> | 2016-04-05 23:01:17 -0400 |
| commit | b505e0464383284e7ce8fefeffc18713488c2c48 (patch) | |
| tree | ed9966173963bd8c14a0c0d97e2a0581ed0b1d29 /function.cpp | |
| parent | 6b41b386563824547554bcfbbffe996c20c57d7d (diff) | |
Add backend support for discovering stack variables
Diffstat (limited to 'function.cpp')
| -rw-r--r-- | function.cpp | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/function.cpp b/function.cpp index ee2c5d36..df3b5090 100644 --- a/function.cpp +++ b/function.cpp @@ -210,3 +210,46 @@ Ref<FunctionGraph> Function::CreateFunctionGraph() BNFunctionGraph* graph = BNCreateFunctionGraph(m_object); return new FunctionGraph(graph); } + + +map<int64_t, NameAndType> Function::GetStackLayout() +{ + size_t count; + BNStackVariable* vars = BNGetStackLayout(m_object, &count); + + map<int64_t, NameAndType> result; + for (size_t i = 0; i < count; i++) + { + NameAndType nt; + nt.name = vars[i].name; + nt.type = new Type(BNNewTypeReference(vars[i].type)); + result[vars[i].offset] = nt; + } + + BNFreeStackLayout(vars, count); + return result; +} + + +void Function::CreateAutoStackVariable(int64_t offset, Type* type, const string& name) +{ + BNCreateAutoStackVariable(m_object, offset, type->GetObject(), name.c_str()); +} + + +void Function::CreateUserStackVariable(int64_t offset, Type* type, const string& name) +{ + BNCreateUserStackVariable(m_object, offset, type->GetObject(), name.c_str()); +} + + +void Function::DeleteAutoStackVariable(int64_t offset) +{ + BNDeleteAutoStackVariable(m_object, offset); +} + + +void Function::DeleteUserStackVariable(int64_t offset) +{ + BNDeleteUserStackVariable(m_object, offset); +} |
