test.cpp
上传用户:graphite
上传日期:2020-09-09
资源大小:2587k
文件大小:1k
源码类别:

破解

开发平台:

Others

  1. // test.cpp : Defines the entry point for the application.
  2. //
  3. #include "stdafx.h"
  4. #include "resource.h"
  5. #include <io.h>
  6. #include "include/aspr_api.h"
  7. #include "include/asprotect.h"
  8. #pragma comment(lib,"include/aspr_ide.lib")
  9. int APIENTRY WinMain(HINSTANCE hInstance,
  10.                      HINSTANCE hPrevInstance,
  11.                      LPSTR     lpCmdLine,
  12.                      int       nCmdShow)
  13. {
  14.         int             f = -1;
  15.         int             fsize;
  16.         unsigned char   *fbuffer = NULL;
  17.         char            *message = "Unregistered version !";
  18.         if ((f = open("test.bin", 0)) != -1)
  19.         {
  20.                 // Read a file with a constant for decryption
  21.                 fsize = filelength(f);
  22.                 fbuffer = (unsigned char*)malloc(fsize);
  23.                 read(f, fbuffer, fsize);
  24.                 // Set a constatnt to ASProtect
  25. if (SetUserKey( (char*)fbuffer, (DWORD)fsize ) == TRUE)
  26. {
  27. // This is an example of fragments decryption/encryption
  28. if (f != -1) close(f);
  29. REG_CRYPT_BEGIN2
  30. message = "Registered version !";
  31. REG_CRYPT_END2
  32. if (fbuffer != NULL) free(fbuffer);
  33. }
  34.         }
  35.         MessageBox(0,message,"",0);
  36.         return 0;
  37. }