Click here to Skip to main content
16,010,553 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralLinked Lists & Arrays and Locality of Reference Pin
Ziro_026-Mar-05 16:28
Ziro_026-Mar-05 16:28 
GeneralRe: Linked Lists & Arrays and Locality of Reference Pin
Michael Dunn26-Mar-05 20:33
sitebuilderMichael Dunn26-Mar-05 20:33 
GeneralRe: Linked Lists & Arrays and Locality of Reference Pin
Anonymous27-Mar-05 6:05
Anonymous27-Mar-05 6:05 
GeneralVC++ relationship between low-level objkects and GUI interfaces Pin
Anonymous26-Mar-05 10:41
Anonymous26-Mar-05 10:41 
GeneralRe: VC++ relationship between low-level objkects and GUI interfaces Pin
PJ Arends26-Mar-05 11:12
professionalPJ Arends26-Mar-05 11:12 
GeneralGlobal Function Pin
Static(x)26-Mar-05 9:49
Static(x)26-Mar-05 9:49 
GeneralRe: Global Function Pin
PJ Arends26-Mar-05 11:18
professionalPJ Arends26-Mar-05 11:18 
GeneralRestarting the process!! Pliz help Pin
mpapeo26-Mar-05 9:41
mpapeo26-Mar-05 9:41 
I want to restart the process. At first i created the process using createprocess() and then suspend it using suspendthread() and then i saved its state and information about it e.g. baseadress, context, state e.t.c in a binary file, after that i terminate it. Now i want to recreate it using its suspended state information. Pliz help me about this because i tried to use the functions below but the process doesnt restart again or atleast how to recreate a process using information from a previous saved information.
<br />
case 5://checkpointing<br />
				<br />
SuspendThread(pi.hThread);// identifies thread to suspend<br />
	printf("\nThe thread of ID: %d",pi.dwProcessId);<br />
	printf(" has been suspended!\n");<br />
	GetLastError();<br />
			<br />
	GetThreadContext(<br />
	hProcess,       // handle to thread with context<br />
	lpContext   // address of context structure<br />
	);<br />
	GetLastError();<br />
<br />
	regnum = 0;<br />
	base = 0;<br />
	fp = fopen("checkpoint.bin","w");<br />
	if( fp )<br />
<br />
	while (base < sinfo.lpMaximumApplicationAddress) <br />
<br />
	 {<br />
          VirtualQueryEx(hProcess, base, &mbi, sizeof(mbi));<br />
<br />
          if (mbi.State == MEM_COMMIT)<br />
               state = "Used";<br />
          else if (mbi.State == MEM_FREE)<br />
               state = "Free";<br />
          else if (mbi.State == MEM_RESERVE)<br />
               state = "Reserved";<br />
          else<br />
               state = "Unknown";<br />
<br />
			<br />
printf("\nREGION #%d\nState:%s\nBase Address:%p\nAllocation Base:%p\nAccess Protection: %08x\nRegion \<br />
Size: %08x\nProtection: %08x\nType: %08x\n", regnum, state, mbi.BaseAddress, mbi.AllocationBase, \<br />
mbi.AllocationProtect, mbi.RegionSize, mbi.Protect, mbi.Type);<br />
<br />
base = (LPVOID)((unsigned long)mbi.BaseAddress + (unsigned long)mbi.RegionSize);<br />
          /* make base point to one byte past the end of current region, which is either the beginning of the next region, or the beginning of the gap before the next region. <br />
 VirtualQueryEx() with this address will tell us about the next region in either case */ <br />
         regnum++;<br />
		 <br />
//printf("Enter the file-name to save the Memory Information: ",fname);<br />
		//scanf ("%s",fname);<br />
<br />
fprintf(fp,"\nREGION #%d\nState:%s\nBase Address:%p\nAllocation Base:%p\nAccess Protection: %08x\nRegion \<br />
		Size: %08x\nProtection: %08x\nType: %08x\n", regnum, state, mbi.BaseAddress, \<br />
		mbi.AllocationBase, mbi.AllocationProtect, mbi.RegionSize, mbi.Protect, mbi.Type);	<br />
		<br />
}//inner while<br />
<br />
	Sleep(3600);<br />
