[BUGFIX] In API: keep the API pure C. Do not use C++ references

This commit is contained in:
hasherezade
2026-04-01 18:10:31 +02:00
parent e17d810108
commit 4ccca01b42
2 changed files with 9 additions and 8 deletions
+2 -2
View File
@@ -42,10 +42,10 @@ typedef t_report_type PEsieve_rtype;
#endif
//! Performs a PE-sieve scan with a supplied set of parameters (defined as a structure t_params). Returns a summary of the scan in a variable of type t_report.
PEsieve_report PESIEVE_API_FUNC PESieve_scan(IN const PEsieve_params &args);
PEsieve_report PESIEVE_API_FUNC PESieve_scan(IN const PEsieve_params *args);
//! Performs a PE-sieve scan with a supplied set of parameters (defined as a structure t_params). Returns a summary of the scan in a variable of type t_report. Allows to supply a buffer that will be filled with full JSON report.
PEsieve_report PESIEVE_API_FUNC PESieve_scan_ex(IN const PEsieve_params &args, IN const PEsieve_rtype rtype, OUT char* json_buf, IN size_t json_buf_size, OUT size_t *buf_needed_size);
PEsieve_report PESIEVE_API_FUNC PESieve_scan_ex(IN const PEsieve_params *args, IN const PEsieve_rtype rtype, OUT char* json_buf, IN size_t json_buf_size, OUT size_t *buf_needed_size);
#ifdef __cplusplus
};
+7 -6
View File
@@ -27,16 +27,17 @@ size_t print_report(const pesieve::ReportEx& report, const pesieve::t_params arg
return report_len;
}
PEsieve_report PESIEVE_API_FUNC PESieve_scan_ex(IN const PEsieve_params &args, IN const PEsieve_rtype rtype, OUT char* json_buf, IN size_t json_buf_size, OUT size_t* needed_size)
PEsieve_report PESIEVE_API_FUNC PESieve_scan_ex(IN const PEsieve_params *args, IN const PEsieve_rtype rtype, OUT char* json_buf, IN size_t json_buf_size, OUT size_t* needed_size)
{
if (IsBadReadPtr((LPVOID)&args, sizeof(PEsieve_params)) ) {
if (!args || IsBadReadPtr((LPVOID)args, sizeof(PEsieve_params))) {
pesieve::t_report empty = { 0 };
empty.errors = 1;
return empty;
}
const pesieve::ReportEx* report = pesieve::scan_and_dump(args);
const PEsieve_params _args = *args;
const pesieve::ReportEx* report = pesieve::scan_and_dump(_args);
pesieve::t_report summary = { 0 };
summary.pid = args.pid;
summary.pid = _args.pid;
summary.errors = pesieve::ERROR_SCAN_FAILURE;
if (!report) {
return summary;
@@ -57,7 +58,7 @@ PEsieve_report PESIEVE_API_FUNC PESieve_scan_ex(IN const PEsieve_params &args, I
//print the report (only if any valid output buffer was passed)
if (json_buf || needed_size) {
const size_t report_size = print_report(*report, args, rtype, json_buf, json_buf_size);
const size_t report_size = print_report(*report, _args, rtype, json_buf, json_buf_size);
if (needed_size) {
*needed_size = report_size;
}
@@ -66,7 +67,7 @@ PEsieve_report PESIEVE_API_FUNC PESieve_scan_ex(IN const PEsieve_params &args, I
return summary;
}
PEsieve_report PESIEVE_API_FUNC PESieve_scan(IN const PEsieve_params &args)
PEsieve_report PESIEVE_API_FUNC PESieve_scan(IN const PEsieve_params *args)
{
return PESieve_scan_ex(args, REPORT_NONE, nullptr, 0, nullptr);
}