ReactOS 0.4.15-dev-6669-g8227c5d
main.c File Reference
#include <stdarg.h>
#include <sys/types.h>
#include "windef.h"
#include "winbase.h"
#include "winsock2.h"
#include "ws2ipdef.h"
#include "ws2tcpip.h"
#include "winnls.h"
#include "wininet.h"
#include "ole2.h"
#include "dispex.h"
#include "activscp.h"
#include "wine/debug.h"
#include "wine/heap.h"
Include dependency graph for main.c:

Go to the source code of this file.

Classes

struct  pac_script
 

Macros

#define COBJMACROS
 
#define DISPID_GLOBAL_DNSRESOLVE   0x1000
 
#define IActiveScriptParse_Release   IActiveScriptParse32_Release
 
#define IActiveScriptParse_InitNew   IActiveScriptParse32_InitNew
 
#define IActiveScriptParse_ParseScriptText   IActiveScriptParse32_ParseScriptText
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (jsproxy)
 
BOOL WINAPI DllMain (HINSTANCE hinst, DWORD reason, LPVOID reserved)
 
static WCHARstrdupAW (const char *src, int len)
 
static charstrdupWA (const WCHAR *src)
 
BOOL WINAPI InternetDeInitializeAutoProxyDll (LPSTR mime, DWORD reserved)
 
static WCHARload_script (const char *filename)
 
BOOL WINAPI JSPROXY_InternetInitializeAutoProxyDll (DWORD version, LPSTR tmpfile, LPSTR mime, AutoProxyHelperFunctions *callbacks, LPAUTO_PROXY_SCRIPT_BUFFER buffer)
 
static HRESULT WINAPI dispex_QueryInterface (IDispatchEx *iface, REFIID riid, void **ppv)
 
static ULONG WINAPI dispex_AddRef (IDispatchEx *iface)
 
static ULONG WINAPI dispex_Release (IDispatchEx *iface)
 
static HRESULT WINAPI dispex_GetTypeInfoCount (IDispatchEx *iface, UINT *info)
 
static HRESULT WINAPI dispex_GetTypeInfo (IDispatchEx *iface, UINT info, LCID lcid, ITypeInfo **type_info)
 
static HRESULT WINAPI dispex_GetIDsOfNames (IDispatchEx *iface, REFIID riid, LPOLESTR *names, UINT count, LCID lcid, DISPID *id)
 
static HRESULT WINAPI dispex_Invoke (IDispatchEx *iface, DISPID member, REFIID riid, LCID lcid, WORD flags, DISPPARAMS *params, VARIANT *result, EXCEPINFO *excep, UINT *err)
 
static HRESULT WINAPI dispex_DeleteMemberByName (IDispatchEx *iface, BSTR name, DWORD flags)
 
static HRESULT WINAPI dispex_DeleteMemberByDispID (IDispatchEx *iface, DISPID id)
 
static HRESULT WINAPI dispex_GetMemberProperties (IDispatchEx *iface, DISPID id, DWORD flags_fetch, DWORD *flags)
 
static HRESULT WINAPI dispex_GetMemberName (IDispatchEx *iface, DISPID id, BSTR *name)
 
static HRESULT WINAPI dispex_GetNextDispID (IDispatchEx *iface, DWORD flags, DISPID id, DISPID *next)
 
static HRESULT WINAPI dispex_GetNameSpaceParent (IDispatchEx *iface, IUnknown **unk)
 
static HRESULT WINAPI dispex_GetDispID (IDispatchEx *iface, BSTR name, DWORD flags, DISPID *id)
 
static charget_computer_name (COMPUTER_NAME_FORMAT format)
 
static void printf_addr (const WCHAR *fmt, WCHAR *buf, SIZE_T size, struct sockaddr_in *addr)
 
static HRESULT dns_resolve (const WCHAR *hostname, VARIANT *result)
 
static HRESULT WINAPI dispex_InvokeEx (IDispatchEx *iface, DISPID id, LCID lcid, WORD flags, DISPPARAMS *params, VARIANT *result, EXCEPINFO *exep, IServiceProvider *caller)
 
static HRESULT WINAPI site_QueryInterface (IActiveScriptSite *iface, REFIID riid, void **ppv)
 
static ULONG WINAPI site_AddRef (IActiveScriptSite *iface)
 
static ULONG WINAPI site_Release (IActiveScriptSite *iface)
 
static HRESULT WINAPI site_GetLCID (IActiveScriptSite *iface, LCID *lcid)
 
static HRESULT WINAPI site_GetItemInfo (IActiveScriptSite *iface, LPCOLESTR name, DWORD mask, IUnknown **item, ITypeInfo **type_info)
 
static HRESULT WINAPI site_GetDocVersionString (IActiveScriptSite *iface, BSTR *version)
 
static HRESULT WINAPI site_OnScriptTerminate (IActiveScriptSite *iface, const VARIANT *result, const EXCEPINFO *info)
 
static HRESULT WINAPI site_OnStateChange (IActiveScriptSite *iface, SCRIPTSTATE state)
 
static HRESULT WINAPI site_OnScriptError (IActiveScriptSite *iface, IActiveScriptError *error)
 
static HRESULT WINAPI site_OnEnterScript (IActiveScriptSite *iface)
 
static HRESULT WINAPI site_OnLeaveScript (IActiveScriptSite *iface)
 
