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

📄 show.cpp

📁 防盗版软件的原理
💻 CPP
字号:
// show.cpp : Defines the class behaviors for the application.
//

#include "stdafx.h"
#include "show.h"

#include "MainFrm.h"
#include "showDoc.h"
#include "showView.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
BOOL ok=false;
/////////////////////////////////////////////////////////////////////////////
// CShowApp

BEGIN_MESSAGE_MAP(CShowApp, CWinApp)
	//{{AFX_MSG_MAP(CShowApp)
	ON_COMMAND(ID_APP_ABOUT, OnAppAbout)
	ON_COMMAND(ID_reg, Onreg)
	//}}AFX_MSG_MAP
	// Standard file based document commands

	ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew)
	ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen)
	// Standard print setup command
	ON_COMMAND(ID_FILE_PRINT_SETUP, CWinApp::OnFilePrintSetup)
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CShowApp construction

CShowApp::CShowApp()
{
	// TODO: add construction code here,
	// Place all significant initialization in InitInstance
}

/////////////////////////////////////////////////////////////////////////////
// The one and only CShowApp object

CShowApp theApp;

/////////////////////////////////////////////////////////////////////////////
// CShowApp initialization

BOOL CShowApp::InitInstance()
{
	AfxEnableControlContainer();

	// Standard initialization
	// If you are not using these features and wish to reduce the size
	//  of your final executable, you should remove from the following
	//  the specific initialization routines you do not need.

#ifdef _AFXDLL
	Enable3dControls();			// Call this when using MFC in a shared DLL
#else
	Enable3dControlsStatic();	// Call this when linking to MFC statically
#endif

	// Change the registry key under which our settings are stored.
	// TODO: You should modify this string to be something appropriate
	// such as the name of your company or organization.
	SetRegistryKey(_T("Local AppWizard-Generated Applications"));

	LoadStdProfileSettings();  // Load standard INI file options (including MRU)

	// Register the application's document templates.  Document templates
	//  serve as the connection between documents, frame windows and views.

	CSingleDocTemplate* pDocTemplate;
	pDocTemplate = new CSingleDocTemplate(
		IDR_MAINFRAME,
		RUNTIME_CLASS(CShowDoc),
		RUNTIME_CLASS(CMainFrame),       // main SDI frame window
		RUNTIME_CLASS(CShowView));
	AddDocTemplate(pDocTemplate);

	// Parse command line for standard shell commands, DDE, file open
	CCommandLineInfo cmdInfo;
	ParseCommandLine(cmdInfo);

	// Dispatch commands specified on the command line
	if (!ProcessShellCommand(cmdInfo))
		return FALSE;

	// The one and only window has been initialized, so show and update it.
	m_pMainWnd->ShowWindow(SW_SHOW);
	m_pMainWnd->UpdateWindow();
    SetWindowText(GetForegroundWindow(),"show v1.0 (试用版)");
	return TRUE;
}


/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App About

class CAboutDlg : public CDialog
{
public:
	CAboutDlg();

// Dialog Data
	//{{AFX_DATA(CAboutDlg)
	enum { IDD = IDD_ABOUTBOX };
	//}}AFX_DATA

	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CAboutDlg)
	protected:
	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
	//}}AFX_VIRTUAL

// Implementation
protected:
	//{{AFX_MSG(CAboutDlg)
		// No message handlers
	//}}AFX_MSG
	DECLARE_MESSAGE_MAP()
};

CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
	//{{AFX_DATA_INIT(CAboutDlg)
	//}}AFX_DATA_INIT
}

void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CAboutDlg)
	//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
	//{{AFX_MSG_MAP(CAboutDlg)
		// No message handlers
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

// App command to run the dialog
void CShowApp::OnAppAbout()
{
	CAboutDlg aboutDlg;
	aboutDlg.DoModal();
}

/////////////////////////////////////////////////////////////////////////////
// CShowApp message handlers

/////////////////////////////////////////////////////////////////////////////
// reg dialog


reg::reg(CWnd* pParent /*=NULL*/)
	: CDialog(reg::IDD, pParent)
{
	//{{AFX_DATA_INIT(reg)
	m_info = 0;
	m_code = _T("");
	//}}AFX_DATA_INIT
}


void reg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(reg)
	DDX_Text(pDX, IDC_EDIT1, m_info);
	DDX_Text(pDX, IDC_EDIT2, m_code);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(reg, CDialog)
	//{{AFX_MSG_MAP(reg)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// reg message handlers



void CShowApp::Onreg() 
{
	// TODO: Add your command handler code here
	reg regbox;
	regbox.DoModal();
    if(ok)SetWindowText(GetForegroundWindow(),"show v1.0 (注册版)");

	//AFX_IDS_APP_TITLE="show reg";
}

BOOL reg::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	DWORD dwIDESerial;
	GetVolumeInformation("c:\\",NULL,NULL,&dwIDESerial,NULL,NULL,NULL,NULL); 
    m_info=dwIDESerial;
    UpdateData(FALSE);
	
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

