Changeset 2128 for trunk/src


Ignore:
Timestamp:
Dec 18, 1999, 10:45:13 PM (26 years ago)
Author:
sandervl
Message:

Token api update

Location:
trunk/src/NTDLL
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/NTDLL/nt.cpp

    r2122 r2128  
    1 /* $Id: nt.cpp,v 1.3 1999-12-18 20:01:13 sandervl Exp $ */
     1/* $Id: nt.cpp,v 1.4 1999-12-18 21:45:13 sandervl Exp $ */
    22
    33
     
    1515#include <string.h>
    1616#include <time.h>
     17#include <os2win.h>
     18#include <handlemanager.h>
    1719
    1820#include "ntdll.h"
     
    258260                                   PHANDLE TokenHandle)
    259261{
    260   dprintf(("NTDLL: NtOpenProcessToken(%08xh,%08xh,%08xh) not implemented.\n",
     262  dprintf(("NTDLL: NtOpenProcessToken(%08xh,%08xh,%08xh) not correctly implemented.\n",
    261263           ProcessHandle,
    262264           DesiredAccess,
    263265           TokenHandle));
    264266
    265   *TokenHandle = 0xcafe;
    266   return 0;
     267  if(ProcessHandle == GetCurrentProcess()) {
     268        HMOpenProcessToken(ProcessHandle, DesiredAccess, (ULONG)&ProcSecInfo, TokenHandle);
     269        return STATUS_SUCCESS;
     270  }
     271  *TokenHandle = 0;
     272  return ERROR_INVALID_HANDLE;
    267273}
    268274
     
    282288           TokenHandle));
    283289
    284   *TokenHandle = 0xcafe;
    285   return 0;
     290  *TokenHandle = 0;
     291  return ERROR_INVALID_HANDLE;
    286292}
    287293
     
    321327                                        LPDWORD ReturnLength)
    322328{
    323   dprintf(("NTDLL: NtQueryInformationToken(%08xh,%08xh,%08xh,%08xh,%08xh) not implemented.\n",
     329 PROCESSTHREAD_SECURITYINFO *pSecInfo;
     330
     331  dprintf(("NTDLL: NtQueryInformationToken(%08xh,%08xh,%08xh,%08xh,%08xh) not correctly implemented.\n",
    324332           Token,
    325333           TokenInformationClass,
     
    328336           ReturnLength));
    329337
     338  pSecInfo = (PROCESSTHREAD_SECURITYINFO*)HMHandleGetUserData(Token);
     339  if((ULONG)pSecInfo == -1) {
     340        return ERROR_INVALID_HANDLE;
     341  }
    330342  switch (TokenInformationClass)
    331343  {
     
    335347                return STATUS_BUFFER_TOO_SMALL;
    336348        }
    337         memset(TokenInformation, 0, sizeof(TOKEN_GROUPS));
     349        memcpy(TokenInformation, (LPVOID)pSecInfo->pTokenGroups, sizeof(TOKEN_GROUPS));
    338350        break;
    339351    case TokenUser:                     /* 1 */
  • trunk/src/NTDLL/ntdll.cpp

    r2122 r2128  
    1 /* $Id: ntdll.cpp,v 1.4 1999-12-18 20:01:14 sandervl Exp $ */
     1/* $Id: ntdll.cpp,v 1.5 1999-12-18 21:45:13 sandervl Exp $ */
    22
    33/*
     
    3838#include <string.h>
    3939#include <ctype.h>
    40 #include "misc.h"
     40#include <misc.h>
    4141#include "unicode.h"
    4242
     
    5252//SvL: per process heap for NTDLL
    5353HANDLE NTDLL_hHeap = 0;
     54
     55PROCESSTHREAD_SECURITYINFO ProcSecInfo = {0};
    5456
    5557/*****************************************************************************
     
    8789    switch (fdwReason) {
    8890    case DLL_PROCESS_ATTACH:
    89         NTDLL_hHeap = HeapCreate(0, 0x10000, 0);
     91    {
     92     SID_IDENTIFIER_AUTHORITY sidIdAuth = {0};
     93
     94        NTDLL_hHeap = HeapCreate(0, 0x10000, 0);
     95
     96        ProcSecInfo.dwType = SECTYPE_PROCESS;
     97        RtlAllocateAndInitializeSid(&sidIdAuth, 1, 0, 0, 0, 0, 0, 0, 0, 0, &ProcSecInfo.SidUser.User.Sid);
     98        ProcSecInfo.SidUser.User.Attributes = 0; //?????????
     99
     100        ProcSecInfo.pTokenGroups = (TOKEN_GROUPS*)Heap_Alloc(sizeof(TOKEN_GROUPS));
     101        ProcSecInfo.pTokenGroups->GroupCount = 1;
     102        RtlAllocateAndInitializeSid(&sidIdAuth, 1, 0, 0, 0, 0, 0, 0, 0, 0, &ProcSecInfo.PrimaryGroup.PrimaryGroup);
     103        ProcSecInfo.pTokenGroups->Groups[0].Sid = ProcSecInfo.PrimaryGroup.PrimaryGroup;
     104        ProcSecInfo.pTokenGroups->Groups[0].Attributes = 0; //????
     105
     106//        pPrivilegeSet   = NULL;
     107//        pTokenPrivileges= NULL;
     108//        TokenOwner      = {0};
     109//        DefaultDACL     = {0};
     110//        TokenSource     = {0};
     111        ProcSecInfo.TokenType = TokenPrimary;
    90112        break;
     113    }
    91114    case DLL_PROCESS_DETACH:
    92115        HeapDestroy(NTDLL_hHeap);
  • trunk/src/NTDLL/ntdll.h

    r2122 r2128  
    1 /* $Id: ntdll.h,v 1.8 1999-12-18 20:01:14 sandervl Exp $ */
     1/* $Id: ntdll.h,v 1.9 1999-12-18 21:45:13 sandervl Exp $ */
    22
    33/*
     
    655655PSID_IDENTIFIER_AUTHORITY WINAPI GetSidIdentifierAuthority(PSID);
    656656
     657//SvL: Security data for win32 process (nothing fancy; just trying to fool apps
     658//     into thinking the security subsystem is in perfect shape.
     659#define SECTYPE_THREAD          0
     660#define SECTYPE_PROCESS         1
     661
     662typedef struct {
     663 DWORD               dwType;
     664 TOKEN_USER          SidUser;
     665 TOKEN_GROUPS       *pTokenGroups;
     666 PRIVILEGE_SET      *pPrivilegeSet;
     667 TOKEN_PRIVILEGES   *pTokenPrivileges;
     668 TOKEN_OWNER         TokenOwner;
     669 TOKEN_PRIMARY_GROUP PrimaryGroup;
     670 TOKEN_DEFAULT_DACL  DefaultDACL;
     671 TOKEN_SOURCE        TokenSource;
     672 TOKEN_TYPE          TokenType;
     673} PROCESSTHREAD_SECURITYINFO;
     674
     675//Per process info; Should probably be stored in process database structure
     676extern PROCESSTHREAD_SECURITYINFO ProcSecInfo;
     677
    657678#ifdef __cplusplus
    658679}
Note: See TracChangeset for help on using the changeset viewer.