mfplat: Read queue subscriber within the critical section.
[wine/zf.git] / dlls / ntdll / ntdll_misc.h
bloba4a178a462ebb57efe9f82d3e2fce388eed6f54c
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 <sys/types.h>
25 #include "windef.h"
26 #include "winnt.h"
27 #include "winternl.h"
28 #include "unixlib.h"
29 #include "wine/asm.h"
31 #define DECLARE_CRITICAL_SECTION(cs) \
32 static RTL_CRITICAL_SECTION cs; \
33 static RTL_CRITICAL_SECTION_DEBUG cs##_debug = \
34 { 0, 0, &cs, { &cs##_debug.ProcessLocksList, &cs##_debug.ProcessLocksList }, \
35 0, 0, { (DWORD_PTR)(__FILE__ ": " # cs) }}; \
36 static RTL_CRITICAL_SECTION cs = { &cs##_debug, -1, 0, 0, 0, 0 };
38 #define MAX_NT_PATH_LENGTH 277
40 #if defined(__i386__) || defined(__x86_64__) || defined(__arm__) || defined(__aarch64__)
41 static const UINT_PTR page_size = 0x1000;
42 #else
43 extern UINT_PTR page_size DECLSPEC_HIDDEN;
44 #endif
46 /* exceptions */
47 extern LONG call_vectored_handlers( EXCEPTION_RECORD *rec, CONTEXT *context ) DECLSPEC_HIDDEN;
48 extern void DECLSPEC_NORETURN raise_status( NTSTATUS status, EXCEPTION_RECORD *rec ) DECLSPEC_HIDDEN;
49 extern LONG WINAPI call_unhandled_exception_filter( PEXCEPTION_POINTERS eptr ) DECLSPEC_HIDDEN;
51 #if defined(__x86_64__) || defined(__arm__) || defined(__aarch64__)
52 extern RUNTIME_FUNCTION *lookup_function_info( ULONG_PTR pc, ULONG_PTR *base, LDR_DATA_TABLE_ENTRY **module ) DECLSPEC_HIDDEN;
53 #endif
55 /* debug helpers */
56 extern LPCSTR debugstr_us( const UNICODE_STRING *str ) DECLSPEC_HIDDEN;
57 extern const char *debugstr_exception_code( DWORD code ) DECLSPEC_HIDDEN;
59 /* init routines */
60 extern void version_init(void) DECLSPEC_HIDDEN;
61 extern void debug_init(void) DECLSPEC_HIDDEN;
62 extern void actctx_init(void) DECLSPEC_HIDDEN;
63 extern void heap_set_debug_flags( HANDLE handle ) DECLSPEC_HIDDEN;
64 extern void init_user_process_params(void) DECLSPEC_HIDDEN;
65 extern void CDECL DECLSPEC_NORETURN signal_start_thread( CONTEXT *ctx ) DECLSPEC_HIDDEN;
67 /* module handling */
68 extern LIST_ENTRY tls_links DECLSPEC_HIDDEN;
69 extern FARPROC RELAY_GetProcAddress( HMODULE module, const IMAGE_EXPORT_DIRECTORY *exports,
70 DWORD exp_size, FARPROC proc, DWORD ordinal, const WCHAR *user ) DECLSPEC_HIDDEN;
71 extern FARPROC SNOOP_GetProcAddress( HMODULE hmod, const IMAGE_EXPORT_DIRECTORY *exports, DWORD exp_size,
72 FARPROC origfun, DWORD ordinal, const WCHAR *user ) DECLSPEC_HIDDEN;
73 extern void RELAY_SetupDLL( HMODULE hmod ) DECLSPEC_HIDDEN;
74 extern void SNOOP_SetupDLL( HMODULE hmod ) DECLSPEC_HIDDEN;
75 extern const WCHAR windows_dir[] DECLSPEC_HIDDEN;
76 extern const WCHAR system_dir[] DECLSPEC_HIDDEN;
77 extern const WCHAR syswow64_dir[] DECLSPEC_HIDDEN;
78 extern HMODULE kernel32_handle DECLSPEC_HIDDEN;
80 extern void (FASTCALL *pBaseThreadInitThunk)(DWORD,LPTHREAD_START_ROUTINE,void *) DECLSPEC_HIDDEN;
81 extern const struct unix_funcs *unix_funcs DECLSPEC_HIDDEN;
83 extern struct _KUSER_SHARED_DATA *user_shared_data DECLSPEC_HIDDEN;
85 extern int CDECL NTDLL__vsnprintf( char *str, SIZE_T len, const char *format, __ms_va_list args ) DECLSPEC_HIDDEN;
86 extern int CDECL NTDLL__vsnwprintf( WCHAR *str, SIZE_T len, const WCHAR *format, __ms_va_list args ) DECLSPEC_HIDDEN;
88 /* load order */
90 #ifdef _WIN64
91 static inline TEB64 *NtCurrentTeb64(void) { return NULL; }
92 #else
93 static inline TEB64 *NtCurrentTeb64(void) { return (TEB64 *)NtCurrentTeb()->GdiBatchCount; }
94 #endif
96 #define HASH_STRING_ALGORITHM_DEFAULT 0
97 #define HASH_STRING_ALGORITHM_X65599 1
98 #define HASH_STRING_ALGORITHM_INVALID 0xffffffff
100 NTSTATUS WINAPI RtlHashUnicodeString(PCUNICODE_STRING,BOOLEAN,ULONG,ULONG*);
102 /* convert from straight ASCII to Unicode without depending on the current codepage */
103 static inline void ascii_to_unicode( WCHAR *dst, const char *src, size_t len )
105 while (len--) *dst++ = (unsigned char)*src++;
108 /* FLS data */
109 extern TEB_FLS_DATA *fls_alloc_data(void) DECLSPEC_HIDDEN;
111 #endif