Commit 0e44f63c authored by Alexandre Julliard's avatar Alexandre Julliard

Replaced HEAP_strdup* and lstrcpynAtoW calls by exported functions.

parent ab687979
......@@ -10,8 +10,8 @@
#include "winbase.h"
#include "winnt.h"
#include "winreg.h"
#include "winnls.h"
#include "wine/unicode.h"
#include "heap.h"
#include "dplay.h"
#include "debugtools.h"
......@@ -3510,7 +3510,7 @@ static HRESULT WINAPI DirectPlay3AImpl_EnumConnections
GUID serviceProviderGUID;
DWORD returnTypeGUID, sizeOfReturnBuffer = 50;
char returnBuffer[51];
LPWSTR lpWGUIDString;
WCHAR buff[51];
DPNAME dpName;
HRESULT hr;
......@@ -3537,9 +3537,8 @@ static HRESULT WINAPI DirectPlay3AImpl_EnumConnections
}
/* FIXME: Check return types to ensure we're interpreting data right */
lpWGUIDString = HEAP_strdupAtoW( GetProcessHeap(), 0, returnBuffer );
CLSIDFromString( (LPCOLESTR)lpWGUIDString, &serviceProviderGUID );
HeapFree( GetProcessHeap(), 0, lpWGUIDString );
MultiByteToWideChar( CP_ACP, 0, returnBuffer, -1, buff, sizeof(buff)/sizeof(WCHAR) );
CLSIDFromString( (LPCOLESTR)buff, &serviceProviderGUID );
/* FIXME: Have I got a memory leak on the serviceProviderGUID? */
/* Fill in the DPNAME struct for the service provider */
......@@ -3616,7 +3615,7 @@ static HRESULT WINAPI DirectPlay3AImpl_EnumConnections
GUID serviceProviderGUID;
DWORD returnTypeGUID, sizeOfReturnBuffer = 50;
char returnBuffer[51];
LPWSTR lpWGUIDString;
WCHAR buff[51];
DPNAME dpName;
HRESULT hr;
......@@ -3643,9 +3642,8 @@ static HRESULT WINAPI DirectPlay3AImpl_EnumConnections
}
/* FIXME: Check return types to ensure we're interpreting data right */
lpWGUIDString = HEAP_strdupAtoW( GetProcessHeap(), 0, returnBuffer );
CLSIDFromString( (LPCOLESTR)lpWGUIDString, &serviceProviderGUID );
HeapFree( GetProcessHeap(), 0, lpWGUIDString );
MultiByteToWideChar( CP_ACP, 0, returnBuffer, -1, buff, sizeof(buff)/sizeof(WCHAR) );
CLSIDFromString( (LPCOLESTR)buff, &serviceProviderGUID );
/* FIXME: Have I got a memory leak on the serviceProviderGUID? */
/* Fill in the DPNAME struct for the service provider */
......@@ -3862,8 +3860,8 @@ static HMODULE DP_LoadSP( LPCGUID lpcGuid, LPSPINITDATA lpSpData, LPBOOL lpbIsDp
GUID serviceProviderGUID;
DWORD returnType, sizeOfReturnBuffer = 255;
char returnBuffer[256];
LPWSTR lpWGUIDString;
DWORD dwTemp;
WCHAR buff[51];
DWORD dwTemp, len;
TRACE(" this time through: %s\n", subKeyName );
......@@ -3884,9 +3882,8 @@ static HMODULE DP_LoadSP( LPCGUID lpcGuid, LPSPINITDATA lpSpData, LPBOOL lpbIsDp
}
/* FIXME: Check return types to ensure we're interpreting data right */
lpWGUIDString = HEAP_strdupAtoW( GetProcessHeap(), 0, returnBuffer );
CLSIDFromString( (LPCOLESTR)lpWGUIDString, &serviceProviderGUID );
HeapFree( GetProcessHeap(), 0, lpWGUIDString );
MultiByteToWideChar( CP_ACP, 0, returnBuffer, -1, buff, sizeof(buff)/sizeof(WCHAR) );
CLSIDFromString( (LPCOLESTR)buff, &serviceProviderGUID );
/* FIXME: Have I got a memory leak on the serviceProviderGUID? */
/* Determine if this is the Service Provider that the user asked for */
......@@ -3896,7 +3893,9 @@ static HMODULE DP_LoadSP( LPCGUID lpcGuid, LPSPINITDATA lpSpData, LPBOOL lpbIsDp
}
/* Save the name of the SP or LP */
lpSpData->lpszName = HEAP_strdupAtoW( GetProcessHeap(), 0, subKeyName );
len = MultiByteToWideChar( CP_ACP, 0, subKeyName, -1, NULL, 0 );
lpSpData->lpszName = HeapAlloc( GetProcessHeap(), 0, len*sizeof(WCHAR) );
MultiByteToWideChar( CP_ACP, 0, subKeyName, -1, lpSpData->lpszName, len );
sizeOfReturnBuffer = 255;
......@@ -4990,8 +4989,8 @@ HRESULT WINAPI DirectPlayEnumerateA( LPDPENUMDPCALLBACKA lpEnumCallback,
GUID serviceProviderGUID;
DWORD returnTypeGUID, returnTypeReserved, sizeOfReturnBuffer = 50;
char returnBuffer[51];
WCHAR buff[51];
DWORD majVersionNum , minVersionNum = 0;
LPWSTR lpWGUIDString;
TRACE(" this time through: %s\n", subKeyName );
......@@ -5015,9 +5014,8 @@ HRESULT WINAPI DirectPlayEnumerateA( LPDPENUMDPCALLBACKA lpEnumCallback,
}
/* FIXME: Check return types to ensure we're interpreting data right */
lpWGUIDString = HEAP_strdupAtoW( GetProcessHeap(), 0, returnBuffer );
CLSIDFromString( (LPCOLESTR)lpWGUIDString, &serviceProviderGUID );
HeapFree( GetProcessHeap(), 0, lpWGUIDString );
MultiByteToWideChar( CP_ACP, 0, returnBuffer, -1, buff, sizeof(buff)/sizeof(WCHAR) );
CLSIDFromString( (LPCOLESTR)buff, &serviceProviderGUID );
/* FIXME: Need to know which of dwReserved1 and dwReserved2 are maj and min */
......
......@@ -1055,15 +1055,15 @@ BOOL DPLAYX_CopyIntoSessionDesc2A( LPDPSESSIONDESC2 lpSessionDest,
if( lpSessionSrc->sess.lpszSessionNameA )
{
lpSessionDest->sess.lpszSessionNameA =
HEAP_strdupA( GetProcessHeap(),
HEAP_ZERO_MEMORY, lpSessionSrc->sess.lpszSessionNameA );
if ((lpSessionDest->sess.lpszSessionNameA = HeapAlloc( GetProcessHeap(), 0,
strlen(lpSessionSrc->sess.lpszSessionNameA)+1 )))
strcpy( lpSessionDest->sess.lpszSessionNameA, lpSessionSrc->sess.lpszSessionNameA );
}
if( lpSessionSrc->pass.lpszPasswordA )
{
lpSessionDest->pass.lpszPasswordA =
HEAP_strdupA( GetProcessHeap(),
HEAP_ZERO_MEMORY, lpSessionSrc->pass.lpszPasswordA );
if ((lpSessionDest->pass.lpszPasswordA = HeapAlloc( GetProcessHeap(), 0,
strlen(lpSessionSrc->pass.lpszPasswordA)+1 )))
strcpy( lpSessionDest->pass.lpszPasswordA, lpSessionSrc->pass.lpszPasswordA );
}
return TRUE;
......
......@@ -8,7 +8,7 @@
#include "winerror.h"
#include "winnt.h"
#include "winreg.h"
#include "heap.h"
#include "winnls.h"
#include "debugtools.h"
#include "dplobby.h"
......@@ -17,7 +17,7 @@
#include "dplayx_messages.h"
#include "dplayx_queue.h"
DEFAULT_DEBUG_CHANNEL(dplay)
DEFAULT_DEBUG_CHANNEL(dplay);
/*****************************************************************************
* Predeclare the interface implementation structures
......@@ -755,7 +755,7 @@ static HRESULT WINAPI IDirectPlayLobbyAImpl_EnumAddressTypes
DWORD returnTypeGUID, sizeOfReturnBuffer = 50;
char atSubKey[51];
char returnBuffer[51];
LPWSTR lpWGUIDString;
WCHAR buff[51];
DWORD dwAtIndex;
LPSTR atKey = "Address Types";
LPSTR guidDataSubKey = "Guid";
......@@ -781,9 +781,8 @@ static HRESULT WINAPI IDirectPlayLobbyAImpl_EnumAddressTypes
}
/* FIXME: Check return types to ensure we're interpreting data right */
lpWGUIDString = HEAP_strdupAtoW( GetProcessHeap(), 0, returnBuffer );
CLSIDFromString( (LPCOLESTR)lpWGUIDString, &serviceProviderGUID );
HeapFree( GetProcessHeap(), 0, lpWGUIDString );
MultiByteToWideChar( CP_ACP, 0, returnBuffer, -1, buff, sizeof(buff)/sizeof(WCHAR) );
CLSIDFromString( (LPCOLESTR)buff, &serviceProviderGUID );
/* FIXME: Have I got a memory leak on the serviceProviderGUID? */
/* Determine if this is the Service Provider that the user asked for */
......@@ -809,9 +808,8 @@ static HRESULT WINAPI IDirectPlayLobbyAImpl_EnumAddressTypes
TRACE( "Found Address Type GUID %s\n", atSubKey );
/* FIXME: Check return types to ensure we're interpreting data right */
lpWGUIDString = HEAP_strdupAtoW( GetProcessHeap(), 0, atSubKey );
CLSIDFromString( (LPCOLESTR)lpWGUIDString, &serviceProviderGUID );
HeapFree( GetProcessHeap(), 0, lpWGUIDString );
MultiByteToWideChar( CP_ACP, 0, atSubKey, -1, buff, sizeof(buff)/sizeof(WCHAR) );
CLSIDFromString( (LPCOLESTR)buff, &serviceProviderGUID );
/* FIXME: Have I got a memory leak on the serviceProviderGUID? */
/* The enumeration will return FALSE if we are not to continue */
......@@ -906,7 +904,7 @@ static HRESULT WINAPI IDirectPlayLobbyAImpl_EnumLocalApplications
GUID serviceProviderGUID;
DWORD returnTypeGUID, sizeOfReturnBuffer = 50;
char returnBuffer[51];
LPWSTR lpWGUIDString;
WCHAR buff[51];
DPLAPPINFO dplAppInfo;
TRACE(" this time through: %s\n", subKeyName );
......@@ -928,9 +926,8 @@ static HRESULT WINAPI IDirectPlayLobbyAImpl_EnumLocalApplications
}
/* FIXME: Check return types to ensure we're interpreting data right */
lpWGUIDString = HEAP_strdupAtoW( GetProcessHeap(), 0, returnBuffer );
CLSIDFromString( (LPCOLESTR)lpWGUIDString, &serviceProviderGUID );
HeapFree( GetProcessHeap(), 0, lpWGUIDString );
MultiByteToWideChar( CP_ACP, 0, returnBuffer, -1, buff, sizeof(buff)/sizeof(WCHAR) );
CLSIDFromString( (LPCOLESTR)buff, &serviceProviderGUID );
/* FIXME: Have I got a memory leak on the serviceProviderGUID? */
dplAppInfo.dwSize = sizeof( dplAppInfo );
......@@ -1084,7 +1081,8 @@ static BOOL CALLBACK RunApplicationA_EnumLocalApplications
}
else
{
lpData->lpszCommandLine = HEAP_strdupA( GetProcessHeap(), HEAP_ZERO_MEMORY, returnBuffer );
if ((lpData->lpszCommandLine = HeapAlloc( GetProcessHeap(), 0, strlen(returnBuffer)+1 )))
strcpy( lpData->lpszCommandLine, returnBuffer );
}
sizeOfReturnBuffer = 200;
......@@ -1097,7 +1095,8 @@ static BOOL CALLBACK RunApplicationA_EnumLocalApplications
}
else
{
lpData->lpszCurrentDirectory = HEAP_strdupA( GetProcessHeap(), HEAP_ZERO_MEMORY, returnBuffer );
if ((lpData->lpszCurrentDirectory = HeapAlloc( GetProcessHeap(), 0, strlen(returnBuffer)+1 )))
strcpy( lpData->lpszCurrentDirectory, returnBuffer );
}
sizeOfReturnBuffer = 200;
......@@ -1110,7 +1109,8 @@ static BOOL CALLBACK RunApplicationA_EnumLocalApplications
}
else
{
lpData->lpszFileName = HEAP_strdupA( GetProcessHeap(), HEAP_ZERO_MEMORY, returnBuffer );
if ((lpData->lpszFileName = HeapAlloc( GetProcessHeap(), 0, strlen(returnBuffer)+1 )))
strcpy( lpData->lpszFileName, returnBuffer );
}
sizeOfReturnBuffer = 200;
......@@ -1123,7 +1123,8 @@ static BOOL CALLBACK RunApplicationA_EnumLocalApplications
}
else
{
lpData->lpszPath = HEAP_strdupA( GetProcessHeap(), HEAP_ZERO_MEMORY, returnBuffer );
if ((lpData->lpszPath = HeapAlloc( GetProcessHeap(), 0, strlen(returnBuffer)+1 )))
strcpy( lpData->lpszPath, returnBuffer );
}
return FALSE; /* No need to keep going as we found what we wanted */
......@@ -1233,13 +1234,14 @@ static HRESULT WINAPI IDirectPlayLobbyAImpl_RunApplication
strcat( temp, enumData.lpszFileName );
HeapFree( GetProcessHeap(), 0, enumData.lpszPath );
HeapFree( GetProcessHeap(), 0, enumData.lpszFileName );
appName = HEAP_strdupA( GetProcessHeap(), HEAP_ZERO_MEMORY, temp );
if ((appName = HeapAlloc( GetProcessHeap(), 0, strlen(temp)+1 ))) strcpy( appName, temp );
/* Now the command line */
strcat( temp, " " );
strcat( temp, enumData.lpszCommandLine );
HeapFree( GetProcessHeap(), 0, enumData.lpszCommandLine );
enumData.lpszCommandLine = HEAP_strdupA( GetProcessHeap(), HEAP_ZERO_MEMORY, temp );
if ((enumData.lpszCommandLine = HeapAlloc( GetProcessHeap(), 0, strlen(temp)+1 )))
strcpy( enumData.lpszCommandLine, temp );
ZeroMemory( &startupInfo, sizeof( startupInfo ) );
startupInfo.cb = sizeof( startupInfo );
......
......@@ -9,8 +9,9 @@
/* NOTE: Methods with the NS_ prefix are name server methods */
#include "winbase.h"
#include "winnls.h"
#include "wine/unicode.h"
#include "debugtools.h"
#include "heap.h"
#include "mmsystem.h"
#include "dplayx_global.h"
......@@ -69,6 +70,7 @@ void NS_SetRemoteComputerAsNameServer( LPVOID lpNSAddrHdr,
LPDPMSG_ENUMSESSIONSREPLY lpMsg,
LPVOID lpNSInfo )
{
DWORD len;
lpNSCache lpCache = (lpNSCache)lpNSInfo;
lpNSCacheData lpCacheNode;
......@@ -115,9 +117,10 @@ void NS_SetRemoteComputerAsNameServer( LPVOID lpNSAddrHdr,
}
CopyMemory( lpCacheNode->data, &lpMsg->sd, sizeof( *lpCacheNode->data ) );
lpCacheNode->data->sess.lpszSessionNameA = HEAP_strdupWtoA( GetProcessHeap(),
HEAP_ZERO_MEMORY,
(LPWSTR)(lpMsg+1) );
len = WideCharToMultiByte( CP_ACP, 0, (LPWSTR)(lpMsg+1), -1, NULL, 0, NULL, NULL );
if ((lpCacheNode->data->sess.lpszSessionNameA = HeapAlloc( GetProcessHeap(), 0, len )))
WideCharToMultiByte( CP_ACP, 0, (LPWSTR)(lpMsg+1), -1,
lpCacheNode->data->sess.lpszSessionNameA, len, NULL, NULL );
lpCacheNode->dwTime = timeGetTime();
......@@ -331,14 +334,17 @@ void NS_ReplyToEnumSessionsRequest( LPVOID lpMsg,
LPDPMSG_ENUMSESSIONSREPLY rmsg;
DWORD dwVariableSize;
DWORD dwVariableLen;
LPWSTR string;
/* LPDPMSG_ENUMSESSIONSREQUEST msg = (LPDPMSG_ENUMSESSIONSREQUEST)lpMsg; */
BOOL bAnsi = TRUE; /* FIXME: This needs to be in the DPLAY interface */
FIXME( ": few fixed + need to check request for response\n" );
dwVariableLen = bAnsi ? lstrlenA( lpDP->dp2->lpSessionDesc->sess.lpszSessionNameA ) + 1
: lstrlenW( lpDP->dp2->lpSessionDesc->sess.lpszSessionName ) + 1;
if (bAnsi)
dwVariableLen = MultiByteToWideChar( CP_ACP, 0,
lpDP->dp2->lpSessionDesc->sess.lpszSessionNameA,
-1, NULL, 0 );
else
dwVariableLen = strlenW( lpDP->dp2->lpSessionDesc->sess.lpszSessionName ) + 1;
dwVariableSize = dwVariableLen * sizeof( WCHAR );
......@@ -358,16 +364,8 @@ void NS_ReplyToEnumSessionsRequest( LPVOID lpMsg,
sizeof( lpDP->dp2->lpSessionDesc->dwSize ) );
rmsg->dwUnknown = 0x0000005c;
if( bAnsi )
{
string = HEAP_strdupAtoW( GetProcessHeap(), 0,
lpDP->dp2->lpSessionDesc->sess.lpszSessionNameA );
/* FIXME: Memory leak */
}
MultiByteToWideChar( CP_ACP, 0, lpDP->dp2->lpSessionDesc->sess.lpszSessionNameA, -1,
(LPWSTR)(rmsg+1), dwVariableLen );
else
{
string = lpDP->dp2->lpSessionDesc->sess.lpszSessionName;
}
lstrcpyW( (LPWSTR)(rmsg+1), string );
strcpyW( (LPWSTR)(rmsg+1), lpDP->dp2->lpSessionDesc->sess.lpszSessionName );
}
......@@ -623,12 +623,12 @@ debug_channels (shell)
@ stub StrChrIA
@ stub StrChrIW
@ stdcall StrChrW (wstr long) StrChrW
@ stdcall StrCmpIW (wstr wstr) lstrcmpiW
@ forward StrCmpIW kernel32.lstrcmpiW
@ stdcall StrCmpNA (str str long) StrCmpNA
@ stdcall StrCmpNIA (str str long) StrCmpNIA
@ stdcall StrCmpNIW (wstr wstr long) StrCmpNIW
@ stdcall StrCmpNW (wstr wstr long) StrCmpNW
@ stdcall StrCmpW (wstr wstr) lstrcmpW
@ forward StrCmpW kernel32.lstrcmpW
@ stdcall StrCpyNW (ptr wstr long) lstrcpynW
@ stdcall StrCpyW (ptr wstr) StrCpyW
@ stdcall StrDupA (str) StrDupA
......
......@@ -12,7 +12,6 @@
#include "shlobj.h"
#include "wine/unicode.h"
#include "wine/winestring.h"
#include "heap.h"
#include "debugtools.h"
DEFAULT_DEBUG_CHANNEL(shell);
......@@ -164,14 +163,12 @@ int WINAPI StrToIntA(LPCSTR lpSrc)
*/
int WINAPI StrToIntW(LPCWSTR lpSrc)
{
int ret;
LPSTR lpStr = HEAP_strdupWtoA(GetProcessHeap(),0,lpSrc);
char buffer[32];
TRACE("%s\n", debugstr_w(lpSrc));
ret = atol(lpStr);
HeapFree(GetProcessHeap(),0,lpStr);
return ret;
TRACE("%s\n", debugstr_w(lpSrc));
WideCharToMultiByte( CP_ACP, 0, lpSrc, -1, buffer, sizeof(buffer), NULL, NULL );
buffer[sizeof(buffer)-1] = 0;
return atol(buffer);
}
/*************************************************************************
......@@ -385,13 +382,16 @@ HRESULT WINAPI StrRetToBufW (LPSTRRET src, const ITEMIDLIST *pidl, LPWSTR dest,
break;
case STRRET_CSTRA:
lstrcpynAtoW((LPWSTR)dest, src->u.cStr, len);
if (!MultiByteToWideChar( CP_ACP, 0, src->u.cStr, -1, dest, len ) && len)
dest[len-1] = 0;
break;
case STRRET_OFFSETA:
if (pidl)
{
lstrcpynAtoW((LPWSTR)dest, ((LPCSTR)&pidl->mkid)+src->u.uOffset, len);
if (!MultiByteToWideChar( CP_ACP, 0, ((LPCSTR)&pidl->mkid)+src->u.uOffset, -1,
dest, len ) && len)
dest[len-1] = 0;
}
break;
......@@ -445,7 +445,8 @@ LPWSTR WINAPI StrFormatByteSizeW ( DWORD dw, LPWSTR pszBuf, UINT cchBuf )
else
{ sprintf (buf,"%3.1f GB", (FLOAT)dw/1073741824L);
}
lstrcpynAtoW (pszBuf, buf, cchBuf);
if (!MultiByteToWideChar( CP_ACP, 0, buf, -1, pszBuf, cchBuf ) && cchBuf)
pszBuf[cchBuf-1] = 0;
return pszBuf;
}
......
......@@ -15,7 +15,6 @@
#include "wine/winuser16.h"
#include "wine/unicode.h"
#include "winerror.h"
#include "heap.h"
#include "debugtools.h"
DEFAULT_DEBUG_CHANNEL(ver);
......@@ -313,8 +312,10 @@ DWORD WINAPI GetFileVersionInfoSizeA( LPCSTR filename, LPDWORD handle )
*/
DWORD WINAPI GetFileVersionInfoSizeW( LPCWSTR filename, LPDWORD handle )
{
LPSTR fn = HEAP_strdupWtoA( GetProcessHeap(), 0, filename );
DWORD ret = GetFileVersionInfoSizeA( fn, handle );
DWORD ret, len = WideCharToMultiByte( CP_ACP, 0, filename, -1, NULL, 0, NULL, NULL );
LPSTR fn = HeapAlloc( GetProcessHeap(), 0, len );
WideCharToMultiByte( CP_ACP, 0, filename, -1, fn, len, NULL, NULL );
ret = GetFileVersionInfoSizeA( fn, handle );
HeapFree( GetProcessHeap(), 0, fn );
return ret;
}
......@@ -351,11 +352,14 @@ DWORD WINAPI GetFileVersionInfoA( LPCSTR filename, DWORD handle,
DWORD WINAPI GetFileVersionInfoW( LPCWSTR filename, DWORD handle,
DWORD datasize, LPVOID data )
{
LPSTR fn = HEAP_strdupWtoA( GetProcessHeap(), 0, filename );
DWORD len = WideCharToMultiByte( CP_ACP, 0, filename, -1, NULL, 0, NULL, NULL );
LPSTR fn = HeapAlloc( GetProcessHeap(), 0, len );
DWORD retv = TRUE;
WideCharToMultiByte( CP_ACP, 0, filename, -1, fn, len, NULL, NULL );
TRACE("(%s,%ld,size=%ld,data=%p)\n",
debugstr_a(fn), handle, datasize, data );
debugstr_w(filename), handle, datasize, data );
if ( !GetFileResource16( fn, MAKEINTRESOURCEA(VS_FILE_INFO),
MAKEINTRESOURCEA(VS_VERSION_INFO),
......
......@@ -11,9 +11,10 @@
#include <sys/types.h>
#include <unistd.h>
#include "winbase.h"
#include "winnls.h"
#include "wine/unicode.h"
#include "heap.h"
#include "neexe.h"
#include "module.h"
#include "winver.h"
......@@ -77,6 +78,7 @@ static const IMAGE_RESOURCE_DIRECTORY *find_entry_by_name( const IMAGE_RESOURCE_
{
const IMAGE_RESOURCE_DIRECTORY *ret = NULL;
LPWSTR nameW;
DWORD namelen;
if (!HIWORD(name)) return find_entry_by_id( dir, LOWORD(name), root );
if (name[0] == '#')
......@@ -84,12 +86,15 @@ static const IMAGE_RESOURCE_DIRECTORY *find_entry_by_name( const IMAGE_RESOURCE_
return find_entry_by_id( dir, atoi(name+1), root );
}
if ((nameW = HEAP_strdupAtoW( GetProcessHeap(), 0, name )))
namelen = MultiByteToWideChar( CP_ACP, 0, name, -1, NULL, 0 );
if ((nameW = HeapAlloc( GetProcessHeap(), 0, namelen * sizeof(WCHAR) )))
{
const IMAGE_RESOURCE_DIRECTORY_ENTRY *entry;
const IMAGE_RESOURCE_DIR_STRING_U *str;
int min, max, res, pos, namelen = strlenW(nameW);
int min, max, res, pos;
MultiByteToWideChar( CP_ACP, 0, name, -1, nameW, namelen );
namelen--; /* remove terminating null */
entry = (const IMAGE_RESOURCE_DIRECTORY_ENTRY *)(dir + 1);
min = 0;
max = dir->NumberOfNamedEntries - 1;
......@@ -154,6 +159,7 @@ static BOOL find_ne_resource( HFILE lzfd, LPCSTR typeid, LPCSTR resid,
DWORD nehdoffset;
LPBYTE resTab;
DWORD resTabSize;
int count;
/* Read in NE header */
nehdoffset = LZSeek( lzfd, 0, SEEK_CUR );
......@@ -179,21 +185,59 @@ static BOOL find_ne_resource( HFILE lzfd, LPCSTR typeid, LPCSTR resid,
/* Find resource */
typeInfo = (NE_TYPEINFO *)(resTab + 2);
typeInfo = NE_FindTypeSection( resTab, typeInfo, typeid );
if ( !typeInfo )
if (HIWORD(typeid) != 0) /* named type */
{
TRACE("No typeid entry found for %p\n", typeid );
HeapFree( GetProcessHeap(), 0, resTab );
return FALSE;
BYTE len = strlen( typeid );
while (typeInfo->type_id)
{
if (!(typeInfo->type_id & 0x8000))
{
BYTE *p = resTab + typeInfo->type_id;
if ((*p == len) && !strncasecmp( p+1, typeid, len )) goto found_type;
}
typeInfo = (NE_TYPEINFO *)((char *)(typeInfo + 1) +
typeInfo->count * sizeof(NE_NAMEINFO));
}
}
nameInfo = NE_FindResourceFromType( resTab, typeInfo, resid );
if ( !nameInfo )
else /* numeric type id */
{
TRACE("No resid entry found for %p\n", typeid );
HeapFree( GetProcessHeap(), 0, resTab );
return FALSE;
WORD id = LOWORD(typeid) | 0x8000;
while (typeInfo->type_id)
{
if (typeInfo->type_id == id) goto found_type;
typeInfo = (NE_TYPEINFO *)((char *)(typeInfo + 1) +
typeInfo->count * sizeof(NE_NAMEINFO));
}
}
TRACE("No typeid entry found for %p\n", typeid );
HeapFree( GetProcessHeap(), 0, resTab );
return FALSE;
found_type:
nameInfo = (NE_NAMEINFO *)(typeInfo + 1);
if (HIWORD(resid) != 0) /* named resource */
{
BYTE len = strlen( resid );
for (count = typeInfo->count; count > 0; count--, nameInfo++)
{
BYTE *p = resTab + nameInfo->id;
if (nameInfo->id & 0x8000) continue;
if ((*p == len) && !strncasecmp( p+1, resid, len )) goto found_name;
}
}
else /* numeric resource id */
{
WORD id = LOWORD(resid) | 0x8000;
for (count = typeInfo->count; count > 0; count--, nameInfo++)
if (nameInfo->id == id) goto found_name;
}
TRACE("No resid entry found for %p\n", typeid );
HeapFree( GetProcessHeap(), 0, resTab );
return FALSE;
found_name:
/* Return resource data */
if ( resLen ) *resLen = nameInfo->length << *(WORD *)resTab;
if ( resOff ) *resOff = nameInfo->offset << *(WORD *)resTab;
......
......@@ -110,6 +110,13 @@ HINTERNET FTP_ReceiveFileList(LPWININETFTPSESSIONA lpwfs, INT nSocket,
LPWIN32_FIND_DATAA lpFindFileData, DWORD dwContext);
DWORD FTP_SetResponseError(DWORD dwResponse);
inline static LPSTR FTP_strdup( LPCSTR str )
{
LPSTR ret = HeapAlloc( GetProcessHeap(), 0, strlen(str) + 1 );
if (ret) strcpy( ret, str );
return ret;
}
/***********************************************************************
* FtpPutFileA (WININET.43)
*
......@@ -139,8 +146,8 @@ BOOL WINAPI FtpPutFileA(HINTERNET hConnect, LPCSTR lpszLocalFile,
workRequest.asyncall = FTPPUTFILEA;
workRequest.HFTPSESSION = (DWORD)hConnect;
workRequest.LPSZLOCALFILE = (DWORD)HEAP_strdupA(GetProcessHeap(),0,lpszLocalFile);
workRequest.LPSZNEWREMOTEFILE = (DWORD)HEAP_strdupA(GetProcessHeap(),0,lpszNewRemoteFile);
workRequest.LPSZLOCALFILE = (DWORD)FTP_strdup(lpszLocalFile);
workRequest.LPSZNEWREMOTEFILE = (DWORD)FTP_strdup(lpszNewRemoteFile);
workRequest.DWFLAGS = dwFlags;
workRequest.DWCONTEXT = dwContext;
......@@ -263,7 +270,7 @@ BOOL WINAPI FtpSetCurrentDirectoryA(HINTERNET hConnect, LPCSTR lpszDirectory)
workRequest.asyncall = FTPSETCURRENTDIRECTORYA;
workRequest.HFTPSESSION = (DWORD)hConnect;
workRequest.LPSZDIRECTORY = (DWORD)HEAP_strdupA(GetProcessHeap(),0,lpszDirectory);
workRequest.LPSZDIRECTORY = (DWORD)FTP_strdup(lpszDirectory);
return INTERNET_AsyncCall(&workRequest);
}
......@@ -360,7 +367,7 @@ BOOL WINAPI FtpCreateDirectoryA(HINTERNET hConnect, LPCSTR lpszDirectory)
workRequest.asyncall = FTPCREATEDIRECTORYA;
workRequest.HFTPSESSION = (DWORD)hConnect;
workRequest.LPSZDIRECTORY = (DWORD)HEAP_strdupA(GetProcessHeap(),0,lpszDirectory);
workRequest.LPSZDIRECTORY = (DWORD)FTP_strdup(lpszDirectory);
return INTERNET_AsyncCall(&workRequest);
}
......@@ -456,7 +463,7 @@ INTERNETAPI HINTERNET WINAPI FtpFindFirstFileA(HINTERNET hConnect,
workRequest.asyncall = FTPFINDFIRSTFILEA;
workRequest.HFTPSESSION = (DWORD)hConnect;
workRequest.LPSZSEARCHFILE = (DWORD)HEAP_strdupA(GetProcessHeap(),0,lpszSearchFile);
workRequest.LPSZSEARCHFILE = (DWORD)FTP_strdup(lpszSearchFile);
workRequest.LPFINDFILEDATA = (DWORD)lpFindFileData;
workRequest.DWFLAGS = dwFlags;
workRequest.DWCONTEXT= dwContext;
......@@ -719,7 +726,7 @@ INTERNETAPI HINTERNET WINAPI FtpOpenFileA(HINTERNET hFtpSession,
workRequest.asyncall = FTPOPENFILEA;
workRequest.HFTPSESSION = (DWORD)hFtpSession;
workRequest.LPSZFILENAME = (DWORD)HEAP_strdupA(GetProcessHeap(),0,lpszFileName);
workRequest.LPSZFILENAME = (DWORD)FTP_strdup(lpszFileName);
workRequest.FDWACCESS = fdwAccess;
workRequest.DWFLAGS = dwFlags;
workRequest.DWCONTEXT = dwContext;
......@@ -840,8 +847,8 @@ BOOL WINAPI FtpGetFileA(HINTERNET hInternet, LPCSTR lpszRemoteFile, LPCSTR lpszN
workRequest.asyncall = FTPGETFILEA;
workRequest.HFTPSESSION = (DWORD)hInternet;
workRequest.LPSZREMOTEFILE = (DWORD)HEAP_strdupA(GetProcessHeap(),0,lpszRemoteFile);
workRequest.LPSZNEWFILE = (DWORD)HEAP_strdupA(GetProcessHeap(),0,lpszNewFile);
workRequest.LPSZREMOTEFILE = (DWORD)FTP_strdup(lpszRemoteFile);
workRequest.LPSZNEWFILE = (DWORD)FTP_strdup(lpszNewFile);
workRequest.DWLOCALFLAGSATTRIBUTE = dwLocalFlagsAttribute;
workRequest.FFAILIFEXISTS = (DWORD)fFailIfExists;
workRequest.DWFLAGS = dwInternetFlags;
......@@ -967,7 +974,7 @@ BOOL WINAPI FtpDeleteFileA(HINTERNET hFtpSession, LPCSTR lpszFileName)
workRequest.asyncall = FTPRENAMEFILEA;
workRequest.HFTPSESSION = (DWORD)hFtpSession;
workRequest.LPSZFILENAME = (DWORD)HEAP_strdupA(GetProcessHeap(),0,lpszFileName);
workRequest.LPSZFILENAME = (DWORD)FTP_strdup(lpszFileName);
return INTERNET_AsyncCall(&workRequest);
}
......@@ -1061,7 +1068,7 @@ BOOL WINAPI FtpRemoveDirectoryA(HINTERNET hFtpSession, LPCSTR lpszDirectory)
workRequest.asyncall = FTPREMOVEDIRECTORYA;
workRequest.HFTPSESSION = (DWORD)hFtpSession;
workRequest.LPSZDIRECTORY = (DWORD)HEAP_strdupA(GetProcessHeap(),0,lpszDirectory);
workRequest.LPSZDIRECTORY = (DWORD)FTP_strdup(lpszDirectory);
return INTERNET_AsyncCall(&workRequest);
}
......@@ -1156,8 +1163,8 @@ BOOL WINAPI FtpRenameFileA(HINTERNET hFtpSession, LPCSTR lpszSrc, LPCSTR lpszDes
workRequest.asyncall = FTPRENAMEFILEA;
workRequest.HFTPSESSION = (DWORD)hFtpSession;
workRequest.LPSZSRCFILE = (DWORD)HEAP_strdupA(GetProcessHeap(),0,lpszSrc);
workRequest.LPSZDESTFILE = (DWORD)HEAP_strdupA(GetProcessHeap(),0,lpszDest);
workRequest.LPSZSRCFILE = (DWORD)FTP_strdup(lpszSrc);
workRequest.LPSZDESTFILE = (DWORD)FTP_strdup(lpszDest);
return INTERNET_AsyncCall(&workRequest);
}
......@@ -1323,13 +1330,13 @@ HINTERNET FTP_Connect(HINTERNET hInternet, LPCSTR lpszServerName,
if (NULL == lpszUserName)
{
lpwfs->lpszUserName = HEAP_strdupA(GetProcessHeap(),0,"anonymous");
lpwfs->lpszPassword = HEAP_strdupA(GetProcessHeap(),0,"user@server");
lpwfs->lpszUserName = FTP_strdup("anonymous");
lpwfs->lpszPassword = FTP_strdup("user@server");
}
else
{
lpwfs->lpszUserName = HEAP_strdupA(GetProcessHeap(),0,lpszUserName);
lpwfs->lpszPassword = HEAP_strdupA(GetProcessHeap(),0,lpszPassword);
lpwfs->lpszUserName = FTP_strdup(lpszUserName);
lpwfs->lpszPassword = FTP_strdup(lpszPassword);
}
if (FTP_ConnectToHost(lpwfs))
......@@ -2309,7 +2316,7 @@ BOOL FTP_ParseDirectory(LPWININETFTPSESSIONA lpwfs, INT nSocket, LPFILEPROPERTIE
pszToken = strtok(NULL, " \t");
if(pszToken != NULL)
{
curFileProp->lpszName = HEAP_strdupA(GetProcessHeap(),0,pszToken);
curFileProp->lpszName = FTP_strdup(pszToken);
TRACE(": %s\n", curFileProp->lpszName);
}
......
......@@ -13,7 +13,6 @@
#include "wininet.h"
#include "debugtools.h"
#include "winerror.h"
#include "heap.h"
#include "winsock.h"
#include <sys/types.h>
......@@ -62,6 +61,13 @@ INT HTTP_GetStdHeaderIndex(LPCSTR lpszField);
INT HTTP_InsertCustomHeader(LPWININETHTTPREQA lpwhr, LPHTTPHEADERA lpHdr);
INT HTTP_GetCustomHeaderIndex(LPWININETHTTPREQA lpwhr, LPCSTR lpszField);
inline static LPSTR HTTP_strdup( LPCSTR str )
{
LPSTR ret = HeapAlloc( GetProcessHeap(), 0, strlen(str) + 1 );
if (ret) strcpy( ret, str );
return ret;
}
/***********************************************************************
* HttpAddRequestHeadersA (WININET.68)
*
......@@ -88,7 +94,7 @@ INTERNETAPI BOOL WINAPI HttpAddRequestHeadersA(HINTERNET hHttpRequest,
return FALSE;
}
buffer = HEAP_strdupA(GetProcessHeap(), 0, lpszHeader);
buffer = HTTP_strdup(lpszHeader);
lpszStart = buffer;
do
......@@ -153,10 +159,10 @@ INTERNETAPI HINTERNET WINAPI HttpOpenRequestA(HINTERNET hHttpSession,
workRequest.asyncall = HTTPOPENREQUESTA;
workRequest.HFTPSESSION = (DWORD)hHttpSession;
workRequest.LPSZVERB = (DWORD)HEAP_strdupA(GetProcessHeap(), 0, lpszVerb);
workRequest.LPSZOBJECTNAME = (DWORD)HEAP_strdupA(GetProcessHeap(), 0, lpszObjectName);
workRequest.LPSZVERSION = (DWORD)HEAP_strdupA(GetProcessHeap(), 0, lpszVersion);
workRequest.LPSZREFERRER = (DWORD)HEAP_strdupA(GetProcessHeap(), 0, lpszReferrer);
workRequest.LPSZVERB = (DWORD)HTTP_strdup(lpszVerb);
workRequest.LPSZOBJECTNAME = (DWORD)HTTP_strdup(lpszObjectName);
workRequest.LPSZVERSION = (DWORD)HTTP_strdup(lpszVersion);
workRequest.LPSZREFERRER = (DWORD)HTTP_strdup(lpszReferrer);
workRequest.LPSZACCEPTTYPES = (DWORD)lpszAcceptTypes;
workRequest.DWFLAGS = dwFlags;
workRequest.DWCONTEXT = dwContext;
......@@ -214,7 +220,7 @@ INTERNETAPI HINTERNET WINAPI HTTP_HttpOpenRequestA(HINTERNET hHttpSession,
lpwhr->nSocketFD = INVALID_SOCKET;
if (NULL != lpszObjectName && strlen(lpszObjectName))
lpwhr->lpszPath = HEAP_strdupA(GetProcessHeap(), 0, lpszObjectName);
lpwhr->lpszPath = HTTP_strdup(lpszObjectName);
if (NULL != lpszReferrer && strlen(lpszReferrer))
HTTP_ProcessHeader(lpwhr, HTTP_REFERER, lpszReferrer, HTTP_ADDHDR_FLAG_COALESCE);
......@@ -224,9 +230,9 @@ INTERNETAPI HINTERNET WINAPI HTTP_HttpOpenRequestA(HINTERNET hHttpSession,
HTTP_ProcessHeader(lpwhr, HTTP_ACCEPT, *lpszAcceptTypes, HTTP_ADDHDR_FLAG_COALESCE);
if (NULL == lpszVerb)
lpwhr->lpszVerb = HEAP_strdupA(GetProcessHeap(), 0, "GET");
lpwhr->lpszVerb = HTTP_strdup("GET");
else if (strlen(lpszVerb))
lpwhr->lpszVerb = HEAP_strdupA(GetProcessHeap(), 0, lpszVerb);
lpwhr->lpszVerb = HTTP_strdup(lpszVerb);
if (NULL != lpszReferrer)
{
......@@ -243,10 +249,9 @@ INTERNETAPI HINTERNET WINAPI HTTP_HttpOpenRequestA(HINTERNET hHttpSession,
InternetCrackUrlA(lpszReferrer, 0, 0, &UrlComponents);
if (strlen(UrlComponents.lpszHostName))
lpwhr->lpszHostName = HEAP_strdupA(GetProcessHeap(), 0, UrlComponents.lpszHostName);
lpwhr->lpszHostName = HTTP_strdup(UrlComponents.lpszHostName);
} else {
lpwhr->lpszHostName = HEAP_strdupA(GetProcessHeap(), 0,
lpwhs->lpszServerName);
lpwhr->lpszHostName = HTTP_strdup(lpwhs->lpszServerName);
}
if (hIC->lpfnStatusCB)
......@@ -519,7 +524,7 @@ BOOL WINAPI HttpSendRequestA(HINTERNET hHttpRequest, LPCSTR lpszHeaders,
workRequest.asyncall = HTTPSENDREQUESTA;
workRequest.HFTPSESSION = (DWORD)hHttpRequest;
workRequest.LPSZHEADER = (DWORD)HEAP_strdupA(GetProcessHeap(), 0, lpszHeaders);
workRequest.LPSZHEADER = (DWORD)HTTP_strdup(lpszHeaders);
workRequest.DWHEADERLENGTH = dwHeaderLength;
workRequest.LPOPTIONAL = (DWORD)lpOptional;
workRequest.DWOPTIONALLENGTH = dwOptionalLength;
......@@ -591,7 +596,7 @@ BOOL WINAPI HTTP_HttpSendRequestA(HINTERNET hHttpRequest, LPCSTR lpszHeaders,
/* If we don't have a path we set it to root */
if (NULL == lpwhr->lpszPath)
lpwhr->lpszPath = HEAP_strdupA(GetProcessHeap(), 0, "/");
lpwhr->lpszPath = HTTP_strdup("/");
/* Calculate length of request string */
requestStringLen =
......@@ -765,9 +770,9 @@ HINTERNET HTTP_Connect(HINTERNET hInternet, LPCSTR lpszServerName,
lpwhs->hdr.dwFlags = dwFlags;
lpwhs->hdr.dwContext = dwContext;
if (NULL != lpszServerName)
lpwhs->lpszServerName = HEAP_strdupA(GetProcessHeap(), 0, lpszServerName);
lpwhs->lpszServerName = HTTP_strdup(lpszServerName);
if (NULL != lpszUserName)
lpwhs->lpszUserName = HEAP_strdupA(GetProcessHeap(), 0, lpszUserName);
lpwhs->lpszUserName = HTTP_strdup(lpszUserName);
lpwhs->nServerPort = nServerPort;
if (hIC->lpfnStatusCB)
......@@ -1094,7 +1099,7 @@ BOOL HTTP_ProcessHeader(LPWININETHTTPREQA lpwhr, LPCSTR field, LPCSTR value, DWO
if (!lpwhr->StdHeaders[index].lpszField)
{
lphttpHdr->lpszField = HEAP_strdupA(GetProcessHeap(), 0, field);
lphttpHdr->lpszField = HTTP_strdup(field);
if (dwModifier & HTTP_ADDHDR_FLAG_REQ)
lphttpHdr->wFlags |= HDR_ISREQUEST;
......@@ -1314,8 +1319,8 @@ INT HTTP_InsertCustomHeader(LPWININETHTTPREQA lpwhr, LPHTTPHEADERA lpHdr)
if (NULL != lph)
{
lpwhr->pCustHeaders = lph;
lpwhr->pCustHeaders[count-1].lpszField = HEAP_strdupA(GetProcessHeap(), 0, lpHdr->lpszField);
lpwhr->pCustHeaders[count-1].lpszValue = HEAP_strdupA(GetProcessHeap(), 0, lpHdr->lpszValue);
lpwhr->pCustHeaders[count-1].lpszField = HTTP_strdup(lpHdr->lpszField);
lpwhr->pCustHeaders[count-1].lpszValue = HTTP_strdup(lpHdr->lpszValue);
lpwhr->pCustHeaders[count-1].wFlags = lpHdr->wFlags;
lpwhr->pCustHeaders[count-1].wCount= lpHdr->wCount;
lpwhr->nCustHeaders++;
......
......@@ -24,7 +24,6 @@
#include "debugtools.h"
#include "winerror.h"
#include "winsock.h"
#include "heap.h"
#include "internet.h"
......@@ -160,11 +159,20 @@ INTERNETAPI HINTERNET WINAPI InternetOpenA(LPCSTR lpszAgent,
lpwai->hdr.lpwhparent = NULL;
lpwai->hdr.dwFlags = dwFlags;
if (NULL != lpszAgent)
lpwai->lpszAgent = HEAP_strdupA(GetProcessHeap(),0,lpszAgent);
{
if ((lpwai->lpszAgent = HeapAlloc( GetProcessHeap(),0,strlen(lpszAgent)+1)))
strcpy( lpwai->lpszAgent, lpszAgent );
}
if (NULL != lpszProxy)
lpwai->lpszProxy = HEAP_strdupA(GetProcessHeap(),0,lpszProxy);
{
if ((lpwai->lpszProxy = HeapAlloc( GetProcessHeap(), 0, strlen(lpszProxy)+1 )))
strcpy( lpwai->lpszProxy, lpszProxy );
}
if (NULL != lpszProxyBypass)
lpwai->lpszProxyBypass = HEAP_strdupA(GetProcessHeap(),0,lpszProxyBypass);
{
if ((lpwai->lpszProxyBypass = HeapAlloc( GetProcessHeap(), 0, strlen(lpszProxyBypass)+1)))
strcpy( lpwai->lpszProxyBypass, lpszProxyBypass );
}
lpwai->dwAccessType = dwAccessType;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment