Author: Liaoning Tieling Song Libo from: Unknown content: the rapid development of the Internet, open up broader scope for efficient dissemination software. For example, the famous domestic gold spider software download center is a typical release software distribution. Publish sharing software mainly includes two forms: date restriction form and electronic registration form. Date limit form allows users to download software to use software for a while, such as one month, etc., if the user is approved, the software can be purchased to continue to use; the electronic registration form is based on the hardware information of the machine used by the user. And restrict some advanced or common functions in the software. If the user wants to use all of the features, the software collected must be given feedback to the developer, and the software can get the software in the machine. The registration code can usage normally. The previous form is easy to cause the piracy to cause a ride, if the production pirates have purchased a registered serial number and published in the world, all users can use this registration number to make normal use; the latter registration The means is slightly more complicated. It also requires a certain programming trushy for developers, but it has "eight-point lock" function, anti-theft is unquestionable. According to your own practice, this article introduces the latter's implementation process to readers who want to make publication sharing software. First, the registration source is in the protection mode of WIN98 / 95, it is not an easy thing to form the registration code according to hardware information. In the real mode, the hard disk port 1F6H and 1F7H directly read the serial number and other information as registration. The data source, but this method is shown in the protection mode. Using the motherboard serial number in the BIOS, the BIOS version serial number or the host is available, and the registration source can be used as a registration code. If there is information related to the hardware configuration in the ROMBIOS in the ROMBIOS, information such as the hardware configuration can also be acquired as the production base of the registration code. For example, the application's registration code is generated in accordance with the F000H: FFF5H-F000H: The host dates and host flag values stored in FFFH. Since the computer product is updated faster, and the computer used by all users is not the same, the source generated by the registration code will not be exactly the same. Moreover, these hardware information content is exactly the same under any operating system, the compatibility is very good, and the registration function is not invalid because of the update of the operating system. After the registration source is determined, the key issue is how to share the software installer to collect the registration source information and let the user return it to the developer. The simplest method is to store the acquired registration source information to a text, form a data source data for the registration code. This registration source data string can be slightly longer, but it is not advisable to use the user to transfer to the developer through an email, telephone or letter. If the author installer is prepared in C language, if the above memory address is used as a registration source, the data string text file is named keyid.doc, the length is 20 characters.
The sample code is as follows: code: file * fp2; unsigned int keyrom [9]; unsigned char buff [0x410]; unsigned char pathstmp [80]; unsigned char path [80] = {"c: // wbcool"}; unsigned INT FAR * PT = (unsigned int far *) 0xF000FFF6L; ... OUTPORTB (0x21, 0x2); strcpy (pathstmp, path); strcat (pathstmp, "//"); strcat (pathstmp, "keyid. "); For (i = 0; i <5; i ) keyrom [i] = (* (pt i) 0x1818) ^ 0x5858; // First level encryption algorithm sprintf (buff," keyid:% 04x % 04x% 04x% 04x% 04x ", KeyROM [0], Keyrom [1], KeyROM [2], KeyROM [3], KeyROM [4]); buff [0x1a] = 0; if ((fp2 = fopen) Pathstmp, "WB")) == NULL) {Printf ("File% s create Error!", Pathtmp);} else {fseek (fp2,0l, seek_set); fprintf (fp2, "% s / xd / xa" , buff); Fclose (FP2);} OUTPORTB (0x21, 0x0); Second, after the registration machine developer gets the registration source data provided by the user, you need to generate a registration code with the registration machine and return to the user. The registration machine uses the established bit operation and irreversible algorithm to form a string registration code that the user is easier to operate. The length of the registration code is generally 8-16 bits. The user can use it for a long time, so the length of the registration code Will not affect user registration operations. Of course, the algorithm of the registration machine should be basically the same as the algorithm part in the shared software. For remote users, the registration machine should have two functions of the registration source data from the keyboard and memory, so the encryption algorithm of the registration machine is actually two branches: the first branch is directly from the keyboard to obtain the registration source data directly according to the registration algorithm The process of the registration code is directly to the remote user feedback registration code; the second branch is to obtain registration source data directly from the ROM BIOS, and then form a registration code according to the registration algorithm, is to read local Machine registration code. After the user gets the registration code, according to the registration method of the shared release software, the application automatically stores this registration code to the specific location of the software, when the application is copied by others, after the registration code Different machines, so the application's functionality or usage is still limited. To use the application in other machines, it is necessary to re-register to reach the shared software release purpose. At the same time, due to the algorithm and registration code algorithms of registration source data, this method is very reliable. The keyboard input registration source is accepted when the registration machine belt parameters; the registration source data is collected directly from the local machine without any parameters.
My registrar sample program is as follows: Code: #include
// Form the first 4-digit code SUM1 = keyrom [SUMI];} SUM ^ = 0x1234 << Sumj; // Moving Sum1 ^ = 0x7456 << Sumj; Sprintf (Buff 4 * Sumj, "% 04x ", SUM); Sprintf (buff1 4 * sumj,"% 04x ", sum1);} // forms 16-bit registration code printf (" / nwin-key: "); Printf (BUFF); Printf (" / NDOS -Key: "); Printf (buff1); exit (1);} else {SUM = 0x1234; Sum1 = 0x7456; for (sumj = 0; sumj <4; sumj ) {// forming 16-bit registration code for (SUMI = 0; SUMI <5; SUMI ) {SUM = (* (PT SUMI) 0x1818) ^ 0x5858; Sum1 = (* (PT SUMI) 0x1818) ^ 0x5858;} SUM ^ = 0x1234 <} Sum ^ = 0x7456 << Sumj; // Different or processed Sprintf (buff 4 * Sumj, "% 04x", SUM); Sprintf (buff1 4 * sumj, "% 04x", sum1);} printf "/ nwin-key:"); Printf (BUFF); Printf ("/ ndos-key:"); Printf (buff1);}} 3, the registration code is written to the sharing software after the user is registered The corresponding position. At this time, the shared software must perform real-time detection and judgment on the user registration code to implement the registration restriction function. At this time, the shared software must be obtained internally to obtain the registration source data, and the same algorithm is generated in the registration. This requires sharing software to directly read the registration source information of the ROM BIOS, and increase the registration code detection judgment function at need restrictions in sharing software, which requires the difficulty of software size and implementation based on the actual needs of sharing software. Determine the number of restrictions, making the piracy difficult to decrypt. This makes both multiple shared software in the computer use the same registration source, and does not have a registered conflict problem; both the same registration source data is used, which will not be the same as the different registration code of the registration algorithm; even if the decryptient knows The registration source address of the registration algorithm is hard to piracy because the registration algorithm is not known and the registration point is spread throughout the entire sharing software. Therefore, this registration method enables sharing software to effectively across a variety of system platforms. To generate a registration code inside the shared software, you must read the ROM BIOS data source memory data in the shared software.
In Windows Protection Mode, you must use the function provided by segment selectors and API programming interfaces to implement: 1.allocselector (selector) Assign a selection of empty selector 2.FreselectElector (selector) with the same parametelector 3.SetSelectorBase ( ) Setting the selector descriptor physical start address 4.getSelectorBase () Get Selector Descriptor Physical Start Address 5.setSelectorLimit () Settings Selector Descriptor Access Boundary 6.getSelectorLimit () Get Selector Descriptor Access Boundell AllocSelector (selector) is the key to physical memory access in the protection mode. After the end of the unit, use the globalfree () release the allocated memory. The easiest way is to direct the system's data segment register __ds as a template parameter, which is fully used in the general application. Then use the setSelectorBase () and setSelectorLimit () functions separately set the physical starting address and access boundary value, using normal pointer operation * Pt = value and value = * Pt access physical memory unit, you must use freeselector () after access is completed. The function releases the allocated selector because Windows does not automatically release the unwanted selector, and the system selector sharing resources are very limited, only 8192 for use.
According to the above principle and registration source and registration code algorithm in the registration machine, it is not difficult to implement the internal registration code function of shared software: code: uint IMECMPKEY (VOID) {// Shared software internal registration code generating function static unsigned int sum; static bool Flag; Static UNT SEL1, SEL2; Static Word SEG, OFF, START; Static DWORD BAS, LIM; FLAG = true; SUM = 0x1234; __ASM MOV SEL1, DS; // Put DS as Template SEL2 = AllocSelector (sel1); // Assign a new selector if (SEL2 == NULL) {flag = false; pt = (unsigned int far *) 0xF000FFF0L;} else {seg = 0xfffff; // absolute address segment OFF = 0x10; // absolute address offset start = 0x0; BAS = ((unsigned long) seg) << 4 | start; limited; setSelectorBase (SEL2, BAS); SetSelectorLimit (SEL2, LIM) Pt = (unsigned int far *) ((unsigned long) << 16) | start);} for (j = 0; j <4; j ) {// form 16 registration code for (i = 0; i <5; i ) SUM = (* (PT 3 I) 0x1818) ^ 0x5858; // Form the first 4 bit SUM ^ = 0x1234 << j; // Perform shift or processed WSPrintf (LPSTR) SIMEG.IMEKEY 4 * J, (LPSTR) "% 04x", SUM;} if (flag == true) freeselector (sel2); SIMEG.IMEKEY [16] = 0; // The registration code itself encryption For (i = 16; I> 0; I - SIMEG.IMEKEY [16-I] ^ = (unsigned char) i; for (i = 0; i <16; i ) {// judgment registration code IF ( Simeg.imekey [i]! = lpimel-> zcmyok [i]) Break;} if (i == 16) {Simeg.zcflag = false; simeg.zccount = 0x0; lpimel-> @UM = 0x0; for (i = 0; I <16; i ) SIMEG.IMEKEY [I] = 0x0; return (0);} else {simeg.zcflag = true; Simeg.zccount = 0x0; Simeg.isel = 1; Simeg.FSCRCZ = true; lstrcpy (Simeg.szsel [0], (LPSTR) "Registration: _________________");
SIMEG.SZSEL [0] [6] = 0x11; Simeg.szsel [0] [23] = 0x0; updateinList (); return (~ 0);}} four, registration point sharing software internal registration code, need to confront How much of pirated registration points depends on many factors such as the own value of sharing software, the developer's encryption depth and software implementation complexity, etc., which also determines the display frequency of registration prompt information, and can be used for legal use. However, as far as the author himself, at least the shared software should be achieved, and the registration point is adopted by the user welcoming and universally used. It is recommended that the registration code between different platforms should be design registration algorithm and registration code respectively. Its code examples are now, for example: code: Registration point one: if (lpimel-> @UM> = 0x3f80) {if (IMECMPKEY () == ~ 0) {Simeg.zcflag = true;} else {Simeg.zcflag = false; lpimel >}}}} Else lpimel->}} else lpimel->}} Else Lpimel->}} = SIMEG.IWORD; Register Point 2: IF (IMECmpKey () == ~ 0) {Simeg.zcflag = true; return;} else {Simeg.zcflag = false; lpimel -> usenum = 0x0;} 5. Registration port For sharing software, no matter what function is implemented, it is best to take a back-line registration method, which can reduce the user's repetitive operations. At the same time, multiple registration portals should be taken. If the software can be registered while increasing or deleting the phrase, as long as a registration successful software is successful, and pay attention to the registration code input by the registration port.
The registered port code sample code in the author sharing software is as follows: code: if (Simeg.zcflag == True) {IF ((ccharcode == 0x8) || (ccharcode == 0x4b) {if (Simeg.zccount> 0) { // Delete button processing IF (Simeg.zccount <17) Simeg.szsel [0] [Simeg.zccount 6] = 0x5f; Else Simeg.szsel [0] [Simeg.zccount 6] = 0x0; Simeg.zccount- -; simeg.szsel [0] [Simeg.zccount 6] = 0x11; lpimel-> zcmyok [Simeg.zccount] = 0x0; Simeg.isel = 0x1; Simeg.FSCRCZ = true; UpdateInList ();} else messagebeep -1);} else if (ccharcode == 0xD) {// Enter key processing if (Simeg.zccount == 0x10) {Simeg.zcFlag = false; Simeg.zccount = 0x0; SIMEG.ISEL = 0x0; ScrNCode Simeg.istart); simeg.fscrcz = true; updateinList (); for (i = 16; i> 0; i -) lpimel-> zcmyok [16-i] ^ = (unsigned char) i; lpimel-> zcmyok [16] = 0; for (i = 0; i <16; i ) {if (Simeg.Imey [i]! = Lpimel-> zcmyok [i]) Break;} if (i == 16) {//// Write registration code For (i = 0; i <16; i ) SIMEG.IMEKEY [I] = 0x0; J = GetSystemDirectory (FileName, 80); IF ((j == 0) || (J> 64)) {WSPRINTF LPSTR) SIMEG.IMEBUFF, (LPSTR) "System path illegal!"); ErrMessageBox ((lpstr) Simeg.imeBuff); for (i = 0; i <16; i ) lpimel-> zcmyok [i] = 0x0; showmessts (8);} else {lstrcat (filename, (lpstr) "//"); lstrcat (filename, (lpstr) "wbcool.ime"); if ((htmp = _lopen (filename, read_write)) ==