Dawn_Dew 2021-06-11 01:32 采纳率: 0%
浏览 23

如何在代码中(C++)跳过dongle实现 compile code

问题:如何通过修改代码跳过dongle 实现compile code

已使用的方法: comment out 源代码中使用smart dongle 部分,出现了一下窗口。

 

软件版本: Microsoft visual studio 2019.

 

以下是包括smartdongle的代码 (App.cpp):

#include "smartdongle.h"

/*
....
....
*/

App::App()
{
	unsigned __int64 P1, P2;
	int error;
	//char errorString[QTS_ERROR_STRING_LENGTH_MAX];


   //SmartDongle  Demo Keys
   P1 = /* 没有展示的一串数字符*/;
   P2 = /* 没有展示的一串数字符*/;  


   while (1)
   {
	   error = SmartDongleRead(P1, P2, 0, NULL, 0);
	   if (error)
	   {
			
			int userchoice = AfxMessageBox("A valid Dongle is not present\n", MB_RETRYCANCEL);
			if(userchoice == IDCANCEL)
			{
				PostQuitMessage(0);
				break;
			}
		 
		//  SmartDongleGetErrorString(errorString, error);
		//  AfxMessageBox(errorString);

	   }
	   else
	   {
		   break;
	   }
   }


}

以下是部分 smartdongle.h

/*
   smartdongle.h for SmartDongle API version 3.2


   www.smartdongle.com

   MicroWorks, Inc.
   2808 North Cole Road
   Boise, ID 83704
*/

#ifndef _DEFINED_2A39393E_C414_4F94_B623_3FBCE5A8190F
#define _DEFINED_2A39393E_C414_4F94_B623_3FBCE5A8190F

#ifndef _WINDOWS_
   #include <Windows.h>
#endif

/*
   Maximum string length returned from GetErrorString()
*/
#define QTS_ERROR_STRING_LENGTH_MAX 128

#if defined(__cplusplus) || defined(__cplusplus__)
extern "C" {
#endif

	unsigned __int64 SmartDongleGetKeylessChallenge();
	int SmartDongleSendKeylessResponse(unsigned __int64 response);
	int SmartDongleKeylessRead(
	  unsigned int address,
	  unsigned char *buffer,
	  int size);
	int SmartDongleKeylessWrite(
	  unsigned int address,
	  unsigned char *buffer,
	  int size);

/*
   Given the correct keys, P1 and P2, will place the dongle into
   the enabled state and read EEPROM into buffer.

   Valid address is 0 to 32431

   Note: Refer to sd_uskerr.h for returned errors.
*/
   int SmartDongleRead (
      unsigned __int64 P1,
      unsigned __int64 P2,
      unsigned int address,
      unsigned char *buffer,
      int size);

以下是部分smartdongle.c

/*
   Given the correct keys, P1 and P2, will place the dongle into
   the enabled state and read EEPROM into buffer.
   Number of bytes read returned in size parameter.

   Note: Refer to uskerr.h for returned errors.
*/
int SmartDongleRead(
   unsigned __int64 P1,
   unsigned __int64 P2,
   unsigned int address,
   unsigned char *buffer,
   int size)
{
   int status;
   int bufferSize = size;
   HANDLE m_UsbHandle = INVALID_HANDLE_VALUE;


   status = OpenUsbDev(&m_UsbHandle);
   if (status != USK_OK)
   {
      return status;
   }

   /*
      Attempt to read user EEPROM space.
      On failure, attempt to disable dongle and return error.
      Number of bytes read returned in size parameter.
   */
   status = ReadEepromUserSpace(
      P1, P2, (unsigned short)address, buffer, &bufferSize, &m_UsbHandle);
   if (status != USK_OK)
   {
      DisableUsk(&m_UsbHandle);
      goto SD_ERROR;
   }

   /*
      Lock SmartDongle.
   */
   status = DisableUsk(&m_UsbHandle);

SD_ERROR:
   if (m_UsbHandle != INVALID_HANDLE_VALUE)
   {
      CloseHandle(m_UsbHandle);
   }

   return status;
}
  • 写回答

1条回答 默认 最新

  • 有问必答小助手 2021-06-16 16:49
    关注

    你好,我是有问必答小助手,非常抱歉,本次您提出的有问必答问题,技术专家团超时未为您做出解答

    本次提问扣除的有问必答次数,将会以问答VIP体验卡(1次有问必答机会、商城购买实体图书享受95折优惠)的形式为您补发到账户。

    ​​​​因为有问必答VIP体验卡有效期仅有1天,您在需要使用的时候【私信】联系我,我会为您补发。

    评论

报告相同问题?

悬赏问题

  • ¥15 vue3页面el-table页面数据过多
  • ¥100 vue3中融入gRPC-web
  • ¥15 kali环境运行volatility分析android内存文件,缺profile
  • ¥15 写uniapp时遇到的问题
  • ¥15 vs 2008 安装遇到问题
  • ¥15 matlab有限元法求解梁带有若干弹簧质量系统的固有频率
  • ¥15 找一个网络防御专家,外包的
  • ¥100 能不能让两张不同的图片md5值一样,(有尝)
  • ¥15 informer代码训练自己的数据集,改参数怎么改
  • ¥15 请看一下,学校实验要求,我需要具体代码