wineandroid: Use the user driver interface to create host desktops.
[wine.git] / dlls / wow64win / wow64win_private.h
blob76e0c98f0f0b7e0000f9404e98d6eee2102cfde0
1 /*
2 * WoW64 private definitions
4 * Copyright 2021 Alexandre Julliard
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #ifndef __WOW64WIN_PRIVATE_H
22 #define __WOW64WIN_PRIVATE_H
24 #include "syscall.h"
26 #define SYSCALL_ENTRY(func) extern NTSTATUS WINAPI wow64_ ## func( UINT *args ) DECLSPEC_HIDDEN;
27 ALL_WIN32_SYSCALLS
28 #undef SYSCALL_ENTRY
30 typedef NTSTATUS (WINAPI *user_callback)( void *params, ULONG size );
31 extern user_callback user_callbacks[] DECLSPEC_HIDDEN;
33 struct object_attr64
35 OBJECT_ATTRIBUTES attr;
36 UNICODE_STRING str;
37 SECURITY_DESCRIPTOR sd;
40 typedef struct
42 ULONG Length;
43 ULONG RootDirectory;
44 ULONG ObjectName;
45 ULONG Attributes;
46 ULONG SecurityDescriptor;
47 ULONG SecurityQualityOfService;
48 } OBJECT_ATTRIBUTES32;
50 static inline ULONG get_ulong( UINT **args ) { return *(*args)++; }
51 static inline HANDLE get_handle( UINT **args ) { return LongToHandle( *(*args)++ ); }
52 static inline void *get_ptr( UINT **args ) { return ULongToPtr( *(*args)++ ); }
54 static inline void **addr_32to64( void **addr, ULONG *addr32 )
56 if (!addr32) return NULL;
57 *addr = ULongToPtr( *addr32 );
58 return addr;
61 static inline SIZE_T *size_32to64( SIZE_T *size, ULONG *size32 )
63 if (!size32) return NULL;
64 *size = *size32;
65 return size;
68 static inline void put_addr( ULONG *addr32, void *addr )
70 if (addr32) *addr32 = PtrToUlong( addr );
73 static inline void put_size( ULONG *size32, SIZE_T size )
75 if (size32) *size32 = min( size, MAXDWORD );
78 static inline UNICODE_STRING *unicode_str_32to64( UNICODE_STRING *str, const UNICODE_STRING32 *str32 )
80 if (!str32) return NULL;
81 str->Length = str32->Length;
82 str->MaximumLength = str32->MaximumLength;
83 str->Buffer = ULongToPtr( str32->Buffer );
84 return str;
87 static inline SECURITY_DESCRIPTOR *secdesc_32to64( SECURITY_DESCRIPTOR *out, const SECURITY_DESCRIPTOR *in )
89 /* relative descr has the same layout for 32 and 64 */
90 const SECURITY_DESCRIPTOR_RELATIVE *sd = (const SECURITY_DESCRIPTOR_RELATIVE *)in;
92 if (!in) return NULL;
93 out->Revision = sd->Revision;
94 out->Sbz1 = sd->Sbz1;
95 out->Control = sd->Control & ~SE_SELF_RELATIVE;
96 if (sd->Control & SE_SELF_RELATIVE)
98 if (sd->Owner) out->Owner = (PSID)((BYTE *)sd + sd->Owner);
99 if (sd->Group) out->Group = (PSID)((BYTE *)sd + sd->Group);
100 if ((sd->Control & SE_SACL_PRESENT) && sd->Sacl) out->Sacl = (PSID)((BYTE *)sd + sd->Sacl);
101 if ((sd->Control & SE_DACL_PRESENT) && sd->Dacl) out->Dacl = (PSID)((BYTE *)sd + sd->Dacl);
103 else
105 out->Owner = ULongToPtr( sd->Owner );
106 out->Group = ULongToPtr( sd->Group );
107 if (sd->Control & SE_SACL_PRESENT) out->Sacl = ULongToPtr( sd->Sacl );
108 if (sd->Control & SE_DACL_PRESENT) out->Dacl = ULongToPtr( sd->Dacl );
110 return out;
113 static inline OBJECT_ATTRIBUTES *objattr_32to64( struct object_attr64 *out, const OBJECT_ATTRIBUTES32 *in )
115 memset( out, 0, sizeof(*out) );
116 if (!in) return NULL;
117 if (in->Length != sizeof(*in)) return &out->attr;
119 out->attr.Length = sizeof(out->attr);
120 out->attr.RootDirectory = LongToHandle( in->RootDirectory );
121 out->attr.Attributes = in->Attributes;
122 out->attr.ObjectName = unicode_str_32to64( &out->str, ULongToPtr( in->ObjectName ));
123 out->attr.SecurityQualityOfService = ULongToPtr( in->SecurityQualityOfService );
124 out->attr.SecurityDescriptor = secdesc_32to64( &out->sd, ULongToPtr( in->SecurityDescriptor ));
125 return &out->attr;
128 static inline void set_last_error32( DWORD err )
130 TEB *teb = NtCurrentTeb();
131 TEB32 *teb32 = (TEB32 *)((char *)teb + teb->WowTebOffset);
132 teb32->LastErrorValue = err;
135 #endif /* __WOW64WIN_PRIVATE_H */