def obtain_privileges(privileges):
	"""
	Given a list of SE privilege names (eg: [ SE_CREATE_TOKEN_NAME, SE_BACKUP_NAME ]), lookup
	the privilege values for each and then attempt to acquire them for the current process.
	"""
	global _obtained_privileges
	privileges = filter(lambda priv: priv not in _obtained_privileges, list(set(privileges)))
	privcount = len(privileges)
	if privcount == 0: return

	class TOKEN_PRIVILEGES(ctypes.Structure):
		#noinspection PyTypeChecker
		_fields_ = [
			('PrivilegeCount', DWORD),
			('Privileges', LUID_AND_ATTRIBUTES * privcount),
		]

	with HANDLE() as hToken:
		tp = TOKEN_PRIVILEGES()
		tp.PrivilegeCount = privcount
		hProcess = GetCurrentProcess()
		if not OpenProcessToken(hProcess, TOKEN_ADJUST_PRIVILEGES, byref(hToken)):
			raise WinError()

		for i, privilege in enumerate(privileges):
			tp.Privileges[i].Attributes = SE_PRIVILEGE_ENABLED
			if not LookupPrivilegeValue(None, privilege, byref(tp.Privileges[i])):
				raise Exception('LookupPrivilegeValue failed for privilege: {0}'.format(privilege))

		if not AdjustTokenPrivileges(hToken, False, byref(tp), sizeof(TOKEN_PRIVILEGES), None, None):
			raise WinError()

		_obtained_privileges.extend(privileges)

	Given a list of SE privilege names (eg: [ SE_CREATE_TOKEN_NAME, SE_BACKUP_NAME ]), lookup
	the privilege values for each and then attempt to acquire them for the current process.
	
recipes/Python/578849_Reimplementatirmtree_supporting_Windows_reparse_/recipe-578849.py