Type of stream object to use?

Hello everyone,

I am trying to figure out which type of stream to use for my task.

Very simply put I am trying to capture my processes thread in action and see how the threads tasks are carried out.

Thank you all in advance for any help you can provide.

EDIT:

I wanted to add clarification on what it is I am trying to do.

I want to learn more about how the Stack / Heap work and actually see the work being done. What I have done is create a small .exe which has three integers.

I initialize all integers to 0, and then give a and b real values, then add them together and store the result in c.

I then call this .exe with the CreateProcess() function and get a HANDLE to both the Process and the Thread. Everything works so far, although I feel I hit a wall.

Conceptually I know what I want to accomplish. Yet actually finding what I NEED in the Windows API is very hard. I have spent countless hours search for a function or tool which will allow me to view the Processes Stack, as well as its Heap.

So the code listed below is my .exe which I am calling, as well as my source for my working project.

Once again I am trying to capture or view what the Process is doing. I would love to dump this into a .txt file to really pick apart the file. This is all really fun for me, but the fun stops when progress does. So if you can please provide me with any reference or just a nudge in the right direction, I would be much obliged.

Another note, I really would prefer to not use the .NET framework as I am not that comfortable with it yet. Just a note to self, or readers.

1
2
3
4
5
6
7
8
9
10
11
12
13
addTwoNumbers.exe

void main()
{
	int a = 0;
	int b = 0;
	int c = 0;

	a = 5;
	b= 10;

	c = a + b;
}


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#include <Windows.h>
#include <iostream>
#include "Utilities.h"

using namespace std;

void main()
{
	Util::Utilities ut;
	PROCESS_INFORMATION pi;
	STARTUPINFO si;
	HANDLE pHandle;
	HANDLE pThread;

	ZeroMemory(&pi, sizeof(pi));
	ZeroMemory(&si, sizeof(si));

	CreateProcess(TEXT("C:\\Users\\netsbeast\\Documents\\Visual Studio 2010\\Projects\\addTwoNumbers\\Debug\\addTwoNumbers.exe"),
				  NULL,
				  NULL,
				  NULL,
				  TRUE,
				  CREATE_NO_WINDOW,
				  NULL,
				  NULL,
				  &si,
				  &pi);
				  
	if(GetLastError != 0)
	{
		cout << GetLastError() << endl;
	}

	pHandle = OpenProcess(PROCESS_ALL_ACCESS, TRUE, pi.dwProcessId);
	pThread = OpenThread(PROCESS_ALL_ACCESS, TRUE, pi.dwThreadId);




	ut.wait();
}

Last edited on
bumping.

That's not a lot of information.

How do you see this working?
What sort of information are you expecting to capture?
and so on and so on....
Based on the limited information you gave us I think you want to use an "fstream" and just capture the data to a "log file", but that seems a little too simple.

Also don't bump your posts, the reason it catches our attention is that we come in here with the intention of reporting the thread weither we do or not at that point is based on the content of the question and weither you've been warned about it before.
Why do you think this is a stream issue?

If you want to do this with any old process (for which you have a PDB file):
Call CreateToolhelp32Snapshot/Process32First/Process32Next/CloseHandle to walk the chain of processes.

You can use the DbgHelp to find the thread in your process and do a stack trace to see what they're doing. That's pretty much what ProcessExplorer does.
http://msdn.microsoft.com/en-us/library/ms679309%28v=VS.85%29.aspx


A better way is to instrument your app and have the threads notify the WMI what it's doing. Then you can monitor your app with the standard performance monitor tools that ship with the OS.
I just wanted to add that I updated the original post with meaningful information. Hopefully someone can chime in now.
I think I may have found what I am looking for:
http://msdn.microsoft.com/en-us/library/ms680650(v=VS.85).aspx

StackWalk64(), will test it out today and give feedback on its behavior!
Would this be exceptable?: http://technet.microsoft.com/en-us/sysinternals/bb896645

It's not your code, but it will show you the data that you're looking for. And it even comes with that handy dump to text file feature you wanted.
Computergeerk01,

Thanks for the example but I can not use other software. I want to accomplish this myself.
Topic archived. No new replies allowed.