mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2024-11-23 20:52:03 +00:00
Merge remote-tracking branch 'origin/GP-1996_make_finding_opDel_opNew_more_generic--SQUASHED'
This commit is contained in:
commit
7a30cefebb
@ -1,72 +0,0 @@
|
||||
/* ###
|
||||
* IP: GHIDRA
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
// Developer script to generate test data. Not for general use.
|
||||
//@category TestScripts
|
||||
import java.util.*;
|
||||
|
||||
import classrecovery.*;
|
||||
import ghidra.app.script.GhidraScript;
|
||||
import ghidra.program.model.address.Address;
|
||||
import ghidra.program.model.listing.*;
|
||||
|
||||
public class FindOperatorDeletesAndNewsScript extends GhidraScript {
|
||||
|
||||
@Override
|
||||
public void run() throws Exception {
|
||||
|
||||
if (currentProgram == null) {
|
||||
println("There is no open program");
|
||||
return;
|
||||
}
|
||||
|
||||
RecoveredClassHelper classHelper = new RecoveredClassHelper(currentProgram, currentLocation,
|
||||
state.getTool(), this, false, false, false, monitor);
|
||||
|
||||
List<Address> discoveredOperatorDeletes =
|
||||
getFunctionAddressList(classHelper.findOperatorDeletes());
|
||||
|
||||
BookmarkManager bookmarkMgr = currentProgram.getBookmarkManager();
|
||||
|
||||
for (Address operatorDelete : discoveredOperatorDeletes) {
|
||||
monitor.checkCanceled();
|
||||
|
||||
bookmarkMgr.setBookmark(operatorDelete, BookmarkType.NOTE, "TEST",
|
||||
"Found operator_delete");
|
||||
}
|
||||
|
||||
List<Address> discoveredOperatorNews =
|
||||
getFunctionAddressList(classHelper.findOperatorNews());
|
||||
|
||||
for (Address operatorNew : discoveredOperatorNews) {
|
||||
monitor.checkCanceled();
|
||||
|
||||
bookmarkMgr.setBookmark(operatorNew, BookmarkType.NOTE, "TEST", "Found operator_new");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private List<Address> getFunctionAddressList(Set<Function> functions) {
|
||||
|
||||
List<Address> addresses = new ArrayList<Address>();
|
||||
for (Function function : functions) {
|
||||
|
||||
addresses.add(function.getEntryPoint());
|
||||
}
|
||||
return addresses;
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -847,28 +847,6 @@ public class ExtendedFlatProgramAPI extends FlatProgramAPI {
|
||||
return pdt;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to retrieve the minimum address on the given list
|
||||
* @param list the list of addresses
|
||||
* @return the minimum address on the given list
|
||||
*/
|
||||
public Address getMinimumAddressOnList(List<Address> list) {
|
||||
|
||||
Collections.sort(list);
|
||||
return list.get(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to retrieve the maximum address on the given list
|
||||
* @param list the list of addresses
|
||||
* @return the maximum address on the given list
|
||||
*/
|
||||
public Address getMaximumAddressOnList(List<Address> list) {
|
||||
|
||||
Collections.sort(list, Collections.reverseOrder());
|
||||
return list.get(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to retrieve the referenced Functions from the given referenceToClassMap
|
||||
* @param referenceToClassMap map of addresses that contain a reference to either a vftable or
|
||||
|
@ -117,8 +117,6 @@ public class RTTIGccClassRecoverer extends RTTIClassRecoverer {
|
||||
return recoveredClasses;
|
||||
}
|
||||
|
||||
createCalledFunctionMap(recoveredClasses);
|
||||
|
||||
createClassHierarchyListAndMapForGcc();
|
||||
|
||||
if (isDwarfLoaded) {
|
||||
@ -1849,12 +1847,6 @@ public class RTTIGccClassRecoverer extends RTTIClassRecoverer {
|
||||
private void processConstructorAndDestructors()
|
||||
throws CancelledException, InvalidInputException, DuplicateNameException, Exception {
|
||||
|
||||
// find deleting destructors using various mechanisms
|
||||
// findDeletingDestructors(recoveredClasses);
|
||||
|
||||
// use atexit param list to find more destructors
|
||||
// findDestructorsUsingAtexitCalledFunctions(recoveredClasses);
|
||||
|
||||
// figure out which are inlined and put on separate list to be processed later
|
||||
separateInlinedConstructorDestructors(recoveredClasses);
|
||||
|
||||
|
@ -131,14 +131,7 @@ public class RTTIWindowsClassRecoverer extends RTTIClassRecoverer {
|
||||
return recoveredClasses;
|
||||
}
|
||||
|
||||
//TODO: decide whether to update to only include possible cds not all functions that
|
||||
// have ref to vftable
|
||||
// if decide to be more restrictive then need to move the method that weeds out inlines and
|
||||
// from the class cd lists
|
||||
createCalledFunctionMap(recoveredClasses);
|
||||
|
||||
// figure out class hierarchies using either RTTI or vftable refs
|
||||
|
||||
monitor.setMessage("Assigning class inheritance and hierarchies");
|
||||
assignClassInheritanceAndHierarchies(recoveredClasses);
|
||||
|
||||
@ -1283,11 +1276,16 @@ public class RTTIWindowsClassRecoverer extends RTTIClassRecoverer {
|
||||
private void processConstructorAndDestructors(List<RecoveredClass> recoveredClasses)
|
||||
throws CancelledException, InvalidInputException, DuplicateNameException, Exception {
|
||||
|
||||
// update the global lists and class lists to narrow the cd lists
|
||||
trimConstructorDestructorLists(recoveredClasses);
|
||||
List<Address> allVftables = getAllVftables();
|
||||
|
||||
// update the class lists to narrow the class objects possible cd lists and indeterminate
|
||||
// lists to remove functions that are also on vfunction lists
|
||||
trimConstructorDestructorLists(recoveredClasses, allVftables);
|
||||
|
||||
determineOperatorDeleteAndNewFunctions(allVftables);
|
||||
|
||||
// find deleting destructors
|
||||
findDeletingDestructors(recoveredClasses);
|
||||
findDeletingDestructors(recoveredClasses, allVftables);
|
||||
|
||||
// use atexit param list to find more destructors
|
||||
findDestructorsUsingAtexitCalledFunctions(recoveredClasses);
|
||||
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user