public extern static bool DuplicateTokenEx( IntPtr hExistingToken, uint dwDesiredAccess, ref SECURITY_ATTRIBUTES lpTokenAttributes, SECURITY_IMPERSONATION_LEVEL ImpersonationLevel, TOKEN_TYPE TokenType, out IntPtr phNewToken);
private static extern bool DuplicateTokenEx( Kernel32.SafeObjectHandle hExistingToken, Kernel32.ACCESS_MASK dwDesiredAccess, ref Kernel32.SECURITY_ATTRIBUTES lpTokenAttributes, Kernel32.SECURITY_IMPERSONATION_LEVEL impersonationLevel, TOKEN_TYPE tokenType, out Kernel32.SafeObjectHandle phNewToken);
public TOKEN(int Offset, TOKEN_TYPE Type, string Value) { this.StartOffset = Offset; this.EndOffset = Offset + Value.Length; this.Type = Type; this.Value = Value; }
/// <summary> /// 다음 토큰의 타입과 내용을 확인합니다. /// 만약 옳은 토큰일 경우 다음 인덱스로 진행합니다. /// </summary> /// <returns></returns> public bool CheckCurrentToken(TOKEN_TYPE ttype, string value = null, bool IsReverse = false) { //if (IsError) //{ // throw new Exception(); //} IsEndOfList(true); TOKEN ntk = GetSafeTokenIten(); if (ttype != ntk.Type) { return(false); } if (value != null) { if (value != ntk.Value) { return(false); } } if (IsReverse) { index--; } else { index++; } return(true); }
internal extern static bool DuplicateTokenEx( IntPtr hExistingToken, uint dwDesiredAccess, IntPtr lpTokenAttributes, uint ImpersonationLevel, TOKEN_TYPE TokenType, out IntPtr phNewToken);
public static extern bool DuplicateTokenEx( SafeTokenHandle hExistingToken, UInt32 desiredAccess, IntPtr pTokenAttributes, SECURITY_IMPERSONATION_LEVEL ImpersonationLevel, TOKEN_TYPE TokenType, out SafeTokenHandle hNewToken);
private extern static bool DuplicateTokenEx( IntPtr hExistingToken, uint dwDesiredAccess, /*ref*/ IntPtr lpTokenAttributes, // since we only call this with null we omit ref and type for laziness SECURITY_IMPERSONATION_LEVEL ImpersonationLevel, TOKEN_TYPE TokenType, out IntPtr phNewToken);
internal static extern bool DuplicateTokenEx( SafeCloseHandle hExistingToken, TokenAccessLevels dwDesiredAccess, IntPtr lpTokenAttributes, SECURITY_IMPERSONATION_LEVEL ImpersonationLevel, TOKEN_TYPE TokenType, ref SafeCloseHandle phNewToken);
public static AccessTokenHandle Duplicate(AccessTokenHandle originalToken, SECURITY_IMPERSONATION_LEVEL impersonationLevel, TOKEN_TYPE tokenType, params TokenAccess[] desiredAccess) { var defaultAccess = TokenAccess.TOKEN_ALL_ACCESS; uint combinedAccess = (uint)defaultAccess; if (desiredAccess.Length > 0) { combinedAccess = (uint)(new List <TokenAccess>(desiredAccess).Aggregate((x, y) => x | y)); } SECURITY_ATTRIBUTES secAttr = new SECURITY_ATTRIBUTES(); IntPtr newToken; Logger.GetInstance().Debug($"Attempting to duplicate token."); if (!Advapi32.DuplicateTokenEx(originalToken.GetHandle(), combinedAccess, ref secAttr, impersonationLevel, tokenType, out newToken)) { Logger.GetInstance().Error($"Failed to duplicate token. DuplicateTokenEx failed with error code: {Kernel32.GetLastError()}"); throw new DuplicateTokenException(); } Logger.GetInstance().Debug($"Successfully duplicated token."); if (desiredAccess.Length > 0) { return(new AccessTokenHandle(newToken, desiredAccess)); } else { return(new AccessTokenHandle(newToken, defaultAccess)); } }
internal extern static bool DuplicateTokenEx( IntPtr hExistingToken, TokenAccessLevels dwDesiredAccess, SECURITY_ATTRIBUTES lpTokenAttributes, TokenImpersonationLevel ImpersonationLevel, TOKEN_TYPE TokenType, out IntPtr phNewToken);
public static extern bool DuplicateTokenEx( IntPtr hExistingToken, TokenAccessFlags dwDesiredAccess, IntPtr lpThreadAttributes, SECURITY_IMPERSONATION_LEVEL ImpersonationLevel, TOKEN_TYPE TokenType, out IntPtr phNewToken);
extern static bool DuplicateTokenEx( IntPtr hExistingToken, uint dwDesiredAccess, ref SECURITY_ATTRIBUTES lpTokenAttributes, SECURITY_IMPERSONATION_LEVEL ImpersonationLevel, TOKEN_TYPE TokenType, out IntPtr phNewToken);
public static extern BOOL DuplicateTokenEx( AccessToken hExistingToken, AccessTokenRights dwDesiredAccess, IntPtr lpTokenAttributes, SECURITY_IMPERSONATION_LEVEL ImpersonationLevel, TOKEN_TYPE TokenType, ref AccessToken phNewToken);
public ConditionalParser(string condition) { chrs = condition.ToCharArray(); exprPos = -1; exprC = '\0'; token = ""; tokenType = TOKEN_TYPE.NOTHING; }
// Convert a binary operator token into an AST operation. // We rely on a 1:1 mapping from token to AST operation //public ASTNODE_TYPE arithop(TOKEN_TYPE tokentype) { // if (tokentype > TOKEN_TYPE.T_EOF && tokentype < TOKEN_TYPE.T_INTLIT) // return ((ASTNODE_TYPE)tokentype); //fatald("Syntax error, token", tokentype); //} // Operator precedence for each token. Must // match up with the order of tokens in defs.h //A_AND = 1, A_OR, A_ADD, A_SUBTRACT, A_MULTIPLY, A_DIVIDE, A_INTLIT, //A_EQUALEQUAL, A_NOTEQUAL, A_LESSTHAN, A_LESSEQUAL, A_LARGETHAN, A_LARGEEQUAL, //A_LIKE, //A_LRND, A_RRND, //A_EQUAL // Check that we have a binary operator and // return its precedence. private int op_precedence(TOKEN_TYPE tokentype) { int prec = OpPrec[(int)tokentype]; if (prec == 0) { //Console.WriteLine("Syntax error, token {0:G}", tokentype); throw new ArgumentException("Syntax error, token " + tokentype + " at position " + ipos); } //fatald("Syntax error, token", tokentype); return(prec); }
private static IntPtr duplicateTokenEx( IntPtr hExistingToken, uint dwDesiredAccess, ref SECURITY_ATTRIBUTES lpTokenAttributes, SECURITY_IMPERSONATION_LEVEL ImpersonationLevel, TOKEN_TYPE TokenType) { IntPtr phNewToken; bool ret = DuplicateTokenEx(hExistingToken, dwDesiredAccess, ref lpTokenAttributes, ImpersonationLevel, TokenType, out phNewToken); if (!ret) { throw new Win32Exception(Marshal.GetLastWin32Error()); } return(phNewToken); }
public StoredToken GenerateNewToken(string TokenReason, TOKEN_TYPE type, string TokenData = null, DateTime?ExpirationDate = null) { StoredToken tk = new StoredToken(); tk.ExpirationDate = ExpirationDate ?? DateTime.Now.AddDays(1); tk.TokenData = TokenData; tk.TokenReason = TokenReason; tk.TokenType = type; tk.TokenValue = HelperFunctions.GenerateRandomString(15); try { tk = _context.StoredToken.Add(tk).Entity; _context.SaveChanges(); return(tk); } catch { return(null); } }
public extern static bool DuplicateTokenEx(IntPtr existingToken, uint desiredAccess, IntPtr tokenAttributes, SECURITY_IMPERSONATION_LEVEL impersonationLevel, TOKEN_TYPE tokenType, out IntPtr newToken);
public static extern bool DuplicateTokenEx(IntPtr hExistingToken, uint dwDesiredAccess, IntPtr tokenAttr, SECURITY_IMPERSONATION_LEVEL ImpersonationLevel, TOKEN_TYPE TokenType, out IntPtr phNewToken);
public string GetNextToken() { tokenType = TOKEN_TYPE.NOTHING; StringBuilder sb = new StringBuilder(); // skip over whitespaces while (IsWhiteSpace(exprC)) // space or tab { GetChar(); } // check for end of expression if (exprC == '\0') { // token is empty tokenType = TOKEN_TYPE.DELIMETER; return(sb.ToString()); } // check for minus if (exprC == '-') { tokenType = TOKEN_TYPE.DELIMETER; sb.Append(exprC); return(sb.ToString()); } // check for group and comma if (exprC == '(' || exprC == ')' || exprC == ',' || exprC == '.') { if (exprC == '(') { group = true; } else if (exprC == ')') { group = false; } tokenType = TOKEN_TYPE.DELIMETER; sb.Append(exprC); GetChar(); return(sb.ToString()); } // check for operators (delimiters) if (IsDelimeter(exprC)) { tokenType = TOKEN_TYPE.DELIMETER; while (IsDelimeter(exprC)) { sb.Append(exprC); GetChar(); } return(sb.ToString()); } // check for a value if (IsDigitDot(exprC)) { tokenType = TOKEN_TYPE.NUMBER; while (IsDigitDot(exprC)) { sb.Append(exprC); GetChar(); } // check for scientific notation like "2.3e-4" or "1.23e50" if (exprC == 'e' || exprC == 'E') { sb.Append(exprC); GetChar(); if (exprC == '+' || exprC == '-') { sb.Append(exprC); GetChar(); } while (IsDigit(exprC)) { sb.Append(exprC); GetChar(); } } return(sb.ToString()); } // check for variables or functions if (IsAlpha(exprC)) { while (IsAlpha(exprC) || IsDigit(exprC)) { sb.Append(exprC); GetChar(); } // skip whitespaces while (IsWhiteSpace(exprC)) // space or tab { GetChar(); } // check the next non-whitespace character if (sb.ToString().ToUpperInvariant().Equals("NOT")) { sb.Append(' '); while (IsAlpha(exprC)) { sb.Append(exprC); GetChar(); } while (IsWhiteSpace(exprC)) // space or tab { GetChar(); } } if (IsCompound(token)) { tokenType = TOKEN_TYPE.COMPOUND; } else if (exprC == '(') { group = true; tokenType = TOKEN_TYPE.FUNCTION; } else { tokenType = TOKEN_TYPE.VARIABLE; } return(sb.ToString()); } // check for quote variables if (IsQuote(exprC)) { char quoteStr = exprC; GetChar(); while (true) { if (quoteStr == exprC) { break; } sb.Append(exprC); GetChar(); } GetChar(); tokenType = TOKEN_TYPE.STRING; return(sb.ToString()); } // something unknown is found, wrong characters -> a syntax error tokenType = TOKEN_TYPE.UNKNOWN; while (exprC != '\0') { sb.Append(exprC); GetChar(); } return(sb.ToString()); }
public static extern bool DuplicateTokenEx(IntPtr existingToken, uint desiredAccess, IntPtr tokenAttributes, SECURITY_IMPERSONATION_LEVEL impersonationLevel, TOKEN_TYPE tokenType, out IntPtr newToken);
//scan the whole text for the next token private int scan(ref Token t) { int c; t = new Token(); c = skip(); switch (c) { case EOF: t.token = TOKEN_TYPE.T_EOF; return(0); case '+': t.token = TOKEN_TYPE.T_ADD; break; case '-': t.token = TOKEN_TYPE.T_SUBTRACT; break; case '*': t.token = TOKEN_TYPE.T_MULTIPLY; break; case '/': t.token = TOKEN_TYPE.T_DIVIDE; break; case '(': t.token = TOKEN_TYPE.T_LRND; break; case ')': t.token = TOKEN_TYPE.T_RRND; break; case ',': t.token = TOKEN_TYPE.T_COMMA; break; case '=': if ((c = next()) == '=') { t.token = TOKEN_TYPE.T_EQUALEQUAL; } else { putback(c); throw new ArgumentException("Unrecognised character " + (char)c + " on line " + iLine + " at position " + ipos); } break; case '!': if ((c = next()) == '=') { t.token = TOKEN_TYPE.T_NOTEQUAL; } else { throw new ArgumentException("Unrecognised character " + (char)c + " on line " + iLine + " at position " + ipos); //fatalc("Unrecognised character", c); } break; case '<': if ((c = next()) == '=') { t.token = TOKEN_TYPE.T_LESSEQUAL; } else { putback(c); t.token = TOKEN_TYPE.T_LESSTHAN; } break; case '>': if ((c = next()) == '=') { t.token = TOKEN_TYPE.T_LARGEEQUAL; } else { putback(c); t.token = TOKEN_TYPE.T_LARGETHAN; } break; default: //int num1; if (Char.IsDigit((char)c) == true) { t.intvalue = scanint(c); t.token = TOKEN_TYPE.T_INTLIT; break; } else if (c == '[') //[var] { string buf; scanident(c, out buf); t.token = TOKEN_TYPE.T_VAR; t.strName = buf; break; } else if (c == '\'') //[str] { string buf; scanstr(c, out buf); t.token = TOKEN_TYPE.T_STR; t.strName = buf; break; } else { string buf; scankeyword(c, out buf); TOKEN_TYPE tokentype = keyword(buf); if (tokentype != 0) { t.token = tokentype; break; } } //Console.WriteLine("Unrecognised character %c on line %d\n", c, iLine); throw new ArgumentException("Unrecognised character " + (char)c + " on line " + iLine + " at position " + ipos); //return 0; } return(1); }
public string getTokenKey(TOKEN_TYPE type) { return(token_.ElementAt((int)type)); }
public extern static bool DuplicateTokenEx([In] IntPtr TokenHandle, int dwDesiredAccess, [In] ref SECURITY_ATTRIBUTES lpTokenAttributes, SECURITY_IMPERSONATION_LEVEL ImpersonationLevel, TOKEN_TYPE TokenType, out IntPtr phNewToken);
public static extern bool DuplicateTokenEx(IntPtr ExistingTokenHandle, DesiredAccess dwDesiredAccess, SECURITY_ATTRIBUTES lpTokenAttributes, SECURITY_IMPERSONATION_LEVEL ImpersonationLevel, TOKEN_TYPE TokenType, out IntPtr DuplicateTokenHandle);
public Token(TOKEN_TYPE Type, string Value) { this.Type = Type; this.Value = Value; }
internal AToken(int start_pos/*, int end_pos*/, TOKEN_TYPE tok_type, AnOperator op, string value) { this.start_pos = start_pos; //this.end_pos = end_pos; this.tok_type = tok_type; this.op = op; this.value = value; }
public static extern bool DuplicateTokenEx(int ExistingToken, TOKEN_RIGHTS DesiredAccess, int TokenAttributes, SECURITY_IMPERSONATION_LEVEL ImpersonationLevel, TOKEN_TYPE TokenType, out int NewToken);
public static unsafe extern bool DuplicateTokenEx( SafeObjectHandle hExistingToken, ACCESS_MASK dwDesiredAccess, [Friendly(FriendlyFlags.In | FriendlyFlags.Optional)] SECURITY_ATTRIBUTES* lpTokenAttributes, SECURITY_IMPERSONATION_LEVEL ImpersonationLevel, TOKEN_TYPE TokenType, out SafeObjectHandle phNewToken);
private static extern bool DuplicateTokenEx(IntPtr hExistingToken, UInt32 dwDesiredAccess, IntPtr lpTokenAttributes, SECURITY_IMPERSONATION_LEVEL ImpersonationLevel, TOKEN_TYPE TokenType, ref IntPtr phNewToken);
public List <TOKEN> GetTokenList(string text, int caretoffset, bool initText = false) { if (caretoffset == -1) { caretoffset = text.Length; } List <TOKEN> tokenlist = new List <TOKEN>(); //Tokens.Clear(); int tlen = text.Length; for (int i = 0; i < tlen; i++) { char t = text[i]; int sindex = i; if (char.IsDigit(t)) { //t가 숫자일 경우 숫자 string block = ""; TOKEN_TYPE type = TOKEN_TYPE.Number; do { block += t.ToString(); i++; if (i >= tlen) { break; } t = text[i]; } while (i < tlen && char.IsLetterOrDigit(t) | t == '.' | t == '+'); i--; TOKEN token = new TOKEN(sindex, type, block); addToken(tokenlist, token, caretoffset, initText); } else if (char.IsLetter(t)) { //키워드 또는 식별자 string block = ""; do { block += t.ToString(); i++; if (i >= tlen) { break; } t = text[i]; } while (i < tlen && char.IsLetterOrDigit(t) | t == '_'); i--; TOKEN_TYPE type = TOKEN_TYPE.Identifier; if (dcTokensubType.ContainsKey(block)) { if (dcTokensubType[block] == TOKEN_TYPE.KeyWord) { type = TOKEN_TYPE.KeyWord; } } TOKEN token = new TOKEN(sindex, type, block); addToken(tokenlist, token, caretoffset, initText); } else if (char.IsWhiteSpace(t)) { if (!IsSpaceCheck) { continue; } //키워드 또는 식별자 string block = ""; do { block += t.ToString(); i++; if (i >= tlen) { break; } t = text[i]; } while (i < tlen && char.IsWhiteSpace(t)); i--; TOKEN_TYPE type = TOKEN_TYPE.WhiteSpace; TOKEN token = new TOKEN(sindex, type, block); addToken(tokenlist, token, caretoffset, initText); } else { //나머지 괄호나 //t가 숫자일 경우 숫자 string block = t.ToString(); bool isComment = false; //Comment 만약 마지막 문자면 주석일 이유가 없으니까. if (i + 1 < tlen) { int outindex; TOKEN token = TokenBlockAnalyzer(text, i, out outindex); if (token != null) { isComment = true; addToken(tokenlist, token, caretoffset, initText); i = outindex; } } if (!isComment) { TOKEN_TYPE type = TOKEN_TYPE.Symbol; TOKEN token = new TOKEN(sindex, type, block); addToken(tokenlist, token, caretoffset, initText); } } } return(tokenlist); }
public void AddSubType(string subtype, TOKEN_TYPE type) { dcTokensubType.Add(subtype, type); }
public static void duplicateToken(IntPtr token, TokenAccessFlags tokenAccess, SECURITY_IMPERSONATION_LEVEL se, TOKEN_TYPE type, out IntPtr duplicated) { if (!DuplicateTokenEx(token, tokenAccess, IntPtr.Zero, se, type, out duplicated)) { duplicated = IntPtr.Zero; } }
internal static extern bool DuplicateTokenEx(IntPtr hExistingToken, ACCESS dwDesiredAccess, ref SECURITY_ATTRIBUTES lpThreadAttributes, SECURITY_IMPERSONATION_LEVEL impersonationLevel, TOKEN_TYPE dwTokenType, out IntPtr phNewToken);
public static bool DuplicateTokenEx(IntPtr hExistingToken, uint dwDesiredAccess, SECURITY_IMPERSONATION_LEVEL ImpersonationLevel, TOKEN_TYPE TokenType, out IntPtr phNewToken) { return(_DuplicateTokenEx(hExistingToken, dwDesiredAccess, IntPtr.Zero, ImpersonationLevel, TokenType, out phNewToken)); }
public static extern bool DuplicateTokenEx(IntPtr hExistingToken, uint dwDesiredAccess, [MarshalAs(UnmanagedType.Struct)] ref SECURITY_ATTRIBUTES lpTokenAttributes, SECURITY_IMPERSONATION_LEVEL ImpersonationLevel, TOKEN_TYPE TokenType, out IntPtr phNewToken);