ReactOS 0.4.16-dev-136-g52192f1
utils.c File Reference
#include "lsasrv.h"
#include <winuser.h>
Include dependency graph for utils.c:

Go to the source code of this file.

Functions

INT LsapLoadString (HINSTANCE hInstance, UINT uId, LPWSTR lpBuffer, INT nBufferMax)
 
INT LsapGetResourceStringLengthEx (_In_ HINSTANCE hInstance, _In_ UINT uId, _In_ USHORT usLanguage)
 
INT LsapLoadStringEx (_In_ HINSTANCE hInstance, _In_ UINT uId, _In_ USHORT usLanguage, _Out_ LPWSTR lpBuffer, _Out_ INT nBufferMax)
 
PSID LsapAppendRidToSid (PSID SrcSid, ULONG Rid)
 

Function Documentation

◆ LsapAppendRidToSid()

PSID LsapAppendRidToSid ( PSID  SrcSid,
ULONG  Rid 
)

Definition at line 152 of file utils.c.

155{
156 ULONG Rids[8] = {0, 0, 0, 0, 0, 0, 0, 0};
157 UCHAR RidCount;
158 PSID DstSid;
159 ULONG i;
160
161 RidCount = *RtlSubAuthorityCountSid(SrcSid);
162 if (RidCount >= 8)
163 return NULL;
164
165 for (i = 0; i < RidCount; i++)
166 Rids[i] = *RtlSubAuthoritySid(SrcSid, i);
167
168 Rids[RidCount] = Rid;
169 RidCount++;
170
172 RidCount,
173 Rids[0],
174 Rids[1],
175 Rids[2],
176 Rids[3],
177 Rids[4],
178 Rids[5],
179 Rids[6],
180 Rids[7],
181 &DstSid);
182
183 return DstSid;
184}
#define NULL
Definition: types.h:112
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
NTSYSAPI PULONG NTAPI RtlSubAuthoritySid(_In_ PSID Sid, _In_ ULONG SubAuthority)
NTSYSAPI PSID_IDENTIFIER_AUTHORITY NTAPI RtlIdentifierAuthoritySid(PSID Sid)
NTSYSAPI NTSTATUS NTAPI RtlAllocateAndInitializeSid(IN PSID_IDENTIFIER_AUTHORITY IdentifierAuthority, IN UCHAR SubAuthorityCount, IN ULONG SubAuthority0, IN ULONG SubAuthority1, IN ULONG SubAuthority2, IN ULONG SubAuthority3, IN ULONG SubAuthority4, IN ULONG SubAuthority5, IN ULONG SubAuthority6, IN ULONG SubAuthority7, OUT PSID *Sid)
Definition: sid.c:290
NTSYSAPI PUCHAR NTAPI RtlSubAuthorityCountSid(IN PSID Sid)
Definition: sid.c:104
uint32_t ULONG
Definition: typedefs.h:59
unsigned char UCHAR
Definition: xmlstorage.h:181

Referenced by LsapAppendSidToGroups().

◆ LsapGetResourceStringLengthEx()

INT LsapGetResourceStringLengthEx ( _In_ HINSTANCE  hInstance,
_In_ UINT  uId,
_In_ USHORT  usLanguage 
)

Definition at line 64 of file utils.c.

