A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://www.ncbi.nlm.nih.gov/IEB/ToolBox/CPP_DOC/doxyhtml/ncbi__os__mswin_8cpp_source.html below:

NCBI C++ ToolKit: src/corelib/ncbi_os_mswin.cpp Source File

40 #define MAX_ACCOUNT_LEN 256 43 # ifdef PRIMARY_POSIX_OFFSET 44 # define CYGWIN_PRIMARY_ID_OFFSET PRIMARY_POSIX_OFFSET 46 # define CYGWIN_PRIMARY_ID_OFFSET 0x100000 50 #define ACCOUNT_SECURITY_INFO (OWNER_SECURITY_INFORMATION | \ 51  GROUP_SECURITY_INFORMATION) 53 #define FILE_SECURITY_INFO (OWNER_SECURITY_INFORMATION | \ 54  GROUP_SECURITY_INFORMATION | \ 55  DACL_SECURITY_INFORMATION) 63  DWORD

name_size =

sizeof

(name) /

sizeof

(name[0]) - 1;

69

name[name_size] =

_TX

(

'\0'

);

83  DWORD

domain_size = 0;

89  if

( !::LookupAccountName(

NULL

, name.c_str(), sid, &sid_size, domain, &domain_size, &use) ) {

90  DWORD

err = ::GetLastError();

91  if

(err != ERROR_INSUFFICIENT_BUFFER) {

98

sid = (PSID) LocalAlloc(LMEM_FIXED, sid_size);

100  if

( !sid || !domain ) {

104  if

( !LookupAccountName(

NULL

, name.c_str(), sid, &sid_size, domain, &domain_size, &use) ) {

119  if

( domain )

free

(domain);

138  DWORD

account_size =

sizeof

(account_name)/

sizeof

(account_name[0]) - 1;

139  DWORD

domain_size =

sizeof

(domain_name)/

sizeof

(domain_name[0]) - 1;

145  if

( !::LookupAccountSid(

NULL

, sid,

146

account_name, &account_size,

147

domain_name, &domain_size, &use) ) {

154

account_name[account_size] =

_TX

(

'\0'

);

159  if

(*domatch !=

int

(use)) {

162

domain_name[domain_size] =

_TX

(

'\0'

);

179  string

* owner_name,

string

* group_name,

180  unsigned int

* uid,

unsigned int

* gid)

182  bool

success =

true

;

186  int match

= SidTypeUser;

195

*uid += *::GetSidSubAuthority(owner_sid, *::GetSidSubAuthorityCount(owner_sid) - 1);

199  int match

= SidTypeGroup;

206

*gid += *::GetSidSubAuthority(group_sid, *::GetSidSubAuthorityCount(group_sid) - 1);

228

SE_OBJECT_TYPE obj_type,

229  string

* owner,

string

* group,

230  unsigned int

* uid,

unsigned int

* gid)

234

PSECURITY_DESCRIPTOR sd;

237

&sid_owner, &sid_group,

NULL

,

NULL

, &sd);

238  if

( res != ERROR_SUCCESS ) {

249

SE_OBJECT_TYPE obj_type,

250  string

* owner,

string

* group,

251  unsigned int

* uid,

unsigned int

* gid)

255

PSECURITY_DESCRIPTOR sd;

259

&sid_owner, &sid_group,

NULL

,

NULL

, &sd);

260  if

( res != ERROR_SUCCESS ) {

275  if

( !::OpenThreadToken(GetCurrentThread(), access,

FALSE

, &token) ) {

276  DWORD

res = GetLastError();

277  if

( res == ERROR_NO_TOKEN ) {

278  if

( !::ImpersonateSelf(SecurityImpersonation) ) {

283  if

( !::OpenThreadToken(GetCurrentThread(), access,

FALSE

, &token) ) {

300  const string

& owner,

const string

& group,

301  unsigned int

* uid,

unsigned int

* gid)

303  _ASSERT

(!owner.empty() || !group.empty());

306

PSID owner_sid =

NULL

;

307

PSID group_sid =

NULL

;

308  bool

success =

false

;

309

SECURITY_INFORMATION security_info = 0;

312  if

( !owner.empty() ) {

318  if

( !group.empty() ) {

331

security_info |= OWNER_SECURITY_INFORMATION;

334

security_info |= GROUP_SECURITY_INFORMATION;

339

SE_FILE_OBJECT, security_info,

340

owner_sid, group_sid,

NULL

,

NULL

) == ERROR_SUCCESS ) {

351  bool

prev_ownership_name;

352  bool

prev_restore_name;

354  if

( !

SetTokenPrivilege

(token, SE_TAKE_OWNERSHIP_NAME,

true

, &prev_ownership_name) ) {

361

SE_FILE_OBJECT, security_info,

362

owner_sid, group_sid,

NULL

,

NULL

) == ERROR_SUCCESS ) {

372  if

( group_sid ) ::LocalFree(group_sid);

373  if

( owner_sid ) ::LocalFree(owner_sid);

380  bool

enable,

bool

*

prev

)

384  if

( !::LookupPrivilegeValue(

NULL

, privilege, &luid) ) {

392

TOKEN_PRIVILEGES tp_prev;

393  DWORD

tp_size =

sizeof

(tp);

395

tp.PrivilegeCount = 1;

396

tp.Privileges[0].Luid = luid;

397

tp.Privileges[0].Attributes = 0;

399

::AdjustTokenPrivileges(token,

FALSE

, &tp, tp_size, &tp_prev, &tp_size);

400  DWORD

res = GetLastError();

401  if

( res != ERROR_SUCCESS ) {

409

tp.PrivilegeCount = 1;

410

tp.Privileges[0].Luid = luid;

412

*

prev

= ((tp_prev.Privileges[0].Attributes & SE_PRIVILEGE_ENABLED) == SE_PRIVILEGE_ENABLED);

414

tp.Privileges[0].Attributes = enable ? SE_PRIVILEGE_ENABLED : 0;

416

::AdjustTokenPrivileges(token,

FALSE

, &tp, tp_size,

NULL

,

NULL

);

417

res = GetLastError();

418  if

( res != ERROR_SUCCESS ) {

444  if

( path.empty() ) {

448

PSECURITY_DESCRIPTOR sd =

NULL

;

453  DWORD

err = ::GetLastError();

454  if

(err != ERROR_INSUFFICIENT_BUFFER) {

459

sd = (PSECURITY_DESCRIPTOR) ::LocalAlloc(LMEM_FIXED, size_need);

467

::LocalFree((HLOCAL) sd);

481  if

( !permissions ) {

497  bool

success =

true

;

505

GENERIC_MAPPING mapping;

506

memset(&mapping, 0,

sizeof

(mapping));

508

PRIVILEGE_SET privileges;

509  DWORD

privileges_size =

sizeof

(privileges);

512  if

( !::AccessCheck(sd, token, MAXIMUM_ALLOWED, &mapping,

513

&privileges, &privileges_size, permissions,

514

&status) || !status ) {

524

::CloseHandle(token);

534  HANDLE const

snapshot = ::CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);

537

entry.dwSize =

sizeof

(PROCESSENTRY32);

538  BOOL

ret = ::Process32First(snapshot, &entry);

539  while

(ret && entry.th32ProcessID !=

id

) {

540

ret = ::Process32Next(snapshot, &entry);

542

::CloseHandle(snapshot);

static bool FindProcessEntry(DWORD id, PROCESSENTRY32 &entry)

Find process entry information by process identifier (pid).

static bool GetFilePermissions(const string &path, ACCESS_MASK *permissions)

Get file access permissions.

static string GetUserName(void)

Get name of the current user.

static bool SetTokenPrivilege(HANDLE token, LPCTSTR privilege, bool enable, bool *prev=0)

Enables or disables privileges in the specified access token.

static bool SetFileOwner(const string &filename, const string &owner, const string &group=kEmptyStr, unsigned int *uid=0, unsigned int *gid=0)

Set file object owner.

static bool GetObjectOwner(const string &obj_name, SE_OBJECT_TYPE obj_type, string *owner, string *group, unsigned int *uid=0, unsigned int *gid=0)

Get owner name of specified system object.

static bool SetThreadPrivilege(LPCTSTR privilege, bool enable, bool *prev=0)

Enables or disables privileges for the current thread.

The NCBI C++ standard methods for dealing with std::string.

static void cleanup(void)

static DLIST_TYPE *DLIST_NAME() prev(DLIST_LIST_TYPE *list, DLIST_TYPE *item)

static void SetFromWindowsError(void)

Set last error on MS Windows using GetLastError()

static void Set(ECode code)

Set last error using native error code enum.

static const CNcbiError & GetLast(void)

Get the error that was last set (in the current thread)

static void SetWindowsError(int native_err_code)

Set last error using Windows-specific error code.

@ eUnknown

Unknown error.

#define END_NCBI_SCOPE

End previously defined NCBI scope.

#define BEGIN_NCBI_SCOPE

Define ncbi namespace.

static SIZE_TYPE FindNoCase(const CTempString str, const CTempString pattern, SIZE_TYPE start, SIZE_TYPE end, EOccurrence which=eFirst)

Find the pattern in the specified range of a string using a case insensitive search.

static bool EqualNocase(const CTempString s1, SIZE_TYPE pos, SIZE_TYPE n, const char *s2)

Case-insensitive equality of a substring with another string.

#define INVALID_HANDLE_VALUE

A value for an invalid file handle.

#define HANDLE

An abstraction for a file handle.

const struct ncbi::grid::netcache::search::fields::SIZE size

#define FILE_SECURITY_INFO

static PSID x_GetAccountSidByName(const string &account, SID_NAME_USE type=(SID_NAME_USE) 0)

#define CYGWIN_PRIMARY_ID_OFFSET

static bool x_GetAccountNameBySid(PSID sid, string *account, int *domatch=0)

static bool s_GetOwnerGroupFromSIDs(PSID owner_sid, PSID group_sid, string *owner_name, string *group_name, unsigned int *uid, unsigned int *gid)

static HANDLE s_GetCurrentThreadToken(DWORD access)

static PSECURITY_DESCRIPTOR s_GetFileSecurityDescriptor(const string &path)

#define ACCOUNT_SECURITY_INFO

Defines MS Windows specific private functions and classes.

#define FALSE

bool replacment for C indicating false.

Defines NCBI C++ diagnostic APIs, classes, and macros.

Defines NCBI C++ Toolkit portable error codes.

static int match(PCRE2_SPTR start_eptr, PCRE2_SPTR start_ecode, uint16_t top_bracket, PCRE2_SIZE frame_size, pcre2_match_data *match_data, match_block *mb)


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4