static BSTR include_pac_utils (const WCHAR *script)
 
static BOOL run_script (const WCHAR *script, const WCHAR *url, const WCHAR *hostname, char **result_str, DWORD *result_len)
 
BOOL WINAPI InternetGetProxyInfo (LPCSTR url, DWORD len_url, LPCSTR hostname, DWORD len_hostname, LPSTR *proxy, LPDWORD len_proxy)
 

Variables

static HINSTANCE instance
 
static CRITICAL_SECTION cs_jsproxy = { &critsect_debug, -1, 0, 0, 0, 0 }
 
static CRITICAL_SECTION_DEBUG critsect_debug
 
static const WCHAR global_funcsW [] = {'g','l','o','b','a','l','_','f','u','n','c','s',0}
 
static const WCHAR dns_resolveW [] = {'d','n','s','_','r','e','s','o','l','v','e',0}
 
static struct pac_script pac_script
 
static struct pac_scriptglobal_script = &pac_script
 
static const IDispatchExVtbl dispex_vtbl
 
static IDispatchEx global_dispex = { &dispex_vtbl }
 
static const IActiveScriptSiteVtbl site_vtbl
 
static IActiveScriptSite script_site = { &site_vtbl }
 

Macro Definition Documentation

◆ COBJMACROS

#define COBJMACROS

Definition at line 34 of file main.c.

◆ DISPID_GLOBAL_DNSRESOLVE

#define DISPID_GLOBAL_DNSRESOLVE   0x1000

Definition at line 275 of file main.c.

◆ IActiveScriptParse_InitNew

#define IActiveScriptParse_InitNew   IActiveScriptParse32_InitNew

Definition at line 505 of file main.c.

◆ IActiveScriptParse_ParseScriptText

#define IActiveScriptParse_ParseScriptText   IActiveScriptParse32_ParseScriptText

Definition at line 506 of file main.c.

◆ IActiveScriptParse_Release

#define IActiveScriptParse_Release   IActiveScriptParse32_Release

Definition at line 504 of file main.c.

Function Documentation

◆ dispex_AddRef()

static ULONG WINAPI dispex_AddRef ( IDispatchEx iface)
static

Definition at line 202 of file main.c.

204{
205 return 2;
206}

◆ dispex_DeleteMemberByDispID()

static HRESULT WINAPI dispex_DeleteMemberByDispID ( IDispatchEx iface,
DISPID  id 
)
static

Definition at line 245 of file main.c.

247{
248 return E_NOTIMPL;
249}
#define E_NOTIMPL
Definition: ddrawi.h:99

◆ dispex_DeleteMemberByName()

static HRESULT WINAPI dispex_DeleteMemberByName ( IDispatchEx iface,
BSTR  name,
DWORD  flags 
)
static

Definition at line 239 of file main.c.

241{
242 return E_NOTIMPL;
243}

◆ dispex_GetDispID()

static HRESULT WINAPI dispex_GetDispID ( IDispatchEx iface,
BSTR  name,
DWORD  flags,
DISPID id 
)
static

Definition at line 277 of file main.c.

