Index: apitests/advapi32/CMakeLists.txt =================================================================== --- modules/rostests/apitests/advapi32/CMakeLists.txt (revision 58278) +++ modules/rostests/apitests/advapi32/CMakeLists.txt (working copy) @@ -1,12 +1,13 @@ list(APPEND SOURCE - CreateService.c - LockDatabase.c - QueryServiceConfig2.c - testlist.c) + CreateService.c + LockDatabase.c + QueryServiceConfig2.c + SaferIdentifyLevel.c + testlist.c) add_executable(advapi32_apitest ${SOURCE}) -target_link_libraries(advapi32_apitest wine) +target_link_libraries(advapi32_apitest wine ${PSEH_LIB}) set_module_type(advapi32_apitest win32cui) add_importlibs(advapi32_apitest advapi32 msvcrt kernel32 ntdll) add_cd_file(TARGET advapi32_apitest DESTINATION reactos/bin FOR all) Index: apitests/advapi32/SaferIdentifyLevel.c =================================================================== --- modules/rostests/apitests/advapi32/SaferIdentifyLevel.c (revision 0) +++ modules/rostests/apitests/advapi32/SaferIdentifyLevel.c (working copy) @@ -0,0 +1,125 @@ +/* + * PROJECT: ReactOS api tests + * LICENSE: GPLv2+ - See COPYING in the top level directory + * PURPOSE: Test for SaferIdentifyLevel + * PROGRAMMER: Thomas Faber + */ + +#define WIN32_NO_STATUS +#include +#include +#include +#include + +#define StartSeh() ExceptionStatus = STATUS_SUCCESS; _SEH2_TRY { +#define EndSeh(ExpectedStatus) } _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) { ExceptionStatus = _SEH2_GetExceptionCode(); } _SEH2_END; ok(ExceptionStatus == ExpectedStatus, "Exception %lx, expected %lx\n", ExceptionStatus, ExpectedStatus) + +#define InvalidPointer ((PVOID)0x5555555555555555ULL) + +#define SaferIdentifyLevel(c, p, h, r) SaferIdentifyLevel(c, (PSAFER_CODE_PROPERTIES)(p), h, r) + +START_TEST(SaferIdentifyLevel) +{ + NTSTATUS ExceptionStatus; + BOOL ret; + DWORD error; + SAFER_LEVEL_HANDLE handle; + SAFER_CODE_PROPERTIES_V2 props[16]; + + StartSeh() + SetLastError(0xbadbad00); + ret = SaferIdentifyLevel(0, NULL, NULL, NULL); + error = GetLastError(); + ok(ret == FALSE, "ret = %d\n", ret); + ok(error == ERROR_NOACCESS, "error = %lu\n", error); + EndSeh(STATUS_SUCCESS); + + StartSeh() + (VOID)SaferIdentifyLevel(0, NULL, &handle, NULL); + EndSeh(STATUS_ACCESS_VIOLATION); + + StartSeh() + ZeroMemory(props, sizeof(props)); + SetLastError(0xbadbad00); + ret = SaferIdentifyLevel(16, props, &handle, NULL); + error = GetLastError(); + ok(ret == FALSE, "ret = %d\n", ret); + ok(error == ERROR_BAD_LENGTH, "error = %lu\n", error); + EndSeh(STATUS_SUCCESS); + + StartSeh() + ZeroMemory(props, sizeof(props)); + SetLastError(0xbadbad00); + ret = SaferIdentifyLevel(1, props, NULL, NULL); + error = GetLastError(); + ok(ret == FALSE, "ret = %d\n", ret); + ok(error == ERROR_NOACCESS, "error = %lu\n", error); + EndSeh(STATUS_SUCCESS); + + StartSeh() + handle = InvalidPointer; + ZeroMemory(props, sizeof(props)); + SetLastError(0xbadbad00); + ret = SaferIdentifyLevel(1, props, &handle, NULL); + error = GetLastError(); + ok(ret == FALSE, "ret = %d\n", ret); + ok(handle == InvalidPointer, "handle = %p\n", handle); + ok(error == ERROR_BAD_LENGTH, "error = %lu\n", error); + if (handle && handle != InvalidPointer) + SaferCloseLevel(handle); + EndSeh(STATUS_SUCCESS); + + /* Struct sizes */ + StartSeh() + handle = InvalidPointer; + ZeroMemory(props, sizeof(props)); + props[0].cbSize = sizeof(SAFER_CODE_PROPERTIES_V1); + SetLastError(0xbadbad00); + ret = SaferIdentifyLevel(1, props, &handle, NULL); + error = GetLastError(); + ok(ret == TRUE, "ret = %d\n", ret); + ok(handle != NULL && handle != INVALID_HANDLE_VALUE && handle != InvalidPointer, "handle = %p\n", handle); + ok(error == 0xbadbad00, "error = %lu\n", error); + if (handle && handle != InvalidPointer) + { + ret = SaferCloseLevel(handle); + ok(ret == TRUE, "ret = %d\n", ret); + } + EndSeh(STATUS_SUCCESS); + + StartSeh() + handle = InvalidPointer; + ZeroMemory(props, sizeof(props)); + props[0].cbSize = sizeof(SAFER_CODE_PROPERTIES_V2); + SetLastError(0xbadbad00); + ret = SaferIdentifyLevel(1, props, &handle, NULL); + error = GetLastError(); + ok(ret == FALSE, "ret = %d\n", ret); + ok(handle == InvalidPointer, "handle = %p\n", handle); + ok(error == ERROR_BAD_LENGTH, "error = %lu\n", error); + if (handle && handle != InvalidPointer) + SaferCloseLevel(handle); + EndSeh(STATUS_SUCCESS); + + /* Test SaferCloseLevel too */ + StartSeh() + ret = SaferCloseLevel(NULL); + error = GetLastError(); + ok(ret == FALSE, "ret = %d\n", ret); + ok(error == ERROR_INVALID_HANDLE, "error = %lu\n", error); + EndSeh(STATUS_SUCCESS); + + StartSeh() + ret = SaferCloseLevel(INVALID_HANDLE_VALUE); + error = GetLastError(); + ok(ret == FALSE, "ret = %d\n", ret); + ok(error == ERROR_INVALID_HANDLE, "error = %lu\n", error); + EndSeh(STATUS_SUCCESS); + + StartSeh() + ret = SaferCloseLevel(InvalidPointer); + error = GetLastError(); + ok(ret == FALSE, "ret = %d\n", ret); + ok(error == ERROR_INVALID_HANDLE, "error = %lu\n", error); + EndSeh(STATUS_SUCCESS); +} Index: apitests/advapi32/SaferIdentifyLevel.c =================================================================== --- modules/rostests/apitests/advapi32/SaferIdentifyLevel.c (revision 0) +++ modules/rostests/apitests/advapi32/SaferIdentifyLevel.c (working copy) Property changes on: apitests/advapi32/SaferIdentifyLevel.c ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Index: apitests/advapi32/testlist.c =================================================================== --- modules/rostests/apitests/advapi32/testlist.c (revision 58278) +++ modules/rostests/apitests/advapi32/testlist.c (working copy) @@ -8,12 +8,14 @@ extern void func_CreateService(void); extern void func_LockDatabase(void); extern void func_QueryServiceConfig2(void); +extern void func_SaferIdentifyLevel(void); const struct test winetest_testlist[] = { { "CreateService", func_CreateService }, { "LockDatabase" , func_LockDatabase }, { "QueryServiceConfig2", func_QueryServiceConfig2 }, + { "SaferIdentifyLevel", func_SaferIdentifyLevel }, { 0, 0 } }; Index: dll/win32/advapi32/advapi32.spec =================================================================== --- dll/win32/advapi32/advapi32.spec (revision 58278) +++ dll/win32/advapi32/advapi32.spec (working copy) @@ -555,13 +555,13 @@ @ stdcall ReportEventA(long long long long ptr long long str ptr) @ stdcall ReportEventW(long long long long ptr long long wstr ptr) @ stdcall RevertToSelf() -@ stub SaferCloseLevel -@ stub SaferComputeTokenFromLevel +@ stdcall SaferCloseLevel(ptr) +@ stdcall SaferComputeTokenFromLevel(ptr ptr ptr long ptr) @ stdcall SaferCreateLevel(long long long ptr ptr) @ stub SaferGetLevelInformation @ stdcall SaferGetPolicyInformation(long long long ptr ptr ptr) -@ stub SaferIdentifyLevel -@ stub SaferRecordEventLogEntry +@ stdcall SaferIdentifyLevel(long ptr ptr ptr) +@ stdcall SaferRecordEventLogEntry(ptr wstr ptr) @ stub SaferSetLevelInformation @ stub SaferSetPolicyInformation @ stub SaferiChangeRegistryScope Index: dll/win32/advapi32/CMakeLists.txt =================================================================== --- dll/win32/advapi32/CMakeLists.txt (revision 58278) +++ dll/win32/advapi32/CMakeLists.txt (working copy) @@ -14,7 +14,6 @@ ${REACTOS_SOURCE_DIR}/include/reactos/idl/eventlogrpc.idl ${REACTOS_SOURCE_DIR}/include/reactos/idl/lsa.idl ${REACTOS_SOURCE_DIR}/include/reactos/idl/svcctl.idl) - list(APPEND SOURCE crypt/crypt.c @@ -38,6 +37,7 @@ sec/cred.c sec/lsa.c sec/misc.c + sec/safer.c sec/sec.c sec/sid.c sec/trustee.c Index: dll/win32/advapi32/sec/misc.c =================================================================== --- dll/win32/advapi32/sec/misc.c (revision 58278) +++ dll/win32/advapi32/sec/misc.c (working copy) @@ -2280,26 +2280,6 @@ } /****************************************************************************** - * SaferCreateLevel [ADVAPI32.@] - */ -BOOL WINAPI SaferCreateLevel(DWORD ScopeId, DWORD LevelId, DWORD OpenFlags, - SAFER_LEVEL_HANDLE* LevelHandle, LPVOID lpReserved) -{ - FIXME("(%u, %x, %u, %p, %p) stub\n", ScopeId, LevelId, OpenFlags, LevelHandle, lpReserved); - return FALSE; -} - -/****************************************************************************** - * SaferGetPolicyInformation [ADVAPI32.@] - */ -BOOL WINAPI SaferGetPolicyInformation(DWORD scope, SAFER_POLICY_INFO_CLASS class, DWORD size, - PVOID buffer, PDWORD required, LPVOID lpReserved) -{ - FIXME("(%u %u %u %p %p %p) stub\n", scope, class, size, buffer, required, lpReserved); - return FALSE; -} - -/****************************************************************************** * QueryWindows31FilesMigration [ADVAPI32.@] * * PARAMS Index: dll/win32/advapi32/sec/safer.c =================================================================== --- dll/win32/advapi32/sec/safer.c (revision 0) +++ dll/win32/advapi32/sec/safer.c (working copy) @@ -0,0 +1,184 @@ +/* + * PROJECT: ReactOS system libraries + * LICENSE: GPLv2+ - See COPYING in the top level directory + * PURPOSE: Safer functions + * PROGRAMMER: Thomas Faber + */ + +/* INCLUDES ******************************************************************/ + +#include +WINE_DEFAULT_DEBUG_CHANNEL(advapi); + + +/* FUNCTIONS *****************************************************************/ + +/********************************************************************** + * SaferCreateLevel + * + * @unimplemented + */ +BOOL +WINAPI +SaferCreateLevel( + _In_ DWORD dwScopeId, + _In_ DWORD dwLevelId, + _In_ DWORD OpenFlags, + _Outptr_ SAFER_LEVEL_HANDLE *pLevelHandle, + _Reserved_ PVOID pReserved) +{ + FIXME("(%lu, %lu, %lu, %p, %p) stub\n", dwScopeId, dwLevelId, OpenFlags, pLevelHandle, pReserved); + *pLevelHandle = (SAFER_LEVEL_HANDLE)0x42; + return TRUE; +} + + +/********************************************************************** + * SaferIdentifyLevel + * + * @unimplemented + */ +BOOL +WINAPI +SaferIdentifyLevel( + _In_ DWORD dwNumProperties, + _In_reads_opt_(dwNumProperties) PSAFER_CODE_PROPERTIES pCodeProperties, + _Outptr_ SAFER_LEVEL_HANDLE *pLevelHandle, + _Reserved_ PVOID pReserved) +{ + DWORD i; + + if (pLevelHandle == NULL) + { + SetLastError(ERROR_NOACCESS); + return FALSE; + } + + for (i = 0; i < dwNumProperties; i++) + { + if (pCodeProperties[i].cbSize != sizeof(SAFER_CODE_PROPERTIES_V1)) + { + SetLastError(ERROR_BAD_LENGTH); + return FALSE; + } + } + + FIXME("(%lu, %p, %p, %p) stub\n", dwNumProperties, pCodeProperties, pLevelHandle, pReserved); + + *pLevelHandle = (SAFER_LEVEL_HANDLE)0x42; + return TRUE; +} + + +/********************************************************************** + * SaferCloseLevel + * + * @unimplemented + */ +BOOL +WINAPI +SaferCloseLevel( + _In_ SAFER_LEVEL_HANDLE hLevelHandle) +{ + FIXME("(%p) stub\n", hLevelHandle); + if (hLevelHandle != (SAFER_LEVEL_HANDLE)0x42) + return FALSE; + return TRUE; +} + + +BOOL +WINAPI +SaferGetLevelInformation( + _In_ SAFER_LEVEL_HANDLE LevelHandle, + _In_ SAFER_OBJECT_INFO_CLASS dwInfoType, + _Out_writes_bytes_opt_(dwInBufferSize) PVOID pQueryBuffer, + _In_ DWORD dwInBufferSize, + _Out_ PDWORD pdwOutBufferSize); + + +BOOL +WINAPI +SaferSetLevelInformation( + _In_ SAFER_LEVEL_HANDLE LevelHandle, + _In_ SAFER_OBJECT_INFO_CLASS dwInfoType, + _In_reads_bytes_(dwInBufferSize) PVOID pQueryBuffer, + _In_ DWORD dwInBufferSize); + + +/********************************************************************** + * SaferGetPolicyInformation + * + * @unimplemented + */ +BOOL +WINAPI +SaferGetPolicyInformation( + _In_ DWORD dwScopeId, + _In_ SAFER_POLICY_INFO_CLASS SaferPolicyInfoClass, + _In_ DWORD InfoBufferSize, + _Out_writes_bytes_opt_(InfoBufferSize) PVOID InfoBuffer, + _Out_ PDWORD InfoBufferRetSize, + _Reserved_ PVOID pReserved) +{ + FIXME("(%lu, %d, %lu, %p, %p, %p) stub\n", dwScopeId, SaferPolicyInfoClass, InfoBufferSize, InfoBuffer, InfoBufferRetSize, pReserved); + SetLastError(ERROR_CALL_NOT_IMPLEMENTED); + return FALSE; +} + + +BOOL +WINAPI +SaferSetPolicyInformation( + _In_ DWORD dwScopeId, + _In_ SAFER_POLICY_INFO_CLASS SaferPolicyInfoClass, + _In_ DWORD InfoBufferSize, + _In_reads_bytes_(InfoBufferSize) PVOID InfoBuffer, + _Reserved_ PVOID pReserved); + + +/********************************************************************** + * SaferComputeTokenFromLevel + * + * @unimplemented + */ +BOOL +WINAPI +SaferComputeTokenFromLevel( + _In_ SAFER_LEVEL_HANDLE LevelHandle, + _In_opt_ HANDLE InAccessToken, + _Out_ PHANDLE OutAccessToken, + _In_ DWORD dwFlags, + _Inout_opt_ PVOID pReserved) +{ + FIXME("(%p, %p, %p, 0x%lx, %p) stub\n", LevelHandle, InAccessToken, OutAccessToken, dwFlags, pReserved); + SetLastError(ERROR_CALL_NOT_IMPLEMENTED); + return FALSE; +} + + +/********************************************************************** + * SaferRecordEventLogEntry + * + * @unimplemented + */ +BOOL +WINAPI +SaferRecordEventLogEntry( + _In_ SAFER_LEVEL_HANDLE hLevel, + _In_ PCWSTR szTargetPath, + _Reserved_ PVOID pReserved) +{ + FIXME("(%p, %s, %p) stub\n", hLevel, wine_dbgstr_w(szTargetPath), pReserved); + SetLastError(ERROR_CALL_NOT_IMPLEMENTED); + return FALSE; +} + + +BOOL +WINAPI +SaferiIsExecutableFileType( + _In_ PCWSTR szFullPath, + _In_ BOOLEAN bFromShellExecute); + +/* EOF */ Index: dll/win32/advapi32/sec/safer.c =================================================================== --- dll/win32/advapi32/sec/safer.c (revision 0) +++ dll/win32/advapi32/sec/safer.c (working copy) Property changes on: dll/win32/advapi32/sec/safer.c ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Index: include/psdk/winsafer.h =================================================================== --- include/psdk/winsafer.h (revision 58287) +++ include/psdk/winsafer.h (working copy) @@ -1,37 +1,38 @@ /* - * Winsafer definitions + * winsafer.h * - * Copyright (C) 2009 Nikolay Sivov + * This file is part of the ReactOS PSDK package. * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. + * Contributors: + * Thomas Faber (thomas.faber@reactos.org) * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. + * THIS SOFTWARE IS NOT COPYRIGHTED * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + * This source code is offered for use in the public domain. You may + * use, modify or distribute it freely. + * + * This code is distributed in the hope that it will be useful but + * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY + * DISCLAIMED. This includes but is not limited to warranties of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * */ +#pragma once -#ifndef __WINE_WINSAFER_H -#define __WINE_WINSAFER_H +#ifndef _WINSAFER_H +#define _WINSAFER_H #include #include #ifdef __cplusplus extern "C" { -#endif +#endif /* __cplusplus */ DECLARE_HANDLE(SAFER_LEVEL_HANDLE); -#define SAFER_SCOPEID_MACHINE 1 -#define SAFER_SCOPEID_USER 2 +#define SAFER_SCOPEID_MACHINE 1 +#define SAFER_SCOPEID_USER 2 #define SAFER_LEVELID_DISALLOWED 0x00000 #define SAFER_LEVELID_UNTRUSTED 0x01000 @@ -39,22 +40,268 @@ #define SAFER_LEVELID_NORMALUSER 0x20000 #define SAFER_LEVELID_FULLYTRUSTED 0x40000 -#define SAFER_LEVEL_OPEN 1 +#define SAFER_LEVEL_OPEN 1 -WINADVAPI BOOL WINAPI SaferCreateLevel(DWORD,DWORD,DWORD,SAFER_LEVEL_HANDLE*,LPVOID); +#define SAFER_MAX_HASH_SIZE 64 +#define SAFER_MAX_DESCRIPTION_SIZE 256 +#define SAFER_MAX_FRIENDLYNAME_SIZE 256 -typedef enum _SAFER_POLICY_INFO_CLASS { +#define SAFER_TOKEN_NULL_IF_EQUAL 0x1 +#define SAFER_TOKEN_COMPARE_ONLY 0x2 +#define SAFER_TOKEN_MAKE_INERT 0x4 +#define SAFER_TOKEN_WANT_FLAGS 0x8 + +#define SAFER_CRITERIA_IMAGEPATH 0x0001 +#define SAFER_CRITERIA_NONSIGNEDHASH 0x0002 +#define SAFER_CRITERIA_IMAGEHASH 0x0004 +#define SAFER_CRITERIA_AUTHENTICODE 0x0008 +#define SAFER_CRITERIA_URLZONE 0x0010 +#define SAFER_CRITERIA_APPX_PACKAGE 0x0020 +#define SAFER_CRITERIA_IMAGEPATH_NT 0x1000 + +#define SAFER_POLICY_JOBID_UNTRUSTED 0x03000000 +#define SAFER_POLICY_JOBID_CONSTRAINED 0x04000000 +#define SAFER_POLICY_JOBID_MASK 0xFF000000 +#define SAFER_POLICY_ONLY_EXES 0x00040000 +#define SAFER_POLICY_SANDBOX_INERT 0x00020000 +#define SAFER_POLICY_HASH_DUPLICATE 0x00010000 +#define SAFER_POLICY_ONLY_AUDIT 0x00002000 +#define SAFER_POLICY_BLOCK_CLIENT_UI 0x00001000 +#define SAFER_POLICY_UIFLAGS_INFORMATION_PROMPT 0x00000001 +#define SAFER_POLICY_UIFLAGS_OPTION_PROMPT 0x00000002 +#define SAFER_POLICY_UIFLAGS_HIDDEN 0x00000004 +#define SAFER_POLICY_UIFLAGS_MASK 0x000000FF + + +#include + +typedef struct SAFER_CODE_PROPERTIES_V1 +{ + DWORD cbSize; + DWORD dwCheckFlags; + PCWSTR ImagePath; + HANDLE hImageFileHandle; + DWORD UrlZoneId; + BYTE ImageHash[SAFER_MAX_HASH_SIZE]; + DWORD dwImageHashSize; + LARGE_INTEGER ImageSize; + ALG_ID HashAlgorithm; + PBYTE pByteBlock; + HWND hWndParent; + DWORD dwWVTUIChoice; +} SAFER_CODE_PROPERTIES_V1, *PSAFER_CODE_PROPERTIES_V1; + +typedef struct SAFER_CODE_PROPERTIES_V2 +{ + SAFER_CODE_PROPERTIES_V1; + PCWSTR PackageMoniker; + PCWSTR PackagePublisher; + PCWSTR PackageName; + ULONG64 PackageVersion; + BOOL PackageIsFramework; +} SAFER_CODE_PROPERTIES_V2, *PSAFER_CODE_PROPERTIES_V2; + +#include + +/* NOTE: MS defines SAFER_CODE_PROPERTIES as V2 unconditionally, + * which is... not smart */ +#if _WIN32_WINNT >= 0x602 +typedef SAFER_CODE_PROPERTIES_V2 SAFER_CODE_PROPERTIES, *PSAFER_CODE_PROPERTIES; +#else /* _WIN32_WINNT */ +typedef SAFER_CODE_PROPERTIES_V1 SAFER_CODE_PROPERTIES, *PSAFER_CODE_PROPERTIES; +#endif /* _WIN32_WINNT */ + +typedef enum SAFER_OBJECT_INFO_CLASS +{ + SaferObjectLevelId = 1, + SaferObjectScopeId = 2, + SaferObjectFriendlyName = 3, + SaferObjectDescription = 4, + SaferObjectBuiltin = 5, + SaferObjectDisallowed = 6, + SaferObjectDisableMaxPrivilege = 7, + SaferObjectInvertDeletedPrivileges = 8, + SaferObjectDeletedPrivileges = 9, + SaferObjectDefaultOwner = 10, + SaferObjectSidsToDisable = 11, + SaferObjectRestrictedSidsInverted = 12, + SaferObjectRestrictedSidsAdded = 13, + SaferObjectAllIdentificationGuids = 14, + SaferObjectSingleIdentification = 15, + SaferObjectExtendedError = 16, +} SAFER_OBJECT_INFO_CLASS; + +typedef enum SAFER_POLICY_INFO_CLASS +{ SaferPolicyLevelList = 1, - SaferPolicyEnableTransparentEnforcement, - SaferPolicyDefaultLevel, - SaferPolicyEvaluateUserScope, - SaferPolicyScopeFlags + SaferPolicyEnableTransparentEnforcement = 2, + SaferPolicyDefaultLevel = 3, + SaferPolicyEvaluateUserScope = 4, + SaferPolicyScopeFlags = 5, + SaferPolicyDefaultLevelFlags = 6, + SaferPolicyAuthenticodeEnabled = 7, } SAFER_POLICY_INFO_CLASS; -WINADVAPI BOOL WINAPI SaferGetPolicyInformation(DWORD,SAFER_POLICY_INFO_CLASS,DWORD,PVOID,PDWORD,LPVOID); +typedef enum SAFER_IDENTIFICATION_TYPES +{ + SaferIdentifyDefault = 0, + SaferIdentityTypeImageName = 1, + SaferIdentityTypeImageHash = 2, + SaferIdentityTypeUrlZone = 3, + SaferIdentityTypeCertificate = 4, +} SAFER_IDENTIFICATION_TYPES; +#include + +typedef struct _SAFER_IDENTIFICATION_HEADER +{ + SAFER_IDENTIFICATION_TYPES dwIdentificationType; + DWORD cbStructSize; + GUID IdentificationGuid; + FILETIME LastModified; +} SAFER_IDENTIFICATION_HEADER, *PSAFER_IDENTIFICATION_HEADER; + +typedef struct _SAFER_PATHNAME_IDENTIFICATION +{ + SAFER_IDENTIFICATION_HEADER header; + WCHAR Description[SAFER_MAX_DESCRIPTION_SIZE]; + PWCHAR ImageName; + DWORD dwSaferFlags; +} SAFER_PATHNAME_IDENTIFICATION, *PSAFER_PATHNAME_IDENTIFICATION; + +typedef struct _SAFER_HASH_IDENTIFICATION +{ + SAFER_IDENTIFICATION_HEADER header; + WCHAR Description[SAFER_MAX_DESCRIPTION_SIZE]; + WCHAR FriendlyName[SAFER_MAX_FRIENDLYNAME_SIZE]; + DWORD HashSize; + BYTE ImageHash[SAFER_MAX_HASH_SIZE]; + ALG_ID HashAlgorithm; + LARGE_INTEGER ImageSize; + DWORD dwSaferFlags; +} SAFER_HASH_IDENTIFICATION, *PSAFER_HASH_IDENTIFICATION; + +typedef struct _SAFER_HASH_IDENTIFICATION2 +{ + SAFER_HASH_IDENTIFICATION hashIdentification; + DWORD HashSize; + BYTE ImageHash[SAFER_MAX_HASH_SIZE]; + ALG_ID HashAlgorithm; +} SAFER_HASH_IDENTIFICATION2, *PSAFER_HASH_IDENTIFICATION2; + +typedef struct _SAFER_URLZONE_IDENTIFICATION +{ + SAFER_IDENTIFICATION_HEADER Header; + DWORD UrlZoneId; + DWORD dwSaferFlags; +} SAFER_URLZONE_IDENTIFICATION, *PSAFER_URLZONE_IDENTIFICATION; + +#include + + +WINADVAPI +BOOL +WINAPI +SaferCloseLevel( + _In_ SAFER_LEVEL_HANDLE hLevelHandle); + +WINADVAPI +BOOL +WINAPI +SaferComputeTokenFromLevel( + _In_ SAFER_LEVEL_HANDLE LevelHandle, + _In_opt_ HANDLE InAccessToken, + _Out_ PHANDLE OutAccessToken, + _In_ DWORD dwFlags, + _Inout_opt_ PVOID pReserved); + +WINADVAPI +BOOL +WINAPI +SaferCreateLevel( + _In_ DWORD dwScopeId, + _In_ DWORD dwLevelId, + _In_ DWORD OpenFlags, + _Outptr_ SAFER_LEVEL_HANDLE *pLevelHandle, + _Reserved_ PVOID pReserved); + +WINADVAPI +BOOL +WINAPI +SaferGetLevelInformation( + _In_ SAFER_LEVEL_HANDLE LevelHandle, + _In_ SAFER_OBJECT_INFO_CLASS dwInfoType, + _Out_writes_bytes_opt_(dwInBufferSize) PVOID pQueryBuffer, + _In_ DWORD dwInBufferSize, + _Out_ PDWORD pdwOutBufferSize); + +WINADVAPI +BOOL +WINAPI +SaferGetPolicyInformation( + _In_ DWORD dwScopeId, + _In_ SAFER_POLICY_INFO_CLASS SaferPolicyInfoClass, + _In_ DWORD InfoBufferSize, + _Out_writes_bytes_opt_(InfoBufferSize) PVOID InfoBuffer, + _Out_ PDWORD InfoBufferRetSize, + _Reserved_ PVOID pReserved); + +WINADVAPI +BOOL +WINAPI +SaferIdentifyLevel( + _In_ DWORD dwNumProperties, + _In_reads_opt_(dwNumProperties) PSAFER_CODE_PROPERTIES pCodeProperties, + _Outptr_ SAFER_LEVEL_HANDLE *pLevelHandle, + _Reserved_ PVOID pReserved); + +WINADVAPI +BOOL +WINAPI +SaferiIsExecutableFileType( + _In_ PCWSTR szFullPath, + _In_ BOOLEAN bFromShellExecute); + +WINADVAPI +BOOL +WINAPI +SaferRecordEventLogEntry( + _In_ SAFER_LEVEL_HANDLE hLevel, + _In_ PCWSTR szTargetPath, + _Reserved_ PVOID pReserved); + +WINADVAPI +BOOL +WINAPI +SaferSetLevelInformation( + _In_ SAFER_LEVEL_HANDLE LevelHandle, + _In_ SAFER_OBJECT_INFO_CLASS dwInfoType, + _In_reads_bytes_(dwInBufferSize) PVOID pQueryBuffer, + _In_ DWORD dwInBufferSize); + +WINADVAPI +BOOL +WINAPI +SaferSetPolicyInformation( + _In_ DWORD dwScopeId, + _In_ SAFER_POLICY_INFO_CLASS SaferPolicyInfoClass, + _In_ DWORD InfoBufferSize, + _In_reads_bytes_(InfoBufferSize) PVOID InfoBuffer, + _Reserved_ PVOID pReserved); + + +#define SRP_POLICY_EXE L"EXE" +#define SRP_POLICY_DLL L"DLL" +#define SRP_POLICY_MSI L"MSI" +#define SRP_POLICY_SCRIPT L"SCRIPT" +#define SRP_POLICY_SHELL L"SHELL" +#define SRP_POLICY_NOV2 L"IGNORESRPV2" +#define SRP_POLICY_APPX L"APPX" +#define SRP_POLICY_WLDPMSI L"WLDPMSI" +#define SRP_POLICY_WLDPSCRIPT L"WLDPSCRIPT" + #ifdef __cplusplus -} -#endif +} /* extern "C" */ +#endif /* __cplusplus */ -#endif /* __WINE_WINSAFER_H */ +#endif /* _WINSAFER_H */