From 8e7535e92fbb4305232eb19405f1d738437dcf4b Mon Sep 17 00:00:00 2001 From: Josh Ferrell Date: Tue, 21 Apr 2026 16:15:20 -0400 Subject: [PDB Import] Initial support for loading locals --- plugins/pdb-ng/src/parser.rs | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) (limited to 'plugins/pdb-ng/src/parser.rs') diff --git a/plugins/pdb-ng/src/parser.rs b/plugins/pdb-ng/src/parser.rs index 82a2bd75..9db635e8 100644 --- a/plugins/pdb-ng/src/parser.rs +++ b/plugins/pdb-ng/src/parser.rs @@ -34,7 +34,7 @@ use binaryninja::types::{ EnumerationBuilder, NamedTypeReference, NamedTypeReferenceClass, StructureBuilder, StructureType, Type, TypeClass, }; -use binaryninja::variable::NamedDataVariableWithType; +use binaryninja::variable::{NamedDataVariableWithType, NamedVariableWithType}; /// Megastruct for all the parsing /// Certain fields are only used by specific files, as marked below. @@ -252,7 +252,7 @@ impl<'a, S: Source<'a> + 'a> PDBParserInstance<'a, S> { address, name, type_, - locals: _, + locals, .. }) => { self.log(|| { @@ -276,7 +276,29 @@ impl<'a, S: Source<'a> + 'a> PDBParserInstance<'a, S> { Some(address), Some(self.platform.clone()), vec![], // TODO : Components - vec![], //TODO: local variables + locals + .iter() + .filter_map(|v| { + let Some(var_type) = &v.type_ else { + return None; + }; + if v.storage.len() != 1 { + // TODO: how should we handle variables with multiple storage locations? + return None; + } + + let mut var_loc = v.storage[0].location; + if v.storage[0].base_relative { + var_loc.storage -= self.arch.address_size() as i64; + } + Some(NamedVariableWithType { + variable: var_loc, + ty: var_type.clone(), + name: v.name.clone(), + auto_defined: false, + }) + }) + .collect::>(), )); } _ => {} -- cgit v1.3.1