3 * Copyright (C) 2004 ReactOS Team
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 * COPYRIGHT: See COPYING in the top level directory
22 * PROJECT: ReactOS system libraries
23 * FILE: lib/userenv/misc.c
24 * PURPOSE: User profile code
25 * PROGRAMMER: Eric Kohl
34 /* FUNCTIONS ***************************************************************/
37 AppendBackslash (LPWSTR String
)
41 Length
= lstrlenW (String
);
42 if (String
[Length
- 1] != L
'\\')
44 String
[Length
] = L
'\\';
46 String
[Length
] = (WCHAR
)0;
49 return &String
[Length
];
54 GetUserSidFromToken (HANDLE hToken
,
55 PUNICODE_STRING SidString
)
57 PSID_AND_ATTRIBUTES SidBuffer
, nsb
;
62 SidBuffer
= LocalAlloc (LMEM_FIXED
,
64 if (SidBuffer
== NULL
)
67 Status
= NtQueryInformationToken (hToken
,
72 if (Status
== STATUS_BUFFER_TOO_SMALL
)
74 nsb
= LocalReAlloc (SidBuffer
,
79 LocalFree((HLOCAL
)SidBuffer
);
84 Status
= NtQueryInformationToken (hToken
,
91 if (!NT_SUCCESS (Status
))
93 LocalFree ((HLOCAL
)SidBuffer
);
94 SetLastError (RtlNtStatusToDosError (Status
));
98 DPRINT ("SidLength: %lu\n", RtlLengthSid (SidBuffer
[0].Sid
));
100 Status
= RtlConvertSidToUnicodeString (SidString
,
104 LocalFree ((HLOCAL
)SidBuffer
);
106 if (!NT_SUCCESS (Status
))
108 SetLastError (RtlNtStatusToDosError (Status
));
112 DPRINT ("SidString.Length: %lu\n", SidString
->Length
);
113 DPRINT ("SidString.MaximumLength: %lu\n", SidString
->MaximumLength
);
114 DPRINT ("SidString: '%wZ'\n", SidString
);
120 CreateDefaultSD(VOID
)
122 /* FIXME - create a default security descriptor */
126 /* Dynamic DLL loading interface **********************************************/
128 /* OLE32.DLL import table */
129 DYN_MODULE DynOle32
=
142 * Use this function to load functions from other modules. We cannot statically
143 * link to e.g. ole32.dll because those dlls would get loaded on startup with
144 * winlogon and they may try to register classes etc when not even a window station
148 LoadDynamicImports(PDYN_MODULE Module
, PDYN_FUNCS DynFuncs
)
153 ZeroMemory(DynFuncs
, sizeof(DYN_FUNCS
));
155 DynFuncs
->hModule
= LoadLibraryW(Module
->Library
);
156 if (!DynFuncs
->hModule
)
161 fn
= &DynFuncs
->fn
.foo
;
163 /* load the imports */
164 for (fname
= Module
->Functions
; *fname
!= NULL
; fname
++)
166 *fn
= GetProcAddress(DynFuncs
->hModule
, *fname
);
169 FreeLibrary(DynFuncs
->hModule
);
170 DynFuncs
->hModule
= (HMODULE
)0;
183 UnloadDynamicImports(PDYN_FUNCS DynFuncs
)
185 if (DynFuncs
->hModule
)
187 FreeLibrary(DynFuncs
->hModule
);
188 DynFuncs
->hModule
= (HMODULE
)0;