• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1045
  • Last Modified:

vb6 getprocess list processes has ? marks in some processes

This code is listing some processes as C:\windows\system32\??xplore.exe

Have been fighting this for months would greatly appreciate a solution!!!

where the heck is it getting the ? marks

Option Explicit
Dim uProcess As PROCESSENTRY32

Global AllCurrentProcs As New Collection
Global AllCurrentProcsPID As New Collection
Global AllCurrentProcsEXE As New Collection
Dim JustEXE As String
Dim I As Long

Public Declare Function CloseHandle Lib "Kernel32.dll" (ByVal Handle As Long) As Long
Public Declare Function OpenProcess Lib "Kernel32.dll" (ByVal dwDesiredAccessas As Long, ByVal bInheritHandle As Long, ByVal dwProcId As Long) As Long
Public Declare Function EnumProcesses Lib "psapi.dll" (ByRef lpidProcess As Long, ByVal cb As Long, ByRef cbNeeded As Long) As Long
Public Declare Function GetModuleFileNameExA Lib "psapi.dll" (ByVal hprocess As Long, ByVal hModule As Long, ByVal ModuleName As String, ByVal nSize As Long) As Long
Public Declare Function GetProcessImageFileNameA Lib "psapi.dll" (ByVal hprocess As Long, ByVal ModuleName As String, ByVal nSize As Long) As Long
Public Declare Function EnumProcessModules Lib "psapi.dll" (ByVal hprocess As Long, ByRef lphModule As Long, ByVal cb As Long, ByRef cbNeeded As Long) As Long
Public Declare Sub ExitProcess Lib "kernel32" (ByVal uExitCode As Long)

Public Sub GetProcesses()
   Dim lProcCount     As Long
   Dim lProcPoss      As Long
   Dim lNum           As Long
   Dim ProcessIDs()   As Long
   Dim cbNeeded2      As Long
   Dim NumElements2   As Long
   Dim hModule        As Long
   Dim lRet           As Long
   Dim sModName       As String
   Dim hwndProcess    As Long
   Dim iCounter       As Long

   Const SIZE = 500
   Const PROCESS_VM_READ = 16
   'Clear the Collections
   Set AllCurrentProcs = New Collection
   Set AllCurrentProcsPID = New Collection
   Set AllCurrentProcsEXE = New Collection

   'need to get the array containing the process id's for each process object

   lProcCount = 8
   lProcPoss = 96
   Do While lProcCount <= lProcPoss
       lProcCount = lProcCount * 2
       ReDim ProcessIDs(lProcCount / 4) As Long
       lRet = EnumProcesses(ProcessIDs(1), lProcCount, lProcPoss)
   lNum = lProcPoss / 4
   For iCounter = 1 To lNum
       'Get a handle to the Process
       hwndProcess = OpenProcess(PROCESS_QUERY_INFORMATION Or PROCESS_VM_READ, 0, ProcessIDs(iCounter))
       'Got a Process handle
       If hwndProcess = 0 Then
           GoTo SkipHost
           sModName = Space(SIZE)
           lRet = EnumProcessModules(hwndProcess, hModule, 4, cbNeeded2)
           sModName = Space(SIZE)
           lRet = GetModuleFileNameExA(hwndProcess, hModule, sModName, SIZE)
           sModName = Left(sModName, lRet)

           If sModName = "" Then
               GoTo SkipHost
           End If
           'Lower case it
           sModName = LCase(sModName)
  • 3
  • 2
1 Solution
That's a known defect in GetModuleFileNameEx().

Fortunately, the defect is well behaved.  

As far as I know, the \??\ appears only on winlogon.exe and can safely be removed.

Another one you didn't mention is \SystemRoot\System32\smss.exe.
The \SystemRoot\ should be erplaced with the return from GetWindowsDirectory().

The cause?  Unknown outside of an embarrassed MS testing cadre, but likely just old NT code that has hung on to life.

bluedragon99Author Commented:
getting this one to C:\windows\system32\??xplore.exe

what replacement code would you suggest?
bluedragon99Author Commented:
bluedragon99Author Commented:
thanks cookre
Brain dead me.  I just say the GetModuleFileNameEx() and the ?? and plopped in the known problem.  

Which OS is giving you the flakey iexplore?  
Your code worked fine (for iexplore) on my XP box.

Aside from the ones already mentioned, are you getting any other diddled names?

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now