jsproxy: Implement InternetInitializeAutoProxyDll and InternetDeinitializeAutoProxyDll.
This commit is contained in:
parent
ae542221a0
commit
8545a971c9
|
@ -1,5 +1,5 @@
|
||||||
@ stub InternetInitializeAutoProxyDll
|
@ stdcall InternetInitializeAutoProxyDll(long str str ptr ptr) JSPROXY_InternetInitializeAutoProxyDll
|
||||||
@ stub InternetInitializeExAutoProxyDll
|
@ stub InternetInitializeExAutoProxyDll
|
||||||
@ stub InternetDeInitializeAutoProxyDll
|
@ stdcall InternetDeInitializeAutoProxyDll(str long)
|
||||||
@ stub InternetDeInitializeExAutoProxyDll
|
@ stub InternetDeInitializeExAutoProxyDll
|
||||||
@ stub InternetGetProxyInfo
|
@ stub InternetGetProxyInfo
|
||||||
|
|
|
@ -23,12 +23,23 @@
|
||||||
|
|
||||||
#include "windef.h"
|
#include "windef.h"
|
||||||
#include "winbase.h"
|
#include "winbase.h"
|
||||||
|
#include "winnls.h"
|
||||||
|
#include "wininet.h"
|
||||||
#include "wine/debug.h"
|
#include "wine/debug.h"
|
||||||
|
|
||||||
static HINSTANCE instance;
|
static HINSTANCE instance;
|
||||||
|
|
||||||
WINE_DEFAULT_DEBUG_CHANNEL(jsproxy);
|
WINE_DEFAULT_DEBUG_CHANNEL(jsproxy);
|
||||||
|
|
||||||
|
static CRITICAL_SECTION cs_jsproxy;
|
||||||
|
static CRITICAL_SECTION_DEBUG critsect_debug =
|
||||||
|
{
|
||||||
|
0, 0, &cs_jsproxy,
|
||||||
|
{ &critsect_debug.ProcessLocksList, &critsect_debug.ProcessLocksList },
|
||||||
|
0, 0, { (DWORD_PTR)(__FILE__ ": cs_jsproxy") }
|
||||||
|
};
|
||||||
|
static CRITICAL_SECTION cs_jsproxy = { &critsect_debug, -1, 0, 0, 0, 0 };
|
||||||
|
|
||||||
/******************************************************************
|
/******************************************************************
|
||||||
* DllMain (jsproxy.@)
|
* DllMain (jsproxy.@)
|
||||||
*/
|
*/
|
||||||
|
@ -46,3 +57,101 @@ BOOL WINAPI DllMain( HINSTANCE hinst, DWORD reason, LPVOID reserved )
|
||||||
}
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline void *heap_alloc( SIZE_T size )
|
||||||
|
{
|
||||||
|
return HeapAlloc( GetProcessHeap(), 0, size );
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline BOOL heap_free( LPVOID mem )
|
||||||
|
{
|
||||||
|
return HeapFree( GetProcessHeap(), 0, mem );
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline WCHAR *strdupAW( const char *src, DWORD len )
|
||||||
|
{
|
||||||
|
WCHAR *dst = NULL;
|
||||||
|
if (src)
|
||||||
|
{
|
||||||
|
int dst_len = MultiByteToWideChar( CP_ACP, 0, src, len, NULL, 0 );
|
||||||
|
if ((dst = heap_alloc( (dst_len + 1) * sizeof(WCHAR) ))) len = MultiByteToWideChar( CP_ACP, 0, src, len, dst, dst_len );
|
||||||
|
dst[dst_len] = 0;
|
||||||
|
}
|
||||||
|
return dst;
|
||||||
|
}
|
||||||
|
|
||||||
|
static struct pac_script
|
||||||
|
{
|
||||||
|
WCHAR *text;
|
||||||
|
} pac_script;
|
||||||
|
static struct pac_script *global_script = &pac_script;
|
||||||
|
|
||||||
|
/******************************************************************
|
||||||
|
* InternetDeInitializeAutoProxyDll (jsproxy.@)
|
||||||
|
*/
|
||||||
|
BOOL WINAPI InternetDeInitializeAutoProxyDll( LPSTR mime, DWORD reserved )
|
||||||
|
{
|
||||||
|
TRACE( "%s, %u\n", debugstr_a(mime), reserved );
|
||||||
|
|
||||||
|
EnterCriticalSection( &cs_jsproxy );
|
||||||
|
|
||||||
|
heap_free( global_script->text );
|
||||||
|
global_script->text = NULL;
|
||||||
|
|
||||||
|
LeaveCriticalSection( &cs_jsproxy );
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static WCHAR *load_script( const char *filename )
|
||||||
|
{
|
||||||
|
HANDLE handle;
|
||||||
|
DWORD size, bytes_read;
|
||||||
|
char *buffer;
|
||||||
|
int len;
|
||||||
|
WCHAR *script = NULL;
|
||||||
|
|
||||||
|
handle = CreateFileA( filename, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, 0 );
|
||||||
|
if (handle == INVALID_HANDLE_VALUE) return NULL;
|
||||||
|
|
||||||
|
size = GetFileSize( handle, NULL );
|
||||||
|
if (!(buffer = heap_alloc( size ))) goto done;
|
||||||
|
if (!ReadFile( handle, buffer, size, &bytes_read, NULL ) || bytes_read != size) goto done;
|
||||||
|
|
||||||
|
len = MultiByteToWideChar( CP_ACP, 0, buffer, size, NULL, 0 );
|
||||||
|
if (!(script = heap_alloc( (len + 1) * sizeof(WCHAR) ))) goto done;
|
||||||
|
MultiByteToWideChar( CP_ACP, 0, buffer, size, script, len );
|
||||||
|
script[len] = 0;
|
||||||
|
|
||||||
|
done:
|
||||||
|
CloseHandle( handle );
|
||||||
|
heap_free( buffer );
|
||||||
|
return script;
|
||||||
|
}
|
||||||
|
|
||||||
|
/******************************************************************
|
||||||
|
* InternetInitializeAutoProxyDll (jsproxy.@)
|
||||||
|
*/
|
||||||
|
BOOL WINAPI JSPROXY_InternetInitializeAutoProxyDll( DWORD version, LPSTR tmpfile, LPSTR mime,
|
||||||
|
AutoProxyHelperFunctions *callbacks,
|
||||||
|
LPAUTO_PROXY_SCRIPT_BUFFER buffer )
|
||||||
|
{
|
||||||
|
BOOL ret = FALSE;
|
||||||
|
|
||||||
|
TRACE( "%u, %s, %s, %p, %p\n", version, debugstr_a(tmpfile), debugstr_a(mime), callbacks, buffer );
|
||||||
|
|
||||||
|
if (callbacks) FIXME( "callbacks not supported\n" );
|
||||||
|
|
||||||
|
EnterCriticalSection( &cs_jsproxy );
|
||||||
|
|
||||||
|
if (global_script->text)
|
||||||
|
{
|
||||||
|
LeaveCriticalSection( &cs_jsproxy );
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
if (buffer && buffer->dwStructSize == sizeof(*buffer) && buffer->lpszScriptBuffer &&
|
||||||
|
(global_script->text = strdupAW( buffer->lpszScriptBuffer, buffer->dwScriptBufferSize ))) ret = TRUE;
|
||||||
|
else if ((global_script->text = load_script( tmpfile ))) ret = TRUE;
|
||||||
|
|
||||||
|
LeaveCriticalSection( &cs_jsproxy );
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue