473,396 Members | 1,886 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

can not get MEMORY_BASIC_INFORMATION

hi,
I want to get some memory information.
the following codes are in a win32 DLL.
---------------------------------------------------------------------------------
MEMORY_BASIC_INFORMATION mbi;
memset(&mbi, 0, sizeof(MEMORY_BASIC_INFORMATION));
DWORD dwOldProtect = 0;
HMODULE h;

/* the "pv" is a DWORD address ,for example,DWORD pv=0xf8003400,it's
an
address of code instruction or a function return address*/

VirtualProtect((LPVOID)pv,sizeof(HANDLE),PAGE_READ WRITE,&dwOldProtect);

if(VirtualQuery((LPVOID)pv,&mbi,sizeof(MEMORY_BASI C_INFORMATION))!=0)
h=(HMODULE)mbi.AllocationBase;
----------------------------------------------------------------------------------

the values of "mbi" are all zero,it does not get any
information.VirtualProtect() return false and VirtualQuery()return 0.
MSDN
said if the pv address is kernel mode,the latter function will return
0.but
the address is just a normal one in an MFC supported DLL which is in
the
same process with my DLL.
Why do they fail?

could anyone help me to figure out the reason and solution? thank you.

regards,
Ryan
Jun 27 '08 #1
1 2068
Ryanivanka wrote:
hi,
I want to get some memory information.
the following codes are in a win32 DLL.
------------------------------------------------------------------------------
---
MEMORY_BASIC_INFORMATION mbi;
memset(&mbi, 0, sizeof(MEMORY_BASIC_INFORMATION));
DWORD dwOldProtect = 0;
HMODULE h;

/* the "pv" is a DWORD address ,for example,DWORD pv=0xf8003400,it's
an
address of code instruction or a function return address*/

VirtualProtect((LPVOID)pv,sizeof(HANDLE),PAGE_READ WRITE,&dwOldProtect);

if(VirtualQuery((LPVOID)pv,&mbi,sizeof(MEMORY_BASI C_INFORMATION))!=0)
h=(HMODULE)mbi.AllocationBase;
------------------------------------------------------------------------------
----
>
the values of "mbi" are all zero,it does not get any
information.VirtualProtect() return false and VirtualQuery()return 0.
MSDN
said if the pv address is kernel mode,the latter function will return
0.but
the address is just a normal one in an MFC supported DLL which is in
the
same process with my DLL.
Why do they fail?

could anyone help me to figure out the reason and solution? thank you.

regards,
Ryan
What's the result of GetLastError after the failed call to VirtualProtect?

--
Cholo Lennon
Bs.As.
ARG

Jun 27 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: patelj27b | last post by:
Hey There, I am trying to read the memory of the text region of a running process. I can open a process and read the data in the process using OpenProcess and ReadProcessMemory. I'm not sure...
25
by: mdh | last post by:
Hi Group, Not looking for an answer, but more of an explanation. Thinking back to those heady days when you had the time to do them, may I ask this. Exercise 1-22 asks for a program to "fold"...
1
by: Scott McFadden | last post by:
Is there a Win32 call for retrieving the path for which the current / active DLL was loaded (I don't care to use GetModuleName as it only gives me the path to the host process EXE). thanks ...
4
by: =?Utf-8?B?U2VyZ2Vp?= | last post by:
Dear staff Can I get your assistance with \3GB (LARGEADDRESSAWARE) switch in mixed mode process built by VS 2008, please? I have a mixed mode application: C# GUI calling native C++ DLL through...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.