747 if (success && exists && pACL != NULL && !isdefault) {
748 FREE_C_HEAP_ARRAY(char, pACL);
749 }
750
751 // free the security descriptor
752 FREE_C_HEAP_ARRAY(char, pSD);
753 }
754 }
755
756 // method to free up a security attributes structure and any
757 // contained security descriptors and ACL
758 //
759 static void free_security_attr(LPSECURITY_ATTRIBUTES lpSA) {
760
761 if (lpSA != NULL) {
762 // free the contained security descriptor and the ACL
763 free_security_desc(lpSA->lpSecurityDescriptor);
764 lpSA->lpSecurityDescriptor = NULL;
765
766 // free the security attributes structure
767 FREE_C_HEAP_ARRAY(char, lpSA);
768 }
769 }
770
771 // get the user SID for the process indicated by the process handle
772 //
773 static PSID get_user_sid(HANDLE hProcess) {
774
775 HANDLE hAccessToken;
776 PTOKEN_USER token_buf = NULL;
777 DWORD rsize = 0;
778
779 if (hProcess == NULL) {
780 return NULL;
781 }
782
783 // get the process token
784 if (!OpenProcessToken(hProcess, TOKEN_READ, &hAccessToken)) {
785 if (PrintMiscellaneous && Verbose) {
786 warning("OpenProcessToken failure: lasterror = %d \n", GetLastError());
787 }
|
747 if (success && exists && pACL != NULL && !isdefault) {
748 FREE_C_HEAP_ARRAY(char, pACL);
749 }
750
751 // free the security descriptor
752 FREE_C_HEAP_ARRAY(char, pSD);
753 }
754 }
755
756 // method to free up a security attributes structure and any
757 // contained security descriptors and ACL
758 //
759 static void free_security_attr(LPSECURITY_ATTRIBUTES lpSA) {
760
761 if (lpSA != NULL) {
762 // free the contained security descriptor and the ACL
763 free_security_desc(lpSA->lpSecurityDescriptor);
764 lpSA->lpSecurityDescriptor = NULL;
765
766 // free the security attributes structure
767 FREE_C_HEAP_OBJ(lpSA);
768 }
769 }
770
771 // get the user SID for the process indicated by the process handle
772 //
773 static PSID get_user_sid(HANDLE hProcess) {
774
775 HANDLE hAccessToken;
776 PTOKEN_USER token_buf = NULL;
777 DWORD rsize = 0;
778
779 if (hProcess == NULL) {
780 return NULL;
781 }
782
783 // get the process token
784 if (!OpenProcessToken(hProcess, TOKEN_READ, &hAccessToken)) {
785 if (PrintMiscellaneous && Verbose) {
786 warning("OpenProcessToken failure: lasterror = %d \n", GetLastError());
787 }
|