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

📄 mirrobot.cpp

📁 传奇的脱机源代码 非常的好 供大家学习 谢谢
💻 CPP
字号:
// MirRobot.cpp : Defines the class behaviors for the application.
//

#include "stdafx.h"
#include "MirRobot.h"

#include "MainFrm.h"

#include "bindef.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

int UnNameCode( char * in, char * out )
{
	int i = 0;
	//int size = strlen( in );
	while( in[i] != '\0' )
	{
		out[i] = (in[i] & 0x3f ) << 2;
		out[i] |= (in[i + 1] & 0xc0 ) >> 6;
		i ++;
	}
	out[i] = '\0';
	return 1;
}

// 登陆数据包解密函数
int UnGateCode(char *in, char *out)
{
	if(in==NULL)
		return 0;
	int lcnt=strlen(in)>>1;
	if(lcnt==0)
		return 0;
	if(in[0]==(char)0)//'\0' )
		return 0;
	int i=0;
	int icode=0;
	

	int _edi=0xf667;

	for(i=0;i<lcnt;i++)
	{
		out[i]=((hex2int(ucase(in[i*2]))&0xf)<<4);
		out[i]+=hex2int(ucase(in[i*2+1]))&0xf;
		icode=((int)out[i])&0xff;
		out[i]^=((_edi & 0xffff)>>8);
		_edi=(((_edi+icode)* 0xce6d)&0xffff)+0x58bf;
	}
	out[lcnt]=(char)0;//'\0';
	return 1;
}

// 登陆数据包加密函数
int CodeGateCode(char *in, char *out)
{
	int lcnt=strlen(in) ;
	int i=0;
	int icode=0;
	int tcode=0;
	int hbyte=0;
	int lbyte=0;
	int _edi=0xf667;
	for(i=0;i<lcnt;i++)
	{
		icode=((int)in[i])&0xff;
		//tcode = icode;
		//icode = ((int)out[i]) & 0xff;
		tcode=icode;
		tcode^=((_edi&0xffff)>>8);
		hbyte=(tcode&0xf0)>>4;
		lbyte=(tcode&0xf);
		out[i*2]=int2hex(hbyte);
		out[i*2+1]=int2hex(lbyte);
		_edi=(((_edi+tcode)*0xce6d)&0xffff)+0x58bf;
	}
	out[i * 2] = '\0';
	return 1;
}

int UnGameCode(char*p, BYTE*out)
{
	int	i=0;
	int ilen=0,olen=0;
	int	iptr=0,optr=0;
	BYTE * pb=(BYTE*)p;
	BYTE b1,b2,b3,b4;
	if(p==NULL || out==NULL)
		return 0;
	ilen = strlen( p );
	if( ilen <= 0 )
		return 0;
	*((DWORD*)&p[ilen]) = 0x3c3c3c;
	olen = (ilen * 6) / 8;
	for( i =0;i < ((ilen + 3)/4);i ++ )
	{
		b1 = (pb[iptr++] - 0x3c) & 0x3f;
		b2 = (pb[iptr++] - 0x3c) & 0x3f;
		b3 = (pb[iptr++] - 0x3c) & 0x3f;
		b4 = (pb[iptr++] - 0x3c) & 0x3f;
		out[optr++] =(( b1 & b00111111) << 2 )| ((b2 & b00110000) >> 4);
		out[optr++] =(( b2 & b00001111) << 4 )| ((b3 & b00111100) >> 2);
		out[optr++] =(( b3 & b00000011) << 6 )| b4;
	}
	out[olen] = '\0';
	return olen;
}

int CodeGameCode( BYTE * in, int size, BYTE * out )
{
	int i = 0,ilen = 0;
	int idxout = 0;
	int	idxin = 0;
	int reallen = 0;
	ilen = size;
	ilen = (size + 2)/3;
	BYTE	b1,b2,b3;
	reallen = (size  * 8 + 5) / 6;
	
	(*(DWORD*)&in[size])=0;
	for( i = 0;i < ilen;i ++ )
	{

		b1 = in[idxin++];
		b2 = in[idxin++];
		b3 = in[idxin++];
		
		out[idxout++] = ((b1 & b11111100) >> 2)+'<'; 
		out[idxout++] = (((b1 & b00000011) << 4)|((b2 & b11110000) >> 4))+'<';
		out[idxout++] = (((b2 & b00001111) << 2)|((b3 & b11000000) >> 6))+'<';
		out[idxout++] = (b3 & b00111111)+'<';
	}
	out[reallen]= '\0';
	return 1;
}

// Returns a char that has been converted to uppercase.
char ucase(char c)
{
	if(c>='a' && c<='z')
		c+='A'-'a';
	return c;
}

// hex2int
int hex2int(char c)
{
	if(c>='A' && c<='F')
		return(int)(c-'A'+10);
	else if(c>='a' && c<='f')
		return(int)(c-'a'+10);
	else if(c>='0' && c<='9')
		return(int)(c-'0');
	return 0;
}

// int2hex
char int2hex(int v)
{
	char hextable[]="0123456789ABCDEF";
	v &= 0xf;
	return hextable[v];
}

/////////////////////////////////////////////////////////////////////////////
// CMirRobotApp

BEGIN_MESSAGE_MAP(CMirRobotApp, CWinApp)
	//{{AFX_MSG_MAP(CMirRobotApp)
	ON_COMMAND(ID_APP_ABOUT, OnAppAbout)
		// NOTE - the ClassWizard will add and remove mapping macros here.
		//    DO NOT EDIT what you see in these blocks of generated code!
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CMirRobotApp construction

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

/////////////////////////////////////////////////////////////////////////////
// The one and only CMirRobotApp object

CMirRobotApp theApp;

/////////////////////////////////////////////////////////////////////////////
// CMirRobotApp initialization

BOOL CMirRobotApp::InitInstance()
{
	// 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"));


	// To create the main window, this code creates a new frame window
	// object and then sets it as the application's main window object.

	CMainFrame* pFrame = new CMainFrame;
	m_pMainWnd = pFrame;

	// create and load the frame with its resources

	pFrame->LoadFrame(IDR_MAINFRAME,
		WS_OVERLAPPEDWINDOW | FWS_ADDTOTITLE, NULL,
		NULL);




	// The one and only window has been initialized, so show and update it.
	pFrame->ShowWindow(SW_MAXIMIZE);
	pFrame->UpdateWindow();

	return TRUE;
}

/////////////////////////////////////////////////////////////////////////////
// CMirRobotApp message handlers





/////////////////////////////////////////////////////////////////////////////
// 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 CMirRobotApp::OnAppAbout()
{
	CAboutDlg aboutDlg;
	aboutDlg.DoModal();
}

/////////////////////////////////////////////////////////////////////////////
// CMirRobotApp message handlers

⌨️ 快捷键说明

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