Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Preprocessor files
- #include <windows.h>
- #define submitButton 101
- #define passwordEdit 102
- //Define variables
- const char g_szClass[] = "CrackMe!";
- const char g_szCaption[] = "CrackMe!";
- MSG Msg;
- HWND hWindow;
- WNDCLASSEX wcex;
- HWND hSubmitButton;
- HWND hPasswordEdit;
- char counter;
- char password[sizeof(g_szCaption)];
- char userPassword[] = "Thank you for trying out my CrackMe. This is just a taster of what a CrackMe is like. Please note that this is very, very simple to crack. :)";
- //Error function
- DWORD WINAPI error() {
- MessageBox(NULL, NULL, "Error", MB_ICONERROR | MB_OK);
- PostQuitMessage(0);
- }
- DWORD WINAPI encryptPassword() {
- for(counter = false; counter < sizeof(g_szCaption); counter++)
- password[counter] = g_szCaption[counter];
- }
- DWORD WINAPI checkPassword() {
- if(strcmp(password, userPassword) == false)
- MessageBox(NULL, "Congratulations! You cracked the password.", "CrackMe!", MB_ICONEXCLAMATION | MB_OK);
- else
- MessageBox(NULL, "Sorry, the password you entered was incorrect.", "CrackMe!", MB_ICONEXCLAMATION | MB_OK);
- }
- //Message procedure
- long FAR PASCAL WindowProc(HWND hWindow, UINT uMsg, WPARAM wParam, LPARAM lParam) {
- switch(uMsg) {
- case WM_CREATE:
- hPasswordEdit = CreateWindowEx(WS_EX_CLIENTEDGE, "Edit", false, WS_VISIBLE | WS_CHILD | WS_BORDER, 10, 10, 124, 27, hWindow, (HMENU)passwordEdit, false, NULL);
- hSubmitButton = CreateWindowEx(false, "Button", "Submit", WS_VISIBLE | WS_CHILD | WS_BORDER, 24, 45, 95, 25, hWindow, (HMENU)submitButton, false, NULL);
- break;
- case WM_COMMAND:
- switch(LOWORD(wParam)) {
- if(!HIWORD(wParam)) {
- case submitButton:
- GetDlgItemText(hWindow, passwordEdit, userPassword, 100);
- checkPassword();
- }
- }
- break;
- case WM_DESTROY:
- PostQuitMessage(false);
- break;
- }
- return DefWindowProc(hWindow, uMsg, wParam, lParam);
- }
- //WinMain
- int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrev, PSTR szCmdLine, int nCmdShow) {
- encryptPassword();
- //Create the window class & register it
- wcex.cbSize = sizeof(wcex);
- wcex.style = CS_CLASSDC;
- wcex.lpfnWndProc = WindowProc;
- wcex.cbClsExtra = 0;
- wcex.cbWndExtra = 0;
- wcex.hInstance = hInst;
- wcex.hIcon = LoadIcon(NULL, IDI_APPLICATION);
- wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
- wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW + 0);
- wcex.lpszMenuName = NULL;
- wcex.lpszClassName = g_szClass;
- wcex.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
- if(!RegisterClassEx(&wcex))
- error();
- //Create window
- hWindow = CreateWindow(g_szClass, g_szCaption, WS_SYSMENU | WS_VISIBLE, CW_USEDEFAULT, CW_USEDEFAULT, 150, 100, NULL, NULL, hInst, NULL);
- //Show and update the window
- ShowWindow(hWindow, SW_NORMAL);
- UpdateWindow(hWindow);
- //Enter the message pump
- ZeroMemory(&Msg, sizeof(MSG));
- while(Msg.message != WM_QUIT) {
- //Handle windows messages (if any)
- if(PeekMessage(&Msg, NULL, false, false, PM_REMOVE)) {
- TranslateMessage(&Msg);
- DispatchMessage(&Msg);
- }
- }
- return false;
- }
Add Comment
Please, Sign In to add comment