GNUnet  0.10.x
Data Structures | Macros | Typedefs | Functions | Variables
winproc.h File Reference
#include <io.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/timeb.h>
#include <time.h>
#include <dirent.h>
#include <winsock2.h>
#include <ws2tcpip.h>
#include <windows.h>
#include <winerror.h>
#include <iphlpapi.h>
#include <shlobj.h>
#include <objbase.h>
#include <sys/param.h>
#include <ntsecapi.h>
#include <lm.h>
#include <aclapi.h>
Include dependency graph for winproc.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  EnumNICs3_results
 

Macros

#define FD_SETSIZE   1024
 
#define MAX_NAME_LENGTH   25
 
#define ENUMNICS3_MASK_OK   0x01
 
#define ENUMNICS3_BCAST_OK   0x02
 

Typedefs

typedef DWORD WINAPI(* TNtQuerySystemInformation) (int, PVOID, ULONG, PULONG)
 
typedef DWORD WINAPI(* TGetIfEntry) (PMIB_IFROW pIfRow)
 
typedef DWORD WINAPI(* TGetIpAddrTable) (PMIB_IPADDRTABLE pIpAddrTable, PULONG pdwSize, BOOL bOrder)
 
typedef DWORD WINAPI(* TGetIfTable) (PMIB_IFTABLE pIfTable, PULONG pdwSize, BOOL bOrder)
 
typedef DWORD WINAPI(* TGetBestInterfaceEx) (struct sockaddr *, PDWORD)
 
typedef DWORD WINAPI(* TCreateHardLink) (LPCTSTR lpFileName, LPCTSTR lpExistingFileName, LPSECURITY_ATTRIBUTES lpSecurityAttributes)
 
typedef SC_HANDLE WINAPI(* TOpenSCManager) (LPCTSTR lpMachineName, LPCTSTR lpDatabaseName, DWORD dwDesiredAccess)
 
typedef SC_HANDLE WINAPI(* TCreateService) (SC_HANDLE hSCManager, LPCTSTR lpServiceName, LPCTSTR lpDisplayName, DWORD dwDesiredAccess, DWORD dwServiceType, DWORD dwStartType, DWORD dwErrorControl, LPCTSTR lpBinaryPathName, LPCTSTR lpLoadOrderGroup, LPDWORD lpdwTagId, LPCTSTR lpDependencies, LPCTSTR lpServiceStartName, LPCTSTR lpPassword)
 
typedef BOOL WINAPI(* TCloseServiceHandle) (SC_HANDLE hSCObject)
 
typedef BOOL WINAPI(* TDeleteService) (SC_HANDLE hService)
 
typedef SERVICE_STATUS_HANDLE WINAPI(* TRegisterServiceCtrlHandler) (LPCTSTR lpServiceName, LPHANDLER_FUNCTION lpHandlerProc)
 
typedef BOOL WINAPI(* TSetServiceStatus) (SERVICE_STATUS_HANDLE hServiceStatus, LPSERVICE_STATUS lpServiceStatus)
 
typedef BOOL WINAPI(* TStartServiceCtrlDispatcher) (const LPSERVICE_TABLE_ENTRY lpServiceTable)
 
typedef BOOL WINAPI(* TControlService) (SC_HANDLE hService, DWORD dwControl, LPSERVICE_STATUS lpServiceStatus)
 
typedef SC_HANDLE WINAPI(* TOpenService) (SC_HANDLE hSCManager, LPCTSTR lpServiceName, DWORD dwDesiredAccess)
 
typedef DWORD WINAPI(* TGetAdaptersInfo) (PIP_ADAPTER_INFO pAdapterInfo, PULONG pOutBufLen)
 
typedef NET_API_STATUS WINAPI(* TNetUserAdd) (LPCWSTR, DWORD, PBYTE, PDWORD)
 
typedef NET_API_STATUS WINAPI(* TNetUserSetInfo) (LPCWSTR servername, LPCWSTR username, DWORD level, LPBYTE buf, LPDWORD param_err)
 
typedef NTSTATUS NTAPI(* TLsaOpenPolicy) (PLSA_UNICODE_STRING, PLSA_OBJECT_ATTRIBUTES, ACCESS_MASK, PLSA_HANDLE)
 
typedef NTSTATUS NTAPI(* TLsaAddAccountRights) (LSA_HANDLE, PSID, PLSA_UNICODE_STRING, ULONG)
 
typedef NTSTATUS NTAPI(* TLsaRemoveAccountRights) (LSA_HANDLE, PSID, BOOLEAN, PLSA_UNICODE_STRING, ULONG)
 
typedef NTSTATUS NTAPI(* TLsaClose) (LSA_HANDLE)
 
typedef BOOL WINAPI(* TLookupAccountName) (LPCTSTR lpSystemName, LPCTSTR lpAccountName, PSID Sid, LPDWORD cbSid, LPTSTR ReferencedDomainName, LPDWORD cchReferencedDomainName, PSID_NAME_USE peUse)
 
typedef BOOL WINAPI(* TGetFileSecurity) (LPCTSTR lpFileName, SECURITY_INFORMATION RequestedInformation, PSECURITY_DESCRIPTOR pSecurityDescriptor, DWORD nLength, LPDWORD lpnLengthNeeded)
 
typedef BOOL WINAPI(* TInitializeSecurityDescriptor) (PSECURITY_DESCRIPTOR pSecurityDescriptor, DWORD dwRevision)
 
typedef BOOL WINAPI(* TGetSecurityDescriptorDacl) (PSECURITY_DESCRIPTOR pSecurityDescriptor, LPBOOL lpbDaclPresent, PACL *pDacl, LPBOOL lpbDaclDefaulted)
 
typedef BOOL WINAPI(* TGetAclInformation) (PACL pAcl, LPVOID pAclInformation, DWORD nAclInformationLength, ACL_INFORMATION_CLASS dwAclInformationClass)
 
typedef BOOL WINAPI(* TInitializeAcl) (PACL pAcl, DWORD nAclLength, DWORD dwAclRevision)
 
typedef BOOL WINAPI(* TGetAce) (PACL pAcl, DWORD dwAceIndex, LPVOID *pAce)
 
typedef BOOL WINAPI(* TEqualSid) (PSID pSid1, PSID pSid2)
 
typedef BOOL WINAPI(* TAddAce) (PACL pAcl, DWORD dwAceRevision, DWORD dwStartingAceIndex, LPVOID pAceList, DWORD nAceListLength)
 
typedef BOOL WINAPI(* TAddAccessAllowedAce) (PACL pAcl, DWORD dwAceRevision, DWORD AccessMask, PSID pSid)
 
typedef BOOL WINAPI(* TSetNamedSecurityInfo) (LPTSTR pObjectName, SE_OBJECT_TYPE ObjectType, SECURITY_INFORMATION SecurityInfo, PSID psidOwner, PSID psidGroup, PACL pDacl, PACL pSacl)
 

