CN104281498B - A kind of automatic method for recovering logical drive under windows systems - Google Patents

A kind of automatic method for recovering logical drive under windows systems Download PDF

Info

Publication number
CN104281498B
CN104281498B CN201410477986.1A CN201410477986A CN104281498B CN 104281498 B CN104281498 B CN 104281498B CN 201410477986 A CN201410477986 A CN 201410477986A CN 104281498 B CN104281498 B CN 104281498B
Authority
CN
China
Prior art keywords
drive
logical
data
current
drive data
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
CN201410477986.1A
Other languages
Chinese (zh)
Other versions
CN104281498A (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 CN201410477986.1A priority Critical patent/CN104281498B/en
Publication of CN104281498A publication Critical patent/CN104281498A/en
Application granted granted Critical
Publication of CN104281498B publication Critical patent/CN104281498B/en
Expired - Fee Related legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Landscapes

  • Control Of Indicators Other Than Cathode Ray Tubes (AREA)

Abstract

The present invention discloses a kind of automatic method for recovering logical drive under windows systems, belongs to information security field, methods described includes:The drive data of visible logical drive are obtained, the drive and drive data of all logical drives is obtained;According to the drive data of all logical drives and the drive data of visible logical drive, the drive for losing logical drive is obtained, following operate is performed to each drive for losing logical drive in the drive of all loss logical drives:According to the drive for losing logical drive, the GUID value for losing logical drive is obtained from system registry, according to the drive and the GUID value tissue drive loading command data of loss logical drive for losing logical drive, the drive of logical drive is lost according to the drive loading command data recovery.Using the solution of the present invention, it is to avoid the disk management instrument carried by system carries out manual lookup and reparation, realizes automation.

Description

A kind of automatic method for recovering logical drive under windows systems
Technical field
The present invention relates to automatic recovery logical drive under information security field, more particularly to a kind of windows systems Method.
Background technology
In the prior art, under windows system platform environment, the situation of similar driving is carrying out operating system platform During migration, because in server system mirror image migration process, mistake has been write the EBR (extension leader record) of logical drive and led The situation for causing the drive of logical drive to lose.
Existing scheme is that the instrument " disk administrator " carried by windows platforms is modified the ginseng, it is necessary to artificial With running counter to the original intention of automation.
The content of the invention
The invention aims to solve problems of the prior art there is provided under a kind of windows systems from The dynamic method for recovering logical drive.
The technical solution adopted by the present invention is:The automatic method for recovering logical drive, bag under a kind of windows systems Include:
Step S1:The drive data of visible logical drive are obtained from system, all patrol is obtained from system registry Collect the drive and drive data of driver;
Step S2:According to the drive data of all logical drives and the drive number of the visible logical drive According to, obtain it is all loss logical drives drive data;
Step S3:According to all drive data for losing logical drive, from the disk of all logical drives The drive of all loss logical drives is obtained in symbol;
Following operate is performed to each drive for losing logical drive in all drives for losing logical drive:
Step T1:According to the drive for losing logical drive, obtained from system registry and lose logical drive GUID value;
Step T2:According to the drive and the GUID value of loss logical drive for losing logical drive, loading command is called System function, organizes drive loading command data;
Step T3:According to the drive loading command data, recovery drive system function is called, recovers to lose logical drive The drive of device.
The step S2 is specially:Obtain and driven with the visible logic from the drive data of all logical drives The different drive data of the drive data of device are moved, the drive data of all loss logical drives are used as.
The step S2 is specially:
Step a1:First untreated logical drive of acquisition from the drive data of all logical drives Drive data, are used as the drive data of current logic driver;
Step a2:Judge that the drive data of current logic driver whether there is in the drive of the visible logical drive In data, if it is, performing step a3, otherwise the drive data of current logic driver are regard as loss logical drive Drive data are simultaneously preserved, and perform step a3;
Step a3:Judge whether also have untreated drive data in the drive data of all logical drives, such as Fruit is, then using the drive data of next untreated logical drive of the drive data of current logic driver as current Otherwise the drive data of logical drive, return to step a2 gets the drive data of all loss logical drives of preservation, Perform step S3.
The step a2 is specially:
Step b1:First untreated visible logical drive is obtained from the drive data of the visible logical drive The drive data of device, are used as the drive data of current visible logical drive;
Step b2:Judge the drive data of current visible logical drive and current logic driver drive data whether It is identical, if it is, performing step b3, otherwise protected the drive of current logic driver as the drive for losing logical drive Deposit, perform step e3;
Step b3:Judge whether also have untreated drive data in the drive data of the visible logical drive, such as Fruit is, then by the drive data of next untreated visible logical drive of the drive data of current visible logical drive As the drive data of current visible logical drive, otherwise return to step b2 performs step a3.
The step a2 is specially:
Step c1:The visible logic for being designated untreated state is obtained from the drive data of the visible logical drive The drive data of driver, are used as the drive data of current visible logical drive;
Step c2:Judge the drive data of current visible logical drive and current logic driver drive data whether It is identical, if it is, performing step c3, otherwise protected the drive of current logic driver as the drive for losing logical drive Deposit, perform step c3;
Step c3:It will be seen that the mark of the drive data of logical drive is set to processed state, current judgement is described can See in the drive data of logical drive whether also have the drive data for being designated untreated state, if it is, return to step C1, otherwise performs step a3.
The step S2, be specially:
Step d1:The logical drive for being designated untreated state is obtained from the drive data of all logical drives The drive data of device, are used as the drive data of current logic driver;
Step d2:Judge that the drive data of current logic driver whether there is in the drive of the visible logical drive In data, if it is, performing step d3, otherwise the drive data of current logic driver are regard as loss logical drive Drive data are simultaneously preserved, and perform step d3;
Step d3:The corresponding mark of the drive data of current logic driver is set to processed state, the institute is judged Have in the drive data of logical drive whether to also have and be designated untreated drive data, if it is, return to step d1, no The drive data of all loss logical drives of preservation are then got, step S3 is performed.
The step d2 is specially:
Step e1:First, which is obtained, from the drive data of the visible logical drive is not carried out recovery operation The drive data of logical drive, are used as the drive data of current visible logical drive;
Step e2:Judge the drive data of current visible logical drive and current logic driver drive data whether It is identical, if it is, performing step e3, otherwise protected the drive of current logic driver as the drive for losing logical drive Deposit, perform step e3;
Step e3:Judge whether also have the drive for being not carried out recovery operation in the drive data of the visible logical drive Data, if it is, by next visible logic for being not carried out recovery operation of the drive data of current visible logical drive Otherwise the drive data of driver perform step d3 as the drive data of current visible logical drive, return to step e2.
The step d2 is specially:
Step f1:The visible logic for being designated untreated state is obtained from the drive data of the visible logical drive The drive data of driver, are used as the drive data of current visible logical drive;
Step f2:Judge the drive data of current visible logical drive and current logic driver drive data whether It is identical, if it is, performing step f3, otherwise protected the drive of current logic driver as the drive for losing logical drive Deposit, perform step f3;
Step f3:The corresponding mark of the drive data of current visible logical drive is set to processed state, institute is judged State in the drive data of visible logical drive and whether also have the drive data for being designated untreated state, if it is, returning Step f1, otherwise performs step d3.
Include before the step T1:
Step g:Selection one is not carried out the loss logic drive of recovery operation from the drive of all loss logical drives The drive of dynamic device;
Include after the step T3:
Step h:Judge whether also to be not carried out the drive of the loss logical drive of recovery operation, if it is, returning Step g, otherwise terminates.
The step T1, in addition to:Judge whether to get from system registry and lose logical drive GUID value, if it is, performing step T2, otherwise performs step h.
The step T3, in addition to:
Step i1:Judge whether successfully to recover the drive of the loss logical drive, if it is, step g is performed, it is no Then perform step i2;
Step i2:Whether the drive for judging the loss logical drive is default maximum drive, if it is, performing step Rapid a2, otherwise updates the drive of the loss logical drive, return to step T3.
The step S1 also includes:The drive quantity of visible logical drive is obtained from system;
The drive quantity that visible logical drive is obtained from system, be specially:
Step k1:It will be seen that the drive quantity of logical drive is set to initial value, the visible logical drive disk of acquisition is called Quantity function is accorded with, first function return value is obtained;
Step k2:Obtain the number of the preset value included in the first function return value, by comprising preset value Count the drive quantity as visible logical drive.
In the step S1, the drive that visible logical drive is obtained from system and drive data are specially:
Step m1:Obtain the drive quantity of the visible logical drive;
Step m2:The function for obtaining visible logical drive drive data is called, second function return value is obtained, will be described Second function return value is preserved as the drive data in visible logical drive;
Step m3:The drive quantity of the visible logical drive is updated, the quantity of the visible logical drive is judged Whether it is more than 0, if it is, performing step m2, otherwise gets the drive data in the visible logical drive of preservation.
The step S1 also includes:The drive quantity of all logical drives is obtained from system registry;
The drive that all logical drives are obtained from system registry and drive data, be specially:
Step n1:Open the default registry entry in system registry;
Step n2:A untreated registry entry title is obtained from the default registry entry, current registration is used as List item title;
Step n3:Judge whether current registry entry title includes the first preset characters string, if it is, performing step N4, otherwise performs step n6;
Step n4:Remaining string data in addition to the first preset characters string in current registry entry title is obtained, As the drive of logical drive, and preserve;
Step n5:The drive quantity of all logical drives is updated, step n6 is performed;
Step n6:Judge current registry entry title whether be the default registry entry last title, if It is the drive for all logical drives for then obtaining preservation, otherwise by next registry entry title of current registry entry title It is used as current registry entry title, return to step n3.
In the step S1, the drive data that all logical drives are obtained from system registry are specially:
Step p1:Obtain the drive quantity of all logical drives;
Step p2:The function for obtaining logical drive drive data is called, the 3rd function return value is obtained, by the described 3rd Function return value as all logical drives drive data and preserve;
Step p3:The drive quantity of all logical drives is updated, all logical drives after updating are judged Whether drive quantity is more than 0, if it is, performing step p2, otherwise gets the drive number of all logical drives of preservation According to.
Also include between the step n2 and the step n3:The corresponding key assignments of current registry entry title is obtained, is judged Whether corresponding key assignments is combined with preset characters starts, if it is, performing step n6, otherwise performs step n3.
The step n4, in addition to:The corresponding drive type of current registry entry title, key assignments and key assignments length are obtained, And preserve.
It is described to obtain the GUID value for losing logical drive in the step T1, be specially:
Step q1:Open the default registry entry in the system registry;
Step q2:A untreated registry entry title is obtained from the default registry entry, current registration is used as List item title;
Step q3:Judge whether include the second preset characters string in current registry entry title, if it is, performing step Q4, otherwise performs step q6;
Step q4:Obtain remaining string data and drive in addition to the second preset characters string in current registry entry title Type, regard the string data as GUID value;
Step q5:Obtain the corresponding drive type of current registry entry title, key assignments and key assignments length;
Step q6:Judge whether also have untreated registry entry title in default registry entry, if it is, performing step Rapid q2, otherwise performs step q7;
Step q7:System registry is closed, and obtains the GUID value of preservation, drive type, key assignments and key assignments length;
Step q8:Judge whether the quantity of GUID value is more than 0, if it is, regarding first GUID value as current GUID Value, performs step q9, otherwise terminates;
Step q9:Judge the corresponding key assignments length of current GUID value key corresponding with the current drive for losing logical drive Whether identical it is worth length, if it is, performing step q10, otherwise performs step q11;
Step q10:Judge the corresponding key assignments of current GUID value key assignments corresponding with the drive of the current logic driver It is whether equal, if it is, current GUID value is performed into step as the current GUID value for losing logical drive and preservation T3, otherwise performs step q11;
Step q11:Judge whether also untreated GUID value, if it is, by next GUID value of current GUID value As current GUID value, return and perform step q9, otherwise get the GUID value for losing logical drive.
Also include between the step q2 and the step q3:The corresponding key assignments of current registry entry title is obtained, is judged Whether corresponding key assignments is combined with preset characters starts, if it is, performing step q6, otherwise performs step q3.
The beneficial effect that the present invention is obtained is:Using the solution of the present invention, it is to avoid the disk management that is carried by system Instrument carries out manual lookup and reparation, realizes automation.
Brief description of the drawings
, below will be to embodiment or existing for the clearer explanation embodiment of the present invention or technical scheme of the prior art There is the accompanying drawing used required in technology description to be briefly described, it should be apparent that, drawings in the following description are only this Some embodiments of invention, for those of ordinary skill in the art, on the premise of not paying creative work, can be with Other accompanying drawings are obtained according to these accompanying drawings.
Fig. 1 is the automatic method stream for recovering logical drive under a kind of windows systems that the embodiment of the present invention one is provided Cheng Tu;
Fig. 2 is the specific refinement figure of step 101 in the embodiment of the present invention one;
Fig. 3 is the specific refinement figure of step 102 in the embodiment of the present invention one;
Fig. 4 is the specific refinement figure of step 109 in the embodiment of the present invention one.
Embodiment
Below in conjunction with the accompanying drawing in the embodiment of the present invention, the technical scheme in the embodiment of the present invention is carried out clear, complete Site preparation is described, it is clear that described embodiment is only a part of embodiment of the invention, rather than whole embodiments.It is based on Embodiment in the present invention, it is every other that those of ordinary skill in the art are obtained under the premise of creative work is not made Embodiment, belongs to the scope of protection of the invention.
Embodiment one
The embodiment of the present invention one provides a kind of automatic method for recovering logical drive under windows systems, such as Fig. 1 institutes Show, including:
When operating system in first main frame is copied in the second main frame, it may appear that what the drive of logical drive was lost Phenomenon, the present embodiment, which provides to search, to be lost drive and recovers to lose the method for drive again, when the first host operating system It is copied to after the completion of the second main frame, the second main frame performs following operate:
Step 101:Obtain the drive data and drive quantity of visible logical drive from system, and preserve to first pre- If in memory block;
In the present embodiment, logical drive includes carry the equipment for being identified as driver on main frame, such as CD-ROM drive, Mobile hard disk, USB flash disk, virtual disk etc.;
In the present embodiment, referring to Fig. 2, the drive data and drive number that visible logical drive is obtained from system Amount, and preserve into the first default memory block, it is specially:
Step 101-1:It will be seen that the drive quantity of logical drive is set to initial value, the visible logical drive of acquisition is called Quantity function, obtains first function return value;
The present embodiment is preferred, it will be seen that the drive data of logical drive are set to initial value 0;
Specifically, calling DWORD GetLogicalDrives (void);Function, obtaining DWORD, (DWORD is exactly Double Word, each word are the length of 2 bytes, and DWORD double words are 4 bytes, and each byte is 8, totally 32 Position) drive type first function return value, length is 32, and each bit identification of first function return value correspondence one is visible Logical drive whether there is, and make an appointment, when a certain position of first function return value is if 1, then it represents that corresponding with the position Logical drive exist, be visible logical drive, when a certain position of first function return value is if 0, then it represents that correspondence Logical drive be not present, be invisible logical drive;Make an appointment, the first bit identification logical drive of function return value Device " C:", the second bit identification logical drive " D:", the rest may be inferred;For example, the second of first function return value is 1, then table Show logical drive " D:" exist, the 3rd is 0, then it represents that logical drive " E:" be not present;
For example, in the present embodiment, obtained function return value is 0x00000011;
Step 101-2:Obtain the number of preset value included in first function return value, by comprising preset value number It is used as the drive quantity of visible logical drive;
It is preferred that, preset value is 1;
In the present embodiment, the number for obtaining the preset value included in first function return value is specially:
Step a1:First function return value and preset byte are done and computing, judge operation result last position whether For preset value, if it is, performing step a2, step a3 is otherwise performed;
It is preferred that, preset byte 0x00000001, preset value is 1;
For example, first function return value 0x00000011 and preset byte 0x00000001 are done and computing, obtained fortune Calculation result is 0x00000001, and last position is preset value 1, performs step a2;
Step a2:Update the drive quantity of visible logical drive;
In the present embodiment, the drive quantity for updating visible logical drive is specially:It will be seen that logical drive Drive quantity adds 1;It is preferred that, it is seen that the drive quantity initial value of logical drive is 0;
Step a3:First function return value is moved to right to an obtained value as new first function return value;
For example, first function return value 0x00000011 is moved to right into one, obtained value is 0x00000001, is used as renewal First function return value afterwards;
Step a4:Judge whether first function return value is more than 0, if it is, step a1 is performed, otherwise it will be seen that logic The drive quantity of driver is preserved into the first default memory block, performs step 101-3;
For example, in the present embodiment, the drive quantity of obtained visible logical drive is 2;
In the present embodiment, the number for obtaining the preset value included in first function return value can also be:
Step b1:First function return value is subtracted to the value obtained after preset data as the first numerical value, first function is returned Return value to do and computing with first numerical value, obtain the first result;
In the present embodiment, the preset data is 0x00000001;
For example, first function return value is 0x00000011, preset data 0x00000001 is subtracted, obtaining the first numerical value is 0x00000010, first function return value 0x00000011 and the first numerical value 0x00000010 are done and computing, the first knot is obtained Fruit is 0x00000010;
Step b2:Update the drive quantity of visible logical drive;
In the present embodiment, the drive quantity for updating visible logical drive is specially:It will be seen that logical drive Drive quantity adds 1;It is preferred that, it is seen that the drive quantity initial value of logical drive is 0;
Step b3:Whether judge the first result is 0, if it is, it will be seen that the drive quantity of logical drive preserve to In first default memory block, step 101-3 is performed, function return value is otherwise updated to the first result, return to step b1;
Step 101-3:Obtain the drive quantity of visible logical drive;
Step 101-4:The function for obtaining visible logical drive drive data is called, second function return value is obtained, will Second function return value is used as the drive data in visible logical drive;
In the present embodiment, the function of the visible logical drive drive data of acquisition is
DWORD WINAPI GetLogicalDriveStrings(
__in DWORD nBufferLength,
__out LPTSTR lpBuffer
);Wherein, nBufferLength is the caching section length that second function return value is deposited, and lpBuffer is defeated to need The second function return value gone out, by calling the drive data of the visible logical drive in the function, acquisition system, passes through ginseng Number lpBuffer will be seen that the drive data of logical drive are returned;
For example, in the present embodiment, the drive data of the visible logical drive got are:C:/<NULL>, preserve to the In one default memory block;
Step 101-5:The drive quantity of visible logical drive is updated, judges whether the quantity of visible logical drive is big In 0, if it is, performing step 101-4, step 102 is otherwise performed;
Wherein, the drive quantity of visible logical drive is updated, is specially:It will be seen that the drive quantity of logical drive subtracts 1;
Step 102:Drive, drive data and the drive quantity of all logical drives are obtained from system registry, and Preserve into the second default memory block;
In the present embodiment, all logical drives include visible partition logical drive and invisible logical drive, such as The quantity of really all logical drives is equal to the quantity of visible logical drive, then illustrates no invisible logical drive, i.e., Logical drive is not lost, if the quantity of all logical drives is more than the quantity of visible logical drive, illustrates to deposit In invisible logical drive, that is, exist and lose logical drive;
In the present embodiment, referring to Fig. 3, the step 102 is specially:
Step 102-1:Open the default registry entry in system registry;
In the present embodiment, by call long lRet=RegOpenKeyEx (HKEY_LOCAL_MACHINE, lpPath, 0,KEY_READ,&hKey);Open system registry;Wherein, HKEY_LOCAL_MACHINE be major key, lpPath be sub-key, KEY_READ is that unfolding mode, hKey are to open handle;
In the present embodiment, the default registry entry is:HKEY_LOCAL_MACHINE\SYSTEM\ MountedDevices;
As shown in table 1, the content in default registry entry is:
Table 1
Step 102-2:A untreated registry entry title is obtained from default registry entry, current registration table is used as Item title;
Step 102-3:The corresponding key assignments of current registry entry title is obtained, judges corresponding key assignments whether with preset characters Combination beginning, if it is, performing step 102-7, otherwise performs step 102-4;
In the present embodiment, it is preferred that the preset characters are combined as DA or 5C, if that is, current registry entry title correspondence Key assignments be to be started with DA or started with 5C, then it is not logical drive to illustrate the registry entry, performs step 102-7;
For example, current registry entry it is entitled\Volume{06e3aea7-b5eb-15a2-861d- Bc305cc0ea53 }, corresponding key assignments be the 3f 00 65 00 55 00 39 00 45 of 00 4D of 5C 00, the key assignments with 5C starts, and it is not logical drive to show the registry entry;
Step 102-4:Judge whether include the first preset characters string in the character string of current registry entry title, if It is then to perform step 102-5, otherwise performs step 102-7;
It is preferred that, the first preset characters string for DosDevices;
For example, current registry entry it is entitled DosDevices E:, comprising the first preset characters string DosDevices, Perform step 102-5;
Step 102-5:Obtain remaining string data in current registry entry title in addition to the first preset characters string, disk Type is accorded with, the corresponding key assignments of current registry entry title and key assignments length is obtained, regard the string data as logical drive Drive, using drive type as the logical drive drive type, by the drive of logical drive, drive type, key assignments Preserved with key assignments length into the second default memory block;
For example, current registry entry it is entitled " DosDevices E:", then obtain except the first preset characters string " DosDevices " outer other string datas " E:", drive type " REG_BINARY ", current registry entry title correspondence 00 3f of key assignments 5F, 00 3f 00 5f 00 55 00 53 00 42 00 53 00 54 00, key assignments length 0x0012, will These data are preserved into the second default memory block;
Step 102-6:The drive quantity of all logical drives is updated, step 102-7 is performed;
In the present embodiment, the drive quantity for updating all logical drives is specially:By all logical drives Drive quantity adds 1;It is preferred that, the initial value of the drive quantity of all logical drives is 0;
Step 102-7:Whether judge current registry entry title is last title for presetting registry entry, if It is then to perform step 102-8, otherwise performs step 102-2;
In the present embodiment, as shown in table 2, the drive of all logical drives in the second default memory block got, Drive type, key assignments and key assignments length are:
Table 2
Step 102-8:Obtain the drive quantity of all logical drives;
Step 102-9:The function for obtaining logical drive drive data is called, the 3rd function return value is obtained, will be described 3rd function return value is as the drive data and preservation of all logical drives into the second default memory block;
In the present embodiment, the function of the acquisition logical drive drive data is
DWORD WINAPI GetLogicalDriveStrings(
__in DWORD nBufferLength,
__out LPTSTR lpBuffer
);Wherein, nBufferLength is the caching section length that the 3rd function return value is deposited, and lpBuffer is defeated to need The 3rd function return value gone out, by calling the function, obtains the drive data of all logical drives in system registry, leads to Parameter lpBuffer is crossed to return to the drive data of logical drive;
For example, in the present embodiment, the function of logical drive drive data, all logics got are obtained by calling The drive data of driver are:C:/<NULL>D:/<NULL>E:/<NULL>, preserve into the second default memory block;
Step 102-10:The drive quantity of all logical drives is updated, the drive quantity of all logical drives is judged Whether it is more than 0, if it is, performing step 102-9, otherwise performs step 103;
In the present embodiment, the drive quantity for updating all logical drives is specially:By all logical drives Drive quantity subtracts 1;
Step 103:From the drive data of all logical drives in the second default memory block from acquisition first not The drive data of the logical drive of reason, are used as the drive data of current logic driver;
For example, the drive data of the current logic driver obtained from the second default memory block are C:/<NULL>;
Step 104:Judge that the drive data of current logic driver whether there is in the disk of the visible logical drive Accord with data, if it is, performing step 105, otherwise regard the drive data of current logic driver as loss logical drive The drive data of device are simultaneously preserved into the 4th default memory block, perform step 105;
Wherein, step 104, it is specially:
Step 104-1:First untreated visible logical drive is obtained from the drive data of visible logical drive The drive data of device, are used as the drive data of current visible logical drive;
Step 104-2:Judge the drive data and the drive data of current logic driver of current visible logical drive It is whether identical, if it is, performing step 104-3, otherwise it regard the drive of current logic driver as loss logical drive Drive preserve, perform step 105;
Step 104-3:Judge whether also have untreated drive data in the drive data of visible logical drive, if It is then to make the drive data of next untreated visible logical drive of the drive data of current visible logical drive For the drive data of current visible logical drive, otherwise return to step 104-2 performs step 105.
For example, the drive data C of current logic driver:/<NULL>From the drive data C of visible logical drive:/< NULL>D:/<NULL>It can find, then perform step 105;
Step 105:Judge whether also have untreated drive data in the drive data of all logical drives, if It is, then using the drive data of next untreated logical drive of the drive data of current logic driver as currently patrolling The drive data of driver are collected, otherwise return to step 104 performs step 106;
In the present embodiment, step 103 to step 104 can also be:
Step 103-1:The logical drive for being designated untreated state is obtained from the drive data of all logical drives The drive data of device, are used as the drive data of current logic driver;
Step 104-1:Judge that the drive data of current logic driver whether there is in the drive of visible logical drive In data, if it is, performing step 105-1, otherwise the drive data of current logic driver are regard as loss logical drive The drive data of device are simultaneously preserved into the 4th default memory block, perform step 105-1;
In the present embodiment, step 104-1 is specially:
Step e1:The visible logic for being designated untreated state is obtained from the drive data of the visible logical drive The drive data of driver, are used as the drive data of current visible logical drive;
Step e2:Judge the drive data of current visible logical drive and current logic driver drive data whether It is identical, if it is, performing step e3, otherwise protected the drive of current logic driver as the drive for losing logical drive Deposit, perform step e3;
Step e3:The corresponding mark of the drive data of current visible logical drive is set to processed state, institute is judged State in the drive data of visible logical drive and whether also have the drive data for being designated untreated state, if it is, returning Step e1, otherwise performs step 105-1.
Step 105-1:The corresponding mark of the drive data of current logic driver is set to processed state, judges all Whether there are the drive data for being designated untreated state in the drive data of logical drive, if it is, return to step 103-1, otherwise performs step 106.
Step 106:Obtain the drive data of all loss logical drives in the 4th default memory block;
For example, the drive data of all loss logical drives got are D:/<NULL>E:/<NULL>;
Step 107:According to the drive data of all loss logical drives, obtained from the drive of all logical drives All drives for losing logical drive;
For example, according to the drive data D of all loss logical drives:/<NULL>E:/<NULL>All loss are obtained to patrol The drive for collecting driver is D:、E:;
Step 108:Selection one is not carried out the loss logic of recovery operation from the drive of all loss logical drives The drive of driver;
For example, from it is all loss logical drives drive D:、E:Selection one is not carried out the loss logic of recovery operation The drive D of driver:;
Step 109:According to the drive for losing logical drive, obtained from system registry and lose logical drive GUID value, judges whether that GUID value can be got, if it is, performing step 110, otherwise performs step 113;
In the present embodiment, referring to Fig. 4, the step 109 is specially:
Step 1:Open the default registry entry in system registry;
In the present embodiment, by call long lRet=RegOpenKeyEx (HKEY_LOCAL_MACHINE, lpPath, 0,KEY_READ,&hKey);Open the registration table in system table;Wherein, HKEY_LOCAL_MACHINE is that major key, lpPath are Sub-key, KEY_READ are that unfolding mode, hKey are to open handle;
In the present embodiment, the default registry entry is:HKEY_LOCAL_MACHINE\SYSTEM\ MountedDevices;
Step 2:A untreated registry entry title is obtained from default registry entry, current registration table key name is used as Claim;
For example, the current registry entry obtained from default registry entry it is entitled "\Volume{24a15926- 4b0d-11e2-8ac9-bc305bc0da53}”;
Step 3:The corresponding key assignments of current registry entry title is obtained, judges whether corresponding key assignments is combined with preset characters Beginning, if it is, performing step 7, otherwise performs step 4;
It is preferred that, the preset characters are combined as DA or 5C, if the corresponding key assignments of that is, current registry entry title be with DA is started or started with 5C, then it is not logical drive to illustrate the registry entry, performs step 7;
For example, obtaining the corresponding key assignments of current registry entry title and being:F2 d2 a4 e8 00 7e 00 00 00 00 00 00, do not started with DA or started with 5C, perform step 4;
Step 4:Judge whether include the second preset characters string in current registry entry title, if it is, performing step 5, otherwise perform step 7;
It is preferred that, the second preset characters string for\Volume;
For example, current registry entry title "\Volume{24a15926-4b0d-11e2-8ac9- Bc305bc0da53 } " comprising the second preset characters stringVolume, perform step 5;
Step 5:Obtain remaining string data and drive in addition to the second preset characters string in current registry entry title Type, using the string data as GUID value, and is preserved into the 4th default memory block;
For example, in the present embodiment, current registry entry it is entitled "\Volume{24a15926-4b0d-11e2- 8ac9-bc305bc0da53 } ", obtain except the second preset characters stringString data " 24a15926- outside Volume 4b0d-11e2-8ac9-bc305bc 0da53 " as GUID value, drive type " REG_BINARY ", and preserve the character string Into the 4th default memory block;
Step 6:The corresponding key assignments of current registry entry title and key assignments length are obtained, and is preserved to the 4th default memory block In;
For example, in the present embodiment, the current registry entry title of acquisition "\Volume{24a15926-4b0d-11e2- 8ac9-bc305bc0da53 } " corresponding key assignments be " 7e 00 00 00 00 00 00 of f2 d2 a4 e8 00 ", key assignments length For in 0x000C, and the default memory block of preservation the 4th;
Step 7:Judge whether also have untreated registry entry title in default registry entry, if it is, performing step Rapid 2, otherwise perform step 7;
Step 8:System registry is closed, and obtains GUID value, drive type, the key assignments preserved in the 4th default memory block With key assignments length;
In the present embodiment, by calling RegCloseKey (hKey);Closing registration table, wherein, returned when hKey is opening Opening handle;
In the present embodiment, as shown in table 3, all GUID values, the drive preserved in the 4th default memory block got Type, key assignments and key assignments length are:
Table 3
Step 9:Judge whether the quantity of GUID value is more than 0, if it is, regarding first GUID value as current GUID Value, performs step 10, otherwise terminates;
In the present embodiment, the quantity of the GUID value got is 3, by first GUID value 08e5ada7-b5eb-11e2- 861d-bc305bc0da53 performs step 10 as current GUID value;
Step 10:Judge that the corresponding key assignments length of current GUID value key assignments corresponding with the drive for losing logical drive is long Whether degree is identical, if it is, performing step 11, otherwise performs step 12;
For example, the key assignments length of current GUID value is 0x12, the corresponding key assignments length of drive for losing logical drive is 0x12, both key assignments length are identical, then perform step 10;
Step 11:Judge the corresponding key assignments of current GUID value with lose logical drive the corresponding key assignments of drive whether phase Deng if it is, using current GUID value is as the GUID value for losing logical drive and preserves into the 5th default memory block, holding Row step 110, otherwise performs step 12;
For example, the corresponding key assignments of current GUID value is the 5f 00 55 00 53 00 42 00 of 00 3f of 5F, 00 3f 00 53 00 54 00, the corresponding key assignments of drive for losing logical drive is the 5c 00 55 00 53 of 00 3f of 5F, 00 3f 00 00 42 00 53 00 54 00, both differ, and perform step 11;
Step 12:Judge whether also to be not carried out the GUID value of recovery operation, if it is, by the next of current GUID value GUID value returns as current GUID value and performs step 10, otherwise performs step 113;
For example, as shown in table 4, the drive and corresponding GUID value for getting all loss logical drives are:
Table 4
Step 110:According to the drive and the GUID value of loss logical drive for losing logical drive, loading command is called System function, organizes drive loading command data;
In the present embodiment, it is specially:By calling loading command system function sprintf (sLoad, " mountvol% s\\\\Volume%s ", sDiskName, p);Drive loading command data are organized, wherein, p patrols for the current loss The GUID value of the drive of driver is collected, corresponding sLoad value is mountvol D:\\\\Volume{24a15926-4b0d- 11e2-8ac9-bc305bc0da53 }, sDiskName is the drive " D for losing logical drive:”;
Step 111:According to drive loading command data, recovery drive system function is called, recovers to lose logical drive Drive, judge whether successfully to recover to lose the drive of logical drive, if it is, performing step 113, otherwise perform step 112:
In the present embodiment, drive system function system (sLoad) is recovered by calling;Recover current and lose logical drive The drive of device, makes the drive for the logical drive currently lost normally show, wherein, sLoad value is mountvol D:\\\\Volume{24a15926-4b0d-11e2-8ac9-bc305bc0da53}\;
Step 112:Whether the drive for judging to lose logical drive is default maximum drive, if it is, performing step 113, otherwise update the drive of the loss logical drive, return to step 111;
It is preferred that, the default maximum drive is Z;
In the present embodiment, the current drive for losing logical drive of renewal is specially:Logical drive will currently be lost The drive of device, adds the drive of a unit in alphabetical order;
For example, the drive for currently losing logical drive is E:, then the current drive for losing logical drive is updated, that is, is pressed Drive F is obtained according to the drive of lexicographic order plus a unit:, return again to currently to be lost according to drive loading command data recovery and patrol Collect the drive of driver;
Step 113:Judge whether also to be not carried out the drive of the loss logical drive of recovery operation, if it is, returning Step 108 is returned, is otherwise terminated.
The foregoing is only a preferred embodiment of the present invention, but protection scope of the present invention be not limited thereto, Any one skilled in the art is in technical scope disclosed by the invention, the change or replacement that can be readily occurred in, It should all be included within the scope of the present invention.Therefore, protection scope of the present invention should be with scope of the claims It is defined.

Claims (18)

1. a kind of automatic method for recovering logical drive under windows systems, it is characterised in that including:
Step S1:The drive data of visible logical drive are obtained from system, all logics are obtained from system registry and are driven The drive and drive data of dynamic device;
Step S2:According to the drive data of all logical drives and the drive data of the visible logical drive, obtain To the drive data of all loss logical drives;
Step S3:According to all drive data for losing logical drive, from the drive of all logical drives Obtain all drives for losing logical drive;
Following operate is performed to each drive for losing logical drive in all drives for losing logical drive:
Step T1:Selection one is not carried out the loss logical drive of recovery operation from the drive of all loss logical drives Drive;
Step T2:According to the drive for losing logical drive, the GUID value for losing logical drive is obtained from system registry;
Step T3:According to the drive and the GUID value of loss logical drive for losing logical drive, loading command system is called Function, organizes drive loading command data;
Step T4:According to the drive loading command data, recovery drive system function is called, recovers to lose logical drive Drive;
Step T5:Judge whether also to be not carried out the drive of the loss logical drive of recovery operation, if it is, return to step T1, otherwise terminates.
2. according to the method described in claim 1, it is characterised in that the step S2 is specially:From all logical drives The drive data different from the drive data of the visible logical drive are obtained in the drive data of device, are patrolled as all loss Collect the drive data of driver.
3. according to the method described in claim 1, it is characterised in that the step S2 is specially:
Step a1:The drive of first untreated logical drive is obtained from the drive data of all logical drives Data, are used as the drive data of current logic driver;
Step a2:Judge that the drive data of current logic driver whether there is in the drive data of the visible logical drive In, if it is, performing step a3, otherwise it regard the drive data of current logic driver as the drive for losing logical drive Data are simultaneously preserved, and perform step a3;
Step a3:Judge whether also have untreated drive data in the drive data of all logical drives, if it is, Then it regard the drive data of next untreated logical drive of the drive data of current logic driver as current logic Otherwise the drive data of driver, return to step a2 gets the drive data of all loss logical drives of preservation, performs Step S3.
4. method according to claim 3, it is characterised in that the step a2 is specially:
Step b1:First untreated visible logical drive of acquisition from the drive data of the visible logical drive Drive data, are used as the drive data of current visible logical drive;
Step b2:Judge the drive data of current visible logical drive and current logic driver drive data whether phase Together, if it is, performing step b3, otherwise protected the drive of current logic driver as the drive for losing logical drive Deposit, perform step a3;
Step b3:Judge whether also have untreated drive data in the drive data of the visible logical drive, if it is, Then using the drive data of next untreated visible logical drive of the drive data of current visible logical drive as Otherwise the drive data of current visible logical drive, return to step b2 performs step a3.
5. method according to claim 3, it is characterised in that the step a2 is specially:
Step c1:The visible logical drive for being designated untreated state is obtained from the drive data of the visible logical drive The drive data of device, are used as the drive data of current visible logical drive;
Step c2:Judge the drive data of current visible logical drive and current logic driver drive data whether phase Together, if it is, performing step c3, otherwise protected the drive of current logic driver as the drive for losing logical drive Deposit, perform step c3;
Step c3:It will be seen that the mark of the drive data of logical drive is set to processed state, described visible patrol currently is judged Whether there are the drive data for being designated untreated state in the drive data of volume driver, if it is, return to step c1, no Then perform step a3.
6. according to the method described in claim 1, it is characterised in that the step S2, it is specially:
Step d1:Acquisition is designated the logical drive of untreated state from the drive data of all logical drives Drive data, are used as the drive data of current logic driver;
Step d2:Judge that the drive data of current logic driver whether there is in the drive data of the visible logical drive In, if it is, performing step d3, otherwise it regard the drive data of current logic driver as the drive for losing logical drive Data are simultaneously preserved, and perform step d3;
Step d3:The corresponding mark of the drive data of current logic driver is set to processed state, described all patrol is judged Collect whether to also have in the drive data of driver and be designated untreated drive data, if it is, return to step d1, is otherwise obtained The drive data of all loss logical drives of preservation are got, step S3 is performed.
7. method according to claim 6, it is characterised in that the step d2 is specially:
Step e1:First visible logic for being not carried out recovery operation is obtained from the drive data of the visible logical drive The drive data of driver, are used as the drive data of current visible logical drive;
Step e2:Judge the drive data of current visible logical drive and current logic driver drive data whether phase Together, if it is, performing step e3, otherwise protected the drive of current logic driver as the drive for losing logical drive Deposit, perform step e3;
Step e3:Judge whether also have the drive number for being not carried out recovery operation in the drive data of the visible logical drive According to if it is, next visible logic for being not carried out recovery operation of the drive data of current visible logical drive is driven Otherwise the drive data of dynamic device perform step d3 as the drive data of current visible logical drive, return to step e2.
8. method according to claim 6, it is characterised in that the step d2 is specially:
Step f1:The visible logical drive for being designated untreated state is obtained from the drive data of the visible logical drive The drive data of device, are used as the drive data of current visible logical drive;
Step f2:Judge the drive data of current visible logical drive and current logic driver drive data whether phase Together, if it is, performing step f3, otherwise protected the drive of current logic driver as the drive for losing logical drive Deposit, perform step f3;
Step f3:The corresponding mark of the drive data of current visible logical drive is set to processed state, judgement is described can See in the drive data of logical drive whether also have the drive data for being designated untreated state, if it is, return to step F1, otherwise performs step d3.
9. according to the method described in claim 1, it is characterised in that the step T2, in addition to:Judge from system registry The GUID value for losing logical drive whether can be got, if it is, performing step T3, step T5 is otherwise performed.
10. according to the method described in claim 1, it is characterised in that the step T4, in addition to:
Step i1:Judge whether successfully to recover the drive for losing logical drive, if it is, performing step T5, otherwise Perform step i2;
Step i2:Whether the drive for judging the loss logical drive is default maximum drive, if it is, performing step T5, otherwise updates the drive of the loss logical drive, return to step T4.
11. according to the method described in claim 1, it is characterised in that the step S1 also includes:Visible patrol is obtained from system Collect the drive quantity of driver;
The drive quantity that visible logical drive is obtained from system, be specially:
Step k1:It will be seen that the drive quantity of logical drive is set to initial value, the visible logical drive drive number of acquisition is called Flow function, obtains first function return value;
Step k2:Obtain the number of the preset value included in the first function return value, by comprising preset value number make For the drive quantity of visible logical drive.
12. method according to claim 11, it is characterised in that described to be obtained from system in the step S1 The drive and drive data of logical drive, be specially:
Step m1:Obtain the drive quantity of the visible logical drive;
Step m2:The function for obtaining visible logical drive drive data is called, second function return value is obtained, by described second Function return value is preserved as the drive data in visible logical drive;
Step m3:Update the drive quantity of the visible logical drive, judge the visible logical drive quantity whether More than 0, if it is, performing step m2, the drive data in the visible logical drive of preservation are otherwise got.
13. according to the method described in claim 1, it is characterised in that the step S1 also includes:Obtained from system registry The drive quantity of all logical drives;
The drive that all logical drives are obtained from system registry and drive data, be specially:
Step n1:Open the default registry entry in system registry;
Step n2:A untreated registry entry title is obtained from the default registry entry, current registry entry is used as Title;
Step n3:Judge whether current registry entry title includes the first preset characters string, if it is, step n4 is performed, it is no Then perform step n6;
Step n4:Remaining string data in addition to the first preset characters string in current registry entry title is obtained, as The drive of logical drive, and preserve;
Step n5:The drive quantity of all logical drives is updated, step n6 is performed;
Step n6:Judge current registry entry title whether be the default registry entry last title, if it is, The drive of all logical drives preserved is obtained, otherwise is referred to as working as by next registry entry name of current registry entry title Preceding registry entry title, return to step n3.
14. method according to claim 13, it is characterised in that described to be obtained from system registry in the step S1 The drive data of all logical drives are taken, are specially:
Step p1:Obtain the drive quantity of all logical drives;
Step p2:The function for obtaining logical drive drive data is called, the 3rd function return value is obtained, by the 3rd function Return value as all logical drives drive data and preserve;
Step p3:The drive quantity of all logical drives is updated, the drive of all logical drives after updating is judged Whether quantity is more than 0, if it is, performing step p2, otherwise gets the drive data of all logical drives of preservation.
15. method according to claim 13, it is characterised in that also include between the step n2 and the step n3: The corresponding key assignments of current registry entry title is obtained, judges whether corresponding key assignments is combined with preset characters and starts, if it is, Step n6 is performed, step n3 is otherwise performed.
16. method according to claim 13, it is characterised in that the step n4, in addition to:Obtain current registry entry The corresponding drive type of title, key assignments and key assignments length, and preserve.
17. method according to claim 16, it is characterised in that described to be obtained from system registry in the step T2 The GUID value for losing logical drive is taken, is specially:
Step q1:Open the default registry entry in the system registry;
Step q2:A untreated registry entry title is obtained from the default registry entry, current registry entry is used as Title;
Step q3:Judge whether include the second preset characters string in current registry entry title, if it is, step q4 is performed, Otherwise step q6 is performed;
Step q4:Obtain remaining string data and drive class in addition to the second preset characters string in current registry entry title Type, regard the string data as GUID value;
Step q5:Obtain the corresponding drive type of current registry entry title, key assignments and key assignments length;
Step q6:Judge whether also have untreated registry entry title in default registry entry, if it is, performing step Q2, otherwise performs step q7;
Step q7:System registry is closed, and obtains the GUID value of preservation, drive type, key assignments and key assignments length;
Step q8:Judge whether the quantity of GUID value is more than 0, if it is, first GUID value is held as current GUID value Row step q9, otherwise terminates;
Step q9:Judge that the corresponding key assignments length of current GUID value key assignments corresponding with the current drive for losing logical drive is long Whether degree is identical, if it is, performing step q10, otherwise performs step q11;
Step q10:Judge whether the corresponding key assignments of current GUID value key assignments corresponding with the drive of current logic driver is equal, If it is, performing step T3, otherwise performing current GUID value as the current GUID value for losing logical drive and preservation Step q11;
Step q11:Judge whether also untreated GUID value, if it is, using next GUID value of current GUID value as Current GUID value, returns and performs step q9, otherwise gets the GUID value for losing logical drive.
18. method according to claim 17, it is characterised in that also include between the step q2 and the step q3: The corresponding key assignments of current registry entry title is obtained, judges whether corresponding key assignments is combined with preset characters and starts, if it is, Step q6 is performed, step q3 is otherwise performed.
CN201410477986.1A 2014-09-18 2014-09-18 A kind of automatic method for recovering logical drive under windows systems Expired - Fee Related CN104281498B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201410477986.1A CN104281498B (en) 2014-09-18 2014-09-18 A kind of automatic method for recovering logical drive under windows systems

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201410477986.1A CN104281498B (en) 2014-09-18 2014-09-18 A kind of automatic method for recovering logical drive under windows systems

Publications (2)

Publication Number Publication Date
CN104281498A CN104281498A (en) 2015-01-14
CN104281498B true CN104281498B (en) 2017-08-11

Family

ID=52256399

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201410477986.1A Expired - Fee Related CN104281498B (en) 2014-09-18 2014-09-18 A kind of automatic method for recovering logical drive under windows systems

Country Status (1)

Country Link
CN (1) CN104281498B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109491604B (en) * 2018-11-01 2021-07-02 郑州云海信息技术有限公司 Method, device and system for processing hard disk drive letter repetition problem

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US5559958A (en) * 1991-06-24 1996-09-24 Compaq Computer Corporation Graphical user interface for computer management system and an associated management information base
CN102693166A (en) * 2012-05-10 2012-09-26 华为技术有限公司 Method, device and system for processing information
CN103135947A (en) * 2013-03-26 2013-06-05 北京奇虎科技有限公司 Method and device for displaying Windows disk letters

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US5559958A (en) * 1991-06-24 1996-09-24 Compaq Computer Corporation Graphical user interface for computer management system and an associated management information base
CN102693166A (en) * 2012-05-10 2012-09-26 华为技术有限公司 Method, device and system for processing information
CN103135947A (en) * 2013-03-26 2013-06-05 北京奇虎科技有限公司 Method and device for displaying Windows disk letters

Also Published As

Publication number Publication date
CN104281498A (en) 2015-01-14

Similar Documents

Publication Publication Date Title
CN107005555B (en) Context-aware distributed firewall
TWI718411B (en) Training method, device and electronic equipment of machine learning model
CN103477593B (en) Network system, switch and connection endpoint detection methods
CN109962832A (en) The method and apparatus of Message processing
CN108833237A (en) Intelligent domestic gateway and its management-control method
CN105959231A (en) Agent port communication flow control method and redundant device
CN101098291B (en) Method for preventing disturbance of medium accessing control address table on access equipment
CN107533507A (en) According to the data in log-structured managing storage
CN103299296A (en) Partition management method, device and system in distributed storage system
CN102609446B (en) Distributed Bloom filter system and application method thereof
CN106383736B (en) Ports-Extending method and apparatus
US10958770B2 (en) Realization of a programmable forwarding pipeline through packet header summaries in a data processing unit
CN108781185A (en) The system and method that programmable packet taxonomy model for the network equipment is provided
US7187676B2 (en) Apparatus and method for steering a communication to an open stream
CN104281498B (en) A kind of automatic method for recovering logical drive under windows systems
CN101841483B (en) Hardware routing table management method and device and communication equipment
CN105871737A (en) Communication flow control device used for communication between redundant networks
CN105591872A (en) Method and device for realization of multi-data center interconnection
CN104461779B (en) A kind of storage method of distributed data, apparatus and system
CN104205742B (en) Packet processing method and forwarding element
CN104246716B (en) The processing method and equipment of memory space object
CN106470153A (en) A kind of method and apparatus of prevention temporary loop
CN102866964B (en) Method and device for protecting data on storage equipment
CN107566158A (en) A kind of route configuration information backup method and system, restoration methods and system
CN103457864B (en) Process the method for route next jump, device and the network equipment

Legal Events

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

Granted publication date: 20170811