[go: up one dir, main page]
More Web Proxy on the site http://driver.im/

CN101794220B - Compression method and device of definition types in.net file - Google Patents

Compression method and device of definition types in.net file Download PDF

Info

Publication number
CN101794220B
CN101794220B CN2009102441633A CN200910244163A CN101794220B CN 101794220 B CN101794220 B CN 101794220B CN 2009102441633 A CN2009102441633 A CN 2009102441633A CN 200910244163 A CN200910244163 A CN 200910244163A CN 101794220 B CN101794220 B CN 101794220B
Authority
CN
China
Prior art keywords
define styles
information
compression
styles
define
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.)
Expired - Fee Related
Application number
CN2009102441633A
Other languages
Chinese (zh)
Other versions
CN101794220A (en
Inventor
陆舟
于华章
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Feitian Technologies Co Ltd
Original Assignee
Feitian Technologies Co Ltd
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by Feitian Technologies Co Ltd filed Critical Feitian Technologies Co Ltd
Priority to CN2009102441633A priority Critical patent/CN101794220B/en
Publication of CN101794220A publication Critical patent/CN101794220A/en
Priority to PCT/CN2010/080459 priority patent/WO2011079796A1/en
Priority to US13/129,296 priority patent/US8805801B2/en
Application granted granted Critical
Publication of CN101794220B publication Critical patent/CN101794220B/en
Expired - Fee Related legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Landscapes

  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The invention provides compression method and device of definition types in a .net file, belonging to the field of computer application. The compression method comprises the following steps of: acquiring information contained in the definition types used in the .net file; acquiring the appointed information and the counting information of the definition types according to the information contained in the definition types; compressing the appointed information; and storing the compressed appointed information and the counting information as the compression result of the definition types. The device comprises a definition type information acquiring module, a compression module and a compression result storing module. The invention effectively reduces the storage capacity occupied by the .net file through compressing the definition types in the .net file so as to enable the .net file to be stored and run on a small-capacity storage medium (such as an intelligent card).

Description

.net the compression method of define styles and device in the file
Technical field
The present invention relates to computer application field, the compression method and the device of define styles in a kind of .net file.
Background technology
.Net be the technology platform of new generation of Microsoft, be brand-new based on the internet stride the lingware development platform, complied with current software industry Distributed Calculation, facing assembly, enterprise-level application, software serviceization and be megatrend such as center with Web..Net be not development language, but on the .Net development platform, can support multiple development language, like C# language, C++, Visual Basic, Jscript etc.
Smart card is a kind of size and the similar plastic cards of common business card, includes a silicon about diameter 1cm, has canned data and the function of carrying out complex calculation.It is widely used in fields such as phonecard, fiscard, identification card and mobile phone, pay TV.Wherein, integrated microprocessor, storer and I/O unit etc. on the chip of smart card make smart card be considered to minimum in the world robot calculator.And on smart card, have the stronger safe and secret controlling mechanism of a whole set of performance, the security control program is cured in the ROM (read-only memory), thereby has safety assurances reliably such as can't duplicating password.Smart card is compared with common magnetic card, and it is big also to have an information storage capacity, and microprocessor capable of using increases advantages such as card function.
.Net card is a kind of microprocessor intelligence card that contains the .Net card virtual machine that can move the .Net program.So-called virtual machine; Be meant and be imagined as a machine of simulating to it with software; Various hardware such as processor, internal memory, register are arranged in this machine; The various instructions of dry run, the software that on this machine, moves does not have specific (special) requirements to running environment, so virtual machine is transparent to the program of on it, moving.For example, what the x86 virtual machine was simulated is the running environment of x86 instruction repertorie, and what the c51 virtual machine was simulated is the running environment of c51 instruction repertorie.
.net program comprises NameSpace, reference type, define styles, define method, quoting method, IL (Intermediate Language, intermediate language) code etc.
But present smart card is owing to the restriction of volume and storage chip, and its storage space is still limited, and along with the development of software, it is bigger that the program that partial function is big takies storage space, can not store and move for a lot of .net programs.
In sum, the .net program compression effectiveness in the correlation technique is relatively poor, can not be well at the storage medium of low capacity (for example: smart card) go up storage and operation, and do not propose effective solution at present as yet to this problem.
Summary of the invention
The present invention aims to provide the compression method and the device of define styles in a kind of .net file, and it is relatively poor to solve .ne t program compression effectiveness, can not be well at the storage medium of low capacity (for example: smart card) go up problems such as storage and operation.
In an embodiment of the present invention, the compression method of define styles in a kind of .net file is provided, said method comprises:
Obtain the information that the define styles that uses in the .net file comprises;
The information that comprises according to said define styles is obtained the appointed information and the count information of said define styles;
Said appointed information is compressed;
Appointed information and said count information after the compression are stored as the compression result of said define styles.
The embodiment of the invention also provides the compression set of define styles in a kind of .net file, and said device comprises:
Define styles information acquisition module is used for obtaining the information that define styles that the .net file uses comprises; The information that comprises according to said define styles is obtained the appointed information and the count information of said define styles;
Compression module is used for the appointed information that said define styles information acquisition module obtains is compressed;
Compression result storing module is used for the count information that the appointed information after the compression of said compression module and said define styles information acquisition module obtain is stored as the compression result of said define styles.
Present embodiment adopts the various piece of the define styles in the .net file is compressed; And with the compression result of each several part according to predetermined format; Overcome the big problem of memory capacity that the .net file takies; And then make the .net file can be (for example: smart card) go up storage and operation, and then (for example: function smart card) strengthened the low capacity storage medium at the low capacity storage medium.
Description of drawings
Accompanying drawing described herein is used to provide further understanding of the present invention, constitutes the application's a part, and illustrative examples of the present invention and explanation thereof are used to explain the present invention, do not constitute improper qualification of the present invention.In the accompanying drawings:
Fig. 1 shows the compression set of define styles in the .net file that embodiment 1 provides;
Fig. 2 shows the compression set of define styles in the .net file that embodiment 2 provides;
Fig. 3 shows the compression set of define styles in the .net file that embodiment 3 provides;
Fig. 4 shows the compression set of define styles in the .net file that embodiment 4 provides;
Fig. 5 shows the compression set of define styles in the .net file that embodiment 5 provides;
Fig. 6 shows the compression method process flow diagram of define styles in the .net file that embodiment 6 provides;
Fig. 7 shows the structural representation of the .net file that embodiment 7 provides;
Fig. 8 shows the compression method process flow diagram of define styles in the .net file that embodiment 7 provides.
Embodiment
Below with reference to accompanying drawing and combine embodiment, specify the present invention.
Embodiment 1
Referring to Fig. 1, present embodiment provides the compression set of define styles in a kind of .net file, and this device comprises:
Define styles information acquisition module 102 is used for obtaining the information that define styles that the .net file uses comprises; The information that comprises according to this define styles is obtained the appointed information and the count information of this define styles;
Compression module 104 is used for the appointed information that define styles information acquisition module 102 obtains is compressed;
Compression result storing module 106 is used for the count information that the appointed information after compression module 104 compression and define styles information acquisition module 102 obtain is stored as the compression result of this define styles.
Wherein, the concrete realization of define styles information acquisition module 102 can be: read the metadata table at the define styles place in the .net file earlier, i.e. metadata table TypeDef; From metadata table TypeDef, obtain the information that the define styles that uses in the .net file comprises again.
The information that this define styles comprises in the present embodiment comprises: the side-play amount of the sign of this define styles, the title of this define styles, the side-play amount of the method in this define styles;
When having used field in this define styles, can also comprise the side-play amount of the field in this define styles in the information that this define styles comprises; These information can obtain through the data that read among the metadata table TypeDef, and in metadata table TypeDef, each row of data is represented a define styles, and each row of data is totally 14 bytes, and the information of these 14 byte records is:
Preceding 4 bytes are Flags (define styles sign); 5,6 bytes are the side-play amount of define styles title in " #Strings " stream; 7,8 bytes are the namespace name side-play amount in " #Strings " stream in the .net file under this define styles; 9,10 bytes are the side-play amount of the parent of being inherited of this define styles; 11, the side-play amount of field in metadata table Field table that comprise for this define styles of 12 bytes, 13,14 bytes are the side-play amount of method in metadata table Method table that this define styles comprised.
According to the information that this define styles in the present embodiment comprises, above-mentioned appointed information comprises: the sign of this define styles, the title of this define styles can also comprise the corresponding information of field in this define styles; Wherein, The title of this define styles can find in .net file corresponding data flow according to the side-play amount of the title of above-mentioned this define styles, and the corresponding information of the field of this define styles also can find in metadata table Field table through the side-play amount of above-mentioned field;
Count information comprises: method counting that comprises in the method overloading information of this define styles, this define styles and field counting etc.
When 104 pairs of appointed information of the compression module of present embodiment are compressed, can according to the compression concrete Object Selection compression method, for example:
When the sign of define styles is compressed, can be earlier the sign of define styles be divided into type identification, access identities and descriptive sign; Then, type identification, access identities and descriptive sign are carried out exclusive disjunction, the data that obtain are as the compression result of the sign of this define styles;
When the title of define styles is compressed, can carry out Hash operation, from operation result, extract the compression result of the byte of agreement as the title of this define styles to the title of define styles;
When compressing, the information content corresponding according to field is divided into following three kinds of situation to the corresponding information (type of the title of field, the sign of field and field) of the field in the define styles:
1) title of above-mentioned field is carried out Hash operation, from operation result, extract the compression result of the byte of agreement as the title of this field;
2) sign with above-mentioned field is divided into access identities and descriptive sign, and access identities in the sign of above-mentioned field and descriptive sign are carried out exclusive disjunction, and the result who obtains is as the compression result of the sign of this field;
3) with the compression result of the side-play amount in the type of type after compression of above-mentioned field as the type of this field.
Can know by foregoing, comprise in the define styles after the compression: the information that the field in the field counting that is comprised in the compression result of define styles title, the compression result of type identification, the type, method counting, method overloading information, the type is corresponding etc.These information can also can be arranged arbitrarily according to predetermined format permutation.
Present embodiment is through compressing the various piece of the define styles in the .net file; And with the compression result of each several part according to predetermined format; Can reduce the storage space that the .net file takies effectively; Make the .net file can be (for example: smart card) go up storage and operation, and then (for example: function smart card) strengthened the low capacity storage medium at the low capacity storage medium.
Embodiment 2
Referring to Fig. 2, present embodiment provides the compression set of define styles in a kind of .net file, and this device comprises:
Define styles information acquisition module 102 is used for obtaining the information that define styles that the .net file uses comprises; The information that comprises according to this define styles is obtained the appointed information and the count information of this define styles;
Wherein, The concrete realization of define styles information acquisition module 102 is identical with embodiment 1; Here repeat no more, the information that this define styles comprises in the present embodiment comprises: the side-play amount of the side-play amount of the sign of this define styles, the title of this define styles, the side-play amount of the method in this define styles and the parent that define styles is inherited; The side-play amount that can also comprise the field in this define styles in the information that this define styles comprises;
Appointed information comprises: the sign of this define styles, the title of this define styles can also comprise the corresponding information of field in this define styles; Count information comprises: method counting that comprises in the method overloading information of this define styles, this define styles and field counting etc.
Compression module 104 is used for the appointed information that define styles information acquisition module 102 obtains is compressed;
First judge module 105 is used for judging whether the parent that the define styles of define styles information acquisition module 102 is inherited compresses;
Parent side-play amount acquisition module 107, the result who is used for when first judge module 105 is judged is that the parent of inheriting compresses, obtains the side-play amount of the parent of succession; If the parent of inheriting is compression not, the parent of inheriting is compressed, and be the parent allocation offsets amount after the compression;
Compression result storing module 106, the parent side-play amount of the succession that is used for the appointed information after compression module 104 compression, count information that define styles information acquisition module 102 obtains and parent side-play amount acquisition module 107 are obtained is stored as the compression result of this define styles.
Concrete implementation method when 104 pairs of appointed information of the compression module in the present embodiment are compressed can be identical with the method among the embodiment 1, no longer details here.
The type of the parent that current define styles is inherited in the present embodiment possibly be reference type, and this reference type is stored among the metadata table TypeRef, at this moment, can from this metadata table TypeRef, directly find the side-play amount of the parent of being inherited; Perhaps, the type of the parent that current define styles is inherited possibly also be define styles, at this moment, needs to judge earlier whether the parent of being inherited compresses, if not compression, then side-play amount of compression reallocation earlier if compressed, is then directly obtained its side-play amount.
Can know by foregoing, comprise in the define styles after the present embodiment compression: the information of field etc. in the parent side-play amount of method overloading information, succession, the type in the field counting that is comprised in the compression result of define styles title, the compression result of type identification, the type, the type.These information can also can be arranged arbitrarily according to predetermined format permutation.
Present embodiment is through compressing the various piece of the define styles in the .net file; And with the compression result of each several part according to predetermined format; Can reduce the storage space that the .net file takies effectively; Make the .net file can be (for example: smart card) go up storage and operation, and then (for example: function smart card) strengthened the low capacity storage medium at the low capacity storage medium.
Embodiment 3
Referring to Fig. 3; Present embodiment provides the compression set of define styles in a kind of .net file, and this device comprises: define styles information acquisition module 102, compression module 104, second judge module 108, interface message acquisition module 109 and compression result storing module 106; Wherein, the function of define styles information acquisition module 102 and compression module 104 is identical with the function of respective modules among embodiment 1, the embodiment 2, repeats no more here;
Second judge module 108, whether the define styles that is used for judging define styles information acquisition module 102 has the interface of succession;
Interface message acquisition module 109, the result who is used for judging when second judge module 108 is the interface that this define styles has succession, obtains the number of the interface of side-play amount and succession after the interface compression that this define styles inherits;
Compression result storing module 106 is used for the number of the interface of the side-play amount of the interface of the appointed information after compression module 104 compression, count information that define styles information acquisition module 102 obtains, succession that interface message acquisition module 109 obtains and succession is stored as the compression result of this define styles.
Can know by foregoing, comprise in the define styles after the present embodiment compression: the information of field etc. in the skew after the interface compression that method overloading information, type are inherited in the field counting that is comprised in the interface counting that the compression result of define styles title, the compression result of type identification, type are inherited, the type, the type, the type.These information can also can be arranged arbitrarily according to predetermined format permutation.
Present embodiment is through compressing the various piece of the define styles in the .net file; And with the compression result of each several part according to predetermined format; Can reduce the storage space that the .net file takies effectively; Make the .net file can be (for example: smart card) go up storage and operation, and then (for example: function smart card) strengthened the low capacity storage medium at the low capacity storage medium.
Embodiment 4
Referring to Fig. 4; Present embodiment provides the compression set of define styles in a kind of .net file, and this device comprises: define styles information acquisition module 102, compression module 104, the 3rd judge module 110, side-play amount acquisition module 111 and compression result storing module 106; Wherein, the function of define styles information acquisition module 102 and compression module 104 is identical with the function of respective modules among embodiment 1, the embodiment 2, repeats no more here;
The 3rd judge module 110 is used for judging whether the define styles of define styles information acquisition module 102 is nested types;
Side-play amount acquisition module 111 is used for when result that the 3rd judge module 110 is judged is nested type for this define styles, the side-play amount after the type of obtaining this nested type place is compressed;
Compression result storing module 106 is used for the side-play amount after the type compression at the appointed information after compression module 104 compression, count information that define styles information acquisition module 102 obtains, this define styles place that side-play amount acquisition module 111 obtains is stored as the compression result of this define styles.
Can know by foregoing, comprise in the define styles after the present embodiment compression: the information of field etc. in the side-play amount of the type at method overloading information, nested type place, the type in the field counting that is comprised in the compression result of define styles title, the compression result of type identification, the type, the type.These information can also can be arranged arbitrarily according to predetermined format permutation.
Present embodiment is through compressing the various piece of the define styles in the .net file; And with the compression result of each several part according to predetermined format; Can reduce the storage space that the .net file takies effectively; Make the .net file can be (for example: smart card) go up storage and operation, and then (for example: function smart card) strengthened the low capacity storage medium at the low capacity storage medium.
Embodiment 5
Referring to Fig. 5; Present embodiment provides the compression set of define styles in a kind of .net file; This device comprises each module among the embodiment 1-4; Wherein, the function of define styles information acquisition module 102, compression module 104, first judge module 105, parent side-play amount acquisition module 107, second judge module 108, interface message acquisition module 109, the 3rd judge module 110, side-play amount acquisition module 111 is identical with the function of respective modules in the foregoing description, no longer details here;
Compression result storing module 106, the side-play amount that is used for after the type compression that number, side-play amount acquisition module 111 with the interface of side-play amount after the interface compression of the side-play amount after the parent compression of the appointed information after compression module 104 compression, count information that define styles information acquisition module 102 obtains, succession that parent side-play amount acquisition module 107 obtains, succession that interface message acquisition module 109 obtains and succession obtain this define styles place is stored as the compression result of this define styles.
Can know by foregoing, comprise in the define styles after the present embodiment compression: the information of field etc. in the side-play amount in the field counting that is comprised in the compression result of define styles title, the compression result of type identification, the type, the type after the type compression at the number of the interface of the side-play amount of the interface of the parent side-play amount of method overloading information, succession, succession, succession, define styles place, the type.These information can also can be arranged arbitrarily according to predetermined format permutation.
Present embodiment is through compressing the various piece of the define styles in the .net file; And with the compression result of each several part according to predetermined format; Can reduce the storage space that the .net file takies effectively; Make the .net file can be (for example: smart card) go up storage and operation, and then (for example: function smart card) strengthened the low capacity storage medium at the low capacity storage medium.
Embodiment 6
Referring to Fig. 6, present embodiment provides the compression method of define styles in a kind of .net file, and this method is embodied as example with the compression set that passes through through embodiment 1 and describes, and this method comprises:
Step S202: define styles information acquisition module 102 obtains the information that the define styles that uses in the .net file comprises;
Step S204: the information that define styles information acquisition module 102 comprises according to this define styles is obtained the appointed information and the count information of this define styles;
Step S206: 104 pairs of above-mentioned appointed information of compression module are compressed;
Step S208: appointed information and count information after compression result storing module 106 will be compressed are stored as the compression result of this define styles.
Wherein, the information that comprises of the define styles that obtains of define styles information acquisition module 102 obtains through following mode:
Read the define styles metadata table in the .net file earlier, i.e. metadata table TypeDef; From metadata table TypeDef, obtain the information that the define styles that uses in the .net file comprises again.
The information that this define styles comprises in the present embodiment comprises: the side-play amount of the sign of this define styles, the title of this define styles, the side-play amount of the method in this define styles;
When having used field in this define styles, can also comprise the side-play amount of the field in this define styles in the information that this define styles comprises; These information can obtain through the data that read among the metadata table TypeDef, and in metadata table TypeDef, each row of data is represented a define styles, and each row of data is totally 14 bytes, and the information of these 14 byte records is:
Preceding 4 bytes are Flags (define styles sign); 5,6 bytes are the side-play amount of define styles title in " #Strings " stream; 7,8 bytes are the namespace name side-play amount in " #Strings " stream in the .net file under this define styles; 9,10 bytes are the side-play amount of the parent of being inherited of this define styles, the side-play amount of the field that 11,12 bytes comprise for this define styles, and 13,14 bytes are the side-play amount of the method that this define styles comprised.
Information corresponding among above-mentioned appointed information and count information and the embodiment 1 is identical, no longer details here.
Preferably, in the present embodiment sign of define styles is divided into type identification, access identities and descriptive sign;
Correspondingly, the step compressed of 104 pairs of above-mentioned appointed information of the compression module among the step S206 comprises:
Said type identification, access identities and descriptive sign are carried out exclusive disjunction, with the compression result of the data that obtain as the sign of define styles; Title to said define styles is carried out Hash operation, from operation result, extracts the compression result of the byte of agreement as the title of define styles.
When comprising field in the current define styles in this .net file, the information that this define styles comprises also comprises: the side-play amount of the field in this define styles;
Correspondingly, above-mentioned appointed information also comprises: the information that the field in this define styles is corresponding; Count information also comprises: the field counting of this define styles.
Preferably, the corresponding information of the field in the present embodiment comprises: the type of the title of field, the sign of field and field; Wherein, the sign of said field is divided into access identities and descriptive sign;
Correspondingly, the step compressed of 104 pairs of above-mentioned appointed information of the compression module among the step S206 comprises:
Title to this field is carried out Hash operation, from operation result, extracts the compression result of the byte of agreement as the title of this field; Access identities in the sign of this field and descriptive sign are carried out exclusive disjunction, and the result who obtains is as the compression result of the sign of this field; With the compression result of the side-play amount in the type of type after compression of this field as the type of this field.
Preferably, the information that comprises of define styles comprises: the side-play amount of the parent that this define styles is inherited; Correspondingly, said method also comprises:
Judge whether the parent that this define styles is inherited compresses, if obtain the side-play amount of the parent of being inherited; Otherwise, to the parent of being inherited compress and for the compression after the parent allocation offsets amount of being inherited; Correspondingly, the side-play amount that also comprises the said parent after the compression in the compression result of above-mentioned define styles.
Preferably, said method also comprises:
Judge whether this define styles has the interface of succession; If have, obtain the number of the interface of side-play amount and succession after the interface compression that this define styles inherits; Correspondingly, the number that also comprises the interface of side-play amount and succession after the interface compression of above-mentioned succession in the compression result of this define styles.
Preferably, said method also comprises:
Judge whether this define styles is nested type, if obtain the side-play amount after the type compression at this define styles place; Correspondingly, also comprise side-play amount after the type compression at above-mentioned define styles place in the compression result of this define styles.
Pass through said method; Data to after the compression of each define styles are organized, and its form is the information of field correspondence etc. in the side-play amount after the side-play amount in the field counting that is comprised in the side-play amount of the compression result of the hash value of define styles title (compression result of define styles title), type identification, the interface that type is inherited counting, type parent, the type, the type after method overloading information, the type compression of define styles place, type institute succession interface compress, the type;
Wherein, the corresponding information of field can have many in the side-play amount after the interface compression that type is inherited, the type, in the time of many, is arranged in order interface side-play amount, the corresponding information of field that current define styles is inherited; In addition, possibly partly exist or not exist among this three of information of field correspondence in the side-play amount after the type compression of define styles place, the side-play amount after interface that type the is inherited compression, the type, at this moment, do not write these information in this define styles.
Present embodiment is through compressing the various piece of the define styles in the .net file; And with the compression result of each several part according to predetermined format; Can reduce the storage space that the .net file takies effectively; Make the .net file can be (for example: smart card) go up storage and operation, and then (for example: function smart card) strengthened the low capacity storage medium at the low capacity storage medium.
Embodiment 7
Present embodiment provides the compression method of define styles in a kind of .net file; This compression method is that example describes with a concrete application example; In this application example; Relate to the part of the compression and the storage of the reference type in the .net file, the compression result of reference type is known content in this instance, can directly use.
Present embodiment is explained the compression method of define styles in the .net file to be example with the file behind the following code compile.Partial code is following:
namespace?MyCompany.MyOnCardApp
{
public?class?MyService:MarshalByRefObject
{
public?String?MySampleMethod()
{
String?strHello=″Hello?World!″;
return?strHello+callCount.ToString();
}
}
public?class?ClassA
{
public?class?ClassC:ClassB,IA,IB
{
static?String?strField;
Int32?iField;
public?ClassC(String?str?1,int?i)
{
strField=str1;
iField=i;
}
public?String?TestC()
{
return?null;
}
}
private?struct?StructB
{?}
}
public?class?ClassB
{?}
public?interface?IA
{?}
public?interface?IB
{?}
}
To obtaining the helloworld.exe file after the compiling of above-mentioned code use .net platform; And with binary stored in form on hard disk; This binary file is the .net file, and the .net file may operate under the Windows environment and meets PE (Portable Executable, portable can be carried out) file layout; The PE form is the form of the executable file of Windows, and the .exe file among the Windows .dll file all are the PE forms.Referring to Fig. 7, be the structural representation of .net file, this document comprises Dos head, PE characteristic and metadata (MetaData), comprises metadata header (MetaData Header), metadata table (MetaData Tables) etc. in the metadata.
Referring to Fig. 8, the compression method of define styles comprises in the .net file that present embodiment provides:
Step S301: the start address of the metadata table (Metadata Tables) in the .net file of location, and obtain existing epi-position vector; Wherein, metadata table is the part of .net file, and the process of location metadata table is following:
1) location .net file Dos head obtains the Dos leader and knows 0x5a4d;
2) after the Dos leader is known, begin to skip first an agreement byte, read the offset address of PE characteristic, obtain the offset address 0x00000080 of PE characteristic; In the present embodiment, first an agreement byte is a 0x003a byte;
3) according to PE characteristic offset address 0x00000080 location PE characteristic, the location obtains PE characteristic 0x00004550;
4) after the PE characteristic, begin; Reading four bytes after the skew second agreement byte, in the present embodiment, is that example describes with 32 machines; A second agreement byte is for after squinting the 0x0074 byte from the PE characteristic backward; The data of reading are 0x00000010, have 0x10 catalogue in this this binary file of value explanation, and comprise the .net data;
Wherein, the metadata header address of .net file writes in above-mentioned 0x0F the catalogue;
If in 64 machines, then second an agreement byte is a 0x0084 byte;
5) begin from above-mentioned data 0x00000010, the 3rd agreement byte that squints backward reads eight byte datas, in the present embodiment; Preferably, the 3rd an agreement byte is a 0x0070 byte, in these eight byte datas; Preceding four bytes are 0x00002008; Be the relative virtual address of .net data head in the .net file, back four bytes are 0x00000048, are the length of .net data head;
6) the relative virtual address 0x00002008 according to .net data head in the .net file obtains linear address 0x00000208 and reads the .net data head obtaining following data:
48000000?02000500?0C220000?9C0A0000
09000000?01000006?00000000?00000000
50200000?80000000?00000000?00000000
00000000?00000000?00000000?00000000
00000000?00000000
Need to prove, the storage mode of above-mentioned The data small end, for example, the storage mode that preceding 4 the byte 0x48000000 of above-mentioned data convert big end to is 0x0000048, representes the length of these data;
Wherein, read the data of 72 bytes according to the length 0x00000048 of .net metadata header.
In the present embodiment; Linear address is the addresses of .net data in the .net file; Relative virtual address is for being written into internal memory skew a little with respect to PE; The transformational relation of linear address and relative virtual address is: the document misregistration of linear address=relative virtual address-Jie relative virtual address+joint, and in the present embodiment, the relative virtual address that reads the joint of .net data directory in the .net file is 0x00002000; The document misregistration of joint is 0x00000200, then linear address=0x00002008-0x00002000+0x00000200=0x00000208;
7) begin to squint backward after the 4th agreement the byte by the .net data head; The 4th an agreement byte reads totally 8 byte datas, in these 8 bytes for after beginning to squint backward 8 bytes from the .net data head in the present embodiment; Preceding four bytes are 0x0000220c; Be the relative virtual address of metadata header (MetaData Header), back four bytes are 0x00000a9c, are the length of metadata;
8) the relative virtual address 0x0000220c according to metadata header obtains linear address 0x0000040c, reads content metadata according to linear address and metadata length;
9) read backward by metadata header,, read sign " #~" eight bytes before, wherein preceding four skews that byte is the relative metadata header of " #~" flow data, the length of back four bytes are " #~" stream when reading sign " #~" (0x237E) time; The data area that relativity shift obtains " #~" to flow of stream through " #~"; The 5th an agreement byte begins to read the data that length is 8 bytes in the stream at " #~"; The bit vector (MaskValid) that obtains existing table in the present embodiment; The bit vector value of existing table is 0x0000020920021f57, and its binary mode is:
100000100100100000000000100001111101010111
In the present embodiment, start bit began to count the 9th byte during the 5th an agreement byte flowed for " #~";
Begin to read the bit vector of existing table from low level, each represents a metadata table, if this table exists, then the value on the corresponding positions is 1, otherwise is 0;
For example, begin from low level, whether the 1st representative element tables of data Module exists, if 1; Then there is metadata table Module in proof, if 0, do not prove to exist; In the present embodiment, have metadata table Module, and the 2nd is 1; Representation element tables of data TypeRef exists, and the 3rd is 1, and representation element tables of data TypeDef exists;
Step S302: location metadata table TypeDef (define styles);
According to the bit vector of the existing table that reads out among the step S301, write down successively from the low level to a high position whether the metadata corresponding table exists in the .net file, wherein; Whether the 3rd representative element tables of data TypeDef exists, if the 3rd is 1, then metadata table TypeDef exists; If the 3rd is 0; Then metadata table TypeDef does not exist, and in the present embodiment, metadata table TypeDef exists;
The 9th byte after existing epi-position vector 0x0000020920021f57 begins; With four bytes number of data lines that is comprised in the metadata table that exists in the .net file that has been the corresponding record of unit; Skip two metadata table number of data lines information in the TypeDef front; The 17th byte place behind data 0x0000020920021f57 begins to read 4 bytes, obtains data 0x0000000a, among this data representation metadata table TypeDef 10 data lines arranged;
After the data of expression number of data lines, stored the particular content of each metadata table successively, be the metadata table zone; The process that reads content among the metadata table TypeDef is following:
Bit vector according to the existing table that reads among the step S301 can be known; There are metadata table Module and metadata table TypeRef in embodiments of the present invention before the metadata table TypeDef; Wherein metadata table Module has 1 data line, 10 bytes; Metadata table TypeRef has 31 data lines, 186 bytes; After skipping 60 byte datas of the data line number that expression comprised in the metadata table, skipping 10 data lines, each data line of reading metadata table TypeDef behind metadata table Module and the metadata table TypeRef again has 14 bytes, and specifically data are following:
0x0000000001000000000001000100
0x0100100019002200050001000100
0x0100100038002200090002000300
0x0100100042002200050007000600
0x0100100049002200050007000700
0xA100000050002200000007000800
0xA100000053002200000007000800
0x0200100056000000140007000800
0x030110005D0000000D0009000A00
0x00000000C8030000050009000A00
In metadata table TypeDef; Data represented define styles in each data line; Preceding 4 bytes of each data line are Flags (define styles sign); 5,6 bytes are define styles title relativity shift in " #Strings " stream in the .net file; 7,8 bytes are the relativity shift of namespace name in " #Strings " stream under this define styles; 9,10 bytes are the information of the parent of being inherited of this define styles, the data line of first field in metadata table Field that 11,12 bytes comprise for this define styles number, and 13,14 bytes are the data line of first method in metadata table Method that this define styles comprised number.
In the present embodiment; In each metadata table in each data line the length of data fix, can calculate the offset address of other metadata table in the .net file according to existing epi-position vector and the metadata table line number method through above-mentioned location metadata table.
Step S303: read the sign and the title of define styles according to the data among this metadata table TypeDef, and respectively the sign and the title of define styles are compressed;
At first, according to the data that read among the metadata table TypeDef, read the sign of define styles and compress;
From metadata table TypeDef, read the sign of the define styles of four bytes, can know each item identity property of this define styles according to the sign of this define styles;
Present embodiment is divided into 3 parts with the sign of define styles: type identification, access identities, descriptive sign; The value of each item identity property of having laid equal stress on redetermination comprises like type identification: predefined type 0x00, value type 0x01, enumeration type 0x02, array type 0x03, type type 0x04, interface type 0x05, non-trustship pointer type 0x06 etc.; Access identities comprises: non-public visit type NotPublic (0x00); Public visit type Public (0x10); If for nested type also has: sign public nested type NestedPublic (0x20) is modified in visit; Privately owned nested type NestedPrivate (0x30); The nested type NestedFamily of family (0x40); Procedure set nested type NestedAssembly (0x50); Procedure set and the nested type NestedFamANDAssem of family (0x60); Procedure set or the nested type NestedFamORAssem of family (0x70); Descriptive sign is used for describing some attributes of current type field, as exist can not serializing field 0x08, otherwise be 0x00;
The method that present embodiment compresses the sign of define styles is specially: type identification, access identities and descriptive sign are carried out exclusive disjunction, and the data of 1 byte that obtains are the sign compression result of define styles.
For example; The define styles ClassC of the 8th data line of the metadata table TypeDef that in step S302, reads out; Define styles sign 0x00100002 according to preceding 4 bytes can know; Its type identification is modified for a type 0x04, visit and is designated NestedPublic (0x20), the descriptive 0x00 of being designated, and the value of above attribute is advanced exclusive disjunction 0x04|0x20|0x00 obtain 0x24, with the sign compression result of 0x24 as define styles ClassC.
Then, according to the data among the metadata table TypeDef that reads, read the define styles title and compress; Promptly read out the title of this define styles according to the relativity shift of define styles title in " #Strings " stream;
For example; Among the metadata table TypeDef that reads out in second data line data; 5th, the value in 6 bytes is 0x0019, navigates to begin reading of data after skipping 0x0019 byte behind " #Strings " stream of .net file, finishes after reading 0x00; Obtain 0x4D79536572766572, these data are the title MyServer of current define styles among the metadata table TypeDef;
The define styles title that reads out is carried out Hash (hash) computing, from the hash operation result, get the result after the 6th an agreement byte is compressed as define styles, the 6th agreement byte is preceding two bytes of hash value in embodiments of the present invention.The hash algorithm that adopts can be MD5, SHA-1, SHA-2 etc.
For example; Adopt the MD5 algorithm that MyServer is carried out the hash computing in embodiments of the present invention; Obtain: 0x0CBEFBC1EF0639BA18485104440F399C, get the compression result of the 6th an agreement byte 0x0CBE as current define styles MyServer title among the metadata table TypeDef.
In addition; If judging current type according to the sign of current type is nested type; Then read out the title of current type place type again; The title of current type place type and the title combination of current type are carried out the hash computing, from the hash operation result, get the compression result of the 6th an agreement byte as this current type; The method of combination can be to use connector that the two is stitched together, or directly these two types spliced, or mathematical operations such as the title of two types is carried out addition, subtracted each other, XOR.
For example; With the code of being given in the present embodiment is that example: Type C lassC is nested among the Type C lassA, when therefore ClassC being compressed, earlier the typonym of ClassA and the typonym of ClassC is spliced; Use connector "+" to splice in the present embodiment; ClassA+ClassC is carried out the hash computing, get the typonym compression result of preceding two bytes of hash value then, the situation that can avoid the compression result of define styles title to duplicate like this as ClassC;
Wherein, The name that reads out ClassA is called 0x0042; The name of ClassC is called 0x0056; Use the MD5 algorithm to carry out the hash computing to ClassA+ClassC, obtain: 0x9B8DE23910B330AD80BDB76E7AC19092, get the compression result of preceding two byte 0x9B8D as current define styles ClassC title among the metadata table TypeDef.
Wherein, present embodiment is located the method for position of " #Strings " stream and is in metadata: behind the address 0x0000040c of the acquisition metadata header in step S301, begin to read backward from metadata header; After finding that mark " #Strings " is (0x23537472696E6773), read " #Strings " 8 byte datas before, obtain data 0x0004000080040000; Wherein the expression mode of high-order 4 byte conversion Cheng Daduan is 0x00000400; Expression " #Strings " stream is with respect to the skew of metadata header, and the expression mode of 4 byte conversion Cheng Daduan of low level is 0x00000480, the length of expression " #Strings " stream;, low 4 bytes; From the address 0x0000040c of metadata header, 0x00000400 the byte that squint backward obtains the data area of " #Strings " stream.
Step S304: obtain the method overloading information in the current define styles, and the method counting and the field counting that obtain the method that is comprised in the current define styles;
The acquisition methods of method counting is following in the present embodiment:
Read the data in 13,14 bytes of current define styles place data line among the metadata table TypeDef; These data are that define styles comprises the data line of first method in metadata table Method number; And then the type of making a definition that reads current define styles comprises the data line of first method in metadata table Method number; The data line of first method that type comprised of making a definition number deducts the data line number of first method that current define styles comprises, all methods countings that resulting result is in the current type to be comprised.The acquisition methods of last data line comprised among the metadata table TypeDef all methods countings is: the number of data lines among the metadata table Method deducts the data line number of first method that last define styles data line comprised, and the result who obtains is all methods countings that last data line comprised among the metadata table TypeDef.
The data line of first method in metadata table Method that define styles ClassC comprised among the metadata table TypeDef that reads in the present embodiment number is 0x0008; The data line of first method in metadata table Method that define styles StructB comprised in the next data line of define styles ClassC number is 0x000A; Can know that by 0x000A-0x0008 the method number that comprises among the define styles ClassC is 0x0002.
The method overloading information of define styles is used for describing current type, and whether to have method be empty method and need open up new holding tank, if exist, then this method overloading information added 1, and wherein, the initial value of each define styles method overloading information is 0.
At first, location metadata table Method (method); The process of location metadata table TypeDef among the similar step S302 of concrete method simply is described below:
According to the bit vector of the existing table that reads out among the step S301, write down successively from the low level to a high position whether the metadata corresponding table exists in the .net file, wherein; Whether the 7th representative element tables of data Method exists; In the present embodiment, the 7th data are 1, and metadata table Method exists;
The 9th byte after existing epi-position vector 0x0000020920021f57 begins; With four bytes data line number that is comprised in the metadata table that exists in the .net file that has been the corresponding record of unit; Can know according to existing epi-position vector and also to have other 4 metadata tables before the metadata table Method; Skip 4 metadata tables in the Method front; The 25th byte place behind data 0x0000020920021f57 begins to read 4 bytes, obtains data 0x00000009, among this data representation metadata table Method 9 data lines arranged;
Read the content that obtains metadata table Method: according to the bit vector of existing table and thereafter the data of representation element tables of data line number can know; Exist metadata table Module to have 10 bytes, metadata table TypeRef to have 186 bytes, metadata table TypeDef to have 140 bytes and metadata table Field that 54 bytes are arranged before the metadata table Method in the present embodiment; After skipping 3 metadata tables of front, read 9 data lines of metadata table Method, totally 126 bytes.
Then; Comprise the data line of first method in metadata table Method according to current define styles and number from metadata table Method, read the capable data of corresponding data; The the 7th, 8 of each data line the byte is the method sign among the metadata table Method; Judge according to this method sign whether the method in the current type is that empty method and needs are opened up new holding tank, if then method overloading information adds 1; If the method for current define styles counting then continues in metadata table Method, to read next data line, according to the said method executable operations greater than 1.Until all being read and judge, the method that current define styles comprised finishes;
Particularly; Judge whether the method in the current type is that empty method and the method that need open up new holding tank are: the sign that reads method in the current type; Should identify with 0x0100 and carry out and computing, if the method that the result of computing then can judge in the current type for 0x0100 is empty method and need opens up new holding tank.
Obtain the field counting that comprised in the current define styles and obtain that to comprise the method that method counts in the current type similar, simply be described below:
Read the data of the 11st, 12 bytes store that current define styles is expert among the metadata table TypeDef; Obtain the data line of first field in metadata table Field that current define styles comprises number; Read the data line of first field in metadata table Field that the type of making a definition of the current define styles that the 11st, 12 bytes in next data line store comprises number then, the field counting that the data line number resulting result that the latter's data line number deducts the former is in the current type to be comprised.
The data line of first field in metadata table Field that define styles ClassC comprised among the metadata table TypeDef that reads in the present embodiment number is 0x0007; First field data row that type StructB comprised of making a definition of define styles ClassC number is 0x0009; Can know by 0x0009-0x0007; The field number that is comprised among the current define styles ClassC is 0x0002, and promptly the field of define styles ClassC counting is 0x0002.
Step S305: obtain corresponding information and the compression of field in the current define styles.
In metadata table Field, read the data of corresponding field according to existing epi-position vector, and according to field that current define styles comprises counting and the field sequence number obtained, the method and the step S302 that read metadata table Field are similar; The length of each data line is 6 bytes among the metadata table Field; Wherein that the 1st, 2 bytes store is the Flags of field (field identification) in this data line among the metadata table Field, the 3rd, 4 bytes store be the name (field name) of field, the 5th, 6 bytes store be the Signature information of field.
The process that the corresponding information of field in the current define styles is compressed is following:
1) obtains field name and it is compressed
Name (field name) to the field that reads carries out the hash computing, gets that the 7th an agreement byte is as the compression result of this field name (field name) in the hash value, and the 7th an agreement byte is preceding two bytes of hash value in the present embodiment;
Comprise two fields in the present embodiment among the ClassC; Name (field name) is respectively strField and iField; Field name " strField " with to field strField carries out the boil down to example; The hash value that obtains after the compression is: 0x846461722F82E1CAB3D95632E8424089, get the compression result of preceding two byte 0x8464 of hash value as this field name " strField ".
2) sign of field is compressed
According to the Flags (field identification) of the field that in metadata table Field, reads, can judge the identification information of this field according to the Flags of this field, the identification information with field in the present embodiment is divided into two types: access identities and descriptive sign; The access identities of this field and the value of descriptive sign are carried out exclusive disjunction, obtain the compression result of this field Flags;
Wherein, access identities comprises:
Privately owned wide-style PrivateScope=0x00
Private type Private=0x01
Family and procedure set type FamANDAssem=0x02
Procedure set type Assembly=0x03
The type Family=0x04 of family
Family or procedure set type FamORAssem=0x05
Common type Public=0x06
Descriptive sign has:
Static types Static=0x10
Initialization InitOnly=0x20
Can not serializing NotSerialized=0x80
In the present embodiment; Comprise two fields among the define styles ClassC and be respectively strField and iField; Analyze its Flags (field identification) when the strField field identification is compressed and to know that the access identities of this field is Private=0x01, the descriptive Static=0x10 that is designated; 0x01 and 0x10 carry out exclusive disjunction and obtain 0x11, and then the sign compression result of strField field is 0x11.
3) obtain the type of field
The type stores of field is in " #Blob " stream; Read the Signature information of the 4th byte of current line among the metadata table Field; This information is the relativity shift address of this field type information in " #Blob " stream, according to this relativity shift address reading corresponding data in " #Blob " stream; Wherein, The data representation data length thereafter of first byte that reads, the 2nd byte representation type of data is if the 2nd byte is 0x06; Represent that then these data are the type of field, the 3rd byte data is represented field type or in the 4th byte, is comprised field type information; Search in the metadata table corresponding type with it, or resolve and comprise field type information in the 4th byte and obtain this field corresponding type in metadata table according to the field type shown in the 3rd byte, and the skew after the type compression in the metadata table is preserved as the type of this field.
Wherein, the method for the position that flow location " #Strings " in metadata is similar among the method for location " #Blob " stream position and the step S302: behind the address 0x0000040c of the acquisition metadata header in step S301, begin to read backward from metadata header; After finding that mark " #Blob " (0x23426C6F6); Read " #Blob " 8 byte datas before, obtain data 0xD4080000C8010000, the expression mode of wherein high 4 byte conversion Cheng Daduan is 0x000008D4; Expression " #Blob " stream is with respect to the skew of metadata header; The expression mode of low 4 byte conversion Cheng Daduan is 0x0001C8, the length of expression " #Blob " stream; From the address 0x0000040c of metadata header, the 0x000008D4 that squints backward obtains the data area of " #Blob " stream.
In the present embodiment; The method of field type of obtaining the field strField that is comprised among the define styles ClassC is following: the data that in metadata table Field, read the 4th byte of strField obtain 0x000A; Skew 0x000A place reading of data in the data area of " #Blob " stream reads the data 0x02 of the 1st byte then, is illustrated in the data that need read 2 byte lengths after these data; Obtain 0x060E; Wherein the 2nd byte is 0x06, expression be after this byte data representation be field type, continue to read the 3rd byte and obtain data 0x0E; Can know that according to linguistic norm 0x0E representes that this field type is the string type; Search the skew after the compression of string type among the metadata table TypeRef, searching the result who obtains is 0x03,0x03 is made the field type of field strField and preserves.
Comprise 3 parts in the information of the field correspondence after the compression of present embodiment define styles: Flags (field identification) compressed value of the name of 2 byte lengths (field name) compressed value, 1 byte and the Signature Information Compression value of 1 byte; If include a plurality of fields in the current type, then order after each field compression is preserved.
According to the method shown in above-mentioned, the result after field strField that is comprised among the ClassC and the Information Compression of iField is: 0x84641103F1EC0106.
If do not have define field in the current define styles, then there is not this in the define styles after the compression.
Step S306: judge whether current define styles exists parent, if exist parent and its parent not to compress, then execution in step 303, compress current type parent through the method for recurrence; Otherwise execution in step 307;
The 9th, 10 byte reading of data of current type place data line from metadata table TypeDef;
If the data that read are 0x0000, then current type does not have parent, execution in step S307; If the data that the 9th, 10 bytes of current type place data line read from metadata table TypeDef are not 0x0000; The data-switching Cheng Daduan formats stored with the preservation of small end storage mode that then will read; Be high byte after the conversion promptly preceding, low byte after form; The binary number that to change the back data then moves to right two, obtains the data line of parent in metadata table TypeRef or TypeDef number of current type; The data line that obtains after the displacement number carries out and computing with 0x03, if operation result is 0, then the parent of current type in metadata table TypeRef, execution in step S307; If operation result is 1, the parent that then can know current type is searched among the metadata table TypeDef type with this data line number corresponding data line in metadata table TypeDef, if compress, and execution in step S307, otherwise, execution in step S303.
Step S307: obtain the side-play amount after the type compression of the parent that define styles inherits;
The 9th, 10 byte reading of data of current type place data line from metadata table TypeDef, if the data that read are 0x0000, then current type does not have parent, preserves 0xFF and representes that current type does not have the parent type;
If the data that the 9th, 10 bytes of current type place data line read from metadata table TypeDef are not 0x0000; The data-switching Cheng Daduan formats stored with the preservation of small end storage mode that then will read; Be high byte after the conversion promptly preceding, low byte after form; The binary number that to change the back data then moves to right two, obtains the data line of parent in metadata table TypeRef or TypeDef number of current type;
The data line that obtains after the displacement number carries out and computing with 0x03; If operation result is 0; Then the parent of current type is in metadata table TypeRef; Search among the metadata table TypeRef skew after the type compression with this data line number corresponding data line, and its offset storage as the parent of current type is got off; If operation result is 1, the parent that then can know current type is searched among the metadata table TypeDef skew after the type compression with this data line number corresponding data line in metadata table TypeDef, and its offset storage as the parent of current type is got off.
For example; The acquisition process of the parent of ClassC is following in the present embodiment: the 9th, 10 bytes that read ClassC place data line among the metadata table TypeDef; Obtain data-switching and be 0x0014 after for big end storage format, convert scale-of-two to and be: 10100, binary number 10100 moved to right 2, and to obtain 101 be 0x05; Since 0x05 and 0x03 carry out with calculated result be 0x01; Can know parent 0x05 data line in metadata table TypeDef of ClassC, search the skew after the define styles compression of 0x05 data line among the metadata table TypeDef then, and its offset storage as the ClassC parent is got off.
Step S308: be current define styles allocation offsets amount;
After according to the described method of above step each define styles being compressed, obtain the compressed information of metadata table TypeRef (reference type) in the .net file, the side-play amount that continues after the reference type compression is define styles allocation offsets amount continuously.For example: if the side-play amount of last type after the reference type compression is 0x1A in the .net file, then the side-play amount of first type is 0x1B in the define styles of compression back, and the skew of compressing back second define styles is 0x1C.
Step S309: the define styles that judges whether to wait for the parent side-play amount in buffer memory, if having, execution in step S307 then, otherwise execution in step S310;
Step S310: the data analysis that judges whether all define styles finishes, if execution in step S311 then, otherwise execution in step S303 continues remaining define styles among the compression metadata table TypeDef;
Step S311: obtain the interface side-play amount that current define styles inherits and the number of ports of succession;
After the data of all define styles are all passed through above-mentioned processing, can obtain each define styles interface side-play amount of inheriting and the number of ports of being inherited through the data among the query metadata Table I nterfaceImpl;
According to existing epi-position vector location metadata table InterfaceImpl (interface class), the method and the step S302 that specifically read metadata table are similar; Read metadata table InterfaceImpl.
In metadata table InterfaceImpl; Every row has 4 bytes; 1st, 2 byte Class represent to inherit the data line that the type of this interface belongs in metadata table TypeDef, and the value among the 3rd, the 4 byte Interface converts the binary number data line that the value that obtains after 2 belongs in metadata table TypeDef for this interface class that moves to right to.
Obtain interface class that each define styles is inherited among the metadata table TypeDef and the number of ports of being inherited according to the information that reads among the metadata table InterfaceImpl; Wherein, also obtain side-play amount after the compression of the corresponding interface class.
If current define styles is not inherited any interface, then number of ports is 0x00 in the define styles after the compression, and the information that interface is corresponding does not exist.
Step S312: obtain the side-play amount after the type compression at nested type place;
Whether the identification information judgment current type according to current define styles is nested type, if nested type then obtains the side-play amount of the type at current nested type place; If judging current type is not nested type, then there is not this in the define styles after the compression.
Whether the define styles identification information judgment current type according in step S303, from metadata table TypeDef, reading four bytes is nested type, if nested type then also will read the information among the metadata table NestedClass (nested type); According to existing epi-position vector location metadata table NestedClass, the similar step S302 of concrete method; Read metadata table NestedClass.
Every row has 4 bytes in metadata table NestedClass; 1st, 2 bytes are that NestedClass representes the data line that current nested type belongs in metadata table TypeDef, and the 3rd, 4 bytes are that EnclosingClass representes the data line that the type at current define styles place belongs in metadata table TypeDef.
Search the data line that in metadata table TypeDef, belongs to current type place type, obtain the side-play amount after current type place type is compressed, and with its type as current nested type place;
For example, the identification information of judging ClassC among the metadata table TypeDef can know that ClassC is a nested type; In metadata table NestedClass, searching nested type is the item of ClassC; Whether the value of judgement the 1st, 2 byte N estedClass in metadata table NestedClass corresponding item in metadata table TypeDef is the data line at ClassC place; If ClassC; Then get the data line of ClassC place type in metadata table TypeDef shown in the EnclosingClass that ClassC is corresponding among the metadata table NestedClass again; Because type corresponding in this data line is ClassA; So can know that the type at nested type ClassC place is ClassA, be 0x17 to the side-play amount after the ClassA compression in addition, the side-play amount of then obtaining after ClassA compresses is 0x17.
Step S313: the define styles data after tissue and the store compressed.
Data to after each define styles compression are organized, and its form is: the corresponding information of field in the side-play amount of the side-play amount of method overloading information, nested type place type, type place interface, the type in the field counting that is comprised in the interface counting that the hash value of define styles title, the compression result of type identification, type are inherited, the side-play amount of type parent, the type, the type;
Wherein, type the skew, type of interface in the corresponding information of field can have many, in the time of many, be arranged in order interface side-play amount, field information in the current define styles; In addition, possibly partly exist or not exist among this three of information of field correspondence in the side-play amount of the side-play amount of nested type place type, the interface that type is inherited, the type, do not write these information in the compression result if do not exist then.
For example, in the code that present embodiment provides, the result after the define styles ClassC compression is: 0x9B8D240216020200171819F1EC010684641103
In order to make above-mentioned compression result seem clearer directly perceived, above-mentioned data are deposited with the form of table 1, referring to table 1, the result's after the define styles ClassC compression analytic structure is:
Table 1
Define styles ClassC compression section is divided Value after the define styles ClassC compression
The define styles title 9B8D
The define styles sign 24
The interface counting of inheriting 02
The side-play amount of the parent of inheriting 16
Field that define styles comprises counting 02
Method counting in the define styles 02
Method overloading information 00
The side-play amount of nested type place type 17
The interface side-play amount of inheriting 18,19
The information that define field is corresponding F1EC?01?06,8464?11?03
After each define styles compression is accomplished in the .net file, sequentially store according to the side-play amount that the compression back is distributed.
In the present embodiment to carry out processed compressed data are the binary data that behind the code compile of writing under the .net framework, become; The method that provides through present embodiment; The compressibility maximum of define styles can reach 30%; And then can reduce the storage space that the .net file takies effectively, make the .net file can be (for example: smart card) go up storage and operation, and then (for example: function smart card) strengthened the low capacity storage medium at the low capacity storage medium.
Compression method that above embodiment provides or compression set have reduced the storage space that the .net file takies effectively, are beneficial to the .net file and on various device, use, and have also saved the resource of system simultaneously significantly, have improved resource utilization.
Obviously; It is apparent to those skilled in the art that above-mentioned each module of the present invention or each step can realize that they can concentrate on the single calculation element with the general calculation device; Perhaps be distributed on the network that a plurality of calculation element forms; Alternatively, they can be realized with the executable program code of calculation element, carried out by calculation element thereby can they be stored in the memory storage; Perhaps they are made into each integrated circuit modules respectively, perhaps a plurality of modules in them or step are made into the single integrated circuit module and realize.Like this, the present invention is not restricted to any specific hardware and software combination.
The above is merely the preferred embodiments of the present invention, is not limited to the present invention, and for a person skilled in the art, the present invention can have various changes and variation.All within spirit of the present invention and principle, any modification of being done, be equal to replacement, improvement etc., all should be included within protection scope of the present invention.