Functions

BOOL CreateShortcut (const char *pszSrc, const char *pszDest)
 
BOOL DereferenceShortcut (char *pszShortcut)
 
long QueryRegistry (HKEY hMainKey, const char *pszKey, const char *pszSubKey, char *pszBuffer, long *pdLength)
 
int ListNICs (void(*callback)(void *, const char *, int), void *cls)
 Lists all network interfaces in a combo box Used by the basic GTK configurator. More...
 
BOOL AddPathAccessRights (char *lpszFileName, char *lpszAccountName, DWORD dwAccessMask)
 Grant permission to a file. More...
 
char * winErrorStr (const char *prefix, int dwErr)
 
void EnumNICs (PMIB_IFTABLE *pIfTable, PMIB_IPADDRTABLE *pAddrTable)
 
int EnumNICs3 (struct EnumNICs3_results **, int *EnumNICs3_results_count)
 
void EnumNICs3_free (struct EnumNICs3_results *)
 
int GNInitWinEnv ()
 
void GNShutdownWinEnv ()
 
BOOL SafeTerminateProcess (HANDLE hProcess, UINT uExitCode, DWORD dwTimeout)
 Terminate a process by creating a remote thread within it, which proceeds to call ExitProcess() inside that process. More...
 

Variables

TGetBestInterfaceEx GNGetBestInterfaceEx
 
TNtQuerySystemInformation GNNtQuerySystemInformation
 
TGetIfEntry GNGetIfEntry
 
TGetIpAddrTable GNGetIpAddrTable
 
TGetIfTable GNGetIfTable
 
TCreateHardLink GNCreateHardLink
 
TOpenSCManager GNOpenSCManager
 
TCreateService GNCreateService
 
TCloseServiceHandle GNCloseServiceHandle
 
TDeleteService GNDeleteService
 
TRegisterServiceCtrlHandler GNRegisterServiceCtrlHandler
 
TSetServiceStatus GNSetServiceStatus
 
TStartServiceCtrlDispatcher GNStartServiceCtrlDispatcher
 
TControlService GNControlService
 
TOpenService GNOpenService
 
TGetAdaptersInfo GNGetAdaptersInfo
 
TNetUserAdd GNNetUserAdd
 
TNetUserSetInfo GNNetUserSetInfo
 
TLsaOpenPolicy GNLsaOpenPolicy
 
TLsaAddAccountRights GNLsaAddAccountRights
 
TLsaRemoveAccountRights GNLsaRemoveAccountRights
 
TLsaClose GNLsaClose
 
TLookupAccountName GNLookupAccountName
 
TGetFileSecurity GNGetFileSecurity
 
TInitializeSecurityDescriptor GNInitializeSecurityDescriptor
 
TGetSecurityDescriptorDacl GNGetSecurityDescriptorDacl
 
TGetAclInformation GNGetAclInformation
 
TInitializeAcl GNInitializeAcl
 
TGetAce GNGetAce
 
TEqualSid GNEqualSid
 
TAddAce GNAddAce
 
TAddAccessAllowedAce GNAddAccessAllowedAce
 
TSetNamedSecurityInfo GNSetNamedSecurityInfo
 

Detailed Description

Author
Nils Durner

Definitions for MS Windows

Definition in file winproc.h.

Macro Definition Documentation

◆ FD_SETSIZE

#define FD_SETSIZE   1024

◆ MAX_NAME_LENGTH

#define MAX_NAME_LENGTH   25

Definition at line 60 of file winproc.h.

Referenced by CreateServiceAccount().

◆ ENUMNICS3_MASK_OK

#define ENUMNICS3_MASK_OK   0x01

Definition at line 212 of file winproc.h.

Referenced by EnumNICs3(), and GNUNET_OS_network_interfaces_list().

◆ ENUMNICS3_BCAST_OK

#define ENUMNICS3_BCAST_OK   0x02

Definition at line 213 of file winproc.h.

Referenced by EnumNICs3(), and GNUNET_OS_network_interfaces_list().

Typedef Documentation

◆ TNtQuerySystemInformation

typedef DWORD WINAPI(* TNtQuerySystemInformation) (int, PVOID, ULONG, PULONG)

Definition at line 63 of file winproc.h.

◆ TGetIfEntry

typedef DWORD WINAPI(* TGetIfEntry) (PMIB_IFROW pIfRow)

Definition at line 64 of file winproc.h.

◆ TGetIpAddrTable

typedef DWORD WINAPI(* TGetIpAddrTable) (PMIB_IPADDRTABLE pIpAddrTable, PULONG pdwSize, BOOL bOrder)

Definition at line 65 of file winproc.h.

◆ TGetIfTable

typedef DWORD WINAPI(* TGetIfTable) (PMIB_IFTABLE pIfTable, PULONG pdwSize, BOOL bOrder)

Definition at line 67 of file winproc.h.

◆ TGetBestInterfaceEx

typedef DWORD WINAPI(* TGetBestInterfaceEx) (struct sockaddr *, PDWORD)

Definition at line 69 of file winproc.h.

◆ TCreateHardLink

typedef DWORD WINAPI(* TCreateHardLink) (LPCTSTR lpFileName, LPCTSTR lpExistingFileName, LPSECURITY_ATTRIBUTES lpSecurityAttributes)

Definition at line 73 of file winproc.h.

◆ TOpenSCManager

typedef SC_HANDLE WINAPI(* TOpenSCManager) (LPCTSTR lpMachineName, LPCTSTR lpDatabaseName, DWORD dwDesiredAccess)

Definition at line 77 of file winproc.h.

◆ TCreateService

typedef SC_HANDLE WINAPI(* TCreateService) (SC_HANDLE hSCManager, LPCTSTR lpServiceName, LPCTSTR lpDisplayName, DWORD dwDesiredAccess, DWORD dwServiceType, DWORD dwStartType, DWORD dwErrorControl, LPCTSTR lpBinaryPathName, LPCTSTR lpLoadOrderGroup, LPDWORD lpdwTagId, LPCTSTR lpDependencies, LPCTSTR lpServiceStartName, LPCTSTR lpPassword)

Definition at line 80 of file winproc.h.

◆ TCloseServiceHandle

typedef BOOL WINAPI(* TCloseServiceHandle) (SC_HANDLE hSCObject)

Definition at line 93 of file winproc.h.

◆ TDeleteService

typedef BOOL WINAPI(* TDeleteService) (SC_HANDLE hService)

Definition at line 94 of file winproc.h.

◆ TRegisterServiceCtrlHandler

typedef SERVICE_STATUS_HANDLE WINAPI(* TRegisterServiceCtrlHandler) (LPCTSTR lpServiceName, LPHANDLER_FUNCTION lpHandlerProc)

Definition at line 95 of file winproc.h.

