home *** CD-ROM | disk | FTP | other *** search
/ The Elite Hackers Toolkit / TheEliteHackersToolkitVolume1_1998.rar / HACKERS.BIN / appcraks / MATHCRAC.ZIP / MCRACK.CPP < prev    next >
C/C++ Source or Header  |  1998-03-17  |  10KB  |  394 lines

  1. #include <windows.h>
  2. #include <commdlg.h>
  3. #include <stdio.h>
  4.  
  5. #include "mcrack.rh"
  6.  
  7. int PASCAL WinMain( HINSTANCE, HINSTANCE, LPSTR, int );
  8. void PaintMainWindow ( HWND );
  9. //BOOL FAR PASCAL _export AboutBoxProc ( HWND, UINT, WPARAM, LPARAM );
  10. BOOL FAR PASCAL _export FirstProc ( HWND, UINT, WPARAM, LPARAM );
  11. long FAR PASCAL _export MainWindowProc( HWND, UINT, WPARAM, LPARAM );
  12.  
  13. HINSTANCE hInst;
  14. HWND hWnd;
  15. char show=0;
  16. unsigned long filelen = 3294720L;
  17. char texto[]="Mathcad 7 Professional - Crack applicator";
  18. char texto1[]="Instrucciones:";
  19. char texto2[]="1) Presione el boton Continuar";
  20. char texto3[]="2) Ubique el archivo correspondiente";
  21. char texto4[]="3) Presione el boton Aceptar";
  22. char texto5[]="4) Disfrute del Mathcad 7 Professional";
  23. char szTemp[] = "MathCad exefile\0demomcad.exe\0\0";
  24. char szName[256] = "Demomcad.exe";
  25. char data1[] = "ThIs VeRsIoN oF MaThCaD\0";            // offset 29b285
  26. char data2[] = "ííWiLl NeVeR ExPiRe!!\0";                // offset 2982a3
  27. char data3[] = "íCrAcKeD vErSiOn!\0";                    // offset 29b34e
  28. char data4[] = {0x33, 0xc0, 0x40, 0x90};                // offset 201792
  29. char data5[] = {0x90, 0x90};                                // offset 20179b
  30. char data6[] = {0xeb};                                        // offset 20179f
  31. char data7[] = {0x90,0x90};                                // offset 2017b8
  32. char data8[] = {0x90,0x90,0x90,0x90,0x90,0x90};        // offset 2017ee
  33.  
  34. int PASCAL WinMain( HINSTANCE hInstance,
  35.                           HINSTANCE,
  36.                           LPSTR ,
  37.                           int )
  38. {
  39.     MSG msg;
  40.  
  41.     WNDCLASS clase;
  42.  
  43.     clase.lpszClassName = "XXX";
  44.     clase.hInstance = hInstance;
  45.     clase.lpfnWndProc = MainWindowProc;
  46.     clase.hCursor = LoadCursor( NULL, IDC_ARROW );
  47.     clase.hIcon = LoadIcon( hInstance, MAKEINTRESOURCE(ICON_1) );
  48.     clase.lpszMenuName = NULL;
  49.     clase.hbrBackground = (HBRUSH)(COLOR_BACKGROUND);
  50.     clase.style = CS_HREDRAW | CS_VREDRAW;
  51.     clase.cbClsExtra = 0;
  52.     clase.cbWndExtra = 0;
  53.  
  54.     RegisterClass( &clase );
  55.  
  56.     hInst = hInstance;
  57.  
  58.     hWnd = CreateWindow( "XXX",
  59.                                 "Crack Applicator",
  60.                                 WS_BORDER,
  61.                                 CW_USEDEFAULT,
  62.                                 CW_USEDEFAULT,
  63.                                 CW_USEDEFAULT,
  64.                                 CW_USEDEFAULT,
  65.                                 HWND_DESKTOP,
  66.                                 NULL,
  67.                                 hInstance,
  68.                                 NULL );
  69.  
  70.     ShowWindow (hWnd, SW_SHOWMAXIMIZED);    // Muestra la Ventana
  71.     UpdateWindow ( hWnd );    // La redibuja
  72.  
  73.     while( GetMessage(&msg, NULL, 0, 0 ))
  74.     {
  75.         TranslateMessage(&msg);
  76.         DispatchMessage(&msg);
  77.     }
  78.     UnregisterClass( "XXX", hInst );
  79.     return (msg.wParam);
  80. }
  81.  
  82.  
  83. //*******************************************************************
  84. //******************  MainWindowProc
  85. //*******************************************************************
  86.  
  87.  
  88. long FAR PASCAL _export MainWindowProc( HWND hWnd,
  89.                                     unsigned message,
  90.                                     WPARAM wParam,
  91.                                     LPARAM lParam )
  92. {
  93.  
  94.     switch (message)
  95.     {
  96.         case WM_DESTROY:
  97.             PostQuitMessage(0);
  98.             break;
  99.  
  100.         case WM_PAINT:
  101.             PaintMainWindow( hWnd );
  102.  
  103.             DLGPROC lpproc;
  104.             if( show )
  105.                 break;
  106.             show=1;
  107.             lpproc = (DLGPROC)MakeProcInstance ((FARPROC)FirstProc, hInst);
  108.             if( DialogBox (hInst, MAKEINTRESOURCE(First), hWnd, lpproc) )
  109.                 MessageBox( hWnd,
  110.                                 "No se ha podido aplicar el jodido crack",
  111.                                 "Error!",
  112.                                 MB_OK );
  113.             else
  114.                 MessageBox( hWnd,
  115.                                 "íEl crack ha sido aplicado!",
  116.                                 "Al Fin...",
  117.                                 MB_OK );
  118.             FreeProcInstance ((FARPROC)lpproc);
  119.             DestroyWindow( hWnd );
  120.  
  121.             break;
  122.  
  123.         default:
  124.             return (DefWindowProc( hWnd, message, wParam, lParam ));
  125.     }
  126.     return 0L;
  127. }
  128.  
  129. void PaintMainWindow( HWND hWnd )
  130. {
  131.     PAINTSTRUCT ps;
  132.     HDC hDC;
  133.     HPEN pen, oldpen;
  134.     RECT rect;
  135.  
  136.     GetClientRect( hWnd, &rect );
  137.  
  138.     hDC = BeginPaint( hWnd, &ps );
  139.  
  140.     for( int i=rect.top; i<rect.bottom; i++)
  141.     {
  142.         pen = CreatePen( PS_SOLID, 0, RGB( 0,0, 255-(BYTE)(((float)i/(float)rect.bottom)*255) ) );
  143.         oldpen = SelectObject(hDC, pen);
  144.         MoveToEx( hDC, rect.left, i, NULL );
  145.         LineTo( hDC, rect.right, i );
  146.         SelectObject(hDC, oldpen);
  147.         DeleteObject(pen);
  148.     }
  149.  
  150.     HFONT font, oldfont;
  151.  
  152.     font = CreateFont( 37,
  153.                              18,
  154.                              0,
  155.                              0,
  156.                              700,
  157.                              1,
  158.                              0,
  159.                              0,
  160.                              ANSI_CHARSET,
  161.                              OUT_TT_PRECIS,
  162.                              CLIP_DEFAULT_PRECIS,
  163.                              PROOF_QUALITY,
  164.                              0x04 | FF_DECORATIVE,
  165.                              "Arial" );
  166.  
  167.     oldfont = SelectObject( hDC, font );
  168.  
  169.     SetTextColor(hDC, RGB(0,0,0));
  170.     SetBkMode( hDC, TRANSPARENT );
  171.     TextOut( hDC, 14, 28, texto, sizeof(texto)-1 );
  172.  
  173.     SetTextColor(hDC, RGB(255,255,255));
  174.     TextOut( hDC, 10, 25, texto, sizeof(texto)-1 );
  175.  
  176.  
  177.     SelectObject( hDC, oldfont );
  178.     DeleteObject( font );
  179.  
  180.     EndPaint( hWnd, &ps );
  181. }
  182.  
  183.  
  184.  
  185. BOOL FAR PASCAL _export FirstProc (HWND hDlg,
  186.                                                   UINT message,
  187.                                                   WPARAM wParam,
  188.                                                   LPARAM)
  189. {
  190.     switch (message)
  191.     {
  192.         case WM_PAINT:
  193.             HDC hDC, hdcMemory;
  194.             PAINTSTRUCT ps;
  195.             HBITMAP hBitmap, hbmpold;
  196.             HPEN pen, oldpen;
  197.  
  198.             hDC = BeginPaint( hDlg, &ps );
  199.  
  200.             hBitmap = LoadBitmap( hInst, MAKEINTRESOURCE(BITMAP_2) );
  201.  
  202.             hdcMemory = CreateCompatibleDC(hDC);
  203.             hbmpold = SelectObject(hdcMemory, hBitmap);
  204.  
  205.             BitBlt(hDC, 0, 0, 400, 81, hdcMemory, -2, -2, SRCCOPY);
  206.  
  207.             SelectObject(hdcMemory, hbmpold);
  208.             DeleteDC( hdcMemory );
  209.             DeleteObject( hBitmap );
  210.  
  211.             pen = CreatePen( PS_SOLID, 1, RGB( 100,100, 100 ) );
  212.             oldpen = SelectObject(hDC, pen);
  213.  
  214.             MoveToEx( hDC, 2, 80, NULL );
  215.             LineTo( hDC, 2, 2 );
  216.             LineTo( hDC, 400, 2 );
  217.  
  218.             MoveToEx( hDC, 10, 285, NULL );
  219.             LineTo( hDC, 390, 285 );
  220.  
  221.             SelectObject(hDC, oldpen);
  222.             DeleteObject(pen);
  223.  
  224.             pen = CreatePen( PS_SOLID, 1, RGB( 255,255, 255 ) );
  225.             oldpen = SelectObject(hDC, pen);
  226.  
  227.             MoveToEx( hDC, 10, 286, NULL );
  228.             LineTo( hDC, 390,286 );
  229.  
  230.             MoveToEx( hDC, 400, 2, NULL );
  231.             LineTo( hDC, 400,80 );
  232.             LineTo( hDC, 1,80 );
  233.  
  234.          SelectObject(hDC, oldpen);
  235.             DeleteObject(pen);
  236.  
  237.  
  238.             HFONT font, oldfont;
  239.             font = CreateFont( 18,
  240.                                      8,
  241.                                      0,
  242.                                      0,
  243.                                      400,
  244.                                      0,
  245.                                      0,
  246.                                      0,
  247.                                      ANSI_CHARSET,
  248.                                      OUT_TT_PRECIS,
  249.                                       CLIP_DEFAULT_PRECIS,
  250.                                      PROOF_QUALITY,
  251.                                      0x04 | FF_DECORATIVE,
  252.                                      "Arial" );
  253.  
  254.             oldfont = SelectObject( hDC, font );
  255.  
  256.             SetTextColor(hDC, RGB(0,0,0));
  257.             SetBkMode( hDC, TRANSPARENT );
  258.  
  259.             TextOut( hDC, 30, 120, texto1, sizeof(texto1)-1 );
  260.             TextOut( hDC, 50, 142, texto2, sizeof(texto2)-1 );
  261.             TextOut( hDC, 50, 164, texto3, sizeof(texto3)-1 );
  262.             TextOut( hDC, 50, 186, texto4, sizeof(texto4)-1 );
  263.             TextOut( hDC, 50, 208, texto5, sizeof(texto5)-1 );
  264.  
  265.             SelectObject( hDC, oldfont );
  266.             DeleteObject( font );
  267.  
  268.             EndPaint( hDlg, &ps );
  269.  
  270.         case WM_SYSCOMMAND:
  271.             switch( wParam & 0xfff0 )
  272.             {
  273.                 case SC_MOVE:
  274.                     return TRUE;
  275.  
  276.                 default:
  277.                     return FALSE;
  278.             }
  279.  
  280.         case WM_SHOWWINDOW:
  281.             RECT wrect;
  282.  
  283.             GetWindowRect( hWnd, &wrect );
  284.             MoveWindow( hDlg,
  285.                             (wrect.right/2) - 205,
  286.                             (wrect.bottom/2) - 200,
  287.                             410,
  288.                             350,
  289.                             1 );
  290.  
  291.             break;
  292.  
  293.  
  294.  
  295.         case WM_COMMAND:
  296.             switch( wParam )
  297.             {
  298.                 case IDC_SEGUIR:
  299.                     OPENFILENAME ofnTemp;
  300.  
  301.                     ofnTemp.lStructSize = sizeof( OPENFILENAME );
  302.                     ofnTemp.hwndOwner = hDlg; // An invalid hWnd causes non-modality
  303.                     ofnTemp.hInstance = 0;
  304.                     ofnTemp.lpstrFilter = (LPSTR)szTemp;  // See previous note concerning string
  305.                     ofnTemp.lpstrCustomFilter = NULL;
  306.                     ofnTemp.nMaxCustFilter = 0;
  307.                     ofnTemp.nFilterIndex = 1;
  308.                     ofnTemp.lpstrFile = (LPSTR)szName;  // Stores the result in this variable
  309.                     ofnTemp.nMaxFile = sizeof( szName );
  310.                     ofnTemp.lpstrFileTitle = NULL;
  311.                     ofnTemp.nMaxFileTitle = 0;
  312.                     ofnTemp.lpstrInitialDir = NULL;
  313.                     ofnTemp.lpstrTitle = "Abrir";  // Title for dialog
  314.                     ofnTemp.Flags = OFN_FILEMUSTEXIST | OFN_HIDEREADONLY | OFN_PATHMUSTEXIST;
  315.                     ofnTemp.nFileOffset = 0;
  316.                     ofnTemp.nFileExtension = 0;
  317.                     ofnTemp.lpstrDefExt = "*";
  318.                     ofnTemp.lCustData = 0L;
  319.                     ofnTemp.lpfnHook = NULL;
  320.                     ofnTemp.lpTemplateName = NULL;
  321.  
  322.                     if( GetOpenFileName( &ofnTemp ) )
  323.                     {
  324.                         HANDLE hfile;
  325.                         SECURITY_ATTRIBUTES info;
  326.  
  327.                         info.nLength = sizeof(SECURITY_ATTRIBUTES);
  328.  
  329.                         if( (hfile = CreateFile(ofnTemp.lpstrFile,
  330.                                                         GENERIC_READ | GENERIC_WRITE,
  331.                                                         0,
  332.                                                         &info,
  333.                                                         OPEN_EXISTING,
  334.                                                         FILE_ATTRIBUTE_NORMAL | FILE_FLAG_RANDOM_ACCESS,
  335.                                                         NULL ))==INVALID_HANDLE_VALUE)
  336.                             MessageBox( hWnd,
  337.                                         "Algo anda mal... Intentelo nuevamente.",
  338.                                         "Error!",
  339.                                         MB_OK );
  340.                         else
  341.                         {
  342.                             unsigned long tam;
  343.                             char temp[256];
  344.                             sprintf(temp, "El Archivo %s no es el correcto.", ofnTemp.lpstrFile);
  345.                             tam = GetFileSize (hfile, (LPDWORD)NULL);
  346.                             if (tam != filelen)
  347.                             {
  348.                                 MessageBox( hWnd, temp, "Error!", MB_OK );
  349.                                 CloseHandle( hfile );
  350.                                 break;
  351.                             }
  352.  
  353.                             SetFilePointer( hfile, 0x201792L, NULL, FILE_BEGIN );
  354.                             WriteFile( hfile, data4, 4, &tam, NULL );
  355.  
  356.                             SetFilePointer( hfile, 0x20179BL, NULL, FILE_BEGIN );
  357.                             WriteFile( hfile, data5, 2, &tam, NULL );
  358.  
  359.                             SetFilePointer( hfile, 0x20179FL, NULL, FILE_BEGIN );
  360.                             WriteFile( hfile, data6, 1, &tam, NULL );
  361.  
  362.                             SetFilePointer( hfile, 0x2017B8L, NULL, FILE_BEGIN );
  363.                             WriteFile( hfile, data7, 2, &tam, NULL );
  364.  
  365.                             SetFilePointer( hfile, 0x2017eeL, NULL, FILE_BEGIN );
  366.                             WriteFile( hfile, data8, 6, &tam, NULL );
  367.  
  368.                             SetFilePointer( hfile, 0x29b285L, NULL, FILE_BEGIN );
  369.                             WriteFile( hfile, data1, sizeof(data1), &tam, NULL );
  370.  
  371.                             SetFilePointer( hfile, 0x29b2a3L, NULL, FILE_BEGIN );
  372.                             WriteFile( hfile, data2, sizeof(data2), &tam, NULL );
  373.  
  374.                             SetFilePointer( hfile, 0x29b34eL, NULL, FILE_BEGIN );
  375.                             WriteFile( hfile, data3, sizeof(data3), &tam, NULL );
  376.  
  377.                             CloseHandle( hfile );
  378.  
  379.                             EndDialog( hDlg, 0 );
  380.                         }
  381.                     }
  382.                 break;
  383.  
  384.             case IDC_CANCELAR:
  385.                 EndDialog( hDlg, 1 );
  386.                 break;
  387.         }
  388.         return TRUE;
  389.     }
  390.     return FALSE;
  391. }
  392.  
  393.  
  394.