#include <stdio.h>
#include <stdbool.h>
#include <stdlib.h>
#include <string.h>
#include <libamfi.h>
int main()
{
printf("[BEGIN] amfi-interpose\n");
char* p1 = malloc(10);
bool interposed = (strncmp(p1, "####################", 20) == 0);
const char* amfiBits = getenv("DYLD_AMFI_FAKE");
if ( amfiBits == NULL ) {
printf("[FAIL] amfi-interpose: DYLD_AMFI_FAKE not setn\n");
return 0;
}
#ifdef AMFI_RETURNS_INTERPOSING_FLAG
bool allowInterposing = (strcmp(amfiBits, "0x7F") == 0);
#else
bool allowInterposing = true;
#endif
if ( interposed == allowInterposing )
printf("[PASS] amfi-interpose\n");
else if ( interposed )
printf("[FAIL] amfi-interpose: malloc interposed, but amfi said to block it\n");
else
printf("[FAIL] amfi-interpose: malloc not interposed, but amfi said to allow it\n");
return 0;
}