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
23 #include <sys/types.h>
29 #include "wine/server.h"
32 #define DECLARE_CRITICAL_SECTION(cs) \
33 static RTL_CRITICAL_SECTION cs; \
34 static RTL_CRITICAL_SECTION_DEBUG cs##_debug = \
35 { 0, 0, &cs, { &cs##_debug.ProcessLocksList, &cs##_debug.ProcessLocksList }, \
36 0, 0, { (DWORD_PTR)(__FILE__ ": " # cs) }}; \
37 static RTL_CRITICAL_SECTION cs = { &cs##_debug, -1, 0, 0, 0, 0 };
39 #define MAX_NT_PATH_LENGTH 277
41 #if defined(__i386__) || defined(__x86_64__) || defined(__arm__) || defined(__aarch64__)
42 static const UINT_PTR page_size
= 0x1000;
44 extern UINT_PTR page_size DECLSPEC_HIDDEN
;
48 extern LONG
call_vectored_handlers( EXCEPTION_RECORD
*rec
, CONTEXT
*context
) DECLSPEC_HIDDEN
;
49 extern void DECLSPEC_NORETURN
raise_status( NTSTATUS status
, EXCEPTION_RECORD
*rec
) DECLSPEC_HIDDEN
;
50 extern LONG WINAPI
call_unhandled_exception_filter( PEXCEPTION_POINTERS eptr
) DECLSPEC_HIDDEN
;
52 #if defined(__x86_64__) || defined(__arm__) || defined(__aarch64__)
53 extern RUNTIME_FUNCTION
*lookup_function_info( ULONG_PTR pc
, ULONG_PTR
*base
, LDR_DATA_TABLE_ENTRY
**module
) DECLSPEC_HIDDEN
;
57 extern LPCSTR
debugstr_us( const UNICODE_STRING
*str
) DECLSPEC_HIDDEN
;
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_unix_codepage(void) DECLSPEC_HIDDEN
;
65 extern void init_locale( HMODULE module
) DECLSPEC_HIDDEN
;
66 extern void init_user_process_params(void) DECLSPEC_HIDDEN
;
67 extern void CDECL DECLSPEC_NORETURN
signal_start_thread( CONTEXT
*ctx
) DECLSPEC_HIDDEN
;
70 extern BOOL is_wow64 DECLSPEC_HIDDEN
;
73 extern LIST_ENTRY tls_links DECLSPEC_HIDDEN
;
74 extern FARPROC
RELAY_GetProcAddress( HMODULE module
, const IMAGE_EXPORT_DIRECTORY
*exports
,
75 DWORD exp_size
, FARPROC proc
, DWORD ordinal
, const WCHAR
*user
) DECLSPEC_HIDDEN
;
76 extern FARPROC
SNOOP_GetProcAddress( HMODULE hmod
, const IMAGE_EXPORT_DIRECTORY
*exports
, DWORD exp_size
,
77 FARPROC origfun
, DWORD ordinal
, const WCHAR
*user
) DECLSPEC_HIDDEN
;
78 extern void RELAY_SetupDLL( HMODULE hmod
) DECLSPEC_HIDDEN
;
79 extern void SNOOP_SetupDLL( HMODULE hmod
) DECLSPEC_HIDDEN
;
80 extern const WCHAR windows_dir
[] DECLSPEC_HIDDEN
;
81 extern const WCHAR system_dir
[] DECLSPEC_HIDDEN
;
82 extern const WCHAR syswow64_dir
[] DECLSPEC_HIDDEN
;
84 extern void (FASTCALL
*pBaseThreadInitThunk
)(DWORD
,LPTHREAD_START_ROUTINE
,void *) DECLSPEC_HIDDEN
;
85 extern const struct unix_funcs
*unix_funcs DECLSPEC_HIDDEN
;
87 extern void init_directories(void) DECLSPEC_HIDDEN
;
89 extern struct _KUSER_SHARED_DATA
*user_shared_data DECLSPEC_HIDDEN
;
92 extern LCID user_lcid
, system_lcid
;
93 extern DWORD
ntdll_umbstowcs( const char* src
, DWORD srclen
, WCHAR
* dst
, DWORD dstlen
) DECLSPEC_HIDDEN
;
94 extern int ntdll_wcstoumbs( const WCHAR
* src
, DWORD srclen
, char* dst
, DWORD dstlen
, BOOL strict
) DECLSPEC_HIDDEN
;
96 extern int CDECL
NTDLL__vsnprintf( char *str
, SIZE_T len
, const char *format
, __ms_va_list args
) DECLSPEC_HIDDEN
;
97 extern int CDECL
NTDLL__vsnwprintf( WCHAR
*str
, SIZE_T len
, const WCHAR
*format
, __ms_va_list args
) DECLSPEC_HIDDEN
;
107 LO_NATIVE_BUILTIN
, /* native then builtin */
108 LO_BUILTIN_NATIVE
, /* builtin then native */
109 LO_DEFAULT
/* nothing specified, use default strategy */
112 extern enum loadorder
get_load_order( const WCHAR
*app_name
, const UNICODE_STRING
*nt_name
) DECLSPEC_HIDDEN
;
115 static inline TEB64
*NtCurrentTeb64(void) { return (TEB64
*)NtCurrentTeb()->GdiBatchCount
; }
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
++;
131 extern void init_global_fls_data(void) DECLSPEC_HIDDEN
;
132 extern TEB_FLS_DATA
*fls_alloc_data(void) DECLSPEC_HIDDEN
;