Skip to content

Commit 91fb460

Browse files
committed
Revert "Statically link undocumented shell32 functions"
This reverts commit 757d271. x86-32 fucking sucks.
1 parent 757d271 commit 91fb460

5 files changed

Lines changed: 30 additions & 30 deletions

File tree

src/OpenWithEx.vcxproj

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@
108108
<SubSystem>Windows</SubSystem>
109109
<GenerateDebugInformation>true</GenerateDebugInformation>
110110
<MinimumRequiredVersion>6.0</MinimumRequiredVersion>
111-
<AdditionalDependencies>shell32.lib;$(OutDir)shell32p.lib;shlwapi.lib;comctl32.lib;uxtheme.lib;crypt32.lib;bcrypt.lib;rpcrt4.lib;%(AdditionalDependencies)</AdditionalDependencies>
111+
<AdditionalDependencies>shell32.lib;shlwapi.lib;comctl32.lib;uxtheme.lib;crypt32.lib;bcrypt.lib;rpcrt4.lib;%(AdditionalDependencies)</AdditionalDependencies>
112112
<AdditionalManifestDependencies>"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'";%(AdditionalManifestDependencies)</AdditionalManifestDependencies>
113113
</Link>
114114
<ResourceCompile>
@@ -145,9 +145,6 @@ muirct -c "$(TargetPath)" -e "$(OutDir)ko-KR\$(TargetFileName).mui"
145145

146146
del "$(IntermediateOutputPath)temp.res"</Command>
147147
</PostBuildEvent>
148-
<PreBuildEvent>
149-
<Command>lib /def:shell32p.def /machine:$(PlatformTargetAsMSBuildArchitecture) /out:"$(OutDir)shell32p.lib"</Command>
150-
</PreBuildEvent>
151148
</ItemDefinitionGroup>
152149
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
153150
<ClCompile>
@@ -167,7 +164,7 @@ del "$(IntermediateOutputPath)temp.res"</Command>
167164
<OptimizeReferences>true</OptimizeReferences>
168165
<GenerateDebugInformation>true</GenerateDebugInformation>
169166
<MinimumRequiredVersion>6.0</MinimumRequiredVersion>
170-
<AdditionalDependencies>shell32.lib;$(OutDir)shell32p.lib;shlwapi.lib;comctl32.lib;uxtheme.lib;crypt32.lib;bcrypt.lib;rpcrt4.lib;%(AdditionalDependencies)</AdditionalDependencies>
167+
<AdditionalDependencies>shell32.lib;shlwapi.lib;comctl32.lib;uxtheme.lib;crypt32.lib;bcrypt.lib;rpcrt4.lib;%(AdditionalDependencies)</AdditionalDependencies>
171168
<AdditionalManifestDependencies>"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'";%(AdditionalManifestDependencies)</AdditionalManifestDependencies>
172169
</Link>
173170
<ResourceCompile>
@@ -204,9 +201,6 @@ muirct -c "$(TargetPath)" -e "$(OutDir)ko-KR\$(TargetFileName).mui"
204201

205202
del "$(IntermediateOutputPath)temp.res"</Command>
206203
</PostBuildEvent>
207-
<PreBuildEvent>
208-
<Command>lib /def:shell32p.def /machine:$(PlatformTargetAsMSBuildArchitecture) /out:"$(OutDir)shell32p.lib"</Command>
209-
</PreBuildEvent>
210204
</ItemDefinitionGroup>
211205
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
212206
<ClCompile>
@@ -224,7 +218,7 @@ del "$(IntermediateOutputPath)temp.res"</Command>
224218
<SubSystem>Windows</SubSystem>
225219
<GenerateDebugInformation>true</GenerateDebugInformation>
226220
<MinimumRequiredVersion>6.0</MinimumRequiredVersion>
227-
<AdditionalDependencies>shell32.lib;$(OutDir)shell32p.lib;shlwapi.lib;comctl32.lib;uxtheme.lib;crypt32.lib;bcrypt.lib;rpcrt4.lib;%(AdditionalDependencies)</AdditionalDependencies>
221+
<AdditionalDependencies>shell32.lib;shlwapi.lib;comctl32.lib;uxtheme.lib;crypt32.lib;bcrypt.lib;rpcrt4.lib;%(AdditionalDependencies)</AdditionalDependencies>
228222
<AdditionalManifestDependencies>"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'";%(AdditionalManifestDependencies)</AdditionalManifestDependencies>
229223
</Link>
230224
<ResourceCompile>
@@ -261,9 +255,6 @@ muirct -c "$(TargetPath)" -e "$(OutDir)ko-KR\$(TargetFileName).mui"
261255

