toolhelp: Avoid using libwine functions.

Signed-off-by: Alexandre Julliard <julliard@winehq.org>
stable
Alexandre Julliard 2019-05-21 17:52:50 +02:00
parent 0d7d0427d0
commit e5590cbe6a
2 changed files with 8 additions and 13 deletions

View File

@ -709,6 +709,8 @@
@ stdcall -arch=win32 GetExeVersion16()
@ stdcall -arch=win32 GetExpWinVer16(long)
@ stdcall -arch=win32 GetModuleHandle16(str)
@ stdcall -arch=win32 GetSelectorBase(long)
@ stdcall -arch=win32 GetSelectorLimit16(long)
@ stdcall -arch=win32 GlobalReAlloc16(long long long)
@ stdcall -arch=win32 InitTask16(ptr)
@ stdcall -arch=win32 IsBadReadPtr16(long long)

View File

@ -36,7 +36,6 @@
#include "wine/winbase16.h"
#include "toolhelp.h"
#include "wine/library.h"
#include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL(toolhelp);
@ -639,15 +638,12 @@ void WINAPI TerminateApp16(HTASK16 hTask, WORD wFlags)
*/
DWORD WINAPI MemoryRead16( WORD sel, DWORD offset, void *buffer, DWORD count )
{
LDT_ENTRY entry;
DWORD limit;
char *base = (char *)GetSelectorBase( sel );
DWORD limit = GetSelectorLimit16( sel );
wine_ldt_get_entry( sel, &entry );
if (wine_ldt_is_empty( &entry )) return 0;
limit = wine_ldt_get_limit( &entry );
if (offset > limit) return 0;
if (offset + count > limit + 1) count = limit + 1 - offset;
memcpy( buffer, (char *)wine_ldt_get_base(&entry) + offset, count );
memcpy( buffer, base + offset, count );
return count;
}
@ -657,15 +653,12 @@ DWORD WINAPI MemoryRead16( WORD sel, DWORD offset, void *buffer, DWORD count )
*/
DWORD WINAPI MemoryWrite16( WORD sel, DWORD offset, void *buffer, DWORD count )
{
LDT_ENTRY entry;
DWORD limit;
char *base = (char *)GetSelectorBase( sel );
DWORD limit = GetSelectorLimit16( sel );
wine_ldt_get_entry( sel, &entry );
if (wine_ldt_is_empty( &entry )) return 0;
limit = wine_ldt_get_limit( &entry );
if (offset > limit) return 0;
if (offset + count > limit) count = limit + 1 - offset;
memcpy( (char *)wine_ldt_get_base(&entry) + offset, buffer, count );
memcpy( base + offset, buffer, count );
return count;
}