Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

747 lines
31 KiB

  1. #include "stdafx.h"
  2. #include <msprintx.h>
  3. #include "shlwapi.h"
  4. #define _NO_NETSHARE_WRAPPERS_
  5. #include "mysvrapi.h"
  6. #define _NO_UNICWRAP_WRAPPERS_
  7. #include "unicwrap.h"
  8. #include "newapi.h"
  9. #include <netcon.h>
  10. #include <rasdlg.h>
  11. #include <tapi.h>
  12. #define NO_LOADING_OF_SHDOCVW_ONLY_FOR_WHICHPLATFORM
  13. #include "..\..\..\inc\dllload.c"
  14. #include <port32.h> // for BOOLFROMPTR used in DELAY_LOAD_NAME_VOID
  15. typedef enum _NETSETUP_NAME_TYPE {
  16. NetSetupUnknown = 0,
  17. NetSetupMachine,
  18. NetSetupWorkgroup,
  19. NetSetupDomain,
  20. NetSetupNonExistentDomain,
  21. #if(_WIN32_WINNT >= 0x0500)
  22. NetSetupDnsMachine
  23. #endif
  24. } NETSETUP_NAME_TYPE, *PNETSETUP_NAME_TYPE;
  25. // -----------shlwapi.dll---------------
  26. HMODULE g_hmodSHLWAPI = NULL;
  27. #undef wvnsprintfW
  28. DELAY_LOAD_NAME(g_hmodSHLWAPI, SHLWAPI, int, _wvnsprintfW, wvnsprintfW,
  29. (LPWSTR lpOut, int cchLimitIn, LPCWSTR lpFmt, va_list arglist),
  30. (lpOut, cchLimitIn, lpFmt, arglist));
  31. DELAY_LOAD_NAME_HRESULT(g_hmodSHLWAPI, SHLWAPI, _StrRetToBufW, StrRetToBufW,
  32. (STRRET* psr, LPCITEMIDLIST pidl, LPWSTR pszBuf, UINT cchBuf),
  33. (psr, pidl, pszBuf, cchBuf));
  34. DELAY_LOAD_ORD_ERR(g_hmodSHLWAPI, SHLWAPI, DWORD, _FormatMessageWrapW, 68,
  35. (DWORD dwFlags, LPCVOID lpSource, DWORD dwMessageId, DWORD dwLanguageId, LPWSTR lpBuffer, DWORD nSize, va_list* Arguments),
  36. (dwFlags, lpSource, dwMessageId, dwLanguageId, lpBuffer, nSize, Arguments), 0);
  37. DELAY_LOAD_ORD_VOID(g_hmodSHLWAPI, SHLWAPI, _SHSetWindowBits, 165,
  38. (HWND hWnd, int iWhich, DWORD dwBits, DWORD dwValue),
  39. (hWnd, iWhich, dwBits, dwValue));
  40. DELAY_LOAD_ORD_ERR(g_hmodSHLWAPI, SHLWAPI, int, _SHAnsiToUnicode, 215,
  41. (LPCSTR pszSrc, LPWSTR pwszDst, int cwchBuf),
  42. (pszSrc, pwszDst, cwchBuf), 0);
  43. DELAY_LOAD_ORD_ERR(g_hmodSHLWAPI, SHLWAPI, int, _SHAnsiToUnicodeCP, 216,
  44. (UINT uiCP, LPCSTR pszSrc, LPWSTR pwszDst, int cwchBuf),
  45. (uiCP, pszSrc, pwszDst, cwchBuf), 0);
  46. DELAY_LOAD_ORD_ERR(g_hmodSHLWAPI, SHLWAPI, int, _SHUnicodeToAnsi, 217,
  47. (LPCWSTR pwszSrc, LPSTR pszDst, int cchBuf),
  48. (pwszSrc, pszDst, cchBuf), 0);
  49. DELAY_LOAD_ORD_ERR(g_hmodSHLWAPI, SHLWAPI, BOOL, _GUIDFromStringA, 269,
  50. (LPCSTR psz, GUID *pguid),
  51. (psz, pguid), FALSE);
  52. DELAY_LOAD_ORD_ERR(g_hmodSHLWAPI, SHLWAPI, UINT, _WhichPlatform, 276,
  53. (void),
  54. (), PLATFORM_UNKNOWN);
  55. DELAY_LOAD_ORD_ERR(g_hmodSHLWAPI, SHLWAPI, BOOL, _WritePrivateProfileStringWrapW, 298,
  56. (LPCWSTR pwzAppName, LPCWSTR pwzKeyName, LPCWSTR pwzString, LPCWSTR pwzFileName),
  57. (pwzAppName, pwzKeyName, pwzString, pwzFileName), FALSE);
  58. DELAY_LOAD_ORD_ERR(g_hmodSHLWAPI, SHLWAPI, BOOL, _ExtTextOutWrapW, 299,
  59. (HDC hdc, int x, int y, UINT fuOptions, CONST RECT *lprc, LPCWSTR lpStr, UINT cch, CONST INT *lpDx),
  60. (hdc, x, y, fuOptions, lprc, lpStr, cch, lpDx), FALSE);
  61. DELAY_LOAD_ORD_ERR(g_hmodSHLWAPI, SHLWAPI, HINSTANCE, _LoadLibraryWrapW, 309,
  62. (LPCWSTR pwzLibFileName),
  63. (pwzLibFileName), NULL);
  64. DELAY_LOAD_ORD_ERR(g_hmodSHLWAPI, SHLWAPI, BOOL, _SHGetPathFromIDListWrapW, 334,
  65. (LPCITEMIDLIST pidl, LPWSTR pwzPath),
  66. (pidl, pwzPath), FALSE);
  67. DELAY_LOAD_ORD_ERR(g_hmodSHLWAPI, SHLWAPI, BOOL, _SetFileAttributesWrapW, 338,
  68. (LPCWSTR pwzFile, DWORD dwFileAttributes),
  69. (pwzFile, dwFileAttributes), FALSE);
  70. DELAY_LOAD_ORD_ERR(g_hmodSHLWAPI, SHLWAPI, int, _MessageBoxWrapW, 340,
  71. (HWND hwnd, LPCWSTR pwzText, LPCWSTR pwzCaption, UINT uType),
  72. (hwnd, pwzText, pwzCaption, uType), 0);
  73. DELAY_LOAD_ORD_ERR(g_hmodSHLWAPI, SHLWAPI, BOOL, _CreateProcessWrapW, 369,
  74. (LPCWSTR lpApplicationName, LPWSTR lpCommandLine, LPSECURITY_ATTRIBUTES lpProcessAttributes, LPSECURITY_ATTRIBUTES lpThreadAttributes, BOOL bInheritHandles, DWORD dwCreationFlags, LPVOID lpEnvironment, LPCWSTR lpCurrentDirectory, LPSTARTUPINFOW lpStartupInfo, LPPROCESS_INFORMATION lpProcessInformation),
  75. (lpApplicationName, lpCommandLine, lpProcessAttributes, lpThreadAttributes, bInheritHandles, dwCreationFlags, lpEnvironment, lpCurrentDirectory, lpStartupInfo, lpProcessInformation), FALSE);
  76. DELAY_LOAD_ORD_VOID(g_hmodSHLWAPI, SHLWAPI, _SHChangeNotify, 394,
  77. (LONG wEventId, UINT uFlags, LPCVOID dwItem1, LPCVOID dwItem2),
  78. (wEventId, uFlags, dwItem1, dwItem2));
  79. // -----------hhctrl.ocx---------------
  80. HMODULE g_hmodHHCtrl = NULL;
  81. DELAY_LOAD_EXT(g_hmodHHCtrl, hhctrl, OCX, HWND, HtmlHelpA,
  82. (HWND hwndCaller, LPCSTR pszFile, UINT uCommand, DWORD dwData),
  83. (hwndCaller, pszFile, uCommand, dwData))
  84. // --------- Shell32.dll (NT) -----------
  85. HINSTANCE g_hinstSHELL32 = NULL;
  86. DELAY_LOAD_NAME(g_hinstSHELL32, SHELL32, BOOL, LinkWindow_RegisterClass_NT, LinkWindow_RegisterClass, (), ());
  87. DELAY_LOAD_NAME(g_hinstSHELL32, SHELL32, LPITEMIDLIST, ILCreateFromPathW_NT, ILCreateFromPathW, (LPCWSTR pszPath), (pszPath));
  88. #undef SHGetFileInfoW
  89. DELAY_LOAD_NAME(g_hinstSHELL32, SHELL32, DWORD_PTR, SHGetFileInfoW_NT, SHGetFileInfoW,
  90. (LPCWSTR pszPath, DWORD dwFileAttributes, SHFILEINFOW *psfi, UINT cbFileInfo, UINT uFlags),
  91. (pszPath, dwFileAttributes, psfi, cbFileInfo, uFlags));
  92. // --------- KERNEL32.DLL (NT) ----------
  93. HINSTANCE g_hinstKERNEL32 = NULL;
  94. DELAY_LOAD_NAME(g_hinstKERNEL32, KERNEL32, BOOL, SetComputerNameExW_NT, SetComputerNameExW,
  95. (COMPUTER_NAME_FORMAT NameType, LPCWSTR lpBuffer),
  96. (NameType, lpBuffer));
  97. DELAY_LOAD_NAME(g_hinstKERNEL32, KERNEL32, BOOL, GetComputerNameExW_NT, GetComputerNameExW,
  98. (COMPUTER_NAME_FORMAT NameType, LPWSTR lpBuffer, LPDWORD lpnSize),
  99. (NameType, lpBuffer, lpnSize));
  100. // --------- NETSHELL.DLL (NT) ----------
  101. HINSTANCE g_hinstNETSHELL = NULL;
  102. DELAY_LOAD_VOID(g_hinstNETSHELL, NETSHELL, NcFreeNetconProperties,
  103. (NETCON_PROPERTIES* pprops),
  104. (pprops));
  105. // --------- ADVAPI32.DLL (NT) ----------
  106. HINSTANCE g_hinstADVAPI = NULL;
  107. DELAY_LOAD_NAME(g_hinstADVAPI, ADVAPI32, BOOL, AllocateAndInitializeSid_NT, AllocateAndInitializeSid,
  108. (PSID_IDENTIFIER_AUTHORITY pIdentifierAuthority, BYTE nSubAuthorityCount, DWORD dwSubAuthority0, DWORD dwSubAuthority1, DWORD dwSubAuthority2, DWORD dwSubAuthority3, DWORD dwSubAuthority4, DWORD dwSubAuthority5, DWORD dwSubAuthority6, DWORD dwSubAuthority7, PSID *pSid),
  109. (pIdentifierAuthority, nSubAuthorityCount, dwSubAuthority0, dwSubAuthority1, dwSubAuthority2, dwSubAuthority3, dwSubAuthority4, dwSubAuthority5, dwSubAuthority6, dwSubAuthority7, pSid));
  110. DELAY_LOAD_NAME(g_hinstADVAPI, ADVAPI32, BOOL, CheckTokenMembership_NT, CheckTokenMembership,
  111. (HANDLE TokenHandle, PSID SidToCheck, PBOOL IsMember),
  112. (TokenHandle, SidToCheck, IsMember));
  113. DELAY_LOAD_NAME(g_hinstADVAPI, ADVAPI32, PVOID, FreeSid_NT, FreeSid,
  114. (PSID SidToFree),
  115. (SidToFree));
  116. // --------- TAPI32.DLL ---------------
  117. /*
  118. HINSTANCE g_hinstTAPI32 = NULL;
  119. DELAY_LOAD(g_hinstTAPI32, TAPI32, LONG, lineInitializeExW,
  120. (LPHLINEAPP lphLineApp, HINSTANCE hInstance, LINECALLBACK lpfnCallback, LPCWSTR lpszFriendlyAppName, LPDWORD lpdwNumDevs, LPDWORD lpdwAPIVersion, LPLINEINITIALIZEEXPARAMS lpLineInitializeExParams),
  121. (lphLineApp, hInstance, lpfnCallback, lpszFriendlyAppName, lpdwNumDevs, lpdwAPIVersion, lpLineInitializeExParams));
  122. DELAY_LOAD(g_hinstTAPI32, TAPI32, LONG, lineInitializeExA,
  123. (LPHLINEAPP lphLineApp, HINSTANCE hInstance, LINECALLBACK lpfnCallback, LPCSTR lpszFriendlyAppName, LPDWORD lpdwNumDevs, LPDWORD lpdwAPIVersion, LPLINEINITIALIZEEXPARAMS lpLineInitializeExParams),
  124. (lphLineApp, hInstance, lpfnCallback, lpszFriendlyAppName, lpdwNumDevs, lpdwAPIVersion, lpLineInitializeExParams));
  125. */
  126. // --------- RASDLG.DLL ---------------
  127. HINSTANCE g_hinstRASDLG = NULL;
  128. DELAY_LOAD_BOOL(g_hinstRASDLG, RASDLG, RasDialDlgW,
  129. (LPWSTR lpszPhoneBook, LPWSTR lpszEntry, LPWSTR lpszPhoneNumber, LPRASDIALDLG lpInfo),
  130. (lpszPhoneBook, lpszEntry, lpszPhoneNumber, lpInfo));
  131. DELAY_LOAD_BOOL(g_hinstRASDLG, RASDLG, RasDialDlgA,
  132. (LPSTR lpszPhoneBook, LPSTR lpszEntry, LPSTR lpszPhoneNumber, LPRASDIALDLG lpInfo),
  133. (lpszPhoneBook, lpszEntry, lpszPhoneNumber, lpInfo));
  134. // --------- RASAPI32.DLL ---------------
  135. HINSTANCE g_hinstRASAPI32 = NULL;
  136. DELAY_LOAD_DWORD(g_hinstRASAPI32, RASAPI32, RasGetEntryPropertiesW,
  137. (LPCWSTR lpszPhoneBook, LPCWSTR lpszEntry, LPRASENTRYW lpRasEntryW, LPDWORD lpdwEntryInfoSize, LPBYTE lpbDeviceInfo, LPDWORD lpdwDeviceInfoSize),
  138. (lpszPhoneBook, lpszEntry, lpRasEntryW, lpdwEntryInfoSize, lpbDeviceInfo, lpdwDeviceInfoSize));
  139. DELAY_LOAD_DWORD(g_hinstRASAPI32, RASAPI32, RasGetEntryPropertiesA,
  140. (LPCSTR lpszPhoneBook, LPCSTR lpszEntry, LPRASENTRYA lpRasEntryA, LPDWORD lpdwEntryInfoSize, LPBYTE lpbDeviceInfo, LPDWORD lpdwDeviceInfoSize),
  141. (lpszPhoneBook, lpszEntry, lpRasEntryA, lpdwEntryInfoSize, lpbDeviceInfo, lpdwDeviceInfoSize));
  142. DELAY_LOAD_DWORD(g_hinstRASAPI32, RASAPI32, RasEnumEntriesW,
  143. (LPCWSTR reserved, LPCWSTR pszPhoneBookPath, LPRASENTRYNAMEW pRasEntryNameW, LPDWORD pcb, LPDWORD pcEntries),
  144. (reserved, pszPhoneBookPath, pRasEntryNameW, pcb, pcEntries));
  145. DELAY_LOAD_DWORD(g_hinstRASAPI32, RASAPI32, RasEnumEntriesA,
  146. (LPCSTR reserved, LPCSTR pszPhoneBookPath, LPRASENTRYNAMEA pRasEntryNameA, LPDWORD pcb, LPDWORD pcEntries),
  147. (reserved, pszPhoneBookPath, pRasEntryNameA, pcb, pcEntries));
  148. DELAY_LOAD_DWORD(g_hinstRASAPI32, RASAPI32, RasSetEntryDialParamsW,
  149. (LPCWSTR pszPhonebook, LPRASDIALPARAMSW lpRasDialParamsW, BOOL fRemovePassword),
  150. (pszPhonebook, lpRasDialParamsW, fRemovePassword));
  151. DELAY_LOAD_DWORD(g_hinstRASAPI32, RASAPI32, RasSetEntryDialParamsA,
  152. (LPCSTR pszPhonebook, LPRASDIALPARAMSA lpRasDialParamsA, BOOL fRemovePassword),
  153. (pszPhonebook, lpRasDialParamsA, fRemovePassword));
  154. DELAY_LOAD_DWORD(g_hinstRASAPI32, RASAPI32, RasGetEntryDialParamsW,
  155. (LPCWSTR pszPhonebook, LPRASDIALPARAMSW lpRasDialParamsW, LPBOOL pfRemovePassword),
  156. (pszPhonebook, lpRasDialParamsW, pfRemovePassword));
  157. DELAY_LOAD_DWORD(g_hinstRASAPI32, RASAPI32, RasGetEntryDialParamsA,
  158. (LPCSTR pszPhonebook, LPRASDIALPARAMSA lpRasDialParamsA, LPBOOL pfRemovePassword),
  159. (pszPhonebook, lpRasDialParamsA, pfRemovePassword));
  160. DELAY_LOAD_DWORD(g_hinstRASAPI32, RASAPI32, RasSetEntryPropertiesW,
  161. (LPCWSTR pszPhonebook, LPCWSTR pszEntry, LPRASENTRYW pRasEntryW, DWORD cbRasEntry, LPBYTE pbDeviceConfig, DWORD cbDeviceConfig),
  162. (pszPhonebook, pszEntry, pRasEntryW, cbRasEntry, pbDeviceConfig, cbDeviceConfig));
  163. DELAY_LOAD_DWORD(g_hinstRASAPI32, RASAPI32, RasSetEntryPropertiesA,
  164. (LPCSTR pszPhonebook, LPCSTR pszEntry, LPRASENTRYA pRasEntryA, DWORD cbRasEntry, LPBYTE pbDeviceConfig, DWORD cbDeviceConfig),
  165. (pszPhonebook, pszEntry, pRasEntryA, cbRasEntry, pbDeviceConfig, cbDeviceConfig));
  166. DELAY_LOAD_DWORD(g_hinstRASAPI32, RASAPI32, RnaGetDefaultAutodialConnection,
  167. (LPSTR szBuffer, DWORD cchBuffer, LPDWORD lpdwOptions),
  168. (szBuffer, cchBuffer, lpdwOptions));
  169. DELAY_LOAD_DWORD(g_hinstRASAPI32, RASAPI32, RnaSetDefaultAutodialConnection,
  170. (LPSTR szEntry, DWORD dwOptions),
  171. (szEntry, dwOptions));
  172. // Only on NT (rasapi32.dll)
  173. //DELAY_LOAD_DWORD(g_hinstRASAPI32, RASAPI32, RasShareConnection,
  174. // (LPRASSHARECONN pConn, GUID* pPrivateLanGuid),
  175. // (pConn, pPrivateLanGuid));
  176. //DELAY_LOAD_DWORD(g_hinstRASAPI32, RASAPI32, RasUnshareConnection,
  177. // (PBOOL pfWasShared),
  178. // (pfWasShared));
  179. // --------- OLE32.DLL ----------------
  180. HINSTANCE g_hmodOLE32 = NULL;
  181. // CoSetProxyBlanket not available on W95 Gold ole32.dll
  182. DELAY_LOAD_NAME_HRESULT(g_hmodOLE32, OLE32, CoSetProxyBlanket_NT, CoSetProxyBlanket,
  183. (IUnknown* pProxy, DWORD dwAuthnSvc, DWORD dwAuthzSvc, OLECHAR* pServerPrincName, DWORD dwAuthnLevel, DWORD dwImpLevel, RPC_AUTH_IDENTITY_HANDLE pAuthInfo, DWORD dwCapabilities),
  184. (pProxy, dwAuthnSvc, dwAuthzSvc, pServerPrincName, dwAuthnLevel, dwImpLevel, pAuthInfo, dwCapabilities));
  185. // --------- MPR.DLL ----------------
  186. HINSTANCE g_hmodMPR = NULL;
  187. DELAY_LOAD_WNET(g_hmodMPR, MPR, WNetOpenEnumW,
  188. (DWORD dwScope, DWORD dwType, DWORD dwUsage, LPNETRESOURCEW lpNetResource, LPHANDLE lphEnum),
  189. (dwScope, dwType, dwUsage, lpNetResource, lphEnum));
  190. DELAY_LOAD_WNET(g_hmodMPR, MPR, WNetOpenEnumA,
  191. (DWORD dwScope, DWORD dwType, DWORD dwUsage, LPNETRESOURCEA lpNetResource, LPHANDLE lphEnum),
  192. (dwScope, dwType, dwUsage, lpNetResource, lphEnum));
  193. DELAY_LOAD_WNET(g_hmodMPR, MPR, WNetEnumResourceW,
  194. (HANDLE hEnum, LPDWORD lpcCount, LPVOID lpBuffer, LPDWORD lpBufferSize),
  195. (hEnum, lpcCount, lpBuffer, lpBufferSize));
  196. DELAY_LOAD_WNET(g_hmodMPR, MPR, WNetEnumResourceA,
  197. (HANDLE hEnum, LPDWORD lpcCount, LPVOID lpBuffer, LPDWORD lpBufferSize),
  198. (hEnum, lpcCount, lpBuffer, lpBufferSize));
  199. DELAY_LOAD_WNET(g_hmodMPR, MPR, WNetCloseEnum, (HANDLE hEnum), (hEnum));
  200. DELAY_LOAD_WNET(g_hmodMPR, MPR, WNetGetUserW,
  201. (LPCWSTR lpName, LPWSTR lpUserName, LPDWORD lpnLength),
  202. (lpName, lpUserName, lpnLength));
  203. DELAY_LOAD_WNET(g_hmodMPR, MPR, WNetGetUserA,
  204. (LPCSTR lpName, LPSTR lpUserName, LPDWORD lpnLength),
  205. (lpName, lpUserName, lpnLength));
  206. // --------- WINSPOOL.DRV ----------------
  207. HINSTANCE g_hinstWINSPOOL_DRV = NULL;
  208. DELAY_LOAD_EXT(g_hinstWINSPOOL_DRV, WINSPOOL, DRV, BOOL, EnumPrintersW,
  209. (DWORD dwFlags, LPWSTR psz1, DWORD dw1, LPBYTE pb1, DWORD dw2, LPDWORD pdw2, LPDWORD pdw3),
  210. (dwFlags, psz1, dw1, pb1, dw2, pdw2, pdw3));
  211. DELAY_LOAD_EXT(g_hinstWINSPOOL_DRV, WINSPOOL, DRV, BOOL, EnumPrintersA,
  212. (DWORD dwFlags, LPSTR psz1, DWORD dw1, LPBYTE pb1, DWORD dw2, LPDWORD pdw2, LPDWORD pdw3),
  213. (dwFlags, psz1, dw1, pb1, dw2, pdw2, pdw3));
  214. DELAY_LOAD_EXT(g_hinstWINSPOOL_DRV, WINSPOOL, DRV, BOOL, GetDefaultPrinter, // NT only
  215. (LPTSTR szDefaultPrinter, LPDWORD pcch),
  216. (szDefaultPrinter, pcch));
  217. DELAY_LOAD_NAME_EXT_ERR(g_hinstWINSPOOL_DRV, Win32Spl, DRV, BOOL, OpenPrinter_NT, OpenPrinterW,
  218. (LPWSTR pPrinterName, LPHANDLE phPrinter, LPPRINTER_DEFAULTSW pDefault),
  219. (pPrinterName, phPrinter, pDefault), 0);
  220. DELAY_LOAD_NAME_EXT_ERR(g_hinstWINSPOOL_DRV, Win32Spl, DRV, BOOL, ClosePrinter_NT, ClosePrinter,
  221. (HANDLE hPrinter),
  222. (hPrinter), 0);
  223. DELAY_LOAD_NAME_EXT_ERR(g_hinstWINSPOOL_DRV, Win32Spl, DRV, BOOL, GetPrinter_NT, GetPrinterW,
  224. (HANDLE hPrinter, DWORD Level, LPBYTE pPrinter, DWORD cbBuf, LPDWORD pcbNeeded),
  225. (hPrinter, Level, pPrinter, cbBuf, pcbNeeded), 0);
  226. DELAY_LOAD_NAME_EXT_ERR(g_hinstWINSPOOL_DRV, Win32Spl, DRV, BOOL, SetPrinter_NT, SetPrinterW,
  227. (HANDLE hPrinter, DWORD Level, LPBYTE pPrinter, DWORD Command),
  228. (hPrinter, Level, pPrinter, Command), 0);
  229. // --------- SVRAPI.DLL (w9x) ----------------
  230. HINSTANCE g_hinstSVRAPI = NULL;
  231. DELAY_LOAD_NAME_ERR(g_hinstSVRAPI, SVRAPI, DWORD, NetShareEnum_W95, NetShareEnum,
  232. (const char FAR * pszServer, short sLevel, char FAR * pbBuffer, unsigned short cbBuffer, unsigned short FAR * pcEntriesRead, unsigned short FAR * pcTotalAvail),
  233. (pszServer, sLevel, pbBuffer, cbBuffer, pcEntriesRead, pcTotalAvail), ~NERR_Success);
  234. DELAY_LOAD_NAME_ERR(g_hinstSVRAPI, SVRAPI, DWORD, NetShareAdd_W95, NetShareAdd,
  235. (const char FAR * pszServer, short sLevel, const char FAR * pbBuffer, unsigned short cbBuffer),
  236. (pszServer, sLevel, pbBuffer, cbBuffer), ~NERR_Success);
  237. DELAY_LOAD_NAME_ERR(g_hinstSVRAPI, SVRAPI, DWORD, NetShareDel_W95, NetShareDel,
  238. (const char FAR * pszServer, const char FAR * pszNetName, unsigned short usReserved),
  239. (pszServer, pszNetName, usReserved), ~NERR_Success);
  240. DELAY_LOAD_NAME_ERR(g_hinstSVRAPI, SVRAPI, DWORD, NetShareGetInfo_W95, NetShareGetInfo,
  241. (const char FAR * pszServer, const char FAR * pszNetName, short sLevel, char FAR * pbBuffer, unsigned short cbBuffer, unsigned short FAR * pcbTotalAvail),
  242. (pszServer, pszNetName, sLevel, pbBuffer, cbBuffer, pcbTotalAvail), ~NERR_Success);
  243. DELAY_LOAD_NAME_ERR(g_hinstSVRAPI, SVRAPI, DWORD, NetShareSetInfo_W95, NetShareSetInfo,
  244. (const char FAR * pszServer, const char FAR * pszNetName, short sLevel, const char FAR * pbBuffer, unsigned short cbBuffer, short sParmNum),
  245. (pszServer, pszNetName, sLevel, pbBuffer, cbBuffer, sParmNum), ~NERR_Success);
  246. // --------- NETAPI32.DLL (NT) ----------------
  247. HINSTANCE g_hinstNETAPI32 = NULL;
  248. DELAY_LOAD_NAME_DWORD(g_hinstNETAPI32, NETAPI32, NetShareEnum_NT, NetShareEnum,
  249. (LPWSTR pszServer, DWORD level, LPBYTE * ppbuffer, DWORD cbbuffer, LPDWORD pcEntriesRead, LPDWORD pcTotalEntries, LPDWORD dsResumeHandle),
  250. (pszServer, level, ppbuffer, cbbuffer, pcEntriesRead, pcTotalEntries, dsResumeHandle));
  251. DELAY_LOAD_NAME_DWORD(g_hinstNETAPI32, NETAPI32, NetShareAdd_NT, NetShareAdd,
  252. (LPWSTR servername, DWORD level, LPBYTE buf, LPDWORD parm_err),
  253. (servername, level, buf, parm_err));
  254. DELAY_LOAD_NAME_DWORD(g_hinstNETAPI32, NETAPI32, NetShareDel_NT, NetShareDel,
  255. (LPWSTR servername, LPWSTR netname, DWORD reserved),
  256. (servername, netname, reserved));
  257. DELAY_LOAD_NAME_DWORD(g_hinstNETAPI32, NETAPI32, NetShareGetInfo_NT, NetShareGetInfo,
  258. (LPWSTR servername, LPWSTR netname, DWORD level, LPBYTE *bufptr),
  259. (servername, netname, level, bufptr));
  260. DELAY_LOAD_NAME_DWORD(g_hinstNETAPI32, NETAPI32, NetShareSetInfo_NT, NetShareSetInfo,
  261. (LPWSTR servername, LPWSTR netname, DWORD level, LPBYTE buf, LPDWORD parm_err),
  262. (servername, netname, level, buf, parm_err));
  263. DELAY_LOAD_NAME_DWORD(g_hinstNETAPI32, NETAPI32, NetServerGetInfo_NT, NetServerGetInfo,
  264. (LPWSTR servername, DWORD level, LPBYTE* pbuf),
  265. (servername, level, pbuf));
  266. DELAY_LOAD_NAME_DWORD(g_hinstNETAPI32, NETAPI32, NetServerSetInfo_NT, NetServerSetInfo,
  267. (LPWSTR servername, DWORD level, LPBYTE buf, LPDWORD parm_err),
  268. (servername, level, buf, parm_err));
  269. DELAY_LOAD_NAME_DWORD(g_hinstNETAPI32, NETAPI32, NetApiBufferFree_NT, NetApiBufferFree,
  270. (LPVOID Buffer), (Buffer));
  271. DELAY_LOAD_DWORD(g_hinstNETAPI32, NETAPI32, NetValidateName,
  272. (LPCWSTR pszServer, LPCWSTR pszName, LPCWSTR pszAccount, LPCWSTR pszPassword, NETSETUP_NAME_TYPE NameType),
  273. (pszServer, pszName, pszAccount, pszPassword, NameType));
  274. // We only use NetGetJoinInformation on NT anyway
  275. DELAY_LOAD_DWORD(g_hinstNETAPI32, NETAPI32, NetGetJoinInformation,
  276. (LPWSTR servername, LPWSTR* pbuffer, LPDWORD type),
  277. (servername, pbuffer, type));
  278. DELAY_LOAD_DWORD(g_hinstNETAPI32, NETAPI32, NetJoinDomain,
  279. (LPCWSTR lpServer, LPCWSTR lpDomain, LPCWSTR lpAccountOU, LPCWSTR lpAccount, LPCWSTR lpPassword, DWORD fJoinOptions),
  280. (lpServer, lpDomain, lpAccountOU, lpAccount, lpPassword, fJoinOptions));
  281. DELAY_LOAD_DWORD(g_hinstNETAPI32, NETAPI32, NetUnjoinDomain,
  282. (LPCWSTR lpServer, LPCWSTR lpAccount, LPCWSTR lpPassword, DWORD fUnjoinOptions),
  283. (lpServer, lpAccount, lpPassword, fUnjoinOptions));
  284. // ws2_32 for Network Location Awareness (NT)
  285. HINSTANCE g_hinstWS2_32 = NULL;
  286. DELAY_LOAD_NAME(g_hinstWS2_32, ws2_32, int, WSAStartup_NT, WSAStartup,
  287. (WORD wVersionRequested, LPWSADATA lpWSAData),
  288. (wVersionRequested, lpWSAData));
  289. DELAY_LOAD_NAME(g_hinstWS2_32, ws2_32, int, WSAGetLastError_NT, WSAGetLastError,
  290. (),
  291. ());
  292. DELAY_LOAD_NAME(g_hinstWS2_32, ws2_32, int, WSACleanup_NT, WSACleanup,
  293. (),
  294. ());
  295. DELAY_LOAD_NAME(g_hinstWS2_32, ws2_32, int, WSALookupServiceEnd_NT, WSALookupServiceEnd,
  296. (HANDLE hLookup),
  297. (hLookup));
  298. DELAY_LOAD_NAME(g_hinstWS2_32, ws2_32, int, WSALookupServiceBegin_NT, WSALookupServiceBegin,
  299. (LPWSAQUERYSET lpqsRestrictions, DWORD dwControlFlags, LPHANDLE lphLookup),
  300. (lpqsRestrictions, dwControlFlags, lphLookup));
  301. DELAY_LOAD_NAME(g_hinstWS2_32, ws2_32, int, WSALookupServiceNext_NT, WSALookupServiceNext,
  302. (HANDLE hLookup, DWORD dwControlFlags, LPDWORD lpdwBufferLength, LPWSAQUERYSET lpqsResults),
  303. (hLookup, dwControlFlags, lpdwBufferLength, lpqsResults));
  304. // --------- NCONN Thunks ----------------
  305. #include "netconn.h"
  306. BOOL g_fRunningOnNT;
  307. //
  308. // The thunk macros do the following:
  309. //
  310. // 1. Create a delay load W9x function for the given API using the delay
  311. // load map macros with Ncxp32.dll and a W9x_ prefix for the
  312. // function name.
  313. //
  314. // 2. Create a delay load NT function for the given API using the delay
  315. // load map macros with NCxpNT.dll and a NT_ prefix for the function
  316. // name.
  317. //
  318. // 3. Create the exported API of the given name that checks what platform
  319. // we're currently running on and calls the W9x or NT delay loaded
  320. // version of the API.
  321. //
  322. #define W9x_NT_THUNK(_W9xhinst, _W9xdll, _NThinst, _NTdll, _ret, _fn, _args, _nargs, _err) \
  323. \
  324. DELAY_LOAD_NAME_ERR(_NThinst, _NTdll, _ret, NT_##_fn, _fn, _args, _nargs, _err);\
  325. \
  326. DELAY_LOAD_NAME_ERR(_W9xhinst, _W9xdll, _ret, W9x_##_fn, _fn, _args, _nargs, _err);\
  327. \
  328. _ret _stdcall _fn _args \
  329. { \
  330. _ret ret; \
  331. \
  332. if (g_fRunningOnNT) \
  333. { \
  334. ret = NT_##_fn _nargs; \
  335. } \
  336. else \
  337. { \
  338. ret = W9x_##_fn _nargs; \
  339. } \
  340. \
  341. return ret; \
  342. }
  343. #define W9x_NT_THUNK_VOID(_W9xhinst, _W9xdll, _NThinst, _NTdll, _fn, _args, _nargs) \
  344. \
  345. DELAY_LOAD_NAME_VOID(_NThinst, _NTdll, NT_##_fn, _fn, _args, _nargs);\
  346. \
  347. DELAY_LOAD_NAME_VOID(_W9xhinst, _W9xdll, W9x_##_fn, _fn, _args, _nargs);\
  348. \
  349. void _stdcall _fn _args \
  350. { \
  351. if (g_fRunningOnNT) \
  352. { \
  353. NT_##_fn _nargs; \
  354. } \
  355. else \
  356. { \
  357. W9x_##_fn _nargs; \
  358. } \
  359. }
  360. //
  361. // Delay load thunk declarations for ncxpnt.dll and ncxp32.dll.
  362. //
  363. HINSTANCE g_hNcxp32 = NULL;
  364. HINSTANCE g_hNcxpNT = NULL;
  365. #define W9x_NT_NCONN_THUNK(_ret, _fn, _args, _nargs, _err) \
  366. W9x_NT_THUNK(g_hNcxp32, ncxp32, g_hNcxpNT, ncxpnt, _ret, _fn, _args, _nargs, _err)
  367. #define W9x_NT_NCONN_THUNK_VOID(_fn, _args, _nargs) \
  368. W9x_NT_THUNK_VOID(g_hNcxp32, ncxp32, g_hNcxpNT, ncxpnt, _fn, _args, _nargs)
  369. W9x_NT_NCONN_THUNK (LPVOID,
  370. NetConnAlloc,
  371. (DWORD cbAlloc),
  372. (cbAlloc),
  373. NULL);
  374. W9x_NT_NCONN_THUNK_VOID (NetConnFree,
  375. (LPVOID pMem),
  376. (pMem));
  377. W9x_NT_NCONN_THUNK (BOOL,
  378. IsProtocolInstalled,
  379. (LPCWSTR pszProtocolDeviceID, BOOL bExhaustive),
  380. (pszProtocolDeviceID, bExhaustive),
  381. FALSE);
  382. W9x_NT_NCONN_THUNK (HRESULT,
  383. InstallProtocol,
  384. (LPCWSTR pszProtocol, HWND hwndParent, PROGRESS_CALLBACK pfnCallback, LPVOID pvCallbackParam),
  385. (pszProtocol, hwndParent, pfnCallback, pvCallbackParam),
  386. E_FAIL);
  387. W9x_NT_NCONN_THUNK (HRESULT,
  388. InstallTCPIP,
  389. (HWND hwndParent, PROGRESS_CALLBACK pfnProgress, LPVOID pvProgressParam),
  390. (hwndParent, pfnProgress, pvProgressParam),
  391. E_FAIL);
  392. W9x_NT_NCONN_THUNK (HRESULT,
  393. RemoveProtocol,
  394. (LPCWSTR pszProtocol),
  395. (pszProtocol),
  396. E_FAIL);
  397. W9x_NT_NCONN_THUNK (BOOL,
  398. IsMSClientInstalled,
  399. (BOOL bExhaustive),
  400. (bExhaustive),
  401. FALSE);
  402. W9x_NT_NCONN_THUNK (HRESULT,
  403. InstallMSClient,
  404. (HWND hwndParent, PROGRESS_CALLBACK pfnProgress, LPVOID pvProgressParam),
  405. (hwndParent, pfnProgress, pvProgressParam),
  406. E_FAIL);
  407. W9x_NT_NCONN_THUNK (HRESULT,
  408. EnableBrowseMaster,
  409. (),
  410. (),
  411. E_FAIL);
  412. W9x_NT_NCONN_THUNK (BOOL,
  413. IsSharingInstalled,
  414. (BOOL bExhaustive),
  415. (bExhaustive),
  416. FALSE);
  417. W9x_NT_NCONN_THUNK (BOOL,
  418. IsFileSharingEnabled,
  419. (),
  420. (),
  421. FALSE);
  422. W9x_NT_NCONN_THUNK (BOOL,
  423. IsPrinterSharingEnabled,
  424. (),
  425. (),
  426. FALSE);
  427. W9x_NT_NCONN_THUNK (HRESULT,
  428. InstallSharing,
  429. (HWND hwndParent, PROGRESS_CALLBACK pfnProgress, LPVOID pvProgressParam),
  430. (hwndParent, pfnProgress, pvProgressParam),
  431. E_FAIL);
  432. W9x_NT_NCONN_THUNK (BOOL,
  433. FindConflictingService,
  434. (LPCWSTR pszWantService, NETSERVICE* pConflict),
  435. (pszWantService, pConflict),
  436. FALSE);
  437. W9x_NT_NCONN_THUNK (int,
  438. EnumNetAdapters,
  439. (NETADAPTER FAR** pprgNetAdapters),
  440. (pprgNetAdapters),
  441. 0);
  442. W9x_NT_NCONN_THUNK (HRESULT,
  443. InstallNetAdapter,
  444. (LPCWSTR pszDeviceID, LPCWSTR pszInfPath, HWND hwndParent, PROGRESS_CALLBACK pfnProgress, LPVOID pvCallbackParam),
  445. (pszDeviceID, pszInfPath, hwndParent, pfnProgress, pvCallbackParam),
  446. E_FAIL);
  447. W9x_NT_NCONN_THUNK (BOOL,
  448. IsAccessControlUserLevel,
  449. (),
  450. (),
  451. FALSE);
  452. W9x_NT_NCONN_THUNK (HRESULT,
  453. DisableUserLevelAccessControl,
  454. (),
  455. (),
  456. E_FAIL);
  457. W9x_NT_NCONN_THUNK (HRESULT,
  458. EnableQuickLogon,
  459. (),
  460. (),
  461. E_FAIL);
  462. W9x_NT_NCONN_THUNK (HRESULT,
  463. DetectHardware,
  464. (LPCWSTR pszDeviceID),
  465. (pszDeviceID),
  466. E_FAIL);
  467. W9x_NT_NCONN_THUNK (BOOL,
  468. IsProtocolBoundToAdapter,
  469. (LPCWSTR pszProtocolID, const NETADAPTER* pAdapter),
  470. (pszProtocolID, pAdapter),
  471. FALSE);
  472. W9x_NT_NCONN_THUNK (HRESULT,
  473. EnableNetAdapter,
  474. (const NETADAPTER* pAdapter),
  475. (pAdapter),
  476. E_FAIL);
  477. W9x_NT_NCONN_THUNK (BOOL,
  478. IsClientInstalled,
  479. (LPCWSTR pszClient, BOOL bExhaustive),
  480. (pszClient, bExhaustive),
  481. FALSE);
  482. W9x_NT_NCONN_THUNK (HRESULT,
  483. RemoveClient,
  484. (LPCWSTR pszClient),
  485. (pszClient),
  486. E_FAIL);
  487. W9x_NT_NCONN_THUNK (HRESULT,
  488. RemoveGhostedAdapters,
  489. (LPCWSTR pszDeviceID),
  490. (pszDeviceID),
  491. E_FAIL);
  492. W9x_NT_NCONN_THUNK (HRESULT,
  493. RemoveUnknownAdapters,
  494. (LPCWSTR pszDeviceID),
  495. (pszDeviceID),
  496. E_FAIL);
  497. W9x_NT_NCONN_THUNK (BOOL,
  498. DoesAdapterMatchDeviceID,
  499. (const NETADAPTER* pAdapter, LPCWSTR pszDeviceID),
  500. (pAdapter, pszDeviceID),
  501. FALSE);
  502. W9x_NT_NCONN_THUNK (BOOL,
  503. IsAdapterBroadband,
  504. (const NETADAPTER* pAdapter),
  505. (pAdapter),
  506. FALSE);
  507. W9x_NT_NCONN_THUNK_VOID (SaveBroadbandSettings,
  508. (LPCWSTR pszBroadbandAdapterNumber),
  509. (pszBroadbandAdapterNumber));
  510. W9x_NT_NCONN_THUNK (BOOL,
  511. UpdateBroadbandSettings,
  512. (LPWSTR pszEnumKeyBuf, int cchEnumKeyBuf),
  513. (pszEnumKeyBuf, cchEnumKeyBuf),
  514. FALSE);
  515. W9x_NT_NCONN_THUNK_VOID (EnableAutodial,
  516. (BOOL bAutodial, LPCWSTR pszConnection),
  517. (bAutodial, pszConnection));
  518. W9x_NT_NCONN_THUNK (BOOL,
  519. IsAutodialEnabled,
  520. (void),
  521. (),
  522. FALSE);
  523. W9x_NT_NCONN_THUNK_VOID (SetDefaultDialupConnection,
  524. (LPCWSTR pszConnectionName),
  525. (pszConnectionName));
  526. W9x_NT_NCONN_THUNK_VOID (GetDefaultDialupConnection,
  527. (LPWSTR pszConnectionName, int cchMax),
  528. (pszConnectionName, cchMax));
  529. W9x_NT_NCONN_THUNK (int,
  530. EnumMatchingNetBindings,
  531. (LPCWSTR pszParentBinding, LPCWSTR pszDeviceID, LPWSTR** pprgBindings),
  532. (pszParentBinding, pszDeviceID, pprgBindings),
  533. 0);
  534. W9x_NT_NCONN_THUNK (HRESULT,
  535. RestartNetAdapter,
  536. (DWORD devnode),
  537. (devnode),
  538. E_FAIL);
  539. W9x_NT_NCONN_THUNK (HRESULT,
  540. HrFromLastWin32Error,
  541. (void),
  542. (),
  543. E_FAIL);
  544. W9x_NT_NCONN_THUNK (HRESULT,
  545. HrWideCharToMultiByte,
  546. (const WCHAR* szwString, char** ppszString),
  547. (szwString, ppszString),
  548. E_FAIL);
  549. W9x_NT_NCONN_THUNK (HRESULT,
  550. HrEnableDhcp,
  551. (VOID* pContext, DWORD dwFlags),
  552. (pContext, dwFlags),
  553. E_FAIL);
  554. W9x_NT_NCONN_THUNK (BOOLEAN,
  555. IsAdapterDisconnected,
  556. (VOID* pContext),
  557. (pContext),
  558. FALSE);
  559. W9x_NT_NCONN_THUNK (HRESULT,
  560. IcsUninstall,
  561. (void),
  562. (),
  563. E_FAIL);
  564. //
  565. // Delay load thunk declarations for internet connection sharing.
  566. //
  567. HINSTANCE g_hicsapi32 = NULL;
  568. HINSTANCE g_hicsapint = NULL;
  569. #define W9x_NT_ICS_THUNK(_ret, _fn, _args, _nargs, _err) \
  570. W9x_NT_THUNK(g_hicsapi32, icsapi32, g_hicsapint, dontknow, _ret, _fn, _args, _nargs, _err)
  571. W9x_NT_ICS_THUNK(DWORD, IcsEnable, (DWORD dwOptions), (dwOptions), 0);
  572. W9x_NT_ICS_THUNK(DWORD, IcsDisable, (DWORD dwOptions), (dwOptions), 0);
  573. W9x_NT_ICS_THUNK(BOOLEAN, IsIcsEnabled, (), (), FALSE);
  574. W9x_NT_ICS_THUNK(BOOLEAN, IsIcsAvailable, (), (), FALSE);