Click here to Skip to main content
16,005,120 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
Questionwindow hook uninstalled? Pin
outoolcoe27-Apr-05 17:27
outoolcoe27-Apr-05 17:27 
GeneralNeed Your Help!!!! Pin
Jack.Fu27-Apr-05 16:31
Jack.Fu27-Apr-05 16:31 
GeneralRe: Need Your Help!!!! Pin
mkuhac27-Apr-05 17:17
mkuhac27-Apr-05 17:17 
GeneralRe: Need Your Help!!!! Pin
Jack.Fu27-Apr-05 17:36
Jack.Fu27-Apr-05 17:36 
GeneralRe: Need Your Help!!!! Pin
Rage27-Apr-05 22:36
professionalRage27-Apr-05 22:36 
GeneralRe: Need Your Help!!!! Pin
ThatsAlok27-Apr-05 23:07
ThatsAlok27-Apr-05 23:07 
Generalimport TStringGrid component to MFC Pin
27-Apr-05 15:51
suss27-Apr-05 15:51 
QuestionCan Use VirtualAllocEx( ) to Get Memory from Other Process? Pin
macauit27-Apr-05 14:49
macauit27-Apr-05 14:49 
MSDN says we can use VirtualAllocEx() to obtain memory from another process.
When I testify this, VirtualAllocEx(MEM_RESERVER|MEM_COMMIT) succeeded,
but when I tried to write to the buffer, most often it caused GPF!

Here is my sample codes:
// Create a child process and obtain its handle.
// Use the handle to allocate memory with VirtualAllocEx().
// Then use the return buffer to do data copying, etc...
-----------------------------------------------------------------
...
CreateProcess( OtherProcess, NULL,NULL, NULL, TRUE, CREATE_SUSPENDED , NULL, NULL, &si, &pi );

pBase = (char*) VirtualAllocEx ( pi.hProcess, NULL, iSize, MEM_RESERVE, PAGE_NOACCESS );

pBuffer = (char*) VirtualAllocEx ( pi.hProcess, pBase, iSize, MEM_COMMIT, PAGE_READWRITE);

ZeroMemory( temp, iSize); // *** Add this line causes GPF at the end of the program***

VirtualFreeEx( pi.hProcess, pBase, 0, MEM_DECOMMIT);
VirtualFreeEx( pi.hProcess, pBase, 0, MEM_RELEASE);
.....
ResumeThread( (HANDLE ) pi.hThread);
CloseHandle( pi.hProcess );
CloseHandle( pi.hThread );
...
-----------------------------------------------------------------

It seemed everything were OK as all the function calls all succeeded.
However, the program could encounter GPF upon end of main().

Obviously it was caused by the ZeroMemory() write action.
If no write action was performed, then no problem arised.
And if only wrote few hundread bytes to the return buffer, it could have no problem either.

I think I could have make some mistakes here but I still couldn't find out the reason after carefully examining all the possibilities.

Can somebody give me insight on this!
Other than FileMapping or WM_COPYDATA,
I really want to use another approach like VirtualAllocEx() to share data among different processes.


Thanks for help.


AnswerRe: Can Use VirtualAllocEx( ) to Get Memory from Other Process? Pin
Ryan Binns27-Apr-05 19:15
Ryan Binns27-Apr-05 19:15 
AnswerRe: Can Use VirtualAllocEx( ) to Get Memory from Other Process? Pin
stolid_rock27-Apr-05 19:21
stolid_rock27-Apr-05 19:21 
GeneralCannot find file bug Pin
Jorgen E.27-Apr-05 13:21
Jorgen E.27-Apr-05 13:21 
Generalinitializing pointers / handles Pin
mkuhac27-Apr-05 12:52
mkuhac27-Apr-05 12:52 
GeneralRe: initializing pointers / handles Pin
Ryan Binns27-Apr-05 19:17
Ryan Binns27-Apr-05 19:17 
GeneralPlugin doesnt detect *.html, Netscape Pin
shaikh_zuber27-Apr-05 12:10
shaikh_zuber27-Apr-05 12:10 
GeneralLinking Problem !! Something to do with Multi-threading Pin
Mohammad Tarik27-Apr-05 11:58
Mohammad Tarik27-Apr-05 11:58 
GeneralRe: Linking Problem !! Something to do with Multi-threading Pin
Taka Muraoka27-Apr-05 21:17
Taka Muraoka27-Apr-05 21:17 
GeneralRe: Linking Problem !! Something to do with Multi-threading Pin
Mohammad Tarik28-Apr-05 0:01
Mohammad Tarik28-Apr-05 0:01 
GeneralInternet Explorer as an activex control Pin
Jörgen Sigvardsson27-Apr-05 11:34
Jörgen Sigvardsson27-Apr-05 11:34 
GeneralRe: Internet Explorer as an activex control Pin
Michael Dunn27-Apr-05 12:06
sitebuilderMichael Dunn27-Apr-05 12:06 
GeneralRe: Internet Explorer as an activex control Pin
Jörgen Sigvardsson27-Apr-05 12:21
Jörgen Sigvardsson27-Apr-05 12:21 
GeneralRe: Internet Explorer as an activex control Pin
Jörgen Sigvardsson27-Apr-05 12:37
Jörgen Sigvardsson27-Apr-05 12:37 
GeneralRe: Internet Explorer as an activex control Pin
Michael Dunn28-Apr-05 5:36
sitebuilderMichael Dunn28-Apr-05 5:36 
Generalsimple equation problem Pin
CNewbie27-Apr-05 9:30
CNewbie27-Apr-05 9:30 
GeneralRe: simple equation problem Pin
Ravi Bhavnani27-Apr-05 9:35
professionalRavi Bhavnani27-Apr-05 9:35 
GeneralRe: simple equation problem Pin
CNewbie27-Apr-05 9:41
CNewbie27-Apr-05 9:41 

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.