From 09d2d47721d5362b7fdc483598740d6faf91de4f Mon Sep 17 00:00:00 2001 From: Mike McCormack Date: Thu, 25 Mar 2004 05:29:47 +0000 Subject: [PATCH] Convert WININETAPPINFOA structure to unicode. --- dlls/wininet/dialogs.c | 123 ++++++++++++++++++++++------------------ dlls/wininet/ftp.c | 84 +++++++++++++-------------- dlls/wininet/http.c | 100 ++++++++++++++++++-------------- dlls/wininet/internet.c | 123 +++++++++++++++++++++------------------- dlls/wininet/internet.h | 18 +++--- dlls/wininet/utility.c | 4 +- 6 files changed, 244 insertions(+), 208 deletions(-) diff --git a/dlls/wininet/dialogs.c b/dlls/wininet/dialogs.c index a806782cbf..2ed82eb867 100644 --- a/dlls/wininet/dialogs.c +++ b/dlls/wininet/dialogs.c @@ -56,12 +56,12 @@ struct WININET_ErrorDlgParams * * Determine the name of the proxy server the request is using */ -static BOOL WININET_GetProxyServer( HINTERNET hRequest, LPSTR szBuf, DWORD sz ) +static BOOL WININET_GetProxyServer( HINTERNET hRequest, LPWSTR szBuf, DWORD sz ) { LPWININETHTTPREQA lpwhr = (LPWININETHTTPREQA) hRequest; LPWININETHTTPSESSIONA lpwhs = NULL; - LPWININETAPPINFOA hIC = NULL; - LPSTR p; + LPWININETAPPINFOW hIC = NULL; + LPWSTR p; if (NULL == lpwhr) return FALSE; @@ -70,14 +70,14 @@ static BOOL WININET_GetProxyServer( HINTERNET hRequest, LPSTR szBuf, DWORD sz ) if (NULL == lpwhs) return FALSE; - hIC = (LPWININETAPPINFOA) lpwhs->hdr.lpwhparent; + hIC = (LPWININETAPPINFOW) lpwhs->hdr.lpwhparent; if (NULL == hIC) return FALSE; - strncpy(szBuf, hIC->lpszProxy, sz); + strncpyW(szBuf, hIC->lpszProxy, sz); /* FIXME: perhaps it would be better to use InternetCrackUrl here */ - p = strchr(szBuf, ':'); + p = strchrW(szBuf, ':'); if(*p) *p = 0; @@ -89,14 +89,15 @@ static BOOL WININET_GetProxyServer( HINTERNET hRequest, LPSTR szBuf, DWORD sz ) * * Determine the name of the (basic) Authentication realm */ -static BOOL WININET_GetAuthRealm( HINTERNET hRequest, LPSTR szBuf, DWORD sz ) +static BOOL WININET_GetAuthRealm( HINTERNET hRequest, LPWSTR szBuf, DWORD sz ) { - LPSTR p, q; + LPWSTR p, q; DWORD index; + WCHAR szRealm[] = { 'r','e','a','l','m','=',0 }; /* extract the Realm from the proxy response and show it */ index = 0; - if( !HttpQueryInfoA( hRequest, HTTP_QUERY_PROXY_AUTHENTICATE, + if( !HttpQueryInfoW( hRequest, HTTP_QUERY_PROXY_AUTHENTICATE, szBuf, &sz, &index) ) return FALSE; @@ -104,21 +105,21 @@ static BOOL WININET_GetAuthRealm( HINTERNET hRequest, LPSTR szBuf, DWORD sz ) * FIXME: maybe we should check that we're * dealing with 'Basic' Authentication */ - p = strchr( szBuf, ' ' ); - if( p && !strncmp( p+1, "realm=", 6 ) ) + p = strchrW( szBuf, ' ' ); + if( p && !strncmpW( p+1, szRealm, strlenW(szRealm) ) ) { /* remove quotes */ p += 7; if( *p == '"' ) { p++; - q = strrchr( p, '"' ); + q = strrchrW( p, '"' ); if( q ) *q = 0; } } - strcpy( szBuf, p ); + strcpyW( szBuf, p ); return TRUE; } @@ -126,50 +127,62 @@ static BOOL WININET_GetAuthRealm( HINTERNET hRequest, LPSTR szBuf, DWORD sz ) /*********************************************************************** * WININET_GetSetPassword */ -static BOOL WININET_GetSetPassword( HWND hdlg, LPCSTR szServer, - LPCSTR szRealm, BOOL bSet ) +static BOOL WININET_GetSetPassword( HWND hdlg, LPCWSTR szServer, + LPCWSTR szRealm, BOOL bSet ) { - CHAR szResource[0x80], szUserPass[0x40]; - LPSTR p; + WCHAR szResource[0x80], szUserPass[0x40]; + LPWSTR p; HWND hUserItem, hPassItem; DWORD r, dwMagic = 19; - UINT len; + UINT r_len, u_len; WORD sz; + WCHAR szColon[] = { ':',0 }, szbs[] = { '/', 0 }; hUserItem = GetDlgItem( hdlg, IDC_USERNAME ); hPassItem = GetDlgItem( hdlg, IDC_PASSWORD ); /* now try fetch the username and password */ - strcpy( szResource, szServer); - strcat( szResource, "/"); - strcat( szResource, szRealm); + lstrcpyW( szResource, szServer); + lstrcatW( szResource, szbs); + lstrcatW( szResource, szRealm); + /* + * WNetCachePassword is only concerned with the length + * of the data stored (which we tell it) and it does + * not use strlen() internally so we can add WCHAR data + * instead of ASCII data and get it back the same way. + */ if( bSet ) { szUserPass[0] = 0; - GetWindowTextA( hUserItem, szUserPass, sizeof szUserPass-1 ); - strcat(szUserPass, ":"); - len = strlen( szUserPass ); - GetWindowTextA( hPassItem, szUserPass+len, sizeof szUserPass-len ); + GetWindowTextW( hUserItem, szUserPass, + (sizeof szUserPass-1)/sizeof(WCHAR) ); + lstrcatW(szUserPass, szColon); + u_len = strlenW( szUserPass ); + GetWindowTextW( hPassItem, szUserPass+u_len, + (sizeof szUserPass)/sizeof(WCHAR)-u_len ); - r = WNetCachePassword( szResource, strlen( szResource ) + 1, - szUserPass, strlen( szUserPass ) + 1, dwMagic, 0 ); + r_len = (strlenW( szResource ) + 1)*sizeof(WCHAR); + u_len = (strlenW( szUserPass ) + 1)*sizeof(WCHAR); + r = WNetCachePassword( (CHAR*)szResource, r_len, + (CHAR*)szUserPass, u_len, dwMagic, 0 ); return ( r == WN_SUCCESS ); } sz = sizeof szUserPass; - r = WNetGetCachedPassword( szResource, strlen( szResource ) + 1, - szUserPass, &sz, dwMagic ); + r_len = (strlenW( szResource ) + 1)*sizeof(WCHAR); + r = WNetGetCachedPassword( (CHAR*)szResource, r_len, + (CHAR*)szUserPass, &sz, dwMagic ); if( r != WN_SUCCESS ) return FALSE; - p = strchr( szUserPass, ':' ); + p = strchrW( szUserPass, ':' ); if( p ) { *p = 0; - SetWindowTextA( hUserItem, szUserPass ); - SetWindowTextA( hPassItem, p+1 ); + SetWindowTextW( hUserItem, szUserPass ); + SetWindowTextW( hPassItem, p+1 ); } return TRUE; @@ -179,12 +192,12 @@ static BOOL WININET_GetSetPassword( HWND hdlg, LPCSTR szServer, * WININET_SetProxyAuthorization */ static BOOL WININET_SetProxyAuthorization( HINTERNET hRequest, - LPSTR username, LPSTR password ) + LPWSTR username, LPWSTR password ) { LPWININETHTTPREQA lpwhr = (LPWININETHTTPREQA) hRequest; LPWININETHTTPSESSIONA lpwhs; - LPWININETAPPINFOA hIC; - LPSTR p; + LPWININETAPPINFOW hIC; + LPWSTR p; lpwhs = (LPWININETHTTPSESSIONA) lpwhr->hdr.lpwhparent; if (NULL == lpwhs || lpwhs->hdr.htype != WH_HHTTPSESSION) @@ -193,20 +206,20 @@ static BOOL WININET_SetProxyAuthorization( HINTERNET hRequest, return FALSE; } - hIC = (LPWININETAPPINFOA) lpwhs->hdr.lpwhparent; + hIC = (LPWININETAPPINFOW) lpwhs->hdr.lpwhparent; - p = HeapAlloc( GetProcessHeap(), 0, strlen( username ) + 1 ); + p = HeapAlloc( GetProcessHeap(), 0, (strlenW( username ) + 1)*sizeof(WCHAR) ); if( !p ) return FALSE; - strcpy( p, username ); + lstrcpyW( p, username ); hIC->lpszProxyUsername = p; - p = HeapAlloc( GetProcessHeap(), 0, strlen( password ) + 1 ); + p = HeapAlloc( GetProcessHeap(), 0, (strlenW( password ) + 1)*sizeof(WCHAR) ); if( !p ) return FALSE; - strcpy( p, password ); + lstrcpyW( p, password ); hIC->lpszProxyPassword = p; return TRUE; @@ -220,7 +233,7 @@ static INT_PTR WINAPI WININET_ProxyPasswordDialog( { HWND hitem; struct WININET_ErrorDlgParams *params; - CHAR szRealm[0x80], szServer[0x80]; + WCHAR szRealm[0x80], szServer[0x80]; if( uMsg == WM_INITDIALOG ) { @@ -232,18 +245,18 @@ static INT_PTR WINAPI WININET_ProxyPasswordDialog( /* extract the Realm from the proxy response and show it */ if( WININET_GetAuthRealm( params->hRequest, - szRealm, sizeof szRealm) ) + szRealm, sizeof szRealm/sizeof(WCHAR)) ) { hitem = GetDlgItem( hdlg, IDC_REALM ); - SetWindowTextA( hitem, szRealm ); + SetWindowTextW( hitem, szRealm ); } /* extract the name of the proxy server */ if( WININET_GetProxyServer( params->hRequest, - szServer, sizeof szServer) ) + szServer, sizeof szServer/sizeof(WCHAR)) ) { hitem = GetDlgItem( hdlg, IDC_PROXY ); - SetWindowTextA( hitem, szServer ); + SetWindowTextW( hitem, szServer ); } WININET_GetSetPassword( hdlg, szServer, szRealm, FALSE ); @@ -260,25 +273,25 @@ static INT_PTR WINAPI WININET_ProxyPasswordDialog( if( wParam == IDOK ) { LPWININETHTTPREQA lpwhr = (LPWININETHTTPREQA) params->hRequest; - CHAR username[0x20], password[0x20]; + WCHAR username[0x20], password[0x20]; username[0] = 0; hitem = GetDlgItem( hdlg, IDC_USERNAME ); if( hitem ) - GetWindowTextA( hitem, username, sizeof username ); + GetWindowTextW( hitem, username, sizeof username/sizeof(WCHAR) ); password[0] = 0; hitem = GetDlgItem( hdlg, IDC_PASSWORD ); if( hitem ) - GetWindowTextA( hitem, password, sizeof password ); + GetWindowTextW( hitem, password, sizeof password/sizeof(WCHAR) ); hitem = GetDlgItem( hdlg, IDC_SAVEPASSWORD ); if( hitem && - SendMessageA( hitem, BM_GETSTATE, 0, 0 ) && + SendMessageW( hitem, BM_GETSTATE, 0, 0 ) && WININET_GetAuthRealm( params->hRequest, - szRealm, sizeof szRealm) && + szRealm, sizeof szRealm/sizeof(WCHAR)) && WININET_GetProxyServer( params->hRequest, - szServer, sizeof szServer) ) + szServer, sizeof szServer/sizeof(WCHAR)) ) { WININET_GetSetPassword( hdlg, szServer, szRealm, TRUE ); } @@ -302,17 +315,17 @@ static INT_PTR WINAPI WININET_ProxyPasswordDialog( */ static INT WININET_GetConnectionStatus( HINTERNET hRequest ) { - CHAR szStatus[0x20]; + WCHAR szStatus[0x20]; DWORD sz, index, dwStatus; TRACE("%p\n", hRequest ); - sz = sizeof szStatus; + sz = sizeof(szStatus) / sizeof(WCHAR); index = 0; - if( !HttpQueryInfoA( hRequest, HTTP_QUERY_STATUS_CODE, + if( !HttpQueryInfoW( hRequest, HTTP_QUERY_STATUS_CODE, szStatus, &sz, &index)) return -1; - dwStatus = atoi( szStatus ); + dwStatus = atoiW( szStatus ); TRACE("request %p status = %ld\n", hRequest, dwStatus ); diff --git a/dlls/wininet/ftp.c b/dlls/wininet/ftp.c index 53265b73db..f81e3f1098 100644 --- a/dlls/wininet/ftp.c +++ b/dlls/wininet/ftp.c @@ -158,7 +158,7 @@ BOOL WINAPI FtpPutFileA(HINTERNET hConnect, LPCSTR lpszLocalFile, LPCSTR lpszNewRemoteFile, DWORD dwFlags, DWORD dwContext) { LPWININETFTPSESSIONA lpwfs; - LPWININETAPPINFOA hIC = NULL; + LPWININETAPPINFOW hIC = NULL; lpwfs = (LPWININETFTPSESSIONA) WININET_GetObject( hConnect ); if (NULL == lpwfs || WH_HFTPSESSION != lpwfs->hdr.htype) @@ -167,7 +167,7 @@ BOOL WINAPI FtpPutFileA(HINTERNET hConnect, LPCSTR lpszLocalFile, return FALSE; } - hIC = (LPWININETAPPINFOA) lpwfs->hdr.lpwhparent; + hIC = (LPWININETAPPINFOW) lpwfs->hdr.lpwhparent; if (hIC->hdr.dwFlags & INTERNET_FLAG_ASYNC) { WORKREQUEST workRequest; @@ -204,7 +204,7 @@ BOOL WINAPI FTP_FtpPutFileA(HINTERNET hConnect, LPCSTR lpszLocalFile, { HANDLE hFile = NULL; BOOL bSuccess = FALSE; - LPWININETAPPINFOA hIC = NULL; + LPWININETAPPINFOW hIC = NULL; LPWININETFTPSESSIONA lpwfs; INT nResCode; @@ -228,7 +228,7 @@ BOOL WINAPI FTP_FtpPutFileA(HINTERNET hConnect, LPCSTR lpszLocalFile, goto lend; } - hIC = (LPWININETAPPINFOA) lpwfs->hdr.lpwhparent; + hIC = (LPWININETAPPINFOW) lpwfs->hdr.lpwhparent; if (hIC->lpfnStatusCB) hIC->lpfnStatusCB(hConnect, lpwfs->hdr.dwContext, INTERNET_STATUS_SENDING_REQUEST, NULL, 0); @@ -287,7 +287,7 @@ lend: BOOL WINAPI FtpSetCurrentDirectoryA(HINTERNET hConnect, LPCSTR lpszDirectory) { LPWININETFTPSESSIONA lpwfs; - LPWININETAPPINFOA hIC = NULL; + LPWININETAPPINFOW hIC = NULL; lpwfs = (LPWININETFTPSESSIONA) WININET_GetObject( hConnect ); if (NULL == lpwfs || WH_HFTPSESSION != lpwfs->hdr.htype) @@ -298,7 +298,7 @@ BOOL WINAPI FtpSetCurrentDirectoryA(HINTERNET hConnect, LPCSTR lpszDirectory) TRACE("lpszDirectory(%s)\n", lpszDirectory); - hIC = (LPWININETAPPINFOA) lpwfs->hdr.lpwhparent; + hIC = (LPWININETAPPINFOW) lpwfs->hdr.lpwhparent; if (hIC->hdr.dwFlags & INTERNET_FLAG_ASYNC) { WORKREQUEST workRequest; @@ -360,7 +360,7 @@ BOOL WINAPI FTP_FtpSetCurrentDirectoryA(HINTERNET hConnect, LPCSTR lpszDirectory { INT nResCode; LPWININETFTPSESSIONA lpwfs; - LPWININETAPPINFOA hIC = NULL; + LPWININETAPPINFOW hIC = NULL; DWORD bSuccess = FALSE; TRACE("lpszDirectory(%s)\n", lpszDirectory); @@ -375,7 +375,7 @@ BOOL WINAPI FTP_FtpSetCurrentDirectoryA(HINTERNET hConnect, LPCSTR lpszDirectory /* Clear any error information */ INTERNET_SetLastError(0); - hIC = (LPWININETAPPINFOA) lpwfs->hdr.lpwhparent; + hIC = (LPWININETAPPINFOW) lpwfs->hdr.lpwhparent; if (!FTP_SendCommand(lpwfs->sndSocket, FTP_CMD_CWD, lpszDirectory, hIC->lpfnStatusCB, hConnect, lpwfs->hdr.dwContext)) goto lend; @@ -418,7 +418,7 @@ lend: BOOL WINAPI FtpCreateDirectoryA(HINTERNET hConnect, LPCSTR lpszDirectory) { LPWININETFTPSESSIONA lpwfs; - LPWININETAPPINFOA hIC = NULL; + LPWININETAPPINFOW hIC = NULL; lpwfs = (LPWININETFTPSESSIONA) WININET_GetObject( hConnect ); if (NULL == lpwfs || WH_HFTPSESSION != lpwfs->hdr.htype) @@ -427,7 +427,7 @@ BOOL WINAPI FtpCreateDirectoryA(HINTERNET hConnect, LPCSTR lpszDirectory) return FALSE; } - hIC = (LPWININETAPPINFOA) lpwfs->hdr.lpwhparent; + hIC = (LPWININETAPPINFOW) lpwfs->hdr.lpwhparent; if (hIC->hdr.dwFlags & INTERNET_FLAG_ASYNC) { WORKREQUEST workRequest; @@ -489,7 +489,7 @@ BOOL WINAPI FTP_FtpCreateDirectoryA(HINTERNET hConnect, LPCSTR lpszDirectory) { INT nResCode; BOOL bSuccess = FALSE; - LPWININETAPPINFOA hIC = NULL; + LPWININETAPPINFOW hIC = NULL; LPWININETFTPSESSIONA lpwfs; TRACE("\n"); @@ -518,7 +518,7 @@ BOOL WINAPI FTP_FtpCreateDirectoryA(HINTERNET hConnect, LPCSTR lpszDirectory) } lend: - hIC = (LPWININETAPPINFOA) lpwfs->hdr.lpwhparent; + hIC = (LPWININETAPPINFOW) lpwfs->hdr.lpwhparent; if (hIC->hdr.dwFlags & INTERNET_FLAG_ASYNC && hIC->lpfnStatusCB) { INTERNET_ASYNC_RESULT iar; @@ -547,7 +547,7 @@ HINTERNET WINAPI FtpFindFirstFileA(HINTERNET hConnect, LPCSTR lpszSearchFile, LPWIN32_FIND_DATAA lpFindFileData, DWORD dwFlags, DWORD dwContext) { LPWININETFTPSESSIONA lpwfs; - LPWININETAPPINFOA hIC = NULL; + LPWININETAPPINFOW hIC = NULL; lpwfs = (LPWININETFTPSESSIONA) WININET_GetObject( hConnect ); if (NULL == lpwfs || WH_HFTPSESSION != lpwfs->hdr.htype) @@ -556,7 +556,7 @@ HINTERNET WINAPI FtpFindFirstFileA(HINTERNET hConnect, return FALSE; } - hIC = (LPWININETAPPINFOA) lpwfs->hdr.lpwhparent; + hIC = (LPWININETAPPINFOW) lpwfs->hdr.lpwhparent; if (hIC->hdr.dwFlags & INTERNET_FLAG_ASYNC) { WORKREQUEST workRequest; @@ -613,7 +613,7 @@ HINTERNET WINAPI FTP_FtpFindFirstFileA(HINTERNET hConnect, LPCSTR lpszSearchFile, LPWIN32_FIND_DATAA lpFindFileData, DWORD dwFlags, DWORD dwContext) { INT nResCode; - LPWININETAPPINFOA hIC = NULL; + LPWININETAPPINFOW hIC = NULL; LPWININETFTPSESSIONA lpwfs; HINTERNET hFindNext = NULL; @@ -638,7 +638,7 @@ HINTERNET WINAPI FTP_FtpFindFirstFileA(HINTERNET hConnect, if (!FTP_SendPortOrPasv(lpwfs)) goto lend; - hIC = (LPWININETAPPINFOA) lpwfs->hdr.lpwhparent; + hIC = (LPWININETAPPINFOW) lpwfs->hdr.lpwhparent; if (!FTP_SendCommand(lpwfs->sndSocket, FTP_CMD_LIST, lpszSearchFile, hIC->lpfnStatusCB, hConnect, lpwfs->hdr.dwContext)) goto lend; @@ -708,7 +708,7 @@ BOOL WINAPI FtpGetCurrentDirectoryA(HINTERNET hFtpSession, LPSTR lpszCurrentDire LPDWORD lpdwCurrentDirectory) { LPWININETFTPSESSIONA lpwfs; - LPWININETAPPINFOA hIC = NULL; + LPWININETAPPINFOW hIC = NULL; TRACE("len(%ld)\n", *lpdwCurrentDirectory); @@ -719,7 +719,7 @@ BOOL WINAPI FtpGetCurrentDirectoryA(HINTERNET hFtpSession, LPSTR lpszCurrentDire return FALSE; } - hIC = (LPWININETAPPINFOA) lpwfs->hdr.lpwhparent; + hIC = (LPWININETAPPINFOW) lpwfs->hdr.lpwhparent; if (hIC->hdr.dwFlags & INTERNET_FLAG_ASYNC) { WORKREQUEST workRequest; @@ -774,7 +774,7 @@ BOOL WINAPI FTP_FtpGetCurrentDirectoryA(HINTERNET hFtpSession, LPSTR lpszCurrent { INT nResCode; LPWININETFTPSESSIONA lpwfs; - LPWININETAPPINFOA hIC = NULL; + LPWININETAPPINFOW hIC = NULL; DWORD bSuccess = FALSE; TRACE("len(%ld)\n", *lpdwCurrentDirectory); @@ -791,7 +791,7 @@ BOOL WINAPI FTP_FtpGetCurrentDirectoryA(HINTERNET hFtpSession, LPSTR lpszCurrent ZeroMemory(lpszCurrentDirectory, *lpdwCurrentDirectory); - hIC = (LPWININETAPPINFOA) lpwfs->hdr.lpwhparent; + hIC = (LPWININETAPPINFOW) lpwfs->hdr.lpwhparent; if (!FTP_SendCommand(lpwfs->sndSocket, FTP_CMD_PWD, NULL, hIC->lpfnStatusCB, hFtpSession, lpwfs->hdr.dwContext)) goto lend; @@ -855,7 +855,7 @@ HINTERNET WINAPI FtpOpenFileA(HINTERNET hFtpSession, DWORD dwContext) { LPWININETFTPSESSIONA lpwfs; - LPWININETAPPINFOA hIC = NULL; + LPWININETAPPINFOW hIC = NULL; lpwfs = (LPWININETFTPSESSIONA) WININET_GetObject( hFtpSession ); if (NULL == lpwfs || WH_HFTPSESSION != lpwfs->hdr.htype) @@ -869,7 +869,7 @@ HINTERNET WINAPI FtpOpenFileA(HINTERNET hFtpSession, return FALSE; } - hIC = (LPWININETAPPINFOA) lpwfs->hdr.lpwhparent; + hIC = (LPWININETAPPINFOW) lpwfs->hdr.lpwhparent; if (hIC->hdr.dwFlags & INTERNET_FLAG_ASYNC) { WORKREQUEST workRequest; @@ -929,7 +929,7 @@ HINTERNET FTP_FtpOpenFileA(HINTERNET hFtpSession, INT nDataSocket; BOOL bSuccess = FALSE; LPWININETFILE lpwh = NULL; - LPWININETAPPINFOA hIC = NULL; + LPWININETAPPINFOW hIC = NULL; LPWININETFTPSESSIONA lpwfs; HINTERNET handle = NULL; @@ -975,7 +975,7 @@ HINTERNET FTP_FtpOpenFileA(HINTERNET hFtpSession, if (lpwfs->lstnSocket != -1) close(lpwfs->lstnSocket); - hIC = (LPWININETAPPINFOA) lpwfs->hdr.lpwhparent; + hIC = (LPWININETAPPINFOW) lpwfs->hdr.lpwhparent; if (hIC->hdr.dwFlags & INTERNET_FLAG_ASYNC && hIC->lpfnStatusCB) { INTERNET_ASYNC_RESULT iar; @@ -1013,7 +1013,7 @@ BOOL WINAPI FtpGetFileA(HINTERNET hInternet, LPCSTR lpszRemoteFile, LPCSTR lpszN DWORD dwContext) { LPWININETFTPSESSIONA lpwfs; - LPWININETAPPINFOA hIC = NULL; + LPWININETAPPINFOW hIC = NULL; lpwfs = (LPWININETFTPSESSIONA) WININET_GetObject( hInternet ); if (NULL == lpwfs || WH_HFTPSESSION != lpwfs->hdr.htype) @@ -1027,7 +1027,7 @@ BOOL WINAPI FtpGetFileA(HINTERNET hInternet, LPCSTR lpszRemoteFile, LPCSTR lpszN return FALSE; } - hIC = (LPWININETAPPINFOA) lpwfs->hdr.lpwhparent; + hIC = (LPWININETAPPINFOW) lpwfs->hdr.lpwhparent; if (hIC->hdr.dwFlags & INTERNET_FLAG_ASYNC) { WORKREQUEST workRequest; @@ -1089,7 +1089,7 @@ BOOL WINAPI FTP_FtpGetFileA(HINTERNET hInternet, LPCSTR lpszRemoteFile, LPCSTR l DWORD nBytes; BOOL bSuccess = FALSE; HANDLE hFile; - LPWININETAPPINFOA hIC = NULL; + LPWININETAPPINFOW hIC = NULL; LPWININETFTPSESSIONA lpwfs; TRACE("lpszRemoteFile(%s) lpszNewFile(%s)\n", lpszRemoteFile, lpszNewFile); @@ -1144,7 +1144,7 @@ lend: if (hFile) CloseHandle(hFile); - hIC = (LPWININETAPPINFOA) lpwfs->hdr.lpwhparent; + hIC = (LPWININETAPPINFOW) lpwfs->hdr.lpwhparent; if (hIC->hdr.dwFlags & INTERNET_FLAG_ASYNC && hIC->lpfnStatusCB) { INTERNET_ASYNC_RESULT iar; @@ -1172,7 +1172,7 @@ lend: BOOL WINAPI FtpDeleteFileA(HINTERNET hFtpSession, LPCSTR lpszFileName) { LPWININETFTPSESSIONA lpwfs; - LPWININETAPPINFOA hIC = NULL; + LPWININETAPPINFOW hIC = NULL; lpwfs = (LPWININETFTPSESSIONA) WININET_GetObject( hFtpSession ); if (NULL == lpwfs || WH_HFTPSESSION != lpwfs->hdr.htype) @@ -1181,7 +1181,7 @@ BOOL WINAPI FtpDeleteFileA(HINTERNET hFtpSession, LPCSTR lpszFileName) return FALSE; } - hIC = (LPWININETAPPINFOA) lpwfs->hdr.lpwhparent; + hIC = (LPWININETAPPINFOW) lpwfs->hdr.lpwhparent; if (hIC->hdr.dwFlags & INTERNET_FLAG_ASYNC) { WORKREQUEST workRequest; @@ -1215,7 +1215,7 @@ BOOL FTP_FtpDeleteFileA(HINTERNET hFtpSession, LPCSTR lpszFileName) { INT nResCode; BOOL bSuccess = FALSE; - LPWININETAPPINFOA hIC = NULL; + LPWININETAPPINFOW hIC = NULL; LPWININETFTPSESSIONA lpwfs; TRACE("0x%08lx\n", (ULONG) hFtpSession); @@ -1243,7 +1243,7 @@ BOOL FTP_FtpDeleteFileA(HINTERNET hFtpSession, LPCSTR lpszFileName) FTP_SetResponseError(nResCode); } lend: - hIC = (LPWININETAPPINFOA) lpwfs->hdr.lpwhparent; + hIC = (LPWININETAPPINFOW) lpwfs->hdr.lpwhparent; if (hIC->hdr.dwFlags & INTERNET_FLAG_ASYNC && hIC->lpfnStatusCB) { INTERNET_ASYNC_RESULT iar; @@ -1271,7 +1271,7 @@ lend: BOOL WINAPI FtpRemoveDirectoryA(HINTERNET hFtpSession, LPCSTR lpszDirectory) { LPWININETFTPSESSIONA lpwfs; - LPWININETAPPINFOA hIC = NULL; + LPWININETAPPINFOW hIC = NULL; lpwfs = (LPWININETFTPSESSIONA) WININET_GetObject( hFtpSession ); if (NULL == lpwfs || WH_HFTPSESSION != lpwfs->hdr.htype) @@ -1280,7 +1280,7 @@ BOOL WINAPI FtpRemoveDirectoryA(HINTERNET hFtpSession, LPCSTR lpszDirectory) return FALSE; } - hIC = (LPWININETAPPINFOA) lpwfs->hdr.lpwhparent; + hIC = (LPWININETAPPINFOW) lpwfs->hdr.lpwhparent; if (hIC->hdr.dwFlags & INTERNET_FLAG_ASYNC) { WORKREQUEST workRequest; @@ -1314,7 +1314,7 @@ BOOL FTP_FtpRemoveDirectoryA(HINTERNET hFtpSession, LPCSTR lpszDirectory) { INT nResCode; BOOL bSuccess = FALSE; - LPWININETAPPINFOA hIC = NULL; + LPWININETAPPINFOW hIC = NULL; LPWININETFTPSESSIONA lpwfs; TRACE("\n"); @@ -1343,7 +1343,7 @@ BOOL FTP_FtpRemoveDirectoryA(HINTERNET hFtpSession, LPCSTR lpszDirectory) } lend: - hIC = (LPWININETAPPINFOA) lpwfs->hdr.lpwhparent; + hIC = (LPWININETAPPINFOW) lpwfs->hdr.lpwhparent; if (hIC->hdr.dwFlags & INTERNET_FLAG_ASYNC && hIC->lpfnStatusCB) { INTERNET_ASYNC_RESULT iar; @@ -1371,7 +1371,7 @@ lend: BOOL WINAPI FtpRenameFileA(HINTERNET hFtpSession, LPCSTR lpszSrc, LPCSTR lpszDest) { LPWININETFTPSESSIONA lpwfs; - LPWININETAPPINFOA hIC = NULL; + LPWININETAPPINFOW hIC = NULL; lpwfs = (LPWININETFTPSESSIONA) WININET_GetObject( hFtpSession ); if (NULL == lpwfs || WH_HFTPSESSION != lpwfs->hdr.htype) @@ -1380,7 +1380,7 @@ BOOL WINAPI FtpRenameFileA(HINTERNET hFtpSession, LPCSTR lpszSrc, LPCSTR lpszDes return FALSE; } - hIC = (LPWININETAPPINFOA) lpwfs->hdr.lpwhparent; + hIC = (LPWININETAPPINFOW) lpwfs->hdr.lpwhparent; if (hIC->hdr.dwFlags & INTERNET_FLAG_ASYNC) { WORKREQUEST workRequest; @@ -1414,7 +1414,7 @@ BOOL FTP_FtpRenameFileA(HINTERNET hFtpSession, LPCSTR lpszSrc, LPCSTR lpszDest) { INT nResCode; BOOL bSuccess = FALSE; - LPWININETAPPINFOA hIC = NULL; + LPWININETAPPINFOW hIC = NULL; LPWININETFTPSESSIONA lpwfs; TRACE("\n"); @@ -1449,7 +1449,7 @@ BOOL FTP_FtpRenameFileA(HINTERNET hFtpSession, LPCSTR lpszSrc, LPCSTR lpszDest) FTP_SetResponseError(nResCode); lend: - hIC = (LPWININETAPPINFOA) lpwfs->hdr.lpwhparent; + hIC = (LPWININETAPPINFOW) lpwfs->hdr.lpwhparent; if (hIC->hdr.dwFlags & INTERNET_FLAG_ASYNC && hIC->lpfnStatusCB) { INTERNET_ASYNC_RESULT iar; @@ -1482,7 +1482,7 @@ HINTERNET FTP_Connect(HINTERNET hInternet, LPCSTR lpszServerName, struct sockaddr_in socketAddr; struct hostent *phe = NULL; INT nsocket = -1, sock_namelen; - LPWININETAPPINFOA hIC = NULL; + LPWININETAPPINFOW hIC = NULL; BOOL bSuccess = FALSE; LPWININETFTPSESSIONA lpwfs = NULL; HINTERNET handle = NULL; @@ -1491,7 +1491,7 @@ HINTERNET FTP_Connect(HINTERNET hInternet, LPCSTR lpszServerName, (ULONG) hInternet, lpszServerName, nServerPort, lpszUserName, lpszPassword); - hIC = (LPWININETAPPINFOA) WININET_GetObject( hInternet ); + hIC = (LPWININETAPPINFOW) WININET_GetObject( hInternet ); if ( (hIC == NULL) || (hIC->hdr.htype != WH_HINIT) ) goto lerror; diff --git a/dlls/wininet/http.c b/dlls/wininet/http.c index af4036610f..f9cab891ef 100644 --- a/dlls/wininet/http.c +++ b/dlls/wininet/http.c @@ -205,7 +205,7 @@ HINTERNET WINAPI HttpOpenRequestA(HINTERNET hHttpSession, DWORD dwFlags, DWORD dwContext) { LPWININETHTTPSESSIONA lpwhs; - LPWININETAPPINFOA hIC = NULL; + LPWININETAPPINFOW hIC = NULL; HINTERNET handle = NULL; TRACE("(%p, %s, %s, %s, %s, %p, %08lx, %08lx)\n", hHttpSession, @@ -225,7 +225,7 @@ HINTERNET WINAPI HttpOpenRequestA(HINTERNET hHttpSession, INTERNET_SetLastError(ERROR_INTERNET_INCORRECT_HANDLE_TYPE); return NULL; } - hIC = (LPWININETAPPINFOA) lpwhs->hdr.lpwhparent; + hIC = (LPWININETAPPINFOW) lpwhs->hdr.lpwhparent; /* * My tests seem to show that the windows version does not @@ -381,7 +381,7 @@ end: /*********************************************************************** * HTTP_Base64 */ -static UINT HTTP_Base64( LPCSTR bin, LPSTR base64 ) +static UINT HTTP_Base64( LPCWSTR bin, LPWSTR base64 ) { UINT n = 0, x; static LPSTR HTTP_Base64Enc = @@ -426,26 +426,28 @@ static UINT HTTP_Base64( LPCSTR bin, LPSTR base64 ) * * Encode the basic authentication string for HTTP 1.1 */ -static LPSTR HTTP_EncodeBasicAuth( LPCSTR username, LPCSTR password) +static LPWSTR HTTP_EncodeBasicAuth( LPCWSTR username, LPCWSTR password) { UINT len; - LPSTR in, out, szBasic = "Basic "; + LPWSTR in, out; + WCHAR szBasic[] = {'B','a','s','i','c',' ',0}; + WCHAR szColon[] = {':',0}; - len = strlen( username ) + 1 + strlen ( password ) + 1; - in = HeapAlloc( GetProcessHeap(), 0, len ); + len = lstrlenW( username ) + 1 + lstrlenW ( password ) + 1; + in = HeapAlloc( GetProcessHeap(), 0, len*sizeof(WCHAR) ); if( !in ) return NULL; - len = strlen(szBasic) + - (strlen( username ) + 1 + strlen ( password ))*2 + 1 + 1; + len = lstrlenW(szBasic) + + (lstrlenW( username ) + 1 + lstrlenW ( password ))*2 + 1 + 1; out = HeapAlloc( GetProcessHeap(), 0, len ); if( out ) { - strcpy( in, username ); - strcat( in, ":" ); - strcat( in, password ); - strcpy( out, szBasic ); - HTTP_Base64( in, &out[strlen(out)] ); + lstrcpyW( in, username ); + lstrcatW( in, szColon ); + lstrcatW( in, password ); + lstrcpyW( out, szBasic ); + HTTP_Base64( in, &out[strlenW(out)] ); } HeapFree( GetProcessHeap(), 0, in ); @@ -458,13 +460,19 @@ static LPSTR HTTP_EncodeBasicAuth( LPCSTR username, LPCSTR password) * Insert the basic authorization field in the request header */ BOOL HTTP_InsertProxyAuthorization( LPWININETHTTPREQA lpwhr, - LPCSTR username, LPCSTR password ) + LPCWSTR username, LPCWSTR password ) { HTTPHEADERA hdr; - INT index; + INT index, len; + LPWSTR authW; + + authW = HTTP_EncodeBasicAuth( username, password ); + + len = WideCharToMultiByte( CP_ACP, 0, authW, -1, NULL, 0, NULL, NULL); + hdr.lpszValue = HeapAlloc( GetProcessHeap(), 0, len ); + WideCharToMultiByte( CP_ACP, 0, authW, -1, hdr.lpszValue, len, NULL, NULL); hdr.lpszField = "Proxy-Authorization"; - hdr.lpszValue = HTTP_EncodeBasicAuth( username, password ); hdr.wFlags = HDR_ISREQUEST; hdr.wCount = 0; if( !hdr.lpszValue ) @@ -480,6 +488,7 @@ BOOL HTTP_InsertProxyAuthorization( LPWININETHTTPREQA lpwhr, HTTP_InsertCustomHeader(lpwhr, &hdr); HeapFree( GetProcessHeap(), 0, hdr.lpszValue ); + HeapFree( GetProcessHeap(), 0, authW ); return TRUE; } @@ -487,7 +496,7 @@ BOOL HTTP_InsertProxyAuthorization( LPWININETHTTPREQA lpwhr, /*********************************************************************** * HTTP_DealWithProxy */ -static BOOL HTTP_DealWithProxy( LPWININETAPPINFOA hIC, +static BOOL HTTP_DealWithProxy( LPWININETAPPINFOW hIC, LPWININETHTTPSESSIONA lpwhs, LPWININETHTTPREQA lpwhr) { char buf[MAXHOSTNAME]; @@ -500,10 +509,11 @@ static BOOL HTTP_DealWithProxy( LPWININETAPPINFOA hIC, UrlComponents.lpszHostName = buf; UrlComponents.dwHostNameLength = MAXHOSTNAME; - if (strncasecmp(hIC->lpszProxy,"http://",strlen("http://"))) - sprintf(proxy, "http://%s/", hIC->lpszProxy); + WideCharToMultiByte(CP_ACP, 0, hIC->lpszProxy, -1, buf, sizeof buf, NULL, NULL); + if (strncasecmp(buf,"http://",strlen("http://"))) + sprintf(proxy, "http://%s/", buf); else - strcpy(proxy,hIC->lpszProxy); + strcpy(proxy,buf); if( !InternetCrackUrlA(proxy, 0, 0, &UrlComponents) ) return FALSE; if( UrlComponents.dwHostNameLength == 0 ) @@ -551,7 +561,7 @@ HINTERNET WINAPI HTTP_HttpOpenRequestA(HINTERNET hHttpSession, DWORD dwFlags, DWORD dwContext) { LPWININETHTTPSESSIONA lpwhs; - LPWININETAPPINFOA hIC = NULL; + LPWININETAPPINFOW hIC = NULL; LPWININETHTTPREQA lpwhr; LPSTR lpszCookies; LPSTR lpszUrl = NULL; @@ -567,7 +577,7 @@ HINTERNET WINAPI HTTP_HttpOpenRequestA(HINTERNET hHttpSession, return NULL; } - hIC = (LPWININETAPPINFOA) lpwhs->hdr.lpwhparent; + hIC = (LPWININETAPPINFOW) lpwhs->hdr.lpwhparent; lpwhr = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(WININETHTTPREQA)); if (NULL == lpwhr) @@ -641,8 +651,16 @@ HINTERNET WINAPI HTTP_HttpOpenRequestA(HINTERNET hHttpSession, if (hIC->lpszAgent) { - char *agent_header = HeapAlloc(GetProcessHeap(), 0, strlen(hIC->lpszAgent) + 1 + 14); - sprintf(agent_header, "User-Agent: %s\r\n", hIC->lpszAgent); + int len = WideCharToMultiByte(CP_ACP, 0, hIC->lpszAgent, -1, NULL, 0, NULL, NULL ); + char *agent_header, *user_agent = "User-Agent: "; + + agent_header = HeapAlloc( GetProcessHeap(), 0, + strlen(user_agent) + len + 3 ); + strcpy(agent_header, user_agent); + WideCharToMultiByte(CP_ACP, 0, hIC->lpszAgent, -1, + agent_header+strlen(user_agent), len, NULL, NULL ); + strcat(agent_header, "\r\n"); + HttpAddRequestHeadersA(handle, agent_header, strlen(agent_header), HTTP_ADDREQ_FLAG_ADD); HeapFree(GetProcessHeap(), 0, agent_header); @@ -1071,7 +1089,7 @@ BOOL WINAPI HttpSendRequestA(HINTERNET hHttpRequest, LPCSTR lpszHeaders, { LPWININETHTTPREQA lpwhr; LPWININETHTTPSESSIONA lpwhs = NULL; - LPWININETAPPINFOA hIC = NULL; + LPWININETAPPINFOW hIC = NULL; TRACE("%p, %p (%s), %li, %p, %li)\n", hHttpRequest, lpszHeaders, debugstr_a(lpszHeaders), dwHeaderLength, lpOptional, dwOptionalLength); @@ -1090,7 +1108,7 @@ BOOL WINAPI HttpSendRequestA(HINTERNET hHttpRequest, LPCSTR lpszHeaders, return FALSE; } - hIC = (LPWININETAPPINFOA) lpwhs->hdr.lpwhparent; + hIC = (LPWININETAPPINFOW) lpwhs->hdr.lpwhparent; if (NULL == hIC || hIC->hdr.htype != WH_HINIT) { INTERNET_SetLastError(ERROR_INTERNET_INCORRECT_HANDLE_TYPE); @@ -1162,7 +1180,7 @@ static BOOL HTTP_HandleRedirect(LPWININETHTTPREQA lpwhr, LPCSTR lpszUrl, LPCSTR DWORD dwHeaderLength, LPVOID lpOptional, DWORD dwOptionalLength) { LPWININETHTTPSESSIONA lpwhs = (LPWININETHTTPSESSIONA) lpwhr->hdr.lpwhparent; - LPWININETAPPINFOA hIC = (LPWININETAPPINFOA) lpwhs->hdr.lpwhparent; + LPWININETAPPINFOW hIC = (LPWININETAPPINFOW) lpwhs->hdr.lpwhparent; char path[2048]; HINTERNET handle; @@ -1295,7 +1313,7 @@ BOOL WINAPI HTTP_HttpSendRequestA(HINTERNET hHttpRequest, LPCSTR lpszHeaders, INT headerLength = 0; LPWININETHTTPREQA lpwhr; LPWININETHTTPSESSIONA lpwhs = NULL; - LPWININETAPPINFOA hIC = NULL; + LPWININETAPPINFOW hIC = NULL; BOOL loop_next = FALSE; int CustHeaderIndex; @@ -1316,7 +1334,7 @@ BOOL WINAPI HTTP_HttpSendRequestA(HINTERNET hHttpRequest, LPCSTR lpszHeaders, return FALSE; } - hIC = (LPWININETAPPINFOA) lpwhs->hdr.lpwhparent; + hIC = (LPWININETAPPINFOW) lpwhs->hdr.lpwhparent; if (NULL == hIC || hIC->hdr.htype != WH_HINIT) { INTERNET_SetLastError(ERROR_INTERNET_INCORRECT_HANDLE_TYPE); @@ -1689,13 +1707,13 @@ HINTERNET HTTP_Connect(HINTERNET hInternet, LPCSTR lpszServerName, LPCSTR lpszPassword, DWORD dwFlags, DWORD dwContext) { BOOL bSuccess = FALSE; - LPWININETAPPINFOA hIC = NULL; + LPWININETAPPINFOW hIC = NULL; LPWININETHTTPSESSIONA lpwhs = NULL; HINTERNET handle = NULL; TRACE("-->\n"); - hIC = (LPWININETAPPINFOA) WININET_GetObject( hInternet ); + hIC = (LPWININETAPPINFOW) WININET_GetObject( hInternet ); if( (hIC == NULL) || (hIC->hdr.htype != WH_HINIT) ) goto lerror; @@ -1728,7 +1746,7 @@ HINTERNET HTTP_Connect(HINTERNET hInternet, LPCSTR lpszServerName, lpwhs->hdr.dwFlags = dwFlags; lpwhs->hdr.dwContext = dwContext; if(hIC->lpszProxy && hIC->dwAccessType == INTERNET_OPEN_TYPE_PROXY) { - if(strchr(hIC->lpszProxy, ' ')) + if(strchrW(hIC->lpszProxy, ' ')) FIXME("Several proxies not implemented.\n"); if(hIC->lpszProxyBypass) FIXME("Proxy bypass is ignored.\n"); @@ -1785,7 +1803,7 @@ BOOL HTTP_OpenConnection(LPWININETHTTPREQA lpwhr) { BOOL bSuccess = FALSE; LPWININETHTTPSESSIONA lpwhs; - LPWININETAPPINFOA hIC = NULL; + LPWININETAPPINFOW hIC = NULL; TRACE("-->\n"); @@ -1798,7 +1816,7 @@ BOOL HTTP_OpenConnection(LPWININETHTTPREQA lpwhr) lpwhs = (LPWININETHTTPSESSIONA)lpwhr->hdr.lpwhparent; - hIC = (LPWININETAPPINFOA) lpwhs->hdr.lpwhparent; + hIC = (LPWININETAPPINFOW) lpwhs->hdr.lpwhparent; SendAsyncCallback(hIC, lpwhr, lpwhr->hdr.dwContext, INTERNET_STATUS_CONNECTING_TO_SERVER, &(lpwhs->socketAddress), @@ -2202,14 +2220,14 @@ VOID HTTP_CloseConnection(LPWININETHTTPREQA lpwhr) LPWININETHTTPSESSIONA lpwhs = NULL; - LPWININETAPPINFOA hIC = NULL; + LPWININETAPPINFOW hIC = NULL; HINTERNET handle; TRACE("%p\n",lpwhr); handle = WININET_FindHandle( &lpwhr->hdr ); lpwhs = (LPWININETHTTPSESSIONA) lpwhr->hdr.lpwhparent; - hIC = (LPWININETAPPINFOA) lpwhs->hdr.lpwhparent; + hIC = (LPWININETAPPINFOW) lpwhs->hdr.lpwhparent; SendAsyncCallback(hIC, lpwhr, lpwhr->hdr.dwContext, INTERNET_STATUS_CLOSING_CONNECTION, 0, 0); @@ -2234,7 +2252,7 @@ void HTTP_CloseHTTPRequestHandle(LPWININETHTTPREQA lpwhr) { int i; LPWININETHTTPSESSIONA lpwhs = NULL; - LPWININETAPPINFOA hIC = NULL; + LPWININETAPPINFOW hIC = NULL; HINTERNET handle; TRACE("\n"); @@ -2244,7 +2262,7 @@ void HTTP_CloseHTTPRequestHandle(LPWININETHTTPREQA lpwhr) handle = WININET_FindHandle( &lpwhr->hdr ); lpwhs = (LPWININETHTTPSESSIONA) lpwhr->hdr.lpwhparent; - hIC = (LPWININETAPPINFOA) lpwhs->hdr.lpwhparent; + hIC = (LPWININETAPPINFOW) lpwhs->hdr.lpwhparent; SendAsyncCallback(hIC, handle, lpwhr->hdr.dwContext, INTERNET_STATUS_HANDLE_CLOSING, lpwhr, @@ -2286,12 +2304,12 @@ void HTTP_CloseHTTPRequestHandle(LPWININETHTTPREQA lpwhr) */ void HTTP_CloseHTTPSessionHandle(LPWININETHTTPSESSIONA lpwhs) { - LPWININETAPPINFOA hIC = NULL; + LPWININETAPPINFOW hIC = NULL; HINTERNET handle; TRACE("%p\n", lpwhs); - hIC = (LPWININETAPPINFOA) lpwhs->hdr.lpwhparent; + hIC = (LPWININETAPPINFOW) lpwhs->hdr.lpwhparent; handle = WININET_FindHandle( &lpwhs->hdr ); SendAsyncCallback(hIC, handle, lpwhs->hdr.dwContext, diff --git a/dlls/wininet/internet.c b/dlls/wininet/internet.c index 76715a78a4..4e6de307d3 100644 --- a/dlls/wininet/internet.c +++ b/dlls/wininet/internet.c @@ -72,7 +72,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(wininet); #define RESPONSE_TIMEOUT 30 #define GET_HWININET_FROM_LPWININETFINDNEXT(lpwh) \ -(LPWININETAPPINFOA)(((LPWININETFTPSESSIONA)(lpwh->hdr.lpwhparent))->hdr.lpwhparent) +(LPWININETAPPINFOW)(((LPWININETFTPSESSIONA)(lpwh->hdr.lpwhparent))->hdr.lpwhparent) typedef struct @@ -336,12 +336,13 @@ BOOL WINAPI DetectAutoProxyUrl(LPSTR lpszAutoProxyUrl, * The proxy may be specified in the form 'http=proxy.my.org' * Presumably that means there can be ftp=ftpproxy.my.org too. */ -static BOOL INTERNET_ConfigureProxyFromReg( LPWININETAPPINFOA lpwai ) +static BOOL INTERNET_ConfigureProxyFromReg( LPWININETAPPINFOW lpwai ) { HKEY key; DWORD r, keytype, len, enabled; LPSTR lpszInternetSettings = "Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings"; + WCHAR szProxyServer[] = { 'P','r','o','x','y','S','e','r','v','e','r', 0 }; r = RegOpenKeyA(HKEY_CURRENT_USER, lpszInternetSettings, &key); if ( r != ERROR_SUCCESS ) @@ -355,31 +356,32 @@ static BOOL INTERNET_ConfigureProxyFromReg( LPWININETAPPINFOA lpwai ) TRACE("Proxy is enabled.\n"); /* figure out how much memory the proxy setting takes */ - r = RegQueryValueExA( key, "ProxyServer", NULL, &keytype, + r = RegQueryValueExW( key, szProxyServer, NULL, &keytype, NULL, &len); if( (r == ERROR_SUCCESS) && len && (keytype == REG_SZ) ) { - LPSTR szProxy, p, szHttp = "http="; + LPWSTR szProxy, p; + WCHAR szHttp[] = {'h','t','t','p','=',0}; - szProxy=HeapAlloc( GetProcessHeap(), 0, len+1 ); - RegQueryValueExA( key, "ProxyServer", NULL, &keytype, + szProxy=HeapAlloc( GetProcessHeap(), 0, len ); + RegQueryValueExW( key, szProxyServer, NULL, &keytype, (BYTE*)szProxy, &len); /* find the http proxy, and strip away everything else */ - p = strstr( szProxy, szHttp ); + p = strstrW( szProxy, szHttp ); if( p ) { - p += strlen(szHttp); - strcpy( szProxy, p ); + p += lstrlenW(szHttp); + lstrcpyW( szProxy, p ); } - p = strchr( szProxy, ' ' ); + p = strchrW( szProxy, ' ' ); if( p ) *p = 0; lpwai->dwAccessType = INTERNET_OPEN_TYPE_PROXY; lpwai->lpszProxy = szProxy; - TRACE("http proxy = %s\n", lpwai->lpszProxy); + TRACE("http proxy = %s\n", debugstr_w(lpwai->lpszProxy)); } else ERR("Couldn't read proxy server settings.\n"); @@ -401,10 +403,10 @@ static BOOL INTERNET_ConfigureProxyFromReg( LPWININETAPPINFOA lpwai ) * NULL on failure * */ -HINTERNET WINAPI InternetOpenA(LPCSTR lpszAgent, DWORD dwAccessType, - LPCSTR lpszProxy, LPCSTR lpszProxyBypass, DWORD dwFlags) +HINTERNET WINAPI InternetOpenW(LPCWSTR lpszAgent, DWORD dwAccessType, + LPCWSTR lpszProxy, LPCWSTR lpszProxyBypass, DWORD dwFlags) { - LPWININETAPPINFOA lpwai = NULL; + LPWININETAPPINFOW lpwai = NULL; HINTERNET handle = NULL; if (TRACE_ON(wininet)) { @@ -425,8 +427,8 @@ HINTERNET WINAPI InternetOpenA(LPCSTR lpszAgent, DWORD dwAccessType, const char *access_type_str = "Unknown"; DWORD flag_val = dwFlags; - TRACE("(%s, %li, %s, %s, %li)\n", debugstr_a(lpszAgent), dwAccessType, - debugstr_a(lpszProxy), debugstr_a(lpszProxyBypass), dwFlags); + TRACE("(%s, %li, %s, %s, %li)\n", debugstr_w(lpszAgent), dwAccessType, + debugstr_w(lpszProxy), debugstr_w(lpszProxyBypass), dwFlags); for (i = 0; i < (sizeof(access_type) / sizeof(access_type[0])); i++) { if (access_type[i].val == dwAccessType) { access_type_str = access_type[i].name; @@ -448,14 +450,14 @@ HINTERNET WINAPI InternetOpenA(LPCSTR lpszAgent, DWORD dwAccessType, /* Clear any error information */ INTERNET_SetLastError(0); - lpwai = HeapAlloc(GetProcessHeap(), 0, sizeof(WININETAPPINFOA)); + lpwai = HeapAlloc(GetProcessHeap(), 0, sizeof(WININETAPPINFOW)); if (NULL == lpwai) { INTERNET_SetLastError(ERROR_OUTOFMEMORY); goto lend; } - memset(lpwai, 0, sizeof(WININETAPPINFOA)); + memset(lpwai, 0, sizeof(WININETAPPINFOW)); lpwai->hdr.htype = WH_HINIT; lpwai->hdr.lpwhparent = NULL; lpwai->hdr.dwFlags = dwFlags; @@ -474,26 +476,26 @@ HINTERNET WINAPI InternetOpenA(LPCSTR lpszAgent, DWORD dwAccessType, if (NULL != lpszAgent) { lpwai->lpszAgent = HeapAlloc( GetProcessHeap(),0, - strlen(lpszAgent)+1); + (strlenW(lpszAgent)+1)*sizeof(WCHAR)); if (lpwai->lpszAgent) - strcpy( lpwai->lpszAgent, lpszAgent ); + lstrcpyW( lpwai->lpszAgent, lpszAgent ); } if(dwAccessType == INTERNET_OPEN_TYPE_PRECONFIG) INTERNET_ConfigureProxyFromReg( lpwai ); else if (NULL != lpszProxy) { lpwai->lpszProxy = HeapAlloc( GetProcessHeap(), 0, - strlen(lpszProxy)+1); + (strlenW(lpszProxy)+1)*sizeof(WCHAR)); if (lpwai->lpszProxy) - strcpy( lpwai->lpszProxy, lpszProxy ); + lstrcpyW( lpwai->lpszProxy, lpszProxy ); } if (NULL != lpszProxyBypass) { lpwai->lpszProxyBypass = HeapAlloc( GetProcessHeap(), 0, - strlen(lpszProxyBypass)+1); + (strlenW(lpszProxyBypass)+1)*sizeof(WCHAR)); if (lpwai->lpszProxyBypass) - strcpy( lpwai->lpszProxyBypass, lpszProxyBypass ); + lstrcpyW( lpwai->lpszProxyBypass, lpszProxyBypass ); } lend: @@ -513,42 +515,45 @@ HINTERNET WINAPI InternetOpenA(LPCSTR lpszAgent, DWORD dwAccessType, * NULL on failure * */ -HINTERNET WINAPI InternetOpenW(LPCWSTR lpszAgent, DWORD dwAccessType, - LPCWSTR lpszProxy, LPCWSTR lpszProxyBypass, DWORD dwFlags) +HINTERNET WINAPI InternetOpenA(LPCSTR lpszAgent, DWORD dwAccessType, + LPCSTR lpszProxy, LPCSTR lpszProxyBypass, DWORD dwFlags) { HINTERNET rc = (HINTERNET)NULL; - INT lenAgent = WideCharToMultiByte(CP_ACP, 0, lpszAgent, -1, NULL, 0, NULL, NULL); - INT lenProxy = WideCharToMultiByte(CP_ACP, 0, lpszProxy, -1, NULL, 0, NULL, NULL); - INT lenBypass = WideCharToMultiByte(CP_ACP, 0, lpszProxyBypass, -1, NULL, 0, NULL, NULL); - CHAR *szAgent = (CHAR *)HeapAlloc(GetProcessHeap(), 0, lenAgent*sizeof(CHAR)); - CHAR *szProxy = (CHAR *)HeapAlloc(GetProcessHeap(), 0, lenProxy*sizeof(CHAR)); - CHAR *szBypass = (CHAR *)HeapAlloc(GetProcessHeap(), 0, lenBypass*sizeof(CHAR)); + INT len; + WCHAR *szAgent = NULL, *szProxy = NULL, *szBypass = NULL; - TRACE("(%s, 0x%08lx, %s, %s, 0x%08lx)\n", debugstr_w(lpszAgent), dwAccessType, debugstr_w(lpszProxy), debugstr_w(lpszProxyBypass), dwFlags); + TRACE("(%s, 0x%08lx, %s, %s, 0x%08lx)\n", debugstr_a(lpszAgent), + dwAccessType, debugstr_a(lpszProxy), debugstr_a(lpszProxyBypass), dwFlags); - if (!szAgent || !szProxy || !szBypass) + if( lpszAgent ) { - if (szAgent) - HeapFree(GetProcessHeap(), 0, szAgent); - if (szProxy) - HeapFree(GetProcessHeap(), 0, szProxy); - if (szBypass) - HeapFree(GetProcessHeap(), 0, szBypass); - return (HINTERNET)NULL; + len = MultiByteToWideChar(CP_ACP, 0, lpszAgent, -1, NULL, 0); + szAgent = HeapAlloc(GetProcessHeap(), 0, len*sizeof(WCHAR)); + MultiByteToWideChar(CP_ACP, 0, lpszAgent, -1, szAgent, len); } - WideCharToMultiByte(CP_ACP, 0, lpszAgent, -1, szAgent, lenAgent, - NULL, NULL); - WideCharToMultiByte(CP_ACP, 0, lpszProxy, -1, szProxy, lenProxy, - NULL, NULL); - WideCharToMultiByte(CP_ACP, 0, lpszProxyBypass, -1, szBypass, lenBypass, - NULL, NULL); + if( lpszProxy ) + { + len = MultiByteToWideChar(CP_ACP, 0, lpszProxy, -1, NULL, 0); + szProxy = HeapAlloc(GetProcessHeap(), 0, len*sizeof(WCHAR)); + MultiByteToWideChar(CP_ACP, 0, lpszProxy, -1, szProxy, len); + } - rc = InternetOpenA(szAgent, dwAccessType, szProxy, szBypass, dwFlags); + if( lpszProxyBypass ) + { + len = MultiByteToWideChar(CP_ACP, 0, lpszProxyBypass, -1, NULL, 0); + szBypass = HeapAlloc(GetProcessHeap(), 0, len*sizeof(WCHAR)); + MultiByteToWideChar(CP_ACP, 0, lpszProxyBypass, -1, szBypass, len); + } - HeapFree(GetProcessHeap(), 0, szAgent); - HeapFree(GetProcessHeap(), 0, szProxy); - HeapFree(GetProcessHeap(), 0, szBypass); + rc = InternetOpenW(szAgent, dwAccessType, szProxy, szBypass, dwFlags); + + if( szAgent ) + HeapFree(GetProcessHeap(), 0, szAgent); + if( szProxy ) + HeapFree(GetProcessHeap(), 0, szProxy); + if( szBypass ) + HeapFree(GetProcessHeap(), 0, szBypass); return rc; } @@ -749,7 +754,7 @@ HINTERNET WINAPI InternetConnectW(HINTERNET hInternet, */ BOOL WINAPI InternetFindNextFileA(HINTERNET hFind, LPVOID lpvFindData) { - LPWININETAPPINFOA hIC = NULL; + LPWININETAPPINFOW hIC = NULL; LPWININETFINDNEXTA lpwh; TRACE("\n"); @@ -794,7 +799,7 @@ BOOL WINAPI InternetFindNextFileA(HINTERNET hFind, LPVOID lpvFindData) BOOL WINAPI INTERNET_FindNextFileA(HINTERNET hFind, LPVOID lpvFindData) { BOOL bSuccess = TRUE; - LPWININETAPPINFOA hIC = NULL; + LPWININETAPPINFOW hIC = NULL; LPWIN32_FIND_DATAA lpFindFileData; LPWININETFINDNEXTA lpwh; @@ -863,7 +868,7 @@ lend: * Void * */ -VOID INTERNET_CloseHandle(LPWININETAPPINFOA lpwai) +VOID INTERNET_CloseHandle(LPWININETAPPINFOW lpwai) { TRACE("%p\n",lpwai); @@ -921,7 +926,7 @@ BOOL WINAPI InternetCloseHandle(HINTERNET hInternet) switch (lpwh->htype) { case WH_HINIT: - INTERNET_CloseHandle((LPWININETAPPINFOA) lpwh); + INTERNET_CloseHandle((LPWININETAPPINFOW) lpwh); retval = TRUE; break; @@ -1461,9 +1466,9 @@ INTERNET_STATUS_CALLBACK WINAPI InternetSetStatusCallbackA( HINTERNET hInternet ,INTERNET_STATUS_CALLBACK lpfnIntCB) { INTERNET_STATUS_CALLBACK retVal; - LPWININETAPPINFOA lpwai; + LPWININETAPPINFOW lpwai; - lpwai = (LPWININETAPPINFOA)WININET_GetObject(hInternet); + lpwai = (LPWININETAPPINFOW)WININET_GetObject(hInternet); if (!lpwai) return NULL; @@ -2126,12 +2131,12 @@ HINTERNET WINAPI InternetOpenUrlA(HINTERNET hInternet, LPCSTR lpszUrl, LPCSTR lpszHeaders, DWORD dwHeadersLength, DWORD dwFlags, DWORD dwContext) { HINTERNET ret = NULL; - LPWININETAPPINFOA hIC = NULL; + LPWININETAPPINFOW hIC = NULL; TRACE("(%p, %s, %s, %08lx, %08lx, %08lx\n", hInternet, debugstr_a(lpszUrl), debugstr_a(lpszHeaders), dwHeadersLength, dwFlags, dwContext); - hIC = (LPWININETAPPINFOA) WININET_GetObject( hInternet ); + hIC = (LPWININETAPPINFOW) WININET_GetObject( hInternet ); if (NULL == hIC || hIC->hdr.htype != WH_HINIT) { INTERNET_SetLastError(ERROR_INTERNET_INCORRECT_HANDLE_TYPE); goto lend; diff --git a/dlls/wininet/internet.h b/dlls/wininet/internet.h index 012273a5e4..291d01a898 100644 --- a/dlls/wininet/internet.h +++ b/dlls/wininet/internet.h @@ -85,14 +85,14 @@ typedef struct _WININETHANDLEHEADER typedef struct { WININETHANDLEHEADER hdr; - LPSTR lpszAgent; - LPSTR lpszProxy; - LPSTR lpszProxyBypass; - LPSTR lpszProxyUsername; - LPSTR lpszProxyPassword; + LPWSTR lpszAgent; + LPWSTR lpszProxy; + LPWSTR lpszProxyBypass; + LPWSTR lpszProxyUsername; + LPWSTR lpszProxyPassword; DWORD dwAccessType; INTERNET_STATUS_CALLBACK lpfnStatusCB; -} WININETAPPINFOA, *LPWININETAPPINFOA; +} WININETAPPINFOW, *LPWININETAPPINFOW; typedef struct @@ -382,16 +382,16 @@ INTERNETAPI HINTERNET WINAPI HTTP_HttpOpenRequestA(HINTERNET hHttpSession, void HTTP_CloseHTTPSessionHandle(LPWININETHTTPSESSIONA lpwhs); void HTTP_CloseHTTPRequestHandle(LPWININETHTTPREQA lpwhr); -VOID SendAsyncCallback(LPWININETAPPINFOA hIC, HINTERNET hHttpSession, +VOID SendAsyncCallback(LPWININETAPPINFOW hIC, HINTERNET hHttpSession, DWORD dwContext, DWORD dwInternetStatus, LPVOID lpvStatusInfo , DWORD dwStatusInfoLength); -VOID SendAsyncCallbackInt(LPWININETAPPINFOA hIC, HINTERNET hHttpSession, +VOID SendAsyncCallbackInt(LPWININETAPPINFOW hIC, HINTERNET hHttpSession, DWORD dwContext, DWORD dwInternetStatus, LPVOID lpvStatusInfo , DWORD dwStatusInfoLength); BOOL HTTP_InsertProxyAuthorization( LPWININETHTTPREQA lpwhr, - LPCSTR username, LPCSTR password ); + LPCWSTR username, LPCWSTR password ); BOOL NETCON_connected(WININET_NETCONNECTION *connection); void NETCON_init(WININET_NETCONNECTION *connnection, BOOL useSSL); diff --git a/dlls/wininet/utility.c b/dlls/wininet/utility.c index a6931f4ad9..f1ce66d18c 100644 --- a/dlls/wininet/utility.c +++ b/dlls/wininet/utility.c @@ -212,7 +212,7 @@ static const char *get_callback_name(DWORD dwInternetStatus) { return "Unknown"; } -VOID SendAsyncCallbackInt(LPWININETAPPINFOA hIC, HINTERNET hHttpSession, +VOID SendAsyncCallbackInt(LPWININETAPPINFOW hIC, HINTERNET hHttpSession, DWORD dwContext, DWORD dwInternetStatus, LPVOID lpvStatusInfo, DWORD dwStatusInfoLength) { @@ -234,7 +234,7 @@ VOID SendAsyncCallbackInt(LPWININETAPPINFOA hIC, HINTERNET hHttpSession, -VOID SendAsyncCallback(LPWININETAPPINFOA hIC, HINTERNET hHttpSession, +VOID SendAsyncCallback(LPWININETAPPINFOW hIC, HINTERNET hHttpSession, DWORD dwContext, DWORD dwInternetStatus, LPVOID lpvStatusInfo, DWORD dwStatusInfoLength) {