summaryrefslogtreecommitdiff
path: root/src/test/burn/TestExe/Task.cs
diff options
context:
space:
mode:
authorSean Hall <r.sean.hall@gmail.com>2022-06-24 12:28:27 -0500
committerSean Hall <r.sean.hall@gmail.com>2022-06-27 11:14:21 -0500
commiteb53852d7ae6838e54525eb57df1d8ce8a722f9b (patch)
tree7fa05bd6df1bce2e20d87c5fbacc1c658dc000aa /src/test/burn/TestExe/Task.cs
parent6ee12a64cb75097a238e60d4fd0ea542e8312214 (diff)
downloadwix-eb53852d7ae6838e54525eb57df1d8ce8a722f9b.tar.gz
wix-eb53852d7ae6838e54525eb57df1d8ce8a722f9b.tar.bz2
wix-eb53852d7ae6838e54525eb57df1d8ce8a722f9b.zip
Add longPathAware to Burn manifest to support long paths.
Fixes 3455
Diffstat (limited to 'src/test/burn/TestExe/Task.cs')
-rw-r--r--src/test/burn/TestExe/Task.cs67
1 files changed, 67 insertions, 0 deletions
diff --git a/src/test/burn/TestExe/Task.cs b/src/test/burn/TestExe/Task.cs
index 59f774fb..0d283c6c 100644
--- a/src/test/burn/TestExe/Task.cs
+++ b/src/test/burn/TestExe/Task.cs
@@ -2,8 +2,10 @@
2 2
3using System; 3using System;
4using System.Collections.Generic; 4using System.Collections.Generic;
5using System.ComponentModel;
5using System.Diagnostics; 6using System.Diagnostics;
6using System.IO; 7using System.IO;
8using System.Runtime.InteropServices;
7using Microsoft.Win32; 9using Microsoft.Win32;
8 10
9namespace TestExe 11namespace TestExe
@@ -151,6 +153,67 @@ namespace TestExe
151 } 153 }
152 } 154 }
153 155
156 public class DeleteManifestsTask : Task
157 {
158 public DeleteManifestsTask(string Data) : base(Data) { }
159
160 public override void RunTask()
161 {
162 string filePath = System.Environment.ExpandEnvironmentVariables(this.data);
163 IntPtr type = new IntPtr(24); //RT_MANIFEST
164 IntPtr name = new IntPtr(1); //CREATEPROCESS_MANIFEST_RESOURCE_ID
165 DeleteResource(filePath, type, name, 1033);
166 }
167
168 private static void DeleteResource(string filePath, IntPtr type, IntPtr name, ushort language, bool throwOnError = false)
169 {
170 bool discard = true;
171 IntPtr handle = BeginUpdateResourceW(filePath, false);
172 try
173 {
174 if (handle == IntPtr.Zero)
175 {
176 throw new Win32Exception();
177 }
178
179 if (!UpdateResourceW(handle, type, name, language, IntPtr.Zero, 0))
180 {
181 throw new Win32Exception();
182 }
183
184 discard = false;
185 }
186 catch
187 {
188 if (throwOnError)
189 {
190 throw;
191 }
192 }
193 finally
194 {
195 if (handle != IntPtr.Zero)
196 {
197 if (!EndUpdateResourceW(handle, discard) && throwOnError)
198 {
199 throw new Win32Exception();
200 }
201 }
202 }
203 }
204
205 [DllImport("kernel32.dll", CharSet = CharSet.Unicode, ExactSpelling = true, SetLastError = true)]
206 private extern static IntPtr BeginUpdateResourceW(string fileName, [MarshalAs(UnmanagedType.Bool)] bool deleteExistingResources);
207
208 [DllImport("kernel32.dll", CharSet = CharSet.Unicode, ExactSpelling = true, SetLastError = true)]
209 [return: MarshalAs(UnmanagedType.Bool)]
210 private extern static bool UpdateResourceW(IntPtr hUpdate, IntPtr type, IntPtr name, ushort language, IntPtr pData, uint cb);
211
212 [DllImport("kernel32.dll", CharSet = CharSet.Unicode, ExactSpelling = true, SetLastError = true)]
213 [return: MarshalAs(UnmanagedType.Bool)]
214 private extern static bool EndUpdateResourceW(IntPtr hUpdate, [MarshalAs(UnmanagedType.Bool)] bool discard);
215 }
216
154 public class TaskParser 217 public class TaskParser
155 { 218 {
156 219
@@ -197,6 +260,10 @@ namespace TestExe
197 t = new FileExistsTask(args[i + 1]); 260 t = new FileExistsTask(args[i + 1]);
198 tasks.Add(t); 261 tasks.Add(t);
199 break; 262 break;
263 case "/dm":
264 t = new DeleteManifestsTask(args[i + 1]);
265 tasks.Add(t);
266 break;
200#if NET35 267#if NET35
201 case "/pinfo": 268 case "/pinfo":
202 t = new ProcessInfoTask(args[i + 1]); 269 t = new ProcessInfoTask(args[i + 1]);