Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

ttokend.c File Reference

#include <stdio.h>
#include <nt.h>
#include <ntsam.h>
#include <ntsamp.h>
#include <ntlsa.h>
#include <ntrpcp.h>
#include <seopaque.h>
#include <string.h>

Go to the source code of this file.

Functions

VOID main (int argc, char **argv)


Function Documentation

VOID main int  argc,
char **  argv
 

Definition at line 322 of file ttokend.c.

References FALSE, NtDuplicateToken(), NtOpenProcessToken(), NTSTATUS(), NULL, and ObjectAttributes.

00328 : 00329 00330 This is the main entry routine for this test. 00331 00332 Arguments: 00333 00334 NONE 00335 00336 00337 Return Value: 00338 00339 00340 00341 00342 --*/ 00343 { 00344 NTSTATUS 00345 NtStatus; 00346 00347 HANDLE 00348 h1, h2, h3; 00349 00350 OBJECT_ATTRIBUTES 00351 ObjectAttributes; 00352 00353 SECURITY_QUALITY_OF_SERVICE 00354 Qos; 00355 00356 // 00357 // Duplicate our primary token to get an impersonation token. 00358 // (no security QOS causes duplicate to have Anonymous level) 00359 // 00360 00361 NtStatus = NtOpenProcessToken( NtCurrentProcess(), 00362 TOKEN_DUPLICATE, 00363 &h1); 00364 printf("Test: Open Process Token: 0x%lx\n", NtStatus); 00365 00366 InitializeObjectAttributes( &ObjectAttributes, NULL, 0, 0, NULL ); 00367 NtStatus = NtDuplicateToken( h1, 00368 TOKEN_DUPLICATE, 00369 &ObjectAttributes, 00370 FALSE, // EffectiveOnly 00371 TokenImpersonation, 00372 &h2); 00373 printf("Test: Duplicate Primary to anonymous Impersonation: 0x%lx\n", NtStatus); 00374 00375 00376 // 00377 // Now duplicate that to get a primary 00378 // 00379 NtStatus = NtDuplicateToken( h2, 00380 TOKEN_DUPLICATE, 00381 &ObjectAttributes, 00382 FALSE, // EffectiveOnly 00383 TokenPrimary, 00384 &h3); 00385 printf("Test: Duplicate anonymous Impersonation to Primary: 0x%lx\n", NtStatus); 00386 00387 // 00388 // Now try it again with Impersonate level. 00389 // 00390 00391 Qos.Length = sizeof(Qos); 00392 Qos.ImpersonationLevel = SecurityImpersonation; 00393 Qos.ContextTrackingMode = SECURITY_STATIC_TRACKING; 00394 Qos.EffectiveOnly = FALSE; 00395 00396 InitializeObjectAttributes( &ObjectAttributes, NULL, 0, 0, NULL ); 00397 ObjectAttributes.SecurityQualityOfService = &Qos; 00398 00399 NtStatus = NtDuplicateToken( h1, 00400 TOKEN_DUPLICATE, 00401 &ObjectAttributes, 00402 FALSE, // EffectiveOnly 00403 TokenImpersonation, 00404 &h2); 00405 printf("Test: Duplicate Primary to IMPERSONATE Impersonation: 0x%lx\n", NtStatus); 00406 00407 00408 // 00409 // Now duplicate that to get a primary 00410 // 00411 NtStatus = NtDuplicateToken( h2, 00412 TOKEN_DUPLICATE, 00413 &ObjectAttributes, 00414 FALSE, // EffectiveOnly 00415 TokenPrimary, 00416 &h3); 00417 printf("Test: Duplicate IMPERSONATE Impersonation to Primary: 0x%lx\n", NtStatus); 00418 00419 return; 00420 }


Generated on Sat May 15 19:45:49 2004 for test by doxygen 1.3.7