Read process information. Win32Exception ERROR_PARTIAL_COPY

0

I want to get the process id of Microsoft Movies & TV (Video.UI.exe).

When I loop through all the processes to check if the file name contains Video.UI.exe I get a lot of Win32Exceptions which I expected. I thought so. I only expected NativeErrorCode 0x00000005 'Access denied' because I'm not simply not allowed. But I get a lot of 0x0000012B 'ERROR_PARTIAL_COPY' exceptions and I don't know why. I tried to create an error repro inside of a console app but there I don't get the error. I made sure to use the same relevant code. Also both applications (the main WinForms app and the console error repro) have the same manifest containing: <requestedExecutionLevel level="requireAdministrator" uiAccess="false" />

Here is the relevant code:

foreach (Process p in Process.GetProcesses()) {
    try {
        if (p.MainModule.FileName.Contains(modelId))
            Console.WriteLine(string.Format("Match: {0} {1}", p.Id, p.MainModule.FileName));
        else
            if (p.MainModule.FileName.Contains("WindowsApps") && p.MainModule.FileName.Contains("Video.UI.exe"))
                Console.WriteLine(string.Format("Match: {0} {1}", p.Id, p.MainModule.FileName));
    }
    catch (Win32Exception e) {
        Console.WriteLine(string.Format("{0,-20}{1}", p.ProcessName, e.NativeErrorCode));
    }
}

Console Output:

csrss                                   5
svchost                                 5
csrss                                   5
wininit                                 5
SgrmBroker                              5
svchost                                 5
NisSrv                                  5
MsMpEng                                 5
svchost                                 5
Match: 4944 C:\Program Files\WindowsApps\Microsoft.ZuneVideo_10.20112.10111.0_x64__8wekyb3d8bbwe\Video.UI.exe
Memory Compression                      5
Registry                                5
smss                                    5
SecurityHealthService                   5
ScriptedSandbox64                       299
services                                5
System                                  -2147467259
Idle                                    -2147467259

WinForm App Trace output (Exception thrown... lines removed):

