Bläddra i källkod

Do not force rfNormalPath in [Code] ApplyPathRedirRules, and instead add PathConvertSuperToNormal.

Martijn Laan 1 månad sedan
förälder
incheckning
ced370703f
4 ändrade filer med 19 tillägg och 6 borttagningar
  1. 11 3
      ISHelp/isxfunc.xml
  2. 5 1
      Projects/Src/Setup.ScriptFunc.pas
  3. 2 1
      Projects/Src/Shared.ScriptFunc.pas
  4. 1 1
      whatsnew.htm

+ 11 - 3
ISHelp/isxfunc.xml

@@ -1258,6 +1258,13 @@ end;</pre></example>
         <prototype>function ExpandUNCFileName(const FileName: String): String;</prototype>
         <description><p>Returns a string containing a fully qualified path name for the file passed in the FileName. A fully qualified path name includes the drive portion of the filename in the UNC format '\\&lt;servername&gt;\&lt;sharename&gt;' if the drive letter is mapped to a network resource instead of a local drive and any directory and subdirectories in addition to the file name and extension.</p></description>
       </function>
+      <function>
+        <name>PathConvertSuperToNormal</name>
+        <prototype>function PathConvertSuperToNormal(const FileName: String): String;</prototype>
+        <description><p>Converts an extended-length path (also known as a super path) to a normal path.</p></description>
+        <remarks><p>Only use this function in cases where an extended-length path is known to not work properly.</p></remarks>
+        <seealso><p><link topic="isxfunc_ApplyPathRedirRules">ApplyPathRedirRules</link></p></seealso>
+      </function>
     </subcategory>
     <subcategory>
       <function>
@@ -1797,16 +1804,17 @@ end;</pre></example>
         <name>ApplyPathRedirRules</name>
         <prototype>function ApplyPathRedirRules(const A64Bit: Boolean; const APath: String; const ATargetProcess64Bit: Boolean): String;</prototype>
         <description><p>Rewrites paths containing System32 to achieve the same effect as disabling/enabling WOW64 file system redirection, without actually changing the redirection state. Additionally, rewrites paths containing Sysnative for 64-bit target processes to ensure access to 64-bit System32.</p>
-<p>Before rewriting, the path is expanded using <link topic="isxfunc_ExpandFileName">ExpandFileName</link>.</p>
+<p>Before rewriting, the path is expanded using <link topic="isxfunc_ExpandFileName">ExpandFileName</link> and converted to an extended-length path (also known as a super path).</p>
 <p>Does not rewrite paths that do not contain System32 or Sysnative. Also does not rewrite when the system is running a 32-bit version of Windows.</p>
-<p>Path expansion always occurs.</p></description>
+<p>Path expansion and conversion to extended-length path always occurs.</p></description>
         <remarks><p>Does not rewrite for certain combinations, such as 64-bit System32 for a 64-bit target process, because no rewriting (or redirection) is needed for the target process to access the intended path. The following table lists all combinations for which rewriting has an effect, and the result:</p>
         <table><tr><td>A64Bit</td><td>APath</td><td>ATargetProcess64Bit</td><td>Result</td><td>Explanation</td></tr>
 <tr><td>True</td><td>System32</td><td>False</td><td>Sysnative</td><td>The 32-bit target process needs to use the Sysnative alias to access 64-bit system files.</td></tr>
 <tr><td>False</td><td>System32</td><td>True</td><td>SysWOW64</td><td>The 64-bit target process needs to use SysWOW64 to access 32-bit system files.</td></tr>
 <tr><td>Any value</td><td>Sysnative</td><td>True</td><td>System32</td><td>The 64-bit target process needs to use System32 instead of the Sysnative alias to access 64-bit system files, because the Sysnative alias only works for 32-bit processes.</td></tr>
 </table></remarks>
-        <seealso><p><link topic="isxfunc_ApplyPathRedirRulesForCurrentProcess">ApplyPathRedirRulesForCurrentProcess</link></p></seealso>
+        <seealso><p><link topic="isxfunc_ApplyPathRedirRulesForCurrentProcess">ApplyPathRedirRulesForCurrentProcess</link><br/>
+<link topic="isxfunc_PathConvertSuperToNormal">PathConvertSuperToNormal</link></p></seealso>
       </function>
       <function>
         <name>EnableFsRedirection</name>

+ 5 - 1
Projects/Src/Setup.ScriptFunc.pas

@@ -2017,7 +2017,11 @@ var
           TargetProcess := tp32Bit;
       end;
       Stack.SetString(PStart, ApplyPathRedirRules(Stack.GetBool(PStart-1),
-        Stack.GetString(PStart-2), [rfNormalPath], TargetProcess));
+        Stack.GetString(PStart-2), [], TargetProcess));
+    end);
+    RegisterScriptFunc('PathConvertSuperToNormal', procedure(const Caller: TPSExec; const OrgName: AnsiString; const Stack: TPSStack; const PStart: Integer)
+    begin
+      Stack.SetString(PStart, PathConvertSuperToNormal(Stack.GetString(PStart-1)));
     end);
   end;
 

+ 2 - 1
Projects/Src/Shared.ScriptFunc.pas

@@ -581,7 +581,8 @@ initialization
     'function StrToColor(const S: String): TColor;',
     'function RPos(const SubStr, S: String): Integer;',
     'function ApplyPathRedirRulesForCurrentProcess(const A64Bit: Boolean; const APath: String): String;',
-    'function ApplyPathRedirRules(const A64Bit: Boolean; const APath: String; const ATargetProcess64Bit: Boolean): String;'
+    'function ApplyPathRedirRules(const A64Bit: Boolean; const APath: String; const ATargetProcess64Bit: Boolean): String;',
+    'function PathConvertSuperToNormal(const Filename: String): String;'
   ];
 
   {$IFDEF ISIDEPROJ}

+ 1 - 1
whatsnew.htm

@@ -104,7 +104,7 @@ For conditions of distribution and use, see <a href="files/is/license.txt">LICEN
 <li>Pascal Scripting:
 <ul>
   <li>Removed support function <tt>EnableFsRedirection</tt>. Use <tt>{sysnative}</tt>, or a 64-bit installer, or new support function <tt>ApplyPathRedirRulesForCurrentProcess</tt> instead.</li>
-  <li>Added support functions <tt>ApplyPathRedirRules</tt> and <tt>IsCurrentProcess64Bit</tt>.</li>
+  <li>Added support functions <tt>ApplyPathRedirRules</tt>, <tt>PathConvertSuperToNormal</tt> and <tt>IsCurrentProcess64Bit</tt>.</li>
   <li>Added types <tt>UInt64</tt>, <tt>NativeInt</tt>, <tt>NativeUInt</tt>, <tt>THandle</tt>, <tt>HWND</tt>, <tt>HDC</tt>, <tt>HBITMAP</tt>, <tt>HFONT</tt>, <tt>HKEY</tt>, <tt>HMODULE</tt>, <tt>LRESULT</tt>, <tt>WPARAM</tt>, and <tt>LPARAM</tt>.</li>
   <li>Support function <tt>Chr</tt> now correctly accepts ordinal values greater than 255.</li>
   <li>Support function <tt>FloatToStr</tt> no longer outputs unnecessary trailing zeros.</li>