| 1 | package com.github.markusbernhardt.proxy.jna.win; |
| 2 | |
| 3 | import com.sun.jna.Native; |
| 4 | import com.sun.jna.platform.win32.WTypes; |
| 5 | import com.sun.jna.platform.win32.WinDef; |
| 6 | import com.sun.jna.win32.StdCallLibrary; |
| 7 | import com.sun.jna.win32.W32APIOptions; |
| 8 | |
| 9 | /** |
| 10 | * WinHttp.dll Interface. |
| 11 | * |
| 12 | * @author Markus Bernhardt, Copyright 2016 |
| 13 | */ |
| 14 | public interface WinHttp extends StdCallLibrary { |
| 15 | |
| 16 | WinHttp INSTANCE = (WinHttp) Native.loadLibrary("winhttp", WinHttp.class, W32APIOptions.UNICODE_OPTIONS); |
| 17 | |
| 18 | /** |
| 19 | * Use DHCP to locate the proxy auto-configuration file. |
| 20 | */ |
| 21 | int WINHTTP_AUTO_DETECT_TYPE_DHCP = 0x00000001; |
| 22 | |
| 23 | /** |
| 24 | * Use DNS to attempt to locate the proxy auto-configuration file at a |
| 25 | * well-known location on the domain of the local computer. |
| 26 | */ |
| 27 | int WINHTTP_AUTO_DETECT_TYPE_DNS_A = 0x00000002; |
| 28 | |
| 29 | /** |
| 30 | * Resolves all host names directly without a proxy. |
| 31 | */ |
| 32 | int WINHTTP_ACCESS_TYPE_DEFAULT_PROXY = 0; |
| 33 | |
| 34 | /** |
| 35 | * Retrieves the static proxy or direct configuration from the registry. |
| 36 | * WINHTTP_ACCESS_TYPE_DEFAULT_PROXY does not inherit browser proxy |
| 37 | * settings. WinHTTP does not share any proxy settings with Internet |
| 38 | * Explorer. |
| 39 | * <p> |
| 40 | * The WinHTTP proxy configuration is set by one of these mechanisms. |
| 41 | * <ul> |
| 42 | * <li>The proxycfg.exe utility on Windows XP and Windows Server 2003 or |
| 43 | * earlier.</li> |
| 44 | * <li>The netsh.exe utility on Windows Vista and Windows Server 2008 or |
| 45 | * later.</li> |
| 46 | * <li>WinHttpSetDefaultProxyConfiguration on all platforms.</li> |
| 47 | * </ul> |
| 48 | */ |
| 49 | int WINHTTP_ACCESS_TYPE_NO_PROXY = 1; |
| 50 | |
| 51 | /** |
| 52 | * Passes requests to the proxy unless a proxy bypass list is supplied and |
| 53 | * the name to be resolved bypasses the proxy. In this case, this function |
| 54 | * uses WINHTTP_ACCESS_TYPE_NAMED_PROXY. |
| 55 | */ |
| 56 | int WINHTTP_ACCESS_TYPE_NAMED_PROXY = 3; |
| 57 | |
| 58 | /** |
| 59 | * The WinHttpDetectAutoProxyConfigUrl function finds the URL for the Proxy |
| 60 | * Auto-Configuration (PAC) file. This function reports the URL of the PAC |
| 61 | * file, but it does not download the file. |
| 62 | * |
| 63 | * @param dwAutoDetectFlags |
| 64 | * A data type that specifies what protocols to use to locate the |
| 65 | * PAC file. If both the DHCP and DNS auto detect flags are set, |
| 66 | * DHCP is used first; if no PAC URL is discovered using DHCP, |
| 67 | * then DNS is used. Set {@code WINHTTP_AUTO_DETECT_TYPE_DHCP}, |
| 68 | * {@code WINHTTP_AUTO_DETECT_TYPE_DNS_A} or both. |
| 69 | * @param ppwszAutoConfigUrl |
| 70 | * A data type that returns a pointer to a null-terminated |
| 71 | * Unicode string that contains the configuration URL that |
| 72 | * receives the proxy data. You must free the string pointed to |
| 73 | * by ppwszAutoConfigUrl using the GlobalFree function. |
| 74 | * @return {@code true} if successful; otherwise, {@code false}. |
| 75 | */ |
| 76 | boolean WinHttpDetectAutoProxyConfigUrl(WinDef.DWORD dwAutoDetectFlags, WTypes.LPWSTR ppwszAutoConfigUrl); |
| 77 | |
| 78 | /** |
| 79 | * The WinHttpGetDefaultProxyConfiguration function retrieves the default |
| 80 | * WinHTTP proxy configuration from the registry. |
| 81 | * |
| 82 | * @param pProxyInfo |
| 83 | * A pointer to a variable of type WINHTTP_PROXY_INFO that |
| 84 | * receives the default proxy configuration. |
| 85 | * @return {@code true} if successful; otherwise, {@code false}. |
| 86 | */ |
| 87 | boolean WinHttpGetDefaultProxyConfiguration(WinHttpProxyInfo pProxyInfo); |
| 88 | |
| 89 | /** |
| 90 | * The WinHttpGetIEProxyConfigForCurrentUser function retrieves the Internet |
| 91 | * Explorer proxy configuration for the current user. |
| 92 | * |
| 93 | * @param pProxyConfig |
| 94 | * A pointer, on input, to a WINHTTP_CURRENT_USER_IE_PROXY_CONFIG |
| 95 | * structure. On output, the structure contains the Internet |
| 96 | * Explorer proxy settings for the current active network |
| 97 | * connection (for example, LAN, dial-up, or VPN connection). |
| 98 | * @return {@code true} if successful; otherwise, {@code false}. |
| 99 | */ |
| 100 | boolean WinHttpGetIEProxyConfigForCurrentUser(WinHttpCurrentUserIEProxyConfig pProxyConfig); |
| 101 | |
| 102 | } |