CN108491190A - Similar integral structural information acquisition methods, device and electronic equipment - Google Patents
Similar integral structural information acquisition methods, device and electronic equipment Download PDFInfo
- Publication number
- CN108491190A CN108491190A CN201810265206.5A CN201810265206A CN108491190A CN 108491190 A CN108491190 A CN 108491190A CN 201810265206 A CN201810265206 A CN 201810265206A CN 108491190 A CN108491190 A CN 108491190A
- Authority
- CN
- China
- Prior art keywords
- fields
- analyzed
- class
- structures
- array
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
Classifications
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/30—Creation or generation of source code
- G06F8/31—Programming languages or programming paradigms
- G06F8/315—Object-oriented languages
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/20—Software design
- G06F8/24—Object-oriented
Landscapes
- Engineering & Computer Science (AREA)
- Software Systems (AREA)
- General Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Computing Systems (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
Abstract
A kind of Similar integral structural information acquisition methods of the embodiment of the present application offer, device and electronic equipment, based on the RTTICompleteObjectLocator structures of class object to be analyzed to obtain pClassHierarchyDescriptor fields therein.RTTIClassHierarchyDescriptor structures are obtained according to the directional information of pClassHierarchyDescriptor fields, and further obtain numBaseClasses fields and pBaseClassArray fields therein.The number that can get the base class of class object to be analyzed according to numBaseClasses fields can get the RTTIBaseClassDescriptor Array for structural body for preserving base class name information according to pBaseClassArray fields.According to base class number and RTTIBaseClassDescriptor Array for structural body to obtain the name information of all base class of class object to be analyzed.In this way, the name information of the base class of class object to be analyzed can be obtained quickly and efficiently, the problem of base class name acquiring inconvenience existing in the prior art is improved, the development efficiency of developer is improved.
Description
Technical field
The present invention relates to applicating developing technology fields, in particular to a kind of Similar integral structural information acquisition methods, dress
It sets and electronic equipment.
Background technology
With the continuous expansion of the application range of smart machine, the application software applied to all kinds of smart machines also obtains
Extensive concern.Wherein, in the development process of application software, developer may need the internal storage structure according to object to obtain
Get such complete succession structural information.Through inventor the study found that object in existing technology it is complete after bearing structure
The mode of information there is a problem of inconvenient.
Invention content
In view of this, the purpose of the application is, a kind of Similar integral structural information acquisition methods, device and electronics are provided and set
For to improve the above problem.
The embodiment of the present application provides a kind of Similar integral structural information acquisition methods, the method includes:
The RTTICompleteObjectLocator structures in class object to be analyzed are obtained, described in access
RTTICompleteObjectLocator structures are to obtain the pClassHierarchyDescriptor fields in the structure;
It is obtained according to the directional information of the pClassHierarchyDescriptor fields
RTTIClassHierarchyDescriptor structures access the RTTIClassHierarchyDescriptor structures to obtain
Obtain the numBaseClasses fields and pBaseClassArray fields in the structure;
The number of the base class of the class object to be analyzed is obtained according to the numBaseClasses fields;
Obtain the RTTIBaseClassDescriptor Array for structural body that the pBaseClassArray fields are directed toward;
The number in the RTTIBaseClassDescriptor Array for structural body is accessed successively according to the number of the base class
Group element, to obtain the name information of all base class of the class object to be analyzed.
Further, the number according to the base class accesses the RTTIBaseClassDescriptor knots successively
The step of array element in structure body array, name information to obtain all base class of the class object to be analyzed, including:
The RTTIBaseClassDescriptor Array for structural body is accessed according to the number of the base class of acquisition, to obtain
Each number of the multiple array elements consistent with the number in the RTTIBaseClassDescriptor Array for structural body
PTypeDescritptor fields in group element;
For each single item array element of acquisition, the pTypeDescritptor fields obtained in the array element are signified
To TypeDescritptor structures;
The TypeDescritptor structures are accessed to obtain the name fields in the TypeDescritptor structures,
And the name information of the base class in the array element recorded in the character string at the name fields is obtained, to be waited for described in acquisition
Analyze the name information of all base class of class object.
Further, the step of RTTICompleteObjectLocator structures obtained in class object to be analyzed,
Including:
Obtain the address of the virtual table of class object to be analyzed;
It is obtained in the class object to be analyzed according to the address of the virtual table
The address of RTTICompleteObjectLocator structures;
It is described to obtain to search the address of the RTTICompleteObjectLocator structures
RTTICompleteObjectLocator structures.
Further, before the step of address of the virtual table for obtaining class object to be analyzed, the method is also wrapped
It includes:
It detects and whether there is Virtual Function in the class object to be analyzed;
If Virtual Function is not present, acquisition failure information is generated, if there are Virtual Function, executes the acquisition class to be analyzed
The step of address of the virtual table of object.
Further, after the step of address of the virtual table for obtaining class object to be analyzed, the method is also wrapped
It includes:
Information when detecting whether to enable operation;
If information when not enabled is run, generates acquisition failure information, if having enabled information when operation, execute according to institute
The address for stating virtual table obtains the address of RTTICompleteObjectLocator structures in the class object to be analyzed
Step.
Further, the address according to the virtual table obtains in the class object to be analyzed
The step of address of RTTICompleteObjectLocator structures, including:
The address of the virtual table is subtracted into specified numerical value to obtain in the class object to be analyzed
The address of RTTICompleteObjectLocator structures.
Further, the step of address of the virtual table for obtaining class object to be analyzed, including:
Obtain the originally address of the class object to be analyzed;
The integer value for obtaining first 4 byte since the originally address has to obtain the class object to be analyzed
The corresponding virtual table of Virtual Function address.
The embodiment of the present application also provides a kind of Similar integral structural information acquisition device, and described device includes:
Structured descriptor field acquisition module, for obtaining in class object to be analyzed
RTTICompleteObjectLocator structures access the RTTICompleteObjectLocator structures to obtain the knot
PClassHierarchyDescriptor fields in structure;
Base class data obtaining module, for the directional information according to the pClassHierarchyDescriptor fields
RTTIClassHierarchyDescriptor structures are obtained, the RTTIClassHierarchyDescriptor structures are accessed
To obtain the numBaseClasses fields and pBaseClassArray fields in the structure;
Number acquisition module, the base class for obtaining the class object to be analyzed according to the numBaseClasses fields
Number;
Array acquisition module, for obtaining the pBaseClassArray fields direction
RTTIBaseClassDescriptor Array for structural body;
Name information acquisition module, described in being accessed successively according to the number of the base class
Array element in RTTIBaseClassDescriptor Array for structural body, to obtain all bases of the class object to be analyzed
The name information of class.
The embodiment of the present application also provides a kind of electronic equipment, including:
Memory;
Processor;And
Similar integral structural information acquisition device, including one or more are stored in the memory and by the processor
The software function module of execution, the Similar integral structural information acquisition device include:
Structured descriptor field acquisition module, for obtaining in class object to be analyzed
RTTICompleteObjectLocator structures access the RTTICompleteObjectLocator structures to obtain the knot
PClassHierarchyDescriptor fields in structure;
Base class data obtaining module, for the directional information according to the pClassHierarchyDescriptor fields
RTTIClassHierarchyDescriptor structures are obtained, the RTTIClassHierarchyDescriptor structures are accessed
To obtain the numBaseClasses fields and pBaseClassArray fields in the structure;
Number acquisition module, the base class for obtaining the class object to be analyzed according to the numBaseClasses fields
Number;
Array acquisition module, for obtaining the pBaseClassArray fields direction
RTTIBaseClassDescriptor Array for structural body;
Name information acquisition module, described in being accessed successively according to the number of the base class
Array element in RTTIBaseClassDescriptor Array for structural body, to obtain all bases of the class object to be analyzed
The name information of class.
The embodiment of the present application also provides a kind of computer readable storage medium, and the computer-readable recording medium storage has
Instruction, when executed, realizes above-mentioned Similar integral structural information acquisition methods.
Similar integral structural information acquisition methods, device and electronic equipment provided by the embodiments of the present application are based on class to be analyzed
The RTTICompleteObjectLocator structures of object are to obtain pClassHierarchyDescriptor fields therein.
RTTIClassHierarchyDescriptor knots are obtained according to the directional information of pClassHierarchyDescriptor fields
Structure, and further obtain numBaseClasses fields and pBaseClassArray fields therein.According to
NumBaseClasses fields can get the number of the base class of class object to be analyzed, can be obtained according to pBaseClassArray fields
The RTTIBaseClassDescriptor Array for structural body of base class name information must be preserved.According to base class number and
RTTIBaseClassDescriptor Array for structural body is to obtain the name information of all base class of class object to be analyzed.In this way,
The name information that the base class of class object to be analyzed can quickly and efficiently be obtained improves base class title existing in the prior art
Inconvenient problem is obtained, the development efficiency of developer is improved.
To enable the above objects, features and advantages of the present invention to be clearer and more comprehensible, preferred embodiment cited below particularly, and coordinate
Appended attached drawing, is described in detail below.
Description of the drawings
In order to illustrate the technical solution of the embodiments of the present invention more clearly, below will be to needed in the embodiment attached
Figure is briefly described, it should be understood that the following drawings illustrates only certain embodiments of the present invention, therefore is not construed as pair
The restriction of range for those of ordinary skill in the art without creative efforts, can also be according to this
A little attached drawings obtain other relevant attached drawings.
Fig. 1 is the structure diagram of electronic equipment provided by the embodiments of the present application.
Fig. 2 is the flow chart of Similar integral structural information acquisition methods provided by the embodiments of the present application.
Fig. 3 is the flow chart of the sub-step of step S110 in Fig. 2.
Fig. 4 is the flow chart of the sub-step of step S111 in Fig. 3.
Fig. 5 is another flow chart of Similar integral structural information acquisition methods provided by the embodiments of the present application.
Fig. 6 is another flow chart of Similar integral structural information acquisition methods provided by the embodiments of the present application.
Fig. 7 is the flow chart of the sub-step of step S150 in Fig. 2.
Fig. 8 is the functional block diagram of Similar integral structural information acquisition device provided by the embodiments of the present application.
Icon:100- electronic equipments;110- Similar integral structural information acquisition device;111- structured descriptor fields obtain mould
Block;112- base class data obtaining modules;113- number acquisition module;114- array acquisition modules;115- name informations obtain mould
Block;120- processors;130- memories.
Specific implementation mode
Below in conjunction with attached drawing in the embodiment of the present invention, technical solution in the embodiment of the present invention carries out clear, complete
Ground describes, it is clear that described embodiments are only a part of the embodiments of the present invention, instead of all the embodiments.Usually exist
The component of the embodiment of the present invention described and illustrated in attached drawing can be arranged and be designed with a variety of different configurations herein.
Therefore, below the detailed description of the embodiment of the present invention to providing in the accompanying drawings be not intended to limit it is claimed
The scope of the present invention, but be merely representative of the present invention selected embodiment.Based on the embodiment of the present invention, people in the art
The every other embodiment that member is obtained without making creative work, shall fall within the protection scope of the present invention.
It should be noted that:Similar label and letter indicate similar terms in following attached drawing, therefore, once a certain Xiang Yi
It is defined, then it further need not be defined and explained in subsequent attached drawing in a attached drawing.
In the development process for carrying out application software by C Plus Plus, it may be necessary to according to the example of an object, from right
The class name of the object is got in the internal storage structure of elephant, and gets such complete succession structural information.Pass through inventor's
It studies for a long period of time, finds the corresponding computer program of application software when compiling enables operation in the C++ executable files of information,
Compiler can be to adding some other information inside the executable file.
And it is possible to which it includes RTTICompleteObjectLocator structures to learn in aforementioned information.Further
Ground is analyzed by the RTTICompleteObjectLocator structures, can therefrom get all base class of class object
Name information.
As shown in Figure 1, the embodiment of the present invention, which is based on the studies above discovery, provides a kind of electronic equipment 100, the electronics
Equipment 100 includes memory 130, processor 120 and Similar integral structural information acquisition device 110.
It is directly or indirectly electrically connected between the memory 130 and processor 120, to realize the transmission or friendship of data
Mutually.It is electrically connected for example, these elements can be realized between each other by one or more communication bus or signal wire.The class after
Bearing structure information acquisition device 110 can be stored in the storage including at least one in the form of software or firmware (firmware)
Software function module in device 130.The processor 120 is for executing the executable calculating stored in the memory 130
Machine program, for example, software function module and computer program etc. included by the Similar integral structural information acquisition device 110,
To realize Similar integral structural information acquisition methods.
Wherein, the memory 130 may be, but not limited to, random access memory (Random Access
Memory, RAM), read-only memory (Read Only Memory, ROM), programmable read only memory (Programmable
Read-Only Memory, PROM), erasable read-only memory (Erasable Programmable Read-Only
Memory, EPROM), electricallyerasable ROM (EEROM) (Electric Erasable Programmable Read-Only
Memory, EEPROM) etc..Wherein, memory 130 is for storing program, the processor 120 after receiving and executing instruction,
Execute described program.
The processor 120 may be a kind of IC chip, the processing capacity with signal.Above-mentioned processor
120 can be general processor, including central processing unit (Central Processing Unit, CPU), network processing unit
(Network Processor, NP) etc.;It can also be digital signal processor (DSP), application-specific integrated circuit (ASIC), scene
Programmable gate array (FPGA) either other programmable logic device, discrete gate or transistor logic, discrete hardware group
Part.It may be implemented or execute disclosed each method, step and the logic diagram in the embodiment of the present invention.General processor can be with
It is microprocessor or the processor 120 can also be any conventional processor etc..
It is appreciated that structure shown in FIG. 1 is only to illustrate, the electronic equipment 100 may also include more than shown in Fig. 1
Either less component or with the configuration different from shown in Fig. 1.Hardware, software may be used in each component shown in Fig. 1
Or combinations thereof realize.
Optionally, the concrete type of the electronic equipment 100 is unrestricted, for example, it may be, but be not limited to, intelligent hand
Machine, PC (personal computer, PC), tablet computer, personal digital assistant (personal digital
Assistant, PDA), mobile internet surfing equipment (mobile Internet device, MID), web (website) server, data
The equipment that server, computer, mobile internet surfing equipment (mobile Internet device, MID) etc. have processing function.
In conjunction with Fig. 2, the embodiment of the present invention also provides a kind of Similar integral structural information can be applied to above-mentioned electronic equipment 100
Acquisition methods.Wherein, method and step defined in the related flow of the method can be realized by the processor 120.Below
Detailed process shown in Fig. 2 will be described in detail.
Step S110, obtains the RTTICompleteObjectLocator structures in class object to be analyzed, described in access
RTTICompleteObjectLocator structures are to obtain the pClassHierarchyDescriptor fields in the structure.
In the present embodiment, referring to Fig. 3, can be obtained by following steps in class object to be analyzed
RTTICompleteObjectLocator structures:
Step S111 obtains the address of the virtual table of class object to be analyzed.
Step S112 is obtained according to the address of the virtual table in the class object to be analyzed
The address of RTTICompleteObjectLocator structures.
Step S113, it is described to obtain to search the address of the RTTICompleteObjectLocator structures
RTTICompleteObjectLocator structures.
In the present embodiment, it is contemplated that in C Plus Plus, if a class has Virtual Function, there are one empty letters for such tool
Number table.Also, the virtual table has certain pass with corresponding RTTICompleteObjectLocator structures on address
System.It therefore, can be by obtaining the table address of virtual table to obtain corresponding object address.Wherein, the object address refers to
To corresponding RTTICompleteObjectLocator structures.
In the present embodiment, since the object address is directed toward corresponding RTTICompleteObjectLocator structures,
That is, the address of the RTTICompleteObjectLocator structures is the object address.Therefore, can pass through
The object address finds corresponding RTTICompleteObjectLocator structures.
Wherein, referring to Fig. 4, in the present embodiment, step S111 may include following sub-step:
Step S1111 obtains the originally address of the class object to be analyzed.
Step S1112, the integer value for obtaining first 4 byte since the originally address are described to be analyzed to obtain
The address for the corresponding virtual table of Virtual Function that class object has.
In the present embodiment, it is contemplated that the virtual table can be located at the beginning address location of the class object, also,
The table address is that the integer value of first 4 byte in the initial address therefore can be by from class object to be analyzed
First address starts to obtain the integer value of first 4 byte, and the address where the integer value is the address of virtual table.
In C++ program languages, the object address generally can be fixed inclined in the presence of one with the virtual table address
Therefore shifting amount can carry out address offset processing with obtaining the object by the offset to the virtual table address
Location.Wherein, the offset can be 4, that is to say, that can subtract 4 using virtual table address and obtain
The address of RTTICompleteObjectLocator structures.
Further, it is contemplated that in C Plus Plus, a class is also possible to do not have virtual table, therefore, if directly holding
Row step S111, it is difficult to the table address for effectively getting virtual table, may result in processor 120 there are the wasting of resources with
And the problem of carrying out endless loop, therefore, in the present embodiment, in conjunction with Fig. 5, before executing step S111, the Similar integral knot
Structure information acquisition method can also include step S210 and step S220.
Step S210 is detected and be whether there is Virtual Function in the class object to be analyzed, if Virtual Function is not present, execute with
If lower step S220 thens follow the steps S111 there are Virtual Function.
Step S220 generates virtual table and obtains failure information.
It in the present embodiment, can timely termination when based on judging to obtain class name failure there is no virtual table
Execution of the device 120 into line program is managed, and then avoids the problem that the endless loop that results in waste of resources or enter.Also, it can also generate
Corresponding notification information, to notify developer.
Based on consideration same as described above, if information when not opening operation in the compilation process of program, step is being executed
When rapid S112, it is difficult to which the address for obtaining RTTICompleteObjectLocator structures according to the virtual table address is gone forward side by side
Processor 120 is caused to one step to there are problems that the wasting of resources or enter endless loop, in the present embodiment, in conjunction with Fig. 6, to avoid
The above problem, after executing step S111, the Similar integral structural information acquisition methods can also include step S310 and step
Rapid S320.
Step S310, information when detecting whether to enable operation, if information when not enabled is run, executes following steps
S320, if information when enabling operation, thens follow the steps S112.
Step S320, generating structure acquisition of information failure information.
In the present embodiment, when the operation information include RTTICompleteObjectLocator structures information.
When information judgement obtains failure when being run based on not enabled, and then it can be kept away into the execution of line program termination handler 120 in time
Exempt to result in waste of resources or into the problem of endless loop.Also, corresponding acquisition failure information can also be generated, to notify to develop
Personnel.
In the present embodiment, the RTTICompleteObjectLocator structures include 5 fields, are respectively successively,
Signature signature fields, offset fields, cdoffset fields, pTypeDescriptor fields and
PClassHierarchyDescriptor fields.In the present embodiment, RTTICompleteObjectLocator structures are being obtained
Afterwards, pClassHierarchyDescriptor fields therein can be found.
Step S120 is obtained according to the directional information of the pClassHierarchyDescriptor fields
RTTIClassHierarchyDescriptor structures access the RTTIClassHierarchyDescriptor structures to obtain
Obtain the numBaseClasses fields and pBaseClassArray fields in the structure.
Step S130 obtains the number of the base class of the class object to be analyzed according to the numBaseClasses fields.
Step S140 obtains the RTTIBaseClassDescriptor structures that the pBaseClassArray fields are directed toward
Body array.
In the present embodiment, pClassHierarchyDescriptor fields are directed toward
RTTIClassHierarchyDescriptor structures.It, can basis in the present embodiment
Related data in RTTIClassHierarchyDescriptor structures is tied with the complete succession for getting class object to be analyzed
Structure information.Wherein, RTTIClassHierarchyDescriptor structures generally comprise four fields, and first character section is 32
The signature signature fields of position integer, second field are the attribute fields of 32 integers, and third field is 32
The numBaseClasses fields of position integer, it is RTTIBaseClassDescriptor that the 4th field, which is a direction structure,
The pBaseClassArray pointer fields of structure.Wherein RTTIBaseClassDescriptor structures just have recorded the base class of class
Information.And numBaseClasses fields indicate how many base class such has altogether.
Step S150 accesses the RTTIBaseClassDescriptor structures successively according to the number of the base class
Array element in array, to obtain the name information of all base class of the class object to be analyzed.
In the present embodiment, referring to Fig. 7, step S150 includes following sub-step:
Step S151 accesses the RTTIBaseClassDescriptor structures number according to the number of the base class of acquisition
Group, to obtain multiple array elements consistent with the number in the RTTIBaseClassDescriptor Array for structural body
Each array element in pTypeDescritptor fields.
Step S152 is obtained for each single item array element of acquisition in the array element
TypeDescritptor structures pointed by pTypeDescritptor fields.
Step S153 accesses the TypeDescritptor structures to obtain in the TypeDescritptor structures
Name fields, and the name information of the base class in the array element recorded in the character string at the name fields is obtained, with
Obtain the name information of all base class of the class object to be analyzed.
Wherein, RTTIBaseClassDescriptor Array for structural body includes multiple array elements, for each number
Group element, the first field are the pointer pTypeDescritptor fields of a direction TypeDescritptor structure.It finds
The character string of name fields in the TypeDescritptor structures, the field locations name preserves the described array
The base class title of base class in element therefore can be by acquisition positioned at the character string of the field locations name, to obtain
State base class name information.Wherein, the name information of class to be analyzed and the institute of the class to be analyzed are preserved in the Array for structural body
The name information of some base class.
In conjunction with Fig. 8, the embodiment of the present application also provides a kind of Similar integral structural information can be applied to above-mentioned electronic equipment 100
Acquisition device 110.Wherein, the Similar integral structural information acquisition device 110 may include structured descriptor field acquisition module
111, base class data obtaining module 112, number acquisition module 113, array acquisition module 114 and name information acquisition module
115。
The structured descriptor field acquisition module 111 is for obtaining in class object to be analyzed
RTTICompleteObjectLocator structures access the RTTICompleteObjectLocator structures to obtain the knot
PClassHierarchyDescriptor fields in structure.In the present embodiment, the structured descriptor field acquisition module
111 can be used for executing step S110 shown in Fig. 2, and the specific descriptions about the structured descriptor field acquisition module 111 can
With with reference to the description to step S110 above.
The base class data obtaining module 112 is used for the finger according to the pClassHierarchyDescriptor fields
To information acquisition RTTIClassHierarchyDescriptor structures, described in access
RTTIClassHierarchyDescriptor structures with obtain numBaseClasses fields in the structure and
PBaseClassArray fields.In the present embodiment, the base class data obtaining module 112 can be used for executing step shown in Fig. 2
Rapid S120, the specific descriptions about the base class data obtaining module 112 are referred to the description to step S120 above.
The number acquisition module 113 is used to obtain the class object to be analyzed according to the numBaseClasses fields
Base class number.In the present embodiment, the number acquisition module 113 can be used for executing step S130 shown in Fig. 2, about
The specific descriptions of the number acquisition module 113 are referred to the description to step S130 above.
The array acquisition module 114 is used to obtain what the pBaseClassArray fields were directed toward
RTTIBaseClassDescriptor Array for structural body.In the present embodiment, the array acquisition module 114 can be used for executing
Step S140 shown in Fig. 2, the specific descriptions about the array acquisition module 114 are referred to above retouch step S140
It states.
Described in the name information acquisition module 115 is used to accessed successively according to the number of the base class
Array element in RTTIBaseClassDescriptor Array for structural body, to obtain all bases of the class object to be analyzed
The name information of class.In the present embodiment, the name information acquisition module 115 can be used for executing step S150 shown in Fig. 2,
Specific descriptions about the name information acquisition module 115 are referred to the description to step S150 above.
The embodiment of the present application also provides a kind of computer readable storage medium, is stored thereon with computer program, the program
The step of above-mentioned Similar integral structural information acquisition methods being realized when being executed by processor 120.
In conclusion Similar integral structural information acquisition methods, device and electronic equipment 100 provided by the embodiments of the present application,
It is therein to obtain based on the RTTICompleteObjectLocator structures of class object to be analyzed
PClassHierarchyDescriptor fields.It is obtained according to the directional information of pClassHierarchyDescriptor fields
RTTIClassHierarchyDescriptor structures, and further obtain numBaseClasses fields therein and
PBaseClassArray fields.The number that can get the base class of class object to be analyzed according to numBaseClasses fields, according to
PBaseClassArray fields can get the RTTIBaseClassDescriptor Array for structural body for preserving base class name information.
According to base class number and RTTIBaseClassDescriptor Array for structural body to obtain all base class of class object to be analyzed
Name information.In this way, the name information of the base class of class object to be analyzed can be obtained quickly and efficiently, the prior art is improved
Present in base class name acquiring inconvenience problem, improve the development efficiency of developer.
In embodiment provided herein, it should be understood that disclosed device and method, it can also be by other
Mode realize.The apparatus embodiments described above are merely exemplary, for example, the flow chart and block diagram in attached drawing are shown
Architectural framework in the cards, function and the behaviour of devices in accordance with embodiments of the present invention, method and computer program product
Make.In this regard, each box in flowchart or block diagram can represent a part for a module, section or code, institute
The part for stating module, section or code includes one or more executable instructions for implementing the specified logical function.
It should also be noted that at some as in the realization method replaced, the function of being marked in box can also be to be different from attached drawing
The sequence marked occurs.For example, two continuous boxes can essentially be basically executed in parallel, they sometimes can also be by
Opposite sequence executes, this is depended on the functions involved.It is also noted that each box in block diagram and or flow chart,
And the combination of the box in block diagram and or flow chart, function or the dedicated of action as defined in executing can be used to be based on hardware
System realize, or can realize using a combination of dedicated hardware and computer instructions.
It should be noted that herein, the terms "include", "comprise" or its any other variant are intended to non-row
His property includes, so that the process, method, article or equipment including a series of elements includes not only those elements, and
And further include other elements that are not explicitly listed, or further include for this process, method, article or equipment institute it is intrinsic
Element.In the absence of more restrictions, the element limited by sentence "including a ...", it is not excluded that including institute
State in the process, method, article or equipment of element that there is also other identical elements.
The foregoing is only a preferred embodiment of the present invention, is not intended to restrict the invention, for the skill of this field
For art personnel, the invention may be variously modified and varied.All within the spirits and principles of the present invention, any made by repair
Change, equivalent replacement, improvement etc., should all be included in the protection scope of the present invention.It should be noted that:Similar label and letter exist
Similar terms are indicated in following attached drawing, therefore, once being defined in a certain Xiang Yi attached drawing, are then not required in subsequent attached drawing
It is further defined and is explained.
The above description is merely a specific embodiment, but scope of protection of the present invention is not limited thereto, any
Those familiar with the art in the technical scope disclosed by the present invention, can easily think of the change or the replacement, and should all contain
Lid is within protection scope of the present invention.Therefore, protection scope of the present invention should be based on the protection scope of the described claims.
Claims (10)
1. a kind of Similar integral structural information acquisition methods, which is characterized in that the method includes:
The RTTICompleteObjectLocator structures in class object to be analyzed are obtained, described in access
RTTICompleteObjectLocator structures are to obtain the pClassHierarchyDescriptor fields in the structure;
It is obtained according to the directional information of the pClassHierarchyDescriptor fields
RTTIClassHierarchyDescriptor structures access the RTTIClassHierarchyDescriptor structures to obtain
Obtain the numBaseClasses fields and pBaseClassArray fields in the structure;
The number of the base class of the class object to be analyzed is obtained according to the numBaseClasses fields;
Obtain the RTTIBaseClassDescriptor Array for structural body that the pBaseClassArray fields are directed toward;
The member of the array in the RTTIBaseClassDescriptor Array for structural body is accessed successively according to the number of the base class
Element, to obtain the name information of all base class of the class object to be analyzed.
2. Similar integral structural information acquisition methods according to claim 1, which is characterized in that described according to the base class
Number accesses the array element in the RTTIBaseClassDescriptor Array for structural body successively, to be waited for described in acquisition point
The step of analysing the name information of all base class of class object, including:
The RTTIBaseClassDescriptor Array for structural body is accessed according to the number of the base class of acquisition, described in acquisition
Each array member of the multiple array elements consistent with the number in RTTIBaseClassDescriptor Array for structural body
PTypeDescritptor fields in element;
For each single item array element of acquisition, obtain pointed by the pTypeDescritptor fields in the array element
TypeDescritptor structures;
The TypeDescritptor structures are accessed to obtain the name fields in the TypeDescritptor structures, and are obtained
The name information of the base class in the array element recorded in the character string at the name fields is obtained, it is described to be analyzed to obtain
The name information of all base class of class object.
3. Similar integral structural information acquisition methods according to claim 1, which is characterized in that described to obtain class pair to be analyzed
The step of RTTICompleteObjectLocator structures as in, including:
Obtain the address of the virtual table of class object to be analyzed;
The knots of the RTTICompleteObjectLocator in the class object to be analyzed are obtained according to the address of the virtual table
The address of structure;
It is described to obtain to search the address of the RTTICompleteObjectLocator structures
RTTICompleteObjectLocator structures.
4. Similar integral structural information acquisition methods according to claim 3, which is characterized in that described to obtain class pair to be analyzed
Before the step of address of the virtual table of elephant, the method further includes:
It detects and whether there is Virtual Function in the class object to be analyzed;
If Virtual Function is not present, generates virtual table and obtain failure information, if there are Virtual Function, executes described obtain and wait for point
The step of analysing the address of the virtual table of class object.
5. Similar integral structural information acquisition methods according to claim 3, which is characterized in that described to obtain class pair to be analyzed
After the step of address of the virtual table of elephant, the method further includes:
Information when detecting whether to enable operation;
If information when not enabled is run, generating structure acquisition of information failure information execute root if having enabled information when operation
The ground of the RTTICompleteObjectLocator structures in the class object to be analyzed is obtained according to the address of the virtual table
The step of location.
6. Similar integral structural information acquisition methods according to claim 3, which is characterized in that described according to the Virtual Function
The address of table obtains the step of address of the RTTICompleteObjectLocator structures in the class object to be analyzed, packet
It includes:
The address of the virtual table is subtracted into specified numerical value to obtain in the class object to be analyzed
The address of RTTICompleteObjectLocator structures.
7. Similar integral structural information acquisition methods according to claim 3, which is characterized in that described to obtain class pair to be analyzed
The step of address of the virtual table of elephant, including:
Obtain the originally address of the class object to be analyzed;
The integer value of first 4 byte since the originally address is obtained to obtain the void that the class object to be analyzed has
The address of the corresponding virtual table of function.
8. a kind of Similar integral structural information acquisition device, which is characterized in that described device includes:
Structured descriptor field acquisition module, for obtaining the RTTICompleteObjectLocator in class object to be analyzed
Structure accesses the RTTICompleteObjectLocator structures to obtain in the structure
PClassHierarchyDescriptor fields;
Base class data obtaining module, for being obtained according to the directional information of the pClassHierarchyDescriptor fields
RTTIClassHierarchyDescriptor structures access the RTTIClassHierarchyDescriptor structures to obtain
Obtain the numBaseClasses fields and pBaseClassArray fields in the structure;
Number acquisition module, of the base class for obtaining the class object to be analyzed according to the numBaseClasses fields
Number;
Array acquisition module, the RTTIBaseClassDescriptor being directed toward for obtaining the pBaseClassArray fields
Array for structural body;
Name information acquisition module, described in being accessed successively according to the number of the base class
Array element in RTTIBaseClassDescriptor Array for structural body, to obtain all bases of the class object to be analyzed
The name information of class.
9. a kind of electronic equipment, which is characterized in that including:
Memory;
Processor;And
Similar integral structural information acquisition device, including one or more are stored in the memory and are executed by the processor
Software function module, the Similar integral structural information acquisition device includes:
Structured descriptor field acquisition module, for obtaining the RTTICompleteObjectLocator in class object to be analyzed
Structure accesses the RTTICompleteObjectLocator structures to obtain in the structure
PClassHierarchyDescriptor fields;
Base class data obtaining module, for being obtained according to the directional information of the pClassHierarchyDescriptor fields
RTTIClassHierarchyDescriptor structures access the RTTIClassHierarchyDescriptor structures to obtain
Obtain the numBaseClasses fields and pBaseClassArray fields in the structure;
Number acquisition module, of the base class for obtaining the class object to be analyzed according to the numBaseClasses fields
Number;
Array acquisition module, the RTTIBaseClassDescriptor being directed toward for obtaining the pBaseClassArray fields
Array for structural body;
Name information acquisition module, described in being accessed successively according to the number of the base class
Array element in RTTIBaseClassDescriptor Array for structural body, to obtain all bases of the class object to be analyzed
The name information of class.
10. a kind of computer readable storage medium, which is characterized in that the computer-readable recording medium storage has instruction, when
Described instruction is performed, and realizes the Similar integral structural information acquisition methods described in claim 1-7 any one.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201810265206.5A CN108491190A (en) | 2018-03-28 | 2018-03-28 | Similar integral structural information acquisition methods, device and electronic equipment |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201810265206.5A CN108491190A (en) | 2018-03-28 | 2018-03-28 | Similar integral structural information acquisition methods, device and electronic equipment |
Publications (1)
Publication Number | Publication Date |
---|---|
CN108491190A true CN108491190A (en) | 2018-09-04 |
Family
ID=63316602
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201810265206.5A Pending CN108491190A (en) | 2018-03-28 | 2018-03-28 | Similar integral structural information acquisition methods, device and electronic equipment |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN108491190A (en) |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN114527963A (en) * | 2020-11-23 | 2022-05-24 | 中国科学院信息工程研究所 | Class inheritance relationship identification method in C + + binary file and electronic device |
Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101751469A (en) * | 2004-02-10 | 2010-06-23 | 微软公司 | systems and methods for supporting inheritance for user-defined types |
CN102707947A (en) * | 2012-04-25 | 2012-10-03 | 北京大学 | High-efficiency dynamic type conversion implementation method |
CN107707544A (en) * | 2017-09-29 | 2018-02-16 | 国网江苏省电力公司电力科学研究院 | A kind of equipment automatic identification collocation methods of IEC 61850 |
-
2018
- 2018-03-28 CN CN201810265206.5A patent/CN108491190A/en active Pending
Patent Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101751469A (en) * | 2004-02-10 | 2010-06-23 | 微软公司 | systems and methods for supporting inheritance for user-defined types |
CN102707947A (en) * | 2012-04-25 | 2012-10-03 | 北京大学 | High-efficiency dynamic type conversion implementation method |
CN107707544A (en) * | 2017-09-29 | 2018-02-16 | 国网江苏省电力公司电力科学研究院 | A kind of equipment automatic identification collocation methods of IEC 61850 |
Non-Patent Citations (1)
Title |
---|
YES-HYH: ""RTTI实现详解"", 《HTTPS://BLOG.CSDN.NET/HEYUHANG112/ARTICLE/DETAILS/41982929》 * |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN114527963A (en) * | 2020-11-23 | 2022-05-24 | 中国科学院信息工程研究所 | Class inheritance relationship identification method in C + + binary file and electronic device |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN110162296B (en) | Method and device for generating application programming interface document and terminal equipment | |
US10198250B1 (en) | Partitioning based migration of systems to container and microservice based platforms | |
CN109347787B (en) | Identity information identification method and device | |
Kim et al. | Shared execution for efficiently testing product lines | |
US10318595B2 (en) | Analytics based on pipes programming model | |
CN107992741A (en) | A model training method, method and device for detecting URL | |
CN110474900B (en) | Game protocol testing method and device | |
EP3001319A1 (en) | Method for detecting libraries in program binaries | |
CN105653949B (en) | Malware program detection method and device | |
CN113535399A (en) | A kind of NFV resource scheduling method, device and system | |
CN109948074A (en) | Website data interconnection method, device, storage medium, processor and electronic equipment | |
CN109271789A (en) | Malicious process detection method, device, electronic equipment and storage medium | |
CN111124479A (en) | Configuration file analysis method and system and electronic equipment | |
CN114169311A (en) | A data analysis method and device | |
CN112181479A (en) | Method and device for determining difference between code file versions and electronic equipment | |
CN112486490B (en) | Front-end code packaging method and device, electronic equipment and storage medium | |
CN112631649B (en) | Smart contract management method, device, terminal equipment and medium | |
CN110084042A (en) | A kind of application heap Static Analysis Method and system | |
CN107133036A (en) | The management method and device of a kind of module | |
CN108491190A (en) | Similar integral structural information acquisition methods, device and electronic equipment | |
CN109345081A (en) | A kind of collecting method, device and electronic equipment | |
CN112596717B (en) | Multi-data packing method, device, electronic equipment and computer readable storage medium | |
CN113656044B (en) | Android installation package compression method and device, computer equipment and storage medium | |
US11356853B1 (en) | Detection of malicious mobile apps | |
CN115809193A (en) | Front-end reverse abnormal data robustness detection method, device and storage medium |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
RJ01 | Rejection of invention patent application after publication |
Application publication date: 20180904 |
|
RJ01 | Rejection of invention patent application after publication |