◆ TSetServiceStatus

typedef BOOL WINAPI(* TSetServiceStatus) (SERVICE_STATUS_HANDLE hServiceStatus, LPSERVICE_STATUS lpServiceStatus)

Definition at line 99 of file winproc.h.

◆ TStartServiceCtrlDispatcher

typedef BOOL WINAPI(* TStartServiceCtrlDispatcher) (const LPSERVICE_TABLE_ENTRY lpServiceTable)

Definition at line 102 of file winproc.h.

◆ TControlService

typedef BOOL WINAPI(* TControlService) (SC_HANDLE hService, DWORD dwControl, LPSERVICE_STATUS lpServiceStatus)

Definition at line 105 of file winproc.h.

◆ TOpenService

typedef SC_HANDLE WINAPI(* TOpenService) (SC_HANDLE hSCManager, LPCTSTR lpServiceName, DWORD dwDesiredAccess)

Definition at line 107 of file winproc.h.

◆ TGetAdaptersInfo

typedef DWORD WINAPI(* TGetAdaptersInfo) (PIP_ADAPTER_INFO pAdapterInfo, PULONG pOutBufLen)

Definition at line 110 of file winproc.h.

◆ TNetUserAdd

typedef NET_API_STATUS WINAPI(* TNetUserAdd) (LPCWSTR, DWORD, PBYTE, PDWORD)

Definition at line 112 of file winproc.h.

◆ TNetUserSetInfo

typedef NET_API_STATUS WINAPI(* TNetUserSetInfo) (LPCWSTR servername, LPCWSTR username, DWORD level, LPBYTE buf, LPDWORD param_err)

Definition at line 113 of file winproc.h.

◆ TLsaOpenPolicy

typedef NTSTATUS NTAPI(* TLsaOpenPolicy) (PLSA_UNICODE_STRING, PLSA_OBJECT_ATTRIBUTES, ACCESS_MASK, PLSA_HANDLE)

Definition at line 117 of file winproc.h.

◆ TLsaAddAccountRights

typedef NTSTATUS NTAPI(* TLsaAddAccountRights) (LSA_HANDLE, PSID, PLSA_UNICODE_STRING, ULONG)

Definition at line 120 of file winproc.h.

◆ TLsaRemoveAccountRights

typedef NTSTATUS NTAPI(* TLsaRemoveAccountRights) (LSA_HANDLE, PSID, BOOLEAN, PLSA_UNICODE_STRING, ULONG)

Definition at line 122 of file winproc.h.

◆ TLsaClose

typedef NTSTATUS NTAPI(* TLsaClose) (LSA_HANDLE)

Definition at line 125 of file winproc.h.

◆ TLookupAccountName

typedef BOOL WINAPI(* TLookupAccountName) (LPCTSTR lpSystemName, LPCTSTR lpAccountName, PSID Sid, LPDWORD cbSid, LPTSTR ReferencedDomainName, LPDWORD cchReferencedDomainName, PSID_NAME_USE peUse)

Definition at line 126 of file winproc.h.

◆ TGetFileSecurity

typedef BOOL WINAPI(* TGetFileSecurity) (LPCTSTR lpFileName, SECURITY_INFORMATION RequestedInformation, PSECURITY_DESCRIPTOR pSecurityDescriptor, DWORD nLength, LPDWORD lpnLengthNeeded)

Definition at line 133 of file winproc.h.

◆ TInitializeSecurityDescriptor

typedef BOOL WINAPI(* TInitializeSecurityDescriptor) (PSECURITY_DESCRIPTOR pSecurityDescriptor, DWORD dwRevision)

Definition at line 139 of file winproc.h.

◆ TGetSecurityDescriptorDacl

typedef BOOL WINAPI(* TGetSecurityDescriptorDacl) (PSECURITY_DESCRIPTOR pSecurityDescriptor, LPBOOL lpbDaclPresent, PACL *pDacl, LPBOOL lpbDaclDefaulted)

Definition at line 142 of file winproc.h.

◆ TGetAclInformation

typedef BOOL WINAPI(* TGetAclInformation) (PACL pAcl, LPVOID pAclInformation, DWORD nAclInformationLength, ACL_INFORMATION_CLASS dwAclInformationClass)

Definition at line 147 of file winproc.h.

◆ TInitializeAcl

typedef BOOL WINAPI(* TInitializeAcl) (PACL pAcl, DWORD nAclLength, DWORD dwAclRevision)

Definition at line 151 of file winproc.h.

◆ TGetAce

typedef BOOL WINAPI(* TGetAce) (PACL pAcl, DWORD dwAceIndex, LPVOID *pAce)

Definition at line 153 of file winproc.h.

◆ TEqualSid

typedef BOOL WINAPI(* TEqualSid) (PSID pSid1, PSID pSid2)

Definition at line 154 of file winproc.h.

◆ TAddAce

typedef BOOL WINAPI(* TAddAce) (PACL pAcl, DWORD dwAceRevision, DWORD dwStartingAceIndex, LPVOID pAceList, DWORD nAceListLength)

Definition at line 155 of file winproc.h.

◆ TAddAccessAllowedAce

typedef BOOL WINAPI(* TAddAccessAllowedAce) (PACL pAcl, DWORD dwAceRevision, DWORD AccessMask, PSID pSid)

Definition at line 158 of file winproc.h.

◆ TSetNamedSecurityInfo

typedef BOOL WINAPI(* TSetNamedSecurityInfo) (LPTSTR pObjectName, SE_OBJECT_TYPE ObjectType, SECURITY_INFORMATION SecurityInfo, PSID psidOwner, PSID psidGroup, PACL pDacl, PACL pSacl)

Definition at line 160 of file winproc.h.

Function Documentation

◆ CreateShortcut()

BOOL CreateShortcut ( const char *  pszSrc,
const char *  pszDest 
)

◆ DereferenceShortcut()

BOOL DereferenceShortcut ( char *  pszShortcut)

◆ QueryRegistry()

long QueryRegistry ( HKEY  hMainKey,
const char *  pszKey,
const char *  pszSubKey,
char *  pszBuffer,
long *  pdLength 
)

◆ ListNICs()

int ListNICs ( void(*)(void *, const char *, int)  callback,
void *  callback_cls 
)

Lists all network interfaces in a combo box Used by the basic GTK configurator.

Parameters
callbackfunction to call for each NIC
callback_clsclosure for callback

Definition at line 640 of file win.c.

References EnumNICs3(), GNUNET_free_non_null, GNUNET_NO, GNUNET_OK, GNUNET_YES, EnumNICs3_results::is_default, EnumNICs3_results::pretty_name, and results.

