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

📄 jgsview.cpp

📁 激光加工控制系统 可以读入plt文件
💻 CPP
字号:
// jgsView.cpp : implementation of the CJgsView class
//

#include "stdafx.h"
#include "jgs.h"

#include "jgsDoc.h"
#include "jgsView.h"

#include "maindlg.h"
#include "process.h"
#include "geniusdog.h"

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


int quit_flag;

int error_flag;
int flag = 0;
unsigned long  SerialNumber=772233;	
unsigned long  UserKey=1704046040;			
unsigned long  i,RetCode;
unsigned char result1[16],result2[16],randomdata[16];
BOOL  b1 = FALSE;
char mz[100];
void * InDogData;
void * OutDogData;

unsigned long  CreateRandom(void);    
unsigned long  GetCurrentNumber(void);
unsigned long  Encrypt(void);        
unsigned long  Decrypt(void);       
void Write1(); 
void Read1();

/////////////////////////////////////////////////////////////////////////////
// CJgsView

IMPLEMENT_DYNCREATE(CJgsView, CView)

BEGIN_MESSAGE_MAP(CJgsView, CView)
	//{{AFX_MSG_MAP(CJgsView)
		// 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()

/////////////////////////////////////////////////////////////////////////////
// CJgsView construction/destruction

CJgsView::CJgsView()
{
	// TODO: add construction code here
			int sn;
			int Retcode;
			char buf[20];

			_asm {
				mov dx,0x37a
				mov al,0
				out dx,al
            }
			strcpy(mz,"asdkghadjksgasdg");
			quit_flag = 0;
		    Write1();
			strcpy(mz,"asdkghagasdg");
		    Read1();
			error_flag = 0;
            if (strcmp(mz,"asdkghadjksgasdg") != 0){
				error_flag = 1;
			}
			_asm {
				mov dx,0x37a
				mov al,0
				out dx,al
            }
}

CJgsView::~CJgsView()
{
			_asm {
				mov dx,0x37a
				mov al,0
				out dx,al
            }
}

BOOL CJgsView::PreCreateWindow(CREATESTRUCT& cs)
{
	// TODO: Modify the Window class or styles here by modifying
	//  the CREATESTRUCT cs

	return CView::PreCreateWindow(cs);
}

/////////////////////////////////////////////////////////////////////////////
// CJgsView drawing

void CJgsView::OnDraw(CDC* pDC)
{
	CJgsDoc* pDoc = GetDocument();
	ASSERT_VALID(pDoc);

	// TODO: add draw code for native data here
    maindlg dlg;

	if (error_flag == 1){
      MessageBox("对不起,您没有插软件狗或者安装驱动程序.");
 	  exit(-1);
    }
	if (flag == 0){
		_asm{
			mov dx,0x3f8
            mov al,0
			out dx,al
        }
		flag = 1;
		dlg.DoModal();
		exit(-1);
    }
	
}

/////////////////////////////////////////////////////////////////////////////
// CJgsView diagnostics

#ifdef _DEBUG
void CJgsView::AssertValid() const
{
	CView::AssertValid();
}

void CJgsView::Dump(CDumpContext& dc) const
{
	CView::Dump(dc);
}

CJgsDoc* CJgsView::GetDocument() // non-debug version is inline
{
	ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CJgsDoc)));
	return (CJgsDoc*)m_pDocument;
}
#endif //_DEBUG

/////////////////////////////////////////////////////////////////////////////
// CJgsView message handlers
void Write1() 
{
	OutDogData = (void *)randomdata;
	CreateRandom();         

	InDogData = (void *)randomdata;
    OutDogData = (void *)result1;      //result1 save challenging result

    Encrypt();          	//run challenging function
}

void Read1() 
{
	// TODO: Add your control notification handler code here
	InDogData = (void *)result1;
    OutDogData = (void *)result2;      //result2 save responsing result
	RetCode = Decrypt();   // run responsing function
	if (RetCode==0)
      strcpy(mz,"asdkghadjksgasdg");
}

⌨️ 快捷键说明

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