void reg::OnOK() 
{
	// TODO: Add extra validation here
    UpdateData(TRUE);
    if(m_code.GetLength()<16)
	{
		AfxMessageBox( "注册码错误!",MB_OK,0 );
		ok=false;
	    return;
	}
    
	int I;
	int A=0x01234567,B=0x89abcdef,C=0xfedcba98,D=0x76543210;
	int a,b,c,d;
	a=A;b=B;c=C;d=D;
	int input[16];
	char result[17]="";
	int Mask[16]={1,2,3,5,7,11,13,17,19,23,29,31,37,41,43,47};
 
  for(I=0;I<16;I++) //第一步,生成12个整数
  {
  input[I]=m_info/Mask[I];
  //input[I]=input[I]%37; 
  }
 
  for(I=0;I<4;I++) //第二步,经过简化的MD5加密算法
  {
    a =b+((a+((b&c)|((~b)&d)+input[I*4+0]+0xd76aa478))<<7);//第一轮
    d =a+((d+((a&b)|((~a)&c)+input[I*4+1]+0xe8c7b756))<<12);	
	c =d+((c+((d&a)|((~d)&b)+input[I*4+2]+0x242070db))<<17);
    b =c+((b+((c&d)|((~c)&a)+input[I*4+3]+0xc1bdceee))<<22);	
//FF(a,b,c,d,M0,7,0xd76aa478)
//FF(d,a,b,c,M1,12,0xe8c7b756)
//FF(c,d,a,b,M2,17,0x242070db)
//FF(b,c,d,a,M3,22,0xc1bdceee)

	a=b+((a+((b&d)|(c&(~d))+input[I*4+0]+0xf61e2562))<<5);//第二轮
	d=a+((d+((a&c)|(b&(~c))+input[I*4+1]+0xc040b340))<<9);
	c=d+((c+((d&b)|(a&(~b))+input[I*4+2]+0x265e5a51))<<14);
	b=c+((b+((c&a)|(d&(~a))+input[I*4+3]+0xe9b6c7aa))<<20);
//GG(a,b,c,d,M1,5,0xf61e2562)
//GG(d,a,b,c,M6,9,0xc040b340)
//GG(c,d,a,b,M11,14,0x265e5a51)
//GG(b,c,d,a,M0,20,0xe9b6c7aa)

    a=b+((a+(b^c^d+input[I*4+0]+0xfffa3942))<<4);//第三轮
    d=a+((d+(a^b^c+input[I*4+1]+0x8771f681))<<11);
	c=d+((c+(d^a^b+input[I*4+2]+0x6d9d6122))<<16);
	b=c+((b+(c^d^a+input[I*4+3]+0xfde5380c))<<23);
//HH(a,b,c,d,M5,4,0xfffa3942)
//HH(d,a,b,c,M8,11,0x8771f681)
//HH(c,d,a,b,M11,16,0x6d9d6122)
//HH(b,c,d,a,M14,23,0xfde5380c)

    a=b+((a+(c^(b|(~d))+input[I*4+0]+0xf4292244))<<6);//第四轮
    d=a+((d+(b^(a|(~c))+input[I*4+1]+0x432aff97))<<10);
	c=d+((c+(a^(d|(~b))+input[I*4+2]+0xab9423a7))<<15);
	b=c+((b+(d^(c|(~a))+input[I*4+3]+0xfc93a039))<<21);
//II(a,b,c,d,M0,6,0xf4292244)
//II(d,a,b,c,M7,10,0x432aff97)
//II(c,d,a,b,M14,15,0xab9423a7)
//II(b,c,d,a,M5,21,0xfc93a039)

input[I*4+0]=a;
input[I*4+1]=b;
input[I*4+2]=c;
input[I*4+3]=d;
  }

  for(I=0;I<16;I++) //第三步,转化为0-35的整数
  {
  input[I]=input[I]%36; 
  if(input[I]<0)
  input[I]=-input[I];
  }
	
char words[37]="QW9ER7T0YUI8OP4ASD5FG3HJKL1Z6XCVB2NM";  
//char user[17];
int Index[16]={15,6,12,4,11,2,7,0,10,13,3,9,8,5,14,1};
int com[16];
 int n; 
 int uinput[16];


	for(n=0;n<16;n++)
 {
	  for(I=0;I<36;I++)
  {
    if(words[I]== m_code[n])
	{
	uinput[n]=I;
	break;
	}
  }
 }
 
 for(I=0;I<16;I++)//第四步,反错序操作 
  { 

		com[I]=uinput[Index[I]]; 

  }
 ok=true;
  for(I=0;I<16;I++)
{
  if(input[I]!= com[I])
  {
   ok=false;
   break;
  }
}
 if(ok)
 {
  MessageBox( "注册成功!",  "Thank you!",MB_OK );
  CDialog::OnOK();
 }
  else
  {
   AfxMessageBox( "注册码不正确!",MB_OK,0 );
  }

	//ok=true;
	
}

⌨️ 快捷键说明

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