279{
280 if (!lstrcmpW( name, dns_resolveW ))
281 {
283 return S_OK;
284 }
285 return DISP_E_UNKNOWNNAME;
286}
static const WCHAR dns_resolveW[]
Definition: main.c:56
#define DISPID_GLOBAL_DNSRESOLVE
Definition: main.c:275
#define S_OK
Definition: intsafe.h:52
int WINAPI lstrcmpW(LPCWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:170
Definition: name.c:39
#define DISP_E_UNKNOWNNAME
Definition: winerror.h:2515

◆ dispex_GetIDsOfNames()

static HRESULT WINAPI dispex_GetIDsOfNames ( IDispatchEx iface,
REFIID  riid,
LPOLESTR names,
UINT  count,
LCID  lcid,
DISPID id 
)
static

Definition at line 226 of file main.c.

228{
229 return E_NOTIMPL;
230}

◆ dispex_GetMemberName()

static HRESULT WINAPI dispex_GetMemberName ( IDispatchEx iface,
DISPID  id,
BSTR name 
)
static

Definition at line 257 of file main.c.

259{
260 return E_NOTIMPL;
261}

◆ dispex_GetMemberProperties()

static HRESULT WINAPI dispex_GetMemberProperties ( IDispatchEx iface,
DISPID  id,
DWORD  flags_fetch,
DWORD flags 
)
static

Definition at line 251 of file main.c.

253{
254 return E_NOTIMPL;
255}

◆ dispex_GetNameSpaceParent()

static HRESULT WINAPI dispex_GetNameSpaceParent ( IDispatchEx iface,
IUnknown **  unk 
)
static

Definition at line 269 of file main.c.

271{
272 return E_NOTIMPL;
273}

◆ dispex_GetNextDispID()

static HRESULT WINAPI dispex_GetNextDispID ( IDispatchEx iface,
DWORD  flags,
DISPID  id,
DISPID next 
)
static

Definition at line 263 of file main.c.

265{
266 return E_NOTIMPL;
267}

◆ dispex_GetTypeInfo()

static HRESULT WINAPI dispex_GetTypeInfo ( IDispatchEx iface,
UINT  info,
LCID  lcid,
ITypeInfo **  type_info 
)
static

Definition at line 220 of file main.c.

222{
223 return E_NOTIMPL;
224}

◆ dispex_GetTypeInfoCount()

static HRESULT WINAPI dispex_GetTypeInfoCount ( IDispatchEx iface,
UINT info 
)
static

Definition at line 214 of file main.c.

216{
217 return E_NOTIMPL;
218}

◆ dispex_Invoke()

static HRESULT WINAPI dispex_Invoke ( IDispatchEx iface,
DISPID  member,
REFIID  riid,
LCID  lcid,
WORD  flags,
DISPPARAMS *  params,
VARIANT result,
EXCEPINFO *  excep,
UINT err 
)
static

Definition at line 232 of file main.c.

235{
236 return E_NOTIMPL;
237}

◆ dispex_InvokeEx()

static HRESULT WINAPI dispex_InvokeEx ( IDispatchEx iface,
DISPID  id,
LCID  lcid,
WORD  flags,
DISPPARAMS *  params,
VARIANT result,
EXCEPINFO *  exep,
IServiceProvider caller 
)
static

Definition at line 345 of file main.c.

348{
349 if (id == DISPID_GLOBAL_DNSRESOLVE)
350 {
351 if (params->cArgs != 1) return DISP_E_BADPARAMCOUNT;
352 if (V_VT(&params->rgvarg[0]) != VT_BSTR) return DISP_E_BADVARTYPE;
353 return dns_resolve( V_BSTR(&params->rgvarg[0]), result );
354 }
356}
@ VT_BSTR
Definition: compat.h:2303
static HRESULT dns_resolve(const WCHAR *hostname, VARIANT *result)
Definition: main.c:313
GLenum const GLfloat * params
Definition: glext.h:5645
GLuint64EXT * result
Definition: glext.h:11304
#define V_VT(A)
Definition: oleauto.h:211
#define V_BSTR(A)
Definition: oleauto.h:226
#define DISP_E_BADVARTYPE
Definition: winerror.h:2517
#define DISP_E_BADPARAMCOUNT
Definition: winerror.h:2523
#define DISP_E_MEMBERNOTFOUND
Definition: winerror.h:2512

◆ dispex_QueryInterface()

static HRESULT WINAPI dispex_QueryInterface ( IDispatchEx iface,
REFIID  riid,
void **  ppv 
)
static

Definition at line 187 of file main.c.

189{
190 *ppv = NULL;
191
192 if (IsEqualGUID( riid, &IID_IUnknown ) ||
194 IsEqualGUID( riid, &IID_IDispatchEx ))
195 *ppv = iface;
196 else
197 return E_NOINTERFACE;
198
199 return S_OK;
200}
const GUID IID_IUnknown
#define NULL
Definition: types.h:112
REFIID riid
Definition: atlbase.h:39
REFIID LPVOID * ppv
Definition: atlbase.h:39
const GUID IID_IDispatch
#define IsEqualGUID(rguid1, rguid2)
Definition: guiddef.h:147
#define E_NOINTERFACE
Definition: winerror.h:2364

◆ dispex_Release()

static ULONG WINAPI dispex_Release ( IDispatchEx iface)
static

Definition at line 208 of file main.c.

210{
211 return 1;
212}

◆ DllMain()

BOOL WINAPI DllMain ( HINSTANCE  hinst,
DWORD  reason,
LPVOID  reserved 
)

Definition at line 61 of file main.c.

62{
63 switch (reason)
64 {
68 break;
69
71 break;
72 }
73 return TRUE;
74}
#define TRUE
Definition: types.h:120
static HINSTANCE instance
Definition: main.c:40
static WCHAR reason[MAX_STRING_RESOURCE_LEN]
Definition: object.c:1904
#define DLL_PROCESS_ATTACH
Definition: compat.h:131
#define DLL_PROCESS_DETACH
Definition: compat.h:130
BOOL WINAPI DisableThreadLibraryCalls(IN HMODULE hLibModule)
Definition: loader.c:85
static HINSTANCE hinst
Definition: edit.c:551

◆ dns_resolve()

static HRESULT dns_resolve ( const WCHAR hostname,
VARIANT result 
)
static

Definition at line 313 of file main.c.

314{
315 static const WCHAR fmtW[] = {'%','u','.','%','u','.','%','u','.','%','u',0};
316 WCHAR addr[16];
317 struct addrinfo *ai, *elem;
318 char *hostnameA;
319 int res;
320
321 if (hostname[0])
322 hostnameA = strdupWA( hostname );
323 else
324 hostnameA = get_computer_name( ComputerNamePhysicalDnsFullyQualified );
325
326 if (!hostnameA) return E_OUTOFMEMORY;
327 res = getaddrinfo( hostnameA, NULL, NULL, &ai );
328 heap_free( hostnameA );
329 if (res) return S_FALSE;
330
331 elem = ai;
332 while (elem && elem->ai_family != AF_INET) elem = elem->ai_next;
333 if (!elem)
334 {
335 freeaddrinfo( ai );
336 return S_FALSE;
337 }
338 printf_addr( fmtW, addr, ARRAY_SIZE(addr), (struct sockaddr_in *)elem->ai_addr );
339 freeaddrinfo( ai );
340 V_VT( result ) = VT_BSTR;
342 return S_OK;
343}
static BOOL heap_free(void *mem)
Definition: appwiz.h:76
char * hostname
Definition: ftp.c:88
#define ARRAY_SIZE(A)
Definition: main.h:33
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
static char * strdupWA(const WCHAR *src)
Definition: main.c:91
static void printf_addr(const WCHAR *fmt, WCHAR *buf, SIZE_T size, struct sockaddr_in *addr)
Definition: main.c:304
static char * get_computer_name(COMPUTER_NAME_FORMAT format)
Definition: main.c:288
#define AF_INET
Definition: tcpip.h:117
GLuint res
Definition: glext.h:9613
GLenum const GLvoid * addr
Definition: glext.h:9621
static size_t elem
Definition: string.c:68
BSTR WINAPI SysAllocString(LPCOLESTR str)
Definition: oleaut.c:238
#define S_FALSE
Definition: winerror.h:2357
#define getaddrinfo
Definition: wspiapi.h:44
#define freeaddrinfo
Definition: wspiapi.h:46
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by dispex_InvokeEx().

◆ get_computer_name()

static char * get_computer_name ( COMPUTER_NAME_FORMAT  format)
static

Definition at line 288 of file main.c.

289{
290 char *ret;
291 DWORD size = 0;
292
294 if (GetLastError() != ERROR_MORE_DATA) return NULL;
295 if (!(ret = heap_alloc( size ))) return NULL;
297 {
298 heap_free( ret );
299 return NULL;
300 }
301 return ret;
302}
static void * heap_alloc(size_t len)
Definition: appwiz.h:66
#define ERROR_MORE_DATA
Definition: dderror.h:13
unsigned long DWORD
Definition: ntddk_ex.h:95
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl.h:1546
GLsizeiptr size
Definition: glext.h:5919
BOOL WINAPI GetComputerNameExA(COMPUTER_NAME_FORMAT, LPSTR, LPDWORD)
Definition: compname.c:376
int ret
DWORD WINAPI GetLastError(void)
Definition: except.c:1042

Referenced by dns_resolve().

◆ include_pac_utils()

static BSTR include_pac_utils ( const WCHAR script)
static

Definition at line 478 of file main.c.

479{
480 static const WCHAR pacjsW[] = {'p','a','c','.','j','s',0};
481 HMODULE hmod = GetModuleHandleA( "jsproxy.dll" );
482 HRSRC rsrc;
483 DWORD size;
484 const char *data;
485 BSTR ret;
486 int len;
487
488 if (!(rsrc = FindResourceW( hmod, pacjsW, (LPCWSTR)40 ))) return NULL;
489 size = SizeofResource( hmod, rsrc );
490 data = LoadResource( hmod, rsrc );
491
493 if (!(ret = SysAllocStringLen( NULL, len + lstrlenW( script ) + 1 ))) return NULL;
495 lstrcpyW( ret + len, script );
496 return ret;
497}
#define CP_ACP
Definition: compat.h:109
OLECHAR * BSTR
Definition: compat.h:2293
#define lstrcpyW
Definition: compat.h:749
#define MultiByteToWideChar
Definition: compat.h:110
#define lstrlenW
Definition: compat.h:750
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Definition: loader.c:812
HRSRC WINAPI FindResourceW(HINSTANCE hModule, LPCWSTR name, LPCWSTR type)
Definition: res.c:176
DWORD WINAPI SizeofResource(HINSTANCE hModule, HRSRC hRsrc)
Definition: res.c:568
HGLOBAL WINAPI LoadResource(HINSTANCE hModule, HRSRC hRsrc)
Definition: res.c:532
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
GLenum GLsizei len
Definition: glext.h:6722
static PEXPLICIT_ACCESSW *static HMODULE hmod
Definition: security.c:143
script
Definition: msipriv.h:383
BSTR WINAPI SysAllocStringLen(const OLECHAR *str, unsigned int len)
Definition: oleaut.c:339
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185

Referenced by run_script().

◆ InternetDeInitializeAutoProxyDll()

BOOL WINAPI InternetDeInitializeAutoProxyDll ( LPSTR  mime,
DWORD  reserved 
)

Definition at line 111 of file main.c.

112{
113 TRACE( "%s, %u\n", debugstr_a(mime), reserved );
114
116
117 heap_free( global_script->text );
118 global_script->text = NULL;
119
121 return TRUE;
122}
static CRITICAL_SECTION cs_jsproxy
Definition: main.c:46
static struct pac_script * global_script
Definition: main.c:106
r reserved
Definition: btrfs.c:3006
#define debugstr_a
Definition: kernel32.h:31
const WCHAR * mime
Definition: mimefilter.c:512
#define TRACE(s)
Definition: solgame.cpp:4
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)