<br />
TerminateProcess(pi.hProcess, 0);<br />
<br />
break;<br />
<br />
	case 6://restarting the process in the other machine<br />
	lpBaseAddress = 0;<br />
	hProcess = mbi.BaseAddress;<br />
	SetThreadContext( <br />
	hThread, <br />
	lpContext <br />
	);<br />
	OpenThreadToken(<br />
	ThreadHandle,  // handle to thread<br />
	DesiredAccess,  // access to process<br />
	OpenAsSelf,      // flag for process or thread security<br />
	TokenHandle   // pointer to handle to open access token<br />
);<br />
<br />
	WriteProcessMemory(<br />
hProcess,	// handle to process whose memory is written to<br />
lpBaseAddress,			// address to start writing to<br />
lpBuffer,		// pointer to buffer to write data to<br />
nSize,			// number of bytes to write<br />
lpNumberOfBytesWritten  // actual number of bytes written<br />
);<br />
				<br />
ResumeThread(hThread);// identifies thread to restart<br />
GetLastError();<br />
		<br />
break;<br />


oam
GeneralRe: Restarting the process!! Pliz help Pin
Gary R. Wheeler26-Mar-05 13:53
Gary R. Wheeler26-Mar-05 13:53 
GeneralRe: Restarting the process!! Pliz help Pin
mpapeo27-Mar-05 3:04
mpapeo27-Mar-05 3:04 
GeneralRe: Restarting the process!! Pliz help Pin
Gary R. Wheeler27-Mar-05 3:40
Gary R. Wheeler27-Mar-05 3:40 
GeneralRe: Restarting the process!! Pliz help Pin
mpapeo27-Mar-05 4:06
mpapeo27-Mar-05 4:06 
GeneralAES imlementation in VC++ Pin
26-Mar-05 9:08
suss26-Mar-05 9:08 
GeneralFew questions, involving 64 bit file support. Pin
Master Shake 14426-Mar-05 7:32
Master Shake 14426-Mar-05 7:32 
GeneralRe: Few questions, involving 64 bit file support. Pin
Ravi Bhavnani26-Mar-05 12:17
professionalRavi Bhavnani26-Mar-05 12:17 
GeneralRe: Few questions, involving 64 bit file support. Pin
PJ Arends26-Mar-05 12:41
professionalPJ Arends26-Mar-05 12:41 
GeneralRe: Few questions, involving 64 bit file support. Pin
Ravi Bhavnani26-Mar-05 12:44
professionalRavi Bhavnani26-Mar-05 12:44 
GeneralRe: Few questions, involving 64 bit file support. Pin
Graham Bradshaw26-Mar-05 23:37
Graham Bradshaw26-Mar-05 23:37 
GeneralC++ Program Parameter Problem Pin
bneacetp26-Mar-05 6:16
bneacetp26-Mar-05 6:16 
GeneralRe: C++ Program Parameter Problem Pin
valikac26-Mar-05 6:27
valikac26-Mar-05 6:27 
GeneralRe: C++ Program Parameter Problem Pin
bneacetp26-Mar-05 6:50
bneacetp26-Mar-05 6:50 
GeneralRe: C++ Program Parameter Problem Pin
David Crow26-Mar-05 7:20
David Crow26-Mar-05 7:20 
GeneralRe: C++ Program Parameter Problem Pin
bneacetp26-Mar-05 14:48
bneacetp26-Mar-05 14:48 
GeneralRe: C++ Program Parameter Problem Pin
Blake Miller28-Mar-05 5:17
Blake Miller28-Mar-05 5:17 
GeneralRe: C++ Program Parameter Problem Pin
bneacetp28-Mar-05 10:35
bneacetp28-Mar-05 10:35 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.