push 9ed7f32abbb93ea3a813fd6b1650e5bcfc506606
[wine/hacks.git] / dlls / ntdll / ntdll_misc.h
blob4f64421d6422a36f5c621fee22b1e091a6ff48bc
1 /*
2 * Copyright 2000 Juergen Schmied
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 #ifndef __WINE_NTDLL_MISC_H
20 #define __WINE_NTDLL_MISC_H
22 #include <stdarg.h>
23 #include <signal.h>
25 #include "windef.h"
26 #include "winnt.h"
27 #include "winternl.h"
28 #include "wine/server.h"
30 #define MAX_NT_PATH_LENGTH 277
32 #define MAX_DOS_DRIVES 26
34 struct drive_info
36 dev_t dev;
37 ino_t ino;
40 /* exceptions */
41 extern void wait_suspend( CONTEXT *context );
42 extern void WINAPI __regs_RtlRaiseException( PEXCEPTION_RECORD, PCONTEXT );
43 extern void get_cpu_context( CONTEXT *context );
44 extern void set_cpu_context( const CONTEXT *context );
46 /* debug helper */
47 extern LPCSTR debugstr_us( const UNICODE_STRING *str );
48 extern void dump_ObjectAttributes (const OBJECT_ATTRIBUTES *ObjectAttributes);
50 extern NTSTATUS NTDLL_queue_process_apc( HANDLE process, const apc_call_t *call, apc_result_t *result );
51 extern NTSTATUS NTDLL_wait_for_multiple_objects( UINT count, const HANDLE *handles, UINT flags,
52 const LARGE_INTEGER *timeout, HANDLE signal_object );
54 /* init routines */
55 extern BOOL SIGNAL_Init(void);
56 extern size_t get_signal_stack_total_size(void);
57 extern void version_init( const WCHAR *appname );
58 extern void debug_init(void);
59 extern HANDLE thread_init(void);
60 extern void actctx_init(void);
61 extern void virtual_init(void);
62 extern void virtual_init_threading(void);
64 /* server support */
65 extern timeout_t server_start_time;
66 extern void server_init_process(void);
67 extern NTSTATUS server_init_process_done(void);
68 extern size_t server_init_thread( int unix_pid, int unix_tid, void *entry_point );
69 extern void DECLSPEC_NORETURN server_protocol_error( const char *err, ... );
70 extern void DECLSPEC_NORETURN server_protocol_perror( const char *err );
71 extern void DECLSPEC_NORETURN server_exit_thread( int status );
72 extern void DECLSPEC_NORETURN server_abort_thread( int status );
73 extern sigset_t server_block_set;
74 extern void server_enter_uninterrupted_section( RTL_CRITICAL_SECTION *cs, sigset_t *sigset );
75 extern void server_leave_uninterrupted_section( RTL_CRITICAL_SECTION *cs, sigset_t *sigset );
76 extern int server_remove_fd_from_cache( obj_handle_t handle );
77 extern int server_get_unix_fd( obj_handle_t handle, unsigned int access, int *unix_fd,
78 int *needs_close, enum server_fd_type *type, unsigned int *options );
80 /* module handling */
81 extern NTSTATUS MODULE_DllThreadAttach( LPVOID lpReserved );
82 extern FARPROC RELAY_GetProcAddress( HMODULE module, const IMAGE_EXPORT_DIRECTORY *exports,
83 DWORD exp_size, FARPROC proc, DWORD ordinal, const WCHAR *user );
84 extern FARPROC SNOOP_GetProcAddress( HMODULE hmod, const IMAGE_EXPORT_DIRECTORY *exports, DWORD exp_size,
85 FARPROC origfun, DWORD ordinal, const WCHAR *user );
86 extern void RELAY_SetupDLL( HMODULE hmod );
87 extern void SNOOP_SetupDLL( HMODULE hmod );
88 extern UNICODE_STRING windows_dir;
89 extern UNICODE_STRING system_dir;
91 /* redefine these to make sure we don't reference kernel symbols */
92 #define GetProcessHeap() (NtCurrentTeb()->Peb->ProcessHeap)
93 #define GetCurrentProcessId() (HandleToULong(NtCurrentTeb()->ClientId.UniqueProcess))
94 #define GetCurrentThreadId() (HandleToULong(NtCurrentTeb()->ClientId.UniqueThread))
96 /* Device IO */
97 extern NTSTATUS CDROM_DeviceIoControl(HANDLE hDevice,
98 HANDLE hEvent, PIO_APC_ROUTINE UserApcRoutine,
99 PVOID UserApcContext,
100 PIO_STATUS_BLOCK piosb,
101 ULONG IoControlCode,
102 LPVOID lpInBuffer, DWORD nInBufferSize,
103 LPVOID lpOutBuffer, DWORD nOutBufferSize);
104 extern NTSTATUS COMM_DeviceIoControl(HANDLE hDevice,
105 HANDLE hEvent, PIO_APC_ROUTINE UserApcRoutine,
106 PVOID UserApcContext,
107 PIO_STATUS_BLOCK piosb,
108 ULONG IoControlCode,
109 LPVOID lpInBuffer, DWORD nInBufferSize,
110 LPVOID lpOutBuffer, DWORD nOutBufferSize);
111 extern NTSTATUS TAPE_DeviceIoControl(HANDLE hDevice,
112 HANDLE hEvent, PIO_APC_ROUTINE UserApcRoutine,
113 PVOID UserApcContext,
114 PIO_STATUS_BLOCK piosb,
115 ULONG IoControlCode,
116 LPVOID lpInBuffer, DWORD nInBufferSize,
117 LPVOID lpOutBuffer, DWORD nOutBufferSize);
119 /* file I/O */
120 extern NTSTATUS FILE_GetNtStatus(void);
121 extern BOOL DIR_is_hidden_file( const UNICODE_STRING *name );
122 extern NTSTATUS DIR_unmount_device( HANDLE handle );
123 extern NTSTATUS DIR_get_unix_cwd( char **cwd );
124 extern unsigned int DIR_get_drives_info( struct drive_info info[MAX_DOS_DRIVES] );
126 /* virtual memory */
127 extern NTSTATUS VIRTUAL_HandleFault(LPCVOID addr);
128 extern void VIRTUAL_SetForceExec( BOOL enable );
129 extern void VIRTUAL_UseLargeAddressSpace(void);
130 extern struct _KUSER_SHARED_DATA *user_shared_data;
132 /* code pages */
133 extern int ntdll_umbstowcs(DWORD flags, const char* src, int srclen, WCHAR* dst, int dstlen);
134 extern int ntdll_wcstoumbs(DWORD flags, const WCHAR* src, int srclen, char* dst, int dstlen,
135 const char* defchar, int *used );
137 /* load order */
139 enum loadorder
141 LO_INVALID,
142 LO_DISABLED,
143 LO_NATIVE,
144 LO_BUILTIN,
145 LO_NATIVE_BUILTIN, /* native then builtin */
146 LO_BUILTIN_NATIVE, /* builtin then native */
147 LO_DEFAULT /* nothing specified, use default strategy */
150 extern enum loadorder get_load_order( const WCHAR *app_name, const WCHAR *path );
152 struct debug_info
154 char *str_pos; /* current position in strings buffer */
155 char *out_pos; /* current position in output buffer */
156 char strings[1024]; /* buffer for temporary strings */
157 char output[1024]; /* current output line */
160 /* thread private data, stored in NtCurrentTeb()->SystemReserved2 */
161 struct ntdll_thread_data
163 DWORD fs; /* 1d4 TEB selector */
164 DWORD gs; /* 1d8 libc selector; update winebuild if you move this! */
165 struct debug_info *debug_info; /* 1dc info for debugstr functions */
166 int request_fd; /* 1e0 fd for sending server requests */
167 int reply_fd; /* 1e4 fd for receiving server replies */
168 int wait_fd[2]; /* 1e8 fd for sleeping server requests */
169 void *vm86_ptr; /* 1f0 data for vm86 mode */
171 void *pad[2]; /* 1f4 change this if you add fields! */
174 static inline struct ntdll_thread_data *ntdll_get_thread_data(void)
176 return (struct ntdll_thread_data *)NtCurrentTeb()->SystemReserved2;
179 /* thread debug_registers, stored in NtCurrentTeb()->SpareBytes1 */
180 struct ntdll_thread_regs
182 DWORD dr0;
183 DWORD dr1;
184 DWORD dr2;
185 DWORD dr3;
186 DWORD dr6;
187 DWORD dr7;
190 static inline struct ntdll_thread_regs *ntdll_get_thread_regs(void)
192 return (struct ntdll_thread_regs *)NtCurrentTeb()->SpareBytes1;
195 #endif