Click here to Skip to main content
15,887,746 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
Hi all,
I'm currently facing an interesting problem to determine the path of a process on WOW64.

The usual approaches via GetModuleFileName or Module32First / Module32Next on a snapshot
are failing with the error ERROR_PARTIAL_COPY. Several pages on the internet advises
to use Get GetProcessImageFileName. This command works, but the result is rather
the device name as the path on the file system (e.g. \Device\Harddisk1\DP(1)0-0+4\myprocess.exe
for a process launched on a mounted USB stick).

This brings me to the task how to convert the device information to a path on the file
system. The usual adviced approach is to determine all mapped drive letters by
GetLogicalDriveStrings and determine their path by QueryDosDevice. Of course this is
only half of the story since you also have to be aware for mounted devices (like my
USB stick above), UNC network paths (e.g \\mycomputer\myshare\... ) and maybe more
other ways to mount devices on a file system.

This brings me to my ultimate :) questions:
- Is there any general way to query for a device mapping in the file system except
from testing for all the different ways (drive letters, mounted devices,
network mapping etc)?

- What is the deeper meaning of the GetProcessImageFileName in the user mode?
in case the GetModuleFileName would work, I currently see no sense of this command
if you are not coding in the kernel mode. Maybe somebody as a clue on this.
Posted

For your first question I can give you one suggestion.
You use the Winodws Platform SDK and use the SetUpDiXXXX APIs
for device mapping in the file system.
 
Share this answer
 
Thanks a lot for this hint, but it looks like I don't manage to retreive the required information. I am able to iterator over all devices and access their properties and by this the physical device object name. This helps me to find the handle to the correct device, but I still fail to determine the mount point (e.g. c:\mount for my USB example above.

I worked through the example of the Simple Device Manager[]and How to Prepare a USB Drive for Safe Removal[^] but I was not able to find the missing link for my application.

I you have any further hints how to do this via the Device Installation Functions I would be glad to hear more about that.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900