+ PSID pSidOwner = NULL;
+ PSECURITY_DESCRIPTOR pSD = NULL;
+ DWORD dwRtnCode = GetSecurityInfo(hFile, SE_FILE_OBJECT, OWNER_SECURITY_INFORMATION, &pSidOwner, NULL, NULL, NULL, &pSD);
+ if (dwRtnCode != ERROR_SUCCESS) {
+ DWORD dwErrorCode = GetLastError();
+ CloseHandle(hFile);
+ char alert_msg[PATH_MAX+4];
+ alert_msg[PATH_MAX + 3] = '\0';
+ snprintf(alert_msg, PATH_MAX + 4, "GetSecurityInfo=%ld %s", dwErrorCode, file_name);
+ send_syscheck_msg(alert_msg);
+ return -1;
+ }
+
+ LPSTR szSID = NULL;
+ ConvertSidToStringSid(pSidOwner, &szSID);
+ char* st_uid = NULL;
+ if( szSID ) {
+ st_uid = (char *) calloc( strlen(szSID) + 1, 1 );
+ memcpy( st_uid, szSID, strlen(szSID) );
+ }
+ LocalFree(szSID);
+ CloseHandle(hFile);
+
+ snprintf(newsum, 255, "%ld:%d:%s:%d:%s:%s",
+ size == 0 ? 0 : (long)statbuf.st_size,
+ perm == 0 ? 0 : (int)statbuf.st_mode,
+ owner == 0 ? "0" : st_uid,
+ group == 0 ? 0 : (int)statbuf.st_gid,
+ md5sum == 0 ? "xxx" : mf_sum,
+ sha1sum == 0 ? "xxx" : sf_sum);
+
+ free(st_uid);
+#endif
+
+ return (0);
+}