Trouble using CoreGraphics

Hi,


I am trying to make a keylogger using CoreGraphics. I downloaded some code from https://github.com/dannvix/keylogger-osx which compiled and worked a few months ago, but now I am getting "No matching function for call to CGEventTapCreate". I tried building my project as Objective C++ and it seems the compiler doesn't recognise this function (CGEventTapCreate). I included CoreGraphics, ApplicationServices and Foundation frameworks. If I try building the project as C++ only the compiler error disappears but during building phase I get dozens of compiler errors not recognising other headers included via Foundation.h (errors which do not appear if I build files as Objective C++). Does anyone have experience with this? Is there another way to build a keylogger without CG ?


PS: I am trying to make a shortcut replacement app, not password stealing (something like TextExpander).


Replies

I’m not sure what’s going on with your project but I have a simple test that might help you narrow down the problem:

  1. Create a new project from the Command Line Tool template

  2. Set

    main.m
    to the source shown below.

Does it build? If it does, you know that the problem is specific to your app. OTOH, if it doesn’t build, there’s something wrong with your Xcode (which would be quite weird).

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"
@import CoreGraphics;
@import Foundation;

int main(int argc, const char * argv[]) {
    NSLog(@"%p", CGEventTapCreate);
    return 0;
}