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();
}
|