Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
f165e25e
Commit
f165e25e
authored
Feb 02, 2011
by
Jacek Caban
Committed by
Alexandre Julliard
Feb 03, 2011
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
wininet: Handles handling clean up.
parent
e1815f5e
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
132 additions
and
110 deletions
+132
-110
dialogs.c
dlls/wininet/dialogs.c
+3
-3
ftp.c
dlls/wininet/ftp.c
+25
-18
http.c
dlls/wininet/http.c
+11
-15
internet.c
dlls/wininet/internet.c
+66
-71
internet.h
dlls/wininet/internet.h
+27
-3
No files found.
dlls/wininet/dialogs.c
View file @
f165e25e
...
...
@@ -70,7 +70,7 @@ static BOOL WININET_GetProxyServer( HINTERNET hRequest, LPWSTR szBuf, DWORD sz )
BOOL
ret
=
FALSE
;
LPWSTR
p
;
lpwhr
=
(
http_request_t
*
)
WININET_GetO
bject
(
hRequest
);
lpwhr
=
(
http_request_t
*
)
get_handle_o
bject
(
hRequest
);
if
(
NULL
==
lpwhr
)
return
FALSE
;
...
...
@@ -107,7 +107,7 @@ static BOOL WININET_GetServer( HINTERNET hRequest, LPWSTR szBuf, DWORD sz )
http_session_t
*
lpwhs
=
NULL
;
BOOL
ret
=
FALSE
;
lpwhr
=
(
http_request_t
*
)
WININET_GetO
bject
(
hRequest
);
lpwhr
=
(
http_request_t
*
)
get_handle_o
bject
(
hRequest
);
if
(
NULL
==
lpwhr
)
return
FALSE
;
...
...
@@ -246,7 +246,7 @@ static BOOL WININET_SetAuthorization( HINTERNET hRequest, LPWSTR username,
BOOL
ret
=
FALSE
;
LPWSTR
p
,
q
;
lpwhr
=
(
http_request_t
*
)
WININET_GetO
bject
(
hRequest
);
lpwhr
=
(
http_request_t
*
)
get_handle_o
bject
(
hRequest
);
if
(
!
lpwhr
)
return
FALSE
;
...
...
dlls/wininet/ftp.c
View file @
f165e25e
...
...
@@ -288,7 +288,7 @@ BOOL WINAPI FtpPutFileW(HINTERNET hConnect, LPCWSTR lpszLocalFile,
return
FALSE
;
}
lpwfs
=
(
ftp_session_t
*
)
WININET_GetO
bject
(
hConnect
);
lpwfs
=
(
ftp_session_t
*
)
get_handle_o
bject
(
hConnect
);
if
(
!
lpwfs
)
{
INTERNET_SetLastError
(
ERROR_INVALID_HANDLE
);
...
...
@@ -470,7 +470,7 @@ BOOL WINAPI FtpSetCurrentDirectoryW(HINTERNET hConnect, LPCWSTR lpszDirectory)
goto
lend
;
}
lpwfs
=
(
ftp_session_t
*
)
WININET_GetO
bject
(
hConnect
);
lpwfs
=
(
ftp_session_t
*
)
get_handle_o
bject
(
hConnect
);
if
(
NULL
==
lpwfs
||
WH_HFTPSESSION
!=
lpwfs
->
hdr
.
htype
)
{
INTERNET_SetLastError
(
ERROR_INTERNET_INCORRECT_HANDLE_TYPE
);
...
...
@@ -610,7 +610,7 @@ BOOL WINAPI FtpCreateDirectoryW(HINTERNET hConnect, LPCWSTR lpszDirectory)
appinfo_t
*
hIC
=
NULL
;
BOOL
r
=
FALSE
;
lpwfs
=
(
ftp_session_t
*
)
WININET_GetO
bject
(
hConnect
);
lpwfs
=
(
ftp_session_t
*
)
get_handle_o
bject
(
hConnect
);
if
(
!
lpwfs
)
{
INTERNET_SetLastError
(
ERROR_INVALID_HANDLE
);
...
...
@@ -766,7 +766,7 @@ HINTERNET WINAPI FtpFindFirstFileW(HINTERNET hConnect,
appinfo_t
*
hIC
=
NULL
;
HINTERNET
r
=
NULL
;
lpwfs
=
(
ftp_session_t
*
)
WININET_GetO
bject
(
hConnect
);
lpwfs
=
(
ftp_session_t
*
)
get_handle_o
bject
(
hConnect
);
if
(
NULL
==
lpwfs
||
WH_HFTPSESSION
!=
lpwfs
->
hdr
.
htype
)
{
INTERNET_SetLastError
(
ERROR_INTERNET_INCORRECT_HANDLE_TYPE
);
...
...
@@ -964,7 +964,7 @@ BOOL WINAPI FtpGetCurrentDirectoryW(HINTERNET hFtpSession, LPWSTR lpszCurrentDir
TRACE
(
"%p %p %p
\n
"
,
hFtpSession
,
lpszCurrentDirectory
,
lpdwCurrentDirectory
);
lpwfs
=
(
ftp_session_t
*
)
WININET_GetO
bject
(
hFtpSession
);
lpwfs
=
(
ftp_session_t
*
)
get_handle_o
bject
(
hFtpSession
);
if
(
NULL
==
lpwfs
)
{
INTERNET_SetLastError
(
ERROR_INVALID_HANDLE
);
...
...
@@ -1327,6 +1327,7 @@ static HINTERNET FTP_FtpOpenFileW(ftp_session_t *lpwfs,
ftp_file_t
*
lpwh
=
NULL
;
appinfo_t
*
hIC
=
NULL
;
HINTERNET
handle
=
NULL
;
DWORD
res
=
ERROR_SUCCESS
;
TRACE
(
"
\n
"
);
...
...
@@ -1364,8 +1365,8 @@ static HINTERNET FTP_FtpOpenFileW(ftp_session_t *lpwfs,
lpwh
->
lpFtpSession
=
lpwfs
;
list_add_head
(
&
lpwfs
->
hdr
.
children
,
&
lpwh
->
hdr
.
entry
);
handle
=
WININET_AllocHandle
(
&
lpwh
->
hdr
);
if
(
!
handle
)
res
=
alloc_handle
(
&
lpwh
->
hdr
,
&
handle
);
if
(
res
!=
ERROR_SUCCESS
)
goto
lend
;
/* Indicate that a download is currently in progress */
...
...
@@ -1440,6 +1441,8 @@ lend:
if
(
lpwh
)
WININET_Release
(
&
lpwh
->
hdr
);
if
(
res
!=
ERROR_SUCCESS
)
INTERNET_SetLastError
(
res
);
return
handle
;
}
...
...
@@ -1501,7 +1504,7 @@ HINTERNET WINAPI FtpOpenFileW(HINTERNET hFtpSession,
TRACE
(
"(%p,%s,0x%08x,0x%08x,0x%08lx)
\n
"
,
hFtpSession
,
debugstr_w
(
lpszFileName
),
fdwAccess
,
dwFlags
,
dwContext
);
lpwfs
=
(
ftp_session_t
*
)
WININET_GetO
bject
(
hFtpSession
);
lpwfs
=
(
ftp_session_t
*
)
get_handle_o
bject
(
hFtpSession
);
if
(
!
lpwfs
)
{
INTERNET_SetLastError
(
ERROR_INVALID_HANDLE
);
...
...
@@ -1624,7 +1627,7 @@ BOOL WINAPI FtpGetFileW(HINTERNET hInternet, LPCWSTR lpszRemoteFile, LPCWSTR lps
return
FALSE
;
}
lpwfs
=
(
ftp_session_t
*
)
WININET_GetO
bject
(
hInternet
);
lpwfs
=
(
ftp_session_t
*
)
get_handle_o
bject
(
hInternet
);
if
(
!
lpwfs
)
{
INTERNET_SetLastError
(
ERROR_INVALID_HANDLE
);
...
...
@@ -1818,7 +1821,7 @@ BOOL WINAPI FtpDeleteFileW(HINTERNET hFtpSession, LPCWSTR lpszFileName)
appinfo_t
*
hIC
=
NULL
;
BOOL
r
=
FALSE
;
lpwfs
=
(
ftp_session_t
*
)
WININET_GetO
bject
(
hFtpSession
);
lpwfs
=
(
ftp_session_t
*
)
get_handle_o
bject
(
hFtpSession
);
if
(
!
lpwfs
)
{
INTERNET_SetLastError
(
ERROR_INVALID_HANDLE
);
...
...
@@ -1963,7 +1966,7 @@ BOOL WINAPI FtpRemoveDirectoryW(HINTERNET hFtpSession, LPCWSTR lpszDirectory)
appinfo_t
*
hIC
=
NULL
;
BOOL
r
=
FALSE
;
lpwfs
=
(
ftp_session_t
*
)
WININET_GetO
bject
(
hFtpSession
);
lpwfs
=
(
ftp_session_t
*
)
get_handle_o
bject
(
hFtpSession
);
if
(
!
lpwfs
)
{
INTERNET_SetLastError
(
ERROR_INVALID_HANDLE
);
...
...
@@ -2113,7 +2116,7 @@ BOOL WINAPI FtpRenameFileW(HINTERNET hFtpSession, LPCWSTR lpszSrc, LPCWSTR lpszD
appinfo_t
*
hIC
=
NULL
;
BOOL
r
=
FALSE
;
lpwfs
=
(
ftp_session_t
*
)
WININET_GetO
bject
(
hFtpSession
);
lpwfs
=
(
ftp_session_t
*
)
get_handle_o
bject
(
hFtpSession
);
if
(
!
lpwfs
)
{
INTERNET_SetLastError
(
ERROR_INVALID_HANDLE
);
...
...
@@ -2279,7 +2282,7 @@ BOOL WINAPI FtpCommandW( HINTERNET hConnect, BOOL fExpectResponse, DWORD dwFlags
return
FALSE
;
}
lpwfs
=
(
ftp_session_t
*
)
WININET_GetO
bject
(
hConnect
);
lpwfs
=
(
ftp_session_t
*
)
get_handle_o
bject
(
hConnect
);
if
(
!
lpwfs
)
{
INTERNET_SetLastError
(
ERROR_INVALID_HANDLE
);
...
...
@@ -2451,6 +2454,7 @@ HINTERNET FTP_Connect(appinfo_t *hIC, LPCWSTR lpszServerName,
ftp_session_t
*
lpwfs
=
NULL
;
HINTERNET
handle
=
NULL
;
char
szaddr
[
INET_ADDRSTRLEN
];
DWORD
res
;
TRACE
(
"%p Server(%s) Port(%d) User(%s) Paswd(%s)
\n
"
,
hIC
,
debugstr_w
(
lpszServerName
),
...
...
@@ -2492,11 +2496,11 @@ HINTERNET FTP_Connect(appinfo_t *hIC, LPCWSTR lpszServerName,
lpwfs
->
lpAppInfo
=
hIC
;
list_add_head
(
&
hIC
->
hdr
.
children
,
&
lpwfs
->
hdr
.
entry
);
handle
=
WININET_AllocHandle
(
&
lpwfs
->
hdr
);
if
(
!
handle
)
res
=
alloc_handle
(
&
lpwfs
->
hdr
,
&
handle
);
if
(
res
!=
ERROR_SUCCESS
)
{
ERR
(
"Failed to alloc handle
\n
"
);
INTERNET_SetLastError
(
ERROR_OUTOFMEMORY
);
INTERNET_SetLastError
(
res
);
goto
lerror
;
}
...
...
@@ -2604,7 +2608,7 @@ lerror:
if
(
!
bSuccess
&&
handle
)
{
WININET_FreeHandle
(
handle
);
InternetCloseHandle
(
handle
);
handle
=
NULL
;
}
...
...
@@ -3531,6 +3535,7 @@ static HINTERNET FTP_ReceiveFileList(ftp_session_t *lpwfs, INT nSocket, LPCWSTR
LPFILEPROPERTIESW
lpafp
=
NULL
;
LPWININETFTPFINDNEXTW
lpwfn
=
NULL
;
HINTERNET
handle
=
0
;
DWORD
res
;
TRACE
(
"(%p,%d,%s,%p,%08lx)
\n
"
,
lpwfs
,
nSocket
,
debugstr_w
(
lpszSearchFile
),
lpFindFileData
,
dwContext
);
...
...
@@ -3555,7 +3560,9 @@ static HINTERNET FTP_ReceiveFileList(ftp_session_t *lpwfs, INT nSocket, LPCWSTR
lpwfn
->
lpFtpSession
=
lpwfs
;
list_add_head
(
&
lpwfs
->
hdr
.
children
,
&
lpwfn
->
hdr
.
entry
);
handle
=
WININET_AllocHandle
(
&
lpwfn
->
hdr
);
res
=
alloc_handle
(
&
lpwfn
->
hdr
,
&
handle
);
if
(
res
!=
ERROR_SUCCESS
)
SetLastError
(
res
);
}
}
...
...
dlls/wininet/http.c
View file @
f165e25e
...
...
@@ -1066,7 +1066,7 @@ BOOL WINAPI HttpAddRequestHeadersW(HINTERNET hHttpRequest,
if
(
!
lpszHeader
)
return
TRUE
;
lpwhr
=
(
http_request_t
*
)
WININET_GetO
bject
(
hHttpRequest
);
lpwhr
=
(
http_request_t
*
)
get_handle_o
bject
(
hHttpRequest
);
if
(
lpwhr
&&
lpwhr
->
hdr
.
htype
==
WH_HHTTPREQ
)
res
=
HTTP_HttpAddRequestHeadersW
(
lpwhr
,
lpszHeader
,
dwHeaderLength
,
dwModifier
);
if
(
lpwhr
)
...
...
@@ -2604,12 +2604,9 @@ static DWORD HTTP_HttpOpenRequestW(http_session_t *lpwhs,
goto
lend
;
}
handle
=
WININET_AllocHandle
(
&
lpwhr
->
hdr
);
if
(
NULL
==
handle
)
{
res
=
ERROR_OUTOFMEMORY
;
res
=
alloc_handle
(
&
lpwhr
->
hdr
,
&
handle
);
if
(
res
!=
ERROR_SUCCESS
)
goto
lend
;
}
if
((
res
=
NETCON_init
(
&
lpwhr
->
netConnection
,
dwFlags
&
INTERNET_FLAG_SECURE
))
!=
ERROR_SUCCESS
)
{
...
...
@@ -2727,7 +2724,7 @@ HINTERNET WINAPI HttpOpenRequestW(HINTERNET hHttpSession,
TRACE
(
"
\t
accept type: %s
\n
"
,
debugstr_w
(
lpszAcceptTypes
[
i
]));
}
lpwhs
=
(
http_session_t
*
)
WININET_GetO
bject
(
hHttpSession
);
lpwhs
=
(
http_session_t
*
)
get_handle_o
bject
(
hHttpSession
);
if
(
NULL
==
lpwhs
||
lpwhs
->
hdr
.
htype
!=
WH_HHTTPSESSION
)
{
res
=
ERROR_INTERNET_INCORRECT_HANDLE_TYPE
;
...
...
@@ -3174,7 +3171,7 @@ BOOL WINAPI HttpQueryInfoW(HINTERNET hHttpRequest, DWORD dwInfoLevel,
TRACE
(
"
\n
"
);
}
lpwhr
=
(
http_request_t
*
)
WININET_GetO
bject
(
hHttpRequest
);
lpwhr
=
(
http_request_t
*
)
get_handle_o
bject
(
hHttpRequest
);
if
(
NULL
==
lpwhr
||
lpwhr
->
hdr
.
htype
!=
WH_HHTTPREQ
)
{
res
=
ERROR_INTERNET_INCORRECT_HANDLE_TYPE
;
...
...
@@ -4045,7 +4042,7 @@ BOOL WINAPI HttpEndRequestW(HINTERNET hRequest,
return
FALSE
;
}
lpwhr
=
(
http_request_t
*
)
WININET_GetO
bject
(
hRequest
);
lpwhr
=
(
http_request_t
*
)
get_handle_o
bject
(
hRequest
);
if
(
NULL
==
lpwhr
||
lpwhr
->
hdr
.
htype
!=
WH_HHTTPREQ
)
{
...
...
@@ -4160,7 +4157,7 @@ BOOL WINAPI HttpSendRequestExW(HINTERNET hRequest,
TRACE
(
"(%p, %p, %p, %08x, %08lx)
\n
"
,
hRequest
,
lpBuffersIn
,
lpBuffersOut
,
dwFlags
,
dwContext
);
lpwhr
=
(
http_request_t
*
)
WININET_GetO
bject
(
hRequest
);
lpwhr
=
(
http_request_t
*
)
get_handle_o
bject
(
hRequest
);
if
(
NULL
==
lpwhr
||
lpwhr
->
hdr
.
htype
!=
WH_HHTTPREQ
)
{
...
...
@@ -4259,7 +4256,7 @@ BOOL WINAPI HttpSendRequestW(HINTERNET hHttpRequest, LPCWSTR lpszHeaders,
TRACE
(
"%p, %s, %i, %p, %i)
\n
"
,
hHttpRequest
,
debugstr_wn
(
lpszHeaders
,
dwHeaderLength
),
dwHeaderLength
,
lpOptional
,
dwOptionalLength
);
lpwhr
=
(
http_request_t
*
)
WININET_GetO
bject
(
hHttpRequest
);
lpwhr
=
(
http_request_t
*
)
get_handle_o
bject
(
hHttpRequest
);
if
(
NULL
==
lpwhr
||
lpwhr
->
hdr
.
htype
!=
WH_HHTTPREQ
)
{
res
=
ERROR_INTERNET_INCORRECT_HANDLE_TYPE
;
...
...
@@ -4444,7 +4441,7 @@ DWORD HTTP_Connect(appinfo_t *hIC, LPCWSTR lpszServerName,
{
http_session_t
*
lpwhs
=
NULL
;
HINTERNET
handle
=
NULL
;
DWORD
res
=
ERROR_SUCCESS
;
DWORD
res
;
TRACE
(
"-->
\n
"
);
...
...
@@ -4473,11 +4470,10 @@ DWORD HTTP_Connect(appinfo_t *hIC, LPCWSTR lpszServerName,
lpwhs
->
lpAppInfo
=
hIC
;
list_add_head
(
&
hIC
->
hdr
.
children
,
&
lpwhs
->
hdr
.
entry
);
handle
=
WININET_AllocHandle
(
&
lpwhs
->
hdr
);
if
(
NULL
==
handle
)
res
=
alloc_handle
(
&
lpwhs
->
hdr
,
&
handle
);
if
(
res
!=
ERROR_SUCCESS
)
{
ERR
(
"Failed to alloc handle
\n
"
);
res
=
ERROR_OUTOFMEMORY
;
goto
lerror
;
}
...
...
dlls/wininet/internet.c
View file @
f165e25e
...
...
@@ -90,8 +90,6 @@ typedef struct
static
DWORD
g_dwTlsErrIndex
=
TLS_OUT_OF_INDEXES
;
HMODULE
WININET_hModule
;
#define HANDLE_CHUNK_SIZE 0x10
static
CRITICAL_SECTION
WININET_cs
;
static
CRITICAL_SECTION_DEBUG
WININET_cs_debug
=
{
...
...
@@ -101,9 +99,9 @@ static CRITICAL_SECTION_DEBUG WININET_cs_debug =
};
static
CRITICAL_SECTION
WININET_cs
=
{
&
WININET_cs_debug
,
-
1
,
0
,
0
,
0
,
0
};
static
object_header_t
**
WININET_Handles
;
static
UINT_PTR
WININET_dwNextH
andle
;
static
UINT_PTR
WININET_dwMaxHandles
;
static
object_header_t
**
handle_table
;
static
UINT_PTR
next_h
andle
;
static
UINT_PTR
handle_table_size
;
typedef
struct
{
...
...
@@ -119,48 +117,51 @@ static const WCHAR szInternetSettings[] =
static
const
WCHAR
szProxyServer
[]
=
{
'P'
,
'r'
,
'o'
,
'x'
,
'y'
,
'S'
,
'e'
,
'r'
,
'v'
,
'e'
,
'r'
,
0
};
static
const
WCHAR
szProxyEnable
[]
=
{
'P'
,
'r'
,
'o'
,
'x'
,
'y'
,
'E'
,
'n'
,
'a'
,
'b'
,
'l'
,
'e'
,
0
};
HINTERNET
WININET_AllocHandle
(
object_header_t
*
info
)
DWORD
alloc_handle
(
object_header_t
*
info
,
HINTERNET
*
ret
)
{
object_header_t
**
p
;
UINT_PTR
handle
=
0
,
num
;
DWORD
res
=
ERROR_SUCCESS
;
list_init
(
&
info
->
children
);
EnterCriticalSection
(
&
WININET_cs
);
if
(
!
WININET_dwMaxHandles
)
{
num
=
HANDLE_CHUNK_SIZE
;
p
=
HeapAlloc
(
GetProcessHeap
(),
HEAP_ZERO_MEMORY
,
sizeof
(
*
WININET_Handles
)
*
num
);
if
(
!
p
)
goto
end
;
WININET_Handles
=
p
;
WININET_dwMaxHandles
=
num
;
}
if
(
WININET_dwMaxHandles
==
WININET_dwNextHandle
)
{
num
=
WININET_dwMaxHandles
+
HANDLE_CHUNK_SIZE
;
p
=
HeapReAlloc
(
GetProcessHeap
(),
HEAP_ZERO_MEMORY
,
WININET_Handles
,
sizeof
(
*
WININET_Handles
)
*
num
);
if
(
!
p
)
goto
end
;
WININET_Handles
=
p
;
WININET_dwMaxHandles
=
num
;
if
(
!
handle_table_size
)
{
num
=
16
;
p
=
heap_alloc_zero
(
sizeof
(
handle_table
[
0
])
*
num
);
if
(
p
)
{
handle_table
=
p
;
handle_table_size
=
num
;
next_handle
=
1
;
}
else
{
res
=
ERROR_OUTOFMEMORY
;
}
}
else
if
(
next_handle
==
handle_table_size
)
{
num
=
handle_table_size
*
2
;
p
=
heap_realloc_zero
(
handle_table
,
sizeof
(
handle_table
[
0
])
*
num
);
if
(
p
)
{
handle_table
=
p
;
handle_table_size
=
num
;
}
else
{
res
=
ERROR_OUTOFMEMORY
;
}
}
handle
=
WININET_dwNextHandle
;
if
(
WININET_Handles
[
handle
]
)
ERR
(
"handle isn't free but should be
\n
"
);
WININET_Handles
[
handle
]
=
WININET_AddRef
(
info
);
if
(
res
==
ERROR_SUCCESS
)
{
handle
=
next_handle
;
if
(
handle_table
[
handle
])
ERR
(
"handle isn't free but should be
\n
"
);
handle_table
[
handle
]
=
WININET_AddRef
(
info
);
while
(
WININET_Handles
[
WININET_dwNextHandle
]
&&
(
WININET_dwNextHandle
<
WININET_dwMaxHandles
)
)
WININET_dwNextHandle
++
;
while
(
handle_table
[
next_handle
]
&&
next_handle
<
handle_table_size
)
next_handle
++
;
}
end:
LeaveCriticalSection
(
&
WININET_cs
);
return
info
->
hInternet
=
(
HINTERNET
)
(
handle
+
1
);
info
->
hInternet
=
*
ret
=
(
HINTERNET
)
handle
;
return
res
;
}
object_header_t
*
WININET_AddRef
(
object_header_t
*
info
)
...
...
@@ -170,16 +171,15 @@ object_header_t *WININET_AddRef( object_header_t *info )
return
info
;
}
object_header_t
*
WININET_GetO
bject
(
HINTERNET
hinternet
)
object_header_t
*
get_handle_o
bject
(
HINTERNET
hinternet
)
{
object_header_t
*
info
=
NULL
;
UINT_PTR
handle
=
(
UINT_PTR
)
hinternet
;
EnterCriticalSection
(
&
WININET_cs
);
if
(
(
handle
>
0
)
&&
(
handle
<=
WININET_dwMaxHandles
)
&&
WININET_Handles
[
handle
-
1
]
)
info
=
WININET_AddRef
(
WININET_Handles
[
handle
-
1
]
);
if
(
handle
>
0
&&
handle
<
handle_table_size
&&
handle_table
[
handle
])
info
=
WININET_AddRef
(
handle_table
[
handle
]);
LeaveCriticalSection
(
&
WININET_cs
);
...
...
@@ -215,23 +215,19 @@ BOOL WININET_Release( object_header_t *info )
return
TRUE
;
}
BOOL
WININET_FreeH
andle
(
HINTERNET
hinternet
)
static
void
invalidate_h
andle
(
HINTERNET
hinternet
)
{
BOOL
ret
=
FALSE
;
UINT_PTR
handle
=
(
UINT_PTR
)
hinternet
;
object_header_t
*
info
=
NULL
,
*
child
,
*
next
;
EnterCriticalSection
(
&
WININET_cs
);
if
(
(
handle
>
0
)
&&
(
handle
<=
WININET_dwMaxHandles
)
)
if
(
handle
&&
handle
<
handle_table_size
)
{
handle
--
;
if
(
WININET_Handles
[
handle
]
)
{
info
=
WININET_Handles
[
handle
];
if
(
handle_table
[
handle
])
{
info
=
handle_table
[
handle
];
TRACE
(
"destroying handle %ld for object %p
\n
"
,
handle
+
1
,
info
);
WININET_Handles
[
handle
]
=
NULL
;
ret
=
TRUE
;
handle_table
[
handle
]
=
NULL
;
}
}
...
...
@@ -247,19 +243,17 @@ BOOL WININET_FreeHandle( HINTERNET hinternet )
{
TRACE
(
"freeing child handle %ld for parent handle %ld
\n
"
,
(
UINT_PTR
)
child
->
hInternet
,
handle
+
1
);
WININET_FreeH
andle
(
child
->
hInternet
);
invalidate_h
andle
(
child
->
hInternet
);
}
WININET_Release
(
info
);
}
EnterCriticalSection
(
&
WININET_cs
);
if
(
WININET_dwNextHandle
>
handle
&&
!
WININET_Handles
[
handle
]
)
WININET_dwNextH
andle
=
handle
;
if
(
next_handle
>
handle
&&
!
handle_table
[
handle
]
)
next_h
andle
=
handle
;
LeaveCriticalSection
(
&
WININET_cs
);
return
ret
;
}
/***********************************************************************
...
...
@@ -843,6 +837,7 @@ HINTERNET WINAPI InternetOpenW(LPCWSTR lpszAgent, DWORD dwAccessType,
{
appinfo_t
*
lpwai
=
NULL
;
HINTERNET
handle
=
NULL
;
DWORD
res
;
if
(
TRACE_ON
(
wininet
))
{
#define FE(x) { x, #x }
...
...
@@ -887,11 +882,11 @@ HINTERNET WINAPI InternetOpenW(LPCWSTR lpszAgent, DWORD dwAccessType,
lpwai
->
lpszProxyUsername
=
NULL
;
lpwai
->
lpszProxyPassword
=
NULL
;
handle
=
WININET_AllocHandle
(
&
lpwai
->
hdr
);
if
(
!
handle
)
res
=
alloc_handle
(
&
lpwai
->
hdr
,
&
handle
);
if
(
res
!=
ERROR_SUCCESS
)
{
HeapFree
(
GetProcessHeap
(),
0
,
lpwai
);
INTERNET_SetLastError
(
ERROR_OUTOFMEMORY
);
INTERNET_SetLastError
(
res
);
goto
lend
;
}
...
...
@@ -1142,7 +1137,7 @@ HINTERNET WINAPI InternetConnectW(HINTERNET hInternet,
return
NULL
;
}
hIC
=
(
appinfo_t
*
)
WININET_GetO
bject
(
hInternet
);
hIC
=
(
appinfo_t
*
)
get_handle_o
bject
(
hInternet
);
if
(
(
hIC
==
NULL
)
||
(
hIC
->
hdr
.
htype
!=
WH_HINIT
)
)
{
res
=
ERROR_INVALID_HANDLE
;
...
...
@@ -1249,7 +1244,7 @@ BOOL WINAPI InternetFindNextFileW(HINTERNET hFind, LPVOID lpvFindData)
TRACE
(
"
\n
"
);
hdr
=
WININET_GetO
bject
(
hFind
);
hdr
=
get_handle_o
bject
(
hFind
);
if
(
!
hdr
)
{
WARN
(
"Invalid handle
\n
"
);
SetLastError
(
ERROR_INVALID_HANDLE
);
...
...
@@ -1286,7 +1281,7 @@ BOOL WINAPI InternetCloseHandle(HINTERNET hInternet)
TRACE
(
"%p
\n
"
,
hInternet
);
lpwh
=
WININET_GetO
bject
(
hInternet
);
lpwh
=
get_handle_o
bject
(
hInternet
);
if
(
NULL
==
lpwh
)
{
INTERNET_SetLastError
(
ERROR_INVALID_HANDLE
);
...
...
@@ -1294,7 +1289,7 @@ BOOL WINAPI InternetCloseHandle(HINTERNET hInternet)
}
WININET_Release
(
lpwh
);
WININET_FreeH
andle
(
hInternet
);
invalidate_h
andle
(
hInternet
);
return
TRUE
;
}
...
...
@@ -2023,7 +2018,7 @@ INTERNET_STATUS_CALLBACK WINAPI InternetSetStatusCallbackA(
TRACE
(
"%p
\n
"
,
hInternet
);
if
(
!
(
lpwh
=
WININET_GetO
bject
(
hInternet
)))
if
(
!
(
lpwh
=
get_handle_o
bject
(
hInternet
)))
return
INTERNET_INVALID_STATUS_CALLBACK
;
retVal
=
set_status_callback
(
lpwh
,
lpfnIntCB
,
FALSE
);
...
...
@@ -2051,7 +2046,7 @@ INTERNET_STATUS_CALLBACK WINAPI InternetSetStatusCallbackW(
TRACE
(
"%p
\n
"
,
hInternet
);
if
(
!
(
lpwh
=
WININET_GetO
bject
(
hInternet
)))
if
(
!
(
lpwh
=
get_handle_o
bject
(
hInternet
)))
return
INTERNET_INVALID_STATUS_CALLBACK
;
retVal
=
set_status_callback
(
lpwh
,
lpfnIntCB
,
TRUE
);
...
...
@@ -2088,7 +2083,7 @@ BOOL WINAPI InternetWriteFile(HINTERNET hFile, LPCVOID lpBuffer,
TRACE
(
"(%p %p %d %p)
\n
"
,
hFile
,
lpBuffer
,
dwNumOfBytesToWrite
,
lpdwNumOfBytesWritten
);
lpwh
=
WININET_GetO
bject
(
hFile
);
lpwh
=
get_handle_o
bject
(
hFile
);
if
(
!
lpwh
)
{
WARN
(
"Invalid handle
\n
"
);
SetLastError
(
ERROR_INVALID_HANDLE
);
...
...
@@ -2128,7 +2123,7 @@ BOOL WINAPI InternetReadFile(HINTERNET hFile, LPVOID lpBuffer,
TRACE
(
"%p %p %d %p
\n
"
,
hFile
,
lpBuffer
,
dwNumOfBytesToRead
,
pdwNumOfBytesRead
);
hdr
=
WININET_GetO
bject
(
hFile
);
hdr
=
get_handle_o
bject
(
hFile
);
if
(
!
hdr
)
{
INTERNET_SetLastError
(
ERROR_INVALID_HANDLE
);
return
FALSE
;
...
...
@@ -2182,7 +2177,7 @@ BOOL WINAPI InternetReadFileExA(HINTERNET hFile, LPINTERNET_BUFFERSA lpBuffersOu
TRACE
(
"(%p %p 0x%x 0x%lx)
\n
"
,
hFile
,
lpBuffersOut
,
dwFlags
,
dwContext
);
hdr
=
WININET_GetO
bject
(
hFile
);
hdr
=
get_handle_o
bject
(
hFile
);
if
(
!
hdr
)
{
INTERNET_SetLastError
(
ERROR_INVALID_HANDLE
);
return
FALSE
;
...
...
@@ -2214,7 +2209,7 @@ BOOL WINAPI InternetReadFileExW(HINTERNET hFile, LPINTERNET_BUFFERSW lpBuffer,
TRACE
(
"(%p %p 0x%x 0x%lx)
\n
"
,
hFile
,
lpBuffer
,
dwFlags
,
dwContext
);
hdr
=
WININET_GetO
bject
(
hFile
);
hdr
=
get_handle_o
bject
(
hFile
);
if
(
!
hdr
)
{
INTERNET_SetLastError
(
ERROR_INVALID_HANDLE
);
return
FALSE
;
...
...
@@ -2440,7 +2435,7 @@ BOOL WINAPI InternetQueryOptionW(HINTERNET hInternet, DWORD dwOption,
TRACE
(
"%p %d %p %p
\n
"
,
hInternet
,
dwOption
,
lpBuffer
,
lpdwBufferLength
);
if
(
hInternet
)
{
hdr
=
WININET_GetO
bject
(
hInternet
);
hdr
=
get_handle_o
bject
(
hInternet
);
if
(
hdr
)
{
res
=
hdr
->
vtbl
->
QueryOption
(
hdr
,
dwOption
,
lpBuffer
,
lpdwBufferLength
,
TRUE
);
WININET_Release
(
hdr
);
...
...
@@ -2473,7 +2468,7 @@ BOOL WINAPI InternetQueryOptionA(HINTERNET hInternet, DWORD dwOption,
TRACE
(
"%p %d %p %p
\n
"
,
hInternet
,
dwOption
,
lpBuffer
,
lpdwBufferLength
);
if
(
hInternet
)
{
hdr
=
WININET_GetO
bject
(
hInternet
);
hdr
=
get_handle_o
bject
(
hInternet
);
if
(
hdr
)
{
res
=
hdr
->
vtbl
->
QueryOption
(
hdr
,
dwOption
,
lpBuffer
,
lpdwBufferLength
,
FALSE
);
WININET_Release
(
hdr
);
...
...
@@ -2506,7 +2501,7 @@ BOOL WINAPI InternetSetOptionW(HINTERNET hInternet, DWORD dwOption,
TRACE
(
"(%p %d %p %d)
\n
"
,
hInternet
,
dwOption
,
lpBuffer
,
dwBufferLength
);
lpwhh
=
(
object_header_t
*
)
WININET_GetO
bject
(
hInternet
);
lpwhh
=
(
object_header_t
*
)
get_handle_o
bject
(
hInternet
);
if
(
lpwhh
&&
lpwhh
->
vtbl
->
SetOption
)
{
DWORD
res
;
...
...
@@ -2764,7 +2759,7 @@ BOOL WINAPI InternetSetOptionA(HINTERNET hInternet, DWORD dwOption,
{
object_header_t
*
lpwh
;
if
(
!
(
lpwh
=
WININET_GetO
bject
(
hInternet
)))
if
(
!
(
lpwh
=
get_handle_o
bject
(
hInternet
)))
{
INTERNET_SetLastError
(
ERROR_INTERNET_INCORRECT_HANDLE_TYPE
);
return
FALSE
;
...
...
@@ -3379,7 +3374,7 @@ HINTERNET WINAPI InternetOpenUrlW(HINTERNET hInternet, LPCWSTR lpszUrl,
goto
lend
;
}
hIC
=
(
appinfo_t
*
)
WININET_GetO
bject
(
hInternet
);
hIC
=
(
appinfo_t
*
)
get_handle_o
bject
(
hInternet
);
if
(
NULL
==
hIC
||
hIC
->
hdr
.
htype
!=
WH_HINIT
)
{
SetLastError
(
ERROR_INTERNET_INCORRECT_HANDLE_TYPE
);
goto
lend
;
...
...
@@ -3679,7 +3674,7 @@ BOOL WINAPI InternetQueryDataAvailable( HINTERNET hFile,
TRACE
(
"(%p %p %x %lx)
\n
"
,
hFile
,
lpdwNumberOfBytesAvailble
,
dwFlags
,
dwContext
);
hdr
=
WININET_GetO
bject
(
hFile
);
hdr
=
get_handle_o
bject
(
hFile
);
if
(
!
hdr
)
{
SetLastError
(
ERROR_INVALID_HANDLE
);
return
FALSE
;
...
...
dlls/wininet/internet.h
View file @
f165e25e
...
...
@@ -58,6 +58,31 @@ typedef struct
DWORD
security_flags
;
}
WININET_NETCONNECTION
;
static
inline
void
*
__WINE_ALLOC_SIZE
(
1
)
heap_alloc
(
size_t
len
)
{
return
HeapAlloc
(
GetProcessHeap
(),
0
,
len
);
}
static
inline
void
*
__WINE_ALLOC_SIZE
(
1
)
heap_alloc_zero
(
size_t
len
)
{
return
HeapAlloc
(
GetProcessHeap
(),
HEAP_ZERO_MEMORY
,
len
);
}
static
inline
void
*
__WINE_ALLOC_SIZE
(
2
)
heap_realloc
(
void
*
mem
,
size_t
len
)
{
return
HeapReAlloc
(
GetProcessHeap
(),
0
,
mem
,
len
);
}
static
inline
void
*
__WINE_ALLOC_SIZE
(
2
)
heap_realloc_zero
(
void
*
mem
,
size_t
len
)
{
return
HeapReAlloc
(
GetProcessHeap
(),
HEAP_ZERO_MEMORY
,
mem
,
len
);
}
static
inline
BOOL
heap_free
(
void
*
mem
)
{
return
HeapFree
(
GetProcessHeap
(),
0
,
mem
);
}
static
inline
LPWSTR
heap_strdupW
(
LPCWSTR
str
)
{
LPWSTR
ret
=
NULL
;
...
...
@@ -409,11 +434,10 @@ typedef struct WORKREQ
}
WORKREQUEST
,
*
LPWORKREQUEST
;
HINTERNET
WININET_AllocHandle
(
object_header_t
*
info
);
object_header_t
*
WININET_GetO
bject
(
HINTERNET
hinternet
);
DWORD
alloc_handle
(
object_header_t
*
,
HINTERNET
*
);
object_header_t
*
get_handle_o
bject
(
HINTERNET
hinternet
);
object_header_t
*
WININET_AddRef
(
object_header_t
*
info
);
BOOL
WININET_Release
(
object_header_t
*
info
);
BOOL
WININET_FreeHandle
(
HINTERNET
hinternet
);
DWORD
INET_QueryOption
(
object_header_t
*
,
DWORD
,
void
*
,
DWORD
*
,
BOOL
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment