@@ -26,6 +26,7 @@ def __init__(self, config=None, backend=None):
2626 config = SmdaConfig ()
2727 self .config = config
2828 self .disassembler = None
29+ self ._explicit_backend = bool (backend )
2930 if backend == "intel" :
3031 self .disassembler = IntelDisassembler (self .config )
3132 elif backend == "cil" :
@@ -136,8 +137,8 @@ def disassembleFile(self, file_path, pdb_path=""):
136137 self .disassembler .addPdbFile (binary_info , pdb_path )
137138 smda_report = self ._disassemble (binary_info , timeout = self .config .TIMEOUT )
138139 if self .config .WITH_STRINGS :
139- is_go_binary = GoSymbolProvider (None ).getPcLntabOffset (binary_info .binary )
140- string_mode = "go" if is_go_binary else None
140+ go_pclntab_offset = GoSymbolProvider (None ).getPcLntabOffset (binary_info .binary )
141+ string_mode = "go" if go_pclntab_offset is not None else None
141142 self ._addStringsToReport (smda_report , binary_info .binary , mode = string_mode )
142143 if self .config .STORE_BUFFER :
143144 smda_report .buffer = binary_info .binary
@@ -157,8 +158,8 @@ def disassembleUnmappedBuffer(self, file_content):
157158 self .initDisassembler (binary_info .architecture )
158159 smda_report = self ._disassemble (binary_info , timeout = self .config .TIMEOUT )
159160 if self .config .WITH_STRINGS :
160- is_go_binary = GoSymbolProvider (None ).getPcLntabOffset (binary_info .binary )
161- string_mode = "go" if is_go_binary else None
161+ go_pclntab_offset = GoSymbolProvider (None ).getPcLntabOffset (binary_info .binary )
162+ string_mode = "go" if go_pclntab_offset is not None else None
162163 self ._addStringsToReport (smda_report , file_content , mode = string_mode )
163164 if self .config .STORE_BUFFER :
164165 smda_report .buffer = file_content
@@ -186,7 +187,7 @@ def disassembleBuffer(
186187 # Auto-detect DEX when the caller did not explicitly override architecture.
187188 # disassembleUnmappedBuffer / disassembleFile already use FileLoader for detection;
188189 # this path bypasses it, so we check the magic bytes manually here.
189- if architecture == "intel" and DexFileLoader .isCompatible (file_content ):
190+ if not self . _explicit_backend and architecture == "intel" and DexFileLoader .isCompatible (file_content ):
190191 architecture = "dalvik"
191192 if bitness is None :
192193 bitness = DexFileLoader .getBitness (file_content )
@@ -205,8 +206,8 @@ def disassembleBuffer(
205206 try :
206207 smda_report = self ._disassemble (binary_info , timeout = self .config .TIMEOUT )
207208 if self .config .WITH_STRINGS :
208- is_go_binary = GoSymbolProvider (None ).getPcLntabOffset (binary_info .binary )
209- string_mode = "go" if is_go_binary else None
209+ go_pclntab_offset = GoSymbolProvider (None ).getPcLntabOffset (binary_info .binary )
210+ string_mode = "go" if go_pclntab_offset is not None else None
210211 self ._addStringsToReport (smda_report , file_content , mode = string_mode )
211212 if self .config .STORE_BUFFER :
212213 smda_report .buffer = file_content
0 commit comments