我试图写一个程序,收集文件的安全信息,并将其转换成人文可读信息。 然而,我面临着一个初始化一个指针结构的问题:
#include <stdio.h>
#include <aclapi.h>
#pragma comment(lib, "advapi32.lib")
struct file_perms {
char user_domain[2050];
unsigned long user_mask;
};
static myfunc (){
PSECURITY_DESCRIPTOR pSD = NULL;
PACL pDACL = NULL;
char *file = "D:/code/test.c";
ACL_SIZE_INFORMATION aclSize;
ULONG result = GetNamedSecurityInfo(file,SE_FILE_OBJECT, DACL_SECURITY_INFORMATION, NULL, NULL, &pDACL, NULL, &pSD);
if (ERROR_SUCCESS != result) {
printf( "GetNamedSecurityInfo Error %u
", result );
}
if(pDACL != NULL){printf ("2
");}
//ACL_SIZE_INFORMATION aclSize = {0};
ZeroMemory(&aclSize, sizeof(ACL_SIZE_INFORMATION));
if(pDACL != NULL){
if(!GetAclInformation(pDACL, &aclSize, sizeof(aclSize),
AclSizeInformation)){
printf("GetAclInformation Error
");
return 0;
}
printf("AceCount %d
",aclSize.AceCount);
}
file_perms *fp = new file_perms[aclSize.AceCount];
}
While compiling, I am getting the following error. getnamed.c
getnamed.c(34) : error C2065: file_perms : undeclared identifier
getnamed.c(34) : error C2065: fp : undeclared identifier
getnamed.c(34) : error C2065: new : undeclared identifier
getnamed.c(34) : error C2106: = : left operand must be l-value
getnamed.c(34) : error C2146: syntax error : missing ; before identifier file
_perms
getnamed.c(34) : error C2065: file_perms : undeclared identifier
getnamed.c(34) : error C2109: subscript requires array or pointer type
有人能帮助我理解为什么文件_perms会被标记为未申报标识符吗? 虽然文件已被宣布为结构?
谢谢你的帮助