Claims (14)

1. the compression method of define styles in the .net file is characterized in that said method comprises:
Obtain the information that the define styles that uses in the .net file comprises; Wherein, the step of obtaining the information that the said define styles that uses in the said .net file comprises comprises:
Read the metadata table at the define styles place in the said .net file; From the metadata table at said define styles place, obtain the information that the define styles that uses in the said .net file comprises;
The information that comprises according to said define styles is obtained the appointed information and the count information of said define styles;
Said appointed information is compressed;
Appointed information and said count information after the compression are stored as the compression result of said define styles.
2. method according to claim 1 is characterized in that, the information that said define styles comprises comprises: the side-play amount of the sign of said define styles, the title of said define styles, the side-play amount of the method in the said define styles;
Correspondingly, said appointed information comprises: the sign of said define styles and the title of said define styles;
Said count information comprises: the method counting that comprises in the method overloading information of said define styles and the said define styles.
3. method according to claim 2 is characterized in that, the sign of said define styles is divided into type identification, access identities and descriptive sign;
Correspondingly, the said step that said appointed information is compressed comprises:
Said type identification, access identities and descriptive sign are carried out exclusive disjunction, with the compression result of the data that obtain as the sign of said define styles;
Title to said define styles is carried out Hash operation, from operation result, extracts the compression result of the byte of agreement as the title of said define styles.
4. method according to claim 2 is characterized in that, the information that said define styles comprises also comprises: the side-play amount of the field in the said define styles;
Correspondingly, said appointed information also comprises: the information that the field in the said define styles is corresponding;
Said count information also comprises: the field counting of said define styles.
5. method according to claim 4 is characterized in that, the corresponding information of the field in the said define styles comprises: the type of the title of field, the sign of field and field;
Wherein, the sign of said field is divided into access identities and descriptive sign;
Correspondingly, the said step that said appointed information is compressed comprises:
Title to said field is carried out Hash operation, from operation result, extracts the compression result of the byte of agreement as the title of said field;
Access identities in the sign of said field and descriptive sign are carried out exclusive disjunction, with the compression result of the result who obtains as the sign of said field;
Side-play amount after the type compression that the type of said field is corresponding is as the compression result of the type of said field.
6. method according to claim 1 is characterized in that, the information that said define styles comprises comprises: the side-play amount of the parent that said define styles is inherited;
Correspondingly, said method also comprises:
Judge whether the parent that said define styles is inherited compresses, if obtain the side-play amount of said parent; Otherwise, said parent is compressed, and is the said parent allocation offsets amount after the compression;
Correspondingly, the side-play amount that also comprises the said parent after the compression in the compression result of said define styles.
7. method according to claim 1 is characterized in that, said method also comprises:
Judge whether said define styles has the interface of succession; If have, obtain the number of the interface of side-play amount and succession after the interface compression that said define styles inherits;
Correspondingly, the number that also comprises the interface of side-play amount and succession after the interface compression of said succession in the compression result of said define styles.
8. method according to claim 1 is characterized in that, said method also comprises:
Judge whether said define styles is nested type, if obtain the side-play amount after the type compression at said define styles place;
Correspondingly, also comprise side-play amount after the type compression at said nested type place in the compression result of said define styles.
9. the compression set of define styles in the .net file is characterized in that said device comprises:
Define styles information acquisition module is used for obtaining the information that define styles that the .net file uses comprises; The information that comprises according to said define styles is obtained the appointed information and the count information of said define styles; Wherein, The step of obtaining the information that the said define styles that uses in the said .net file comprises comprises: read the metadata table at the define styles place in the said .net file, from the metadata table at said define styles place, obtain the information that the define styles that uses in the said .net file comprises;
Compression module is used for the appointed information that said define styles information acquisition module obtains is compressed;
Compression result storing module is used for the count information that the appointed information after the compression of said compression module and said define styles information acquisition module obtain is stored as the compression result of said define styles.
10. device according to claim 9; It is characterized in that the information that the define styles in the said define styles information acquisition module comprises comprises: the side-play amount of the sign of said define styles, the title of said define styles, the side-play amount of the method in the said define styles;
Correspondingly, said appointed information comprises: the sign of said define styles and the title of said define styles;
Said count information comprises: the method counting that comprises in the method overloading information of said define styles and the said define styles.
11. device according to claim 9 is characterized in that, the information that the define styles in the said define styles information acquisition module comprises comprises: the side-play amount of the parent that said define styles is inherited;
Correspondingly, said device also comprises:
First judge module is used for judging whether the parent that the define styles of said define styles information acquisition module is inherited compresses;
Parent side-play amount acquisition module, the result who is used for judging when said first judge module is that said parent compresses, obtains the side-play amount of said parent; Said parent is compression not, said parent is compressed, and be the said parent allocation offsets amount after the compression;
The side-play amount that also comprises the said parent after the compression in the compression result of the define styles of correspondingly, storing in the said compression result storing module.
12. device according to claim 9 is characterized in that, said device also comprises:
Second judge module, whether the define styles that is used for judging said define styles information acquisition module has the interface of succession;
The interface message acquisition module, the result who is used for judging when said second judge module is the interface that said define styles has succession, obtains the number of the interface of side-play amount and succession after the interface compression that said define styles inherits;
Correspondingly, the number that also comprises the interface of side-play amount and succession after the interface compression that said define styles inherits in the compression result of said define styles.
13. device according to claim 9 is characterized in that, said device also comprises:
The 3rd judge module is used for judging whether the define styles of said define styles information acquisition module is nested type;
The side-play amount acquisition module, be used for when result that said the 3rd judge module is judged be said define styles when being nested type, obtain the side-play amount after the type compression at said define styles place;
Also comprise the side-play amount after the type compression at said define styles place in the compression result of the define styles of correspondingly, storing in the said compression result storing module.
14., it is characterized in that the information that said define styles comprises also comprises: the side-play amount of the field in the said define styles according to the arbitrary described device of claim 9-13;
Correspondingly, said appointed information also comprises: the information that the field in the said define styles is corresponding;
Said count information also comprises: the field counting of said define styles.
CN2009102441633A 2009-12-30 2009-12-30 Compression method and device of definition types in.net file Expired - Fee Related CN101794220B (en)

