1 /* $Id: misc.c,v 1.6 2004/08/15 19:02:40 chorns Exp $
3 * COPYRIGHT: See COPYING in the top level directory
4 * PROJECT: ReactOS system libraries
5 * FILE: lib/userenv/misc.c
6 * PURPOSE: User profile code
7 * PROGRAMMER: Eric Kohl
13 /* FUNCTIONS ***************************************************************/
16 AppendBackslash (LPWSTR String
)
20 Length
= lstrlenW (String
);
21 if (String
[Length
- 1] != L
'\\')
23 String
[Length
] = L
'\\';
25 String
[Length
] = (WCHAR
)0;
28 return &String
[Length
];
33 GetUserSidFromToken (HANDLE hToken
,
34 PUNICODE_STRING SidString
)
36 PSID_AND_ATTRIBUTES SidBuffer
;
41 SidBuffer
= LocalAlloc (0,
43 if (SidBuffer
== NULL
)
46 Status
= NtQueryInformationToken (hToken
,
51 if (Status
== STATUS_BUFFER_TOO_SMALL
)
53 SidBuffer
= LocalReAlloc (SidBuffer
,
56 if (SidBuffer
== NULL
)
59 Status
= NtQueryInformationToken (hToken
,
66 if (!NT_SUCCESS (Status
))
68 LocalFree (SidBuffer
);
72 DPRINT ("SidLength: %lu\n", RtlLengthSid (SidBuffer
[0].Sid
));
74 Status
= RtlConvertSidToUnicodeString (SidString
,
78 LocalFree (SidBuffer
);
80 if (!NT_SUCCESS (Status
))
83 DPRINT ("SidString.Length: %lu\n", SidString
->Length
);
84 DPRINT ("SidString.MaximumLength: %lu\n", SidString
->MaximumLength
);
85 DPRINT ("SidString: '%wZ'\n", SidString
);
90 /* Dynamic DLL loading interface **********************************************/
92 /* OLE32.DLL import table */
105 Use this function to load functions from other modules. We cannot statically
106 link to e.g. ole32.dll because those dlls would get loaded on startup with
107 winlogon and they may try to register classes etc when not even a window station
112 LoadDynamicImports(PDYN_MODULE Module
, PDYN_FUNCS DynFuncs
)
117 ZeroMemory(DynFuncs
, sizeof(DYN_FUNCS
));
119 DynFuncs
->hModule
= LoadLibraryW(Module
->Library
);
120 if(!DynFuncs
->hModule
)
125 fn
= &DynFuncs
->fn
.foo
;
127 /* load the imports */
128 for(fname
= Module
->Functions
; *fname
!= NULL
; fname
++)
130 *fn
= GetProcAddress(DynFuncs
->hModule
, *fname
);
133 FreeLibrary(DynFuncs
->hModule
);
134 DynFuncs
->hModule
= (HMODULE
)0;
144 UnloadDynamicImports(PDYN_FUNCS DynFuncs
)
146 if(DynFuncs
->hModule
)
148 FreeLibrary(DynFuncs
->hModule
);
149 DynFuncs
->hModule
= (HMODULE
)0;