1// Licensed to the .NET Foundation under one or more agreements.
2// The .NET Foundation licenses this file to you under the MIT license.
3// See the LICENSE file in the project root for more information.
4
5
6//
7
8#ifndef _DLWRAP_H
9#define _DLWRAP_H
10
11//include this file if you get contract violation because of delayload
12
13//nothrow implementations
14
15#if defined(VER_H) && !defined (GetFileVersionInfoSizeW_NoThrow)
16DWORD
17GetFileVersionInfoSizeW_NoThrow(
18 LPCWSTR lptstrFilename, /* Filename of version stamped file */
19 LPDWORD lpdwHandle
20 );
21#endif
22
23#if defined(VER_H) && !defined (GetFileVersionInfoW_NoThrow)
24BOOL
25GetFileVersionInfoW_NoThrow(
26 LPCWSTR lptstrFilename, /* Filename of version stamped file */
27 DWORD dwHandle, /* Information from GetFileVersionSize */
28 DWORD dwLen, /* Length of buffer for info */
29 LPVOID lpData
30 );
31#endif
32
33#if defined(VER_H) && !defined (VerQueryValueW_NoThrow)
34BOOL
35VerQueryValueW_NoThrow(
36 const LPVOID pBlock,
37 LPCWSTR lpSubBlock,
38 LPVOID * lplpBuffer,
39 PUINT puLen
40 );
41#endif
42
43#if defined(_WININET_) && !defined (CreateUrlCacheEntryW_NoThrow)
44__success(return)
45BOOL
46CreateUrlCacheEntryW_NoThrow(
47 IN LPCWSTR lpszUrlName,
48 IN DWORD dwExpectedFileSize,
49 IN LPCWSTR lpszFileExtension,
50 __out_ecount(MAX_LONGPATH+1) LPWSTR lpszFileName,
51 IN DWORD dwReserved
52 );
53#endif
54
55#if defined(_WININET_) && !defined (CommitUrlCacheEntryW_NoThrow)
56BOOL
57CommitUrlCacheEntryW_NoThrow(
58 IN LPCWSTR lpszUrlName,
59 IN LPCWSTR lpszLocalFileName,
60 IN FILETIME ExpireTime,
61 IN FILETIME LastModifiedTime,
62 IN DWORD CacheEntryType,
63 IN LPCWSTR lpHeaderInfo,
64 IN DWORD dwHeaderSize,
65 IN LPCWSTR lpszFileExtension,
66 IN LPCWSTR lpszOriginalUrl
67 );
68#endif
69
70#if defined(_WININET_) && !defined (InternetTimeToSystemTimeA_NoThrow)
71BOOL
72InternetTimeToSystemTimeA_NoThrow(
73 IN LPCSTR lpszTime, // NULL terminated string
74 OUT SYSTEMTIME *pst, // output in GMT time
75 IN DWORD dwReserved
76 );
77#endif
78
79#if defined(__urlmon_h__) && !defined(CoInternetCreateSecurityManager_NoThrow)
80HRESULT
81CoInternetCreateSecurityManager_NoThrow(
82 IServiceProvider *pSP,
83 IInternetSecurityManager **ppSM,
84 DWORD dwReserved
85 );
86#endif
87
88#if defined(__urlmon_h__) && !defined(URLDownloadToCacheFileW_NoThrow)
89HRESULT
90URLDownloadToCacheFileW_NoThrow(
91 LPUNKNOWN lpUnkcaller,
92 LPCWSTR szURL,
93 __out_ecount(dwBufLength) LPWSTR szFileName,
94 DWORD dwBufLength,
95 DWORD dwReserved,
96 IBindStatusCallback *pBSC
97 );
98#endif
99
100#if defined(__urlmon_h__) && !defined(CoInternetGetSession_NoThrow)
101HRESULT
102CoInternetGetSession_NoThrow(
103 WORD dwSessionMode,
104 IInternetSession **ppIInternetSession,
105 DWORD dwReserved
106 );
107#endif
108
109#if defined(__urlmon_h__) && !defined(CopyBindInfo_NoThrow)
110HRESULT
111CopyBindInfo_NoThrow(
112 const BINDINFO * pcbiSrc, BINDINFO * pbiDest
113 );
114#endif
115
116
117
118//overrides
119#undef InternetTimeToSystemTimeA
120#undef CommitUrlCacheEntryW
121#undef HttpQueryInfoA
122#undef InternetCloseHandle
123#undef HttpSendRequestA
124#undef HttpOpenRequestA
125#undef InternetConnectA
126#undef InternetOpenA
127#undef InternetReadFile
128#undef CreateUrlCacheEntryW
129#undef CoInternetGetSession
130#undef CopyBindInfo
131#undef CoInternetCreateSecurityManager
132#undef URLDownloadToCacheFileW
133#undef FDICreate
134#undef FDIIsCabinet
135#undef FDICopy
136#undef FDIDestroy
137#undef VerQueryValueW
138#undef GetFileVersionInfoW
139#undef GetFileVersionInfoSizeW
140#undef VerQueryValueA
141#undef GetFileVersionInfoA
142#undef GetFileVersionInfoSizeA
143
144
145#define InternetTimeToSystemTimeA InternetTimeToSystemTimeA_NoThrow
146#define CommitUrlCacheEntryW CommitUrlCacheEntryW_NoThrow
147#define CreateUrlCacheEntryW CreateUrlCacheEntryW_NoThrow
148#define CoInternetGetSession CoInternetGetSession_NoThrow
149#define CopyBindInfo CopyBindInfo_NoThrow
150#define CoInternetCreateSecurityManager CoInternetCreateSecurityManager_NoThrow
151#define URLDownloadToCacheFileW URLDownloadToCacheFileW_NoThrow
152#define VerQueryValueW VerQueryValueW_NoThrow
153#define GetFileVersionInfoW GetFileVersionInfoW_NoThrow
154#define GetFileVersionInfoSizeW GetFileVersionInfoSizeW_NoThrow
155#define VerQueryValueA Use_VerQueryValueW
156#define GetFileVersionInfoA Use_GetFileVersionInfoW
157#define GetFileVersionInfoSizeA Use_GetFileVersionInfoSizeW
158
159#if defined(_WININET_)
160 inline
161 HRESULT HrCreateUrlCacheEntryW(
162 IN LPCWSTR lpszUrlName,
163 IN DWORD dwExpectedFileSize,
164 IN LPCWSTR lpszFileExtension,
165 __out_ecount(MAX_LONGPATH+1) LPWSTR lpszFileName,
166 IN DWORD dwReserved
167 )
168 {
169 if (!CreateUrlCacheEntryW(lpszUrlName, dwExpectedFileSize, lpszFileExtension, lpszFileName, dwReserved))
170 {
171 return HRESULT_FROM_WIN32(GetLastError());
172 }
173 else
174 {
175 return S_OK;
176 }
177 }
178
179 inline
180 HRESULT HrCommitUrlCacheEntryW(
181 IN LPCWSTR lpszUrlName,
182 IN LPCWSTR lpszLocalFileName,
183 IN FILETIME ExpireTime,
184 IN FILETIME LastModifiedTime,
185 IN DWORD CacheEntryType,
186 IN LPCWSTR lpHeaderInfo,
187 IN DWORD dwHeaderSize,
188 IN LPCWSTR lpszFileExtension,
189 IN LPCWSTR lpszOriginalUrl
190 )
191 {
192 if (!CommitUrlCacheEntryW(lpszUrlName, lpszLocalFileName, ExpireTime, LastModifiedTime, CacheEntryType,
193 lpHeaderInfo, dwHeaderSize, lpszFileExtension, lpszOriginalUrl))
194 {
195 return HRESULT_FROM_WIN32(GetLastError());
196 }
197 else
198 {
199 return S_OK;
200 }
201 }
202#endif // defined(_WININET_)
203
204#endif
205
206