Thread Loop

Posts 1–3 of 3 · Page 1 of 1
Thread Loop
Hey Guys

I have a problem here with my code. My aim is to inject this dll and when i press 8 or 2 a message box pops up. Its not a hook or something, Im just trying to learn some basic stuff If you can explain a little how the function is looping that would help alot!


Here is my code:

[HTML]
#include <Windows.h>
#include <Stdio.h>


void Main_Thread()
{
if(GetAsyncKeyState(VK_NUMPAD8))
{

MessageBoxA(NULL, "You Pressed 8", "Succesfull", MB_OK);
}

if(GetAsyncKeyState(VK_NUMPAD2))
{

MessageBoxA(NULL, "You Pressed 2", "Succesfull", MB_OK);
}

}


BOOL WINAPI DllMain ( HMODULE hDll, DWORD dwReason, LPVOID lpReserved ){
if ( dwReason == DLL_PROCESS_ATTACH ){
HANDLE hThread;
DWORD dwReason;
CreateThread(NULL, NULL, (LPTHREAD_START_ROUTINE)Main_Thread, NULL, NULL, NULL);
CloseHandle(hThread);
}

return TRUE;
}
[/HTML]

Thanks in advance
Your title says it all
You've forgotten your loop, here's how it should look:

Code:
#include <Windows.h>
#include <Stdio.h>


void Main_Thread() 
{
   while(1){  // the loop you've forgotten
Sleep(100); // play it cool on the cpu, he's your best friend :D
   if(GetAsyncKeyState(VK_NUMPAD8))
	{

		MessageBoxA(NULL, "You Pressed 8", "Succesfull", MB_OK);
	}

	if(GetAsyncKeyState(VK_NUMPAD2))
	{

		MessageBoxA(NULL, "You Pressed 2", "Succesfull", MB_OK);
	}

   }
}

BOOL WINAPI DllMain ( HMODULE hDll, DWORD dwReason, LPVOID lpReserved ){
    if ( dwReason == DLL_PROCESS_ATTACH ){
        CreateThread(NULL, NULL, (LPTHREAD_START_ROUTINE)Main_Thread, NULL, NULL, NULL); 
        CloseHandle(hThread);
    }
	
    return TRUE;
}
ohh and btw
You're not getting these boxes on pressing 2 & 8, but numpad 2 & 8
Yes yes i know!

Thanks alot dude! D

/Close plz
Posts 1–3 of 3 · Page 1 of 1

Post a Reply

Similar Threads

Tags for this Thread

None

Talk with us