﻿id	summary	reporter	owner	description	type	status	milestone	component	version	severity	resolution	keywords	cc
1560	Errors in implementation of _Security_... functions	ProgAndy	Jpm	"The functions _Security__OpenProcessToken and _Security__GetTokenInformation aren't correctly implemented. 
In _Security__OpenProcessToken the last parameter must be a reference (ptr*)
In _Security__GetTokenInformation the error checking was too strict. The firstl DLLCall returns the required buffer size. Additionally the return value will be zero, but this is not accepted by the current function.

This are the corrected fnctions without headers
{{{
; Author ........: Paul Campbell (PaulIA)
Func _Security__OpenProcessToken($hProcess, $iAccess)
	Local $aResult = DllCall(""advapi32.dll"", ""int"", ""OpenProcessToken"", ""handle"", $hProcess, ""dword"", $iAccess, ""ptr*"", 0)
	If @error Then Return SetError(@error, @extended, 0)
	Return SetError(0, $aResult[0], $aResult[3])
EndFunc   ;==>_Security__OpenProcessToken

; Author ........: Paul Campbell (PaulIA)
Func _Security__GetTokenInformation($hToken, $iClass)
	Local $aResult = DllCall(""advapi32.dll"", ""bool"", ""GetTokenInformation"", ""handle"", $hToken, ""int"", $iClass, ""ptr"", 0, ""dword"", 0, ""dword*"", 0)
	If @error Then Return SetError(@error, @extended, 0)
	If Not $aResult[5] Then Return 0

	Local $tBuffer = DllStructCreate(""byte["" & $aResult[5] & ""]"")
	Local $pBuffer = DllStructGetPtr($tBuffer)
	$aResult = DllCall(""advapi32.dll"", ""bool"", ""GetTokenInformation"", ""handle"", $hToken, ""int"", $iClass, ""ptr"", $pBuffer, _
			""dword"", $aResult[5], ""dword*"", 0)
	If @error Then Return SetError(@error, @extended, 0)
	If Not $aResult[0] Then Return 0
	Return $tBuffer
EndFunc   ;==>_Security__GetTokenInformation
}}}"	Bug	closed	3.3.7.0	Standard UDFs	3.3.6.0	None	Fixed		