rundll32 299
svchost                                 299
csrss                                   5
svchost                                 299
svchost                                 299
svchost                                 299
chrome                                  299
conhost                                 299
svchost                                 299
svchost                                 5
conhost                                 299
svchost                                 299
conhost                                 299
ServiceHub.RoslynCodeAnalysisService    299
steamwebhelper                          299
svchost                                 299
dwm                                     299
svchost                                 299
ShinraMeter                             299
svchost                                 299
SearchIndexer                           299
svchost                                 299
chrome                                  299
Microsoft.ServiceHub.Controller         299
svchost                                 299
svchost                                 299
svchost                                 299
RuntimeBroker                           299
csrss                                   5
svchost                                 299
sihost                                  299
svchost                                 299
svchost                                 299
wininit                                 5
chrome                                  299
Microsoft.Photos                        299
RuntimeBroker                           299
SgrmBroker                              5
chrome                                  299
steamwebhelper                          299
dllhost                                 299
svchost                                 299
svchost                                 299
RuntimeBroker                           299
svchost                                 299
svchost                                 299
svchost                                 299
conhost                                 299
svchost                                 299
svchost                                 299
StartMenuExperienceHost                 299
svchost                                 299
Taskmgr                                 299
svchost                                 299
svchost                                 299
svchost                                 299
svchost                                 299
fontdrvhost                             299
taskhostw                               299
chrome                                  299
svchost                                 299
fontdrvhost                             299
conhost                                 299
conhost                                 299
LockApp                                 299
svchost                                 299
chrome                                  299
svchost                                 299
ScriptedSandbox64                       299
svchost                                 299
conhost                                 299
chrome                                  299
steamwebhelper                          299
chrome                                  299
Corsair.Service.CpuIdRemote64           299
conhost                                 299
NisSrv                                  5
conhost                                 299
conhost                                 299
ServiceHub.DataWarehouseHost            299
conhost                                 299
RuntimeBroker                           299
chrome                                  299
ShellExperienceHost                     299
svchost                                 299
winlogon                                299
conhost                                 299
Microsoft.ServiceHub.Controller         299
MsMpEng                                 5
svchost                                 299
steamwebhelper                          299
ServiceHub.RoslynCodeAnalysisService    299
ServiceHub.DataWarehouseHost            299
svchost                                 5
SearchProtocolHost                      299
ServiceHub.DataWarehouseHost            299
ConsoleApp1                             299
GameBarPresenceWriter                   299
steamwebhelper                          299
UserOOBEBroker                          299
RuntimeBroker                           299
conhost                                 299
svchost                                 299
svchost                                 299
nvcontainer                             299
svchost                                 299
conhost                                 299
svchost                                 299
svchost                                 299
conhost                                 299
RuntimeBroker                           299
chrome                                  299
svchost                                 299
steamwebhelper                          299
svchost                                 299
svchost                                 299
TextInputHost                           299
Microsoft.ServiceHub.Controller         299
conhost                                 299
chrome                                  299
SettingSyncHost                         299
Video.UI                                299
svchost                                 299
chrome                                  299
svchost                                 299
chrome                                  299
svchost                                 299
svchost                                 299
ApplicationFrameHost                    299
WmiPrvSE                                299
conhost                                 299
YourPhone                               299
ScriptedSandbox64                       299
nvcontainer                             299
chrome                                  299
WmiPrvSE                                299
svchost                                 299
WUDFHost                                299
StandardCollector.Service               299
svchost                                 299
ServiceHub.RoslynCodeAnalysisService    299
conhost                                 299
svchost                                 299
chrome                                  299
conhost                                 299
steamwebhelper                          299
svchost                                 299
nvsphelper64                            299
SearchFilterHost                        299
conhost                                 299
chrome                                  299
ctfmon                                  299
Memory Compression                      5
conhost                                 299
Registry                                5
svchost                                 299
svchost                                 299
dllhost                                 299
conhost                                 299
chrome                                  299
svchost                                 299
svchost                                 299
NVDisplay.Container                     299
chrome                                  299
svchost                                 299
conhost                                 299
conhost                                 299
OfficeClickToRun                        299
steamwebhelper                          299
conhost                                 299
NVIDIA Share                            299
RuntimeBroker                           299
nvcontainer                             299
svchost                                 299
dllhost                                 299
SearchApp                               299
conhost                                 299
svchost                                 299
smss                                    5
chrome                                  299
ScriptedSandbox64                       299
conhost                                 299
NVDisplay.Container                     299
VBCSCompiler                            299
conhost                                 299
rundll32                                299
conhost                                 299
svchost                                 299
svchost                                 299
spoolsv                                 299
svchost                                 299
svchost                                 299
svchost                                 299
msvsmon                                 299
conhost                                 299
svchost                                 299
conhost                                 299
NVIDIA Share                            299
conhost                                 299
svchost                                 299
audiodg                                 299
SearchProtocolHost                      299
svchost                                 299
conhost                                 299
svchost                                 299
taskhostw                               299
NVIDIA Share                            299
svchost                                 299
GoogleCrashHandler64                    299
CompPkgSrv                              299
svchost                                 299
SystemSettings                          299
svchost                                 299
SecurityHealthService                   5
explorer                                299
TERA                                    299
CorsairGamingAudioCfgService64          299
svchost                                 299
svchost                                 299
svchost                                 299
conhost                                 299
MoUsoCoreWorker                         299
svchost                                 299
svchost                                 299
svchost                                 299
svchost                                 299
lsass                                   299
chrome                                  299
chrome                                  299
svchost                                 299
mDNSResponder                           299
SecurityHealthSystray                   299
RuntimeBroker                           299
services                                5
chrome                                  299
System                                  -2147467259
svchost                                 299
svchost                                 299
Idle                                    -2147467259
c#
process
win32exception
asked on Stack Overflow Jan 3, 2021 by Kaskorian

1 Answer

0

From the docs:

Exceptions

Win32Exception

A 32-bit process is trying to access the modules of a 64-bit process.

Process.MainModule calls through eventually to OpenProcess on kernel32.dll. It seems that ERROR_PARTIAL_COPY is often caused by 32-bit processes trying to read info regarding 64-bit processes.

To fix this, compile your app as 64-bit.


But you may find your original problem easier to solve with Process.GetProcessesByName

answered on Stack Overflow Jan 3, 2021 by Charlieface

User contributions licensed under CC BY-SA 3.0