mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-01-22 17:12:25 -05:00
Maybe fix client not working under guest account in XP.
This commit is contained in:
parent
97636267e2
commit
c2022f6950
3 changed files with 37 additions and 1 deletions
|
@ -19,6 +19,7 @@ namespace ClassicalSharp {
|
|||
string logPath = Path.Combine(AppDirectory, "client.log");
|
||||
ErrorHandler.InstallHandler(logPath);
|
||||
CleanupMainDirectory();
|
||||
Configuration.SkipPerfCountersHack();
|
||||
|
||||
Utils.LogDebug("Starting " + AppName + "..");
|
||||
string path = Path.Combine(Program.AppDirectory, TexturePack.Dir);
|
||||
|
|
|
@ -44,6 +44,7 @@ namespace Launcher {
|
|||
string logPath = Path.Combine(AppDirectory, "launcher.log");
|
||||
AppDomain.CurrentDomain.UnhandledException += UnhandledExceptionHandler;
|
||||
ErrorHandler2.InstallHandler(logPath);
|
||||
OpenTK.Configuration.SkipPerfCountersHack();
|
||||
LauncherWindow window = new LauncherWindow();
|
||||
window.Run();
|
||||
}
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
#endregion
|
||||
|
||||
using System;
|
||||
using System.Reflection;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace OpenTK {
|
||||
|
@ -33,7 +34,7 @@ namespace OpenTK {
|
|||
/// <summary>Provides information about the underlying OS and runtime.</summary>
|
||||
public static class Configuration {
|
||||
|
||||
public static bool RunningOnWindows, RunningOnUnix, RunningOnX11,
|
||||
public static bool RunningOnWindows, RunningOnUnix, RunningOnX11,
|
||||
RunningOnMacOS, RunningOnLinux, RunningOnMono;
|
||||
|
||||
// Detects the underlying OS and runtime.
|
||||
|
@ -80,5 +81,38 @@ namespace OpenTK {
|
|||
|
||||
[DllImport("libc")]
|
||||
unsafe static extern void uname(sbyte* uname_struct);
|
||||
|
||||
public static void SkipPerfCountersHack() {
|
||||
if (RunningOnMono || !RunningOnWindows) return;
|
||||
|
||||
// On XP (maybe other versions) with guest account, we get this error
|
||||
/*System.UnauthorizedAccessException: Access to the path 'Global\.net clr networking' is denied.
|
||||
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
|
||||
at System.Threading.Mutex.<>c__DisplayClass3.<.ctor>b__0(Object userData)
|
||||
at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)
|
||||
at System.Threading.Mutex..ctor(Boolean initiallyOwned, String name, Boolean& createdNew, MutexSecurity mutexSecurity)
|
||||
at System.Diagnostics.SharedUtils.EnterMutexWithoutGlobal(String mutexName, Mutex& mutex)
|
||||
at System.Diagnostics.SharedPerformanceCounter.Verify(CategoryEntry* currentCategoryPointer)
|
||||
at System.Diagnostics.SharedPerformanceCounter.FindCategory(CategoryEntry** returnCategoryPointerReference)
|
||||
at System.Diagnostics.SharedPerformanceCounter.GetCounter(String counterName, String instanceName, Boolean enableReuse, PerformanceCounterInstanceLifetime lifetime)
|
||||
at System.Diagnostics.SharedPerformanceCounter..ctor(String catName, String counterName, String instanceName, PerformanceCounterInstanceLifetime lifetime)
|
||||
at System.Diagnostics.PerformanceCounter.Initialize()
|
||||
at System.Diagnostics.PerformanceCounter.set_RawValue(Int64 value)
|
||||
at System.Net.NetworkingPerfCounters.Initialize()*/
|
||||
|
||||
// So we hack around and prevent them ever being initalised.
|
||||
// TODO: only seems to work before .NET 4.0, not sure if still needed by then
|
||||
try {
|
||||
Assembly assem = typeof(System.Net.IPAddress).Assembly;
|
||||
Type perfType = assem.GetType("System.Net.NetworkingPerfCounters");
|
||||
if (perfType == null) return;
|
||||
|
||||
FieldInfo field = perfType.GetField("initialized", BindingFlags.NonPublic | BindingFlags.Static);
|
||||
if (field == null) return;
|
||||
|
||||
field.SetValue(null, true);
|
||||
} catch {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue