Example #1
0
File: tse.c Project: mingpen/OpenNT
void
TestGetPrivNameW(
    LPWSTR *PrivName,
    PLUID  lpLuid
    )
{


    BOOL          Bool;
    DWORD         cbName = 0;
    PWCHAR        Name = NULL;


    Bool = LookupPrivilegeNameW(
               NULL,
               lpLuid,
               Name,
               &cbName
               );
    ASSERT( !Bool && GetLastError() == ERROR_INSUFFICIENT_BUFFER );

    Name = RtlAllocateHeap( RtlProcessHeap(), 0, (cbName+1)*sizeof(WCHAR) );

    Bool = LookupPrivilegeNameW(
               NULL,
               lpLuid,
               Name,
               &cbName
               );
    ASSERT(Bool);

    (*PrivName) = (LPWSTR)Name;

    return;
}
Example #2
0
/*************************************************************************
 * LookupPrivilegeNameA [ADVAPI32.@]
 */
BOOL WINAPI LookupPrivilegeNameA (LPCSTR lpSystemName, PLUID lpLuid,
                                  LPSTR lpName, LPDWORD cchName)
{
    LPWSTR lpSystemNameW = HEAP_strdupAtoW (GetProcessHeap (), 0, lpSystemName);
    LPWSTR lpNameW = NULL;
    BOOL Ret;

    TRACE ("(%s, %p, %p, %p)\n", lpSystemName, lpLuid, lpName, cchName);

    if (*cchName)
        lpNameW = HeapAlloc (GetProcessHeap (), 0, *cchName * sizeof (WCHAR));

    Ret = LookupPrivilegeNameW (lpSystemNameW, lpLuid, lpNameW, cchName);
    if (Ret)
        WideCharToMultiByte (CP_ACP, 0, lpNameW, -1, lpName, *cchName,
                             NULL, NULL);

    if (lpNameW)
        HeapFree (GetProcessHeap (), 0, lpNameW);
    HeapFree (GetProcessHeap (), 0, lpSystemNameW);

    return Ret;
}
Example #3
0
File: tse.c Project: mingpen/OpenNT
void
TestLookupPrivilegeNameW(
    PLUID lpLuid
    )

{

    //
    // LookupPrivilegeNameW test
    //

    BOOL          Bool;
    DWORD         cbName = 0;
    WCHAR         Name[BUFFER_SIZE];


    printf("      LookupW call . . . . . . . . . . . . . . . . . ");


    Bool = LookupPrivilegeNameW(
               NULL,
               lpLuid,
               Name,
               &cbName
               );

    //
    // Expect failure here
    //

    if ( !Bool && GetLastError() != ERROR_INSUFFICIENT_BUFFER ) {
        printf("** FAILED **\n");
        printf("        First call.\n");
        printf("        Status:             %d\n", GetLastError());
        printf("        Name Length:        %d\n", cbName);
    } else {


        Bool = LookupPrivilegeNameW(
                   NULL,
                   lpLuid,
                   Name,
                   &cbName
                   );

        if ( !Bool ) {
            printf("** FAILED **\n");
            printf("        Second call.\n");
            printf("        Status:             %d\n", GetLastError());
            printf("        Name Length:        %d\n", cbName);
        } else {
            printf("Succeeded\n");
            printf("        Name Length:        %d\n", cbName);
            printf("        Name:               *");
            DumpWCharString( Name );
            printf("*\n");
            printf("\n\n");
        }
    }

    return;
}