CN104281498A - Method for automatically restoring logical drive in windows system - Google Patents

Method for automatically restoring logical drive in windows system Download PDF

Info

Publication number
CN104281498A
CN104281498A CN201410477986.1A CN201410477986A CN104281498A CN 104281498 A CN104281498 A CN 104281498A CN 201410477986 A CN201410477986 A CN 201410477986A CN 104281498 A CN104281498 A CN 104281498A
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.)
Granted
Application number
CN201410477986.1A
Other languages
Chinese (zh)
Other versions
CN104281498B (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
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Abstract

The invention discloses a method for automatically restoring a logical drive in a windows system, and belongs to the field of information security. The method comprises the following steps that drive letter data of one visible logical drive is obtained, and drive letters and the drive letter data of all logical drives are obtained; the drive letters of lost logical drives are obtained according to the drive letter data of all of the logical dives and the drive letter data of the visible logical drive, and the following operations are executed on the drive letter of each lost logical drive in the drive letters of all of the lost logical drives: a GUID value of the lost logical drive is obtained from a system registry according to the drive letter of the lost logical drive, drive letter loading command data is organized according to the drive letter of the lost logical drive and the GUID value of the lost logical drive, and the drive letter of the lost logical drive is restored according to the drive letter loading command data. When the scheme is adopted, the manual finding and restoration through provided disc management tools of the system are avoided, and the automation is realized.

Description

Automatically the method for logical drive is recovered under a kind of windows system
Technical field
The present invention relates to information security field, under particularly relating to a kind of windows system, automatically recover the method for logical drive.
Background technology
In prior art, under windows system platform environment, the situation of similar driving is when carrying out the migration of operating system platform, due in server system mirror image migration process, mistake has been write the EBR (expansion leader record) of logical drive and has caused the situation that the drive of logical drive is lost.
Existing scheme is that the instrument " disk administrator " carried by windows platform is changed, and needs artificial participation, runs counter to the original intention of robotization.
Summary of the invention
The object of the invention is to solve problems of the prior art, under providing a kind of windows system, automatically recovering the method for logical drive.
The technical solution used in the present invention is: a kind of method automatically recovering logical drive under windows system, comprising:
Step S1: the drive data obtaining visible logical drive from system, obtains drive and the drive data of all logical drives from system registry;
Step S2: according to the drive data of described all logical drives and the drive data of described visible logical drive, obtain the drive data of all loss logical drives;
Step S3: according to the drive data of described all loss logical drives, obtains the drive of all loss logical drives from the drive of described all logical drives;
Following operation is performed to the drive of each loss logical drive in the drive of described all loss logical drives:
Step T1: according to the drive losing logical drive, obtains the GUID value of losing logical drive from system registry;
Step T2: according to losing the drive of logical drive and losing the GUID value of logical drive, call loading command system function, organize drive loading command data;
Step T3: according to described drive loading command data, calls and recovers drive system function, recovers the drive losing logical drive.
Described step S2 is specially: from the drive data of described all logical drives, obtain the drive data different from the drive data of described visible logical drive, as the drive data of all loss logical drives.
Described step S2 is specially:
Step a1: the drive data obtaining first untreated logical drive from the drive data of described all logical drives, as the drive data of current logic driver;
Step a2: judge whether the drive data of current logic driver are present in the drive data of described visible logical drive, if, then perform step a3, otherwise using the drive data of current logic driver as lose logical drive drive data and preserve, perform step a3;
Step a3: judge whether also have untreated drive data in the drive data of described all logical drives, if, then using the drive data of the drive data of the untreated logical drive of the next one of the drive data of current logic driver as current logic driver, return step a2, otherwise get the drive data of all loss logical drives of preservation, perform step S3.
Described step a2 is specially:
Step b1: the drive data obtaining first untreated visible logical drive from the drive data of described visible logical drive, as the drive data of current visible logical drive;
Step b2: judge that whether the drive data of current visible logical drive are identical with the drive data of current logic driver, if, then perform step b3, otherwise the drive of current logic driver is preserved as the drive losing logical drive, perform step e3;
Step b3: judge whether also have untreated drive data in the drive data of described visible logical drive, if, then using the drive data of the drive data of untreated for the next one of the drive data of current visible logical drive visible logical drive as current visible logical drive, return step b2, otherwise perform step a3.
Described step a2 is specially:
Step c1: obtain the drive data being designated the visible logical drive of untreated state from the drive data of described visible logical drive, as the drive data of current visible logical drive;
Step c2: judge that whether the drive data of current visible logical drive are identical with the drive data of current logic driver, if, then perform step c3, otherwise the drive of current logic driver is preserved as the drive losing logical drive, perform step c3;
Step c3: the mark of the drive data of visible logical drive is set to processed state, currently judge the drive data whether being designated untreated state in the drive data of described visible logical drive in addition, if so, then return step c1, otherwise perform step a3.
Described step S2, is specially:
Steps d 1: obtain the drive data being designated the logical drive of untreated state from the drive data of described all logical drives, as the drive data of current logic driver;
Steps d 2: judge whether the drive data of current logic driver are present in the drive data of described visible logical drive, if, then perform steps d 3, otherwise using the drive data of current logic driver as lose logical drive drive data and preserve, perform steps d 3;
Steps d 3: mark corresponding for the drive data of current logic driver is set to processed state, judge whether be designated untreated drive data in addition in the drive data of described all logical drives, if, then return steps d 1, otherwise get the drive data of all loss logical drives of preservation, perform step S3.
Described steps d 2 is specially:
Step e1: obtain the drive data that first does not perform the visible logical drive of recovery operation from the drive data of described visible logical drive, as the drive data of current visible logical drive;
Step e2: judge that whether the drive data of current visible logical drive are identical with the drive data of current logic driver, if, then perform step e3, otherwise the drive of current logic driver is preserved as the drive losing logical drive, perform step e3;
Step e3: judge the drive data whether not performing recovery operation in the drive data of described visible logical drive in addition, if, then the next one of the drive data of current visible logical drive is not performed the drive data of drive data as current visible logical drive of the visible logical drive of recovery operation, return step e2, otherwise perform steps d 3.
Described steps d 2 is specially:
Step f1: obtain the drive data being designated the visible logical drive of untreated state from the drive data of described visible logical drive, as the drive data of current visible logical drive;
Step f2: judge that whether the drive data of current visible logical drive are identical with the drive data of current logic driver, if, then perform step f3, otherwise the drive of current logic driver is preserved as the drive losing logical drive, perform step f3;
Step f3: mark corresponding for the drive data of current visible logical drive is set to processed state, judge the drive data whether being designated untreated state in the drive data of described visible logical drive in addition, if so, then return step f1, otherwise perform steps d 3.
Comprise before described step T1:
Step g: select a drive not performing the loss logical drive of recovery operation from the drive of all loss logical drives;
Comprise after described step T3:
Step h: the drive judging whether the loss logical drive not performing recovery operation in addition, if so, then returns step g, otherwise terminate.
Described step T1, also comprises: judge from system registry, whether can get the GUID value of losing logical drive, if so, then performs step T2, otherwise performs step h.
Described step T3, also comprises:
Step I 1: judge whether the drive successfully recovering described loss logical drive, if so, then perform step g, otherwise perform step I 2;
Step I 2: whether the drive judging described loss logical drive is default maximum drive, if so, then performs step a2, otherwise upgrades the drive of described loss logical drive, return step T3.
Described step S1 also comprises: the drive quantity obtaining visible logical drive from system;
The described drive quantity obtaining visible logical drive from system, is specially:
Step k1: the drive quantity of visible logical drive is set to initial value, calls and obtains visible logical drive drive quantity function, obtain the first function return value;
Step k2: the number obtaining the preset value comprised in described first function return value, using the number of preset value that the comprises drive quantity as visible logical drive.
In described step S1, described drive and the drive data obtaining visible logical drive from system, are specially:
Step m1: the drive quantity obtaining described visible logical drive;
Step m2: call the function obtaining visible logical drive drive data, obtain the second function return value, using described second function return value as the drive data in visible logical drive, and preserve;
Step m3: the drive quantity upgrading described visible logical drive, judges whether the quantity of described visible logical drive is greater than 0, if so, then performs step m2, otherwise gets the drive data in the visible logical drive of preservation.
Described step S1 also comprises: the drive quantity obtaining all logical drives from system registry;
Described drive and the drive data obtaining all logical drives from system registry, are specially:
Step n1: open the default registry entry in system registry;
Step n2: obtain a untreated registry entry title from described default registry entry, as current registry entry title;
Step n3: judge whether current registry entry title comprises the first preset characters string, if so, then performs step n4, otherwise performs step n6;
Step n4: obtain all the other string datas except described first preset characters string in current registry entry title, as the drive of logical drive, and preserve;
Step n5: the drive quantity upgrading all logical drives, performs step n6;
Step n6: judge that whether current registry entry title is last title of described default registry entry, if, then obtain the drive of all logical drives of preservation, otherwise next registry entry name of current registry entry title is referred to as current registry entry title, return step n3.
In described step S1, the described drive data obtaining all logical drives from system registry, are specially:
Step p1: the drive quantity obtaining described all logical drives;
Step p2: call the function obtaining logical drive drive data, obtain the 3rd function return value, preserves described 3rd function return value as the drive data of all logical drives;
Step p3: the drive quantity upgrading described all logical drives, judges whether the drive quantity of all logical drives after upgrading is greater than 0, if so, then performs step p2, otherwise get the drive data of all logical drives of preservation.
Also comprise between described step n2 and described step n3: obtain the key assignments that current registry entry title is corresponding, judge that whether corresponding key assignments is with preset characters combination beginning, if so, then performs step n6, otherwise performs step n3.
Described step n4, also comprises: obtain drive type corresponding to current registry entry title, key assignments and key assignments length, and preserve.
In described step T1, the GUID value of the described loss logical drive of described acquisition, is specially:
Step q1: open the default registry entry in described system registry;
Step q2: obtain a untreated registry entry title from described default registry entry, as current registry entry title;
Step q3: judge whether comprise the second preset characters string in current registry entry title, if so, then performs step q4, otherwise performs step q6;
Step q4: obtain all the other string datas in current registry entry title except the second preset characters string and drive type, using this string data as GUID value;
Step q5: obtain drive type corresponding to current registry entry title, key assignments and key assignments length;
Step q6: judge to preset in registry entry whether also have untreated registry entry title, if so, then performs step q2, otherwise performs step q7;
Step q7: shutdown system registration table, and obtain GUID value, drive type, key assignments and the key assignments length of preserving;
Step q8: judge whether the quantity of GUID value is greater than 0, if so, then using first GUID value as current GUID value, perform step q8, otherwise terminate;
Step q9: judge that whether key assignments length corresponding to the current GUID value key assignments length corresponding with the drive of current loss logical drive is identical, if so, then perform step q10, otherwise execution step q11;
Step q10: judge that whether the key assignments that the key assignments of current GUID value correspondence is corresponding with the drive of described current logic driver is equal, if, then current GUID value is preserved as the GUID value of current loss logical drive, perform step S4, otherwise perform step q11;
Step q11: judge whether in addition untreated GUID value, if so, then using next GUID value of current GUID value as current GUID value, return execution step q9, otherwise get the GUID value of loss logical drive.
Also comprise between described step q2 and described step q3: obtain the key assignments that current registry entry title is corresponding, judge that whether corresponding key assignments is with preset characters combination beginning, if so, then performs step q6, otherwise performs step q3.
The beneficial effect that the present invention obtains is: adopt the solution of the present invention, avoids the disk management instrument carried by system and carries out craft and search and repair, achieve robotization.
Accompanying drawing explanation
In order to the clearer explanation embodiment of the present invention or technical scheme of the prior art, be briefly described to the accompanying drawing used required in embodiment or description of the prior art below, apparently, accompanying drawing in the following describes is only some embodiments of the present invention, for those of ordinary skill in the art, under the prerequisite not paying creative work, other accompanying drawing can also be obtained according to these accompanying drawings.
Fig. 1 is the method flow diagram automatically recovering logical drive under a kind of windows system of providing of the embodiment of the present invention one;
Fig. 2 is the concrete refinement figure of step 101 in the embodiment of the present invention one;
Fig. 3 is the concrete refinement figure of step 102 in the embodiment of the present invention one;
Fig. 4 is the concrete 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, be clearly and completely described the technical scheme in the embodiment of the present invention, obviously, described embodiment is only the present invention's part embodiment, instead of whole embodiments.Based on the embodiment in the present invention, those of ordinary skill in the art, not making the every other embodiment obtained under creative work prerequisite, belong to the scope of protection of the invention.
Embodiment one
The embodiment of the present invention one recovers the method for logical drive automatically under providing a kind of windows system, as shown in Figure 1, comprising:
When operating system in first main frame is copied in the second main frame, the phenomenon that the drive that there will be logical drive is lost, the present embodiment provides the method for searching and losing drive and again recovering to lose drive, when the first host operating system is copied to after the second main frame completes, the second main frame performs following operation:
Step 101: the drive data and the drive quantity that obtain visible logical drive from system, and be saved in the first default memory block;
In the present embodiment, logical drive comprises the equipment of the be identified as driver of carry on main frame, as CD-ROM drive, portable hard drive, USB flash disk, virtual disk etc.;
In the present embodiment, see Fig. 2, described drive data and the drive quantity obtaining visible logical drive from system, and be saved in the first default memory block, be specially:
Step 101-1: the drive quantity of visible logical drive is set to initial value, calls and obtains visible logical drive quantity function, obtain the first function return value;
The present embodiment is preferred, and the drive data of visible logical drive are set to initial value 0;
Concrete, call DWORD GetLogicalDrives (void), function, (DWORD is exactly Double Word to obtain DWORD, each word is the length of 2 bytes, DWORD double word is 4 bytes, each byte is 8, totally 32) the first function return value of drive type, length is 32, whether the corresponding visible logical drive of each mark of the first function return value exists, make an appointment, when a certain position of the first function return value is if 1, then represent that the logical drive corresponding with this exists, for visible logical drive, when a certain position of the first function return value is if 0, then represent that corresponding logical drive does not exist, for invisible logical drive, make an appointment, the first bit-identify logical drive " C: " of function return value, second tagging logic driver " D: ", the rest may be inferred, such as, the second of the first function return value is 1, then presentation logic driver " D: " exists, and the 3rd is 0, then presentation logic driver " E: " does not exist,
Such as, in the present embodiment, the function return value obtained is 0x00000011;
Step 101-2: the number obtaining the preset value comprised in the first function return value, using the number of preset value that the comprises drive quantity as visible logical drive;
Preferably, preset value is 1;
In the present embodiment, the number of the preset value comprised in described acquisition first function return value, is specially:
Step a1: the first function return value and default byte are done and computing, judges whether last position of operation result is preset value, if so, then performs step a2, otherwise performs step a3;
Preferably, preset byte 0x00000001, preset value is 1;
Such as, done and computing by the first function return value 0x00000011 and default byte 0x00000001, the operation result obtained is 0x00000001, and last position is preset value 1, performs step a2;
Step a2: the drive quantity upgrading visible logical drive;
In the present embodiment, the drive quantity of the visible logical drive of described renewal, is specially: the drive quantity of visible logical drive is added 1; Preferably, the drive quantity initial value of visible logical drive is 0;
Step a3: the value obtained that moved to right by the first function return value is as the first new function return value;
Such as, the first function return value 0x00000011 is moved to right one, the value obtained is 0x00000001, as the first function return value after renewal;
Step a4: judge whether the first function return value is greater than 0, if so, then performs step a1, otherwise the drive quantity of visible logical drive is saved in the first default memory block, performs step 101-3;
Such as, in the present embodiment, the drive quantity of the visible logical drive obtained is 2;
In the present embodiment, the number of the preset value comprised in described acquisition first function return value, can also be:
Step b1: the first function return value is subtracted the value that obtains after preset data as the first numerical value, the first function return value and described first numerical value are done and computing, obtains the first result;
In the present embodiment, described preset data is 0x00000001;
Such as, first function return value is 0x00000011, deducts preset data 0x00000001, and obtaining the first numerical value is 0x00000010, done and computing by first function return value 0x00000011 and the first numerical value 0x00000010, obtaining the first result is 0x00000010;
Step b2: the drive quantity upgrading visible logical drive;
In the present embodiment, the drive quantity of the visible logical drive of described renewal, is specially: the drive quantity of visible logical drive is added 1; Preferably, the drive quantity initial value of visible logical drive is 0;
Step b3: judge whether the first result is 0, if so, is then saved to first and presets in memory block, perform step 101-3, otherwise function return value is updated to the first result, return step b1 by the drive quantity of visible logical drive;
Step 101-3: the drive quantity obtaining visible logical drive;
Step 101-4: call the function obtaining visible logical drive drive data, obtain the second function return value, using the second function return value as the drive data in visible logical drive;
In the present embodiment, the function of described acquisition visible logical drive drive data is
DWORD?WINAPI?GetLogicalDriveStrings(
__in DWORD?nBufferLength,
__out LPTSTR?lpBuffer
); Wherein, nBufferLength is the buffer area length that the second function return value is deposited, lpBuffer is the second function return value needing to export, by calling this function, the drive data of visible logical drive are returned by parameter lpBuffer by the drive data of the visible logical drive in acquisition system;
Such as, in the present embodiment, the drive data of the visible logical drive got are: C:/<NULL>, are saved to first and preset in memory block;
Step 101-5: the drive quantity upgrading visible logical drive, judges whether the quantity of visible logical drive is greater than 0, if so, then performs step 101-4, otherwise performs step 102;
Wherein, upgrade the drive quantity of visible logical drive, be specially: the drive quantity of visible logical drive is subtracted 1;
Step 102: obtain the drive of all logical drives, drive data and drive quantity from system registry, and be saved in the second default memory block;
In the present embodiment, all logical drives comprise visible partition logical drive and invisible logical drive, if the quantity of all logical drives equals the quantity of visible logical drive, then illustrate there is no invisible logical drive, namely logical drive is not lost, if the quantity of all logical drives is greater than the quantity of visible logical drive, then illustrate to there is invisible logical drive, namely exist and lose logical drive;
In the present embodiment, see Fig. 3, described step 102 is specially:
Step 102-1: open the default registry entry in system registry;
In the present embodiment, by calling long lRet=RegOpenKeyEx (HKEY_LOCAL_MACHINE, lpPath, 0, KEY_READ, & hKey); Open system registry; Wherein, HKEY_LOCAL_MACHINE is major key, lpPath is sub-key, KEY_READ is that unfolding mode, hKey are for opening handle;
In the present embodiment, described default registry entry is: HKEY_LOCAL_MACHINE SYSTEM MountedDevices;
As shown in table 1, the content preset in registry entry is:
Table 1
Step 102-2: obtain a untreated registry entry title from default registry entry, as current registry entry title;
Step 102-3: obtain the key assignments that current registry entry title is corresponding, judges that whether corresponding key assignments is with preset characters combination beginning, if so, then performs step 102-7, otherwise performs step 102-4;
In the present embodiment, preferably, described preset characters is combined as DA or 5C, if the key assignments that namely current registry entry title is corresponding is with DA beginning or with 5C beginning, then illustrates that this registry entry is not logical drive, performs step 102-7;
Such as, current registry entry name Cheng Wei? Volume{06e3aea7-b5eb-15a2-861d-bc305cc0ea53}, key assignments corresponding is with it 5C 00 4D 00 3f 00 65 00 55 00 39 00 45, and this key assignments starts with 5C, shows that this registry entry is not logical drive;
Step 102-4: judge whether comprise the first preset characters string in the character string of current registry entry title, if so, then performs step 102-5, otherwise performs step 102-7;
Preferably, the first preset characters string be DosDevices;
Such as, current registry entry name Cheng Wei DosDevices E:, comprise the first preset characters Chuan DosDevices, perform step 102-5;
Step 102-5: obtain all the other string datas in current registry entry title except the first preset characters string, drive type, obtain key assignments corresponding to current registry entry title and key assignments length, using this string data as the drive of logical drive, using the drive type of drive type as this logical drive, the drive of logical drive, drive type, key assignments and key assignments length are saved to second and preset in memory block;
Such as, current registry entry name is called “ DosDevices E: ", then obtain other string datas " E: " except the first preset characters string " DosDevices ", key assignments 5F 00 3f 00 3f 00 5f 00 55 00 53 00 42 00 53 00 5400 that drive type " REG_BINARY ", current registry entry title are corresponding, these data are saved to second and preset in memory block by key assignments length 0x0012;
Step 102-6: the drive quantity upgrading all logical drives, performs step 102-7;
In the present embodiment, the drive quantity of all logical drives of described renewal, is specially: the drive quantity of all logical drives is added 1; Preferably, the initial value of the drive quantity of all logical drives is 0;
Step 102-7: judge that whether current registry entry title is last title of default registry entry, if so, then perform step 102-8, otherwise perform step 102-2;
In the present embodiment, as shown in table 2, the get second drive presetting all logical drives in memory block, drive type, key assignments and key assignments length are:
Table 2
Step 102-8: the drive quantity obtaining all logical drives;
Step 102-9: call the function obtaining logical drive drive data, obtain the 3rd function return value, is saved to second using described 3rd function return value presets in memory block as the drive data of all logical drives;
In the present embodiment, the function of described acquisition logical drive drive data is
DWORD?WINAPI?GetLogicalDriveStrings(
__in DWORD?nBufferLength,
__out LPTSTR?lpBuffer
); Wherein, nBufferLength is the buffer area length that the 3rd function return value is deposited, lpBuffer is the 3rd function return value needing to export, by calling this function, obtain the drive data of all logical drives in system registry, by parameter lpBuffer, the drive data of logical drive are returned;
Such as, in the present embodiment, by calling the function obtaining logical drive drive data, the drive data of all logical drives got are: C:/<NULL>D:/<NUL L>E:/<NULL>, are saved to second and preset in memory block;
Step 102-10: the drive quantity upgrading all logical drives, judges whether the drive quantity of all logical drives is greater than 0, if so, then performs step 102-9, otherwise performs step 103;
In the present embodiment, the drive quantity of all logical drives of described renewal, is specially: the drive quantity of all logical drives is subtracted 1;
Step 103: preset the drive data obtaining first untreated logical drive in the drive data of all logical drives memory block, as the drive data of current logic driver from second;
Such as, the drive data presetting from second the current logic driver obtained memory block are C:/<NULL>;
Step 104: judge whether the drive data of current logic driver are present in the drive data of described visible logical drive, if, then perform step 105, otherwise the drive data of current logic driver are saved to the 4th and preset in memory block as the drive data of losing logical drive, performs step 105;
Wherein, step 104, is specially:
Step 104-1: the drive data obtaining first untreated visible logical drive from the drive data of visible logical drive, as the drive data of current visible logical drive;
Step 104-2: judge that whether the drive data of current visible logical drive are identical with the drive data of current logic driver, if, then perform step 104-3, otherwise the drive of current logic driver is preserved as the drive losing logical drive, perform step 105;
Step 104-3: judge whether also have untreated drive data in the drive data of visible logical drive, if, then using the drive data of the drive data of untreated for the next one of the drive data of current visible logical drive visible logical drive as current visible logical drive, return step 104-2, otherwise perform step 105.
Such as, the drive data C:/<NULL> of current logic driver can find from the drive data C:/<NULL>D:/<NUL L> of visible logical drive, then perform step 105;
Step 105: judge whether also have untreated drive data in the drive data of all logical drives, if, then using the drive data of the drive data of the untreated logical drive of the next one of the drive data of current logic driver as current logic driver, return step 104, otherwise perform step 106;
In the present embodiment, step 103 to step 104 can also be:
Step 103-1: obtain the drive data being designated the logical drive of untreated state from the drive data of all logical drives, as the drive data of current logic driver;
Step 104-1: judge whether the drive data of current logic driver are present in the drive data of visible logical drive, if, then perform step 105-1, otherwise the drive data of current logic driver are saved to the 4th and preset in memory block as the drive data of losing logical drive, performs step 105-1;
In the present embodiment, step 104-1 is specially:
Step e1: obtain the drive data being designated the visible logical drive of untreated state from the drive data of described visible logical drive, as the drive data of current visible logical drive;
Step e2: judge that whether the drive data of current visible logical drive are identical with the drive data of current logic driver, if, then perform step e3, otherwise the drive of current logic driver is preserved as the drive losing logical drive, perform step e3;
Step e3: mark corresponding for the drive data of current visible logical drive is set to processed state, judge the drive data whether being designated untreated state in the drive data of described visible logical drive in addition, if so, then return step e1, otherwise perform step 105-1.
Step 105-1: mark corresponding for the drive data of current logic driver is set to processed state, judge the drive data whether being designated untreated state in the drive data of all logical drives in addition, if so, then return step 103-1, otherwise perform step 106.
Step 106: obtain the drive data that the 4th presets all loss logical drives in memory block;
Such as, the drive data of all loss logical drives got are D:/<NULL>E:/<NUL L>;
Step 107: according to the drive data of all loss logical drives, obtains the drive of all loss logical drives from the drive of all logical drives;
Such as, the drive obtaining all loss logical drives according to the drive data D:/<NULL>E:/<NUL L> of all loss logical drives is D:, E:;
Step 108: select a drive not performing the loss logical drive of recovery operation from the drive of all loss logical drives;
Such as, from the drive D of all loss logical drives:, E: select a drive D not performing the loss logical drive of recovery operation:;
Step 109: according to the drive losing logical drive, obtains the GUID value of losing logical drive, judges whether to get GUID value from system registry, if so, then performs step 110, otherwise performs step 113;
In the present embodiment, see Fig. 4, described step 109, is specially:
Step 1: open the default registry entry in system registry;
In the present embodiment, by calling long lRet=RegOpenKeyEx (HKEY_LOCAL_MACHINE, lpPath, 0, KEY_READ, & hKey); Open the registration table in system table; Wherein, HKEY_LOCAL_MACHINE is major key, lpPath is sub-key, KEY_READ is that unfolding mode, hKey are for opening handle;
In the present embodiment, described default registry entry is: HKEY_LOCAL_MACHINE SYSTEM MountedDevices;
Step 2: obtain a untreated registry entry title from default registry entry, as current registry entry title;
Does is such as, the current registry entry name obtained from default registry entry called “? 0 Volume{24a15926-4b0d-11e2-8ac9-bc305bc0da53} ";
Step 3: obtain the key assignments that current registry entry title is corresponding, judges that whether corresponding key assignments is with preset characters combination beginning, if so, then performs step 7, otherwise performs step 4;
Preferably, described preset characters is combined as DA or 5C, if the key assignments that namely current registry entry title is corresponding is with DA beginning or with 5C beginning, then illustrates that this registry entry is not logical drive, performs step 7;
Such as, the key assignments obtaining current registry entry title corresponding is: F2 d2 a4 e8007e 000000000000, not with DA beginning or with 5C beginning, performs step 4;
Step 4: judge whether comprise the second preset characters string in current registry entry title, if so, then performs step 5, otherwise performs step 7;
Preferably, the second preset characters string be? Volume;
Such as, current registry entry title " Volume{24a15926-4b0d-11e2-8ac9-bc305bc0da53} " comprise the second preset characters string? Volume, perform step 5;
Step 5: obtain all the other string datas in current registry entry title except the second preset characters string and drive type, using this string data as GUID value, and is saved in the 4th default memory block;
Such as, in the present embodiment, does is current registry entry name called “? 0 Volume{24a15926-4b0d-11e2-8ac9-bc305bc0da53} ", obtain except the second preset characters string? string data " 24a15926-4b0d-11e2-8ac9-bc305bc 0da53 " outside Volume using this character string as GUID value, drive type " REG_BINARY ", and be saved to the 4th and preset in memory block;
Step 6: obtain key assignments corresponding to current registry entry title and key assignments length, and be saved in the 4th default memory block;
Such as, in the present embodiment, obtain current registry entry title " Volume{24a15926-4b0d-11e2-8ac9-bc305bc0da53} " corresponding key assignments is " f2 d2 a4 e8007e 000000000000 ", key assignments length is 0x000C, and preserves in the 4th default memory block;
Step 7: judge to preset in registry entry whether also have untreated registry entry title, if so, then performs step 2, otherwise performs step 7;
Step 8: shutdown system registration table, and obtain GUID value, drive type, key assignments and the key assignments length of preserving in the 4th default memory block;
In the present embodiment, by calling RegCloseKey (hKey); Closing registration table, wherein, what return when hKey is and opens opens handle;
In the present embodiment, as shown in table 3, the get the 4th presets all GUID value, drive type, key assignments and the key assignments length of preserving in memory block is:
Table 3
Step 9: judge whether the quantity of GUID value is greater than 0, if so, then using first GUID value as current GUID value, perform step 10, otherwise terminate;
In the present embodiment, the quantity of the GUID value got is 3, using first GUID value 08e5ada7-b5eb-11e2-861d-bc305bc0da53 as current GUID value, performs step 10;
Step 10: judge that whether key assignments length corresponding to the current GUID value key assignments length corresponding with the drive losing logical drive is identical, if so, then perform step 11, otherwise execution step 12;
Such as, the key assignments length of current GUID value is 0x12, and the key assignments length that the drive of loss logical drive is corresponding is 0x12, and both key assignments length is identical, then perform step 10;
Step 11: judge that whether the key assignments that the key assignments of current GUID value correspondence is corresponding with the drive losing logical drive is equal, if, then current GUID value is saved to the 5th and presets in memory block as the GUID value of losing logical drive, perform step 110, otherwise execution step 12;
Such as, the key assignments of current GUID value correspondence is 5F 003f 003f 005f 0055005300420053005400, the key assignments that the drive of loss logical drive is corresponding is 5F 003f 003f 005c 0055005300420053005400, and both are not identical, perform step 11;
Step 12: judge whether the GUID value not performing recovery operation in addition, if so, then using next GUID value of current GUID value as current GUID value, return perform step 10, otherwise perform step 113;
Such as, as shown in table 4, the drive and the corresponding GUID value that get all loss logical drives are:
Table 4
Step 110: according to losing the drive of logical drive and losing the GUID value of logical drive, call loading command system function, organize drive loading command data;
In the present embodiment, be specially: by call loading command system function sprintf (sLoad, " and mountvol%s? Volume%s ", sDiskName, p); Organize drive loading command data, wherein, p is the GUID value of the drive of described current loss logical drive, the value of corresponding sLoad be mountvolD:? Volume{24a15926-4b0d-11e2-8ac9-bc305bc0da53}, sDiskName loses the drive " D: " of logical drive;
Step 111: according to drive loading command data, calls and recovers drive system function, recovers the drive losing logical drive, judges whether the drive successfully recovering to lose logical drive, if so, then performs step 113, otherwise performs step 112:
In the present embodiment, recover drive system function system (sLoad) by calling; Recover the drive of current loss logical drive, the drive of the logical drive of current loss normally shown, wherein, the value of sLoad be mountvol D:? Volume{24a15926-4b0d-11e2-8ac9-bc305bc0da53};
Step 112: judge whether the drive losing logical drive is default maximum drive, if so, then perform step 113, otherwise upgrade the drive of described loss logical drive, return step 111;
Preferably, described default maximum drive is Z;
In the present embodiment, the drive of the current loss logical drive of described renewal, is specially: by the drive of current loss logical drive, add the drive of a unit in alphabetical order;
Such as, the drive of current loss logical drive is E:, then upgrade the drive of current loss logical drive, the drive namely adding a unit in alphabetical order obtains drive F:, then return the drive according to the current loss logical drive of drive loading command date restoring;
Step 113: the drive judging whether the loss logical drive not performing recovery operation in addition, if so, then returns step 108, otherwise terminate.
The above; be only the present invention's preferably embodiment, but protection scope of the present invention is not limited thereto, is anyly familiar with those skilled in the art in technical scope disclosed by the invention; the change that can expect easily or replacement, all should be encompassed within protection scope of the present invention.Therefore, protection scope of the present invention should be as the criterion with the protection domain of claim.

Claims (19)

1. automatically recover a method for logical drive under windows system, it is characterized in that, comprising:
Step S1: the drive data obtaining visible logical drive from system, obtains drive and the drive data of all logical drives from system registry;
Step S2: according to the drive data of described all logical drives and the drive data of described visible logical drive, obtain the drive data of all loss logical drives;
Step S3: according to the drive data of described all loss logical drives, obtains the drive of all loss logical drives from the drive of described all logical drives;
Following operation is performed to the drive of each loss logical drive in the drive of described all loss logical drives:
Step T1: according to the drive losing logical drive, obtains the GUID value of losing logical drive from system registry;
Step T2: according to losing the drive of logical drive and losing the GUID value of logical drive, call loading command system function, organize drive loading command data;
Step T3: according to described drive loading command data, calls and recovers drive system function, recovers the drive losing logical drive.
2. method according to claim 1, it is characterized in that, described step S2 is specially: from the drive data of described all logical drives, obtain the drive data different from the drive data of described visible logical drive, as the drive data of all loss logical drives.
3. method according to claim 1, is characterized in that, described step S2 is specially:
Step a1: the drive data obtaining first untreated logical drive from the drive data of described all logical drives, as the drive data of current logic driver;
Step a2: judge whether the drive data of current logic driver are present in the drive data of described visible logical drive, if, then perform step a3, otherwise using the drive data of current logic driver as lose logical drive drive data and preserve, perform step a3;
Step a3: judge whether also have untreated drive data in the drive data of described all logical drives, if, then using the drive data of the drive data of the untreated logical drive of the next one of the drive data of current logic driver as current logic driver, return step a2, otherwise get the drive data of all loss logical drives of preservation, perform step S3.
4. method according to claim 3, is characterized in that, described step a2 is specially:
Step b1: the drive data obtaining first untreated visible logical drive from the drive data of described visible logical drive, as the drive data of current visible logical drive;
Step b2: judge that whether the drive data of current visible logical drive are identical with the drive data of current logic driver, if, then perform step b3, otherwise the drive of current logic driver is preserved as the drive losing logical drive, perform step e3;
Step b3: judge whether also have untreated drive data in the drive data of described visible logical drive, if, then using the drive data of the drive data of untreated for the next one of the drive data of current visible logical drive visible logical drive as current visible logical drive, return step b2, otherwise perform step a3.
5. method according to claim 3, is characterized in that, described step a2 is specially:
Step c1: obtain the drive data being designated the visible logical drive of untreated state from the drive data of described visible logical drive, as the drive data of current visible logical drive;
Step c2: judge that whether the drive data of current visible logical drive are identical with the drive data of current logic driver, if, then perform step c3, otherwise the drive of current logic driver is preserved as the drive losing logical drive, perform step c3;
Step c3: the mark of the drive data of visible logical drive is set to processed state, currently judge the drive data whether being designated untreated state in the drive data of described visible logical drive in addition, if so, then return step c1, otherwise perform step a3.
6. method according to claim 1, is characterized in that, described step S2, is specially:
Steps d 1: obtain the drive data being designated the logical drive of untreated state from the drive data of described all logical drives, as the drive data of current logic driver;
Steps d 2: judge whether the drive data of current logic driver are present in the drive data of described visible logical drive, if, then perform steps d 3, otherwise using the drive data of current logic driver as lose logical drive drive data and preserve, perform steps d 3;
Steps d 3: mark corresponding for the drive data of current logic driver is set to processed state, judge whether be designated untreated drive data in addition in the drive data of described all logical drives, if, then return steps d 1, otherwise get the drive data of all loss logical drives of preservation, perform step S3.
7. method according to claim 6, is characterized in that, described steps d 2 is specially:
Step e1: obtain the drive data that first does not perform the visible logical drive of recovery operation from the drive data of described visible logical drive, as the drive data of current visible logical drive;
Step e2: judge that whether the drive data of current visible logical drive are identical with the drive data of current logic driver, if, then perform step e3, otherwise the drive of current logic driver is preserved as the drive losing logical drive, perform step e3;
Step e3: judge the drive data whether not performing recovery operation in the drive data of described visible logical drive in addition, if, then the next one of the drive data of current visible logical drive is not performed the drive data of drive data as current visible logical drive of the visible logical drive of recovery operation, return step e2, otherwise perform steps d 3.
8. method according to claim 6, is characterized in that, described steps d 2 is specially:
Step f1: obtain the drive data being designated the visible logical drive of untreated state from the drive data of described visible logical drive, as the drive data of current visible logical drive;
Step f2: judge that whether the drive data of current visible logical drive are identical with the drive data of current logic driver, if, then perform step f3, otherwise the drive of current logic driver is preserved as the drive losing logical drive, perform step f3;
Step f3: mark corresponding for the drive data of current visible logical drive is set to processed state, judge the drive data whether being designated untreated state in the drive data of described visible logical drive in addition, if so, then return step f1, otherwise perform steps d 3.
9. method according to claim 1, is characterized in that,
Comprise before described step T1:
Step g: select a drive not performing the loss logical drive of recovery operation from the drive of all loss logical drives;
Comprise after described step T3:
Step h: the drive judging whether the loss logical drive not performing recovery operation in addition, if so, then returns step g, otherwise terminate.
10. method according to claim 9, is characterized in that, described step T1, also comprises: judge from system registry, whether can get the GUID value of losing logical drive, if so, then performs step T2, otherwise performs step h.
11. methods according to claim 9, is characterized in that, described step T3, also comprises:
Step I 1: judge whether the drive successfully recovering described loss logical drive, if so, then perform step g, otherwise perform step I 2;
Step I 2: whether the drive judging described loss logical drive is default maximum drive, if so, then performs step a2, otherwise upgrades the drive of described loss logical drive, return step T3.
12. methods according to claim 1, is characterized in that, described step S1 also comprises: the drive quantity obtaining visible logical drive from system;
The described drive quantity obtaining visible logical drive from system, is specially:
Step k1: the drive quantity of visible logical drive is set to initial value, calls and obtains visible logical drive drive quantity function, obtain the first function return value;
Step k2: the number obtaining the preset value comprised in described first function return value, using the number of preset value that the comprises drive quantity as visible logical drive.
13. methods according to claim 12, is characterized in that, in described step S1, described drive and the drive data obtaining visible logical drive from system, are specially:
Step m1: the drive quantity obtaining described visible logical drive;
Step m2: call the function obtaining visible logical drive drive data, obtain the second function return value, using described second function return value as the drive data in visible logical drive, and preserve;
Step m3: the drive quantity upgrading described visible logical drive, judges whether the quantity of described visible logical drive is greater than 0, if so, then performs step m2, otherwise gets the drive data in the visible logical drive of preservation.
14. methods according to claim 1, is characterized in that, described step S1 also comprises: the drive quantity obtaining all logical drives from system registry;
Described drive and the drive data obtaining all logical drives from system registry, are specially:
Step n1: open the default registry entry in system registry;
Step n2: obtain a untreated registry entry title from described default registry entry, as current registry entry title;
Step n3: judge whether current registry entry title comprises the first preset characters string, if so, then performs step n4, otherwise performs step n6;
Step n4: obtain all the other string datas except described first preset characters string in current registry entry title, as the drive of logical drive, and preserve;
Step n5: the drive quantity upgrading all logical drives, performs step n6;
Step n6: judge that whether current registry entry title is last title of described default registry entry, if, then obtain the drive of all logical drives of preservation, otherwise next registry entry name of current registry entry title is referred to as current registry entry title, return step n3.
15. methods according to claim 14, is characterized in that, in described step S1, the described drive data obtaining all logical drives from system registry, are specially:
Step p1: the drive quantity obtaining described all logical drives;
Step p2: call the function obtaining logical drive drive data, obtain the 3rd function return value, preserves described 3rd function return value as the drive data of all logical drives;
Step p3: the drive quantity upgrading described all logical drives, judges whether the drive quantity of all logical drives after upgrading is greater than 0, if so, then performs step p2, otherwise get the drive data of all logical drives of preservation.
16. methods according to claim 14, is characterized in that, also comprise between described step n2 and described step n3: obtain the key assignments that current registry entry title is corresponding, judge that whether corresponding key assignments is with preset characters combination beginning, if so, then perform step n6, otherwise perform step n3.
17. methods according to claim 14, is characterized in that, described step n4, also comprises: obtain drive type corresponding to current registry entry title, key assignments and key assignments length, and preserve.
18. methods according to claim 17, is characterized in that, in described step T1, the GUID value of the described loss logical drive of described acquisition, is specially:
Step q1: open the default registry entry in described system registry;
Step q2: obtain a untreated registry entry title from described default registry entry, as current registry entry title;
Step q3: judge whether comprise the second preset characters string in current registry entry title, if so, then performs step q4, otherwise performs step q6;
Step q4: obtain all the other string datas in current registry entry title except the second preset characters string and drive type, using this string data as GUID value;
Step q5: obtain drive type corresponding to current registry entry title, key assignments and key assignments length;
Step q6: judge to preset in registry entry whether also have untreated registry entry title, if so, then performs step q2, otherwise performs step q7;
Step q7: shutdown system registration table, and obtain GUID value, drive type, key assignments and the key assignments length of preserving;
Step q8: judge whether the quantity of GUID value is greater than 0, if so, then using first GUID value as current GUID value, perform step q8, otherwise terminate;
Step q9: judge that whether key assignments length corresponding to the current GUID value key assignments length corresponding with the drive of current loss logical drive is identical, if so, then perform step q10, otherwise execution step q11;
Step q10: judge that whether the key assignments that the key assignments of current GUID value correspondence is corresponding with the drive of described current logic driver is equal, if, then current GUID value is preserved as the GUID value of current loss logical drive, perform step S4, otherwise perform step q11;
Step q11: judge whether in addition untreated GUID value, if so, then using next GUID value of current GUID value as current GUID value, return execution step q9, otherwise get the GUID value of loss logical drive.
19. methods according to claim 18, is characterized in that, also comprise between described step q2 and described step q3: obtain the key assignments that current registry entry title is corresponding, judge that whether corresponding key assignments is with preset characters combination beginning, if so, then perform step q6, otherwise perform step q3.
CN201410477986.1A 2014-09-18 2014-09-18 A kind of automatic method for recovering logical drive under windows systems Active 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 true CN104281498A (en) 2015-01-14
CN104281498B CN104281498B (en) 2017-08-11

Family

ID=52256399

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201410477986.1A Active 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)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109491604A (en) * 2018-11-01 2019-03-19 郑州云海信息技术有限公司 A kind of processing method of disk identifier of hard disk replication problem, apparatus and system

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

