I need to access a thread of a process in a Visual Studio project in the Process Explorer. I can’t find it, I tried to look for it while it was running, after it finished running, and before. Don’t know if it’s important bu the code is
#include <windows.h>
#include <stdio.h>
#include <stdlib.h> // For malloc and free
struct MyStruct {
INT a;
INT b;
};
DWORD WINAPI bla(LPVOID lparam) {
struct MyStruct* nums = (struct MyStruct*)lparam;
INT count = nums->a + nums->b;
for (INT i = 1; i <= count; i++) {
printf("blan");
Sleep(1000);
}
return 0; // Typically, thread functions return 0 for success
}
int main()
{
struct MyStruct* my_struct = (struct MyStruct*)malloc(sizeof(struct MyStruct));
if (my_struct == NULL) {
fprintf(stderr, "Memory allocation failedn");
return 1;
}
my_struct->a = 3;
my_struct->b = 4;
LPVOID pstruct = my_struct;
HANDLE hThread = CreateThread(
NULL, //default security attributes
0, //default stack size
bla, //thread function
pstruct, //thread param
0, //default creation flags
NULL //return thread identifier
);
if (hThread == NULL) {
fprintf(stderr, "Failed to create threadn");
free(my_struct); // Free memory if thread creation fails
return 1;
}
WaitForSingleObject(hThread, INFINITE);
}