2005-05-16 21:44:54 +02:00
|
|
|
/*
|
|
|
|
* 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
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2005-05-16 21:44:54 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __WINE_KERNEL16_PRIVATE_H
|
|
|
|
#define __WINE_KERNEL16_PRIVATE_H
|
|
|
|
|
|
|
|
#include "wine/winbase16.h"
|
|
|
|
#include "winreg.h"
|
|
|
|
#include "winternl.h"
|
|
|
|
|
|
|
|
#include "pshpack1.h"
|
|
|
|
|
2005-05-17 12:21:29 +02:00
|
|
|
/* In-memory module structure. See 'Windows Internals' p. 219 */
|
|
|
|
typedef struct _NE_MODULE
|
|
|
|
{
|
2005-05-17 16:36:09 +02:00
|
|
|
WORD ne_magic; /* 00 'NE' signature */
|
|
|
|
WORD count; /* 02 Usage count (ne_ver/ne_rev on disk) */
|
|
|
|
WORD ne_enttab; /* 04 Near ptr to entry table */
|
|
|
|
HMODULE16 next; /* 06 Selector to next module (ne_cbenttab on disk) */
|
|
|
|
WORD dgroup_entry; /* 08 Near ptr to segment entry for DGROUP (ne_crc on disk) */
|
|
|
|
WORD fileinfo; /* 0a Near ptr to file info (OFSTRUCT) (ne_crc on disk) */
|
|
|
|
WORD ne_flags; /* 0c Module flags */
|
|
|
|
WORD ne_autodata; /* 0e Logical segment for DGROUP */
|
|
|
|
WORD ne_heap; /* 10 Initial heap size */
|
|
|
|
WORD ne_stack; /* 12 Initial stack size */
|
|
|
|
DWORD ne_csip; /* 14 Initial cs:ip */
|
|
|
|
DWORD ne_sssp; /* 18 Initial ss:sp */
|
|
|
|
WORD ne_cseg; /* 1c Number of segments in segment table */
|
|
|
|
WORD ne_cmod; /* 1e Number of module references */
|
|
|
|
WORD ne_cbnrestab; /* 20 Size of non-resident names table */
|
|
|
|
WORD ne_segtab; /* 22 Near ptr to segment table */
|
|
|
|
WORD ne_rsrctab; /* 24 Near ptr to resource table */
|
|
|
|
WORD ne_restab; /* 26 Near ptr to resident names table */
|
|
|
|
WORD ne_modtab; /* 28 Near ptr to module reference table */
|
|
|
|
WORD ne_imptab; /* 2a Near ptr to imported names table */
|
|
|
|
DWORD ne_nrestab; /* 2c File offset of non-resident names table */
|
|
|
|
WORD ne_cmovent; /* 30 Number of moveable entries in entry table*/
|
|
|
|
WORD ne_align; /* 32 Alignment shift count */
|
|
|
|
WORD ne_cres; /* 34 # of resource segments */
|
|
|
|
BYTE ne_exetyp; /* 36 Operating system flags */
|
|
|
|
BYTE ne_flagsothers; /* 37 Misc. flags */
|
|
|
|
HANDLE16 dlls_to_init; /* 38 List of DLLs to initialize (ne_pretthunks on disk) */
|
|
|
|
HANDLE16 nrname_handle; /* 3a Handle to non-resident name table (ne_psegrefbytes on disk) */
|
|
|
|
WORD ne_swaparea; /* 3c Min. swap area size */
|
|
|
|
WORD ne_expver; /* 3e Expected Windows version */
|
2005-05-17 12:21:29 +02:00
|
|
|
/* From here, these are extra fields not present in normal Windows */
|
2005-05-19 14:05:28 +02:00
|
|
|
HMODULE module32; /* PE module handle for Win32 modules */
|
2005-05-23 14:15:26 +02:00
|
|
|
HMODULE owner32; /* PE module containing this one for 16-bit builtins */
|
2005-05-19 14:05:28 +02:00
|
|
|
HMODULE16 self; /* Handle for this module */
|
|
|
|
WORD self_loading_sel; /* Selector used for self-loading apps. */
|
|
|
|
LPVOID rsrc32_map; /* HRSRC 16->32 map (for 32-bit modules) */
|
|
|
|
LPCVOID mapping; /* mapping of the binary file */
|
|
|
|
SIZE_T mapping_size; /* size of the file mapping */
|
2005-05-17 12:21:29 +02:00
|
|
|
} NE_MODULE;
|
|
|
|
|
2005-05-18 20:27:54 +02:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
BYTE type;
|
|
|
|
BYTE flags;
|
|
|
|
BYTE segnum;
|
|
|
|
WORD offs;
|
|
|
|
} ET_ENTRY;
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
WORD first; /* ordinal */
|
|
|
|
WORD last; /* ordinal */
|
|
|
|
WORD next; /* bundle */
|
|
|
|
} ET_BUNDLE;
|
|
|
|
|
|
|
|
|
|
|
|
/* In-memory segment table */
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
WORD filepos; /* Position in file, in sectors */
|
|
|
|
WORD size; /* Segment size on disk */
|
|
|
|
WORD flags; /* Segment flags */
|
|
|
|
WORD minsize; /* Min. size of segment in memory */
|
|
|
|
HANDLE16 hSeg; /* Selector or handle (selector - 1) of segment in memory */
|
|
|
|
} SEGTABLEENTRY;
|
|
|
|
|
2005-05-16 21:44:54 +02:00
|
|
|
/* 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;
|
|
|
|
|
2005-05-23 14:07:15 +02:00
|
|
|
/* relay entry points */
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
WORD pushw_bp; /* pushw %bp */
|
|
|
|
BYTE pushl; /* pushl $target */
|
2009-10-06 12:56:33 +02:00
|
|
|
void *target;
|
2005-05-23 14:07:15 +02:00
|
|
|
WORD call; /* call CALLFROM16 */
|
|
|
|
short callfrom16;
|
|
|
|
} ENTRYPOINT16;
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
BYTE pushl; /* pushl $relay */
|
|
|
|
void *relay;
|
|
|
|
BYTE lcall; /* lcall __FLATCS__:glue */
|
|
|
|
void *glue;
|
|
|
|
WORD flatcs;
|
2005-09-18 14:25:22 +02:00
|
|
|
WORD ret[5]; /* return sequence */
|
|
|
|
WORD movl; /* movl arg_types[1],arg_types[0](%esi) */
|
2005-05-23 14:07:15 +02:00
|
|
|
DWORD arg_types[2]; /* type of each argument */
|
|
|
|
} CALLFROM16;
|
|
|
|
|
2005-05-16 21:44:54 +02:00
|
|
|
/* 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;
|
|
|
|
|
2009-10-06 12:56:33 +02:00
|
|
|
extern LONG __wine_call_from_16(void);
|
|
|
|
extern void __wine_call_from_16_regs(void);
|
2005-09-18 14:25:22 +02:00
|
|
|
|
2015-03-18 19:05:17 +01:00
|
|
|
extern THHOOK *pThhook DECLSPEC_HIDDEN;
|
2005-05-16 21:44:54 +02:00
|
|
|
|
|
|
|
#include "poppack.h"
|
|
|
|
|
|
|
|
#define NE_SEG_TABLE(pModule) \
|
2005-05-17 16:36:09 +02:00
|
|
|
((SEGTABLEENTRY *)((char *)(pModule) + (pModule)->ne_segtab))
|
2005-05-16 21:44:54 +02:00
|
|
|
|
|
|
|
#define NE_MODULE_NAME(pModule) \
|
|
|
|
(((OFSTRUCT *)((char*)(pModule) + (pModule)->fileinfo))->szPathName)
|
|
|
|
|
2005-05-19 14:05:28 +02:00
|
|
|
#define NE_GET_DATA(pModule,offset,size) \
|
|
|
|
((const void *)(((offset)+(size) <= pModule->mapping_size) ? \
|
|
|
|
(const char *)pModule->mapping + (offset) : NULL))
|
|
|
|
|
|
|
|
#define NE_READ_DATA(pModule,buffer,offset,size) \
|
|
|
|
(((offset)+(size) <= pModule->mapping_size) ? \
|
|
|
|
(memcpy( buffer, (const char *)pModule->mapping + (offset), (size) ), TRUE) : FALSE)
|
|
|
|
|
2007-05-30 12:31:52 +02:00
|
|
|
#define CURRENT_STACK16 ((STACK16FRAME*)MapSL(PtrToUlong(NtCurrentTeb()->WOW32Reserved)))
|
2005-05-16 21:44:54 +02:00
|
|
|
#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;
|
|
|
|
}
|
|
|
|
|
2009-10-08 19:25:30 +02:00
|
|
|
/* dosmem.c */
|
2015-03-18 19:05:17 +01:00
|
|
|
extern BOOL DOSMEM_Init(void) DECLSPEC_HIDDEN;
|
|
|
|
extern BOOL DOSMEM_InitDosMemory(void) DECLSPEC_HIDDEN;
|
|
|
|
extern LPVOID DOSMEM_MapRealToLinear(DWORD) DECLSPEC_HIDDEN; /* real-mode to linear */
|
|
|
|
extern LPVOID DOSMEM_MapDosToLinear(UINT) DECLSPEC_HIDDEN; /* linear DOS to Wine */
|
|
|
|
extern UINT DOSMEM_MapLinearToDos(LPVOID) DECLSPEC_HIDDEN; /* linear Wine to DOS */
|
|
|
|
extern BOOL DOSMEM_MapDosLayout(void) DECLSPEC_HIDDEN;
|
|
|
|
extern LPVOID DOSMEM_AllocBlock(UINT size, WORD* p) DECLSPEC_HIDDEN;
|
|
|
|
extern BOOL DOSMEM_FreeBlock(void* ptr) DECLSPEC_HIDDEN;
|
|
|
|
extern UINT DOSMEM_ResizeBlock(void* ptr, UINT size, BOOL exact) DECLSPEC_HIDDEN;
|
|
|
|
extern UINT DOSMEM_Available(void) DECLSPEC_HIDDEN;
|
2009-10-08 19:25:30 +02:00
|
|
|
|
2009-09-28 19:59:09 +02:00
|
|
|
/* global16.c */
|
|
|
|
extern HGLOBAL16 GLOBAL_CreateBlock( UINT16 flags, void *ptr, DWORD size,
|
2015-03-18 19:05:17 +01:00
|
|
|
HGLOBAL16 hOwner, unsigned char selflags ) DECLSPEC_HIDDEN;
|
|
|
|
extern BOOL16 GLOBAL_FreeBlock( HGLOBAL16 handle ) DECLSPEC_HIDDEN;
|
|
|
|
extern BOOL16 GLOBAL_MoveBlock( HGLOBAL16 handle, void *ptr, DWORD size ) DECLSPEC_HIDDEN;
|
|
|
|
extern HGLOBAL16 GLOBAL_Alloc( WORD flags, DWORD size, HGLOBAL16 hOwner, unsigned char selflags ) DECLSPEC_HIDDEN;
|
2009-09-28 19:59:09 +02:00
|
|
|
|
2009-10-08 19:25:30 +02:00
|
|
|
/* instr.c */
|
2015-03-18 19:05:17 +01:00
|
|
|
extern DWORD __wine_emulate_instruction( EXCEPTION_RECORD *rec, CONTEXT *context ) DECLSPEC_HIDDEN;
|
|
|
|
extern LONG CALLBACK INSTR_vectored_handler( EXCEPTION_POINTERS *ptrs ) DECLSPEC_HIDDEN;
|
2009-10-08 19:25:30 +02:00
|
|
|
|
2005-05-16 21:44:54 +02:00
|
|
|
/* ne_module.c */
|
2015-03-18 19:05:17 +01:00
|
|
|
extern NE_MODULE *NE_GetPtr( HMODULE16 hModule ) DECLSPEC_HIDDEN;
|
|
|
|
extern WORD NE_GetOrdinal( HMODULE16 hModule, const char *name ) DECLSPEC_HIDDEN;
|
|
|
|
extern FARPROC16 WINAPI NE_GetEntryPoint( HMODULE16 hModule, WORD ordinal ) DECLSPEC_HIDDEN;
|
|
|
|
extern FARPROC16 NE_GetEntryPointEx( HMODULE16 hModule, WORD ordinal, BOOL16 snoop ) DECLSPEC_HIDDEN;
|
|
|
|
extern BOOL16 NE_SetEntryPoint( HMODULE16 hModule, WORD ordinal, WORD offset ) DECLSPEC_HIDDEN;
|
|
|
|
extern DWORD NE_StartTask(void) DECLSPEC_HIDDEN;
|
2005-05-16 21:44:54 +02:00
|
|
|
|
|
|
|
/* ne_segment.c */
|
2015-03-18 19:05:17 +01:00
|
|
|
extern BOOL NE_LoadSegment( NE_MODULE *pModule, WORD segnum ) DECLSPEC_HIDDEN;
|
|
|
|
extern BOOL NE_LoadAllSegments( NE_MODULE *pModule ) DECLSPEC_HIDDEN;
|
|
|
|
extern BOOL NE_CreateSegment( NE_MODULE *pModule, int segnum ) DECLSPEC_HIDDEN;
|
|
|
|
extern BOOL NE_CreateAllSegments( NE_MODULE *pModule ) DECLSPEC_HIDDEN;
|
|
|
|
extern HINSTANCE16 NE_GetInstance( NE_MODULE *pModule ) DECLSPEC_HIDDEN;
|
|
|
|
extern void NE_InitializeDLLs( HMODULE16 hModule ) DECLSPEC_HIDDEN;
|
|
|
|
extern void NE_DllProcessAttach( HMODULE16 hModule ) DECLSPEC_HIDDEN;
|
|
|
|
extern void NE_CallUserSignalProc( HMODULE16 hModule, UINT16 code ) DECLSPEC_HIDDEN;
|
2005-05-16 21:44:54 +02:00
|
|
|
|
|
|
|
/* selector.c */
|
2015-03-18 19:05:17 +01:00
|
|
|
extern WORD SELECTOR_AllocBlock( const void *base, DWORD size, unsigned char flags ) DECLSPEC_HIDDEN;
|
|
|
|
extern WORD SELECTOR_ReallocBlock( WORD sel, const void *base, DWORD size ) DECLSPEC_HIDDEN;
|
|
|
|
extern void SELECTOR_FreeBlock( WORD sel ) DECLSPEC_HIDDEN;
|
2005-05-16 21:44:54 +02:00
|
|
|
#define IS_SELECTOR_32BIT(sel) \
|
|
|
|
(wine_ldt_is_system(sel) || (wine_ldt_copy.flags[LOWORD(sel) >> 3] & WINE_LDT_FLAGS_32BIT))
|
|
|
|
|
2005-07-05 14:52:07 +02:00
|
|
|
/* relay16.c */
|
2015-03-18 19:05:17 +01:00
|
|
|
extern int relay_call_from_16( void *entry_point, unsigned char *args16, CONTEXT *context ) DECLSPEC_HIDDEN;
|
|
|
|
extern void RELAY16_InitDebugLists(void) DECLSPEC_HIDDEN;
|
2005-07-05 14:52:07 +02:00
|
|
|
|
2005-05-18 11:58:43 +02:00
|
|
|
/* snoop16.c */
|
2015-03-18 19:05:17 +01:00
|
|
|
extern void SNOOP16_RegisterDLL(HMODULE16,LPCSTR) DECLSPEC_HIDDEN;
|
|
|
|
extern FARPROC16 SNOOP16_GetProcAddress16(HMODULE16,DWORD,FARPROC16) DECLSPEC_HIDDEN;
|
|
|
|
extern BOOL SNOOP16_ShowDebugmsgSnoop(const char *dll,int ord,const char *fname) DECLSPEC_HIDDEN;
|
2005-05-18 11:58:43 +02:00
|
|
|
|
2009-12-28 17:26:55 +01:00
|
|
|
/* syslevel.c */
|
2015-03-18 19:05:17 +01:00
|
|
|
extern VOID SYSLEVEL_CheckNotLevel( INT level ) DECLSPEC_HIDDEN;
|
2009-12-28 17:26:55 +01:00
|
|
|
|
2005-05-16 21:44:54 +02:00
|
|
|
/* task.c */
|
2015-03-18 19:05:17 +01:00
|
|
|
extern void TASK_CreateMainTask(void) DECLSPEC_HIDDEN;
|
2005-05-16 21:44:54 +02:00
|
|
|
extern HTASK16 TASK_SpawnTask( NE_MODULE *pModule, WORD cmdShow,
|
2015-03-18 19:05:17 +01:00
|
|
|
LPCSTR cmdline, BYTE len, HANDLE *hThread ) DECLSPEC_HIDDEN;
|
|
|
|
extern void TASK_ExitTask(void) DECLSPEC_HIDDEN;
|
|
|
|
extern HTASK16 TASK_GetTaskFromThread( DWORD thread ) DECLSPEC_HIDDEN;
|
|
|
|
extern TDB *TASK_GetCurrent(void) DECLSPEC_HIDDEN;
|
|
|
|
extern void TASK_InstallTHHook( THHOOK *pNewThook ) DECLSPEC_HIDDEN;
|
|
|
|
|
|
|
|
extern BOOL WOWTHUNK_Init(void) DECLSPEC_HIDDEN;
|
|
|
|
|
|
|
|
extern WORD DOSMEM_0000H DECLSPEC_HIDDEN;
|
|
|
|
extern WORD DOSMEM_BiosDataSeg DECLSPEC_HIDDEN;
|
|
|
|
extern WORD DOSMEM_BiosSysSeg DECLSPEC_HIDDEN;
|
|
|
|
extern DWORD CallTo16_DataSelector DECLSPEC_HIDDEN;
|
|
|
|
extern DWORD CallTo16_TebSelector DECLSPEC_HIDDEN;
|
|
|
|
extern SEGPTR CALL32_CBClient_RetAddr DECLSPEC_HIDDEN;
|
|
|
|
extern SEGPTR CALL32_CBClientEx_RetAddr DECLSPEC_HIDDEN;
|
2005-07-01 18:24:32 +02:00
|
|
|
|
2009-12-28 17:26:55 +01:00
|
|
|
struct tagSYSLEVEL;
|
|
|
|
|
|
|
|
struct kernel_thread_data
|
|
|
|
{
|
|
|
|
WORD stack_sel; /* 16-bit stack selector */
|
|
|
|
WORD htask16; /* Win16 task handle */
|
|
|
|
DWORD sys_count[4]; /* syslevel mutex entry counters */
|
|
|
|
struct tagSYSLEVEL *sys_mutex[4]; /* syslevel mutex pointers */
|
|
|
|
void *pad[45]; /* change this if you add fields! */
|
|
|
|
};
|
|
|
|
|
|
|
|
static inline struct kernel_thread_data *kernel_get_thread_data(void)
|
|
|
|
{
|
|
|
|
return (struct kernel_thread_data *)NtCurrentTeb()->SystemReserved1;
|
|
|
|
}
|
|
|
|
|
2009-10-08 19:25:30 +02:00
|
|
|
#define DEFINE_REGS_ENTRYPOINT( name, args ) \
|
|
|
|
__ASM_GLOBAL_FUNC( name, \
|
|
|
|
".byte 0x68\n\t" /* pushl $__regs_func */ \
|
|
|
|
".long " __ASM_NAME("__regs_") #name "-.-11\n\t" \
|
|
|
|
".byte 0x6a," #args "\n\t" /* pushl $args */ \
|
2010-01-16 15:41:48 +01:00
|
|
|
"call " __ASM_NAME("__wine_call_from_regs") "\n\t" \
|
2009-10-08 19:25:30 +02:00
|
|
|
"ret $(4*" #args ")" ) /* fake ret to make copy protections happy */
|
|
|
|
|
2005-05-16 21:44:54 +02:00
|
|
|
#endif /* __WINE_KERNEL16_PRIVATE_H */
|