Commit 996c0bff authored by Alexandre Julliard's avatar Alexandre Julliard

Removed ntdll dependency on MultiByteToWideChar/WideCharToMultiByte

kernel32 functions, plus a few small cleanups.
parent 63d13317
......@@ -25,23 +25,6 @@ void dump_ObjectAttributes (const OBJECT_ATTRIBUTES *oa)
oa->Attributes, oa->RootDirectory, oa->SecurityDescriptor);
}
void dump_UnicodeString(const UNICODE_STRING *us, BOOLEAN showstring)
{
if (us)
{
if (showstring)
TRACE("%p %p(%s) (%u %u)\n", us, us->Buffer, debugstr_us(us), us->Length, us->MaximumLength);
else
TRACE("%p %p(<OUT>) (%u %u)\n", us, us->Buffer, us->Length, us->MaximumLength);
}
}
LPCSTR debugstr_as( const STRING *str )
{
if (!str) return "<null>";
return debugstr_an(str->Buffer, str->Length);
}
LPCSTR debugstr_us( const UNICODE_STRING *us )
{
if (!us) return "<null>";
......
......@@ -60,8 +60,9 @@ debug_channels (atom cdrom console debug delayhlp dll dosfs dosmem file fixup
@ stub LdrUnloadDll
@ stub LdrVerifyImageMatchesChecksum
@ stub NPXEMULATORTABLE
@ stub NlsMbCodePageTag
@ stub NlsMbOemCodePageTag
@ extern NlsAnsiCodePage NlsAnsiCodePage
@ extern NlsMbCodePageTag NlsMbCodePageTag
@ extern NlsMbOemCodePageTag NlsMbOemCodePageTag
@ stdcall NtAcceptConnectPort(long long long long long long) NtAcceptConnectPort
@ stdcall NtAccessCheck(ptr long long ptr ptr ptr ptr ptr) NtAccessCheck
@ stub NtAccessCheckAndAuditAlarm
......@@ -1034,3 +1035,6 @@ debug_channels (atom cdrom console debug delayhlp dll dosfs dosmem file fixup
# Server interface
@ cdecl -norelay wine_server_call(ptr) wine_server_call
# Codepages
@ cdecl __wine_init_codepages(ptr ptr) __wine_init_codepages
......@@ -5,9 +5,7 @@
#include "winnt.h"
/* debug helper */
extern LPCSTR debugstr_as( const STRING *str );
extern LPCSTR debugstr_us( const UNICODE_STRING *str );
extern void dump_ObjectAttributes (const OBJECT_ATTRIBUTES *ObjectAttributes);
extern void dump_UnicodeString(const UNICODE_STRING *us, BOOLEAN showstring);
#endif
......@@ -261,14 +261,13 @@ BOOLEAN WINAPI RtlFreeHeap(
/******************************************************************************
* RtlDestroyHeap [NTDLL.@]
*
* FIXME: prototype guessed
*/
BOOLEAN WINAPI RtlDestroyHeap(
HANDLE WINAPI RtlDestroyHeap(
HANDLE Heap)
{
TRACE("(0x%08x) semi stub\n", Heap);
return HeapDestroy(Heap);
if (!HeapDestroy(Heap)) return Heap;
return 0;
}
/*
......
......@@ -7,18 +7,49 @@
#include "config.h"
#include <assert.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include "ntddk.h"
#include "wine/unicode.h"
#include "winnls.h"
#include "debugtools.h"
#include "ntdll_misc.h"
#include "ntddk.h"
DEFAULT_DEBUG_CHANNEL(ntdll);
/* STRING CREATION FUNCTIONS */
UINT NlsAnsiCodePage = 1252;
BYTE NlsMbCodePageTag = 0;
BYTE NlsMbOemCodePageTag = 0;
static const union cptable *ansi_table;
static const union cptable *oem_table;
inline static const union cptable *get_ansi_table(void)
{
if (!ansi_table) ansi_table = cp_get_table( 1252 );
return ansi_table;
}
inline static const union cptable *get_oem_table(void)
{
if (!oem_table) oem_table = cp_get_table( 437 );
return oem_table;
}
/**************************************************************************
* __wine_init_codepages (NTDLL.@)
*
* Set the code page once kernel32 is loaded. Should be done differently.
*/
void __wine_init_codepages( const union cptable *ansi, const union cptable *oem )
{
ansi_table = ansi;
oem_table = oem;
NlsAnsiCodePage = ansi->info.codepage;
}
/**************************************************************************
* RtlInitAnsiString (NTDLL.@)
......@@ -48,7 +79,7 @@ void WINAPI RtlInitString( PSTRING target, LPCSTR source )
*/
void WINAPI RtlFreeAnsiString( PSTRING str )
{
if (str->Buffer) HeapFree( GetProcessHeap(), 0, str->Buffer );
if (str->Buffer) RtlFreeHeap( GetProcessHeap(), 0, str->Buffer );
}
......@@ -96,7 +127,7 @@ void WINAPI RtlInitUnicodeString( PUNICODE_STRING target, LPCWSTR source )
BOOLEAN WINAPI RtlCreateUnicodeString( PUNICODE_STRING target, LPCWSTR src )
{
int len = (strlenW(src) + 1) * sizeof(WCHAR);
if (!(target->Buffer = HeapAlloc( GetProcessHeap(), 0, len ))) return FALSE;
if (!(target->Buffer = RtlAllocateHeap( GetProcessHeap(), 0, len ))) return FALSE;
memcpy( target->Buffer, src, len );
target->MaximumLength = len;
target->Length = len - 2;
......@@ -120,7 +151,7 @@ BOOLEAN WINAPI RtlCreateUnicodeStringFromAsciiz( PUNICODE_STRING target, LPCSTR
*/
void WINAPI RtlFreeUnicodeString( PUNICODE_STRING str )
{
if (str->Buffer) HeapFree( GetProcessHeap(), 0, str->Buffer );
if (str->Buffer) RtlFreeHeap( GetProcessHeap(), 0, str->Buffer );
}
......@@ -297,20 +328,19 @@ NTSTATUS WINAPI RtlAnsiStringToUnicodeString( UNICODE_STRING *uni,
const STRING *ansi,
BOOLEAN doalloc )
{
DWORD len = MultiByteToWideChar( CP_ACP, 0, ansi->Buffer, ansi->Length, NULL, 0 );
DWORD total = (len + 1) * sizeof(WCHAR);
DWORD total = RtlAnsiStringToUnicodeSize( ansi );
if (total > 0xffff) return STATUS_INVALID_PARAMETER_2;
uni->Length = len * sizeof(WCHAR);
uni->Length = total - sizeof(WCHAR);
if (doalloc)
{
uni->MaximumLength = total;
if (!(uni->Buffer = HeapAlloc( GetProcessHeap(), 0, total ))) return STATUS_NO_MEMORY;
if (!(uni->Buffer = RtlAllocateHeap( GetProcessHeap(), 0, total ))) return STATUS_NO_MEMORY;
}
else if (total > uni->MaximumLength) return STATUS_BUFFER_OVERFLOW;
MultiByteToWideChar( CP_ACP, 0, ansi->Buffer, ansi->Length, uni->Buffer, len );
uni->Buffer[len] = 0;
RtlMultiByteToUnicodeN( uni->Buffer, uni->Length, NULL, ansi->Buffer, ansi->Length );
uni->Buffer[uni->Length / sizeof(WCHAR)] = 0;
return STATUS_SUCCESS;
}
......@@ -326,20 +356,19 @@ NTSTATUS WINAPI RtlOemStringToUnicodeString( UNICODE_STRING *uni,
const STRING *oem,
BOOLEAN doalloc )
{
DWORD len = MultiByteToWideChar( CP_OEMCP, 0, oem->Buffer, oem->Length, NULL, 0 );
DWORD total = (len + 1) * sizeof(WCHAR);
DWORD total = RtlOemStringToUnicodeSize( oem );
if (total > 0xffff) return STATUS_INVALID_PARAMETER_2;
uni->Length = len * sizeof(WCHAR);
uni->Length = total - sizeof(WCHAR);
if (doalloc)
{
uni->MaximumLength = total;
if (!(uni->Buffer = HeapAlloc( GetProcessHeap(), 0, total ))) return STATUS_NO_MEMORY;
if (!(uni->Buffer = RtlAllocateHeap( GetProcessHeap(), 0, total ))) return STATUS_NO_MEMORY;
}
else if (total > uni->MaximumLength) return STATUS_BUFFER_OVERFLOW;
MultiByteToWideChar( CP_OEMCP, 0, oem->Buffer, oem->Length, uni->Buffer, len );
uni->Buffer[len] = 0;
RtlOemToUnicodeN( uni->Buffer, uni->Length, NULL, oem->Buffer, oem->Length );
uni->Buffer[uni->Length / sizeof(WCHAR)] = 0;
return STATUS_SUCCESS;
}
......@@ -362,7 +391,7 @@ NTSTATUS WINAPI RtlUnicodeStringToAnsiString( STRING *ansi,
if (doalloc)
{
ansi->MaximumLength = len + 1;
if (!(ansi->Buffer = HeapAlloc( GetProcessHeap(), 0, len + 1 ))) return STATUS_NO_MEMORY;
if (!(ansi->Buffer = RtlAllocateHeap( GetProcessHeap(), 0, len + 1 ))) return STATUS_NO_MEMORY;
}
else if (ansi->MaximumLength <= len)
{
......@@ -371,8 +400,7 @@ NTSTATUS WINAPI RtlUnicodeStringToAnsiString( STRING *ansi,
ret = STATUS_BUFFER_OVERFLOW;
}
WideCharToMultiByte( CP_ACP, 0, uni->Buffer, uni->Length / sizeof(WCHAR),
ansi->Buffer, ansi->Length, NULL, NULL );
RtlUnicodeToMultiByteN( ansi->Buffer, ansi->Length, NULL, uni->Buffer, uni->Length );
ansi->Buffer[ansi->Length] = 0;
return ret;
}
......@@ -396,7 +424,7 @@ NTSTATUS WINAPI RtlUnicodeStringToOemString( STRING *oem,
if (doalloc)
{
oem->MaximumLength = len + 1;
if (!(oem->Buffer = HeapAlloc( GetProcessHeap(), 0, len + 1 ))) return STATUS_NO_MEMORY;
if (!(oem->Buffer = RtlAllocateHeap( GetProcessHeap(), 0, len + 1 ))) return STATUS_NO_MEMORY;
}
else if (oem->MaximumLength <= len)
{
......@@ -405,8 +433,7 @@ NTSTATUS WINAPI RtlUnicodeStringToOemString( STRING *oem,
ret = STATUS_BUFFER_OVERFLOW;
}
WideCharToMultiByte( CP_OEMCP, 0, uni->Buffer, uni->Length / sizeof(WCHAR),
oem->Buffer, oem->Length, NULL, NULL );
RtlUnicodeToOemN( oem->Buffer, oem->Length, NULL, uni->Buffer, uni->Length );
oem->Buffer[oem->Length] = 0;
return ret;
}
......@@ -421,9 +448,10 @@ NTSTATUS WINAPI RtlUnicodeStringToOemString( STRING *oem,
NTSTATUS WINAPI RtlMultiByteToUnicodeN( LPWSTR dst, DWORD dstlen, LPDWORD reslen,
LPCSTR src, DWORD srclen )
{
DWORD res = MultiByteToWideChar( CP_ACP, 0, src, srclen, dst, dstlen/sizeof(WCHAR) );
int ret = cp_mbstowcs( get_ansi_table(), 0, src, srclen, dst, dstlen/sizeof(WCHAR) );
if (reslen)
*reslen = res ? res * sizeof(WCHAR) : dstlen; /* overflow -> we filled up to dstlen */
*reslen = (ret >= 0) ? ret*sizeof(WCHAR) : dstlen; /* overflow -> we filled up to dstlen */
return STATUS_SUCCESS;
}
......@@ -434,9 +462,9 @@ NTSTATUS WINAPI RtlMultiByteToUnicodeN( LPWSTR dst, DWORD dstlen, LPDWORD reslen
NTSTATUS WINAPI RtlOemToUnicodeN( LPWSTR dst, DWORD dstlen, LPDWORD reslen,
LPCSTR src, DWORD srclen )
{
DWORD res = MultiByteToWideChar( CP_OEMCP, 0, src, srclen, dst, dstlen/sizeof(WCHAR) );
int ret = cp_mbstowcs( get_oem_table(), 0, src, srclen, dst, dstlen/sizeof(WCHAR) );
if (reslen)
*reslen = res ? res * sizeof(WCHAR) : dstlen; /* overflow -> we filled up to dstlen */
*reslen = (ret >= 0) ? ret*sizeof(WCHAR) : dstlen; /* overflow -> we filled up to dstlen */
return STATUS_SUCCESS;
}
......@@ -447,10 +475,10 @@ NTSTATUS WINAPI RtlOemToUnicodeN( LPWSTR dst, DWORD dstlen, LPDWORD reslen,
NTSTATUS WINAPI RtlUnicodeToMultiByteN( LPSTR dst, DWORD dstlen, LPDWORD reslen,
LPCWSTR src, DWORD srclen )
{
DWORD res = WideCharToMultiByte( CP_ACP, 0, src, srclen/sizeof(WCHAR),
dst, dstlen, NULL, NULL );
int ret = cp_wcstombs( get_ansi_table(), 0, src, srclen / sizeof(WCHAR),
dst, dstlen, NULL, NULL );
if (reslen)
*reslen = res ? res * sizeof(WCHAR) : dstlen; /* overflow -> we filled up to dstlen */
*reslen = (ret >= 0) ? ret : dstlen; /* overflow -> we filled up to dstlen */
return STATUS_SUCCESS;
}
......@@ -461,10 +489,10 @@ NTSTATUS WINAPI RtlUnicodeToMultiByteN( LPSTR dst, DWORD dstlen, LPDWORD reslen,
NTSTATUS WINAPI RtlUnicodeToOemN( LPSTR dst, DWORD dstlen, LPDWORD reslen,
LPCWSTR src, DWORD srclen )
{
DWORD res = WideCharToMultiByte( CP_OEMCP, 0, src, srclen/sizeof(WCHAR),
dst, dstlen, NULL, NULL );
int ret = cp_wcstombs( get_oem_table(), 0, src, srclen / sizeof(WCHAR),
dst, dstlen, NULL, NULL );
if (reslen)
*reslen = res ? res * sizeof(WCHAR) : dstlen; /* overflow -> we filled up to dstlen */
*reslen = (ret >= 0) ? ret : dstlen; /* overflow -> we filled up to dstlen */
return STATUS_SUCCESS;
}
......@@ -502,7 +530,7 @@ NTSTATUS WINAPI RtlUpcaseUnicodeString( UNICODE_STRING *dest,
if (doalloc)
{
dest->MaximumLength = len;
if (!(dest->Buffer = HeapAlloc( GetProcessHeap(), 0, len ))) return STATUS_NO_MEMORY;
if (!(dest->Buffer = RtlAllocateHeap( GetProcessHeap(), 0, len ))) return STATUS_NO_MEMORY;
}
else if (len > dest->MaximumLength) return STATUS_BUFFER_OVERFLOW;
......@@ -566,10 +594,10 @@ NTSTATUS WINAPI RtlUpcaseUnicodeToMultiByteN( LPSTR dst, DWORD dstlen, LPDWORD r
LPWSTR upcase;
DWORD i;
if (!(upcase = HeapAlloc( GetProcessHeap(), 0, srclen ))) return STATUS_NO_MEMORY;
if (!(upcase = RtlAllocateHeap( GetProcessHeap(), 0, srclen ))) return STATUS_NO_MEMORY;
for (i = 0; i < srclen/sizeof(WCHAR); i++) upcase[i] = toupperW(src[i]);
ret = RtlUnicodeToMultiByteN( dst, dstlen, reslen, upcase, srclen );
HeapFree( GetProcessHeap(), 0, upcase );
RtlFreeHeap( GetProcessHeap(), 0, upcase );
return ret;
}
......@@ -584,10 +612,10 @@ NTSTATUS WINAPI RtlUpcaseUnicodeToOemN( LPSTR dst, DWORD dstlen, LPDWORD reslen,
LPWSTR upcase;
DWORD i;
if (!(upcase = HeapAlloc( GetProcessHeap(), 0, srclen ))) return STATUS_NO_MEMORY;
if (!(upcase = RtlAllocateHeap( GetProcessHeap(), 0, srclen ))) return STATUS_NO_MEMORY;
for (i = 0; i < srclen/sizeof(WCHAR); i++) upcase[i] = toupperW(src[i]);
ret = RtlUnicodeToOemN( dst, dstlen, reslen, upcase, srclen );
HeapFree( GetProcessHeap(), 0, upcase );
RtlFreeHeap( GetProcessHeap(), 0, upcase );
return ret;
}
......@@ -603,9 +631,9 @@ NTSTATUS WINAPI RtlUpcaseUnicodeToOemN( LPSTR dst, DWORD dstlen, LPDWORD reslen,
* Return the size in bytes necessary for the Unicode conversion of 'str',
* including the terminating NULL.
*/
UINT WINAPI RtlOemStringToUnicodeSize(PSTRING str)
UINT WINAPI RtlOemStringToUnicodeSize( const STRING *str )
{
DWORD ret = MultiByteToWideChar( CP_OEMCP, 0, str->Buffer, str->Length, NULL, 0 );
int ret = cp_mbstowcs( get_oem_table(), 0, str->Buffer, str->Length, NULL, 0 );
return (ret + 1) * sizeof(WCHAR);
}
......@@ -617,10 +645,11 @@ UINT WINAPI RtlOemStringToUnicodeSize(PSTRING str)
* Return the size in bytes necessary for the Unicode conversion of 'str',
* including the terminating NULL.
*/
DWORD WINAPI RtlAnsiStringToUnicodeSize(PSTRING str)
DWORD WINAPI RtlAnsiStringToUnicodeSize( const STRING *str )
{
DWORD ret = MultiByteToWideChar( CP_ACP, 0, str->Buffer, str->Length, NULL, 0 );
return (ret + 1) * sizeof(WCHAR);
DWORD ret;
RtlMultiByteToUnicodeSize( &ret, str->Buffer, str->Length );
return ret + sizeof(WCHAR);
}
......@@ -632,8 +661,8 @@ DWORD WINAPI RtlAnsiStringToUnicodeSize(PSTRING str)
*/
NTSTATUS WINAPI RtlMultiByteToUnicodeSize( DWORD *size, LPCSTR str, UINT len )
{
*size = MultiByteToWideChar( CP_ACP, 0, str, len, NULL, 0 ) * sizeof(WCHAR);
return 0;
*size = cp_mbstowcs( get_ansi_table(), 0, str, len, NULL, 0 ) * sizeof(WCHAR);
return STATUS_SUCCESS;
}
......@@ -645,8 +674,8 @@ NTSTATUS WINAPI RtlMultiByteToUnicodeSize( DWORD *size, LPCSTR str, UINT len )
*/
NTSTATUS WINAPI RtlUnicodeToMultiByteSize( DWORD *size, LPCWSTR str, UINT len )
{
*size = WideCharToMultiByte( CP_ACP, 0, str, len / sizeof(WCHAR), NULL, 0, NULL, NULL );
return 0;
*size = cp_wcstombs( get_ansi_table(), 0, str, len / sizeof(WCHAR), NULL, 0, NULL, NULL );
return STATUS_SUCCESS;
}
......@@ -659,8 +688,9 @@ NTSTATUS WINAPI RtlUnicodeToMultiByteSize( DWORD *size, LPCWSTR str, UINT len )
*/
DWORD WINAPI RtlUnicodeStringToAnsiSize( const UNICODE_STRING *str )
{
return WideCharToMultiByte( CP_ACP, 0, str->Buffer, str->Length / sizeof(WCHAR),
NULL, 0, NULL, NULL ) + 1;
DWORD ret;
RtlUnicodeToMultiByteSize( &ret, str->Buffer, str->Length );
return ret + 1;
}
......@@ -673,8 +703,8 @@ DWORD WINAPI RtlUnicodeStringToAnsiSize( const UNICODE_STRING *str )
*/
DWORD WINAPI RtlUnicodeStringToOemSize( const UNICODE_STRING *str )
{
return WideCharToMultiByte( CP_OEMCP, 0, str->Buffer, str->Length / sizeof(WCHAR),
NULL, 0, NULL, NULL ) + 1;
return cp_wcstombs( get_oem_table(), 0, str->Buffer, str->Length / sizeof(WCHAR),
NULL, 0, NULL, NULL ) + 1;
}
......
......@@ -56,7 +56,7 @@ BOOLEAN WINAPI RtlAllocateAndInitializeSid (
nSubAuthority0, nSubAuthority1, nSubAuthority2, nSubAuthority3,
nSubAuthority4, nSubAuthority5, nSubAuthority6, nSubAuthority7, pSid);
if (!(*pSid = HeapAlloc( GetProcessHeap(), 0, RtlLengthRequiredSid(nSubAuthorityCount))))
if (!(*pSid = RtlAllocateHeap( GetProcessHeap(), 0, RtlLengthRequiredSid(nSubAuthorityCount))))
return FALSE;
(*pSid)->Revision = SID_REVISION;
......@@ -126,7 +126,7 @@ BOOL WINAPI RtlEqualPrefixSid (PSID pSid1, PSID pSid2)
DWORD WINAPI RtlFreeSid(PSID pSid)
{
TRACE("(%p)\n", pSid);
HeapFree( GetProcessHeap(), 0, pSid );
RtlFreeHeap( GetProcessHeap(), 0, pSid );
return STATUS_SUCCESS;
}
......@@ -719,7 +719,9 @@ NTSTATUS WINAPI RtlConvertSidToUnicodeString(
ANSI_STRING AnsiStr;
FIXME("(%p %p)\n", UnicodeSID, pSid);
dump_UnicodeString(UnicodeSID, FALSE);
if (UnicodeSID)
TRACE("%p(<OUT>) (%u %u)\n",
UnicodeSID->Buffer, UnicodeSID->Length, UnicodeSID->MaximumLength);
RtlInitAnsiString(&AnsiStr, GenSID);
return RtlAnsiStringToUnicodeString(UnicodeSID, &AnsiStr, TRUE);
......
......@@ -13,11 +13,8 @@
#include <string.h>
#include <stdio.h>
#include "windef.h"
#include "winbase.h"
#include "winnls.h"
#include "ntddk.h"
#include "wine/unicode.h"
#include "heap.h"
#include "debugtools.h"
DEFAULT_DEBUG_CHANNEL(ntdll);
......@@ -252,11 +249,20 @@ LPWSTR __cdecl NTDLL_wcstok( LPWSTR str, LPCWSTR delim )
*/
INT __cdecl NTDLL_wcstombs( LPSTR dst, LPCWSTR src, INT n )
{
INT ret;
if (n <= 0) return 0;
ret = WideCharToMultiByte( CP_ACP, 0, src, -1, dst, dst ? n : 0, NULL, NULL );
if (!ret) return n; /* overflow */
return ret - 1; /* do not count terminating NULL */
DWORD len;
if (!dst)
{
RtlUnicodeToMultiByteSize( &len, src, strlenW(src)*sizeof(WCHAR) );
return len;
}
else
{
if (n <= 0) return 0;
RtlUnicodeToMultiByteN( dst, n, &len, src, strlenW(src)*sizeof(WCHAR) );
if (len < n) dst[len] = 0;
}
return len;
}
......@@ -265,11 +271,19 @@ INT __cdecl NTDLL_wcstombs( LPSTR dst, LPCWSTR src, INT n )
*/
INT __cdecl NTDLL_mbstowcs( LPWSTR dst, LPCSTR src, INT n )
{
INT ret;
if (n <= 0) return 0;
ret = MultiByteToWideChar( CP_ACP, 0, src, -1, dst, dst ? n : 0 );
if (!ret) return n; /* overflow */
return ret - 1; /* do not count terminating NULL */
DWORD len;
if (!dst)
{
RtlMultiByteToUnicodeSize( &len, src, strlen(src) );
}
else
{
if (n <= 0) return 0;
RtlMultiByteToUnicodeN( dst, n*sizeof(WCHAR), &len, src, strlen(src) );
if (len / sizeof(WCHAR) < n) dst[len / sizeof(WCHAR)] = 0;
}
return len / sizeof(WCHAR);
}
......@@ -279,11 +293,21 @@ INT __cdecl NTDLL_mbstowcs( LPWSTR dst, LPCSTR src, INT n )
*/
INT __cdecl NTDLL_wcstol(LPCWSTR s,LPWSTR *end,INT base)
{
LPSTR sA = HEAP_strdupWtoA(GetProcessHeap(),0,s),endA;
INT ret = strtol(sA,&endA,base);
UNICODE_STRING uni;
ANSI_STRING ansi;
INT ret;
LPSTR endA;
HeapFree(GetProcessHeap(),0,sA);
if (end) *end = ((LPWSTR)s)+(endA-sA); /* pointer magic checked. */
RtlInitUnicodeString( &uni, s );
RtlUnicodeStringToAnsiString( &ansi, &uni, TRUE );
ret = strtol( ansi.Buffer, &endA, base );
if (end)
{
DWORD len;
RtlMultiByteToUnicodeSize( &len, ansi.Buffer, endA - ansi.Buffer );
*end = (LPWSTR)s + len/sizeof(WCHAR);
}
RtlFreeAnsiString( &ansi );
return ret;
}
......@@ -294,11 +318,21 @@ INT __cdecl NTDLL_wcstol(LPCWSTR s,LPWSTR *end,INT base)
*/
INT __cdecl NTDLL_wcstoul(LPCWSTR s,LPWSTR *end,INT base)
{
LPSTR sA = HEAP_strdupWtoA(GetProcessHeap(),0,s),endA;
INT ret = strtoul(sA,&endA,base);
UNICODE_STRING uni;
ANSI_STRING ansi;
INT ret;
LPSTR endA;
HeapFree(GetProcessHeap(),0,sA);
if (end) *end = ((LPWSTR)s)+(endA-sA); /* pointer magic checked. */
RtlInitUnicodeString( &uni, s );
RtlUnicodeStringToAnsiString( &ansi, &uni, TRUE );
ret = strtoul( ansi.Buffer, &endA, base );
if (end)
{
DWORD len;
RtlMultiByteToUnicodeSize( &len, ansi.Buffer, endA - ansi.Buffer );
*end = (LPWSTR)s + len/sizeof(WCHAR);
}
RtlFreeAnsiString( &ansi );
return ret;
}
......
......@@ -583,7 +583,7 @@ DWORD WINAPI RtlGetAce(
/* string functions */
DWORD WINAPI RtlAnsiStringToUnicodeSize(PSTRING);
DWORD WINAPI RtlAnsiStringToUnicodeSize(const STRING*);
NTSTATUS WINAPI RtlAnsiStringToUnicodeString(UNICODE_STRING*,const STRING *,BOOLEAN);
NTSTATUS WINAPI RtlAppendAsciizToString(STRING*,LPCSTR);
NTSTATUS WINAPI RtlAppendStringToString(STRING*,const STRING*);
......@@ -606,7 +606,7 @@ void WINAPI RtlInitString(PSTRING,LPCSTR);
void WINAPI RtlInitUnicodeString(PUNICODE_STRING,LPCWSTR);
NTSTATUS WINAPI RtlMultiByteToUnicodeN(LPWSTR,DWORD,LPDWORD,LPCSTR,DWORD);
NTSTATUS WINAPI RtlMultiByteToUnicodeSize(DWORD*,LPCSTR,UINT);
UINT WINAPI RtlOemStringToUnicodeSize(PSTRING);
UINT WINAPI RtlOemStringToUnicodeSize(const STRING*);
NTSTATUS WINAPI RtlOemStringToUnicodeString(UNICODE_STRING*,const STRING*,BOOLEAN);
NTSTATUS WINAPI RtlOemToUnicodeN(LPWSTR,DWORD,LPDWORD,LPCSTR,DWORD);
BOOLEAN WINAPI RtlPrefixString(const STRING*,const STRING*,BOOLEAN);
......@@ -712,24 +712,17 @@ typedef struct
ULONG Unknown[11];
} RTL_HEAP_DEFINITION, *PRTL_HEAP_DEFINITION;
HANDLE WINAPI RtlCreateHeap(
ULONG Flags,
PVOID BaseAddress,
ULONG SizeToReserve,
ULONG SizeToCommit,
PVOID Unknown,
PRTL_HEAP_DEFINITION Definition);
PVOID WINAPI RtlAllocateHeap(
HANDLE Heap,
ULONG Flags,
ULONG Size);
BOOLEAN WINAPI RtlFreeHeap(
HANDLE Heap,
ULONG Flags,
PVOID Address);
HANDLE WINAPI RtlCreateHeap(ULONG,PVOID,ULONG,ULONG,PVOID,PRTL_HEAP_DEFINITION);
HANDLE WINAPI RtlDestroyHeap(HANDLE);
PVOID WINAPI RtlAllocateHeap(HANDLE,ULONG,ULONG);
BOOLEAN WINAPI RtlFreeHeap(HANDLE,ULONG,PVOID);
PVOID WINAPI RtlReAllocateHeap(HANDLE,ULONG,PVOID,ULONG);
ULONG WINAPI RtlCompactHeap(HANDLE,ULONG);
BOOLEAN WINAPI RtlLockHeap(HANDLE);
BOOLEAN WINAPI RtlUnlockHeap(HANDLE);
ULONG WINAPI RtlSizeHeap(HANDLE,ULONG,PVOID);
BOOLEAN WINAPI RtlValidateHeap(HANDLE,ULONG,PCVOID);
ULONG WINAPI RtlGetProcessHeaps(ULONG,HANDLE*);
/* exception */
......
......@@ -74,14 +74,16 @@ static const union cptable *get_codepage_table( unsigned int codepage )
/* since it needs KERNEL32 to be loaded for the locale info. */
void CODEPAGE_Init(void)
{
extern void __wine_init_codepages( const union cptable *ansi, const union cptable *oem );
const union cptable *table;
LCID lcid = GetUserDefaultLCID();
if (!ansi_cptable) init_codepages(); /* just in case */
if ((table = get_locale_cp( lcid, LOCALE_IDEFAULTANSICODEPAGE ))) ansi_cptable = table;
if ((table = get_locale_cp( lcid, LOCALE_IDEFAULTMACCODEPAGE ))) mac_cptable = table;
if ((table = get_locale_cp( lcid, LOCALE_IDEFAULTCODEPAGE ))) oem_cptable = table;
__wine_init_codepages( ansi_cptable, oem_cptable );
TRACE( "ansi=%03d oem=%03d mac=%03d\n", ansi_cptable->info.codepage,
oem_cptable->info.codepage, mac_cptable->info.codepage );
......
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