Referenced by run_script().

◆ InternetGetProxyInfo()

BOOL WINAPI InternetGetProxyInfo ( LPCSTR  url,
DWORD  len_url,
LPCSTR  hostname,
DWORD  len_hostname,
LPSTR proxy,
LPDWORD  len_proxy 
)

Definition at line 598 of file main.c.

600{
601 WCHAR *urlW = NULL, *hostnameW = NULL;
602 BOOL ret = FALSE;
603
604 TRACE( "%s, %u, %s, %u, %p, %p\n", debugstr_a(url), len_url, hostname, len_hostname, proxy, len_proxy );
605
607
608 if (!global_script->text)
609 {
611 goto done;
612 }
613 if (hostname && len_hostname < strlen( hostname ))
614 {
616 goto done;
617 }
618 if (!(urlW = strdupAW( url, -1 ))) goto done;
619 if (hostname && !(hostnameW = strdupAW( hostname, -1 ))) goto done;
620
621 TRACE( "%s\n", debugstr_w(global_script->text) );
622 ret = run_script( global_script->text, urlW, hostnameW, proxy, len_proxy );
623
624done:
625 heap_free( hostnameW );
626 heap_free( urlW );
628 return ret;
629}
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
static void run_script(const WCHAR *filename, IActiveScript *script, IActiveScriptParse *parser)
Definition: main.c:367
int proxy
Definition: main.c:67
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10
#define FALSE
Definition: types.h:117
#define SetLastError(x)
Definition: compat.h:752
static WCHAR * strdupAW(const char *src, int len)
Definition: main.c:76
unsigned int BOOL
Definition: ntddk_ex.h:94
#define debugstr_w
Definition: kernel32.h:32
static const WCHAR url[]
Definition: encode.c:1432
#define ERROR_CAN_NOT_COMPLETE
Definition: winerror.h:582

