home *** CD-ROM | disk | FTP | other *** search
/ Reverse Code Engineering RCE CD +sandman 2000 / ReverseCodeEngineeringRceCdsandman2000.iso / RCE / Quantico / km / windld.cpp.txt < prev    next >
Encoding:
Text File  |  2000-05-25  |  5.4 KB  |  212 lines

  1. // windl34kgDlg.cpp : implementation file
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include "windl34kg.h"
  6. #include "windl34kgDlg.h"
  7.  
  8. #ifdef _DEBUG
  9. #define new DEBUG_NEW
  10. #undef THIS_FILE
  11. static char THIS_FILE[] = __FILE__;
  12. #endif
  13.  
  14. /////////////////////////////////////////////////////////////////////////////
  15. // CAboutDlg dialog used for App About
  16. char *keygen (char *name);
  17.  
  18. class CAboutDlg : public CDialog
  19. {
  20. public:
  21.         CAboutDlg();
  22.  
  23. // Dialog Data
  24.         //{{AFX_DATA(CAboutDlg)
  25.         enum { IDD = IDD_ABOUTBOX };
  26.         //}}AFX_DATA
  27.  
  28.         // ClassWizard generated virtual function overrides
  29.         //{{AFX_VIRTUAL(CAboutDlg)
  30.         protected:
  31.         virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
  32.         //}}AFX_VIRTUAL
  33.  
  34. // Implementation
  35. protected:
  36.         //{{AFX_MSG(CAboutDlg)
  37.         //}}AFX_MSG
  38.         DECLARE_MESSAGE_MAP()
  39. };
  40.  
  41. CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
  42. {
  43.         //{{AFX_DATA_INIT(CAboutDlg)
  44.         //}}AFX_DATA_INIT
  45. }
  46.  
  47. void CAboutDlg::DoDataExchange(CDataExchange* pDX)
  48. {
  49.         CDialog::DoDataExchange(pDX);
  50.         //{{AFX_DATA_MAP(CAboutDlg)
  51.         //}}AFX_DATA_MAP
  52. }
  53.  
  54. BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
  55.         //{{AFX_MSG_MAP(CAboutDlg)
  56.                 // No message handlers
  57.         //}}AFX_MSG_MAP
  58. END_MESSAGE_MAP()
  59.  
  60. /////////////////////////////////////////////////////////////////////////////
  61. // CWindl34kgDlg dialog
  62.  
  63. CWindl34kgDlg::CWindl34kgDlg(CWnd* pParent /*=NULL*/)
  64.         : CDialog(CWindl34kgDlg::IDD, pParent)
  65. {
  66.         //{{AFX_DATA_INIT(CWindl34kgDlg)
  67.         m_Name = _T("");
  68.         m_Serial = _T("");
  69.         //}}AFX_DATA_INIT
  70.         // Note that LoadIcon does not require a subsequent DestroyIcon in Win32
  71.         m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
  72. }
  73.  
  74. void CWindl34kgDlg::DoDataExchange(CDataExchange* pDX)
  75. {
  76.         CDialog::DoDataExchange(pDX);
  77.         //{{AFX_DATA_MAP(CWindl34kgDlg)
  78.         DDX_Text(pDX, IDC_EDIT1, m_Name);
  79.         DDX_Text(pDX, IDC_EDIT2, m_Serial);
  80.         //}}AFX_DATA_MAP
  81. }
  82.  
  83. BEGIN_MESSAGE_MAP(CWindl34kgDlg, CDialog)
  84.         //{{AFX_MSG_MAP(CWindl34kgDlg)
  85.         ON_WM_SYSCOMMAND()
  86.         ON_WM_PAINT()
  87.         ON_WM_QUERYDRAGICON()
  88.         ON_BN_CLICKED(IDOK, OnOk)
  89.         //}}AFX_MSG_MAP
  90. END_MESSAGE_MAP()
  91.  
  92. /////////////////////////////////////////////////////////////////////////////
  93. // CWindl34kgDlg message handlers
  94.  
  95. BOOL CWindl34kgDlg::OnInitDialog()
  96. {
  97.         CDialog::OnInitDialog();
  98.  
  99.         // Add "About..." menu item to system menu.
  100.  
  101.         // IDM_ABOUTBOX must be in the system command range.
  102.         ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
  103.         ASSERT(IDM_ABOUTBOX < 0xF000);
  104.  
  105.         CMenu* pSysMenu = GetSystemMenu(FALSE);
  106.         CString strAboutMenu;
  107.         strAboutMenu.LoadString(IDS_ABOUTBOX);
  108.         if (!strAboutMenu.IsEmpty())
  109.         {
  110.                 pSysMenu->AppendMenu(MF_SEPARATOR);
  111.                 pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
  112.         }
  113.  
  114.         // Set the icon for this dialog.  The framework does this automatically
  115.         //  when the application's main window is not a dialog
  116.         SetIcon(m_hIcon, TRUE);                 // Set big icon
  117.         SetIcon(m_hIcon, FALSE);                // Set small icon
  118.  
  119.         // TODO: Add extra initialization here
  120.  
  121.         return TRUE;  // return TRUE  unless you set the focus to a control
  122. }
  123.  
  124. void CWindl34kgDlg::OnSysCommand(UINT nID, LPARAM lParam)
  125. {
  126.         if ((nID & 0xFFF0) == IDM_ABOUTBOX)
  127.         {
  128.                 CAboutDlg dlgAbout;
  129.                 dlgAbout.DoModal();
  130.         }
  131.         else
  132.         {
  133.                 CDialog::OnSysCommand(nID, lParam);
  134.         }
  135. }
  136.  
  137. // If you add a minimize button to your dialog, you will need the code below
  138. //  to draw the icon.  For MFC applications using the document/view model,
  139. //  this is automatically done for you by the framework.
  140.  
  141. void CWindl34kgDlg::OnPaint()
  142. {
  143.         if (IsIconic())
  144.         {
  145.                 CPaintDC dc(this); // device context for painting
  146.  
  147.                 SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
  148.  
  149.                 // Center icon in client rectangle
  150.                 int cxIcon = GetSystemMetrics(SM_CXICON);
  151.                 int cyIcon = GetSystemMetrics(SM_CYICON);
  152.                 CRect rect;
  153.                 GetClientRect(&rect);
  154.                 int x = (rect.Width() - cxIcon + 1) / 2;
  155.                 int y = (rect.Height() - cyIcon + 1) / 2;
  156.  
  157.                 // Draw the icon
  158.                 dc.DrawIcon(x, y, m_hIcon);
  159.         }
  160.         else
  161.         {
  162.                 CDialog::OnPaint();
  163.         }
  164. }
  165.  
  166. // The system calls this to obtain the cursor to display while the user drags
  167. //  the minimized window.
  168. HCURSOR CWindl34kgDlg::OnQueryDragIcon()
  169. {
  170.         return (HCURSOR) m_hIcon;
  171. }
  172.  
  173. void CWindl34kgDlg::OnOk()
  174. {
  175. char test[100], *rez;
  176. UpdateData();
  177. strcpy(test,m_Name);
  178. rez = keygen(test);
  179. m_Serial = rez;
  180. UpdateData(FALSE);
  181. }
  182.  
  183. //WinDonload 3.4 KeyGen          [MD/UCF]
  184. // MegaDoc UCF
  185.  
  186. char key[100];
  187. char *keygen (char *name)
  188. {
  189. union b64 {
  190. __int64 x;
  191. struct Y {
  192. __int32 l,h;
  193. } y;
  194. } x;
  195. long l;
  196. int j;
  197. char a[100];
  198. for (j=0;j<100;j++) key[j]=0;
  199. l=atol(name); srand(l);
  200. for (j=0;j<7;j++){
  201. x.x=rand(); x.y.l=(((((x.y.l^x.y.h)-x.y.h)&1)^x.y.h)-x.y.h);
  202. if (x.y.l==0) {
  203. x.x=rand(); x.x%=10000;
  204. } else {
  205. x.x=rand(); x.x=(x.x%10000)+name[j*3];
  206. }
  207. sprintf(a,"%04d",x.x);
  208. strcat(key,a);
  209. }
  210. return key;
  211. }
  212.