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
10 /* INCLUDES ****************************************************************/
14 WINE_DEFAULT_DEBUG_CHANNEL(samsrv
);
17 /* GLOBALS *****************************************************************/
20 /* FUNCTIONS ***************************************************************/
23 SampLoadString(HINSTANCE hInstance
,
34 /* Use loword (incremented by 1) as resourceid */
35 hrsrc
= FindResourceW(hInstance
,
36 MAKEINTRESOURCEW((LOWORD(uId
) >> 4) + 1),
41 hmem
= LoadResource(hInstance
, hrsrc
);
45 p
= LockResource(hmem
);
46 string_num
= uId
& 0x000f;
47 for (i
= 0; i
< string_num
; i
++)
50 i
= min(nBufferMax
- 1, *p
);
53 memcpy(lpBuffer
, p
+ 1, i
* sizeof(WCHAR
));
70 SampIsSetupRunning(VOID
)
78 TRACE("SampIsSetupRunning()\n");
81 dwError
= RegOpenKeyExW(HKEY_LOCAL_MACHINE
,
86 if (dwError
!= ERROR_SUCCESS
)
90 dwSize
= sizeof(DWORD
);
91 dwError
= RegQueryValueExW(hKey
,
98 /* Close key, and check if returned values are correct */
100 if (dwError
!= ERROR_SUCCESS
|| dwType
!= REG_DWORD
|| dwSize
!= sizeof(DWORD
))
103 TRACE("SampIsSetupRunning() returns %s\n", (dwSetupType
!= 0) ? "TRUE" : "FALSE");
104 return (dwSetupType
!= 0);
109 AppendRidToSid(PSID SrcSid
,
112 ULONG Rids
[8] = {0, 0, 0, 0, 0, 0, 0, 0};
117 RidCount
= *RtlSubAuthorityCountSid(SrcSid
);
121 for (i
= 0; i
< RidCount
; i
++)
122 Rids
[i
] = *RtlSubAuthoritySid(SrcSid
, i
);
124 Rids
[RidCount
] = Rid
;
127 RtlAllocateAndInitializeSid(RtlIdentifierAuthoritySid(SrcSid
),
144 SampGetRidFromSid(IN PSID Sid
,
149 RidCount
= *RtlSubAuthorityCountSid(Sid
);
151 return STATUS_INVALID_SID
;
153 *Rid
= *RtlSubAuthoritySid(Sid
, RidCount
- 1);
155 return STATUS_SUCCESS
;
160 SampCheckAccountName(IN PRPC_UNICODE_STRING AccountName
,
163 if (AccountName
->Length
> MaxLength
* sizeof(WCHAR
))
164 return STATUS_INVALID_ACCOUNT_NAME
;
166 return STATUS_SUCCESS
;