MCPcopy Create free account
hub / github.com/abbeycode/UnrarKit / ExtractACL20

Function ExtractACL20

Libraries/unrar/win32acl.cpp:8–63  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6
7#ifndef SFX_MODULE
8void ExtractACL20(Archive &Arc,const wchar *FileName)
9{
10 SetACLPrivileges();
11
12 if (Arc.BrokenHeader)
13 {
14 uiMsg(UIERROR_ACLBROKEN,Arc.FileName,FileName);
15 ErrHandler.SetErrorCode(RARX_CRC);
16 return;
17 }
18
19 if (Arc.EAHead.Method<0x31 || Arc.EAHead.Method>0x35 || Arc.EAHead.UnpVer>VER_PACK)
20 {
21 uiMsg(UIERROR_ACLUNKNOWN,Arc.FileName,FileName);
22 ErrHandler.SetErrorCode(RARX_WARNING);
23 return;
24 }
25
26 ComprDataIO DataIO;
27 Unpack Unpack(&DataIO);
28 Unpack.Init(0x10000,false);
29
30 Array<byte> UnpData(Arc.EAHead.UnpSize);
31 DataIO.SetUnpackToMemory(&UnpData[0],Arc.EAHead.UnpSize);
32 DataIO.SetPackedSizeToRead(Arc.EAHead.DataSize);
33 DataIO.EnableShowProgress(false);
34 DataIO.SetFiles(&Arc,NULL);
35 DataIO.UnpHash.Init(HASH_CRC32,1);
36 Unpack.SetDestSize(Arc.EAHead.UnpSize);
37 Unpack.DoUnpack(Arc.EAHead.UnpVer,false);
38
39 if (Arc.EAHead.EACRC!=DataIO.UnpHash.GetCRC32())
40 {
41 uiMsg(UIERROR_ACLBROKEN,Arc.FileName,FileName);
42 ErrHandler.SetErrorCode(RARX_CRC);
43 return;
44 }
45
46 SECURITY_INFORMATION si=OWNER_SECURITY_INFORMATION|GROUP_SECURITY_INFORMATION|
47 DACL_SECURITY_INFORMATION;
48 if (ReadSacl)
49 si|=SACL_SECURITY_INFORMATION;
50 SECURITY_DESCRIPTOR *sd=(SECURITY_DESCRIPTOR *)&UnpData[0];
51
52 int SetCode=SetFileSecurity(FileName,si,sd);
53
54 if (!SetCode)
55 {
56 uiMsg(UIERROR_ACLSET,Arc.FileName,FileName);
57 DWORD LastError=GetLastError();
58 ErrHandler.SysErrMsg();
59 if (LastError==ERROR_ACCESS_DENIED && !IsUserAdmin())
60 uiMsg(UIERROR_NEEDADMIN);
61 ErrHandler.SetErrorCode(RARX_WARNING);
62 }
63}
64#endif
65

Callers 1

SetExtraInfo20Function · 0.85

Calls 13

SetACLPrivilegesFunction · 0.85
uiMsgFunction · 0.85
IsUserAdminFunction · 0.85
SetErrorCodeMethod · 0.80
SetUnpackToMemoryMethod · 0.80
SetPackedSizeToReadMethod · 0.80
EnableShowProgressMethod · 0.80
SetFilesMethod · 0.80
SetDestSizeMethod · 0.80
DoUnpackMethod · 0.80
GetCRC32Method · 0.80
SysErrMsgMethod · 0.80

Tested by

no test coverage detected