⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 share.pas

📁 FIR引擎最新源码+注册
💻 PAS
字号:
unit Share;

interface
uses
  Windows, Classes, SysUtils, JSocket, RSA, MSI_CPU, MSI_Storage, HumDB, Controls;
const
  MAXSESSION = 2000;

const
  VERDEMO = 0;
  VERFREE = 1;
  VERSTD = 2;
  VEROEM = 3;
  VERPRO = 4;
  VERENT = 5;
  SoftVersion = VERSTD; //程序版本类型
{$IF SoftVersion = VERENT}
  DLLVersion = 98;
{$ELSE}
  DLLVersion = 15;
{$IFEND}
  DEBUG = 0;
  SELFCRC: LongWord = 2190575127; //3937893187
type
  TCheckStatus = (c_Idle, c_Connect, c_Checking, c_CheckError, c_CheckFail, c_CheckOK);
  TCheckStep = (c_None, c_SendClinetKey, c_SendLicense, c_SendLicense2, c_CheckOver);
  TSessionStatus = (s_NoUse, s_Used, s_GetLic, s_SendLic, s_Finished);

  TClientInfo = packed record
    btSoftType: Byte; //1    1=企业M2Server 2=英雄M2Server 3=全部通过
    nSoftVersion: Integer; //4    主程序版本号
    nIniRegIP: Integer; //4    在INI中填写的Reg IP
    nServerKey: Integer; //验证服务器的序列号
    sSerialNumber: string[32];
    nParam1: Integer; //4    保留以后用
    sParam2: string[15]; //保留以后用
    nUsrEngnRunAddr: Integer;
    nObjBaseRunAddr: Integer;
  end;

  TUserLicense = packed record
    btSoftType: Byte; //1    1=企业M2Server 2=英雄M2Server 3=全部通过
    nSoftVersion: Integer; //4    主程序版本号
    nServerKey: Integer; //验证服务器的序列号
    btMode: Byte;
    nUserCount: Integer; //用户数
    nCount: Integer; //授权剩余天数 //授权剩余次数
    nUsrEngnRunAddr: Integer;
    nObjBaseRunAddr: Integer;
    nIniRegIP: Integer; //4    在INI中填写的Reg IP
    nParam1: Integer; //4    保留以后用
    sParam2: string[15]; //保留以后用
  end;









  TXORItem = packed record
    btSoftType: Byte; //1    1=M2Server 2=RunGate 3=DBServer
    nSoftVersion: Integer; //4    主程序版本号
    nIniRegIP: Integer; //4    在INI中填写的Reg IP
    nServerKey: Integer; //验证服务器的序列号
    nParam1: Integer; //4    保留以后用
    sParam2: string[15]; //保留以后用
  end;
  TXORRecord = packed record
    XORKey: Integer; //重要字段,用来判断是否是我们的验证服务器
    XORItemLen: Integer;
    XORItem: string[33]; //长度和 TXORItem一样长
  end;
  TRSARecord = packed record
    RSAKey: Int64;
    RSAItemLen: Integer;
    RSAItem: TInt64Item; //保存TXORRecord RSA加密后的结果
  end;
  pRSARecord = ^TRSARecord;

  TUserLicenseEx = packed record
    UserLicese: TUserLicense; //兼容RSA加密前的版本
    RSARecord: TRSARecord; //RSA加密
  end;

  TIPaddr = record
    A: Byte;
    b: Byte;
    c: Byte;
    D: Byte;
    Port: Integer;
  end;

  TLoginGateInfo = record
    Socket: TCustomWinSocket;
    sIPaddr: string;
    nPort: Integer;
    sReceiveMsg: string;
    nSuccesCount: Integer;
    nFailCount: Integer;
    UserList: TList;
    dwKeepAliveTick: LongWord;
  end;
  pTLoginGateInfo = ^TLoginGateInfo;

  TSession = record
    Socket: TCustomWinSocket;
    sReviceMsg: string;
    nRemoteAddr: Integer;
    dwStartTick: LongWord;
    CheckStep: TCheckStep;
    UserLicense: TUserLicense;
    CodeBuff: PChar;
    nCodeLen: Integer;
    nLicDays: Integer; //授权剩余天数
    nUserCount: Integer; //用户数
    Status: TSessionStatus; //检查授权
    dwSendLicTick: LongWord;
    dwClientTick: LongWord;
    dwServerTick: LongWord;
  end;
  pTSession = ^TSession;

  TSuperSession = record
    sAccount: string;
    sPassword: string;
    nUserQQ: Integer;
    boLogined: Boolean;
    boLockLogined: Boolean;
  end;
  pTSuperSession = ^TSuperSession;

  TUserSession = record
    sAccount: string[32];
    sPassword: string[32];
    sSerialNumber: string[32];
    btBind: Byte;
    nUserQQ: Integer;
    btMode: Byte;
    btPermission: Byte;
    btMainVersion: Byte; //引擎版本
    nUserIPaddr: Integer;
    nUserCount: Integer; //用户数
    nLicCount: Integer; //授权剩余次数
    dStartDate: TDateTime; //开始时间
    dEndDate: TDateTime; //结束时间
  end;
  pTUserSession = ^TUserSession;

  TM2UserInfo = record
    Socket: TCustomWinSocket;
    sUserIPaddr: string;
    sGateIPaddr: string; //用户连接到网关,网关的连接IP
    sSockIndex: string;
    sReceiveMsg: string;
    sSerialNumber: string;
    nRemoteAddr: Integer;
    dwStartTick: LongWord;
    btSoftType: Byte;
    btBind: Byte;
    btMode: Byte;
    nLicDays: Integer; //授权剩余天数
    nUserCount: Integer; //用户数
    nLicCount: Integer; //授权剩余次数
    dwClientTick: LongWord;
    btPermission: Byte; //权限
    dStartDate: TDateTime; //开始时间
    dEndDate: TDateTime; //结束时间
    nMainVersion: Integer; //引擎版本
    dLoginDate: TDate;
    boKick: Boolean;
    dwKickTick: LongWord;
    SuperSession: TSuperSession;
    Gate: pTLoginGateInfo;
  end;
  pTM2UserInfo = ^TM2UserInfo;

  TConfig = record
    sGateIPaddr: string[30];
    boShowDetailMsg: Boolean;
    GateCriticalSection: TRTLCriticalSection;
    dwProcessGateTick: LongWord;
    dwProcessGateTime: LongWord;
    GateList: TList;
  end;
  pTConfig = ^TConfig;