Cited By (2)

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

Also Published As

Publication number Publication date
CN104281498B (en) 2017-08-11

Similar Documents

Publication Publication Date Title
US9507672B2 (en) Method, apparatus, and system for generating and recovering memory snapshot of virtual machine
CN103970585B (en) Create the method and device of virtual machine
US9767035B2 (en) Pass-through tape access in a disk storage environment
CN103890728B (en) The method of live migration of virtual machine and server
CN107003893A (en) Virtual machine backup method, back-up device and host
US20160117231A1 (en) Complex Network Modeling For Disaster Recovery
CN102214128B (en) Repurposable recovery environment
US20180189371A1 (en) Updating sqlite database
US9996424B2 (en) Splitting a clone having snapshots from a parent
JP2007272881A (en) Method and device for reclaiming space in memory, and computer program
US9792075B1 (en) Systems and methods for synthesizing virtual hard drives
CN104346479A (en) Database synchronization method and database synchronization device
US9239873B2 (en) Process-aware code migration
CN109002330A (en) A kind of method, device and equipment identifying UEFI OS startup item
CN106371763A (en) Snapshot storage method and apparatus, disk and computer
US8788801B2 (en) Backup and recovery of systems by restoring a backup boot configuration data (BCD) with installation files from an operating system install disk
CN108829351B (en) Method for converting MBR disk into GPT disk
CN109683825A (en) A kind of storage system online data compression method, device and equipment
CN106775481B (en) Method for reading data and equipment
US9423973B2 (en) Asynchronous tape backup and restore from tape backup in a disk storage environment
CN102207905A (en) System recovery method, storage media controller and storage system
CN104281498A (en) Method for automatically restoring logical drive in windows system
CN103019847A (en) Method and system for migrating data of virtual machine
CN104268097A (en) Metadata processing method and system
CN104461779A (en) Distributed data storage method, device and system

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