641 {
642  int r;
643  int i;
644  struct EnumNICs3_results *results = NULL;
645  int results_count;
646 
647  r = EnumNICs3(&results, &results_count);
648  if (r != GNUNET_OK)
649  return GNUNET_NO;
650 
651  for (i = 0; i < results_count; i++)
652  callback(callback_cls, results[i].pretty_name, results[i].is_default);
653  GNUNET_free_non_null(results);
654  return GNUNET_YES;
655 }
#define GNUNET_NO
Definition: gnunet_common.h:81
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:78
char pretty_name[1001]
Definition: winproc.h:218
#define GNUNET_free_non_null(a)
Definition: win.c:261
static unsigned int results
Definition: gnunet-search.c:52
int EnumNICs3(struct EnumNICs3_results **results, int *results_count)
Definition: win.c:364
#define GNUNET_YES
Definition: gnunet_common.h:80
Here is the call graph for this function:

◆ AddPathAccessRights()

BOOL AddPathAccessRights ( char *  lpszFileName,
char *  lpszAccountName,
DWORD  dwAccessMask 
)

Grant permission to a file.

Parameters
lpszFileNamethe name of the file or directory
lpszAccountNamethe user account
dwAccessMaskthe desired access (e.g. GENERIC_ALL)
Returns
TRUE on success
Remarks
based on http://support.microsoft.com/default.aspx?scid=KB;EN-US;Q102102&

STEP 1: Get SID of the account name specified.

STEP 2: Get security descriptor (SD) of the file specified.

STEP 3: Initialize new SD.

STEP 4: Get DACL from the old SD.

STEP 5: Get size information for DACL.

STEP 6: Compute size needed for the new ACL.

STEP 7: Allocate memory for new ACL.

STEP 8: Initialize the new ACL.

STEP 9 If DACL is present, copy all the ACEs from the old DACL to the new DACL.

The following code assumes that the old DACL is already in Windows 2000 preferred order. To conform to the new Windows 2000 preferred order, first we will copy all non-inherited ACEs from the old DACL to the new DACL, irrespective of the ACE type.

TEP 10: Get an ACE.

STEP 11: Check if it is a non-inherited ACE. If it is an inherited ACE, break from the loop so that the new access allowed non-inherited ACE can be added in the correct position, immediately after all non-inherited ACEs.

STEP 12: Skip adding the ACE, if the SID matches with the account specified, as we are going to add an access allowed ACE with a different access mask.

STEP 13: Add the ACE to the new ACL.

STEP 14: Add the access-allowed ACE to the new DACL. The new ACE added here will be in the correct position, immediately after all existing non-inherited ACEs.

STEP 14.5: Make new ACE inheritable

STEP 15: To conform to the new Windows 2000 preferred order, we will now copy the rest of inherited ACEs from the old DACL to the new DACL.

STEP 16: Get an ACE.

STEP 17: Add the ACE to the new ACL.

STEP 18: Set permissions

STEP 19: Free allocated memory

Definition at line 972 of file win.c.

References end, GNAddAccessAllowedAce, GNAddAce, GNEqualSid, GNGetAce, GNGetAclInformation, GNGetFileSecurity, GNGetSecurityDescriptorDacl, GNInitializeAcl, GNInitializeSecurityDescriptor, GNLookupAccountName, GNSetNamedSecurityInfo, and INHERITED_ACE.