68{
69 HGLOBAL hmem;
70 HRSRC hrsrc;
71 WCHAR *p;
72 UINT i, string_num;
73
74 /* Use loword (incremented by 1) as resourceid */
75// hrsrc = FindResourceExW(hInstance,
76// MAKEINTRESOURCEW((LOWORD(uId) >> 4) + 1),
77// (LPWSTR)RT_STRING,
78// usLanguage);
80 MAKEINTRESOURCEW((LOWORD(uId) >> 4) + 1),
82 if (!hrsrc)
83 return 0;
84
85 hmem = LoadResource(hInstance, hrsrc);
86 if (!hmem)
87 return 0;
88
89 p = LockResource(hmem);
90 string_num = uId & 0x000f;
91 for (i = 0; i < string_num; i++)
92 p += *p + 1;
93
94 return *p + 1;
95}
HINSTANCE hInstance
Definition: charmap.c:19
HRSRC WINAPI FindResourceW(HINSTANCE hModule, LPCWSTR name, LPCWSTR type)
Definition: res.c:176
LPVOID WINAPI LockResource(HGLOBAL handle)
Definition: res.c:550
HGLOBAL WINAPI LoadResource(HINSTANCE hModule, HRSRC hRsrc)
Definition: res.c:532
GLfloat GLfloat p
Definition: glext.h:8902
unsigned int UINT
Definition: ndis.h:50
#define LOWORD(l)
Definition: pedump.c:82
#define RT_STRING
Definition: pedump.c:368
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
__wchar_t WCHAR
Definition: xmlstorage.h:180
WCHAR * LPWSTR
Definition: xmlstorage.h:184

Referenced by LsarpLookupPrivilegeDisplayName().

◆ LsapLoadString()

INT LsapLoadString ( HINSTANCE  hInstance,
UINT  uId,
LPWSTR  lpBuffer,
INT  nBufferMax 
)

Definition at line 17 of file utils.c.

21{
22 HGLOBAL hmem;
23 HRSRC hrsrc;
24 WCHAR *p;
25 int string_num;
26 int i;
27
28 /* Use loword (incremented by 1) as resourceid */
30 MAKEINTRESOURCEW((LOWORD(uId) >> 4) + 1),
32 if (!hrsrc)
33 return 0;
34
35 hmem = LoadResource(hInstance, hrsrc);
36 if (!hmem)
37 return 0;
38
39 p = LockResource(hmem);
40 string_num = uId & 0x000f;
41 for (i = 0; i < string_num; i++)
42 p += *p + 1;
43
44 i = min(nBufferMax - 1, *p);
45 if (i > 0)
46 {
47 memcpy(lpBuffer, p + 1, i * sizeof(WCHAR));
48 lpBuffer[i] = 0;
49 }
50 else
51 {
52 if (nBufferMax > 1)
53 {
54 lpBuffer[0] = 0;
55 return 0;
56 }
57 }
58
59 return i;
60}
static TAGREF LPCWSTR LPDWORD LPVOID lpBuffer
Definition: db.cpp:175
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define min(a, b)
Definition: monoChain.cc:55

Referenced by LsapInitSids().

◆ LsapLoadStringEx()

INT LsapLoadStringEx ( _In_ HINSTANCE  hInstance,
_In_ UINT  uId,
_In_ USHORT  usLanguage,
_Out_ LPWSTR  lpBuffer,
_Out_ INT  nBufferMax 
)

Definition at line 99 of file utils.c.

105{
106 HGLOBAL hmem;
107 HRSRC hrsrc;
108 WCHAR *p;
109 int string_num;
110 int i;
111
112 /* Use loword (incremented by 1) as resourceid */
113// hrsrc = FindResourceExW(hInstance,
114// MAKEINTRESOURCEW((LOWORD(uId) >> 4) + 1),
115// (LPWSTR)RT_STRING,
116// usLanguage);
117 hrsrc = FindResourceW(hInstance,
118 MAKEINTRESOURCEW((LOWORD(uId) >> 4) + 1),
120 if (!hrsrc)
121 return 0;
122
123 hmem = LoadResource(hInstance, hrsrc);
124 if (!hmem)
125 return 0;
126
127 p = LockResource(hmem);
128 string_num = uId & 0x000f;
129 for (i = 0; i < string_num; i++)
130 p += *p + 1;
131
132 i = min(nBufferMax - 1, *p);
133 if (i > 0)
134 {
135 memcpy(lpBuffer, p + 1, i * sizeof(WCHAR));
136 lpBuffer[i] = 0;
137 }
138 else
139 {
140 if (nBufferMax > 1)
141 {
142 lpBuffer[0] = 0;
143 return 0;
144 }
145 }
146
147 return i;
148}

Referenced by LsarpLookupPrivilegeDisplayName().