◆ JSPROXY_InternetInitializeAutoProxyDll()

BOOL WINAPI JSPROXY_InternetInitializeAutoProxyDll ( DWORD  version,
LPSTR  tmpfile,
LPSTR  mime,
AutoProxyHelperFunctions callbacks,
LPAUTO_PROXY_SCRIPT_BUFFER  buffer 
)

Definition at line 153 of file main.c.

156{
157 BOOL ret = FALSE;
158
159 TRACE( "%u, %s, %s, %p, %p\n", version, debugstr_a(tmpfile), debugstr_a(mime), callbacks, buffer );
160
161 if (callbacks) FIXME( "callbacks not supported\n" );
162
164
165 if (buffer && buffer->dwStructSize == sizeof(*buffer) && buffer->lpszScriptBuffer)
166 {
167 if (!buffer->dwScriptBufferSize)
168 {
171 return FALSE;
172 }
173 heap_free( global_script->text );
174 if ((global_script->text = strdupAW( buffer->lpszScriptBuffer,
175 buffer->dwScriptBufferSize ))) ret = TRUE;
176 }
177 else
178 {
179 heap_free( global_script->text );
180 if ((global_script->text = load_script( tmpfile ))) ret = TRUE;
181 }
182
184 return ret;
185}
#define FIXME(fmt,...)
Definition: debug.h:111
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
static const WCHAR version[]
Definition: asmname.c:66
static WCHAR * load_script(const char *filename)
Definition: main.c:124
GLuint buffer
Definition: glext.h:5915
_Check_return_ _CRTIMP FILE *__cdecl tmpfile(void)
Definition: file.c:3914
static int callbacks
Definition: xmllint.c:838

◆ load_script()

static WCHAR * load_script ( const char filename)
static

Definition at line 124 of file main.c.

125{
127 DWORD size, bytes_read;
128 char *buffer;
129 int len;
130 WCHAR *script = NULL;
131
133 if (handle == INVALID_HANDLE_VALUE) return NULL;
134
136 if (!(buffer = heap_alloc( size ))) goto done;
137 if (!ReadFile( handle, buffer, size, &bytes_read, NULL ) || bytes_read != size) goto done;
138
140 if (!(script = heap_alloc( (len + 1) * sizeof(WCHAR) ))) goto done;
142 script[len] = 0;
143
144done:
146 heap_free( buffer );
147 return script;
148}
#define CloseHandle
Definition: compat.h:739
#define OPEN_EXISTING
Definition: compat.h:775
#define ReadFile(a, b, c, d, e)
Definition: compat.h:742
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
#define CreateFileA(a, b, c, d, e, f, g)
Definition: compat.h:740
#define GENERIC_READ
Definition: compat.h:135
#define FILE_SHARE_READ
Definition: compat.h:136
DWORD WINAPI GetFileSize(HANDLE hFile, LPDWORD lpFileSizeHigh)
Definition: fileinfo.c:331
const char * filename
Definition: ioapi.h:137

Referenced by JSPROXY_InternetInitializeAutoProxyDll().

◆ printf_addr()

static void printf_addr ( const WCHAR fmt,
WCHAR buf,
SIZE_T  size,
struct sockaddr_in addr 
)
static

Definition at line 304 of file main.c.

305{
306 swprintf( buf, fmt,
307 (unsigned int)(ntohl( addr->sin_addr.s_addr ) >> 24 & 0xff),
308 (unsigned int)(ntohl( addr->sin_addr.s_addr ) >> 16 & 0xff),
309 (unsigned int)(ntohl( addr->sin_addr.s_addr ) >> 8 & 0xff),
310 (unsigned int)(ntohl( addr->sin_addr.s_addr ) & 0xff) );
311}
#define swprintf
Definition: precomp.h:40
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
#define ntohl(x)
Definition: module.h:205
Definition: dsound.c:943

Referenced by dns_resolve().

◆ run_script()

static BOOL run_script ( const WCHAR script,
const WCHAR url,
const WCHAR hostname,
char **  result_str,
DWORD result_len 
)
static

Definition at line 509 of file main.c.

