I need to make a listbox refresh, but cannot get it to work. IDK what's wrong and IDK if I should be using a timer or loop to refresh it. Also, when I read from memory into the listbox, I am currently using LBS_SORT style, but I want it to read into the listbox in order as it is reading it, not alphabetically. Any suggestions? Here's my coding for the listbox:
Code://main.cpp
#include <windows.h>
#include <commctrl.h>
#include <stdio.h>
#include <string.h>
#include "main.h"
BOOL CALLBACK DoListboxProcess(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
HWND hwnd;
DWORD pid;
HANDLE process;
int x, y, z;
DWORD iAddress = 0x4BD7AFC6;
DWORD dummy = 0;
unsigned char value[512];
char outvalue[32];
switch (message) {
case WM_INITDIALOG:
hwnd=FindWindow(NULL, "Halo");
SendDlgItemMessage(hDlg, IDC_PLAYERLIST, LB_RESETCONTENT, 0, 0);
GetWindowThreadProcessId(hwnd, &pid);
process = OpenProcess(PROCESS_VM_READ
|PROCESS_VM_WRITE|
PROCESS_VM_OPERATION
|PROCESS_QUERY_INFORMATION,
FALSE, pid);
for(x = 0; x < 16;x++)
{
ReadProcessMemory(process // handle to the process
,(void*) iAddress, // address to start reading
(void*) &value, // address of buffer to place read data
sizeof(value) // number of bytes to read
,&dummy); // number of bytes read
z = 0;
for(y = 10; y < 32; y+=2)
{
outvalue[z++] = value[y];
}
outvalue[11] = '\0';
SendDlgItemMessage(hDlg, IDC_PLAYERLIST, LB_ADDSTRING, 0, (LPARAM)outvalue);
iAddress += sizeof value;
}
return (TRUE);
case WM_COMMAND:
if (LOWORD(wParam) == IDOK ||LOWORD(wParam)== IDCANCEL ) {
EndDialog(hDlg, TRUE);
return (TRUE);
}
break;
}
return FALSE;
}
int WINAPI WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpszArgs,
int nWinMode)
{
InitCommonControls();
DialogBox(hInstance ,MAKEINTRESOURCE(IDD_LISTBOX) , 0, DoListboxProcess);
return 0;
}
Code://main.h
#pragma comment(lib,"USER32.LIB")
#pragma comment(lib,"GDI32.LIB")
#pragma comment(lib,"COMCTL32.LIB")
#define IDD_LISTBOX 100
#define IDC_PLAYERLIST 101
Code://util.rc
/////////////////////////////////////////////////////////////////////////////
//
// Dialog
//
IDD_LISTBOX DIALOG DISCARDABLE 0, 0, 185, 171
STYLE DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Just a test list box"
FONT 8, "MS Shell Dlg"
BEGIN
DEFPUSHBUTTON "OK",IDOK,89,52,50,14
PUSHBUTTON "Cancel",IDCANCEL,89,81,50,14
LISTBOX IDC_PLAYERLIST,8,6,72,157,LBS_SORT |
LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP
END