974 {
975  /* SID variables. */
976  SID_NAME_USE snuType;
977  TCHAR * szDomain = NULL;
978  DWORD cbDomain = 0;
979  LPVOID pUserSID = NULL;
980  DWORD cbUserSID = 0;
981 
982  /* File SD variables. */
983  PSECURITY_DESCRIPTOR pFileSD = NULL;
984  DWORD cbFileSD = 0;
985 
986  /* New SD variables. */
987  SECURITY_DESCRIPTOR newSD;
988 
989  /* ACL variables. */
990  PACL pACL = NULL;
991  BOOL fDaclPresent;
992  BOOL fDaclDefaulted;
993  ACL_SIZE_INFORMATION AclInfo;
994 
995  /* New ACL variables. */
996  PACL pNewACL = NULL;
997  DWORD cbNewACL = 0;
998 
999  /* Temporary ACE. */
1000  LPVOID pTempAce = NULL;
1001  UINT CurrentAceIndex = 0;
1002 
1003  UINT newAceIndex = 0;
1004 
1005  /* Assume function will fail. */
1006  BOOL fResult = FALSE;
1007  BOOL fAPISuccess;
1008 
1009  SECURITY_INFORMATION secInfo = DACL_SECURITY_INFORMATION;
1010 
1014  fAPISuccess = GNLookupAccountName(NULL, (LPCTSTR)lpszAccountName,
1015  pUserSID, &cbUserSID, (LPTSTR)szDomain, &cbDomain, &snuType);
1016 
1017  /* API should have failed with insufficient buffer. */
1018  if (fAPISuccess)
1019  goto end;
1020  else if (GetLastError() != ERROR_INSUFFICIENT_BUFFER)
1021  {
1022  goto end;
1023  }
1024 
1025  pUserSID = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, cbUserSID);
1026  if (!pUserSID)
1027  {
1028  goto end;
1029  }
1030 
1031  szDomain = (TCHAR *)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, cbDomain * sizeof(TCHAR));
1032  if (!szDomain)
1033  {
1034  goto end;
1035  }
1036 
1037  fAPISuccess = GNLookupAccountName(NULL, (LPCTSTR)lpszAccountName,
1038  pUserSID, &cbUserSID, (LPTSTR)szDomain, &cbDomain, &snuType);
1039  if (!fAPISuccess)
1040  {
1041  goto end;
1042  }
1043 
1047  fAPISuccess = GNGetFileSecurity((LPCTSTR)lpszFileName,
1048  secInfo, pFileSD, 0, &cbFileSD);
1049 
1050  /* API should have failed with insufficient buffer. */
1051  if (fAPISuccess)
1052  goto end;
1053  else if (GetLastError() != ERROR_INSUFFICIENT_BUFFER)
1054  {
1055  goto end;
1056  }
1057 
1058  pFileSD = (PSECURITY_DESCRIPTOR)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
1059  cbFileSD);
1060  if (!pFileSD)
1061  {
1062  goto end;
1063  }
1064 
1065  fAPISuccess = GNGetFileSecurity((LPCTSTR)lpszFileName,
1066  secInfo, pFileSD, cbFileSD, &cbFileSD);
1067  if (!fAPISuccess)
1068  {
1069  goto end;
1070  }
1071 
1075  if (!GNInitializeSecurityDescriptor(&newSD,
1076  SECURITY_DESCRIPTOR_REVISION))
1077  {
1078  goto end;
1079  }
1080 
1084  if (!GNGetSecurityDescriptorDacl(pFileSD, &fDaclPresent, &pACL,
1085  &fDaclDefaulted))
1086  {
1087  goto end;
1088  }
1089 
1093  AclInfo.AceCount = 0; // Assume NULL DACL.
1094  AclInfo.AclBytesFree = 0;
1095  AclInfo.AclBytesInUse = sizeof(ACL);
1096 
1097  if (pACL == NULL)
1098  fDaclPresent = FALSE;
1099 
1100  /* If not NULL DACL, gather size information from DACL. */
1101  if (fDaclPresent)
1102  {
1103  if (!GNGetAclInformation(pACL, &AclInfo,
1104  sizeof(ACL_SIZE_INFORMATION), AclSizeInformation))
1105  {
1106  goto end;
1107  }
1108  }
1109 
1113  cbNewACL = AclInfo.AclBytesInUse + sizeof(ACCESS_ALLOWED_ACE)
1114  + GetLengthSid(pUserSID) - sizeof(DWORD);
1115 
1119  pNewACL = (PACL)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, cbNewACL);
1120  if (!pNewACL)
1121  {
1122  goto end;
1123  }
1124 
1128  if (!GNInitializeAcl(pNewACL, cbNewACL, ACL_REVISION2))
1129  {
1130  goto end;
1131  }
1132 
1144  newAceIndex = 0;
1145 
1146  if (fDaclPresent && AclInfo.AceCount)
1147  {
1148  for (CurrentAceIndex = 0;
1149  CurrentAceIndex < AclInfo.AceCount;
1150  CurrentAceIndex++)
1151  {
1155  if (!GNGetAce(pACL, CurrentAceIndex, &pTempAce))
1156  {
1157  goto end;
1158  }
1159 
1167  if (((ACCESS_ALLOWED_ACE *)pTempAce)->Header.AceFlags
1168  & INHERITED_ACE)
1169  break;
1170 
1177  if (GNEqualSid(pUserSID,
1178  &(((ACCESS_ALLOWED_ACE *)pTempAce)->SidStart)))
1179  continue;
1180 
1184  if (!GNAddAce(pNewACL, ACL_REVISION, MAXDWORD, pTempAce,
1185  ((PACE_HEADER)pTempAce)->AceSize))
1186  {
1187  goto end;
1188  }
1189 
1190  newAceIndex++;
1191  }
1192  }
1193 
1199  if (!GNAddAccessAllowedAce(pNewACL, ACL_REVISION2, dwAccessMask,
1200  pUserSID))
1201  {
1202  goto end;
1203  }
1204 
1208  if (!GetAce(pNewACL, newAceIndex, &pTempAce))
1209  goto end;
1210  ((ACCESS_ALLOWED_ACE *)pTempAce)->Header.AceFlags |=
1211  (CONTAINER_INHERIT_ACE | OBJECT_INHERIT_ACE);
1212 
1218  if (fDaclPresent && AclInfo.AceCount)
1219  {
1220  for (;
1221  CurrentAceIndex < AclInfo.AceCount;
1222  CurrentAceIndex++)
1223  {
1227  if (!GNGetAce(pACL, CurrentAceIndex, &pTempAce))
1228  {
1229  goto end;
1230  }
1231 
1235  if (!GNAddAce(pNewACL, ACL_REVISION, MAXDWORD, pTempAce,
1236  ((PACE_HEADER)pTempAce)->AceSize))
1237  {
1238  goto end;
1239  }
1240  }
1241  }
1242 
1246  if (GNSetNamedSecurityInfo((LPTSTR)lpszFileName, SE_FILE_OBJECT,
1247  DACL_SECURITY_INFORMATION, NULL, NULL, pNewACL, NULL) != ERROR_SUCCESS)
1248  {
1249  goto end;
1250  }
1251 
1252  fResult = TRUE;
1253 
1254 end:
1255 
1259  if (pUserSID)
1260  HeapFree(GetProcessHeap(), 0, pUserSID);
1261 
1262  if (szDomain)
1263  HeapFree(GetProcessHeap(), 0, szDomain);
1264 
1265  if (pFileSD)
1266  HeapFree(GetProcessHeap(), 0, pFileSD);
1267 
1268  if (pNewACL)
1269  HeapFree(GetProcessHeap(), 0, pNewACL);
1270 
1271  return fResult;
1272 }
TEqualSid GNEqualSid
TLookupAccountName GNLookupAccountName
static int end
Set if we are to shutdown all services (including ARM).
Definition: gnunet-arm.c:34
TGetAce GNGetAce
TGetAclInformation GNGetAclInformation
TInitializeSecurityDescriptor GNInitializeSecurityDescriptor
#define INHERITED_ACE
Definition: win.c:38
TSetNamedSecurityInfo GNSetNamedSecurityInfo
TAddAccessAllowedAce GNAddAccessAllowedAce
TAddAce GNAddAce
TGetSecurityDescriptorDacl GNGetSecurityDescriptorDacl
TGetFileSecurity GNGetFileSecurity
TInitializeAcl GNInitializeAcl

◆ winErrorStr()

char* winErrorStr ( const char *  prefix,
int  dwErr 
)

Definition at line 1274 of file win.c.

References ret.

1275 {
1276  char *err, *ret;
1277  int mem;
1278 
1279  if (!FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
1280  NULL, (DWORD)dwErr, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR)&err,
1281  0, NULL))
1282  {
1283  err = (char *)LocalAlloc(LMEM_FIXED | LMEM_ZEROINIT, 1);
1284  }
1285 
1286  mem = strlen(err) + strlen(prefix) + 20;
1287  ret = (char *)malloc(mem);
1288 
1289  snprintf(ret, mem, "%s: %s (#%u)", prefix, err, dwErr);
1290 
1291  LocalFree(err);
1292 
1293  return ret;
1294 }
static int ret
Final status code.
Definition: gnunet-arm.c:89

◆ EnumNICs()

void EnumNICs ( PMIB_IFTABLE *  pIfTable,
PMIB_IPADDRTABLE *  pAddrTable 
)

◆ EnumNICs3()

int EnumNICs3 ( struct EnumNICs3_results **  results,
int *  results_count 
)
Returns
GNUNET_OK on success, GNUNET_SYSERR on error

Definition at line 364 of file win.c.

References EnumNICs3_results::addr_size, EnumNICs3_results::address, EnumNICs3_results::broadcast, EnumNICs2(), ENUMNICS3_BCAST_OK, ENUMNICS3_MASK_OK, EnumNICs3_results::flags, GNGetBestInterfaceEx, GNUNET_free, GNUNET_free_non_null, GNUNET_malloc, GNUNET_memcpy, GNUNET_OK, GNUNET_SYSERR, inet_pton(), EnumNICs3_results::is_default, m, EnumNICs3_results::mask, EnumNICs3_results::pretty_name, and unicast().

Referenced by GNUNET_OS_network_interfaces_list(), and ListNICs().

