Moved a bunch of definitions out of module.h into a new
[wine/testsucceed.git] / dlls / kernel / kernel16_private.h
blobc2e50f73030caf3d44a86853925b5f9b179b2492
1 /*
2 * Kernel 16-bit private definitions
4 * Copyright 1995 Alexandre Julliard
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 #ifndef __WINE_KERNEL16_PRIVATE_H
22 #define __WINE_KERNEL16_PRIVATE_H
24 #include "wine/winbase16.h"
25 #include "winreg.h"
26 #include "winternl.h"
27 #include "module.h"
29 #include "pshpack1.h"
31 /* this structure is always located at offset 0 of the DGROUP segment */
32 typedef struct
34 WORD null; /* Always 0 */
35 DWORD old_ss_sp; /* Stack pointer; used by SwitchTaskTo() */
36 WORD heap; /* Pointer to the local heap information (if any) */
37 WORD atomtable; /* Pointer to the local atom table (if any) */
38 WORD stacktop; /* Top of the stack */
39 WORD stackmin; /* Lowest stack address used so far */
40 WORD stackbottom; /* Bottom of the stack */
41 } INSTANCEDATA;
43 /* THHOOK Kernel Data Structure */
44 typedef struct _THHOOK
46 HANDLE16 hGlobalHeap; /* 00 (handle BURGERMASTER) */
47 WORD pGlobalHeap; /* 02 (selector BURGERMASTER) */
48 HMODULE16 hExeHead; /* 04 hFirstModule */
49 HMODULE16 hExeSweep; /* 06 (unused) */
50 HANDLE16 TopPDB; /* 08 (handle of KERNEL PDB) */
51 HANDLE16 HeadPDB; /* 0A (first PDB in list) */
52 HANDLE16 TopSizePDB; /* 0C (unused) */
53 HTASK16 HeadTDB; /* 0E hFirstTask */
54 HTASK16 CurTDB; /* 10 hCurrentTask */
55 HTASK16 LoadTDB; /* 12 (unused) */
56 HTASK16 LockTDB; /* 14 hLockedTask */
57 } THHOOK;
59 extern THHOOK *pThhook;
61 #include "poppack.h"
63 #define NE_SEG_TABLE(pModule) \
64 ((SEGTABLEENTRY *)((char *)(pModule) + (pModule)->seg_table))
66 #define NE_MODULE_NAME(pModule) \
67 (((OFSTRUCT *)((char*)(pModule) + (pModule)->fileinfo))->szPathName)
69 #define CURRENT_STACK16 ((STACK16FRAME*)MapSL((SEGPTR)NtCurrentTeb()->WOW32Reserved))
70 #define CURRENT_DS (CURRENT_STACK16->ds)
72 /* push bytes on the 16-bit stack of a thread; return a segptr to the first pushed byte */
73 static inline SEGPTR stack16_push( int size )
75 STACK16FRAME *frame = CURRENT_STACK16;
76 memmove( (char*)frame - size, frame, sizeof(*frame) );
77 NtCurrentTeb()->WOW32Reserved = (char *)NtCurrentTeb()->WOW32Reserved - size;
78 return (SEGPTR)((char *)NtCurrentTeb()->WOW32Reserved + sizeof(*frame));
81 /* pop bytes from the 16-bit stack of a thread */
82 static inline void stack16_pop( int size )
84 STACK16FRAME *frame = CURRENT_STACK16;
85 memmove( (char*)frame + size, frame, sizeof(*frame) );
86 NtCurrentTeb()->WOW32Reserved = (char *)NtCurrentTeb()->WOW32Reserved + size;
89 /* ne_module.c */
90 extern NE_MODULE *NE_GetPtr( HMODULE16 hModule );
91 extern WORD NE_GetOrdinal( HMODULE16 hModule, const char *name );
92 extern FARPROC16 WINAPI NE_GetEntryPoint( HMODULE16 hModule, WORD ordinal );
93 extern FARPROC16 NE_GetEntryPointEx( HMODULE16 hModule, WORD ordinal, BOOL16 snoop );
94 extern BOOL16 NE_SetEntryPoint( HMODULE16 hModule, WORD ordinal, WORD offset );
95 extern HANDLE NE_OpenFile( NE_MODULE *pModule );
96 extern DWORD NE_StartTask(void);
98 /* ne_segment.c */
99 extern BOOL NE_LoadSegment( NE_MODULE *pModule, WORD segnum );
100 extern BOOL NE_LoadAllSegments( NE_MODULE *pModule );
101 extern BOOL NE_CreateSegment( NE_MODULE *pModule, int segnum );
102 extern BOOL NE_CreateAllSegments( NE_MODULE *pModule );
103 extern HINSTANCE16 NE_GetInstance( NE_MODULE *pModule );
104 extern void NE_InitializeDLLs( HMODULE16 hModule );
105 extern void NE_DllProcessAttach( HMODULE16 hModule );
106 extern void NE_CallUserSignalProc( HMODULE16 hModule, UINT16 code );
108 /* selector.c */
109 extern WORD SELECTOR_AllocBlock( const void *base, DWORD size, unsigned char flags );
110 extern WORD SELECTOR_ReallocBlock( WORD sel, const void *base, DWORD size );
111 extern void SELECTOR_FreeBlock( WORD sel );
112 #define IS_SELECTOR_32BIT(sel) \
113 (wine_ldt_is_system(sel) || (wine_ldt_copy.flags[LOWORD(sel) >> 3] & WINE_LDT_FLAGS_32BIT))
115 /* task.c */
116 extern void TASK_CreateMainTask(void);
117 extern HTASK16 TASK_SpawnTask( NE_MODULE *pModule, WORD cmdShow,
118 LPCSTR cmdline, BYTE len, HANDLE *hThread );
119 extern void TASK_ExitTask(void);
120 extern HTASK16 TASK_GetTaskFromThread( DWORD thread );
121 extern TDB *TASK_GetCurrent(void);
122 extern void TASK_InstallTHHook( THHOOK *pNewThook );
124 #endif /* __WINE_KERNEL16_PRIVATE_H */