On 7/30/2012 19:08, Detlef Riekenberg wrote:
try2: now using EqualSid.
Thanks Nikolay for comments
- pConvertSidToStringSidA = (void *)GetProcAddress( hmod, "ConvertSidToStringSidA" );
- if( !pConvertSidToStringSidA )
return;
- pConvertStringSidToSidA = (void *)GetProcAddress( hmod, "ConvertStringSidToSidA" );
- if( !pConvertStringSidToSidA )
- if( !pConvertSidToStringSidA || !pConvertStringSidToSidA )
- {
skip("ConvertSidToStringSidA or ConvertStringSidToSidA not available\n"); return;
- }
I probably missed that, you need to use win_skip here.
r = pConvertStringSidToSidA( NULL, NULL ); ok( !r, "expected failure with NULL parameters\n" );
@@ -4274,6 +4275,73 @@ static void test_kernel_objects_security(void) CloseHandle(token); }
+static void test_TokenIntegrityLevel(void) +{
- TOKEN_MANDATORY_LABEL *tml;
- HANDLE token;
- DWORD size;
- DWORD res;
- LPVOID buffer = NULL;
- char *sidname = NULL;
- static SID medium_level = {SID_REVISION, 1, {SECURITY_MANDATORY_LABEL_AUTHORITY},
{SECURITY_MANDATORY_HIGH_RID}};
- static SID high_level = {SID_REVISION, 1, {SECURITY_MANDATORY_LABEL_AUTHORITY},
{SECURITY_MANDATORY_MEDIUM_RID}};
- if(!pConvertSidToStringSidA)
- {
skip("ConvertSidToStringSidA not available\n");
return;
- }
and here.
- SetLastError(0xdeadbeef);
- res = OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &token);
- ok(res, "got %d with %d (expected TRUE)\n", res, GetLastError());
- if (!res)
return;
Does it really fail on some test machine?
- SetLastError(0xdeadbeef);
- res = GetTokenInformation(token, TokenIntegrityLevel, NULL, 0, &size);
- /* not supported before Vista */
- if (!res && (GetLastError() == ERROR_INVALID_PARAMETER))
- {
skip("TokenIntegrityLevel not supported\n");
CloseHandle(token);
return;
- }
- if (!res && (GetLastError() == ERROR_INSUFFICIENT_BUFFER))
- {
buffer = HeapAlloc(GetProcessHeap(), 0, size);
SetLastError(0xdeadbeef);
res = GetTokenInformation(token, TokenIntegrityLevel, buffer, size, &size);
- }
Again, you don't need to allocate anything here, so you don't need cleanup code.