510{
511 static const WCHAR jscriptW[] = {'J','S','c','r','i','p','t',0};
512 static const WCHAR findproxyW[] = {'F','i','n','d','P','r','o','x','y','F','o','r','U','R','L',0};
513 IActiveScriptParse *parser = NULL;
514 IActiveScript *engine = NULL;
516 BOOL ret = FALSE;
517 CLSID clsid;
518 DISPID dispid;
519 BSTR func = NULL, full_script = NULL;
520 VARIANT args[2], retval;
522 HRESULT hr, init;
523
525 hr = CLSIDFromProgID( jscriptW, &clsid );
526 if (hr != S_OK) goto done;
527
528 hr = CoCreateInstance( &clsid, NULL, CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER,
529 &IID_IActiveScript, (void **)&engine );
530 if (hr != S_OK) goto done;
531
532 hr = IActiveScript_QueryInterface( engine, &IID_IActiveScriptParse, (void **)&parser );
533 if (hr != S_OK) goto done;
534
536 if (hr != S_OK) goto done;
537
538 hr = IActiveScript_SetScriptSite( engine, &script_site );
539 if (hr != S_OK) goto done;
540
541 hr = IActiveScript_AddNamedItem( engine, global_funcsW, SCRIPTITEM_GLOBALMEMBERS );
542 if (hr != S_OK) goto done;
543
544 if (!(full_script = include_pac_utils( script ))) goto done;
545
546 hr = IActiveScriptParse_ParseScriptText( parser, full_script, NULL, NULL, NULL, 0, 0, 0, NULL, NULL );
547 if (hr != S_OK) goto done;
548
549 hr = IActiveScript_SetScriptState( engine, SCRIPTSTATE_STARTED );
550 if (hr != S_OK) goto done;
551
552 hr = IActiveScript_GetScriptDispatch( engine, NULL, &dispatch );
553 if (hr != S_OK) goto done;
554
555 if (!(func = SysAllocString( findproxyW ))) goto done;
556 hr = IDispatch_GetIDsOfNames( dispatch, &IID_NULL, &func, 1, LOCALE_SYSTEM_DEFAULT, &dispid );
557 if (hr != S_OK) goto done;
558
559 V_VT( &args[0] ) = VT_BSTR;
561 V_VT( &args[1] ) = VT_BSTR;
562 V_BSTR( &args[1] ) = SysAllocString( url );
563
564 params.rgvarg = args;
565 params.rgdispidNamedArgs = NULL;
566 params.cArgs = 2;
567 params.cNamedArgs = 0;
568 hr = IDispatch_Invoke( dispatch, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT, DISPATCH_METHOD,
569 &params, &retval, NULL, NULL );
570 VariantClear( &args[0] );
571 VariantClear( &args[1] );
572 if (hr != S_OK)
573 {
574 WARN("script failed 0x%08x\n", hr);
575 goto done;
576 }
577 if ((*result_str = strdupWA( V_BSTR( &retval ) )))
578 {
579 TRACE( "result: %s\n", debugstr_a(*result_str) );
580 *result_len = strlen( *result_str ) + 1;
581 ret = TRUE;
582 }
583 VariantClear( &retval );
584
585done:
586 SysFreeString( full_script );
588 if (dispatch) IDispatch_Release( dispatch );
590 if (engine) IActiveScript_Release( engine );
591 if (SUCCEEDED( init )) CoUninitialize();
592 return ret;
593}
@ SCRIPTSTATE_STARTED
Definition: activscp.idl:58
#define IActiveScriptParse_InitNew
Definition: main.c:47
#define IActiveScriptParse_ParseScriptText
Definition: main.c:48
#define IActiveScriptParse_Release
Definition: main.c:46
static IActiveScriptSite script_site
Definition: main.c:162
void dispatch(HANDLE hStopEvent)
Definition: dispatch.c:70
#define WARN(fmt,...)
Definition: debug.h:112
static const WCHAR global_funcsW[]
Definition: main.c:55
static BSTR include_pac_utils(const WCHAR *script)
Definition: main.c:478
HRESULT WINAPI DECLSPEC_HOTPATCH CoCreateInstance(REFCLSID rclsid, LPUNKNOWN pUnkOuter, DWORD dwClsContext, REFIID iid, LPVOID *ppv)
Definition: compobj.c:3325
HRESULT WINAPI DECLSPEC_HOTPATCH CLSIDFromProgID(LPCOLESTR progid, LPCLSID clsid)
Definition: compobj.c:2602
HRESULT WINAPI CoInitialize(LPVOID lpReserved)
Definition: compobj.c:1964
void WINAPI DECLSPEC_HOTPATCH CoUninitialize(void)
Definition: compobj.c:2067
GLenum func
Definition: glext.h:6028
#define SUCCEEDED(hr)
Definition: intsafe.h:50
static VARIANTARG static DISPID
Definition: ordinal.c:52
REFCLSID clsid
Definition: msctf.c:82
struct stdole::DISPPARAMS DISPPARAMS
#define LOCALE_SYSTEM_DEFAULT
void WINAPI DECLSPEC_HOTPATCH SysFreeString(BSTR str)
Definition: oleaut.c:271
#define DISPATCH_METHOD
Definition: oleauto.h:1006
#define IID_NULL
Definition: guiddef.h:98
#define args
Definition: format.c:66
HRESULT hr
Definition: shlfolder.c:183
Definition: match.c:390
Definition: import.c:81
HRESULT WINAPI DECLSPEC_HOTPATCH VariantClear(VARIANTARG *pVarg)
Definition: variant.c:648
static int init
Definition: wintirpc.c:33

