GetMappedFileName

new_learner0

Member
Joined
May 3, 2011
Messages
7
Programming Experience
Beginner
Hi All,
I am trying to convert a code from C to VB.NET.

I have a function with the following declaration -

Declare Function GetMappedFileName Lib "psapi" (ByVal hProcess As IntPtr, ByVal lpv As IntPtr, <Out()> ByRef lpFilename As String, ByVal nSize As Long) As Long
I am calling the function as follows -
GetMappedFileName(handle, Address, MappedFile, Marshal.SizeOf(MappedFile))
where MappedFile is declared as -

Dim MappedFile As String = ""
MappedFile does not return anything. Any help will be appreciated.
 
Maybe try passing a string builder instead of a string:

VB.NET:
Dim MappedFile as StringBuilder = New StringBuilder(x)

Where x is the size that you want your string buffer to be, not sure if that will work or not but I remember there being something you need to do when you pass strings to some of the win32 API.
 
I saw you posted this on MSDN forum as well did the link they provided for you on there have any thing good in it? I saw some csharp code

Also, What is in the address variable?

Taken from: (visual fox pro sample) http://www.news2news.com/vfp/?group=-1&function=880

Parameters:
hProcess
[in] Handle to the process.
lpv
[in] Address to be verified.
lpFilename
[out] Pointer to the buffer that receives the name of the memory-mapped file to which the address specified by lpv belongs.
nSize
[in] Size of the lpFilename buffer, in characters.
 
I am trying to traverse the memory addresses for a process. Address variable contains the value of the memory address at that particular iteration (only if that part of memory is expected to contain a file).
 
This is a tough one here is my last shot at it, anytime I worked with the win32 api on a new call I would have to play around a bunch until I found something that worked:

VB.NET:
MappedFile = Space(255)
 
Back
Top