Permalink
Browse files

fixed environment and elevation proxy. closes #58 #66 #59 #57 #50 #56 #…

  • Loading branch information...
1 parent 7bd9aa5 commit 621edb30947f725b0a44dec938a816e7b5bad617 @fearthecowboy fearthecowboy committed Sep 10, 2012
View
@@ -39,7 +39,7 @@
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
- <UseVSHostingProcess>false</UseVSHostingProcess>
+ <UseVSHostingProcess>true</UseVSHostingProcess>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|AnyCPU'">
<PlatformTarget>AnyCPU</PlatformTarget>
@@ -1,12 +1,12 @@
-//-----------------------------------------------------------------------
+//-----------------------------------------------------------------------
// <copyright company="CoApp Project">
-// Copyright (c) 2010-2012 Garrett Serack and CoApp Contributors.
+// Copyright (c) 2010-2012 Garrett Serack and CoApp Contributors.
// Contributors can be discovered using the 'git log' command.
// All rights reserved.
// </copyright>
// <license>
// The software is licensed under the Apache 2.0 License (the "License")
-// You may not use the software except in compliance with the License.
+// You may not use the software except in compliance with the License.
// </license>
//-----------------------------------------------------------------------
@@ -115,7 +115,7 @@ public struct SidIdentifierAuthority {
private byte[] _ssmessage;
- internal static void ElevateSelf() {
+ internal static void ElevateSelf(bool processCreated) {
try {
var ntAuth = new SidIdentifierAuthority();
ntAuth.Value = new byte[] {0, 0, 0, 0, 0, 5};
@@ -129,6 +129,7 @@ public struct SidIdentifierAuthority {
// :) Seems that we need to elevate?
}
+ if (!processCreated) {
// we're not an admin I guess.
try {
var process = new Process {
@@ -137,7 +138,7 @@ public struct SidIdentifierAuthority {
WorkingDirectory = Environment.CurrentDirectory,
FileName = Assembly.GetEntryAssembly().Location,
Verb = "runas",
- Arguments = Environment.GetCommandLineArgs().Skip(1).Aggregate(string.Empty, (current, each) => current + " \"" + each + "\"").Trim(),
+ Arguments = Environment.GetCommandLineArgs().Skip(1).Aggregate(string.Empty, (current, each) => current + " \"" + each + "\"").Trim() + " __EPM1__",
ErrorDialog = true,
ErrorDialogParentHandle = GetForegroundWindow(),
WindowStyle = ProcessWindowStyle.Maximized,
@@ -155,6 +156,7 @@ public struct SidIdentifierAuthority {
} catch {
// nWindow.Fail(LocalizedMessage.IDS_REQUIRES_ADMIN_RIGHTS, "The installer requires administrator permissions.");
}
+ }
// we should have elevated, or failed to. either way, GTFO.
Environment.Exit(0);
@@ -210,7 +212,7 @@ public struct SidIdentifierAuthority {
System.Windows.Forms.MessageBox.Show("Required: PipeName", "CoApp Elevation Proxy", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
- ElevateSelf();
+ ElevateSelf(args.Length == 2 && args[1] == "__EPM1__");
var epm = new ElevationProxyMain {
ClientPipeName = args[0]
};
@@ -71,7 +71,7 @@ public class Installer : MarshalByRefObject, INotifyPropertyChanged {
if (((AppDomain.CurrentDomain.GetData("COAPP_INSTALLED") as string) ?? "false").IsTrue()) {
// we'd better make sure that the most recent version of the service is running.
EngineServiceManager.InstallAndStartService();
-
+ EnvironmentUtility.BroadcastChange();
}
bool wasCreated;
var ewhSec = new EventWaitHandleSecurity();
@@ -1,3 +1,3 @@
// This is an autogenerated file (see inc-build-numbers.js)
-#define COAPP_TOOLKIT_VERSION 1,2,0,448
-#define COAPP_TOOLKIT_VERSION_STR "1.2.0.448\0"
+#define COAPP_TOOLKIT_VERSION 1,2,0,453
+#define COAPP_TOOLKIT_VERSION_STR "1.2.0.453\0"
@@ -14,8 +14,8 @@
// we publish it, so now we will have just one set of Version lines, and no strong
// naming until publishing.
-[assembly: AssemblyVersion("1.2.0.448")]
-[assembly: AssemblyFileVersion("1.2.0.448")]
+[assembly: AssemblyVersion("1.2.0.453")]
+[assembly: AssemblyFileVersion("1.2.0.453")]
[AttributeUsage(AttributeTargets.Assembly, Inherited = false)]
internal class AssemblyBugtrackerAttribute : Attribute {
@@ -18,20 +18,18 @@ namespace CoApp.Toolkit.Win32 {
using Extensions;
public static class EnvironmentUtility {
-#if !COAPP_ENGINE_CORE
private const Int32 HWND_BROADCAST = 0xffff;
private const Int32 WM_SETTINGCHANGE = 0x001A;
private const Int32 SMTO_ABORTIFHUNG = 0x0002;
-#endif
public static void BroadcastChange() {
#if COAPP_ENGINE_CORE
Rehash.ForceProcessToReloadEnvironment("explorer", "services");
-#else
+#endif
Task.Factory.StartNew(() => {
User32.SendMessageTimeout(HWND_BROADCAST, WM_SETTINGCHANGE, 0, "Environment", SMTO_ABORTIFHUNG, 1000, IntPtr.Zero);
});
-#endif
+
}
public static string GetSystemEnvironmentVariable(string name) {

0 comments on commit 621edb3

Please sign in to comment.