◆ site_AddRef()

static ULONG WINAPI site_AddRef ( IActiveScriptSite iface)
static

Definition at line 395 of file main.c.

397{
398 return 2;
399}

◆ site_GetDocVersionString()

static HRESULT WINAPI site_GetDocVersionString ( IActiveScriptSite iface,
BSTR version 
)
static

Definition at line 425 of file main.c.

427{
428 return E_NOTIMPL;
429}

◆ site_GetItemInfo()

static HRESULT WINAPI site_GetItemInfo ( IActiveScriptSite iface,
LPCOLESTR  name,
DWORD  mask,
IUnknown **  item,
ITypeInfo **  type_info 
)
static

Definition at line 413 of file main.c.

416{
417 if (!lstrcmpW( name, global_funcsW ) && mask == SCRIPTINFO_IUNKNOWN)
418 {
420 return S_OK;
421 }
422 return E_NOTIMPL;
423}
static IDispatchEx global_dispex
Definition: main.c:377
GLenum GLint GLuint mask
Definition: glext.h:6028
static ATOM item
Definition: dde.c:856

◆ site_GetLCID()

static HRESULT WINAPI site_GetLCID ( IActiveScriptSite iface,
LCID lcid 
)
static

Definition at line 407 of file main.c.

409{
410 return E_NOTIMPL;
411}

◆ site_OnEnterScript()

static HRESULT WINAPI site_OnEnterScript ( IActiveScriptSite iface)
static

Definition at line 449 of file main.c.

451{
452 return E_NOTIMPL;
453}

◆ site_OnLeaveScript()

static HRESULT WINAPI site_OnLeaveScript ( IActiveScriptSite iface)
static

Definition at line 455 of file main.c.

457{
458 return E_NOTIMPL;
459}

◆ site_OnScriptError()

static HRESULT WINAPI site_OnScriptError ( IActiveScriptSite iface,
IActiveScriptError error 
)
static

Definition at line 443 of file main.c.

445{
446 return E_NOTIMPL;
447}

◆ site_OnScriptTerminate()

static HRESULT WINAPI site_OnScriptTerminate ( IActiveScriptSite iface,
const VARIANT result,
const EXCEPINFO *  info 
)
static

Definition at line 431 of file main.c.

433{
434 return E_NOTIMPL;
435}

◆ site_OnStateChange()

static HRESULT WINAPI site_OnStateChange ( IActiveScriptSite iface,
SCRIPTSTATE  state 
)
static

Definition at line 437 of file main.c.

439{
440 return E_NOTIMPL;
441}

◆ site_QueryInterface()

static HRESULT WINAPI site_QueryInterface ( IActiveScriptSite iface,
REFIID  riid,
void **  ppv 
)
static

Definition at line 379 of file main.c.

381{
382 *ppv = NULL;
383
385 *ppv = iface;
386 else if (IsEqualGUID( &IID_IActiveScriptSite, riid ))
387 *ppv = iface;
388 else
389 return E_NOINTERFACE;
390
391 IUnknown_AddRef( (IUnknown *)*ppv );
392 return S_OK;
393}

◆ site_Release()

static ULONG WINAPI site_Release ( IActiveScriptSite iface)
static

Definition at line 401 of file main.c.

403{
404 return 1;
405}

◆ strdupAW()

static WCHAR * strdupAW ( const char src,
int  len 
)
inlinestatic

Definition at line 76 of file main.c.

77{
78 WCHAR *dst = NULL;
79 if (src)
80 {
81 int dst_len = MultiByteToWideChar( CP_ACP, 0, src, len, NULL, 0 );
82 if ((dst = heap_alloc( (dst_len + 1) * sizeof(WCHAR) )))
83 {
84 len = MultiByteToWideChar( CP_ACP, 0, src, len, dst, dst_len );
85 dst[dst_len] = 0;
86 }
87 }
88 return dst;
89}
GLenum src
Definition: glext.h:6340
GLenum GLenum dst
Definition: glext.h:6340

Referenced by addr_to_str(), InternetGetProxyInfo(), JSPROXY_InternetInitializeAutoProxyDll(), parse_script_result(), and WinHttpDetectAutoProxyConfigUrl().

◆ strdupWA()

static char * strdupWA ( const WCHAR src)
inlinestatic

Definition at line 91 of file main.c.

92{
93 char *dst = NULL;
94 if (src)
95 {
96 int len = WideCharToMultiByte( CP_ACP, 0, src, -1, NULL, 0, NULL, NULL );
97 if ((dst = heap_alloc( len ))) WideCharToMultiByte( CP_ACP, 0, src, -1, dst, len, NULL, NULL );
98 }
99 return dst;
100}
#define WideCharToMultiByte
Definition: compat.h:111

Referenced by dns_resolve(), run_script(), and secure_proxy_connect().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( jsproxy  )

Variable Documentation

◆ critsect_debug

CRITICAL_SECTION_DEBUG critsect_debug
static
Initial value:
=
{
0, 0, &cs_jsproxy,
0, 0, { (DWORD_PTR)(__FILE__ ": cs_jsproxy") }
}
static CRITICAL_SECTION_DEBUG critsect_debug
Definition: main.c:47
LIST_ENTRY ProcessLocksList
Definition: winbase.h:883
#define DWORD_PTR
Definition: treelist.c:76