function GetDiskSerialNumber: string;
function GetCPUSerialNumber: string;
function MakeIPToStr(IPAddr: TIPaddr): string;
function MakeIPToInt(sIPaddr: string): Integer;
function MakeIntToIP(nIPaddr: Integer): string;
var
  nLocalXORKey: Integer; //本地XOR Key
  nRemoteXORKey: Integer;

  n4ADAE4: Integer;
  n4ADAE8: Integer;
  n4ADAF0: Integer;
  n4ADAEC: Integer;
  HumDB_CS: TRTLCriticalSection;
  g_Config: pTConfig;

implementation

uses HUtil32;
function MakeIntToIP(nIPaddr: Integer): string;
var
  IPAddr: TIPaddr;
begin
  FillChar(IPAddr, SizeOf(TIPaddr), 0);
  IPAddr.A := LoByte(LoWord(nIPaddr));
  IPAddr.b := HiByte(LoWord(nIPaddr));
  IPAddr.c := LoByte(HiWord(nIPaddr));
  IPAddr.D := HiByte(HiWord(nIPaddr));
  Result := MakeIPToStr(IPAddr);
end;

function MakeIPToStr(IPAddr: TIPaddr): string;
begin
  Result := IntToStr(IPAddr.A) + '.' + IntToStr(IPAddr.b) + '.' + IntToStr(IPAddr.c) + '.' + IntToStr(IPAddr.D);
end;

function MakeIPToInt(sIPaddr: string): Integer;
var
  sA, sB, SC, sD: string;
  A, b, c, D: Byte;
begin
  Result := -1;
  sIPaddr := Trim(GetValidStr3(sIPaddr, sA, ['.']));
  sIPaddr := Trim(GetValidStr3(sIPaddr, sB, ['.']));
  sD := Trim(GetValidStr3(sIPaddr, SC, ['.']));
  if (sA <> '') and (sB <> '') and (SC <> '') and (sD <> '') then begin
    A := Str_ToInt(sA, 0);
    b := Str_ToInt(sB, 0);
    c := Str_ToInt(SC, 0);
    D := Str_ToInt(sD, 0);
    Result := MakeLong(MakeWord(A, b), MakeWord(c, D));
  end;
end;

function GetDiskSerialNumber: string;
var
  Storage: TStorage;
begin
  Result := '';
  Storage := TStorage.Create;
  Storage.GetInfo;
  if Storage.DeviceCount > 0 then begin
    Result := Storage.Devices[0].SerialNumber;
  end;
  Storage.Free;
end;

function GetCPUSerialNumber: string;
var
  CPU: TCPU;
begin
  CPU := TCPU.Create;
  CPU.GetInfo();
  Result := CPU.SerialNumber;
  CPU.Free;
end;

end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -