Hello,
I need to monitor input events and convert keycode to symbol. E.g. convert kHIDUsage_KeyboardQ to symbol according to used keyboard layout.
Are there any API to get current keyboard layout (language) in C++? If I understand correctly, the API TISGetInputSourceProperty() is deprecated.
Are there any way to monitor keyboard layout changed? (some system notification in case of keyboard layout change)
Are there any way to translate keycode to symbol except UCKeyTranslate() which is part of deprecated Unicode Utilities?
Thank you in advance.
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
I need to intercept traffic (by port range) and need to have ability to modify it. If I understand correctly, the best way is to use NETransparentProxyProvider for this purpose. Is my understanding correct?
I am trying to figure out how to make system extension (NETransparentProxyProvider) intercept the traffic.
Unfortunately I have not found any description or example (similar to Network Filter).
I am novice in Network Extension. Are there any guide, example or quick start how to implement app proxy?
Thank you!
The scenario is quite simple
run an application which uses [SCShareableContent getShareableContentExcludingDesktopWindows] and invoke captureImageWithFilter in completionHandler.
delay invoking captureImageWithFilter for several seconds and switch user session before call it.
The WindowServer crashes if app runs in inactive session.
How to manage this issue correctly? Are there any way to avoid this crash?
The kernel sends SIGKILL to application if it handles ES_EVENT_TYPE_AUTH_OPEN and lldb is attached to this process.
App:
int main(int /*argc*/, char** /*argv*/)
{
es_client_t *pEpClient = nullptr;
es_new_client_result_t result = es_new_client(&pEpClient, ^(es_client_t *pClient, const es_message_t *pMessage)
{
switch (pMessage->event_type)
{
case ES_EVENT_TYPE_AUTH_OPEN:
{
uint32_t authorizedFlags = pMessage->event.open.fflag;
if ((authorizedFlags & FREAD) || (authorizedFlags & FWRITE))
{
std::filesystem::path filePath = std::string(pMessage->event.open.file->path.data, pMessage->event.open.file->path.length);
std::string fileName = filePath.filename();
if (fileName == "test.txt")
{
std::cout << "blocked fileName: " << filePath.filename() << std::endl;
authorizedFlags &= ~FWRITE;
authorizedFlags &= ~FREAD;
}
}
if (es_respond_flags_result(pClient, pMessage, authorizedFlags, false) != ES_RESPOND_RESULT_SUCCESS)
{
std::cout << "es_respond_flags_result() failed with error " << std::endl;
}
}
break;
default:
break;
}
});
if (result != ES_NEW_CLIENT_RESULT_SUCCESS)
{
std::cout << "es_new_client() failed." << std::endl;
return 1;
}
es_event_type_t eventsList[] =
{
ES_EVENT_TYPE_AUTH_OPEN
};
if (es_subscribe(pEpClient, eventsList, 1) == ES_RETURN_ERROR)
{
std::cout << "es_subscribe() failed." << std::endl;
}
// wait
int i = 0;
std::cin >> i;
if (es_delete_client(pEpClient) == ES_RETURN_ERROR)
{
std::cout << "es_delete_client() failed." << std::endl;
}
return 0;
}
(lldb) process attach --pid 61127
....
(lldb) c
Process 61127 resuming
Process 61127 exited with status = 9 (0x00000009) Terminated due to signal 9
System log:
Allowing set_exception_ports from [debugserver] on [ep_sample] for entitled process/debugger
Client did not respond in appropriate amount of time (client pid: 61127), sent SIGKILL
Hello,
Let's say I have several opened user sessions in parallel.
Endpoint Security notify about executing a process (ES_EVENT_TYPE_NOTIFY_EXEC) and provide audit token.
The goal is to find relationship between logged-in users and new process.
Can I use audit user ID for this?
Thank you in advance.
I have NTFS which is mounted on '/Volumes/usb_vol'
#mount
Filesystem Mounted on
/dev/disk5s1 /Volumes/usb_vol
The following simple code reports different values of device Id for device-file and mount point directory
struct stat buf;
for (int i = 1; i < argc; i++)
{
std::cout << argv[i] << std::endl;
if (stat(argv[i], &buf) < 0)
{
continue;
}
if (S_ISBLK(buf.st_mode))
{
std::cout << "st_rdev (" << major(buf.st_rdev) << "/" << minor(buf.st_rdev) << ") hex: " << std::hex << buf.st_rdev << std::endl;
}
else
{
std::cout << "st_dev (" << major(buf.st_dev) << "/" << minor(buf.st_dev) << ") hex: " << std::hex << buf.st_dev << std::endl;
}
}
Output:
/dev/disk5s1
st_rdev (1/22) hex: 1000016
/Volumes/usb_vol
st_dev (48/119) hex: 30000077
I believe this is expected but I have not found any explanation of this behaviour.
Are there any explanation of difference these values?
I can assume the stat() will report (48/119) for all objects which are located on this file system. Is it correct?
Thank you for the help!
Hello,
My app is handling ES_EVENT_TYPE_AUTH_OPEN.
Which character encoding is used in Endpoint Security events? (es_file_t)
Thank you in advance,
Pavel
Hello,
My app needs to report whether a file, which is located on usb volume, is modified by specific application.
I use Endpoint Security framework and I know about "Inferring High-Level Semantics from Low-Level Operations" problem.
However, in spite of this limitation, I need to implement app which reports as much info as possible.
I faced with some unclear behaviour of TestEdit. The scenario is:
Open a file, which is located on usb volume, by TextEdit
/dev/disk4s2 on /Volumes/USBVol (msdos, local, nodev, nosuid, noowners, noatime, fskit)
Modify and save it
Endpoint Security reports open and close events only (modified flag is false)
ES_EVENT_TYPE_AUTH_COPYFILE, ES_EVENT_TYPE_AUTH_CLONE, ES_EVENT_TYPE_NOTIFY_UTIMES and ES_EVENT_TYPE_NOTIFY_WRITE are not reported by Endpoint Security (monitored all processes in system). (Looks like the same behaviour for Xcode)
I am stuck in this moment. Are there any way to monitor file modification if user do it by TextEdit?
Thank you in advance!
Hello,
es_event_mount_t includes statfs structure. This structure has the field 'f_type' which defines type of filesystem. However, man page says nothing about possible values of this field.
What is the best way to define file system type?
Can I use 'f_type' or 'f_fstypename'? If so, are there any constants in header files which can be used?
Thank you for your help!
Hello Dev,
The App, which I am working on, uses fcopyfile() to copy file from external storage (USB, thunderbolt) to internal disk. Looks like this call provides the best performance.
fcopyfile(from, to, nullptr, COPYFILE_DATA);
I need to be sure the data is copied after the call. Are there any necessity to synchronize a file's state with that on disk the data? (e.g. call fsync())
Thank you in advance!
Pavel
Hello,
What is the best and Apple recommended way to get display name and its vendor information?
The CoreGraphics framework provides ModelNumber and VendorNumber only.
Looks like IOKit does not provide any documented way at all.
Are there any daemon safe way to get such information?
Thank you in advance,
Pavel
Hello,
I am trying to get space which is consumed by APFS volume. The call getattrlist() works fine on macOS 15 (Apple silicon). However, it returns EINVAL on macOS 11.7.10 (Intel) if ATTR_VOL_SPACEUSED is defined.
struct VolAttrBuf
{
u_int32_t length;
off_t spaceUsed;
} __attribute__((aligned(4), packed));
int64_t GetVolumeSpaceUsed(const std::string& mountPath)
{
struct attrlist attrList;
std::memset(&attrList, 0, sizeof(attrList));
attrList.bitmapcount = ATTR_BIT_MAP_COUNT;
attrList.volattr = ATTR_VOL_INFO | ATTR_VOL_SPACEUSED;
VolAttrBuf attrBuf;
if (getattrlist(mountPath.c_str(), &attrList, &attrBuf, sizeof(attrBuf), 0) ||
attrBuf.length > sizeof(attrBuf))
{
std::cout << "getattrlist() failed with errno (" << errno << ")" << std::endl;
return -1;
}
return attrBuf.spaceUsed;
}
Is it bug or ATTR_VOL_SPACEUSED is unsupported on macOS 11?
Are there any other way to get space which is used on an APFS volume? (C++)
Thank you in advance,
Pavel
Hello,
I am working on a daemon which collects information about disk space usage on macOS.
APFS has quite complex structure and there is a challenge to get detailed info.
My application must provide disk usage by APFS containers.
Are there any recommended way to get space usage by particular APFS volume?
Are there any recommended way to get free space on particular APFS container?
Are there any recommended way to enumerate APFS containers and volumes?
I am using Disk Arbitration to get APFS info. However, I get restricted info about space usage because I get get disk usage for mounted volumes only.
Are there any public API (daemon-safe) which allows to easily get disk space usage on macOS?
Thank you in advance,
Pavel
Hello,
I'm trying to get a list of all network devices (device audit for DLP system).
CFMutableDictionaryRef matchingDictionary = IOServiceMatching(kIONetworkControllerClass);
if (matchingDictionary == nullptr)
{
std::cerr << "IOServiceMatching() returned empty matching dictionary" << std::endl;
return 1;
}
io_iterator_t iter;
if (kern_return_t kr = IOServiceGetMatchingServices(kIOMasterPortDefault, matchingDictionary, &iter);
kr != KERN_SUCCESS)
{
std::cerr << "IOServiceGetMatchingServices() failed" << std::endl;
return 1;
}
io_service_t networkController;
while ((networkController = IOIteratorNext(iter)) != IO_OBJECT_NULL)
{
std::cout << "network device: ";
if (CFDataRef cfIOMACAddress = (CFDataRef) IORegistryEntryCreateCFProperty(networkController, CFSTR(kIOMACAddress), kCFAllocatorDefault, kNilOptions);
cfIOMACAddress != nullptr)
{
std::vector<uint8_t> data(CFDataGetLength(cfIOMACAddress));
CFDataGetBytes(cfIOMACAddress, CFRangeMake(0, data.size()), data.data());
std::cout << std::hex << std::setfill('0') << std::setw(2) << (short)data[0] << ":"
<< std::hex << std::setfill('0') << std::setw(2) << (short) data[1] << ":"
<< std::hex << std::setfill('0') << std::setw(2) << (short) data[2] << ":"
<< std::hex << std::setfill('0') << std::setw(2) << (short) data[3] << ":"
<< std::hex << std::setfill('0') << std::setw(2) << (short) data[4] << ":"
<< std::hex << std::setfill('0') << std::setw(2) << (short) data[5];
CFRelease(cfIOMACAddress);
}
std::cout << std::endl;
IOObjectRelease(networkController);
}
IOObjectRelease(iter);
The Wi-Fi controller shows up in I/O Registry Explorer, but IOServiceGetMatchingServices() does not return any information about it.
Any way to retrieve Wi-Fi controller info in daemon code?
Thank you in advance!
Hello,
As part of developing a DLP system, I need to block input devices upon detection of data leakage.
Could you advise if it's possible to temporarily disable the built-in keyboard and camera?
Thank you in advance,
Pavel