Remove redundant check.
[wine] / dlls / ntdll / ntdll_misc.h
1 /*
2  * Copyright 2000 Juergen Schmied
3  *
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.
8  *
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.
13  *
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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
17  */
18
19 #ifndef __WINE_NTDLL_MISC_H
20 #define __WINE_NTDLL_MISC_H
21
22 #include <stdarg.h>
23
24 #include "windef.h"
25 #include "winnt.h"
26 #include "ntstatus.h"
27 #include "winternl.h"
28 #include "winioctl.h"
29 #include "wine/server.h"
30
31 /* The per-thread signal stack size */
32 #ifdef __i386__
33 #define SIGNAL_STACK_SIZE  4096
34 #else
35 #define SIGNAL_STACK_SIZE  0  /* we don't need a signal stack on non-i386 */
36 #endif
37
38 #define MAX_NT_PATH_LENGTH 277
39
40 extern void WINAPI __regs_RtlRaiseException( PEXCEPTION_RECORD, PCONTEXT );
41
42 /* debug helper */
43 extern LPCSTR debugstr_us( const UNICODE_STRING *str );
44 extern void dump_ObjectAttributes (const OBJECT_ATTRIBUTES *ObjectAttributes);
45
46 extern void NTDLL_get_server_timeout( abs_time_t *when, const LARGE_INTEGER *timeout );
47 extern void NTDLL_from_server_timeout( LARGE_INTEGER *timeout, const abs_time_t *when );
48 extern NTSTATUS NTDLL_wait_for_multiple_objects( UINT count, const HANDLE *handles, UINT flags,
49                                                  const LARGE_INTEGER *timeout, HANDLE signal_object );
50
51 /* init routines */
52 extern BOOL SIGNAL_Init(void);
53 extern void version_init( const WCHAR *appname );
54 extern void debug_init(void);
55 extern void thread_init(void);
56
57 /* server support */
58 extern time_t server_start_time;
59 extern void server_init_process(void);
60 extern size_t server_init_thread( int unix_pid, int unix_tid, void *entry_point );
61 extern void DECLSPEC_NORETURN server_protocol_error( const char *err, ... );
62 extern void DECLSPEC_NORETURN server_protocol_perror( const char *err );
63 extern void DECLSPEC_NORETURN server_exit_thread( int status );
64 extern void DECLSPEC_NORETURN server_abort_thread( int status );
65
66 /* module handling */
67 extern FARPROC RELAY_GetProcAddress( HMODULE module, const IMAGE_EXPORT_DIRECTORY *exports,
68                                      DWORD exp_size, FARPROC proc, const WCHAR *user );
69 extern FARPROC SNOOP_GetProcAddress( HMODULE hmod, const IMAGE_EXPORT_DIRECTORY *exports, DWORD exp_size,
70                                      FARPROC origfun, DWORD ordinal, const WCHAR *user );
71 extern void RELAY_SetupDLL( HMODULE hmod );
72 extern void SNOOP_SetupDLL( HMODULE hmod );
73 extern UNICODE_STRING system_dir;
74
75 /* redefine these to make sure we don't reference kernel symbols */
76 #define GetProcessHeap()       (NtCurrentTeb()->Peb->ProcessHeap)
77 #define GetCurrentProcessId()  ((DWORD)NtCurrentTeb()->ClientId.UniqueProcess)
78 #define GetCurrentThreadId()   ((DWORD)NtCurrentTeb()->ClientId.UniqueThread)
79
80 /* Device IO */
81 extern NTSTATUS CDROM_DeviceIoControl(HANDLE hDevice, 
82                                       HANDLE hEvent, PIO_APC_ROUTINE UserApcRoutine,
83                                       PVOID UserApcContext, 
84                                       PIO_STATUS_BLOCK piosb, 
85                                       ULONG IoControlCode,
86                                       LPVOID lpInBuffer, DWORD nInBufferSize,
87                                       LPVOID lpOutBuffer, DWORD nOutBufferSize);
88
89 /* file I/O */
90 extern NTSTATUS FILE_GetNtStatus(void);
91 extern NTSTATUS FILE_GetDeviceInfo( int fd, FILE_FS_DEVICE_INFORMATION *info );
92 extern BOOL DIR_is_hidden_file( const UNICODE_STRING *name );
93 extern NTSTATUS DIR_get_unix_cwd( char **cwd );
94
95 /* virtual memory */
96 extern NTSTATUS VIRTUAL_alloc_teb( void **ret, size_t size, BOOL first );
97 extern NTSTATUS VIRTUAL_HandleFault(LPCVOID addr);
98 extern BOOL VIRTUAL_HasMapping( LPCVOID addr );
99 extern void VIRTUAL_UseLargeAddressSpace(void);
100
101 extern BOOL is_current_process( HANDLE handle );
102
103 /* code pages */
104 extern int ntdll_umbstowcs(DWORD flags, const char* src, int srclen, WCHAR* dst, int dstlen);
105 extern int ntdll_wcstoumbs(DWORD flags, const WCHAR* src, int srclen, char* dst, int dstlen,
106                            const char* defchar, int *used );
107
108 struct debug_info
109 {
110     char *str_pos;       /* current position in strings buffer */
111     char *out_pos;       /* current position in output buffer */
112     char  strings[1024]; /* buffer for temporary strings */
113     char  output[1024];  /* current output line */
114 };
115
116 struct ntdll_thread_data
117 {
118     DWORD              teb_sel;       /* selector to TEB */
119     struct debug_info *debug_info;    /* info for debugstr functions */
120     int                request_fd;    /* fd for sending server requests */
121     int                reply_fd;      /* fd for receiving server replies */
122     int                wait_fd[2];    /* fd for sleeping server requests */
123     void              *vm86_ptr;      /* data for vm86 mode */
124
125     void              *pad[3];        /* change this if you add fields! */
126 };
127
128 static inline struct ntdll_thread_data *ntdll_get_thread_data(void)
129 {
130     return (struct ntdll_thread_data *)NtCurrentTeb()->SystemReserved2;
131 }
132
133 #endif