Post

Replies

Boosts

Views

Activity

System events (notifications) listening on Mac
Hi there! Please advice how I can subscribe to listening system events (Lock Screen/User log off/Device mounted/etc)? I try to use NSDistributedNotificationCenter to do it, but I can receive only own notifications =( This is the my test Console application: // //  main.m //  EventsListener // #import <Foundation/Foundation.h> #import <AppKit/AppKit.h> #include <iostream> @interface MyClass : NSObject -(void)subscribe; -(void)handleNotification:(NSNotification*)notification; @end @implementation MyClass : NSObject -(void)subscribe {     [[NSDistributedNotificationCenter defaultCenter] addObserver:self selector:@selector(handleNotification:) name:nil object:nil];     [[[NSWorkspace sharedWorkspace] notificationCenter] addObserver:self selector:@selector(handleNotification2:) name:nil object:nil];     [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleNotification3:) name:nil object:nil];     [[NSDistributedNotificationCenter defaultCenter] addObserver:self selector:@selector(handleNotification4:) name:@"com.apple.screenIsLocked" object:nil];     [[[NSWorkspace sharedWorkspace] notificationCenter] addObserver:self selector:@selector(handleNotification4:) name:@"com.apple.screenIsLocked" object:nil]; } -(void)handleNotification:(NSNotification*)notification {     NSLog(@"handleNotification: %@", notification); } -(void)handleNotification2:(NSNotification*)notification {     NSLog(@"handleNotification2: %@", notification); } -(void)handleNotification3:(NSNotification*)notification {     NSLog(@"handleNotification3: %@", notification); } -(void)handleNotification4:(NSNotification*)notification {     NSLog(@"handleNotification3: %@", notification); } @end int main(int argc, const char * argv[]) {     @autoreleasepool {         // insert code here...         NSLog(@"Hello, World!");         MyClass* mc = [MyClass new];         [mc subscribe];         [[NSNotificationCenter defaultCenter] postNotificationName:@"test notification" object:nil];         NSLog(@"Press enter to abort");         getchar();     }     return 0; } What wrong I does? Thanks!
3
0
2.1k
Jul ’21
Real path of /Users and other files in /System/Volumes/Data on APFS
Hello, Is in macOS exist system call which can resolve real path to file/directory for APFS? For example, in BigSur real path of /Users directory is /System/Volumes/Data/Users. So, I expect something like this: c++ std::string userFriendlyPath = "/Users/myuser1" const char* pRealPath = realpath(userFriendlyPath.c_str()); if (pRealPath == nullptr) _log.info("real path is the same"); // but in this case pRealPath should be == "/System/Volumes/Data/Users/myuser1" Thanks!
0
0
640
May ’21
App crashes on pthread_mutex_init (BigSur Beta, ARM)
Hello, We have application which works fine on macOS 10.13-11.0 with x64 architecture and in Rosetta2 on ARM. But the same code rebuilt for ARM64 caused to SEGV on pthread_mutex_init. Part of crash report: Thread 9 Crashed:: MyService server thread 0 libsystempthread.dylib 0x000000019101476c pthreadmutexinit + 368 1 myservice 0x00000001024ea654 0x1024b8000 + 206420 // boost::mutex::mutex() (in myservice) (mutex.hpp:52) 2 myservice 0x00000001024e8ed4 0x1024b8000 + 200404 // boost::mutex::mutex() (in myservice) (mutex.hpp:51) 3 myservice 0x0000000102911290 0x1024b8000 + 4559504 // veeamrpc::CTcpThread::CTcpThread(std::1::basicstring<char, std::1::chartraits<char>, std::1::allocator<char> > const&) (in myservice) (TcpThread.cpp:15) 4 myservice 0x00000001029113e0 0x1024b8000 + 4559840 5 myservice 0x00000001024fea64 0x1024b8000 + 289380 6 myservice 0x00000001024febf0 0x1024b8000 + 289776 7 myservice 0x00000001024e9564 0x1024b8000 + 202084 8 myservice 0x00000001024e8d3c 0x1024b8000 + 199996 9 myservice 0x00000001024f0810 boost::mfi::mf1<void, service::CLpbSvcServer, boost::sharedptr<api::CSocketIP> >::operator()(service::CLpbSvcServer*, boost::sharedptr<api::CSocketIP>) const + 144 10 myservice 0x00000001024f0738 void boost::bi::list2<boost::bi::value<service::CLpbSvcServer*>, boost::bi::value<boost::sharedptr<api::CSocketIP> > >::operator()<boost::mfi::mf1<void, service::CLpbSvcServer, boost::sharedptr<api::CSocketIP> >, boost::bi::list0>(boost::bi::type<void>, boost::mfi::mf1<void, service::CLpbSvcServer, boost::sharedptr<api::CSocketIP> >&, boost::bi::list0&, int) + 144 11 myservice 0x00000001024f069c boost::bi::bindt<void, boost::mfi::mf1<void, service::CLpbSvcServer, boost::sharedptr<api::CSocketIP> >, boost::bi::list2<boost::bi::value<service::CLpbSvcServer*>, boost::bi::value<boost::sharedptr<api::CSocketIP> > > >::operator()() + 72 12 myservice 0x00000001024f03b4 boost::detail::function::voidfunctionobjinvoker0<boost::bi::bindt<void, boost::mfi::mf1<void, service::CLpbSvcServer, boost::sharedptr<api::CSocketIP> >, boost::bi::list2<boost::bi::value<service::CLpbSvcServer*>, boost::bi::value<boost::sharedptr<api::CSocketIP> > > >, void>::invoke(boost::detail::function::functionbuffer&) + 36 13 myservice 0x0000000102737e3c boost::function0<void>::operator()() const + 116 14 myservice 0x0000000102737018 0x1024b8000 + 2617368 15 myservice 0x000000010273a64c boost::mfi::mf2<void, synch::Thread, boost::function<void ()>, std::1::basicstring<char, std::1::chartraits<char>, std::1::allocator<char> > const&>::operator()(synch::Thread*, boost::function<void ()>, std::1::basicstring<char, std::1::chartraits<char>, std::1::allocator<char> > const&) const + 152 16 myservice 0x000000010273a56c void boost::bi::list3<boost::bi::value<synch::Thread*>, boost::bi::value<boost::function<void ()> >, boost::bi::value<std::1::basicstring<char, std::1::chartraits<char>, std::1::allocator<char> > > >::operator()<boost::mfi::mf2<void, synch::Thread, boost::function<void ()>, std::1::basicstring<char, std::1::chartraits<char>, std::1::allocator<char> > const&>, boost::bi::list0>(boost::bi::type<void>, boost::mfi::mf2<void, synch::Thread, boost::function<void ()>, std::1::basicstring<char, std::1::chartraits<char>, std::_1::allocator<char> > const&>&, boost::bi::list0&, int) + 168 17 myservice 0x000000010273a4b8 boost::bi::bindt<void, boost::mfi::mf2<void, synch::Thread, boost::function<void ()>, std::1::basicstring<char, std::1::chartraits<char>, std::1::allocator<char> > const&>, boost::bi::list3<boost::bi::value<synch::Thread*>, boost::bi::value<boost::function<void ()> >, boost::bi::value<std::1::basicstring<char, std::1::chartraits<char>, std::1::allocator<char> > > > >::operator()() + 72 18 myservice 0x00000001027395b4 0x1024b8000 + 2626996 19 libcpprest.2.10.dylib 0x00000001051de4a8 boost::(anonymous namespace)::threadproxy(void*) + 176 20 libsystempthread.dylib 0x000000019101906c pthreadstart + 320 21 libsystempthread.dylib 0x0000000191013da0 thread_start + 8 Maybe some additional code needed for ARM64 platform? P.S. We have boost 1.70.
1
0
520
Oct ’20
Installer reopens after allowing to determine if the software can be installed on BigSur ARM64
Hello, We have plugin for installer and we use InstallerJS for additional checks before installation. Because of that when I run installer I see that message: This package will run a program to determine if the software can be installed. [Cancel] [Allow] And when I allow it my installer re-opens. It reproduces only on AppleSilicon (ARM64) version of BigSur (11.0.1 as well). Here is part of install.log: 2020-10-30 09:34:17+01 BigSurARM-MAC Installer[93715]: @(#)PROGRAM:Install PROJECT:Install-1000 2020-10-30 09:34:17+01 BigSurARM-MAC Installer[93715]: @(#)PROGRAM:Installer PROJECT:Installer-1018 2020-10-30 09:34:17+01 BigSurARM-MAC Installer[93715]: Hardware: ADP3,2 @ 0 MHz (x 8), 16384 MB RAM 2020-10-30 09:34:17+01 BigSurARM-MAC Installer[93715]: Running OS Build: macOS 11.0.1 (20B5012d) 2020-10-30 09:34:17+01 BigSurARM-MAC Installer[93715]: Env: USER=user 2020-10-30 09:34:17+01 BigSurARM-MAC Installer[93715]: Env: _CFBundleIdentifier=com.apple.installer 2020-10-30 09:34:17+01 BigSurARM-MAC Installer[93715]: Env: COMMANDMODE=unix2003 2020-10-30 09:34:17+01 BigSurARM-MAC Installer[93715]: Env: LOGNAME=user 2020-10-30 09:34:17+01 BigSurARM-MAC Installer[93715]: Env: PATH=/usr/bin:/bin:/usr/sbin:/sbin 2020-10-30 09:34:17+01 BigSurARM-MAC Installer[93715]: Env: SSHAUTHSOCK=/private/tmp/com.apple.launchd.PQMDXH1vBR/Listeners 2020-10-30 09:34:17+01 BigSurARM-MAC Installer[93715]: Env: SHELL=/bin/zsh 2020-10-30 09:34:17+01 BigSurARM-MAC Installer[93715]: Env: HOME=/Users/user 2020-10-30 09:34:17+01 BigSurARM-MAC Installer[93715]: Env: _CFUSERTEXTENCODING=0x1F6:0x0:0x0 2020-10-30 09:34:17+01 BigSurARM-MAC Installer[93715]: Env: TMPDIR=/var/folders/ks/n9ygc5yn61bdh1py1pnk7ylh0000gp/T/ 2020-10-30 09:34:17+01 BigSurARM-MAC Installer[93715]: Env: XPCSERVICENAME=application.com.apple.installer.1152921500312163792.1152921500312163797 2020-10-30 09:34:17+01 BigSurARM-MAC Installer[93715]: Env: XPCFLAGS=0x0 2020-10-30 09:34:17+01 BigSurARM-MAC Installer[93715]: MyPkg 1.0.0.605 1.0.0.605 Installation Log 2020-10-30 09:34:17+01 BigSurARM-MAC Installer[93715]: Opened from: /Users/user/MyPkg -1.0.0.605-Universal.pkg 2020-10-30 09:34:17+01 BigSurARM-MAC Installer[93715]: Package Authoring Error: <backgroundscaling> has an unsupported MIME type: X-NSObject/NSNumber 2020-10-30 09:34:17+01 BigSurARM-MAC Installer[93715]: Package Authoring Error: <backgroundalignment> has an unsupported MIME type: X-NSObject/NSNumber 2020-10-30 09:34:17+01 BigSurARM-MAC Installer[93715]: Package Authoring Error: <layout-direction> has an unsupported MIME type: X-NSObject/NSNumber 2020-10-30 09:34:17+01 BigSurARM-MAC Installer[93715]: Failed to load specified background image 2020-10-30 09:34:17+01 BigSurARM-MAC Installer[93715]: Product archive /Users/user/MyPkg -1.0.0.605-Universal.pkg trustLevel=350 2020-10-30 09:34:17+01 BigSurARM-MAC Installer[93715]: External component packages (1) trustLevel=350 2020-10-30 09:34:19+01 BigSurARM-MAC Installer[93715]: Could not load resource readme: (null) 2020-10-30 09:34:19+01 BigSurARM-MAC Installer[93715]: Architecture Translation: Distribution failed architecture check and is about to be re-executed as Intel. 2020-10-30 09:34:19+01 BigSurARM-MAC Installer[93715]: Architecture Translation: Process is about to get executed as Intel. 2020-10-30 09:34:19+01 BigSurARM-MAC Installer[93715]: @(#)PROGRAM:Install PROJECT:Install-1000 2020-10-30 09:34:19+01 BigSurARM-MAC Installer[93715]: @(#)PROGRAM:Installer PROJECT:Installer-1018 So, I have "Architecture Translation: Process is about to get executed as Intel." error, but one thing - it is Universal package (built on Intel based Mac using cross-compilation). It means that plugin for installer was built for both architectures and then Universal binary was made from them, which is actually stored in the package. Then I built just ARM package: lipo -archs /tmp/pkgbuild/darwin/flat/Plugins/LicenseAgeementsPlugin.bundle/Contents/MacOS/LicenseAgeementsPlugin arm64 , but I got the same error: 2020-10-30 09:48:34+01 BigSurARM-MAC Installer[93836]: Could not load resource readme: (null) 2020-10-30 09:48:34+01 BigSurARM-MAC Installer[93836]: Architecture Translation: Distribution failed architecture check and is about to be re-executed as Intel. 2020-10-30 09:48:34+01 BigSurARM-MAC Installer[93836]: Architecture Translation: Process is about to get executed as Intel. 2020-10-30 09:48:35+01 BigSurARM-MAC Installer[93836]: @(#)PROGRAM:Install PROJECT:Install-1000 2020-10-30 09:48:35+01 BigSurARM-MAC Installer[93836]: @(#)PROGRAM:Installer PROJECT:Installer-1018 2020-10-30 09:48:35+01 BigSurARM-MAC Installer[93836]: Hardware: ADP3,2 @ 2.40 GHz (x 4), 16384 MB RAM But I didn't have x8664 binaries in my package. How is it possible? What I do wrong? Thanks.
5
0
2.4k
Oct ’20
Using MDM profile in application
Hello all, I have found many articles how to distribute MDM profiles, but no one about using MDM profiles in applications. Is there some API or any documentation for that? For example, my application is already installed and now awaiting for MDM profile installed for all users. How I can determine that I need MDM profile installed? How I can determine path of this profile to read it in own application? Should I have some entitlements for that? Does any API exist for that, maybe? Thanks!
8
0
2.2k
Jun ’20
Mount SMB share via attaching to StdIn & StdOut of child process
Hello!I try to read stdout and to write to stdin of a child process using method described here: http://www.microhowto.info/howto/capture_the_output_of_a_child_process_in_c.htmlIt's work fine for typical commandline tools, but it doesn't work for mount utility - password prompt everytime showed in my (parent) process. Why it happens? What is the difference between typical writing to stdout and password prompting in macOS?Thanks
3
0
1.3k
Feb ’20
Get a filesystem UUID
Hello!I have flash storage with exFAT filesystem and I need to get it filesystem UUID. How can I do it programmatically?I attempt to get it via ioreg, and I think that Filesystem UUID is "Content" property of partition. Below we can think that filesystem UUID is EBD0A0A2-B9E5-4433-87C0-68B6B72699C7.+-o IOBlockStorageServices &lt;class IORegistryEntry:IOService:IOBlockStorageDevice:IOBlockStorageServices, id 0x10000129c, registered, matched, active, busy 0 (73 ms), retain 6&gt; | { | "IOMinimumSegmentAlignmentByteCount" = 4 | "device-type" = "Generic" | "Protocol Characteristics" = {"Physical Interconnect"="USB","Read Time Out Duration"=30000,"SCSI Logical Unit Number"=0,"Physical Interconnect Location"="External","Write Time Out Duration"=30000,"Retry Count"=20} | "Device Characteristics" = {"Vendor Name"="Kingston","Product Name"="DataTraveler 2.0","Product Revision Level"="1.00"} | } | +-o IOBlockStorageDriver &lt;class IORegistryEntry:IOService:IOStorage:IOBlockStorageDriver, id 0x10000129d, registered, matched, active, busy 0 (72 ms), retain 8&gt; | { | "IOPropertyMatch" = {"device-type"="Generic"} | "CFBundleIdentifier" = "com.apple.iokit.IOStorageFamily" | "IOProviderClass" = "IOBlockStorageDevice" | "IOClass" = "IOBlockStorageDriver" | "IOProbeScore" = 0 | "CFBundleIdentifierKernel" = "com.apple.iokit.IOStorageFamily" | "Statistics" = {"Operations (Write)"=338,"Latency Time (Write)"=0,"Bytes (Read)"=532992,"Errors (Write)"=0,"Total Time (Read)"=147844763,"Latency Time (Read)"=0,"Retries (Read)"=0,"Errors (Read)"=0,"Total Time (Write)"=3660822621,"Bytes (Write)"=1882624,"Operations (Read)"=101,"Retries (Write)"=0} | "IOMatchCategory" = "IODefaultMatchCategory" | "IOGeneralInterest" = "IOCommand is not serializable" | } | +-o Kingston DataTraveler 2.0 Media &lt;class IORegistryEntry:IOService:IOStorage:IOMedia, id 0x1000012b3, registered, matched, active, busy 0 (72 ms), retain 12&gt; | { | "Content" = "GUID_partition_scheme" | "Removable" = Yes | "Whole" = Yes | "Leaf" = No | "BSD Name" = "disk2" | "Ejectable" = Yes | "Preferred Block Size" = 512 | "IOMediaIcon" = {"IOBundleResourceFile"="Removable.icns","CFBundleIdentifier"="com.apple.iokit.IOStorageFamily"} | "BSD Minor" = 9 | "IOGeneralInterest" = "IOCommand is not serializable" | "Writable" = Yes | "BSD Major" = 1 | "Size" = 15500574720 | "IOBusyInterest" = "IOCommand is not serializable" | "Open" = Yes | "Content Hint" = "" | "BSD Unit" = 2 | } | +-o IOMediaBSDClient &lt;class IORegistryEntry:IOService:IOMediaBSDClient, id 0x1000012b8, registered, matched, active, busy 0 (0 ms), retain 6&gt; | { | "IOProbeScore" = 30000 | "CFBundleIdentifier" = "com.apple.iokit.IOStorageFamily" | "IOMatchCategory" = "IOMediaBSDClient" | "IOClass" = "IOMediaBSDClient" | "IOProviderClass" = "IOMedia" | "CFBundleIdentifierKernel" = "com.apple.iokit.IOStorageFamily" | "IOResourceMatch" = "IOBSD" | } | +-o IOGUIDPartitionScheme &lt;class IORegistryEntry:IOService:IOStorage:IOPartitionScheme:IOGUIDPartitionScheme, id 0x1000012ba, !registered, !matched, active, busy 0 (0 ms), retain 6&gt; | { | "IOProbeScore" = 4000 | "IOPropertyMatch" = {"Whole"=Yes} | "IOMatchCategory" = "IOStorage" | "IOClass" = "IOGUIDPartitionScheme" | "IOProviderClass" = "IOMedia" | "CFBundleIdentifier" = "com.apple.iokit.IOStorageFamily" | "CFBundleIdentifierKernel" = "com.apple.iokit.IOStorageFamily" | "UUID" = "DB6A5DED-C145-4F28-B80E-5DA726D76AF2" | "Content Mask" = "GUID_partition_scheme" | } | +-o Microsoft Basic Data@1 &lt;class IORegistryEntry:IOService:IOStorage:IOMedia, id 0x1000012be, registered, matched, active, busy 0 (0 ms), retain 11&gt; | { | "Open" = Yes | "Preferred Block Size" = 512 | "Base" = 1048576 | "Writable" = Yes | "IOBusyInterest" = "IOCommand is not serializable" | "Size" = 15499509248 | "Content" = "EBD0A0A2-B9E5-4433-87C0-68B6B72699C7" | "BSD Minor" = 10 | "Whole" = No | "Removable" = Yes | "UUID" = "E704A750-5562-4578-9F97-D4D0E0326C7A" | "BSD Unit" = 2 | "BSD Major" = 1 | "Ejectable" = Yes | "BSD Name" = "disk2s1" | "Partition ID" = 1 | "IOGeneralInterest" = "IOCommand is not serializable" | "GPT Attributes" = 0 | "Content Hint" = "EBD0A0A2-B9E5-4433-87C0-68B6B72699C7" | "Leaf" = Yes | } | +-o IOMediaBSDClient &lt;class IORegistryEntry:IOService:IOMediaBSDClient, id 0x1000012bf, registered, matched, active, busy 0 (0 ms), retain 7&gt; { "IOProbeScore" = 30000 "CFBundleIdentifier" = "com.apple.iokit.IOStorageFamily" "IOMatchCategory" = "IOMediaBSDClient" "IOClass" = "IOMediaBSDClient" "IOProviderClass" = "IOMedia" "CFBundleIdentifierKernel" = "com.apple.iokit.IOStorageFamily" "IOResourceMatch" = "IOBSD" }BUT when I try to check it via diskutil, I've get two ID's with similiar names - volume, disk/partition:diskutil info disk2s1 | grep UUID Volume UUID: C1E39943-2F19-369A-A22F-11027887EBC8 Disk / Partition UUID: E704A750-5562-4578-9F97-D4D0E0326C7AAnd one of these UUIDs is not present in ioreg output - C1E39943-2F19-369A-A22F-11027887EBC8. Very interesting. I'd check in Disk Utility (with GUI) and in information about partition I see that (Filesystem UUID: C1E39943-2F19-369A-A22F-11027887EBC8):https://i.ibb.co/pKrqs3r/Screenshot-2020-02-11-at-10-45-34.pngAnd for more information here is output of blkid in Linux:sudo blkid /dev/sdf1/dev/sdf1: LABEL="exFAT" UUID="9CAD-0C6D" TYPE="exfat" PARTLABEL="Microsoft Basic Data" PARTUUID="e704a750-5562-4578-9f97-d4d0e0326c7a"We can see that partition UUID is equal, but filesystem UUID - is not.Someone can explain me:1. how I can get Filesystem UUID of volume programmatically?2. why results in Linux and macOS are different?3. why in some places C1E39943-2F19-369A-A22F-11027887EBC8 is Volume UUID, but in some places - Filesystem UUID? After all It really different things!Thanks!
6
0
3.5k
Feb ’20