diff --git a/dlls/kernel32/kernel32.spec b/dlls/kernel32/kernel32.spec index 2fc1d147f2a..169ba37564a 100644 --- a/dlls/kernel32/kernel32.spec +++ b/dlls/kernel32/kernel32.spec @@ -17,13 +17,13 @@ 7 stdcall -noname -i386 -register VxDCall6(long) VxDCall 8 stdcall -noname -i386 -register VxDCall7(long) VxDCall 9 stdcall -noname -i386 -register VxDCall8(long) VxDCall - 10 stdcall -noname k32CharToOemA(str ptr) - 11 stdcall -noname k32CharToOemBuffA(str ptr long) - 12 stdcall -noname k32OemToCharA(ptr ptr) - 13 stdcall -noname k32OemToCharBuffA(ptr ptr long) - 14 stdcall -noname k32LoadStringA(long long ptr long) - 15 varargs -noname k32wsprintfA(str str) - 16 stdcall -noname k32wvsprintfA(ptr str ptr) + 10 stdcall -noname -i386 k32CharToOemA(str ptr) + 11 stdcall -noname -i386 k32CharToOemBuffA(str ptr long) + 12 stdcall -noname -i386 k32OemToCharA(ptr ptr) + 13 stdcall -noname -i386 k32OemToCharBuffA(ptr ptr long) + 14 stdcall -noname -i386 k32LoadStringA(long long ptr long) + 15 varargs -noname -i386 k32wsprintfA(str str) + 16 stdcall -noname -i386 k32wvsprintfA(ptr str ptr) 17 stdcall -noname -i386 -register CommonUnimpStub() 18 stdcall -noname GetProcessDword(long long) 19 stub -noname ThunkTheTemplateHandle diff --git a/dlls/kernel32/string.c b/dlls/kernel32/string.c index c584bf73abc..120c868b70f 100644 --- a/dlls/kernel32/string.c +++ b/dlls/kernel32/string.c @@ -30,116 +30,10 @@ #define WINE_NO_INLINE_STRING #include "windef.h" #include "winbase.h" -#include "wine/winbase16.h" #include "wine/unicode.h" #include "wine/exception.h" -static INT (WINAPI *pLoadStringA)(HINSTANCE, UINT, LPSTR, INT); -static INT (WINAPI *pwvsprintfA)(LPSTR, LPCSTR, __ms_va_list); - - -/*********************************************************************** - * Helper for k32 family functions - */ -static void *user32_proc_address(const char *proc_name) -{ - static HMODULE hUser32; - - if(!hUser32) hUser32 = LoadLibraryA("user32.dll"); - return GetProcAddress(hUser32, proc_name); -} - - -/*********************************************************************** - * k32CharToOemBuffA (KERNEL32.11) - */ -BOOL WINAPI k32CharToOemBuffA(LPCSTR s, LPSTR d, DWORD len) -{ - WCHAR *bufW; - - if ((bufW = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) ))) - { - MultiByteToWideChar( CP_ACP, 0, s, len, bufW, len ); - WideCharToMultiByte( CP_OEMCP, 0, bufW, len, d, len, NULL, NULL ); - HeapFree( GetProcessHeap(), 0, bufW ); - } - return TRUE; -} - - -/*********************************************************************** - * k32CharToOemA (KERNEL32.10) - */ -BOOL WINAPI k32CharToOemA(LPCSTR s, LPSTR d) -{ - if (!s || !d) return TRUE; - return k32CharToOemBuffA( s, d, strlen(s) + 1 ); -} - - -/*********************************************************************** - * k32OemToCharBuffA (KERNEL32.13) - */ -BOOL WINAPI k32OemToCharBuffA(LPCSTR s, LPSTR d, DWORD len) -{ - WCHAR *bufW; - - if ((bufW = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) ))) - { - MultiByteToWideChar( CP_OEMCP, 0, s, len, bufW, len ); - WideCharToMultiByte( CP_ACP, 0, bufW, len, d, len, NULL, NULL ); - HeapFree( GetProcessHeap(), 0, bufW ); - } - return TRUE; -} - - -/*********************************************************************** - * k32OemToCharA (KERNEL32.12) - */ -BOOL WINAPI k32OemToCharA(LPCSTR s, LPSTR d) -{ - return k32OemToCharBuffA( s, d, strlen(s) + 1 ); -} - - -/********************************************************************** - * k32LoadStringA (KERNEL32.14) - */ -INT WINAPI k32LoadStringA(HINSTANCE instance, UINT resource_id, - LPSTR buffer, INT buflen) -{ - if(!pLoadStringA) pLoadStringA = user32_proc_address("LoadStringA"); - return pLoadStringA(instance, resource_id, buffer, buflen); -} - - -/*********************************************************************** - * k32wvsprintfA (KERNEL32.16) - */ -INT WINAPI k32wvsprintfA(LPSTR buffer, LPCSTR spec, __ms_va_list args) -{ - if(!pwvsprintfA) pwvsprintfA = user32_proc_address("wvsprintfA"); - return (*pwvsprintfA)(buffer, spec, args); -} - - -/*********************************************************************** - * k32wsprintfA (KERNEL32.15) - */ -INT WINAPIV k32wsprintfA(LPSTR buffer, LPCSTR spec, ...) -{ - __ms_va_list args; - INT res; - - __ms_va_start(args, spec); - res = k32wvsprintfA(buffer, spec, args); - __ms_va_end(args); - return res; -} - - /*********************************************************************** * lstrcatA (KERNEL32.@) * lstrcat (KERNEL32.@) diff --git a/dlls/kernel32/thunk.c b/dlls/kernel32/thunk.c index 5befee572cc..78ba2f73805 100644 --- a/dlls/kernel32/thunk.c +++ b/dlls/kernel32/thunk.c @@ -2176,6 +2176,103 @@ DWORD WINAPI _KERNEL32_99(DWORD x) } +/*********************************************************************** + * Helper for k32 family functions + */ +static void *user32_proc_address(const char *proc_name) +{ + static HMODULE hUser32; + + if(!hUser32) hUser32 = LoadLibraryA("user32.dll"); + return GetProcAddress(hUser32, proc_name); +} + +/*********************************************************************** + * k32CharToOemBuffA (KERNEL32.11) + */ +BOOL WINAPI k32CharToOemBuffA(LPCSTR s, LPSTR d, DWORD len) +{ + WCHAR *bufW; + + if ((bufW = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) ))) + { + MultiByteToWideChar( CP_ACP, 0, s, len, bufW, len ); + WideCharToMultiByte( CP_OEMCP, 0, bufW, len, d, len, NULL, NULL ); + HeapFree( GetProcessHeap(), 0, bufW ); + } + return TRUE; +} + +/*********************************************************************** + * k32CharToOemA (KERNEL32.10) + */ +BOOL WINAPI k32CharToOemA(LPCSTR s, LPSTR d) +{ + if (!s || !d) return TRUE; + return k32CharToOemBuffA( s, d, strlen(s) + 1 ); +} + +/*********************************************************************** + * k32OemToCharBuffA (KERNEL32.13) + */ +BOOL WINAPI k32OemToCharBuffA(LPCSTR s, LPSTR d, DWORD len) +{ + WCHAR *bufW; + + if ((bufW = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) ))) + { + MultiByteToWideChar( CP_OEMCP, 0, s, len, bufW, len ); + WideCharToMultiByte( CP_ACP, 0, bufW, len, d, len, NULL, NULL ); + HeapFree( GetProcessHeap(), 0, bufW ); + } + return TRUE; +} + +/*********************************************************************** + * k32OemToCharA (KERNEL32.12) + */ +BOOL WINAPI k32OemToCharA(LPCSTR s, LPSTR d) +{ + return k32OemToCharBuffA( s, d, strlen(s) + 1 ); +} + +/********************************************************************** + * k32LoadStringA (KERNEL32.14) + */ +INT WINAPI k32LoadStringA(HINSTANCE instance, UINT resource_id, + LPSTR buffer, INT buflen) +{ + static INT (WINAPI *pLoadStringA)(HINSTANCE, UINT, LPSTR, INT); + + if(!pLoadStringA) pLoadStringA = user32_proc_address("LoadStringA"); + return pLoadStringA(instance, resource_id, buffer, buflen); +} + +/*********************************************************************** + * k32wvsprintfA (KERNEL32.16) + */ +INT WINAPI k32wvsprintfA(LPSTR buffer, LPCSTR spec, __ms_va_list args) +{ + static INT (WINAPI *pwvsprintfA)(LPSTR, LPCSTR, __ms_va_list); + + if(!pwvsprintfA) pwvsprintfA = user32_proc_address("wvsprintfA"); + return (*pwvsprintfA)(buffer, spec, args); +} + +/*********************************************************************** + * k32wsprintfA (KERNEL32.15) + */ +INT WINAPIV k32wsprintfA(LPSTR buffer, LPCSTR spec, ...) +{ + __ms_va_list args; + INT res; + + __ms_va_start(args, spec); + res = k32wvsprintfA(buffer, spec, args); + __ms_va_end(args); + return res; +} + /********************************************************************** * Catch (KERNEL.55) *