wined3d: Restore blitting environment after modifying it.
[wine/testsucceed.git] / dlls / ntdll / ntdll_misc.h
blob443b2812ae63d490db072cf79ab8dce7abd8ed7c
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 "winioctl.h"
29 #include "wine/server.h"
31 #define MAX_NT_PATH_LENGTH 277
33 /* exceptions */
34 extern void wait_suspend( CONTEXT *context );
35 extern void WINAPI __regs_RtlRaiseException( PEXCEPTION_RECORD, PCONTEXT );
36 extern void get_cpu_context( CONTEXT *context );
37 extern void set_cpu_context( const CONTEXT *context );
39 /* debug helper */
40 extern LPCSTR debugstr_us( const UNICODE_STRING *str );
41 extern void dump_ObjectAttributes (const OBJECT_ATTRIBUTES *ObjectAttributes);
43 extern void NTDLL_get_server_abstime( abs_time_t *when, const LARGE_INTEGER *timeout );
44 extern void NTDLL_from_server_abstime( LARGE_INTEGER *time, const abs_time_t *when );
45 extern NTSTATUS NTDLL_queue_process_apc( HANDLE process, const apc_call_t *call, apc_result_t *result );
46 extern NTSTATUS NTDLL_wait_for_multiple_objects( UINT count, const HANDLE *handles, UINT flags,
47 const LARGE_INTEGER *timeout, HANDLE signal_object );
49 /* init routines */
50 extern BOOL SIGNAL_Init(void);
51 extern size_t get_signal_stack_total_size(void);
52 extern void version_init( const WCHAR *appname );
53 extern void debug_init(void);
54 extern HANDLE thread_init(void);
55 extern void virtual_init(void);
56 extern void virtual_init_threading(void);
58 /* server support */
59 extern abs_time_t server_start_time;
60 extern void server_init_process(void);
61 extern NTSTATUS server_init_process_done(void);
62 extern size_t server_init_thread( int unix_pid, int unix_tid, void *entry_point );
63 extern void DECLSPEC_NORETURN server_protocol_error( const char *err, ... );
64 extern void DECLSPEC_NORETURN server_protocol_perror( const char *err );
65 extern void DECLSPEC_NORETURN server_exit_thread( int status );
66 extern void DECLSPEC_NORETURN server_abort_thread( int status );
67 extern sigset_t server_block_set;
68 extern void server_enter_uninterrupted_section( RTL_CRITICAL_SECTION *cs, sigset_t *sigset );
69 extern void server_leave_uninterrupted_section( RTL_CRITICAL_SECTION *cs, sigset_t *sigset );
70 extern int server_remove_fd_from_cache( obj_handle_t handle );
71 extern int server_get_unix_fd( obj_handle_t handle, unsigned int access, int *unix_fd,
72 int *needs_close, enum server_fd_type *type, int *flags );
74 /* module handling */
75 extern NTSTATUS MODULE_DllThreadAttach( LPVOID lpReserved );
76 extern FARPROC RELAY_GetProcAddress( HMODULE module, const IMAGE_EXPORT_DIRECTORY *exports,
77 DWORD exp_size, FARPROC proc, DWORD ordinal, const WCHAR *user );
78 extern FARPROC SNOOP_GetProcAddress( HMODULE hmod, const IMAGE_EXPORT_DIRECTORY *exports, DWORD exp_size,
79 FARPROC origfun, DWORD ordinal, const WCHAR *user );
80 extern void RELAY_SetupDLL( HMODULE hmod );
81 extern void SNOOP_SetupDLL( HMODULE hmod );
82 extern UNICODE_STRING system_dir;
84 /* redefine these to make sure we don't reference kernel symbols */
85 #define GetProcessHeap() (NtCurrentTeb()->Peb->ProcessHeap)
86 #define GetCurrentProcessId() ((DWORD)NtCurrentTeb()->ClientId.UniqueProcess)
87 #define GetCurrentThreadId() ((DWORD)NtCurrentTeb()->ClientId.UniqueThread)
89 /* Device IO */
90 extern NTSTATUS CDROM_DeviceIoControl(HANDLE hDevice,
91 HANDLE hEvent, PIO_APC_ROUTINE UserApcRoutine,
92 PVOID UserApcContext,
93 PIO_STATUS_BLOCK piosb,
94 ULONG IoControlCode,
95 LPVOID lpInBuffer, DWORD nInBufferSize,
96 LPVOID lpOutBuffer, DWORD nOutBufferSize);
97 extern NTSTATUS COMM_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 TAPE_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);
112 /* file I/O */
113 extern NTSTATUS FILE_GetNtStatus(void);
114 extern BOOL DIR_is_hidden_file( const UNICODE_STRING *name );
115 extern NTSTATUS DIR_unmount_device( HANDLE handle );
116 extern NTSTATUS DIR_get_unix_cwd( char **cwd );
118 /* virtual memory */
119 extern NTSTATUS VIRTUAL_HandleFault(LPCVOID addr);
120 extern void VIRTUAL_SetForceExec( BOOL enable );
121 extern void VIRTUAL_UseLargeAddressSpace(void);
123 /* code pages */
124 extern int ntdll_umbstowcs(DWORD flags, const char* src, int srclen, WCHAR* dst, int dstlen);
125 extern int ntdll_wcstoumbs(DWORD flags, const WCHAR* src, int srclen, char* dst, int dstlen,
126 const char* defchar, int *used );
128 /* load order */
130 enum loadorder
132 LO_INVALID,
133 LO_DISABLED,
134 LO_NATIVE,
135 LO_BUILTIN,
136 LO_NATIVE_BUILTIN, /* native then builtin */
137 LO_BUILTIN_NATIVE, /* builtin then native */
138 LO_DEFAULT /* nothing specified, use default strategy */
141 extern enum loadorder get_load_order( const WCHAR *app_name, const WCHAR *path );
143 struct debug_info
145 char *str_pos; /* current position in strings buffer */
146 char *out_pos; /* current position in output buffer */
147 char strings[1024]; /* buffer for temporary strings */
148 char output[1024]; /* current output line */
151 struct ntdll_thread_data
153 struct debug_info *debug_info; /* info for debugstr functions */
154 int request_fd; /* fd for sending server requests */
155 int reply_fd; /* fd for receiving server replies */
156 int wait_fd[2]; /* fd for sleeping server requests */
157 void *vm86_ptr; /* data for vm86 mode */
159 void *pad[4]; /* change this if you add fields! */
162 static inline struct ntdll_thread_data *ntdll_get_thread_data(void)
164 return (struct ntdll_thread_data *)NtCurrentTeb()->SystemReserved2;
167 /* thread registers, stored in NtCurrentTeb()->SpareBytes1 */
168 struct ntdll_thread_regs
170 DWORD fs; /* 00 TEB selector */
171 DWORD gs; /* 04 libc selector; update winebuild if you move this! */
172 DWORD dr0; /* 08 debug registers */
173 DWORD dr1; /* 0c */
174 DWORD dr2; /* 10 */
175 DWORD dr3; /* 14 */
176 DWORD dr6; /* 18 */
177 DWORD dr7; /* 1c */
178 DWORD spare[2]; /* 20 change this if you add fields! */
181 static inline struct ntdll_thread_regs *ntdll_get_thread_regs(void)
183 return (struct ntdll_thread_regs *)NtCurrentTeb()->SpareBytes1;
186 #endif