From 4776085c9c1145839488e41feb80353bcf1be2ab Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Mon, 16 May 2005 19:44:54 +0000 Subject: [PATCH] Moved a bunch of definitions out of module.h into a new kernel16_private.h header. --- dlls/kernel/atom16.c | 1 + dlls/kernel/debugger.c | 1 + dlls/kernel/global16.c | 1 + dlls/kernel/instr.c | 2 +- dlls/kernel/kernel16_private.h | 124 +++++++++++++++++++++++++++++++++ dlls/kernel/kernel_main.c | 2 +- dlls/kernel/kernel_private.h | 59 +++++----------- dlls/kernel/local16.c | 2 +- dlls/kernel/ne_module.c | 2 +- dlls/kernel/ne_segment.c | 2 +- dlls/kernel/relay16.c | 2 +- dlls/kernel/resource16.c | 2 +- dlls/kernel/snoop16.c | 2 +- dlls/kernel/system.c | 1 + dlls/kernel/task.c | 2 +- dlls/kernel/thunk.c | 2 +- dlls/kernel/wowthunk.c | 2 +- include/module.h | 70 ------------------- 18 files changed, 155 insertions(+), 124 deletions(-) create mode 100644 dlls/kernel/kernel16_private.h diff --git a/dlls/kernel/atom16.c b/dlls/kernel/atom16.c index d38ea54791..601225e758 100644 --- a/dlls/kernel/atom16.c +++ b/dlls/kernel/atom16.c @@ -42,6 +42,7 @@ #include "wine/unicode.h" #include "wine/winbase16.h" #include "kernel_private.h" +#include "kernel16_private.h" #include "wine/debug.h" diff --git a/dlls/kernel/debugger.c b/dlls/kernel/debugger.c index a648ccb922..45900997f7 100644 --- a/dlls/kernel/debugger.c +++ b/dlls/kernel/debugger.c @@ -26,6 +26,7 @@ #include "wine/server.h" #include "ntstatus.h" #include "kernel_private.h" +#include "kernel16_private.h" #include "wine/debug.h" WINE_DEFAULT_DEBUG_CHANNEL(debugstr); diff --git a/dlls/kernel/global16.c b/dlls/kernel/global16.c index 7ca503a7a8..251238c431 100644 --- a/dlls/kernel/global16.c +++ b/dlls/kernel/global16.c @@ -41,6 +41,7 @@ #include "ntstatus.h" #include "toolhelp.h" #include "kernel_private.h" +#include "kernel16_private.h" #include "wine/debug.h" #include "winerror.h" diff --git a/dlls/kernel/instr.c b/dlls/kernel/instr.c index 18e995e3d6..dd23f36649 100644 --- a/dlls/kernel/instr.c +++ b/dlls/kernel/instr.c @@ -30,9 +30,9 @@ #include "wine/winuser16.h" #include "excpt.h" #include "thread.h" -#include "module.h" #include "wine/debug.h" #include "kernel_private.h" +#include "kernel16_private.h" #include "wine/exception.h" WINE_DEFAULT_DEBUG_CHANNEL(int); diff --git a/dlls/kernel/kernel16_private.h b/dlls/kernel/kernel16_private.h new file mode 100644 index 0000000000..c2e50f7303 --- /dev/null +++ b/dlls/kernel/kernel16_private.h @@ -0,0 +1,124 @@ +/* + * Kernel 16-bit private definitions + * + * Copyright 1995 Alexandre Julliard + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef __WINE_KERNEL16_PRIVATE_H +#define __WINE_KERNEL16_PRIVATE_H + +#include "wine/winbase16.h" +#include "winreg.h" +#include "winternl.h" +#include "module.h" + +#include "pshpack1.h" + +/* this structure is always located at offset 0 of the DGROUP segment */ +typedef struct +{ + WORD null; /* Always 0 */ + DWORD old_ss_sp; /* Stack pointer; used by SwitchTaskTo() */ + WORD heap; /* Pointer to the local heap information (if any) */ + WORD atomtable; /* Pointer to the local atom table (if any) */ + WORD stacktop; /* Top of the stack */ + WORD stackmin; /* Lowest stack address used so far */ + WORD stackbottom; /* Bottom of the stack */ +} INSTANCEDATA; + +/* THHOOK Kernel Data Structure */ +typedef struct _THHOOK +{ + HANDLE16 hGlobalHeap; /* 00 (handle BURGERMASTER) */ + WORD pGlobalHeap; /* 02 (selector BURGERMASTER) */ + HMODULE16 hExeHead; /* 04 hFirstModule */ + HMODULE16 hExeSweep; /* 06 (unused) */ + HANDLE16 TopPDB; /* 08 (handle of KERNEL PDB) */ + HANDLE16 HeadPDB; /* 0A (first PDB in list) */ + HANDLE16 TopSizePDB; /* 0C (unused) */ + HTASK16 HeadTDB; /* 0E hFirstTask */ + HTASK16 CurTDB; /* 10 hCurrentTask */ + HTASK16 LoadTDB; /* 12 (unused) */ + HTASK16 LockTDB; /* 14 hLockedTask */ +} THHOOK; + +extern THHOOK *pThhook; + +#include "poppack.h" + +#define NE_SEG_TABLE(pModule) \ + ((SEGTABLEENTRY *)((char *)(pModule) + (pModule)->seg_table)) + +#define NE_MODULE_NAME(pModule) \ + (((OFSTRUCT *)((char*)(pModule) + (pModule)->fileinfo))->szPathName) + +#define CURRENT_STACK16 ((STACK16FRAME*)MapSL((SEGPTR)NtCurrentTeb()->WOW32Reserved)) +#define CURRENT_DS (CURRENT_STACK16->ds) + +/* push bytes on the 16-bit stack of a thread; return a segptr to the first pushed byte */ +static inline SEGPTR stack16_push( int size ) +{ + STACK16FRAME *frame = CURRENT_STACK16; + memmove( (char*)frame - size, frame, sizeof(*frame) ); + NtCurrentTeb()->WOW32Reserved = (char *)NtCurrentTeb()->WOW32Reserved - size; + return (SEGPTR)((char *)NtCurrentTeb()->WOW32Reserved + sizeof(*frame)); +} + +/* pop bytes from the 16-bit stack of a thread */ +static inline void stack16_pop( int size ) +{ + STACK16FRAME *frame = CURRENT_STACK16; + memmove( (char*)frame + size, frame, sizeof(*frame) ); + NtCurrentTeb()->WOW32Reserved = (char *)NtCurrentTeb()->WOW32Reserved + size; +} + +/* ne_module.c */ +extern NE_MODULE *NE_GetPtr( HMODULE16 hModule ); +extern WORD NE_GetOrdinal( HMODULE16 hModule, const char *name ); +extern FARPROC16 WINAPI NE_GetEntryPoint( HMODULE16 hModule, WORD ordinal ); +extern FARPROC16 NE_GetEntryPointEx( HMODULE16 hModule, WORD ordinal, BOOL16 snoop ); +extern BOOL16 NE_SetEntryPoint( HMODULE16 hModule, WORD ordinal, WORD offset ); +extern HANDLE NE_OpenFile( NE_MODULE *pModule ); +extern DWORD NE_StartTask(void); + +/* ne_segment.c */ +extern BOOL NE_LoadSegment( NE_MODULE *pModule, WORD segnum ); +extern BOOL NE_LoadAllSegments( NE_MODULE *pModule ); +extern BOOL NE_CreateSegment( NE_MODULE *pModule, int segnum ); +extern BOOL NE_CreateAllSegments( NE_MODULE *pModule ); +extern HINSTANCE16 NE_GetInstance( NE_MODULE *pModule ); +extern void NE_InitializeDLLs( HMODULE16 hModule ); +extern void NE_DllProcessAttach( HMODULE16 hModule ); +extern void NE_CallUserSignalProc( HMODULE16 hModule, UINT16 code ); + +/* selector.c */ +extern WORD SELECTOR_AllocBlock( const void *base, DWORD size, unsigned char flags ); +extern WORD SELECTOR_ReallocBlock( WORD sel, const void *base, DWORD size ); +extern void SELECTOR_FreeBlock( WORD sel ); +#define IS_SELECTOR_32BIT(sel) \ + (wine_ldt_is_system(sel) || (wine_ldt_copy.flags[LOWORD(sel) >> 3] & WINE_LDT_FLAGS_32BIT)) + +/* task.c */ +extern void TASK_CreateMainTask(void); +extern HTASK16 TASK_SpawnTask( NE_MODULE *pModule, WORD cmdShow, + LPCSTR cmdline, BYTE len, HANDLE *hThread ); +extern void TASK_ExitTask(void); +extern HTASK16 TASK_GetTaskFromThread( DWORD thread ); +extern TDB *TASK_GetCurrent(void); +extern void TASK_InstallTHHook( THHOOK *pNewThook ); + +#endif /* __WINE_KERNEL16_PRIVATE_H */ diff --git a/dlls/kernel/kernel_main.c b/dlls/kernel/kernel_main.c index aaada84bed..5ede144ef1 100644 --- a/dlls/kernel/kernel_main.c +++ b/dlls/kernel/kernel_main.c @@ -39,10 +39,10 @@ #include "wine/winbase16.h" #include "wine/library.h" -#include "module.h" #include "wincon.h" #include "toolhelp.h" #include "kernel_private.h" +#include "kernel16_private.h" #include "console_private.h" extern void LOCALE_InitRegistry(void); diff --git a/dlls/kernel/kernel_private.h b/dlls/kernel/kernel_private.h index de96d856ba..8da81745aa 100644 --- a/dlls/kernel/kernel_private.h +++ b/dlls/kernel/kernel_private.h @@ -21,9 +21,6 @@ #ifndef __WINE_KERNEL_PRIVATE_H #define __WINE_KERNEL_PRIVATE_H -#include "wine/winbase16.h" -#include "thread.h" - HANDLE WINAPI OpenConsoleW(LPCWSTR, DWORD, BOOL, DWORD); BOOL WINAPI VerifyConsoleIoHandle(HANDLE); HANDLE WINAPI DuplicateConsoleHandle(HANDLE, DWORD, BOOL, DWORD); @@ -47,26 +44,6 @@ static inline HANDLE console_handle_unmap(HANDLE h) return h != INVALID_HANDLE_VALUE ? (HANDLE)((DWORD)h ^ 3) : INVALID_HANDLE_VALUE; } -#define CURRENT_STACK16 ((STACK16FRAME*)MapSL((SEGPTR)NtCurrentTeb()->WOW32Reserved)) -#define CURRENT_DS (CURRENT_STACK16->ds) - -/* push bytes on the 16-bit stack of a thread; return a segptr to the first pushed byte */ -static inline SEGPTR stack16_push( int size ) -{ - STACK16FRAME *frame = CURRENT_STACK16; - memmove( (char*)frame - size, frame, sizeof(*frame) ); - NtCurrentTeb()->WOW32Reserved = (char *)NtCurrentTeb()->WOW32Reserved - size; - return (SEGPTR)((char *)NtCurrentTeb()->WOW32Reserved + sizeof(*frame)); -} - -/* pop bytes from the 16-bit stack of a thread */ -static inline void stack16_pop( int size ) -{ - STACK16FRAME *frame = CURRENT_STACK16; - memmove( (char*)frame + size, frame, sizeof(*frame) ); - NtCurrentTeb()->WOW32Reserved = (char *)NtCurrentTeb()->WOW32Reserved + size; -} - extern HMODULE kernel32_handle; /* Size of per-process table of DOS handles */ @@ -88,36 +65,32 @@ extern DWORD FILE_name_WtoA( LPCWSTR src, INT srclen, LPSTR dest, INT destlen ); extern DWORD INSTR_EmulateInstruction( EXCEPTION_RECORD *rec, CONTEXT86 *context ); extern void INSTR_CallBuiltinHandler( CONTEXT86 *context, BYTE intnum ); +/* return values for MODULE_GetBinaryType */ +enum binary_type +{ + BINARY_UNKNOWN, + BINARY_PE_EXE, + BINARY_PE_DLL, + BINARY_WIN16, + BINARY_OS216, + BINARY_DOS, + BINARY_UNIX_EXE, + BINARY_UNIX_LIB +}; + +/* module.c */ extern WCHAR *MODULE_get_dll_load_path( LPCWSTR module ); +extern enum binary_type MODULE_GetBinaryType( HANDLE hfile, void **res_start, void **res_end ); extern BOOL NLS_IsUnicodeOnlyLcid(LCID); -extern WORD SELECTOR_AllocBlock( const void *base, DWORD size, unsigned char flags ); -extern WORD SELECTOR_ReallocBlock( WORD sel, const void *base, DWORD size ); -extern void SELECTOR_FreeBlock( WORD sel ); -#define IS_SELECTOR_32BIT(sel) \ - (wine_ldt_is_system(sel) || (wine_ldt_copy.flags[LOWORD(sel) >> 3] & WINE_LDT_FLAGS_32BIT)) - extern HANDLE VXD_Open( LPCWSTR filename, DWORD access, LPSECURITY_ATTRIBUTES sa ); -/* this structure is always located at offset 0 of the DGROUP segment */ -#include "pshpack1.h" -typedef struct -{ - WORD null; /* Always 0 */ - DWORD old_ss_sp; /* Stack pointer; used by SwitchTaskTo() */ - WORD heap; /* Pointer to the local heap information (if any) */ - WORD atomtable; /* Pointer to the local atom table (if any) */ - WORD stacktop; /* Top of the stack */ - WORD stackmin; /* Lowest stack address used so far */ - WORD stackbottom; /* Bottom of the stack */ -} INSTANCEDATA; -#include "poppack.h" extern WORD DOSMEM_0000H; extern WORD DOSMEM_BiosDataSeg; extern WORD DOSMEM_BiosSysSeg; -/* msdos/dosmem.c */ +/* dosmem.c */ extern BOOL DOSMEM_Init(void); extern WORD DOSMEM_AllocSelector(WORD); extern LPVOID DOSMEM_MapRealToLinear(DWORD); /* real-mode to linear */ diff --git a/dlls/kernel/local16.c b/dlls/kernel/local16.c index c993207a79..bc352c8f11 100644 --- a/dlls/kernel/local16.c +++ b/dlls/kernel/local16.c @@ -35,9 +35,9 @@ #include #include "wine/winbase16.h" #include "wownt32.h" -#include "module.h" #include "toolhelp.h" #include "kernel_private.h" +#include "kernel16_private.h" #include "wine/debug.h" WINE_DEFAULT_DEBUG_CHANNEL(local); diff --git a/dlls/kernel/ne_module.c b/dlls/kernel/ne_module.c index 95869dd652..31fc86cace 100644 --- a/dlls/kernel/ne_module.c +++ b/dlls/kernel/ne_module.c @@ -35,10 +35,10 @@ #include "windef.h" #include "wine/winbase16.h" #include "wownt32.h" -#include "module.h" #include "toolhelp.h" #include "excpt.h" #include "kernel_private.h" +#include "kernel16_private.h" #include "wine/exception.h" #include "wine/debug.h" diff --git a/dlls/kernel/ne_segment.c b/dlls/kernel/ne_segment.c index 37e540576b..e5d7d77392 100644 --- a/dlls/kernel/ne_segment.c +++ b/dlls/kernel/ne_segment.c @@ -37,7 +37,7 @@ #include "wownt32.h" #include "wine/library.h" #include "kernel_private.h" -#include "module.h" +#include "kernel16_private.h" #include "toolhelp.h" #include "wine/debug.h" diff --git a/dlls/kernel/relay16.c b/dlls/kernel/relay16.c index 2c2f5ff64f..4efb85100c 100644 --- a/dlls/kernel/relay16.c +++ b/dlls/kernel/relay16.c @@ -29,8 +29,8 @@ #include "windef.h" #include "winbase.h" #include "wine/winbase16.h" -#include "module.h" #include "kernel_private.h" +#include "kernel16_private.h" #include "wine/unicode.h" #include "wine/library.h" #include "wine/debug.h" diff --git a/dlls/kernel/resource16.c b/dlls/kernel/resource16.c index 3e51435096..d00af6250a 100644 --- a/dlls/kernel/resource16.c +++ b/dlls/kernel/resource16.c @@ -36,7 +36,7 @@ #include "wine/winbase16.h" #include "wine/winuser16.h" #include "wine/unicode.h" -#include "module.h" +#include "kernel16_private.h" #include "wine/debug.h" WINE_DEFAULT_DEBUG_CHANNEL(resource); diff --git a/dlls/kernel/snoop16.c b/dlls/kernel/snoop16.c index 449fece558..19055d365f 100644 --- a/dlls/kernel/snoop16.c +++ b/dlls/kernel/snoop16.c @@ -31,7 +31,7 @@ #include "wine/winbase16.h" #include "wine/library.h" #include "kernel_private.h" -#include "module.h" +#include "kernel16_private.h" #include "toolhelp.h" #include "wine/debug.h" diff --git a/dlls/kernel/system.c b/dlls/kernel/system.c index b21c9132cd..82461c53e6 100644 --- a/dlls/kernel/system.c +++ b/dlls/kernel/system.c @@ -29,6 +29,7 @@ #include "wine/winuser16.h" #include "wownt32.h" #include "kernel_private.h" +#include "kernel16_private.h" #include "wine/debug.h" WINE_DEFAULT_DEBUG_CHANNEL(system); diff --git a/dlls/kernel/task.c b/dlls/kernel/task.c index 28f116590d..922adbd283 100644 --- a/dlls/kernel/task.c +++ b/dlls/kernel/task.c @@ -38,11 +38,11 @@ #include "wine/winbase16.h" #include "thread.h" -#include "module.h" #include "winternl.h" #include "wine/server.h" #include "toolhelp.h" #include "kernel_private.h" +#include "kernel16_private.h" #include "wine/debug.h" diff --git a/dlls/kernel/thunk.c b/dlls/kernel/thunk.c index 30ac039170..393d8a7477 100644 --- a/dlls/kernel/thunk.c +++ b/dlls/kernel/thunk.c @@ -42,8 +42,8 @@ #include "wine/debug.h" #include "wine/library.h" -#include "module.h" #include "kernel_private.h" +#include "kernel16_private.h" WINE_DEFAULT_DEBUG_CHANNEL(thunk); diff --git a/dlls/kernel/wowthunk.c b/dlls/kernel/wowthunk.c index 276dddd5ae..8b237aecb6 100644 --- a/dlls/kernel/wowthunk.c +++ b/dlls/kernel/wowthunk.c @@ -33,8 +33,8 @@ #include "thread.h" #include "winreg.h" #include "winternl.h" -#include "module.h" #include "kernel_private.h" +#include "kernel16_private.h" #include "wine/exception.h" #include "wine/debug.h" diff --git a/include/module.h b/include/module.h index fbc7ed58a3..902bb14ee2 100644 --- a/include/module.h +++ b/include/module.h @@ -100,36 +100,8 @@ typedef struct /* of segment in memory */ } SEGTABLEENTRY; - - /* THHOOK Kernel Data Structure */ -typedef struct _THHOOK -{ - HANDLE16 hGlobalHeap; /* 00 (handle BURGERMASTER) */ - WORD pGlobalHeap; /* 02 (selector BURGERMASTER) */ - HMODULE16 hExeHead; /* 04 hFirstModule */ - HMODULE16 hExeSweep; /* 06 (unused) */ - HANDLE16 TopPDB; /* 08 (handle of KERNEL PDB) */ - HANDLE16 HeadPDB; /* 0A (first PDB in list) */ - HANDLE16 TopSizePDB; /* 0C (unused) */ - HTASK16 HeadTDB; /* 0E hFirstTask */ - HTASK16 CurTDB; /* 10 hCurrentTask */ - HTASK16 LoadTDB; /* 12 (unused) */ - HTASK16 LockTDB; /* 14 hLockedTask */ -} THHOOK; - -extern THHOOK *pThhook; - #include -/* Resource types */ - -#define NE_SEG_TABLE(pModule) \ - ((SEGTABLEENTRY *)((char *)(pModule) + (pModule)->seg_table)) - -#define NE_MODULE_NAME(pModule) \ - (((OFSTRUCT *)((char*)(pModule) + (pModule)->fileinfo))->szPathName) - - enum loadorder_type { LOADORDER_INVALID = 0, /* Must be 0 */ @@ -138,54 +110,12 @@ enum loadorder_type LOADORDER_NTYPES }; -/* return values for MODULE_GetBinaryType */ -enum binary_type -{ - BINARY_UNKNOWN, - BINARY_PE_EXE, - BINARY_PE_DLL, - BINARY_WIN16, - BINARY_OS216, - BINARY_DOS, - BINARY_UNIX_EXE, - BINARY_UNIX_LIB -}; - /* module.c */ extern NTSTATUS MODULE_DllThreadAttach( LPVOID lpReserved ); -extern enum binary_type MODULE_GetBinaryType( HANDLE hfile, void **res_start, void **res_end ); - -/* ne_module.c */ -extern NE_MODULE *NE_GetPtr( HMODULE16 hModule ); -extern WORD NE_GetOrdinal( HMODULE16 hModule, const char *name ); -extern FARPROC16 WINAPI NE_GetEntryPoint( HMODULE16 hModule, WORD ordinal ); -extern FARPROC16 NE_GetEntryPointEx( HMODULE16 hModule, WORD ordinal, BOOL16 snoop ); -extern BOOL16 NE_SetEntryPoint( HMODULE16 hModule, WORD ordinal, WORD offset ); -extern HANDLE NE_OpenFile( NE_MODULE *pModule ); -extern DWORD NE_StartTask(void); /* resource16.c */ extern HGLOBAL16 WINAPI NE_DefResourceHandler(HGLOBAL16,HMODULE16,HRSRC16); -/* ne_segment.c */ -extern BOOL NE_LoadSegment( NE_MODULE *pModule, WORD segnum ); -extern BOOL NE_LoadAllSegments( NE_MODULE *pModule ); -extern BOOL NE_CreateSegment( NE_MODULE *pModule, int segnum ); -extern BOOL NE_CreateAllSegments( NE_MODULE *pModule ); -extern HINSTANCE16 NE_GetInstance( NE_MODULE *pModule ); -extern void NE_InitializeDLLs( HMODULE16 hModule ); -extern void NE_DllProcessAttach( HMODULE16 hModule ); -extern void NE_CallUserSignalProc( HMODULE16 hModule, UINT16 code ); - -/* task.c */ -extern void TASK_CreateMainTask(void); -extern HTASK16 TASK_SpawnTask( NE_MODULE *pModule, WORD cmdShow, - LPCSTR cmdline, BYTE len, HANDLE *hThread ); -extern void TASK_ExitTask(void); -extern HTASK16 TASK_GetTaskFromThread( DWORD thread ); -extern TDB *TASK_GetCurrent(void); -extern void TASK_InstallTHHook( THHOOK *pNewThook ); - /* loadorder.c */ extern void MODULE_GetLoadOrderW( enum loadorder_type plo[], const WCHAR *app_name, const WCHAR *path );