2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: Security Account Manager (SAM) Server
4 * FILE: reactos/dll/win32/samsrv/utils.c
5 * PURPOSE: Utility functions
7 * PROGRAMMERS: Eric Kohl
14 /* FUNCTIONS ***************************************************************/
17 SampLoadString(HINSTANCE hInstance
,
28 /* Use loword (incremented by 1) as resourceid */
29 hrsrc
= FindResourceW(hInstance
,
30 MAKEINTRESOURCEW((LOWORD(uId
) >> 4) + 1),
35 hmem
= LoadResource(hInstance
, hrsrc
);
39 p
= LockResource(hmem
);
40 string_num
= uId
& 0x000f;
41 for (i
= 0; i
< string_num
; i
++)
44 i
= min(nBufferMax
- 1, *p
);
47 memcpy(lpBuffer
, p
+ 1, i
* sizeof(WCHAR
));
64 SampIsSetupRunning(VOID
)
72 TRACE("SampIsSetupRunning()\n");
75 dwError
= RegOpenKeyExW(HKEY_LOCAL_MACHINE
,
80 if (dwError
!= ERROR_SUCCESS
)
84 dwSize
= sizeof(DWORD
);
85 dwError
= RegQueryValueExW(hKey
,
92 /* Close key, and check if returned values are correct */
94 if (dwError
!= ERROR_SUCCESS
|| dwType
!= REG_DWORD
|| dwSize
!= sizeof(DWORD
))
97 TRACE("SampIsSetupRunning() returns %s\n", (dwSetupType
!= 0) ? "TRUE" : "FALSE");
98 return (dwSetupType
!= 0);
103 AppendRidToSid(PSID SrcSid
,
106 ULONG Rids
[8] = {0, 0, 0, 0, 0, 0, 0, 0};
111 RidCount
= *RtlSubAuthorityCountSid(SrcSid
);
115 for (i
= 0; i
< RidCount
; i
++)
116 Rids
[i
] = *RtlSubAuthoritySid(SrcSid
, i
);
118 Rids
[RidCount
] = Rid
;
121 RtlAllocateAndInitializeSid(RtlIdentifierAuthoritySid(SrcSid
),
138 SampGetRidFromSid(IN PSID Sid
,
143 RidCount
= *RtlSubAuthorityCountSid(Sid
);
145 return STATUS_INVALID_SID
;
147 *Rid
= *RtlSubAuthoritySid(Sid
, RidCount
- 1);
149 return STATUS_SUCCESS
;
154 SampCheckAccountName(IN PRPC_UNICODE_STRING AccountName
,
157 if (AccountName
->Length
> MaxLength
* sizeof(WCHAR
))
158 return STATUS_INVALID_ACCOUNT_NAME
;
160 return STATUS_SUCCESS
;