Browse Source

Fix an exception caused by process.MainModule.

Try to access a dead process's MainModule will cause
"A 32 bit processes cannot access modules of
a 64 bit process." exception on win7 x64.
Simply ignore it.

Signed-off-by: noisyfox <timemanager.rick@gmail.com>
tags/3.3
noisyfox 8 years ago
parent
commit
80fc8b4ccf
1 changed files with 16 additions and 2 deletions
  1. +16
    -2
      shadowsocks-csharp/Controller/Service/PolipoRunner.cs

+ 16
- 2
shadowsocks-csharp/Controller/Service/PolipoRunner.cs View File

@@ -122,6 +122,7 @@ namespace Shadowsocks.Controller
* different instance will create their unique "privoxy_UID.conf" where
* UID is hash of ss's location.
*/
private static bool IsChildProcess(Process process)
{
if (Utils.IsPortableMode())
@@ -129,8 +130,21 @@ namespace Shadowsocks.Controller
/*
* Under PortableMode, we could identify it by the path of ss_privoxy.exe.
*/
string path = process.MainModule.FileName;
return Utils.GetTempPath("ss_privoxy.exe").Equals(path);
try
{
/*
* Sometimes Process.GetProcessesByName will return some processes that
* are already dead, and that will cause exceptions here.
* We could simply ignore those exceptions.
*/
string path = process.MainModule.FileName;
return Utils.GetTempPath("ss_privoxy.exe").Equals(path);
}
catch (Exception ex)
{
Logging.LogUsefulException(ex);
return false;
}
}
else
{


Loading…
Cancel
Save