Priority Applications (3)

Application Number Priority Date Filing Date Title
CN2009102441633A CN101794220B (en) 2009-12-30 2009-12-30 Compression method and device of definition types in.net file
PCT/CN2010/080459 WO2011079796A1 (en) 2009-12-30 2010-12-29 Method for compressing.net document
US13/129,296 US8805801B2 (en) 2009-12-30 2010-12-29 Method for compressing a .net file

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN2009102441633A CN101794220B (en) 2009-12-30 2009-12-30 Compression method and device of definition types in.net file

Publications (2)

Publication Number Publication Date
CN101794220A CN101794220A (en) 2010-08-04
CN101794220B true CN101794220B (en) 2012-08-08

Family

ID=42586932

Family Applications (1)

Application Number Title Priority Date Filing Date
CN2009102441633A Expired - Fee Related CN101794220B (en) 2009-12-30 2009-12-30 Compression method and device of definition types in.net file

Country Status (1)

Country Link
CN (1) CN101794220B (en)

Families Citing this family (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2011079796A1 (en) * 2009-12-30 2011-07-07 北京飞天诚信科技有限公司 Method for compressing.net document
CN106294202A (en) * 2015-06-12 2017-01-04 联想(北京)有限公司 A kind of date storage method and device
CN106934066B (en) * 2017-03-31 2024-06-18 联想(北京)有限公司 Metadata processing method and device and storage equipment
CN114528027B (en) * 2022-01-25 2024-07-09 深圳市优易控软件有限公司 Intelligent equipment response time lifting method based on PC platform

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6633882B1 (en) * 2000-06-29 2003-10-14 Microsoft Corporation Multi-dimensional database record compression utilizing optimized cluster models
CN101123613A (en) * 2007-08-23 2008-02-13 张建中 A coding method and device and system for multi-dimension address

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6633882B1 (en) * 2000-06-29 2003-10-14 Microsoft Corporation Multi-dimensional database record compression utilizing optimized cluster models
CN101123613A (en) * 2007-08-23 2008-02-13 张建中 A coding method and device and system for multi-dimension address

Also Published As

Publication number Publication date
CN101794220A (en) 2010-08-04

Similar Documents

Publication Publication Date Title
KR100329063B1 (en) Using a high level programming language with a microcontroller
JP4913302B2 (en) Language subset validation
CN109478217A (en) Kernel-based detection of target application functionality using offset-based virtual address mapping
CN108090360B (en) Behavior feature-based android malicious application classification method and system
CN101894028B (en) Realization method and device for Linux kernel mirror image data supporting various CPUs
CN101794220B (en) Compression method and device of definition types in.net file
CN101251799B (en) Apparatus and method for implementing management
CN101770367B (en) Compressing method and compressing device of .NET file
CN101794219B (en) Compression method and device of .net files
Ray An overview of webassembly for iot: Background, tools, state-of-the-art, challenges, and future directions
EA001598B1 (en) Portable, secure transaction system for programmable, intelligent devices
CN108985052A (en) A kind of rogue program recognition methods, device and storage medium
Kaminsky Building Parallel Programs: SMPs, Clusters & Java
CN105793864A (en) System and method of detecting malicious multimedia files
CN101593258B (en) System for realizing.Net virtual machine in software protection device and method thereof
US20020169556A1 (en) Identifying and tracking object references in a java programming environment
JP4864287B2 (en) Identification method, recording medium, and computer system
CN101794221B (en) Compression method and device of reference types in .net file
CN115840775A (en) Data extraction method, device, server and storage medium
CN101770368B (en) Compressing method and compressing device of namespace in .net file
US9176753B2 (en) Method for searching for class and function based on .NET card and .NET card thereof
Varbanescu et al. An effective strategy for porting c++ applications on cell
Azevedo Annotation-aware dynamic compilation and interpretation
Schmidt A Recent Open Source Embedded Implementation of the DESFire Specification Designed for On-the-Fly Logging with NFC Based Systems
CN116414771A (en) Data migration method, device, electronic equipment and storage medium

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
C14 Grant of patent or utility model
GR01 Patent grant
CF01 Termination of patent right due to non-payment of annual fee
CF01 Termination of patent right due to non-payment of annual fee

Granted publication date: 20120808