Class MSDataTypeUtils


  • public class MSDataTypeUtils
    extends java.lang.Object
    An abstract class containing static utility methods for creating structure data types.
    • Method Detail

      • is64Bit

        public static boolean is64Bit​(Program program)
        Determines if the indicated program appears to be 64 bit (has 64 bit pointers).
        Parameters:
        program - the program
        Returns:
        true if 64 bit.
      • getAlignedPack8Structure

        public static StructureDataType getAlignedPack8Structure​(DataTypeManager dataTypeManager,
                                                                 CategoryPath categoryPath,
                                                                 java.lang.String structureName)
        Gets an empty aligned structure with a packing value of 8 that can be use to create the model's data type.
        Parameters:
        dataTypeManager - the data type manager to associate with the structure.
        categoryPath - the structure's category path.
        structureName - the structure's name.
        Returns:
        the aligned pack(8) structure.
      • getAlignedPack4Structure

        public static StructureDataType getAlignedPack4Structure​(DataTypeManager dataTypeManager,
                                                                 CategoryPath categoryPath,
                                                                 java.lang.String structureName)
        Gets an empty aligned structure with a packing value of 4 that can be use to create the model's data type.
        Parameters:
        dataTypeManager - the data type manager to associate with the structure.
        categoryPath - the structure's category path.
        structureName - the structure's name.
        Returns:
        the aligned pack(4) structure.
      • getEHStateDataType

        public static DataType getEHStateDataType​(Program program)
        Gets an exception handling state data type.
        Parameters:
        program - the program for the data type.
        Returns:
        the exception handling state data type.
      • getPointerDisplacementDataType

        public static DataType getPointerDisplacementDataType​(Program program)
        Gets a pointer displacement data type.
        Parameters:
        program - the program for the data type.
        Returns:
        the pointer displacement data type.
      • getPMDDataType

        public static Structure getPMDDataType​(Program program)
        Gets a PMD displacement structure data type.
        Parameters:
        program - the program for the data type.
        Returns:
        the PMD data type or null.
      • getMatchingDataType

        public static DataType getMatchingDataType​(Program program,
                                                   DataType comparisonDt)
        Gets the named data type from the program or the windows data type archive. If neither the program or data type archive has an equivalent data type then the original data type is returned.
        Parameters:
        program - the program for the data type.
        comparisonDt - the data type it should match
        Returns:
        the matching data type
      • getAbsoluteAddress

        public static Address getAbsoluteAddress​(Program program,
                                                 Address address)
        Extracts an absolute address from the bytes in memory at the indicated address in memory.
        Parameters:
        program - the program containing the bytes
        address - the address in memory where the address bytes should be obtained.
        Returns:
        the absolute address or null if the address isn't in the program's memory.
      • getReferencedAddress

        public static Address getReferencedAddress​(Program program,
                                                   Address address)
        Gets the referred to address from the bytes in the program at the indicated address. If the program has 64 bit pointers, then a 32 bit image base offset value is expected to be found at the indicated address. If the program has 32 bit pointers, then a 32 bit absolute pointer value is expected at the indicated address.
        Parameters:
        program - the program whose memory is to be read.
        address - the address to start reading the bytes for the referenced address.
        Returns:
        the referred to address or null.
      • getBytes

        public static byte[] getBytes​(Memory memory,
                                      Address startAddress,
                                      int length)
                               throws InvalidDataTypeException
        Gets bytes from memory at the indicated startAddress. The length indicates the number of bytes that must be read from memory.
        Parameters:
        memory - the program memory for obtaining the bytes
        startAddress - the address to begin reading bytes
        length - the number of bytes to read
        Returns:
        the bytes
        Throws:
        InvalidDataTypeException - if the length number of bytes couldn't be read starting at the startAddress in memory.
      • getReferenceDataType

        public static DataType getReferenceDataType​(Program program,
                                                    DataType referredToDataType)
        Gets the appropriate reference data type. If program is 64 bit, then a 32-bit image base offset data type will be returned. Otherwise, a default pointer to the referredToDataType will be returned.
        Parameters:
        program - the program that will contain the returned data type
        referredToDataType - the data type that is at the address being referred to by the pointer or image base offset. Otherwise, null.
        Returns:
        the image base offset or pointer reference data type