mirror of
https://github.com/reactos/reactos.git
synced 2025-08-02 21:36:41 +00:00
import LookupPrivilegeNameA from wine
svn path=/trunk/; revision=36986
This commit is contained in:
parent
c22ad7e659
commit
41ab62c3a6
1 changed files with 44 additions and 4 deletions
|
@ -1396,11 +1396,51 @@ STDCALL
|
||||||
LookupPrivilegeNameA(LPCSTR lpSystemName,
|
LookupPrivilegeNameA(LPCSTR lpSystemName,
|
||||||
PLUID lpLuid,
|
PLUID lpLuid,
|
||||||
LPSTR lpName,
|
LPSTR lpName,
|
||||||
LPDWORD cbName)
|
LPDWORD cchName)
|
||||||
{
|
{
|
||||||
FIXME("%s() not implemented!\n", __FUNCTION__);
|
UNICODE_STRING lpSystemNameW;
|
||||||
SetLastError (ERROR_CALL_NOT_IMPLEMENTED);
|
BOOL ret;
|
||||||
return FALSE;
|
DWORD wLen = 0;
|
||||||
|
|
||||||
|
TRACE("%s %p %p %p\n", debugstr_a(lpSystemName), lpLuid, lpName, cchName);
|
||||||
|
|
||||||
|
RtlCreateUnicodeStringFromAsciiz(&lpSystemNameW, lpSystemName);
|
||||||
|
ret = LookupPrivilegeNameW(lpSystemNameW.Buffer, lpLuid, NULL, &wLen);
|
||||||
|
if (!ret && GetLastError() == ERROR_INSUFFICIENT_BUFFER)
|
||||||
|
{
|
||||||
|
LPWSTR lpNameW = HeapAlloc(GetProcessHeap(), 0, wLen * sizeof(WCHAR));
|
||||||
|
|
||||||
|
ret = LookupPrivilegeNameW(lpSystemNameW.Buffer, lpLuid, lpNameW,
|
||||||
|
&wLen);
|
||||||
|
if (ret)
|
||||||
|
{
|
||||||
|
/* Windows crashes if cchName is NULL, so will I */
|
||||||
|
unsigned int len = WideCharToMultiByte(CP_ACP, 0, lpNameW, -1, lpName,
|
||||||
|
*cchName, NULL, NULL);
|
||||||
|
|
||||||
|
if (len == 0)
|
||||||
|
{
|
||||||
|
/* WideCharToMultiByte failed */
|
||||||
|
ret = FALSE;
|
||||||
|
}
|
||||||
|
else if (len > *cchName)
|
||||||
|
{
|
||||||
|
*cchName = len;
|
||||||
|
SetLastError(ERROR_INSUFFICIENT_BUFFER);
|
||||||
|
ret = FALSE;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* WideCharToMultiByte succeeded, output length needs to be
|
||||||
|
* length not including NULL terminator
|
||||||
|
*/
|
||||||
|
*cchName = len - 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
HeapFree(GetProcessHeap(), 0, lpNameW);
|
||||||
|
}
|
||||||
|
RtlFreeUnicodeString(&lpSystemNameW);
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue