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

Moved 16-bit relay and snoop support to dlls/kernel.

parent 1df015ae
...@@ -5,6 +5,7 @@ kernel32.dll.dbg.c ...@@ -5,6 +5,7 @@ kernel32.dll.dbg.c
kernel32.spec.c kernel32.spec.c
kernel32.spec.def kernel32.spec.def
krnl386.exe.spec.c krnl386.exe.spec.c
relay16asm.s
stress.spec.c stress.spec.c
system.drv.spec.c system.drv.spec.c
toolhelp.spec.c toolhelp.spec.c
......
...@@ -38,8 +38,10 @@ C_SRCS = \ ...@@ -38,8 +38,10 @@ C_SRCS = \
ne_segment.c \ ne_segment.c \
powermgnt.c \ powermgnt.c \
process.c \ process.c \
relay16.c \
resource.c \ resource.c \
resource16.c \ resource16.c \
snoop16.c \
stress.c \ stress.c \
string.c \ string.c \
sync.c \ sync.c \
...@@ -59,6 +61,8 @@ C_SRCS16 = \ ...@@ -59,6 +61,8 @@ C_SRCS16 = \
registry16.c \ registry16.c \
system.c system.c
ASM_SRCS = relay16asm.s
RC_SRCS = kernel.rc RC_SRCS = kernel.rc
RC_SRCS16 = \ RC_SRCS16 = \
...@@ -67,6 +71,7 @@ RC_SRCS16 = \ ...@@ -67,6 +71,7 @@ RC_SRCS16 = \
MC_SRCS = \ MC_SRCS = \
messages/winerr_enu.mc messages/winerr_enu.mc
EXTRA_OBJS = $(ASM_SRCS:.s=.o)
SUBDIRS = tests SUBDIRS = tests
EXTRASUBDIRS = messages nls EXTRASUBDIRS = messages nls
...@@ -74,6 +79,9 @@ EXTRASUBDIRS = messages nls ...@@ -74,6 +79,9 @@ EXTRASUBDIRS = messages nls
kernel.res: $(MC_SRCS:.mc=.mc.rc) kernel.res: $(MC_SRCS:.mc=.mc.rc)
relay16asm.s: $(WINEBUILD)
$(WINEBUILD) $(DEFS) -o $@ --relay16
# Special rules for 16-bit resource and spec files # Special rules for 16-bit resource and spec files
krnl386.exe.spec.c: krnl386.exe.spec version16.res krnl386.exe.spec.c: krnl386.exe.spec version16.res
......
...@@ -210,6 +210,16 @@ void __wine_unregister_dll_16( const BUILTIN16_DESCRIPTOR *descr ) ...@@ -210,6 +210,16 @@ void __wine_unregister_dll_16( const BUILTIN16_DESCRIPTOR *descr )
} }
/**********************************************************************
* NE_RegisterModule
*/
void NE_RegisterModule( NE_MODULE *pModule )
{
pModule->next = hFirstModule;
hFirstModule = pModule->self;
}
/*********************************************************************** /***********************************************************************
* NE_DumpModule * NE_DumpModule
*/ */
...@@ -364,6 +374,143 @@ void NE_WalkModules(void) ...@@ -364,6 +374,143 @@ void NE_WalkModules(void)
/*********************************************************************** /***********************************************************************
* NE_InitResourceHandler
*
* Fill in 'resloader' fields in the resource table.
*/
void NE_InitResourceHandler( NE_MODULE *pModule )
{
static FARPROC16 proc;
NE_TYPEINFO *pTypeInfo = (NE_TYPEINFO *)((char *)pModule + pModule->res_table + 2);
TRACE("InitResourceHandler[%04x]\n", pModule->self );
if (!proc) proc = GetProcAddress16( GetModuleHandle16("KERNEL"), "DefResourceHandler" );
while(pTypeInfo->type_id)
{
memcpy_unaligned( &pTypeInfo->resloader, &proc, sizeof(FARPROC16) );
pTypeInfo = (NE_TYPEINFO *)((char*)(pTypeInfo + 1) + pTypeInfo->count * sizeof(NE_NAMEINFO));
}
}
/***********************************************************************
* NE_GetOrdinal
*
* Lookup the ordinal for a given name.
*/
WORD NE_GetOrdinal( HMODULE16 hModule, const char *name )
{
unsigned char buffer[256], *cpnt;
BYTE len;
NE_MODULE *pModule;
if (!(pModule = NE_GetPtr( hModule ))) return 0;
if (pModule->flags & NE_FFLAGS_WIN32) return 0;
TRACE("(%04x,'%s')\n", hModule, name );
/* First handle names of the form '#xxxx' */
if (name[0] == '#') return atoi( name + 1 );
/* Now copy and uppercase the string */
strcpy( buffer, name );
for (cpnt = buffer; *cpnt; cpnt++) *cpnt = FILE_toupper(*cpnt);
len = cpnt - buffer;
/* First search the resident names */
cpnt = (char *)pModule + pModule->name_table;
/* Skip the first entry (module name) */
cpnt += *cpnt + 1 + sizeof(WORD);
while (*cpnt)
{
if (((BYTE)*cpnt == len) && !memcmp( cpnt+1, buffer, len ))
{
WORD ordinal;
memcpy( &ordinal, cpnt + *cpnt + 1, sizeof(ordinal) );
TRACE(" Found: ordinal=%d\n", ordinal );
return ordinal;
}
cpnt += *cpnt + 1 + sizeof(WORD);
}
/* Now search the non-resident names table */
if (!pModule->nrname_handle) return 0; /* No non-resident table */
cpnt = (char *)GlobalLock16( pModule->nrname_handle );
/* Skip the first entry (module description string) */
cpnt += *cpnt + 1 + sizeof(WORD);
while (*cpnt)
{
if (((BYTE)*cpnt == len) && !memcmp( cpnt+1, buffer, len ))
{
WORD ordinal;
memcpy( &ordinal, cpnt + *cpnt + 1, sizeof(ordinal) );
TRACE(" Found: ordinal=%d\n", ordinal );
return ordinal;
}
cpnt += *cpnt + 1 + sizeof(WORD);
}
return 0;
}
/***********************************************************************
* NE_GetEntryPoint
*/
FARPROC16 WINAPI NE_GetEntryPoint( HMODULE16 hModule, WORD ordinal )
{
return NE_GetEntryPointEx( hModule, ordinal, TRUE );
}
/***********************************************************************
* NE_GetEntryPointEx
*/
FARPROC16 NE_GetEntryPointEx( HMODULE16 hModule, WORD ordinal, BOOL16 snoop )
{
NE_MODULE *pModule;
WORD sel, offset, i;
ET_ENTRY *entry;
ET_BUNDLE *bundle;
if (!(pModule = NE_GetPtr( hModule ))) return 0;
assert( !(pModule->flags & NE_FFLAGS_WIN32) );
bundle = (ET_BUNDLE *)((BYTE *)pModule + pModule->entry_table);
while ((ordinal < bundle->first + 1) || (ordinal > bundle->last))
{
if (!(bundle->next))
return 0;
bundle = (ET_BUNDLE *)((BYTE *)pModule + bundle->next);
}
entry = (ET_ENTRY *)((BYTE *)bundle+6);
for (i=0; i < (ordinal - bundle->first - 1); i++)
entry++;
sel = entry->segnum;
memcpy( &offset, &entry->offs, sizeof(WORD) );
if (sel == 0xfe) sel = 0xffff; /* constant entry */
else sel = GlobalHandleToSel16(NE_SEG_TABLE(pModule)[sel-1].hSeg);
if (sel==0xffff)
return (FARPROC16)MAKESEGPTR( sel, offset );
if (!snoop)
return (FARPROC16)MAKESEGPTR( sel, offset );
else
return (FARPROC16)SNOOP16_GetProcAddress16(hModule,ordinal,(FARPROC16)MAKESEGPTR( sel, offset ));
}
/***********************************************************************
* EntryAddrProc (KERNEL.667) Wine-specific export * EntryAddrProc (KERNEL.667) Wine-specific export
* *
* Return the entry point for a given ordinal. * Return the entry point for a given ordinal.
...@@ -1566,6 +1713,66 @@ HINSTANCE16 WINAPI WinExec16( LPCSTR lpCmdLine, UINT16 nCmdShow ) ...@@ -1566,6 +1713,66 @@ HINSTANCE16 WINAPI WinExec16( LPCSTR lpCmdLine, UINT16 nCmdShow )
return ret; return ret;
} }
/***********************************************************************
* GetProcAddress (KERNEL.50)
*/
FARPROC16 WINAPI GetProcAddress16( HMODULE16 hModule, LPCSTR name )
{
WORD ordinal;
FARPROC16 ret;
if (!hModule) hModule = GetCurrentTask();
hModule = GetExePtr( hModule );
if (HIWORD(name) != 0)
{
ordinal = NE_GetOrdinal( hModule, name );
TRACE("%04x '%s'\n", hModule, name );
}
else
{
ordinal = LOWORD(name);
TRACE("%04x %04x\n", hModule, ordinal );
}
if (!ordinal) return (FARPROC16)0;
ret = NE_GetEntryPoint( hModule, ordinal );
TRACE("returning %08x\n", (UINT)ret );
return ret;
}
/***************************************************************************
* HasGPHandler (KERNEL.338)
*/
SEGPTR WINAPI HasGPHandler16( SEGPTR address )
{
HMODULE16 hModule;
int gpOrdinal;
SEGPTR gpPtr;
GPHANDLERDEF *gpHandler;
if ( (hModule = FarGetOwner16( SELECTOROF(address) )) != 0
&& (gpOrdinal = NE_GetOrdinal( hModule, "__GP" )) != 0
&& (gpPtr = (SEGPTR)NE_GetEntryPointEx( hModule, gpOrdinal, FALSE )) != 0
&& !IsBadReadPtr16( gpPtr, sizeof(GPHANDLERDEF) )
&& (gpHandler = MapSL( gpPtr )) != NULL )
{
while (gpHandler->selector)
{
if ( SELECTOROF(address) == gpHandler->selector
&& OFFSETOF(address) >= gpHandler->rangeStart
&& OFFSETOF(address) < gpHandler->rangeEnd )
return MAKESEGPTR( gpHandler->selector, gpHandler->handler );
gpHandler++;
}
}
return 0;
}
/********************************************************************** /**********************************************************************
* GetModuleHandle (KERNEL.47) * GetModuleHandle (KERNEL.47)
* *
......
...@@ -2,5 +2,4 @@ Makefile ...@@ -2,5 +2,4 @@ Makefile
ntdll.dll.dbg.c ntdll.dll.dbg.c
ntdll.spec.c ntdll.spec.c
ntdll.spec.def ntdll.spec.def
relay16.s
relay32.s relay32.s
...@@ -13,8 +13,6 @@ C_SRCS = \ ...@@ -13,8 +13,6 @@ C_SRCS = \
$(TOPOBJDIR)/files/file.c \ $(TOPOBJDIR)/files/file.c \
$(TOPOBJDIR)/files/profile.c \ $(TOPOBJDIR)/files/profile.c \
$(TOPOBJDIR)/files/smb.c \ $(TOPOBJDIR)/files/smb.c \
$(TOPOBJDIR)/if1632/relay.c \
$(TOPOBJDIR)/if1632/snoop.c \
$(TOPOBJDIR)/loader/loadorder.c \ $(TOPOBJDIR)/loader/loadorder.c \
$(TOPOBJDIR)/loader/module.c \ $(TOPOBJDIR)/loader/module.c \
$(TOPOBJDIR)/loader/pe_image.c \ $(TOPOBJDIR)/loader/pe_image.c \
...@@ -83,9 +81,7 @@ C_SRCS = \ ...@@ -83,9 +81,7 @@ C_SRCS = \
virtual.c \ virtual.c \
wcstring.c wcstring.c
ASM_SRCS = \ ASM_SRCS = relay32.s
relay16.s \
relay32.s
EXTRA_OBJS = $(ASM_SRCS:.s=.o) EXTRA_OBJS = $(ASM_SRCS:.s=.o)
...@@ -93,7 +89,6 @@ SUBDIRS = tests ...@@ -93,7 +89,6 @@ SUBDIRS = tests
EXTRASUBDIRS = \ EXTRASUBDIRS = \
$(TOPOBJDIR)/files \ $(TOPOBJDIR)/files \
$(TOPOBJDIR)/if1632 \
$(TOPOBJDIR)/loader \ $(TOPOBJDIR)/loader \
$(TOPOBJDIR)/loader/ne \ $(TOPOBJDIR)/loader/ne \
$(TOPOBJDIR)/memory \ $(TOPOBJDIR)/memory \
...@@ -105,9 +100,6 @@ EXTRASUBDIRS = \ ...@@ -105,9 +100,6 @@ EXTRASUBDIRS = \
@MAKE_DLL_RULES@ @MAKE_DLL_RULES@
relay16.s: $(WINEBUILD)
$(WINEBUILD) $(DEFS) -o $@ --relay16
relay32.s: $(WINEBUILD) relay32.s: $(WINEBUILD)
$(WINEBUILD) $(DEFS) -o $@ --relay32 $(WINEBUILD) $(DEFS) -o $@ --relay32
......
...@@ -72,153 +72,6 @@ NE_MODULE *NE_GetPtr( HMODULE16 hModule ) ...@@ -72,153 +72,6 @@ NE_MODULE *NE_GetPtr( HMODULE16 hModule )
/********************************************************************** /**********************************************************************
* NE_RegisterModule
*/
void NE_RegisterModule( NE_MODULE *pModule )
{
pModule->next = hFirstModule;
hFirstModule = pModule->self;
}
/***********************************************************************
* NE_InitResourceHandler
*
* Fill in 'resloader' fields in the resource table.
*/
void NE_InitResourceHandler( NE_MODULE *pModule )
{
static FARPROC16 proc;
NE_TYPEINFO *pTypeInfo = (NE_TYPEINFO *)((char *)pModule + pModule->res_table + 2);
TRACE("InitResourceHandler[%04x]\n", pModule->self );
if (!proc) proc = GetProcAddress16( GetModuleHandle16("KERNEL"), "DefResourceHandler" );
while(pTypeInfo->type_id)
{
memcpy_unaligned( &pTypeInfo->resloader, &proc, sizeof(FARPROC16) );
pTypeInfo = (NE_TYPEINFO *)((char*)(pTypeInfo + 1) + pTypeInfo->count * sizeof(NE_NAMEINFO));
}
}
/***********************************************************************
* NE_GetOrdinal
*
* Lookup the ordinal for a given name.
*/
WORD NE_GetOrdinal( HMODULE16 hModule, const char *name )
{
unsigned char buffer[256], *cpnt;
BYTE len;
NE_MODULE *pModule;
if (!(pModule = NE_GetPtr( hModule ))) return 0;
if (pModule->flags & NE_FFLAGS_WIN32) return 0;
TRACE("(%04x,'%s')\n", hModule, name );
/* First handle names of the form '#xxxx' */
if (name[0] == '#') return atoi( name + 1 );
/* Now copy and uppercase the string */
strcpy( buffer, name );
for (cpnt = buffer; *cpnt; cpnt++) *cpnt = FILE_toupper(*cpnt);
len = cpnt - buffer;
/* First search the resident names */
cpnt = (char *)pModule + pModule->name_table;
/* Skip the first entry (module name) */
cpnt += *cpnt + 1 + sizeof(WORD);
while (*cpnt)
{
if (((BYTE)*cpnt == len) && !memcmp( cpnt+1, buffer, len ))
{
WORD ordinal;
memcpy( &ordinal, cpnt + *cpnt + 1, sizeof(ordinal) );
TRACE(" Found: ordinal=%d\n", ordinal );
return ordinal;
}
cpnt += *cpnt + 1 + sizeof(WORD);
}
/* Now search the non-resident names table */
if (!pModule->nrname_handle) return 0; /* No non-resident table */
cpnt = (char *)GlobalLock16( pModule->nrname_handle );
/* Skip the first entry (module description string) */
cpnt += *cpnt + 1 + sizeof(WORD);
while (*cpnt)
{
if (((BYTE)*cpnt == len) && !memcmp( cpnt+1, buffer, len ))
{
WORD ordinal;
memcpy( &ordinal, cpnt + *cpnt + 1, sizeof(ordinal) );
TRACE(" Found: ordinal=%d\n", ordinal );
return ordinal;
}
cpnt += *cpnt + 1 + sizeof(WORD);
}
return 0;
}
/***********************************************************************
* NE_GetEntryPoint
*/
FARPROC16 WINAPI NE_GetEntryPoint( HMODULE16 hModule, WORD ordinal )
{
return NE_GetEntryPointEx( hModule, ordinal, TRUE );
}
/***********************************************************************
* NE_GetEntryPointEx
*/
FARPROC16 NE_GetEntryPointEx( HMODULE16 hModule, WORD ordinal, BOOL16 snoop )
{
NE_MODULE *pModule;
WORD sel, offset, i;
ET_ENTRY *entry;
ET_BUNDLE *bundle;
if (!(pModule = NE_GetPtr( hModule ))) return 0;
assert( !(pModule->flags & NE_FFLAGS_WIN32) );
bundle = (ET_BUNDLE *)((BYTE *)pModule + pModule->entry_table);
while ((ordinal < bundle->first + 1) || (ordinal > bundle->last))
{
if (!(bundle->next))
return 0;
bundle = (ET_BUNDLE *)((BYTE *)pModule + bundle->next);
}
entry = (ET_ENTRY *)((BYTE *)bundle+6);
for (i=0; i < (ordinal - bundle->first - 1); i++)
entry++;
sel = entry->segnum;
memcpy( &offset, &entry->offs, sizeof(WORD) );
if (sel == 0xfe) sel = 0xffff; /* constant entry */
else sel = GlobalHandleToSel16(NE_SEG_TABLE(pModule)[sel-1].hSeg);
if (sel==0xffff)
return (FARPROC16)MAKESEGPTR( sel, offset );
if (!snoop)
return (FARPROC16)MAKESEGPTR( sel, offset );
else
return (FARPROC16)SNOOP16_GetProcAddress16(hModule,ordinal,(FARPROC16)MAKESEGPTR( sel, offset ));
}
/**********************************************************************
* GetModuleFileName (KERNEL.49) * GetModuleFileName (KERNEL.49)
* *
* Comment: see GetModuleFileNameA * Comment: see GetModuleFileNameA
...@@ -342,62 +195,3 @@ HMODULE16 WINAPI GetModuleHandle16( LPCSTR name ) ...@@ -342,62 +195,3 @@ HMODULE16 WINAPI GetModuleHandle16( LPCSTR name )
} }
return 0; return 0;
} }
/***********************************************************************
* GetProcAddress (KERNEL.50)
*/
FARPROC16 WINAPI GetProcAddress16( HMODULE16 hModule, LPCSTR name )
{
WORD ordinal;
FARPROC16 ret;
if (!hModule) hModule = GetCurrentTask();
hModule = GetExePtr( hModule );
if (HIWORD(name) != 0)
{
ordinal = NE_GetOrdinal( hModule, name );
TRACE("%04x '%s'\n", hModule, name );
}
else
{
ordinal = LOWORD(name);
TRACE("%04x %04x\n", hModule, ordinal );
}
if (!ordinal) return (FARPROC16)0;
ret = NE_GetEntryPoint( hModule, ordinal );
TRACE("returning %08x\n", (UINT)ret );
return ret;
}
/***************************************************************************
* HasGPHandler (KERNEL.338)
*/
SEGPTR WINAPI HasGPHandler16( SEGPTR address )
{
HMODULE16 hModule;
int gpOrdinal;
SEGPTR gpPtr;
GPHANDLERDEF *gpHandler;
if ( (hModule = FarGetOwner16( SELECTOROF(address) )) != 0
&& (gpOrdinal = NE_GetOrdinal( hModule, "__GP" )) != 0
&& (gpPtr = (SEGPTR)NE_GetEntryPointEx( hModule, gpOrdinal, FALSE )) != 0
&& !IsBadReadPtr16( gpPtr, sizeof(GPHANDLERDEF) )
&& (gpHandler = MapSL( gpPtr )) != NULL )
{
while (gpHandler->selector)
{
if ( SELECTOROF(address) == gpHandler->selector
&& OFFSETOF(address) >= gpHandler->rangeStart
&& OFFSETOF(address) < gpHandler->rangeEnd )
return MAKESEGPTR( gpHandler->selector, gpHandler->handler );
gpHandler++;
}
}
return 0;
}
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