You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

109 lines
2.7 KiB
C++

#include "StdAfx.h"
#include "EncryptionMgr.h"
#include "LogMgr.h"
#include "MsgBox.h"
#include "winioctl.h"
#include "WarningMgr.h"
#pragma comment( lib, "KernelMode.lib")
CKernelMode gKernelMode;
#define LEFT_DAYS_ALAM 10 //剩余几天提示
CEncryptionMgr *gEncryptionMgr = new CEncryptionMgr;
CEncryptionMgr::CEncryptionMgr(void)
{
m_LeftDays = 0;//剩余的天数
m_bRunAtNoteBook = false;//是否在笔记本上运行
}
CEncryptionMgr::~CEncryptionMgr(void)
{
}
void CEncryptionMgr::OnAppInitialize()
{
m_CurHardDiskSerialNum = GetHardDiskSerialNum();
set<CString> NoteBookHardDiskSerialSet;
NoteBookHardDiskSerialSet.insert("2cc413dd");//k2450 笔记本
NoteBookHardDiskSerialSet.insert("4a410fe7");//t420 笔记本
NoteBookHardDiskSerialSet.insert("ebfac14d");//T460S 笔记本
NoteBookHardDiskSerialSet.insert("d8affd1b");//实验平台
NoteBookHardDiskSerialSet.insert("6c83a0a8");//小米notebook
//NoteBookHardDiskSerialSet.insert("600451aa");//实验平台
//笔记本
if(NoteBookHardDiskSerialSet.count(m_CurHardDiskSerialNum))
{
m_bRunAtNoteBook = true;
}
}
//获取硬盘序列号(C盘所在硬盘)
CString CEncryptionMgr::GetHardDiskSerialNum()
{
CString id;
char Name[MAX_PATH];
DWORD serno;
DWORD length;
DWORD FileFlag;
char FileName[MAX_PATH];
BOOL Ret;
Ret = GetVolumeInformation("c:\\", Name, MAX_PATH, &serno, &length, &FileFlag, FileName, MAX_PATH);
if (Ret)
id.Format( "%x", serno);
return id;
}
#if 1
/*
code:530001 设备上没有发现加密狗
code:530002 读取Binary文件错误
code:530003 Binary文件ID和加密狗ID不匹配
code:530004 年份过期
code:530005 月份过期
code:530006 天过期
code:530007 磁盘驱动器序列号不匹配
*/
//检查锁定状态(锁定返回false)
bool CEncryptionMgr::CheckLockState()
{
return true;
#ifndef __USE_SUPER_DOG__
return true;
#endif
//笔记本
if(m_bRunAtNoteBook)
{
return true;
}
int code = gKernelMode.CheckState();
//到期时间还剩n 天
if(code>100 && code<=(100+LEFT_DAYS_ALAM))
{
m_LeftDays = code-100;
}
else if(code==0 || code>(100+LEFT_DAYS_ALAM))
{
m_LeftDays = 0;//剩余的天数
}
else if(code>0 && code!=7)//其他错误(不要检查磁盘序列号)
{
m_LeftDays = 0;//剩余的天数
CString AddInfo;
AddInfo.Format(_T("使用授权异常(code :53000%d)"),code);
gWarningMgr->SendWarningMsg(_Warning_Code_14,AddInfo);
return false;
}
//检查剩余的天数(10 天以内提示警告)
CheckLeftDays();
return true;
}
//检查剩余的天数(10 天以内提示警告)
void CEncryptionMgr::CheckLeftDays()
{
}
#endif