How to use VC restriction software trial number

zhaozj2021-02-17  46

There are many ways to limit the number of software trials. The key is where the number of times is stored. Here, a method is introduced to limit the number of figures by changing the time of the file, thereby limiting the trial of the software.

First, limit the number of software trials by changing the file time

In MS-DOS, the time of the file is saved by a 16-bit value. Bits 15 to 11 are used to save the hour number, and the bits 10 to 5 are used to save the number of minutes, and the bits 4 ~ 0 are used to save the second number. . This 16-bit value is prior to use us to save the number of trials. For example, in the sample program below, the author uses the number of saved number of minutes. Run the instruction routine, we can see that the number of minutes of the file time is added 1, and the average person is difficult to detect. This method has a better concealment.

Second, the interrupt involved in the sample program

1. Interrupt 21h function 3DH

Uses: Open files for reading. Write or make up.

Call register: AH = 3DH, Al = 00H, DS: DX = file name;

Return Register: CF Reset - Success, AX = File Handle.

CF set - error, ax = error code.

2. Interrupt features of 21h 3EH

Uses: Forced to remove all buffers, update the directory, make the file handle invalid.

Call register: AH = 3EH, bx = file handle;

Return Register: CF Reset - Success, AX is destroyed,

CF set - error, ax = error code.

3. The function of the interrupt 21h is 57h, the subfunction 00h

Uses: The date and time of the read file is finally modified.

Call register: AX = 5700h, bx = file handle;

Return Register: CF Reset - Success, CX = File Time, DX = File Date,

CF set - error, ax = error code.

4. The function of the interrupt 21h 57h, sub function 01h

Uses: The date and time information that will last modified by the file becomes the specified value.

Call register: AX = 5701H, bx = file handle, CX = new time, DX = new date;

Return Register: CF Reset - Success,

CF set - error, ax = error code.

Third, sample program

#include

#include

#include

Int count ()

{

Union Regs INREGS, OUTREGS

Strut Sregs Segs;

UNSIGNED HANDLE;

Unsigned Times;

/ * open a file * /

INREGS.H.AH = 0x3d;

INREGS.H.AL = 0;

SCGREAD (& segs);

INREGS.X.DX = "Test.exe";

INTDDOSX (& INREGS, & OUTREGS, & SEGS);

IF (outregs.x.cflag) return (0);

Else

{

/ * Read file dates and time * /

Handle = OUTREGS.X.AX;

INREGS.X.AX = 0x5700;

INREGS.X.BX = HANDLE;

INTDDOSX (& INREGS, & OUTREGS, & SEGS);

Times = (outregs.x.cx & 0x7e0)>> 5; if (Times <40) / * Trial number can be implemented by changing the '40' here * /

{

INREGS.X.AX = 0x5701;

INREGS.X.BX = HANDLE;

INREGS.X.CX = OUTREGS.X.CX 0x20; / * Trial number count * /

INREGS.X.DX = OUTREGS.X.DX;

INTDDOSX (& INREGS, & OUTREGS, & segs); / * Reset Date * /

Return (2);

}

Else Return (1);

/ * Close the file * /

INREGS.H.AH = 0x3e;

INREGS.X.BX = HANDLE;

INTDDOSX (& INREGS, & OUTREGS, & SEGS);

}

}

Main ()

{

Int flag;

Flag = count ();

IF (Flag == 0) Printf ("This software is a trial version, please do not modify! / n");

IF (Flag == 1) Printf ("This software is a trial version, your trial is full! / n");

IF (Flag == 2) Printf ("This software is a trial version, welcome trial! / n");

转载请注明原文地址:https://www.9cbs.com/read-28770.html

New Post(0)