MagistrAnatol

Silver Member | Редактировать | Профиль | Сообщение | ICQ | Цитировать | Сообщить модератору Народ, помогите допилить код - надо дать разрешения на реестр Код: wchar_t *lpSystemName,*lpSubKey; wchar_t lpAccountName[15]={0}; wchar_t ReferencedDomainName[32]={0}; void *Sid; DWORD cbSid,cchReferencedDomainName,dwDACLLength; SID_NAME_USE *peUse; HKEY root,Key; int is_key_open; PSECURITY_DESCRIPTOR pAbsSD; PACL pNewDACL; cbSid=32; cchReferencedDomainName=32; //ReferencedDomainName = new wchar_t[64]; Sid=new BYTE[32]; memset(Sid, 0, 32); memset(ReferencedDomainName, 0, 32*sizeof(WCHAR)); lpSystemName=NULL;// 0 для локального компа wcscpy(lpAccountName,L"ng\\antarey"); //wcscpy(ReferencedDomainName,L"WMK-AC011"); if(!LookupAccountName(lpSystemName,lpAccountName,Sid,&cbSid,ReferencedDomainName,&cchReferencedDomainName,peUse)) { AnsiLastError(); return; } root=HKEY_LOCAL_MACHINE; lpSubKey=L"SOFTWARE\\111"; is_key_open = RegOpenKeyEx(root,lpSubKey,NULL,KEY_ALL_ACCESS, &Key); if (is_key_open == ERROR_SUCCESS ) { dwDACLLength=sizeof(TACL)+8+GetLengthSid(Sid); memset(pAbsSD,0,SECURITY_DESCRIPTOR_MIN_LENGTH+dwDACLLength); InitializeSecurityDescriptor(pAbsSD,SECURITY_DESCRIPTOR_REVISION); memset(pNewDACL,0,dwDACLLength); InitializeAcl(pNewDACL,dwDACLLength,ACL_REVISION_DS); AddAccessAllowedAce(pNewDACL,ACL_REVISION_DS,GENERIC_ALL,Sid); SetSecurityDescriptorDacl(pAbsSD,true,pNewDACL,false); RegSetKeySecurity(Key,DACL_SECURITY_INFORMATION,pAbsSD); } else AnsiLastError(); | на LookupAccountName - First chance exception at $76196486. Exception class $C0000005 with message 'access violation at 0x76196486: write of address 0x50170092'. Process uProfile.exe (3852) |