Code:
HWND myDialog;
HWND editBox;
void createWindow()
{
myDialog = CreateWindowEx(0, WC_DIALOG,"Just a random window",WS_OVERLAPPEDWINDOW | WS_VISIBLE, 400,100,800,380,NULL,NULL,NULL,NULL );
CreateWindow( "listbox", "",
WS_VISIBLE|WS_CHILD|LBS_HASSTRINGS|WS_HSCROLL|WS_VSCROLL,
0, 0, 780, 300, myDialog, (HMENU)156, 0, NULL);
editBox = CreateWindow( "edit", "",
WS_VISIBLE|WS_CHILD,
0, 305, 780, 20, myDialog, (HMENU)158, 0, NULL);
}
DWORD WINAPI mySexyThread( LPVOID lpParam )
{
while(1)
{
MSG msg;
if(PeekMessage(&msg,NULL,0,0,PM_NOREMOVE))
{
if(msg.hwnd == editBox && msg.message == WM_KEYDOWN && msg.wParam == VK_RETURN)
{
int len = GetWindowTextLength(editBox);
char *tmp = new char[len+1];
GetWindowText(editBox, tmp, len+1);
string tmps(tmp);
if(tmps.find(" ") == string::npos)
{
if(cvar->FindVar(tmp) != NULL)
{
int selpos = SendDlgItemMessage(myDialog, 156, LB_ADDSTRING, 0, (LPARAM)tmp);
SendDlgItemMessage(myDialog, 156, LB_SETCURSEL, selpos, 0);
char tbuff[512] = "";
sprintf(tbuff, "\"%s\" = \"%s\" (def. \"%s\")", tmp, cvar->FindVar(tmp)->GetString(), cvar->FindVar(tmp)->m_pszDefaultValue);
selpos = SendDlgItemMessage(myDialog, 156, LB_ADDSTRING, 0, (LPARAM)tbuff);
SendDlgItemMessage(myDialog, 156, LB_SETCURSEL, selpos, 0);
}
}
}
}
Sleep(1);
}
}
dllmain DLL_PROCESS_ATTACH:
createWindow();
CreateThread(0, 0, &mySexyThread, 0, 0, 0);
it peeks in the message buffer but doesn't remove the message(so the application injected into will still have to handle those), you might be able to use PM_REMOVE for some applications without anything breaking(this was the case for vindictus), or peekmessage with PM_NOREMOVE and if it's supposed to go to your window peekmessage with PM_REMOVE to remove those messages from the buffer.