87 lines
2.5 KiB
C++
87 lines
2.5 KiB
C++
#ifndef _AUTHORITY_WINDOWS_H
|
|
#define _AUTHORITY_WINDOWS_H
|
|
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
#ifdef WIN32
|
|
#define DC_ROOT_KEY HKEY_CURRENT_USER
|
|
#define DC_HIGH_DEEPCAM_AUTHORITY "SOFTWARE\\HighDeepCamS"
|
|
#define DC_KEY_VALUE_NAME "AuthorityKey"
|
|
#define DC_XD_FRDLL_AUTHORITY_TIME "SOFTWARE\\XdFrInfo"
|
|
#define DC_AUTH_TIME_VALUE_NAME "AuthorityTime"
|
|
#define DC_XD_FRDLL_LASTUSED_TIME "SOFTWARE\\SweepXd"
|
|
#define DC_LAST_TIME_VALUE_NAME "AuthorityTime"
|
|
|
|
#define DC_AES_CRYPTCODE "DeepCamCryptCode" //16 bytes lenth (128 bits)
|
|
#define DC_AES_LEN_IN_BITS 128
|
|
|
|
#define DC_OfficialVersion_YEAR 2099
|
|
#define DC_OfficialVersion_FLAG "Official_Version"//16Bytes
|
|
#include <windows.h>
|
|
|
|
|
|
class RegMgr
|
|
{
|
|
public:
|
|
static RegMgr* GetInstance();
|
|
bool IsKeyExists(HKEY hRootKey, char* strKey);
|
|
HKEY OpenKey(HKEY hRootKey, char* strKey);
|
|
|
|
long SetDwordVal(HKEY hKey, char* lpValueName, DWORD dwValue);
|
|
long GetDwordVal(HKEY hKey, char* lpValueName, DWORD& dwVale);
|
|
long SetStrVal(HKEY hKey, char* lpValueName, char * strValue);
|
|
long GetStrVal(HKEY hKey, char* lpValueName, char * strValue, DWORD strLen);
|
|
|
|
long SetAuthorityKey(char * strAuthKey);
|
|
long GetAuthorityKey(char * strAuthKey, DWORD strLen);
|
|
|
|
long SetAuthorityByTimeStr(char * strAuthTime);
|
|
long SetAuthorityTime();
|
|
long GetAuthorityTime(time_t & authTime);
|
|
|
|
long SetLastUsedTime();
|
|
long GetLastUsedTime(time_t & usedTime);
|
|
long DeleteAllUsedKeys();
|
|
private:
|
|
static RegMgr* m_instance;
|
|
};
|
|
#endif
|
|
|
|
|
|
class Authority {
|
|
struct Mac_Key
|
|
{
|
|
std::string _Mac;
|
|
std::string _MacKey;
|
|
};
|
|
|
|
struct AuthorizeConfigs
|
|
{
|
|
std::string _Type; //1:Local without Mac 2:Local with Macs 3:Network
|
|
std::string _LimitTime;
|
|
std::string _PackageName;
|
|
std::string _AuthorizeKey;
|
|
std::string _ToolKey; //5th line of Key file.(When _Type "2")
|
|
std::vector<Mac_Key> _MacKeys; //6th-End lines of Key file.(When _Type "2")
|
|
std::string _ActivateUrl; //5th line of Key file.(When _Type "3")
|
|
std::string _ActivateLocalCipher; //6th line of Key file.(When _Type "3")
|
|
};
|
|
|
|
public:
|
|
static Authority* GetInstance();
|
|
|
|
|
|
bool CheckAuthority();
|
|
bool EnumFilesForConfigs(AuthorizeConfigs & configs); //ö¾ÙËùÓеÄÊÚȨÎļþ
|
|
|
|
long EncryptString(char * strSrc, char * strEncrypted);
|
|
long DecryptString(char * strSrc, char * strDecrypted);
|
|
|
|
std::string GetCurrDir();
|
|
bool FindAllFilesInPath(std::string strPath, std::vector<std::string> & fileList, std::vector<std::string> & suffixFilters);
|
|
private:
|
|
static Authority* m_instance;
|
|
};
|
|
|
|
#endif _AUTHORITY_WINDOWS_H |