365 {
366  DWORD dwRetVal = 0;
367  int count = 0;
368  ULONG flags = /*GAA_FLAG_INCLUDE_PREFIX |*/ GAA_FLAG_SKIP_ANYCAST |
369  GAA_FLAG_SKIP_MULTICAST | GAA_FLAG_SKIP_DNS_SERVER;
370  struct sockaddr_in6 examplecom6;
371  IPAddr examplecom;
372  DWORD best_interface = 0;
373  DWORD best_interface6 = 0;
374 
375  int use_enum2 = 0;
376  INTERFACE_INFO *interfaces4 = NULL;
377  int interfaces4_len = 0;
378  SOCKET_ADDRESS_LIST *interfaces6 = NULL;
379 
380  unsigned long outBufLen = sizeof(IP_ADAPTER_ADDRESSES);
381  IP_ADAPTER_ADDRESSES *pCurrentAddress = NULL;
382  IP_ADAPTER_ADDRESSES *pAddresses = (IP_ADAPTER_ADDRESSES *)GNUNET_malloc(outBufLen);
383 
384  if (GetAdaptersAddresses(AF_UNSPEC, flags, NULL, pAddresses, &outBufLen)
385  == ERROR_BUFFER_OVERFLOW)
386  {
387  GNUNET_free(pAddresses);
388  pAddresses = (IP_ADAPTER_ADDRESSES *)GNUNET_malloc(outBufLen);
389  }
390 
391  dwRetVal = GetAdaptersAddresses(AF_UNSPEC, flags, NULL, pAddresses, &outBufLen);
392 
393  if (dwRetVal != NO_ERROR)
394  {
395  GNUNET_free(pAddresses);
396  return GNUNET_SYSERR;
397  }
398 
399  if (pAddresses->Length < sizeof(IP_ADAPTER_ADDRESSES_VISTA))
400  {
401  use_enum2 = 1;
402 
403  /* Enumerate NICs using WSAIoctl() */
404  if (GNUNET_OK != EnumNICs2(&interfaces4, &interfaces4_len, &interfaces6))
405  {
406  GNUNET_free(pAddresses);
407  return GNUNET_SYSERR;
408  }
409  }
410 
411  examplecom = inet_addr("192.0.34.166"); /* www.example.com */
412  if (GetBestInterface(examplecom, &best_interface) != NO_ERROR)
413  best_interface = 0;
414 
415  if (GNGetBestInterfaceEx != NULL)
416  {
417  examplecom6.sin6_family = AF_INET6;
418  examplecom6.sin6_port = 0;
419  examplecom6.sin6_flowinfo = 0;
420  examplecom6.sin6_scope_id = 0;
421  inet_pton(AF_INET6, "2001:500:88:200:0:0:0:10",
422  (struct sockaddr *)&examplecom6.sin6_addr);
423  dwRetVal = GNGetBestInterfaceEx((struct sockaddr *)&examplecom6,
424  &best_interface6);
425  if (dwRetVal != NO_ERROR)
426  best_interface6 = 0;
427  }
428 
429  /* Give IPv6 a priority */
430  if (best_interface6 != 0)
431  best_interface = best_interface6;
432 
433  count = 0;
434  for (pCurrentAddress = pAddresses;
435  pCurrentAddress != NULL; pCurrentAddress = pCurrentAddress->Next)
436  {
437  if (pCurrentAddress->OperStatus == IfOperStatusUp)
438  {
439  IP_ADAPTER_UNICAST_ADDRESS *unicast = NULL;
440  for (unicast = pCurrentAddress->FirstUnicastAddress; unicast != NULL;
441  unicast = unicast->Next)
442  {
443  if ((unicast->Address.lpSockaddr->sa_family == AF_INET ||
444  unicast->Address.lpSockaddr->sa_family == AF_INET6) &&
445  (unicast->DadState == IpDadStateDeprecated ||
446  unicast->DadState == IpDadStatePreferred))
447  count += 1;
448  }
449  }
450  }
451 
452  if (count == 0)
453  {
454  *results = NULL;
455  *results_count = 0;
456  GNUNET_free(pAddresses);
457  GNUNET_free_non_null(interfaces4);
458  GNUNET_free_non_null(interfaces6);
459  return GNUNET_OK;
460  }
461 
462  *results = (struct EnumNICs3_results *)GNUNET_malloc(
463  sizeof(struct EnumNICs3_results) * count);
464  *results_count = count;
465 
466  count = 0;
467  for (pCurrentAddress = pAddresses;
468  pCurrentAddress != NULL; pCurrentAddress = pCurrentAddress->Next)
469  {
470  struct EnumNICs3_results *r;
471  IP_ADAPTER_UNICAST_ADDRESS *unicast = NULL;
472  if (pCurrentAddress->OperStatus != IfOperStatusUp)
473  continue;
474  for (unicast = pCurrentAddress->FirstUnicastAddress; unicast != NULL;
475  unicast = unicast->Next)
476  {
477  int i, j;
478  int mask_length = -1;
479  char dst[INET6_ADDRSTRLEN + 1];
480 
481  if ((unicast->Address.lpSockaddr->sa_family != AF_INET &&
482  unicast->Address.lpSockaddr->sa_family != AF_INET6) ||
483  (unicast->DadState != IpDadStateDeprecated &&
484  unicast->DadState != IpDadStatePreferred))
485  continue;
486 
487  r = &(*results)[count];
488  r->flags = 0;
489  if (pCurrentAddress->IfIndex > 0 &&
490  pCurrentAddress->IfIndex == best_interface &&
491  unicast->Address.lpSockaddr->sa_family == AF_INET)
492  r->is_default = 1;
493  else if (pCurrentAddress->Ipv6IfIndex > 0 &&
494  pCurrentAddress->Ipv6IfIndex == best_interface6 &&
495  unicast->Address.lpSockaddr->sa_family == AF_INET6)
496  r->is_default = 1;
497  else
498  r->is_default = 0;
499 
500  /* Don't choose default interface twice */
501  if (r->is_default)
502  best_interface = best_interface6 = 0;
503 
504  if (!use_enum2)
505  {
506  GNUNET_memcpy(&r->address, unicast->Address.lpSockaddr,
507  unicast->Address.iSockaddrLength);
508  memset(&r->mask, 0, sizeof(struct sockaddr));
509  mask_length = ((IP_ADAPTER_UNICAST_ADDRESS_VISTA *)unicast)->
510  OnLinkPrefixLength;
511  /* OnLinkPrefixLength is the number of leading 1s in the mask.
512  * OnLinkPrefixLength is available on Vista and later (hence use_enum2).
513  */
514  if (unicast->Address.lpSockaddr->sa_family == AF_INET)
515  {
516  struct sockaddr_in *m = (struct sockaddr_in *)&r->mask;
517  for (i = 0; i < mask_length; i++)
518  ((unsigned char *)&m->sin_addr)[i / 8] |= 0x80 >> (i % 8);
519  }
520  else if (unicast->Address.lpSockaddr->sa_family == AF_INET6)
521  {
522  struct sockaddr_in6 *m = (struct sockaddr_in6 *)&r->mask;
523  struct sockaddr_in6 *b = (struct sockaddr_in6 *)&r->broadcast;
524  for (i = 0; i < mask_length; i++)
525  ((unsigned char *)&m->sin6_addr)[i / 8] |= 0x80 >> (i % 8);
526  GNUNET_memcpy(&r->broadcast, &r->address, unicast->Address.iSockaddrLength);
527  for (i = mask_length; i < 128; i++)
528  ((unsigned char *)&b->sin6_addr)[i / 8] |= 0x80 >> (i % 8);
529  }
530  r->flags |= ENUMNICS3_MASK_OK;
531  }
532  else
533  {
534  int found = 0;
535  if (unicast->Address.lpSockaddr->sa_family == AF_INET)
536  {
537  for (i = 0; !found && i < interfaces4_len / sizeof(INTERFACE_INFO); i++)
538  {
539  struct sockaddr_in *m = (struct sockaddr_in *)&r->mask;
540  GNUNET_memcpy(&interfaces4[i].iiAddress.Address,
541  unicast->Address.lpSockaddr,
542  unicast->Address.iSockaddrLength);
543  found = 1;
544  GNUNET_memcpy(&r->address, &interfaces4[i].iiAddress.Address,
545  sizeof(struct sockaddr_in));
546  GNUNET_memcpy(&r->mask, &interfaces4[i].iiNetmask.Address,
547  sizeof(struct sockaddr_in));
548  for (mask_length = 0;
549  ((unsigned char *)&m->sin_addr)[mask_length / 8] &
550  0x80 >> (mask_length % 8); mask_length++)
551  {
552  }
553  r->flags |= ENUMNICS3_MASK_OK;
554  }
555  }
556  else if (unicast->Address.lpSockaddr->sa_family == AF_INET6)
557  {
558  for (i = 0;
559  interfaces6 != NULL && !found && i < interfaces6->iAddressCount;
560  i++)
561  {
562  GNUNET_memcpy(interfaces6->Address[i].lpSockaddr,
563  unicast->Address.lpSockaddr,
564  unicast->Address.iSockaddrLength);
565  found = 1;
566  GNUNET_memcpy(&r->address, interfaces6->Address[i].lpSockaddr,
567  sizeof(struct sockaddr_in6));
568  /* TODO: Find a way to reliably get network mask for IPv6 on XP */
569  memset(&r->mask, 0, sizeof(struct sockaddr));
570  r->flags &= ~ENUMNICS3_MASK_OK;
571  }
572  }
573  if (!found)
574  {
575  DebugBreak();
576  }
577  }
578  if (unicast->Address.lpSockaddr->sa_family == AF_INET)
579  {
580  struct sockaddr_in *m = (struct sockaddr_in *)&r->mask;
581  struct sockaddr_in *a = (struct sockaddr_in *)&r->address;
582  /* copy address to broadcast, then flip all the trailing bits not
583  * falling under netmask to 1,
584  * so we get, 192.168.0.255 from, say, 192.168.0.43 with mask == 24.
585  */
586  GNUNET_memcpy(&r->broadcast, &r->address, unicast->Address.iSockaddrLength);
587  for (i = mask_length; i < 32; i++)
588  ((unsigned char *)&m->sin_addr)[i / 8] |= 0x80 >> (i % 8);
590  r->addr_size = sizeof(struct sockaddr_in);
591  inet_ntop(AF_INET, &a->sin_addr, dst, INET_ADDRSTRLEN);
592  }
593  else if (unicast->Address.lpSockaddr->sa_family == AF_INET6)
594  {
595  struct sockaddr_in6 *a = (struct sockaddr_in6 *)&r->address;
596  /* for IPv6 broadcast is not defined, zero it down */
597  memset(&r->broadcast, 0, sizeof(struct sockaddr));
598  r->flags &= ~ENUMNICS3_BCAST_OK;
599  r->addr_size = sizeof(struct sockaddr_in6);
600  inet_ntop(AF_INET6, &a->sin6_addr, dst, INET6_ADDRSTRLEN);
601  }
602 
603  i = 0;
604  i += snprintf(&r->pretty_name[i], 1000 - i > 0 ? 1000 - i : 0,
605  "%S (%s", pCurrentAddress->FriendlyName, dst);
606  for (j = 0; j < pCurrentAddress->PhysicalAddressLength; j++)
607  i += snprintf(&r->pretty_name[i], 1000 - i > 0 ? 1000 - i : 0,
608  "%s%02X", j > 0 ? ":" : " - ", pCurrentAddress->PhysicalAddress[j]);
609  i += snprintf(&r->pretty_name[i], 1000 - i > 0 ? 1000 - i : 0, ")");
610  r->pretty_name[1000] = '\0';
611  count += 1;
612  }
613  }
614 
615  if (use_enum2)
616  {
617  GNUNET_free_non_null(interfaces4);
618  GNUNET_free_non_null(interfaces6);
619  }
620 
621  GNUNET_free(pAddresses);
622  return GNUNET_OK;
623 }
SOCKADDR_STORAGE address
Definition: winproc.h:220
#define GNUNET_free(a)
Definition: win.c:258
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:78
#define GNUNET_malloc(a)
Definition: win.c:254
static struct GNUNET_ARM_MonitorHandle * m
Monitor connection with ARM.
Definition: gnunet-arm.c:99
#define GNUNET_memcpy(dst, src, n)
char pretty_name[1001]
Definition: winproc.h:218
size_t addr_size
Definition: winproc.h:219
SOCKADDR_STORAGE broadcast
Definition: winproc.h:222
#define GNUNET_SYSERR
Definition: gnunet_common.h:79
static void unicast(struct TransportClient *tc, const struct GNUNET_MessageHeader *msg, int may_drop)
Queue the given message for transmission to the given client.
#define GNUNET_free_non_null(a)
Definition: win.c:261
unsigned char flags
Definition: winproc.h:216
TGetBestInterfaceEx GNGetBestInterfaceEx
#define ENUMNICS3_BCAST_OK
Definition: winproc.h:213
static int inet_pton(int af, const char *cp, struct in_addr *buf)
Convert IPv4 address from text to binary form.
#define ENUMNICS3_MASK_OK
Definition: winproc.h:212
int EnumNICs2(INTERFACE_INFO **ifs4, int *ifs4_len, SOCKET_ADDRESS_LIST **ifs6)
Definition: win.c:303
SOCKADDR_STORAGE mask
Definition: winproc.h:221
Here is the call graph for this function:
Here is the caller graph for this function:

◆ EnumNICs3_free()

void EnumNICs3_free ( struct EnumNICs3_results )

Definition at line 626 of file win.c.

References GNUNET_free_non_null.

Referenced by GNUNET_OS_network_interfaces_list().

627 {
629 }
#define GNUNET_free_non_null(a)
Definition: win.c:261
Here is the caller graph for this function:

◆ GNInitWinEnv()

int GNInitWinEnv ( )

◆ GNShutdownWinEnv()

void GNShutdownWinEnv ( )

◆ SafeTerminateProcess()

BOOL SafeTerminateProcess ( HANDLE  hProcess,
UINT  uExitCode,
DWORD  dwTimeout 
)

Terminate a process by creating a remote thread within it, which proceeds to call ExitProcess() inside that process.

Safer than TerminateProcess ().

Code is from From http://private-storm.de/2009/08/11/case-terminateprocess/

Parameters
hProcesshandle of a process to terminate
uExitCodeexit code to use for ExitProcess()
dwTimeoutnumber of ms to wait for the process to terminate
Returns
TRUE on success, FALSE on failure (check last error for the code)

Definition at line 1309 of file win.c.

Referenced by start_process().

1310 {
1311  DWORD dwTID, dwCode, dwErr = 0;
1312  HANDLE hProcessDup = INVALID_HANDLE_VALUE;
1313  HANDLE hRT = NULL;
1314  HINSTANCE hKernel = GetModuleHandle("Kernel32");
1315  BOOL bSuccess = FALSE;
1316 
1317  BOOL bDup = DuplicateHandle(GetCurrentProcess(), hProcess,
1318  GetCurrentProcess(), &hProcessDup, PROCESS_ALL_ACCESS,
1319  FALSE, 0);
1320 
1321  /* Detect the special case where the process is
1322  * already dead...
1323  */
1324  if (GetExitCodeProcess(bDup ? hProcessDup : hProcess, &dwCode) &&
1325  (STILL_ACTIVE == dwCode))
1326  {
1327  FARPROC pfnExitProc;
1328 
1329  pfnExitProc = GetProcAddress(hKernel, "ExitProcess");
1330 
1331  hRT = CreateRemoteThread((bDup) ? hProcessDup : hProcess, NULL, 0,
1332  (LPTHREAD_START_ROUTINE)pfnExitProc, (PVOID)uExitCode, 0, &dwTID);
1333 
1334  dwErr = GetLastError();
1335  }
1336  else
1337  {
1338  dwErr = ERROR_PROCESS_ABORTED;
1339  }
1340 
1341  if (hRT)
1342  {
1343  /* Must wait process to terminate to
1344  * guarantee that it has exited...
1345  */
1346  DWORD dwWaitResult = WaitForSingleObject((bDup) ? hProcessDup : hProcess,
1347  dwTimeout);
1348  if (dwWaitResult == WAIT_TIMEOUT)
1349  dwErr = WAIT_TIMEOUT;
1350  else
1351  dwErr = GetLastError();
1352 
1353  CloseHandle(hRT);
1354  bSuccess = dwErr == NO_ERROR;
1355  }
1356 
1357  if (bDup)
1358  CloseHandle(hProcessDup);
1359 
1360  SetLastError(dwErr);
1361 
1362  return bSuccess;
1363 }
Here is the caller graph for this function:

Variable Documentation

◆ GNGetBestInterfaceEx

TGetBestInterfaceEx GNGetBestInterfaceEx

Referenced by EnumNICs3().

◆ GNNtQuerySystemInformation

TNtQuerySystemInformation GNNtQuerySystemInformation

Referenced by updateUsage().

◆ GNGetIfEntry

TGetIfEntry GNGetIfEntry

◆ GNGetIpAddrTable

TGetIpAddrTable GNGetIpAddrTable

◆ GNGetIfTable

TGetIfTable GNGetIfTable

◆ GNCreateHardLink

TCreateHardLink GNCreateHardLink

◆ GNOpenSCManager

TOpenSCManager GNOpenSCManager

◆ GNCreateService

TCreateService GNCreateService

Referenced by InstallAsService().

◆ GNCloseServiceHandle

TCloseServiceHandle GNCloseServiceHandle

◆ GNDeleteService

TDeleteService GNDeleteService

Referenced by UninstallService().

◆ GNRegisterServiceCtrlHandler

TRegisterServiceCtrlHandler GNRegisterServiceCtrlHandler

◆ GNSetServiceStatus

TSetServiceStatus GNSetServiceStatus

◆ GNStartServiceCtrlDispatcher

TStartServiceCtrlDispatcher GNStartServiceCtrlDispatcher

◆ GNControlService

TControlService GNControlService

◆ GNOpenService

TOpenService GNOpenService

Referenced by UninstallService().

◆ GNGetAdaptersInfo

TGetAdaptersInfo GNGetAdaptersInfo

◆ GNNetUserAdd

TNetUserAdd GNNetUserAdd

Referenced by CreateServiceAccount().

◆ GNNetUserSetInfo

TNetUserSetInfo GNNetUserSetInfo

Referenced by CreateServiceAccount().

◆ GNLsaOpenPolicy

TLsaOpenPolicy GNLsaOpenPolicy

Referenced by _OpenPolicy().

◆ GNLsaAddAccountRights

TLsaAddAccountRights GNLsaAddAccountRights

Referenced by _SetPrivilegeOnAccount().

◆ GNLsaRemoveAccountRights

TLsaRemoveAccountRights GNLsaRemoveAccountRights

Referenced by _SetPrivilegeOnAccount().

◆ GNLsaClose

TLsaClose GNLsaClose

Referenced by CreateServiceAccount().

◆ GNLookupAccountName

TLookupAccountName GNLookupAccountName

◆ GNGetFileSecurity

TGetFileSecurity GNGetFileSecurity

Referenced by AddPathAccessRights().

◆ GNInitializeSecurityDescriptor

TInitializeSecurityDescriptor GNInitializeSecurityDescriptor

Referenced by AddPathAccessRights().

◆ GNGetSecurityDescriptorDacl

TGetSecurityDescriptorDacl GNGetSecurityDescriptorDacl

Referenced by AddPathAccessRights().

◆ GNGetAclInformation

TGetAclInformation GNGetAclInformation

Referenced by AddPathAccessRights().

◆ GNInitializeAcl

TInitializeAcl GNInitializeAcl

Referenced by AddPathAccessRights().

◆ GNGetAce

TGetAce GNGetAce

Referenced by AddPathAccessRights().

◆ GNEqualSid

TEqualSid GNEqualSid

Referenced by AddPathAccessRights().

◆ GNAddAce

TAddAce GNAddAce

Referenced by AddPathAccessRights().

◆ GNAddAccessAllowedAce

TAddAccessAllowedAce GNAddAccessAllowedAce

Referenced by AddPathAccessRights().

◆ GNSetNamedSecurityInfo

TSetNamedSecurityInfo GNSetNamedSecurityInfo

Referenced by AddPathAccessRights().