From aedd00e2621fc84093e150a1bd0af8123f4e83bf Mon Sep 17 00:00:00 2001 From: Mark Jansen Date: Sat, 9 Apr 2022 02:13:38 +0200 Subject: [PATCH] [sxs] Add support for the undocumented loadFrom keyword --- DependenciesLib/SxsManifest.cs | 25 ++++++++++++++++++ .../manifest-regress/Test-ManifestRegress.ps1 | 16 +++++++++-- .../test_folder/custom_name64.dll | Bin 0 -> 2560 bytes .../manifest-regress/test_folder/depdll32.dll | Bin 0 -> 2560 bytes test/manifest-regress/use_dll32.exe | Bin 0 -> 2048 bytes test/manifest-regress/use_dll32.exe.manifest | 8 ++++++ test/manifest-regress/use_dll64.exe | Bin 0 -> 2048 bytes test/manifest-regress/use_dll64.exe.manifest | 8 ++++++ 8 files changed, 55 insertions(+), 2 deletions(-) create mode 100644 test/manifest-regress/test_folder/custom_name64.dll create mode 100644 test/manifest-regress/test_folder/depdll32.dll create mode 100644 test/manifest-regress/use_dll32.exe create mode 100644 test/manifest-regress/use_dll32.exe.manifest create mode 100644 test/manifest-regress/use_dll64.exe create mode 100644 test/manifest-regress/use_dll64.exe.manifest diff --git a/DependenciesLib/SxsManifest.cs b/DependenciesLib/SxsManifest.cs index efb8c19..7aa86ed 100644 --- a/DependenciesLib/SxsManifest.cs +++ b/DependenciesLib/SxsManifest.cs @@ -42,6 +42,31 @@ public SxsEntry(XElement SxsAssemblyIdentity, XElement SxsFile, string Folder) Type = ""; PublicKeyToken = ""; + string loadFrom = SxsFile.Attribute("loadFrom")?.Value?.ToString(); + if (!string.IsNullOrEmpty(loadFrom)) + { + loadFrom = Environment.ExpandEnvironmentVariables(loadFrom); + if (!System.IO.Path.IsPathRooted(loadFrom)) + { + loadFrom = System.IO.Path.Combine(Folder, loadFrom); + } + + // It's only a folder + if (loadFrom.EndsWith("\\") || loadFrom.EndsWith("/")) + { + Path = System.IO.Path.Combine(loadFrom, RelPath); + } + else + { + // It's also a dll name! + Path = loadFrom; + if (!Path.ToLower().EndsWith(".dll")) + { + Path += ".DLL"; + } + } + } + if (SxsAssemblyIdentity != null) { if (SxsAssemblyIdentity.Attribute("version") != null) diff --git a/test/manifest-regress/Test-ManifestRegress.ps1 b/test/manifest-regress/Test-ManifestRegress.ps1 index 165cd4d..83f21d1 100644 --- a/test/manifest-regress/Test-ManifestRegress.ps1 +++ b/test/manifest-regress/Test-ManifestRegress.ps1 @@ -53,7 +53,7 @@ function Test-Executable { } else { - Write-Host -ForegroundColor Green "[+] $TestName test passed"; + Write-Host -ForegroundColor Green "[+] $TestName test passed"; } Write-Output "" @@ -72,4 +72,16 @@ Test-Executable -TestName "SystemSettings" -TestExecutable $SystemSettingsPath - # Double quotes in assemblyIdentity name attribute ! $DevicePairingFolderPath = Join-Path $RegressDir "DevicePairingFolder.dll"; -Test-Executable -TestName "DevicePairingFolder" -TestExecutable $DevicePairingFolderPath -Command "-manifest" -StringToFound '`D;SNi)dj5w5!Y<o5x7c9D6@QZx3yhddk8^>BdT<&0Mc_&oi5>ZaPlOXUm*hf>gFiD^F(*qy)Tv5k}~!%|vqxQp_)<0tn(HYuwYN{OkX&8plMoEuk zrtri~aod#Q9T_M6CmrV}eZl|SZ>^Lzcnx2C$1g{?ukihmIISjn7xVqG{P(f=Z|j=v z2X)WaEZfE@ZQrvwesZ(~&uP?~F5Tyz!|k(Y;)=`MuePjJn_p_!{HodH7e92^yzD&RkOyfP9Pz(AH`X=_j0DnPup!+hp GH}D%+)27}4 literal 0 HcmV?d00001 diff --git a/test/manifest-regress/test_folder/depdll32.dll b/test/manifest-regress/test_folder/depdll32.dll new file mode 100644 index 0000000000000000000000000000000000000000..faa8e04bf55110bc7ccff78e7e9a390958a43c37 GIT binary patch literal 2560 zcmeHIzl#$=6n?8w&NG)>pzIpSQ-L2hOqy0pb z!-!*|E<9UV&*P`3kP9c?7wFxgjZ)XBZj^2{TWt|W!Gp;5M8o#|K#BWOM2o&?`Qq}8 zo5BkmY0k_{pH5TPD@0X;E6D5@6;2&C4rT<DbB!DOdxc z54wF=#IQ2ax*16~Xr#5GW}Rz_)y&F7m$E29w^#o>`^)*(I+dyV<_Dmq&$-n~zf8iYrGEbaMvLaMpWF zf}`ZIk9okIHe4Td%+^~`M9Q=z^dz<=EoY#KTh?MELF4DAB{MsypSHs$d~TfGwF(} zQq=-y(Un(PuDou0^5V$d@d-FdWI!8?E!5D*An^Q-6xov_L+qSp2bvFU)ns8}d!Ylk a2mF6KZk@NPma@KEKds;V|CrdG=)gZxgqG?6 literal 0 HcmV?d00001 diff --git a/test/manifest-regress/use_dll32.exe b/test/manifest-regress/use_dll32.exe new file mode 100644 index 0000000000000000000000000000000000000000..64efcea1d7d785cac4f448a3928c915538888b8f GIT binary patch literal 2048 zcmeHHO=uHA6n<%=#M;&hMGqdFLV6Ii{#`_=q|nuiKPy@gQPMR#Z9_MkWwVtOR9b4V z%NoqVgU5;p9u+)9PnGl{=tYVY^pJzX2HTsU2XXyovW=;S9*XqjgZIAozIlH$EPM7! ziCT#$3Jn6HGEhiD+V#y8jyw0h>ZBLj-u09tXWsQ(8cXMxWoJiiEyGfpX=WXEoilsF zWNDKPp1;U4S)KQFbhO38)~Z5uCepHIP?dJHZjWqT%XJ|X$^@OL`zRB83t2@vgaCa1 zE|T|>iK0#vOKgB3i7_HodjHl~=zDCPmVFM-J2;;eR~LJU3kbhS7}0Q_t~naGxd;ph znX~q3C_yxjlMTs``(=8$9nDMSD6Cp6{QMOJs{9O8zY`lt*Dd@2?MYjh-*IOPhSj#i z)bnd%qx$JfVhOsS`XAA4W+CPlzR5yi8-=WqEvSx0^b#J;#%g;cBT5o~4K7RuK@jff zPstHcwcLu4sy|tuDEF<2PH!qi@_zdfl!}V4`oG}KEJW*fQWk-&BrY34{Xkd`Ky;$s zyr?XOk5N=UsYRs<{jB=E^0eCn=YjJC_Z<7qEVR4IlBX=Gep|hPSYjQyyFWfuG~&?< zZf&|IK7>N#fPj8sZY}S7U5L0<_pKKThNGUcT=Bo-0X*`k;;+C{{jbtK!HDUF7;MGk zzW+gz4-vu%UhPcKduZ)Gh#}92$BKh->`8~`T_vhN0!ywED=#C*Rocr{iCyBfyQswU z$0Ffc{T@NDg~vwU-h7C2A>IseD#SY>&W3m|#8QY4LVPGujQB5`{{mMJ(x725Bdh6L zKhAn{ZEJUU%KpSv_~O6ztch#sA<83OYT|B#n`?@xNmfF>139~)40-^15_%3g1WiH5 zp+dY6H(EE&ZIc^EkM!w=fp(|4b2h6_82nV);ODdqAD~R`M#^@=^PFQ_*X?m+T6WrW zM&KkoU$CuaJVg^RhH*d d+;Wm*nyDMyK1w>buvcR{_(@B1#!#|Z@*6wpYeE13 literal 0 HcmV?d00001 diff --git a/test/manifest-regress/use_dll32.exe.manifest b/test/manifest-regress/use_dll32.exe.manifest new file mode 100644 index 0000000..f459350 --- /dev/null +++ b/test/manifest-regress/use_dll32.exe.manifest @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/test/manifest-regress/use_dll64.exe b/test/manifest-regress/use_dll64.exe new file mode 100644 index 0000000000000000000000000000000000000000..c4d436b6f9ff1334f0edcecff5b4355ecb335f24 GIT binary patch literal 2048 zcmeHHOKTHR6uwDQwePwR+<7bQN}7s_3s+GZor2MV7Da?~+PQ5*Co{ujsufD9Xv86m zSg?P<-{2zcD&ocm-MH#9iwYBPksnYTzjJ5us7e;1D?M<}<2&Cu_uM;|$=rL%x)@^# ztRP^l3`>%dy0h9qdhpcFAbZoZJ5r8a-yONVlq+z{HWzI*&*xRcFdaT8xV>WVoWUn= z-r{*v6Ul*r-qEP_beb{k8BNfVI-7|1#gDWAc>FljFhMC&p&t+DrjX{Bl7a@lbe73; zMMX{1bY!ovq|IfVGd3NNTi(%Mn-!#vnkVtXexhY0j2^2e#8TlB*|WSV_W zw`vI+Y=v^5=f`RzAtZ~RRAN8PQ&a=m(4$fOPegW$dvd2OX}p0RjN(%}d8is3_Te3i zCF0$QuGpc^-?*O!*G*S<=w+ce#{6}_+c*mI*Ps+HT~*x4Q7*eqxo-jZ@mTC3)puFghS1NSOKQ4~y{`!;V`?k9xSG?&4K*(=vwY#fyzNB!f@52A_A;23 zoim&TIN5pAaBNdwuqenDgp*Y*E9*S6gaj6alUH+wYA+TLi`AUNG+|-8ix;A%@Uxcc dEFt~Jr4Rp_KKxtzvCd#^V!gupFaO33d + + + + + + +