E
E
Evgeny Petryaev2020-07-23 16:50:30
C++ / C#
Evgeny Petryaev, 2020-07-23 16:50:30

Handle not caught?

Not catching message box window handle

// simple.cpp : Этот файл содержит функцию "main". Здесь начинается и заканчивается выполнение программы.
//
#include <Windows.h>
#include <stdio.h>
void session_(LPVOID args)
{
    MessageBox(NULL, L"What a you doing", L"Fuck this shit", MB_OK);
}
int main()
{

    HANDLE* thread = (HANDLE*)malloc(sizeof(HANDLE) * 1);
    thread[0] = CreateThread(0, 0, (LPTHREAD_START_ROUTINE)(session_), 0, 0, 0);
    
    long i;
    HWND hWnd = NULL;
    char sMsg[256] = { 0 };
    system("chcp 1251");
    while (TRUE)
    {
        //"#32770" äà ïðàâåëüíî ïîíÿëè ó MessageBox êëàññíºéì èìåííî òàêîé
        if (!(hWnd = FindWindow(L"simple",NULL)))
            printf("MessageBox is not detected\n");
        else
        {
            for (i = 100000; 0 < i; i--)
            {
                if (GetDlgItemText(hWnd, i, (LPWSTR)sMsg, 256))
                    printf("MessageBox says (in ID %d) : %s\n", i, sMsg);
            }
            system("pause");
        }
    }
    
    return 0;
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
maaGames, 2020-07-23
@maaGames

1) HANDLE thread = CreateThread(...), not that's all.
2) you want to catch the messagebox from the stream? Then at least call it "simple" and not "fuck".

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question