Definition at line 47 of file main.c.

◆ cs_jsproxy

static CRITICAL_SECTION cs_jsproxy = { &critsect_debug, -1, 0, 0, 0, 0 }
static

◆ dispex_vtbl

const IDispatchExVtbl dispex_vtbl
static
Initial value:
=
{
}
static HRESULT WINAPI dispex_InvokeEx(IDispatchEx *iface, DISPID id, LCID lcid, WORD flags, DISPPARAMS *params, VARIANT *result, EXCEPINFO *exep, IServiceProvider *caller)
Definition: main.c:345
static HRESULT WINAPI dispex_DeleteMemberByDispID(IDispatchEx *iface, DISPID id)
Definition: main.c:245
static HRESULT WINAPI dispex_GetTypeInfoCount(IDispatchEx *iface, UINT *info)
Definition: main.c:214
static ULONG WINAPI dispex_Release(IDispatchEx *iface)
Definition: main.c:208
static HRESULT WINAPI dispex_Invoke(IDispatchEx *iface, DISPID member, REFIID riid, LCID lcid, WORD flags, DISPPARAMS *params, VARIANT *result, EXCEPINFO *excep, UINT *err)
Definition: main.c:232
static HRESULT WINAPI dispex_GetIDsOfNames(IDispatchEx *iface, REFIID riid, LPOLESTR *names, UINT count, LCID lcid, DISPID *id)
Definition: main.c:226
static HRESULT WINAPI dispex_DeleteMemberByName(IDispatchEx *iface, BSTR name, DWORD flags)
Definition: main.c:239
static HRESULT WINAPI dispex_QueryInterface(IDispatchEx *iface, REFIID riid, void **ppv)
Definition: main.c:187
static ULONG WINAPI dispex_AddRef(IDispatchEx *iface)
Definition: main.c:202
static HRESULT WINAPI dispex_GetDispID(IDispatchEx *iface, BSTR name, DWORD flags, DISPID *id)
Definition: main.c:277
static HRESULT WINAPI dispex_GetTypeInfo(IDispatchEx *iface, UINT info, LCID lcid, ITypeInfo **type_info)
Definition: main.c:220
static HRESULT WINAPI dispex_GetMemberName(IDispatchEx *iface, DISPID id, BSTR *name)
Definition: main.c:257
static HRESULT WINAPI dispex_GetNextDispID(IDispatchEx *iface, DWORD flags, DISPID id, DISPID *next)
Definition: main.c:263
static HRESULT WINAPI dispex_GetMemberProperties(IDispatchEx *iface, DISPID id, DWORD flags_fetch, DWORD *flags)
Definition: main.c:251
static HRESULT WINAPI dispex_GetNameSpaceParent(IDispatchEx *iface, IUnknown **unk)
Definition: main.c:269

Definition at line 358 of file main.c.

◆ dns_resolveW

const WCHAR dns_resolveW[] = {'d','n','s','_','r','e','s','o','l','v','e',0}
static

Definition at line 56 of file main.c.

Referenced by dispex_GetDispID().

◆ global_dispex

IDispatchEx global_dispex = { &dispex_vtbl }
static

Definition at line 377 of file main.c.

Referenced by site_GetItemInfo().

◆ global_funcsW

const WCHAR global_funcsW[] = {'g','l','o','b','a','l','_','f','u','n','c','s',0}
static

Definition at line 55 of file main.c.

Referenced by run_script(), and site_GetItemInfo().

◆ global_script

◆ instance

HINSTANCE instance
static

Definition at line 42 of file main.c.

◆ pac_script

◆ script_site

IActiveScriptSite script_site = { &site_vtbl }
static

Definition at line 476 of file main.c.

◆ site_vtbl

const IActiveScriptSiteVtbl site_vtbl
static
Initial value:
=
{
}
static HRESULT WINAPI site_OnStateChange(IActiveScriptSite *iface, SCRIPTSTATE state)
Definition: main.c:437
static HRESULT WINAPI site_OnLeaveScript(IActiveScriptSite *iface)
Definition: main.c:455
static HRESULT WINAPI site_GetLCID(IActiveScriptSite *iface, LCID *lcid)
Definition: main.c:407
static HRESULT WINAPI site_QueryInterface(IActiveScriptSite *iface, REFIID riid, void **ppv)
Definition: main.c:379
static ULONG WINAPI site_AddRef(IActiveScriptSite *iface)
Definition: main.c:395
static HRESULT WINAPI site_OnScriptError(IActiveScriptSite *iface, IActiveScriptError *error)
Definition: main.c:443
static ULONG WINAPI site_Release(IActiveScriptSite *iface)
Definition: main.c:401
static HRESULT WINAPI site_OnScriptTerminate(IActiveScriptSite *iface, const VARIANT *result, const EXCEPINFO *info)
Definition: main.c:431
static HRESULT WINAPI site_GetItemInfo(IActiveScriptSite *iface, LPCOLESTR name, DWORD mask, IUnknown **item, ITypeInfo **type_info)
Definition: main.c:413
static HRESULT WINAPI site_OnEnterScript(IActiveScriptSite *iface)
Definition: main.c:449
static HRESULT WINAPI site_GetDocVersionString(IActiveScriptSite *iface, BSTR *version)
Definition: main.c:425

Definition at line 461 of file main.c.