include/mscvpdb.h: Use flexible array members for the rest of structures.
[wine.git] / dlls / fltmgr.sys / main.c
blob51f777598f57e7fc99553115867c8cfcdf55f914
1 /*
2 * fltmgr.sys
4 * Copyright 2015 Austin English
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 #include <stdarg.h>
23 #include "ntstatus.h"
24 #define WIN32_NO_STATUS
25 #include "windef.h"
26 #include "winternl.h"
27 #include "ddk/fltkernel.h"
29 #include "wine/debug.h"
31 WINE_DEFAULT_DEBUG_CHANNEL(fltmgr);
33 NTSTATUS WINAPI DriverEntry( DRIVER_OBJECT *driver, UNICODE_STRING *path )
35 TRACE( "(%p, %s)\n", driver, debugstr_w(path->Buffer) );
37 return STATUS_SUCCESS;
40 void WINAPI FltInitializePushLock( EX_PUSH_LOCK *lock )
42 FIXME( "(%p): stub\n", lock );
45 void WINAPI FltDeletePushLock( EX_PUSH_LOCK *lock )
47 FIXME( "(%p): stub\n", lock );
50 void WINAPI FltAcquirePushLockExclusive( EX_PUSH_LOCK *lock )
52 FIXME( "(%p): stub\n", lock );
55 void WINAPI FltReleasePushLock( EX_PUSH_LOCK *lock )
57 FIXME( "(%p): stub\n", lock );
60 NTSTATUS WINAPI FltRegisterFilter( PDRIVER_OBJECT driver, const FLT_REGISTRATION *reg, PFLT_FILTER *filter )
62 FIXME( "(%p,%p,%p): stub\n", driver, reg, filter );
64 if(filter)
65 *filter = UlongToHandle(0xdeadbeaf);
67 return STATUS_SUCCESS;
70 NTSTATUS WINAPI FltStartFiltering( PFLT_FILTER filter )
72 FIXME( "(%p): stub\n", filter );
74 return STATUS_SUCCESS;
77 void WINAPI FltUnregisterFilter( PFLT_FILTER filter )
79 FIXME( "(%p): stub\n", filter );
82 void* WINAPI FltGetRoutineAddress(LPCSTR name)
84 HMODULE mod = GetModuleHandleW(L"fltmgr.sys");
85 void *func;
87 func = GetProcAddress(mod, name);
88 if (func)
89 TRACE( "%s -> %p\n", debugstr_a(name), func );
90 else
91 FIXME( "%s not found\n", debugstr_a(name) );
93 return func;
96 NTSTATUS WINAPI FltBuildDefaultSecurityDescriptor(PSECURITY_DESCRIPTOR *descriptor, ACCESS_MASK access)
98 PACL dacl;
99 NTSTATUS ret = STATUS_INSUFFICIENT_RESOURCES;
100 DWORD sid_len;
101 SID *sid;
102 SID *sid_system = NULL;
103 PSECURITY_DESCRIPTOR sec_desc = NULL;
104 SID_IDENTIFIER_AUTHORITY auth = { SECURITY_NULL_SID_AUTHORITY };
106 *descriptor = NULL;
108 sid_len = RtlLengthRequiredSid(2);
109 sid = ExAllocatePool(PagedPool, sid_len);
110 if (!sid)
111 goto done;
112 RtlInitializeSid(sid, &auth, 2);
113 sid->SubAuthority[1] = DOMAIN_GROUP_RID_ADMINS;
114 sid->SubAuthority[0] = SECURITY_BUILTIN_DOMAIN_RID;
116 sid_len = RtlLengthRequiredSid(1);
117 sid_system = ExAllocatePool(PagedPool, sid_len);
118 if (!sid_system)
119 goto done;
120 RtlInitializeSid(sid_system, &auth, 1);
121 sid_system->SubAuthority[0] = SECURITY_LOCAL_SYSTEM_RID;
123 sid_len = SECURITY_DESCRIPTOR_MIN_LENGTH + sizeof(ACL) +
124 sizeof(ACCESS_ALLOWED_ACE) + RtlLengthSid(sid) +
125 sizeof(ACCESS_ALLOWED_ACE) + RtlLengthSid(sid_system);
127 sec_desc = ExAllocatePool(PagedPool, sid_len);
128 if (!sec_desc)
130 ret = STATUS_NO_MEMORY;
131 goto done;
134 RtlCreateSecurityDescriptor(sec_desc, SECURITY_DESCRIPTOR_REVISION);
135 dacl = (PACL)((char*)sec_desc + SECURITY_DESCRIPTOR_MIN_LENGTH);
136 RtlCreateAcl(dacl, sid_len - SECURITY_DESCRIPTOR_MIN_LENGTH, ACL_REVISION);
137 RtlAddAccessAllowedAce(dacl, ACL_REVISION, access, sid);
138 RtlAddAccessAllowedAce(dacl, ACL_REVISION, access, sid_system);
139 RtlSetDaclSecurityDescriptor(sec_desc, 1, dacl, 0);
140 *descriptor = sec_desc;
141 ret = STATUS_SUCCESS;
143 done:
144 ExFreePool(sid);
145 ExFreePool(sid_system);
146 return ret;
149 void WINAPI FltFreeSecurityDescriptor(PSECURITY_DESCRIPTOR descriptor)
151 ExFreePool(descriptor);