windows.applicationmodel/tests: Use PathRemoveFileSpecW() instead of PathCchRemoveFil...
[wine.git] / dlls / ntdll / ntdll_misc.h
blobad8e2691224c25634821cf8d93aae9adbc25e3dd
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 <stdlib.h>
24 #include <sys/types.h>
26 #include "windef.h"
27 #include "winbase.h"
28 #include "winnt.h"
29 #include "winternl.h"
30 #include "unixlib.h"
31 #include "wine/asm.h"
33 #define DECLARE_CRITICAL_SECTION(cs) \
34 static RTL_CRITICAL_SECTION cs; \
35 static RTL_CRITICAL_SECTION_DEBUG cs##_debug = \
36 { 0, 0, &cs, { &cs##_debug.ProcessLocksList, &cs##_debug.ProcessLocksList }, \
37 0, 0, { (DWORD_PTR)(__FILE__ ": " # cs) }}; \
38 static RTL_CRITICAL_SECTION cs = { &cs##_debug, -1, 0, 0, 0, 0 };
40 #define MAX_NT_PATH_LENGTH 277
42 #define NTDLL_TLS_ERRNO 16 /* TLS slot for _errno() */
44 #if defined(__i386__) || defined(__x86_64__) || defined(__arm__) || defined(__aarch64__)
45 static const UINT_PTR page_size = 0x1000;
46 #else
47 extern UINT_PTR page_size DECLSPEC_HIDDEN;
48 #endif
50 /* exceptions */
51 extern LONG call_vectored_handlers( EXCEPTION_RECORD *rec, CONTEXT *context ) DECLSPEC_HIDDEN;
52 extern void DECLSPEC_NORETURN raise_status( NTSTATUS status, EXCEPTION_RECORD *rec ) DECLSPEC_HIDDEN;
53 extern LONG WINAPI call_unhandled_exception_filter( PEXCEPTION_POINTERS eptr ) DECLSPEC_HIDDEN;
55 extern void WINAPI LdrInitializeThunk(CONTEXT*,ULONG_PTR,ULONG_PTR,ULONG_PTR) DECLSPEC_HIDDEN;
56 extern NTSTATUS WINAPI KiUserExceptionDispatcher(EXCEPTION_RECORD*,CONTEXT*) DECLSPEC_HIDDEN;
57 extern void WINAPI KiUserApcDispatcher(CONTEXT*,ULONG_PTR,ULONG_PTR,ULONG_PTR,PNTAPCFUNC) DECLSPEC_HIDDEN;
58 extern void WINAPI KiUserCallbackDispatcher(ULONG,void*,ULONG) DECLSPEC_HIDDEN;
59 extern void (WINAPI *pWow64PrepareForException)( EXCEPTION_RECORD *rec, CONTEXT *context ) DECLSPEC_HIDDEN;
61 #if defined(__x86_64__) || defined(__arm__) || defined(__aarch64__)
62 extern RUNTIME_FUNCTION *lookup_function_info( ULONG_PTR pc, ULONG_PTR *base, LDR_DATA_TABLE_ENTRY **module ) DECLSPEC_HIDDEN;
63 #endif
65 /* debug helpers */
66 extern LPCSTR debugstr_us( const UNICODE_STRING *str ) DECLSPEC_HIDDEN;
67 extern const char *debugstr_exception_code( DWORD code ) DECLSPEC_HIDDEN;
68 extern void set_native_thread_name( DWORD tid, const char *name ) DECLSPEC_HIDDEN;
70 /* init routines */
71 extern void version_init(void) DECLSPEC_HIDDEN;
72 extern void debug_init(void) DECLSPEC_HIDDEN;
73 extern void actctx_init(void) DECLSPEC_HIDDEN;
74 extern void locale_init(void) DECLSPEC_HIDDEN;
75 extern void init_user_process_params(void) DECLSPEC_HIDDEN;
76 extern void CDECL DECLSPEC_NORETURN signal_start_thread( CONTEXT *ctx ) DECLSPEC_HIDDEN;
77 extern void get_resource_lcids( LANGID *user, LANGID *user_neutral, LANGID *system ) DECLSPEC_HIDDEN;
79 /* module handling */
80 extern LIST_ENTRY tls_links DECLSPEC_HIDDEN;
81 extern FARPROC RELAY_GetProcAddress( HMODULE module, const IMAGE_EXPORT_DIRECTORY *exports,
82 DWORD exp_size, FARPROC proc, DWORD ordinal, const WCHAR *user ) DECLSPEC_HIDDEN;
83 extern FARPROC SNOOP_GetProcAddress( HMODULE hmod, const IMAGE_EXPORT_DIRECTORY *exports, DWORD exp_size,
84 FARPROC origfun, DWORD ordinal, const WCHAR *user ) DECLSPEC_HIDDEN;
85 extern void RELAY_SetupDLL( HMODULE hmod ) DECLSPEC_HIDDEN;
86 extern void SNOOP_SetupDLL( HMODULE hmod ) DECLSPEC_HIDDEN;
87 extern const WCHAR windows_dir[] DECLSPEC_HIDDEN;
88 extern const WCHAR system_dir[] DECLSPEC_HIDDEN;
90 extern void (FASTCALL *pBaseThreadInitThunk)(DWORD,LPTHREAD_START_ROUTINE,void *) DECLSPEC_HIDDEN;
92 extern struct _KUSER_SHARED_DATA *user_shared_data DECLSPEC_HIDDEN;
94 extern int CDECL NTDLL__vsnprintf( char *str, SIZE_T len, const char *format, va_list args ) DECLSPEC_HIDDEN;
95 extern int CDECL NTDLL__vsnwprintf( WCHAR *str, SIZE_T len, const WCHAR *format, va_list args ) DECLSPEC_HIDDEN;
97 struct dllredirect_data
99 ULONG size;
100 ULONG flags;
101 ULONG total_len;
102 ULONG paths_count;
103 ULONG paths_offset;
104 struct { ULONG len; ULONG offset; } paths[1];
107 #define DLL_REDIRECT_PATH_INCLUDES_BASE_NAME 1
108 #define DLL_REDIRECT_PATH_OMITS_ASSEMBLY_ROOT 2
109 #define DLL_REDIRECT_PATH_EXPAND 4
110 #define DLL_REDIRECT_PATH_SYSTEM_DEFAULT_REDIRECTED_SYSTEM32_DLL 8
112 #ifdef _WIN64
113 static inline TEB64 *NtCurrentTeb64(void) { return NULL; }
114 #else
115 static inline TEB64 *NtCurrentTeb64(void) { return (TEB64 *)NtCurrentTeb()->GdiBatchCount; }
116 #endif
118 #define HASH_STRING_ALGORITHM_DEFAULT 0
119 #define HASH_STRING_ALGORITHM_X65599 1
120 #define HASH_STRING_ALGORITHM_INVALID 0xffffffff
122 NTSTATUS WINAPI RtlHashUnicodeString(PCUNICODE_STRING,BOOLEAN,ULONG,ULONG*);
124 /* convert from straight ASCII to Unicode without depending on the current codepage */
125 static inline void ascii_to_unicode( WCHAR *dst, const char *src, size_t len )
127 while (len--) *dst++ = (unsigned char)*src++;
130 /* FLS data */
131 extern TEB_FLS_DATA *fls_alloc_data(void) DECLSPEC_HIDDEN;
132 extern void heap_thread_detach(void) DECLSPEC_HIDDEN;
134 #endif