262256
del "$(IntermediateOutputPath)temp.res"</Command>
263257
</PostBuildEvent>
264-
<PreBuildEvent>
265-
<Command>lib /def:shell32p.def /machine:$(PlatformTargetAsMSBuildArchitecture) /out:"$(OutDir)shell32p.lib"</Command>
266-
</PreBuildEvent>
267258
</ItemDefinitionGroup>
268259
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
269260
<ClCompile>
@@ -284,7 +275,7 @@ del "$(IntermediateOutputPath)temp.res"</Command>
284275
<OptimizeReferences>true</OptimizeReferences>
285276
<GenerateDebugInformation>true</GenerateDebugInformation>
286277
<MinimumRequiredVersion>6.0</MinimumRequiredVersion>
287-
<AdditionalDependencies>shell32.lib;$(OutDir)shell32p.lib;shlwapi.lib;comctl32.lib;uxtheme.lib;crypt32.lib;bcrypt.lib;rpcrt4.lib;%(AdditionalDependencies)</AdditionalDependencies>
278+
<AdditionalDependencies>shell32.lib;shlwapi.lib;comctl32.lib;uxtheme.lib;crypt32.lib;bcrypt.lib;rpcrt4.lib;%(AdditionalDependencies)</AdditionalDependencies>
288279
<AdditionalManifestDependencies>"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'";%(AdditionalManifestDependencies)</AdditionalManifestDependencies>
289280
</Link>
290281
<ResourceCompile>
@@ -321,9 +312,6 @@ muirct -c "$(TargetPath)" -e "$(OutDir)ko-KR\$(TargetFileName).mui"
321312

322313
del "$(IntermediateOutputPath)temp.res"</Command>
323314
</PostBuildEvent>
324-
<PreBuildEvent>
325-
<Command>lib /def:shell32p.def /machine:$(PlatformTargetAsMSBuildArchitecture) /out:"$(OutDir)shell32p.lib"</Command>
326-
</PreBuildEvent>
327315
</ItemDefinitionGroup>
328316
<ItemGroup>
329317
<ClCompile Include="assocuserchoice.cpp" />
@@ -408,9 +396,6 @@ del "$(IntermediateOutputPath)temp.res"</Command>
408396
<ItemGroup>
409397
<Xml Include="muiconfig.xml" />
410398
</ItemGroup>
411-
<ItemGroup>
412-
<None Include="shell32p.def" />
413-
</ItemGroup>
414399
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
415400
<ImportGroup Label="ExtensionTargets">
416401
</ImportGroup>

src/OpenWithEx.vcxproj.filters

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -236,9 +236,4 @@
236236
<ItemGroup>
237237
<Xml Include="muiconfig.xml" />
238238
</ItemGroup>
239-
<ItemGroup>
240-
<None Include="shell32p.def">
241-
<Filter>Source Files</Filter>
242-
</None>
243-
</ItemGroup>
244239
</Project>

src/openwithex.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ HMODULE g_hInst = nullptr;
1717
HMODULE g_hShell32 = nullptr;
1818
OPENWITHEXSTYLE g_style = OWXS_VISTA;
1919

20+
SHCreateAssocHandler_t SHCreateAssocHandler = nullptr;
21+
IsBlockedFromOpenWithBrowse_t IsBlockedFromOpenWithBrowse = nullptr;
22+
2023
WCHAR szPath[MAX_PATH] = { 0 };
2124

2225
void OpenDownloadURL(LPCWSTR pszExtension)
@@ -138,7 +141,25 @@ int WINAPI wWinMain(
138141
g_style = (OPENWITHEXSTYLE)dwValue;
139142
}
140143

144+
/* Load undocumented functions */
141145
g_hShell32 = GetModuleHandleW(L"shell32.dll");
146+
SHCreateAssocHandler = (SHCreateAssocHandler_t)GetProcAddress(
147+
g_hShell32,
148+
(LPCSTR)765 // Ordinal number
149+
);
150+
IsBlockedFromOpenWithBrowse = (IsBlockedFromOpenWithBrowse_t)GetProcAddress(
151+
g_hShell32,
152+
(LPCSTR)779
153+
);
154+
if (!SHCreateAssocHandler || !IsBlockedFromOpenWithBrowse)
155+
{
156+
LocalizedMessageBox(
157+
NULL,
158+
IDS_ERR_UNDOC,
159+
MB_ICONERROR
160+
);
161+
return -1;
162+
}
142163

143164
/**
144165
* HACKHACK: Windows loves to pass the full executable path as the first

src/openwithex.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,11 @@ enum IMMERSIVE_OPENWITH_FLAGS
4040
void OpenDownloadURL(LPCWSTR pszExtension);
4141
void ShowOpenWithDialog(HWND hWndParent, LPCWSTR lpszPath, IMMERSIVE_OPENWITH_FLAGS flags);
4242

43-
EXTERN_C WINUSERAPI HRESULT WINAPI SHCreateAssocHandler(UINT uFlags, LPCWSTR pszExt, LPCWSTR pszApp, IAssocHandler **ppah);
44-
EXTERN_C WINUSERAPI bool WINAPI IsBlockedFromOpenWithBrowse(LPCWSTR lpszPath);
43+
typedef HRESULT (WINAPI *SHCreateAssocHandler_t)(UINT uFlags, LPCWSTR pszExt, LPCWSTR pszApp, IAssocHandler **ppah);
44+
extern SHCreateAssocHandler_t SHCreateAssocHandler;
45+
46+
typedef bool (WINAPI *IsBlockedFromOpenWithBrowse_t)(LPCWSTR lpszPath);
47+
extern IsBlockedFromOpenWithBrowse_t IsBlockedFromOpenWithBrowse;
4548

4649
DEFINE_GUID(CLSID_ExecuteUnknown, 0xE44E9428, 0xBDBC, 0x4987, 0xA0,0x99, 0x40,0xDC,0x8F,0xD2,0x55,0xE7);
4750

src/shell32p.def

Lines changed: 0 additions & 4 deletions
This file was deleted.

0 commit comments

Comments
 (0)