|
Hi all,
I am developing a Win32 Console application that reads XML file and displays the data. I am importing msxml4.dll and then usiing the following code to create the instance of the DomDocument class
HRESULT hr;
IXMLDOMDocumentPtr pDocument = NULL;
IXMLDOMParseErrorPtr pParseError = NULL;
BSTR bstr = NULL;
VARIANT_BOOL status = NULL;
VARIANT vsrc;
CoInitialize(NULL);
hr = CoCreateInstance(CLSID_XMLDocument,NULL,_ CLSCTX_INPROC_SERVER,IID_IXMLDocument,(void**)&pDocument);
VariantInit(&vsrc);
V_BSTR(&vsrc) = SysAllocString(L"try.xml");
V_VT(&vsrc) = VT_BSTR;
hr = pDocument->load(vsrc,&status);
hr = pDocument->Getxml(&bstr);
cout << "Try.xml comtents: " << bstr;
if(bstr)
SysFreeString(bstr);
if(&vsrc)
VariantClear(&vsrc);
if(pParseError)
pParseError->Release();
if(pDocument)
pDocument->Release();
CoUninitialize();
when I compiled the program it gives error
'Getxml' : is not a member of 'IXMLDOMDocument'
when I run the application without calling getXML function it gives me run time error that unhandled exception in the application.exe 0xC0000005: Access Violation.
Can anyone tell me where I am wrong.
I ahve the following files in system folder
msxml2.dll,msxml2r.dll,msxml3a.dll,msxml3.dll.msxml3r.dll.msxml4.dll,msxml4r.dll.msxmlr.dll
One point where I suspect error could be as to crete instance using CLSID_DOMDocument40, IXMLDOMDocument4 but in my project it gives me error when I call the CoCreateInstance with the above mentioned parameters.
Thanks in advance.
Ritu Kwatra
|
|
|
|
|
Instead of GetXml() simply use IXmlDomDocument::xml variable. it is BSTR variable which contain whole XML file which is currently loaded in interface.
Anyway from where you got this example Code!
[Vote One Here, Complete my Survey....]
Alok Gupta visit me at http://www.thisisalok.tk
"I Think Believe this Will Help"
|
|
|
|
|
|
Here is small example,hope that's work for you.
MSXML2::IXMLDOMDocument *l_pXMLDomDocument;
MSXML2::IXMLDOMElement *l_XMLDomElemnent;
MSXML2::IXMLDOMNode *l_XMLDomFirstNode,*l_XMLDomNextNode;
CLSID clsidXMLDom;
::CLSIDFromProgID(OLESTR"msxml2.domdocument"),&clsidXMLDom);
if(SUCCEEDED(CoCreateInstance(clsidXMLDom,NULL,CLSCTX_ALL,IID_IXMLDOMDocument,reinterpret_cast<LPVOID*>(&l_pXMLDomDocument))))
{
MessageBox("Object Creation successful");
}
CString strXml="<xml><cp>helloo</cp></xml>";
l_pXMLDomDocument->loadXml(_variant_t(strXml.AllocSysString()));
MessageBoxW(NULL,l_pXMLDomDocument->xml,L"XML",MB_OK);
l_pXMLDomDocument->get_firstChild(&l_XMLDomFirstNode);
MessageBoxW(NULL,l_XMLDomFirstNode->GetnodeName(),L"",MB_OK);
l_XMLDomFirstNode->get_firstChild(&l_XMLDomNextNode);
CString str;
while(l_XMLDomNextNode)
{
MessageBoxW(NULL,l_XMLDomNextNode->GetnodeName(),L"",MB_OKCANCEL);
l_XMLDomNextNode->get_firstChild(&l_XMLDomFirstNode);
while(l_XMLDomFirstNode)
{
MessageBoxW(NULL,l_XMLDomFirstNode->GetnodeName(),l_XMLDomFirstNode->GetnodeValue().bstrVal,MB_OK);
l_XMLDomFirstNode->get_nextSibling(&l_XMLDomFirstNode);
}
if(l_XMLDomNextNode->get_nextSibling(&l_XMLDomNextNode)==S_FALSE)
l_XMLDomNextNode=NULL;
}
[Vote One Here, Complete my Survey....]
Alok Gupta visit me at http://www.thisisalok.tk
"I Think Believe this Will Help"
|
|
|
|
|
Hi Alok,
Error in the CoCreateInstance is still the same. Error is
D:\Ritu\VC++\Win32XML\xmlsource.cpp(20) : error C2065: 'IID_IXMLDOMDocument' : undeclared identifier
Ritu Kwatra
|
|
|
|
|
Hi Alok,
The type of errors are still same. Errors are:
error C2039: 'loadXml' : is not a member of 'IXMLDOMDocument'
error C2039: 'xml' : is not a member of 'IXMLDOMDocument'
error C2039: 'GetnodeName' : is not a member of 'IXMLDOMNode'
error C2039: 'GetnodeName' : is not a member of 'IXMLDOMNode'
error C2039: 'GetnodeValue' : is not a member of 'IXMLDOMNode'
Ritu Kwatra
|
|
|
|
|
|
Hi Alok,
Including msxml2.h does not make any difference. Right now I am downloading MSXML 4.0 SP2. It may change the scenario.
But to run the XML from visual basic we don't need to install MSXML4.0. Just registering the dlls are sufficient.
Do we really need to install MSXML4.0 for VC++ ??? I think if we have the DLLs then it should run in the proper way.
Ritu Kwatra
|
|
|
|
|
There is theoretically no difference in COM programming in both VB and VC.
If some COM dll run in vb then it defiantly run in VC, that’s the power of COM!
Ritu Kwatra wrote:
Do we really need to install MSXML4.0 for VC++???
Actually MSXML SKD provide you -> documentation, sample source code and msxml4.h. it's upto u what do u need
Ritu Kwatra wrote:
I think if we have the DLLs then it should run in the proper way.
Just by registering the proper dll makes your program work properly.
[Vote One Here, Complete my Survey....]
Alok Gupta visit me at http://www.thisisalok.tk
"I Think Believe this Will Help"
|
|
|
|
|
hi all,
i've managed to write a simply add-in for visual studio. the toolbar currently only consists of a couple of command buttons.
i would like to add an edit box as part of my add-in. is this possible?
could someone please reply with some sample code to get me started?
cheers,
suresh
|
|
|
|
|
Hi
I have an application which runs a timer synchronously. I think I have a bug in the timer. Can I find out the bug with the VC++ debugger or should I go for any other tools. Please help with ideas.
Regards
Sreekanth Muralidharan
Hyderabad
|
|
|
|
|
|
Hi
Thanks a lot. That was a great tool. Was due to memory leak !!
Regards
Sreekanth Muralidharan
|
|
|
|
|
|
Hi
That was a great tool. Thanks a lot for your invaluable guidance.
Problem due to memory leak..
Regards
Sreekanth Muralidharan
|
|
|
|
|
hi, how do i execute a dos program in MFC Application?i try using ShellExecuteEx, the prompt is shown but not the dos program it self.i think the dos program has running at the background of dos prompt..who can help me ,please!!
SHELLEXECUTEINFO ShExecInfo = {0};
ShExecInfo.cbSize = sizeof(SHELLEXECUTEINFO);
ShExecInfo.fMask = SEE_MASK_NOCLOSEPROCESS;
ShExecInfo.hwnd = NULL;
ShExecInfo.lpVerb = NULL;
ShExecInfo.lpFile = "C:\\GLAP1.EXE";
ShExecInfo.lpParameters = "";
ShExecInfo.lpDirectory = NULL;
ShExecInfo.nShow = SW_SHOWNORMAL;
ShExecInfo.hInstApp = NULL;
if(ShellExecuteEx(&ShExecInfo)!= 0)
{
ShExecInfo.hProcess;
WaitForSingleObject(ShExecInfo.hProcess,INFINITE);
return 0;
}
else
return 1;
|
|
|
|
|
Hello,
I have a C++ dll that I just created and im having trouble converting the data inside a BYTE * to a C# version of byte[].
On my C# App I DllImported the dll, the return type i set to be an IntPtr (the return type of the C++ dll is BYTE *)
I then put the IntPtr I then Marshaled it and put the results inside a MemoryStream.
The output should have been an image (bitmap). but when trying to save to file it gives an error of not valid type.
My question is, on the C++ dll, what type is BYTE *? on my C# side should I go int, Uint32, IntPtr??
Any help would be greatly appreciated.
Steve
|
|
|
|
|
Did I create a tough question?
Does anyone know what to Marshal the BYTE * to on the C# side?
|
|
|
|
|
i've tried everything i can think of, but can't seem to capture a double-click in my CSliderCtrl-derived class.
i've tried ON_WM_LBUTTONDBLCLK, ON_WM_NCLBUTTONDBLCLK, PreTranslateMessage and even WindowProc , but none of them respond to double-clicks.
i've looked at the source for the control, but there's not much there (it's a common ctrl, so the bulk of the implementation is probably in COMCTRL32.DLL).
so, anyone else ever managed to capture dblclicks on a slider ?
Image Toolkits | Image Processing | Cleek
|
|
|
|
|
I want to create a submenu which uses the case statements. So my problem is the program crushes and i can't get the logic how i can arrange the case statements. Please help me, i am already under pressure because of time.
I want the program run such that if i enter option 1 it create a process and then produce which i can now suspend the process from there or shut it down in the submenu
Here is my code
<br />
#include <windows.h><br />
#include <stdio.h><br />
#include <windef.h><br />
#include <winbase.h><br />
#include <imagehlp.h><br />
#include <stdlib.h><br />
#include <ctype.h><br />
typedef struct _iobuf FILE;<br />
#include <assert.h><br />
#include <sys/types.h><br />
#include <sys/stat.h><br />
<br />
int menu(void)<br />
{<br />
char iobuf[80];<br />
int choice;<br />
int i,len,valid;<br />
printf ("\n");<br />
printf ("*****************************************\n");<br />
printf ("*\t\t\t\t\t*\n*\tPROCESS CREATION \t\t*\n");<br />
printf ("=========================================");<br />
printf ("\n=\t 1: Create a process \t\t=");<br />
printf ("\n=\t 2: Quit the system\t\t=");<br />
printf ("\n=========================================\n");<br />
valid=0;<br />
printf("\nEnter choice (1-3): ");<br />
<br />
while( valid == 0)<br />
{<br />
fgets(iobuf,sizeof(iobuf),stdin);<br />
len = strlen(iobuf)-1;<br />
iobuf[len] = 0;<br />
valid = 1;
for(i = 0; i < len; i++)<br />
{<br />
if( !isdigit(iobuf[i]))<br />
{<br />
printf("\nPlese enter numeric digits only (1-5)\n");<br />
valid = 0;<br />
}<br />
}<br />
}<br />
choice = atoi(iobuf);<br />
<br />
return choice; <br />
}<br />
<br />
int submenu(void)<br />
{<br />
char iobuf[80];<br />
int choice2;<br />
int i,len,valid;<br />
<br />
PROCESS_INFORMATION pi; <br />
STARTUPINFO si; <br />
HANDLE hProcess;<br />
DWORD lpAddr = 0;<br />
TCHAR lpApplicationName[_MAX_PATH]=""; <br />
int result;<br />
char ans [4]="";<br />
<br />
printf ("\n*****************************************\n");<br />
printf ("*\t\t\t\t\t*\n*\tPROCESS CREATION \t\t*\n");<br />
printf ("=========================================");<br />
printf ("\n=\t 1: Suspend the process\t\t=");<br />
printf ("\n=\t 2: Resume process \t=");<br />
printf ("\n=\t 3: Shutdown the process \t=");<br />
printf ("\n=\t 4: Exit the system \t=");<br />
printf ("\n=========================================\n");<br />
printf ("\n");<br />
valid=0;<br />
printf("\nEnter choice (1-4): "); <br />
while( valid == 0)<br />
{<br />
fgets(iobuf,sizeof(iobuf),stdin);<br />
len = strlen(iobuf)-1;<br />
iobuf[len] = 0;<br />
valid = 1;
for(i = 0; i < len; i++)<br />
{<br />
if( !isdigit(iobuf[i]))<br />
{<br />
printf("\nPlese enter numeric digits only (1-4)\n");<br />
valid = 0;<br />
}<br />
}<br />
}<br />
while((choice2 = submenu())!=3)
{<br />
switch (choice2)<br />
{<br />
case 1:<br />
SuspendThread(pi.hThread);
break;<br />
case 2:<br />
ResumeThread(pi.hThread); <br />
break;<br />
case 3:<br />
printf("\nYou are about to terminate a running process, do you want to continue ( y or n) ");<br />
scanf ("%s",ans); <br />
result = strcmp(ans,"y");<br />
if (result==0)<br />
{<br />
TerminateProcess(pi.hThread, 0);
GetLastError();<br />
}<br />
break;<br />
default: printf("Invalid choice: ");<br />
<br />
}}<br />
choice2 = atoi(iobuf);<br />
return choice2; <br />
valid = 0;<br />
}
<br />
int main(int argc, char **argv) <br />
{<br />
PROCESS_INFORMATION pi; <br />
STARTUPINFO si; <br />
HANDLE hProcess;<br />
DWORD lpAddr = 0;<br />
TCHAR lpApplicationName[_MAX_PATH]=""; <br />
int result;<br />
char ans [4]="";<br />
int choice;<br />
while((choice = menu())!=6)
{<br />
switch (choice)<br />
{<br />
case 1: <br />
GetStartupInfo(&si);<br />
lpAddr = 0;<br />
ZeroMemory( &si, sizeof(si) );<br />
si.cb = sizeof(si);<br />
ZeroMemory( &pi, sizeof(pi) );<br />
printf("Enter process you want to execute: ",lpApplicationName);<br />
scanf ("%s",lpApplicationName);<br />
printf("Process %d reporting for creation\n",GetCurrentProcessId());
<br />
CreateProcess(NULL, <br />
lpApplicationName, <br />
NULL, <br />
NULL, <br />
FALSE, <br />
CREATE_NEW_CONSOLE, <br />
NULL, <br />
NULL, <br />
&si, <br />
&pi <br />
); <br />
hProcess = pi.hProcess;<br />
printf("New Process ID: %d ",pi.dwProcessId);<br />
submenu();<br />
<br />
break;<br />
case 2:<br />
printf("\n\tAre you sure you want to quit the system!(y or n) ");<br />
scanf ("%s",ans);<br />
<br />
result = strcmp(ans,"y");
<br />
if (result==0)<br />
<br />
{<br />
TerminateProcess(pi.hProcess, 0);
GetLastError();<br />
exit(EXIT_SUCCESS);
}GetLastError(); <br />
break; <br />
default:<br />
printf("\nInvalid choice: ");<br />
}<br />
}<br />
return (0);<br />
}<br />
|
|
|
|
|
I still think that you should have gone with my suggestion - which was to have one menu and only show valid options.
Where does it crash ? Perhaps if you posted the full code ( at the moment, what you're including is missing ), someone will post it into a project and try to work out what's going wrong, but it would be more helpful if you told us.
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
Well i wanted to go with your suggestion but then i have the program crushing and i have already intergrated my code it is now large. But even the submenu one that i am thinking above cannot confuse user's of the system if it is used.
-oam-
|
|
|
|
|
First trick of programming - if it crashes, work out why, don't just change to a lesser design
To reiterate - where/why does it crash ? I assume that crush == crash ?
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
Christian Graus wrote:
First trick of programming - if it crashes, work out why, don't just change to a lesser design
Yes i am working on it day and night but now i am under presure as i have to submit this tommorrow.
<br />
#include <windows.h><br />
#include <stdio.h><br />
#include <windef.h><br />
#include <winbase.h><br />
#include <stdlib.h><br />
typedef struct _iobuf FILE;<br />
#include <assert.h><br />
#include <sys/types.h><br />
#include <sys/stat.h><br />
#include <string.h><br />
<br />
int menu(void)<br />
{<br />
char iobuf[80];<br />
int i,len,valid;<br />
HANDLE hProcess;<br />
<br />
printf ("\n");<br />
printf ("\t\t\t*****************************************\n");<br />
printf ("\t\t\t*\t\t\t\t\t*\n\t\t\t*\t\tPROCESS\t\t\t*\n");<br />
printf ("\t\t\t*\t\t\t\t\t*\n\t\t\t* CHECKPOINTING AND MIGRATION SYSTEM\t*\n");<br />
printf ("\t\t\t*\t\t\t\t\t*\n");<br />
printf ("\t\t\t=========================================");<br />
printf ("\n\t\t\t=\t 1: Create a Process \t=");<br />
printf ("\n\t\t\t=\t 2: Suspend Process \t=");<br />
printf ("\n\t\t\t=\t 3: Resume Process \t=");<br />
printf ("\n\t\t\t=\t 4: Shutdown Process\t\t=");<br />
printf ("\n\t\t\t=\t 5: Checkpoint Process\t\t=");<br />
printf ("\n\t\t\t=\t 6: Restart Process\t\t=");<br />
printf ("\n\t\t\t=\t 7: Help \t\t\t=");<br />
printf ("\n\t\t\t=\t 8: Quit the system\t\t=");<br />
printf ("\n\t\t\t=========================================\n");<br />
printf ("\n");<br />
<br />
printf("\n\t\t\tEnter choice (1-8): ");<br />
<br />
valid = 0;<br />
while( valid == 0)<br />
{<br />
fgets(iobuf,sizeof(iobuf),stdin);<br />
<br />
len = strlen(iobuf)-1;<br />
iobuf[len] = 0;
valid = 1;
for(i = 0; i < len; i++)
{<br />
if( !isdigit(iobuf[i]))<br />
{<br />
printf("\n\t\t\tPlese enter numeric digits only (1-8):");<br />
valid = 0; <br />
}<br />
}<br />
}
<br />
hProcess = atoi(iobuf);<br />
return hProcess;<br />
<br />
}
<br />
<br />
HWND g_hWnd = NULL;<br />
<br />
BOOL CALLBACK EnumWindowsProc(HWND hwnd,LPARAM lParam)<br />
{<br />
DWORD dwProcID;<br />
GetWindowThreadProcessId(hwnd,&dwProcID);<br />
if(dwProcID == (DWORD)lParam)<br />
{<br />
g_hWnd = hwnd;<br />
}<br />
<br />
return TRUE;<br />
}<br />
int main(int argc, char **argv) <br />
{<br />
<br />
FILE* fp;<br />
char ans[4];<br />
int result;<br />
<br />
PROCESS_INFORMATION pi; <br />
STARTUPINFO si; <br />
HANDLE hProcess;<br />
HANDLE hThread = 0;<br />
DWORD NumberOfBytesRead = 0;<br />
BYTE buf[20000];<br />
DWORD bufsize = sizeof buf;<br />
DWORD baseaddr = 0;<br />
DWORD lpAddr = 0;<br />
PMEMORY_BASIC_INFORMATION lpBuffer = 0;<br />
DWORD dwLength = 200000;<br />
DWORD flNewProtect =0;<br />
PDWORD lpflOldProtect = 0;<br />
DWORD dwSize =0;<br />
LPCVOID lpBaseAddress = 0;<br />
DWORD nSize = 0;<br />
MEMORY_BASIC_INFORMATION mbi;<br />
LPDWORD lpNumberOfBytesWritten = 0;<br />
TCHAR lpApplicationName[_MAX_PATH]="";<br />
SYSTEM_INFO sinfo;<br />
LPDWORD lpExitCode = 0;<br />
DWORD pid;<br />
LPVOID base;<br />
HWND hWnd = 0;<br />
DWORD dwProcessID = 0;<br />
UINT GetBase();<br />
LPCONTEXT lpContext = 0;<br />
PHANDLE TokenHandle =0;<br />
BOOL OpenAsSelf=0;<br />
DWORD DesiredAccess=0;<br />
HANDLE ThreadHandle=0;<br />
DWORD dwDesiredAccess = 0;<br />
BOOL bInheritHandle = 0;<br />
DWORD dwThreadId = 0;<br />
<br />
<br />
LPSECURITY_ATTRIBUTES lpThreadAttributes = 0;<br />
DWORD dwStackSize = 0;<br />
LPTHREAD_START_ROUTINE lpStartAddress = 0;<br />
LPVOID lpParameter = 0;<br />
DWORD dwCreationFlags = 0;<br />
LPDWORD lpThreadId = 0;<br />
int nRet = 0;<br />
char *state;<br />
unsigned int regnum = 0;<br />
BOOL OpenThread();<br />
int choice;<br />
<br />
while((choice = menu())!=9)<br />
{<br />
switch (choice)<br />
{ <br />
case 1:<br />
<br />
GetSystemInfo(&sinfo);<br />
lpAddr = 0;<br />
ZeroMemory( &si, sizeof(si) );<br />
si.cb = sizeof(si);<br />
ZeroMemory( &pi, sizeof(pi) );<br />
<br />
printf("\t\t\tEnter process you want to execute: ",lpApplicationName);<br />
scanf ("%s",lpApplicationName);<br />
<br />
GetStartupInfo(&si);<br />
<br />
CreateProcess(NULL, <br />
lpApplicationName, <br />
NULL, <br />
NULL, <br />
FALSE, <br />
CREATE_NEW_CONSOLE, <br />
NULL, <br />
NULL, <br />
&si, <br />
&pi <br />
);<br />
<br />
hProcess = pi.hProcess; <br />
<br />
pid = atoi(lpApplicationName);<br />
<br />
if ((hProcess = OpenProcess(PROCESS_QUERY_INFORMATION, FALSE, pi.dwProcessId)) == NULL) <br />
<br />
printf("\t\t\tUnable to open process, the process does not exist!\n");<br />
<br />
VirtualProtectEx(<br />
hProcess,
&lpAddr,
dwSize,
flNewProtect,
lpflOldProtect );
<br />
<br />
<br />
<br />
break;<br />
case 2:<br />
<br />
<br />
<br />
SuspendThread(pi.hThread);
<br />
printf("\n\t\tThe thread of ID: %d",pi.dwProcessId);<br />
printf("\t\t has been suspended!\n");<br />
GetLastError();<br />
<br />
GetThreadContext(<br />
hProcess,
lpContext
);<br />
GetLastError();<br />
<br />
<br />
<br />
<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 />
break;<br />
<br />
case 3:<br />
<br />
ResumeThread(pi.hThread);// identifies thread to restart<br />
GetLastError(); <br />
// return ResumeThread(pi.hThread);<br />
<br />
break;<br />
<br />
case 4:<br />
printf("\n\t\t\tYou are about to terminate a running process, do you want to continue ( y or n) ");<br />
scanf ("%s",ans);<br />
<br />
result = strcmp(ans,"y");<br />
<br />
if (result==0)<br />
<br />
TerminateProcess(pi.hProcess, 0);//identifies the process to terminate<br />
GetLastError();<br />
<br />
break;<br />
<br />
case 5://checkpointing<br />
<br />
SuspendThread(pi.hThread);// identifies thread to suspend<br />
<br />
printf("\n\t\tThe thread of ID: %d",pi.dwProcessId);<br />
printf(" \t\thas 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 />
ZeroMemory(buf, sizeof(buf));<br />
if( ReadProcessMemory( hProcess, //handle to the process to be suspended<br />
&baseaddr, //address to start reading<br />
&buf, //buffer where to place data to<br />
bufsize, //size of the buffer<br />
NULL ) == FALSE )<br />
/*{<br />
printf("\nProcess memory read failed", GetLastError());<br />
_exit(1);<br />
}<br />
else<br />
{<br />
printf("\nProcess memory read: \n",buf);<br />
}*/<br />
<br />
//fp = fopen(f"checkpoint.bin","w");<br />
//if( fp )<br />
<br />
//printf("Enter the file-name to save the Memory Information: ",fname);<br />
//scanf ("%s",fname);<br />
<br />
regnum = 0;<br />
base = 0;<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 />
printf("\n\t\tREGION #%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 />
/*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 />
break;<br />
<br />
case 6://restarting the process using information from the file<br />
<br />
lpBaseAddress = 0;<br />
hProcess = mbi.BaseAddress;<br />
<br />
SetThreadContext( <br />
hThread, <br />
lpContext <br />
); <br />
GetThreadContext(<br />
hThread, // handle to thread with context<br />
lpContext // address of context structure<br />
);<br />
//fp = fopen("info.bin","r");<br />
//if( fp )<br />
nSize = 10000; //numbers of bytes in the file<br />
<br />
lpBuffer = buf; //pointer to the file where data is to be read<br />
<br />
WriteProcessMemory(<br />
hThread, // handle to process whose memory is written to<br />
lpBaseAddress, // address to start writing to--dwDesiredAccess<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 />
printf("Numbers of bytes written: ",lpNumberOfBytesWritten);<br />
CreateThread(<br />
lpThreadAttributes, // pointer to security attributes<br />
dwStackSize, // initial thread stack size<br />
lpStartAddress, // pointer to thread function<br />
lpParameter, // argument for new thread<br />
dwCreationFlags, // creation flags<br />
lpThreadId // pointer to receive thread ID<br />
);<br />
<br />
ResumeThread(hThread);// identifies thread to restart(dwDesiredAccess)<br />
GetLastError();<br />
break;<br />
<br />
case 7:<br />
<br />
printf ("\n");<br />
printf ("\t\t\t*****************************************\n");<br />
printf ("\t\t\t*\t\t\t\t\t*\n\t\t\t*\t\tPROCESS\t\t\t*\n");<br />
printf ("\t\t\t*\t\t\t\t\t*\n\t\t\t* CHECKPOINTING AND MIGRATION SYSTEM\t*\n");<br />
printf ("\t\t\t*\t\t\t\t\t*\n");<br />
printf ("\t\t\t=========================================\n\n");<br />
printf ("\t\t\t<<>>Create a Process:<<>>\n");<br />
printf ("\t\t\tThis option is used to create an executable file specified\<br />
by the user.\n");<br />
printf ("\t\t\tThe file should be in the same directory of the systemt\<br />
or it should and executable file from Windows system directory\n");<br />
printf ("\t\t\t-------------------------------------------------------------\n\n");<br />
printf ("\t\t\t<<>>Stop Process:<<>>\n");<br />
printf ("\t\t\tThe SuspendThread function suspends the specified thread \n");<br />
<br />
printf ("\t\t\t<<>>The ResumeThread:<<>> \n");<br />
printf ("\t\t\tThe function decrements a thread's suspend count. \n");<br />
printf ("\t\t\tWhen the suspend count is decremented to zero, the execution of\<br />
the thread is resumed.\n");<br />
printf ("\t\t\t----------------------------------------------------------------\n\n");<br />
printf ("\t\t\t<<>>Shutdown:<<>> \n");<br />
printf ("\t\t\tThe option terminates the process, and exits with the supplied\<br />
status code.\n");<br />
<br />
printf ("\t\t\t<<>>checkpoint:<<>> \n");<br />
printf ("\t\t\tThis option stops a process and save its state in a file \n");<br />
<br />
printf ("\t\t\t<<>>Restart:<<>> \n");<br />
printf ("\t\t\tThis option restarts the execution of the process from where it left\n");<br />
printf ("\t\t\toff when it was checkpointed\n");<br />
printf ("\t\t\t------------------------------------------------------------------\n\n");<br />
printf ("\t\t\t<<>>Help:<<>> \n");<br />
printf ("\t\t\tGives information about how different options do in the system\n");<br />
<br />
printf ("\t\t\t<<>>Quit:<<>> \n");<br />
printf ("\t\t\tThis option quites the whole system. If there are any running\<br />
processes it will also terminate them while they are still running\n");<br />
<br />
printf ("\t\t\t------------------------------------------------------------------\n");<br />
&sinfo;<br />
<br />
break;<br />
<br />
case 8:<br />
printf("\n\t\t\tAre you sure you want to quit the system!(y or n) ");<br />
scanf ("%s",ans);<br />
<br />
result = strcmp(ans,"y"); //comparing the input and y to quit<br />
<br />
if (result==0)<br />
<br />
{<br />
TerminateProcess(pi.hProcess, 0);//identifies the process to terminate<br />
GetLastError();<br />
exit(EXIT_SUCCESS);//exiting the console<br />
}GetLastError(); <br />
break;<br />
<br />
default: printf("\n\t\t\tYou have entered an invalid choice, check the menu below: \n");<br />
GetLastError(); <br />
}//switch<br />
} //while base <br />
fclose(fp); <br />
return(0);<br />
}<br />
-oam-
|
|
|
|
|
I keep hoping that at some point you will either check the 'Do not treat <'s as HTML tags' box so that your includes come out in your post, or you'll stop just posting all the code over and over, and actually tell us what's going wrong/what error messages you get/etc.
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|