Skip to content

Commit

Permalink
Implement new string hiding in plain sight
Browse files Browse the repository at this point in the history
  • Loading branch information
LeoNatan committed Sep 3, 2024
1 parent 2804df6 commit fb65937
Show file tree
Hide file tree
Showing 21 changed files with 334 additions and 326 deletions.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2015-2021 Leo Natan
Copyright (c) 2015-2024 Léo Natan

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
87 changes: 50 additions & 37 deletions LNPopupController/LNPopupController.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions LNPopupController/LNPopupController/Private/LNMath.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@
#ifndef C__Math_h
#define C__Math_h

#import <CoreFoundation/CoreFoundation.h>

CF_EXTERN_C_BEGIN

extern double _ln_clamp(double v, double lo, double hi);

CF_EXTERN_C_END

#endif /* C__Math_h */
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
#import "_LNPopupBackgroundShadowView.h"
#import "_LNPopupBarBackgroundMaskView.h"

CF_EXTERN_C_BEGIN

extern const CGFloat LNPopupBarHeightCompact;
extern const CGFloat LNPopupBarHeightProminent;
extern const CGFloat LNPopupBarHeightFloating;
Expand Down Expand Up @@ -134,3 +136,5 @@ inline __attribute__((always_inline)) LNPopupBarStyle _LNPopupResolveBarStyleFro
- (void)_cancelAnyUserInteraction;

@end

CF_EXTERN_C_END
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#import "LNPopupCustomBarViewController+Private.h"
#import "MarqueeLabel.h"
#import "_LNPopupSwizzlingUtils.h"
#import "_LNPopupBase64Utils.hh"
#import "NSAttributedString+LNPopupSupport.h"
#import "_LNPopupBarShadowedImageView.h"
#import "UIView+LNPopupSupportPrivate.h"
Expand Down Expand Up @@ -78,17 +79,15 @@ CGFloat _LNPopupBarHeightForPopupBar(LNPopupBar* popupBar)
}

#ifndef LNPopupControllerEnforceStrictClean
//_effectWithStyle:tintColor:invertAutomaticStyle:
static NSString* const _eWSti = @"X2VmZmVjdFdpdGhTdHlsZTp0aW50Q29sb3I6aW52ZXJ0QXV0b21hdGljU3R5bGU6";
static SEL _effectWithStyle_tintColor_invertAutomaticStyle_SEL;
static id(*_effectWithStyle_tintColor_invertAutomaticStyle)(id, SEL, NSUInteger, UIColor*, BOOL);

__attribute__((constructor))
static void __setupFunction(void)
{
_effectWithStyle_tintColor_invertAutomaticStyle_SEL = NSSelectorFromString(_LNPopupDecodeBase64String(_eWSti));
_effectWithStyle_tintColor_invertAutomaticStyle_SEL = NSSelectorFromString(LNPopupHiddenString("_effectWithStyle:tintColor:invertAutomaticStyle:"));
Method m = class_getClassMethod(UIBlurEffect.class, _effectWithStyle_tintColor_invertAutomaticStyle_SEL);
_effectWithStyle_tintColor_invertAutomaticStyle = (void*)method_getImplementation(m);
_effectWithStyle_tintColor_invertAutomaticStyle = reinterpret_cast<decltype(_effectWithStyle_tintColor_invertAutomaticStyle)>(method_getImplementation(m));
}
#endif

Expand Down Expand Up @@ -221,7 +220,7 @@ @implementation LNPopupBar
{
BOOL _delaysBarButtonItemLayout;

_LNPopupBarShadowedImageView* _imageView;
UIImageView* _imageView;

_LNPopupBarTitlesView* _titlesView;
NSLayoutConstraint* _titlesViewLeadingConstraint;
Expand Down Expand Up @@ -440,7 +439,7 @@ - (nonnull instancetype)initWithFrame:(CGRect)frame
_imageView.isAccessibilityElement = YES;
_imageView.layer.cornerCurve = kCACornerCurveContinuous;
_imageView.layer.masksToBounds = YES;
_imageView.cornerRadius = 6;
static_cast<_LNPopupBarShadowedImageView*>(_imageView).cornerRadius = 6;

// support smart invert and therefore do not invert image view colors
_imageView.accessibilityIgnoresInvertColors = YES;
Expand Down Expand Up @@ -738,10 +737,8 @@ - (void)willMoveToWindow:(UIWindow *)newWindow
static NSString* didRotate = nil;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
//UIWindowWillRotateNotification
willRotate = _LNPopupDecodeBase64String(@"VUlXaW5kb3dXaWxsUm90YXRlTm90aWZpY2F0aW9u");
//UIWindowDidRotateNotification
didRotate = _LNPopupDecodeBase64String(@"VUlXaW5kb3dEaWRSb3RhdGVOb3RpZmljYXRpb24=");
willRotate = LNPopupHiddenString("UIWindowWillRotateNotification");
didRotate = LNPopupHiddenString("UIWindowDidRotateNotification");
});

if(self.window)
Expand Down Expand Up @@ -781,11 +778,10 @@ - (void)_windowDidRotate:(NSNotification*)note

- (NSString*)_effectGroupingIdentifierKey
{
static NSString* gN = @"Z3JvdXBOYW1l";
static NSString* rv = nil;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
rv = _LNPopupDecodeBase64String(gN);
rv = LNPopupHiddenString("groupName");
});
return rv;
}
Expand Down Expand Up @@ -943,7 +939,7 @@ - (void)_appearanceDidChange
_contentView.effect = nil;
_contentView.foregroundColor = nil;
_contentView.foregroundImage = nil;
_contentView.foregroundImageContentMode = 0;
_contentView.foregroundImageContentMode = (UIViewContentMode)0;
[_contentView hideOrShowImageViewIfNecessary];
}

Expand Down Expand Up @@ -972,7 +968,7 @@ - (void)_appearanceDidChange

_floatingBackgroundShadowView.shadow = self.activeAppearance.floatingBarBackgroundShadow;

_imageView.shadow = self.activeAppearance.imageShadow;
static_cast<_LNPopupBarShadowedImageView*>(_imageView).shadow = self.activeAppearance.imageShadow;

[self.customBarViewController _activeAppearanceDidChange:self.activeAppearance];

Expand Down Expand Up @@ -1247,8 +1243,14 @@ - (void)setBarItemsSemanticContentAttribute:(UISemanticContentAttribute)barItems
- (UIView*)_viewForBarButtonItem:(UIBarButtonItem*)barButtonItem
{
UIView* itemView = [barButtonItem valueForKey:@"view"];
//_UITAMICAdaptorView
if([itemView.superview isKindOfClass:NSClassFromString(_LNPopupDecodeBase64String(@"X1VJVEFNSUNBZGFwdG9yVmlldw=="))])

static NSString* adaptorView = nil;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
adaptorView = LNPopupHiddenString("_UITAMICAdaptorView");
});

if([itemView.superview isKindOfClass:NSClassFromString(adaptorView)])
{
itemView = itemView.superview;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,10 @@

#import "LNPopupBarAppearance+Private.h"
#import "_LNPopupSwizzlingUtils.h"
#import "_LNPopupBase64Utils.hh"

static void* _LNPopupItemObservationContext = &_LNPopupItemObservationContext;

//appearance:categoriesChanged:
static NSString* const aCC = @"YXBwZWFyYW5jZTpjYXRlZ29yaWVzQ2hhbmdlZDo=";
//changeObserver
static NSString* const cO = @"Y2hhbmdlT2JzZXJ2ZXI=";

@implementation LNPopupBarAppearance
{
BOOL _wantsDynamicFloatingBackgroundEffect;
Expand All @@ -32,13 +28,12 @@ + (void)initialize
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
__notifiedProperties = _LNPopupGetPropertyNames(self, nil);
});


#ifndef LNPopupControllerEnforceStrictClean
//appearance:categoriesChanged:
Method m1 = class_getInstanceMethod(self, @selector(a:cC:));
class_addMethod(self, NSSelectorFromString(_LNPopupDecodeBase64String(aCC)), method_getImplementation(m1), method_getTypeEncoding(m1));
Method m1 = class_getInstanceMethod(self, @selector(a:cC:));
class_addMethod(self, NSSelectorFromString(LNPopupHiddenString("appearance:categoriesChanged:")), method_getImplementation(m1), method_getTypeEncoding(m1));
#endif
});
}
}

Expand All @@ -58,8 +53,7 @@ - (void)a:(UIBarAppearance *)arg1 cC:(NSUInteger)arg2
- (void)_commonInit
{
#ifndef LNPopupControllerEnforceStrictClean
//changeObserver
[self setValue:self forKey:_LNPopupDecodeBase64String(cO)];
[self setValue:self forKey:LNPopupHiddenString("changeObserver")];
#endif

for(NSString* key in __notifiedProperties)
Expand All @@ -70,10 +64,10 @@ - (void)_commonInit

- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary<NSKeyValueChangeKey,id> *)change context:(void *)context
{
id old = change[NSKeyValueChangeOldKey];
id new = change[NSKeyValueChangeNewKey];
id oldValue = change[NSKeyValueChangeOldKey];
id newValue = change[NSKeyValueChangeNewKey];

if([old isEqual:new])
if([oldValue isEqual:newValue])
{
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// Copyright © 2015-2024 Léo Natan. All rights reserved.
//

@import UIKit;
#import <UIKit/UIKit.h>
#import "LNPopupBarAppearance+Private.h"

NS_ASSUME_NONNULL_BEGIN
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
//

#import "LNPopupCloseButton+Private.h"
@import ObjectiveC;
#import <objc/runtime.h>
#import "LNChevronView.h"
#import "_LNPopupSwizzlingUtils.h"
#import "_LNPopupBase64Utils.hh"
#import "LNPopupContentView+Private.h"

@interface LNPopupCloseButton ()
Expand All @@ -36,15 +36,12 @@ @implementation LNPopupCloseButton

#ifndef LNPopupControllerEnforceStrictClean

//_actingParentViewForGestureRecognizers
static NSString* const _aPVFGR = @"X2FjdGluZ1BhcmVudFZpZXdGb3JHZXN0dXJlUmVjb2duaXplcnM=";

+ (void)load
{
@autoreleasepool
{
Method m = class_getInstanceMethod(self, @selector(_aPVFGR));
class_addMethod(self, NSSelectorFromString(_LNPopupDecodeBase64String(_aPVFGR)), method_getImplementation(m), method_getTypeEncoding(m));
class_addMethod(self, NSSelectorFromString(LNPopupHiddenString("_actingParentViewForGestureRecognizers")), method_getImplementation(m), method_getTypeEncoding(m));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@
#import <LNPopupController/LNPopupCloseButton.h>
#import "LNPopupContentView+Private.h"

extern const NSUInteger _LNPopupPresentationStateTransitioning;
CF_EXTERN_C_BEGIN

#define _LNPopupPresentationStateTransitioning ((LNPopupPresentationState)2)

@interface LNPopupController : NSObject

Expand Down Expand Up @@ -60,3 +62,5 @@ extern const NSUInteger _LNPopupPresentationStateTransitioning;
+ (CGFloat)_statusBarHeightForView:(UIView*)view;

@end

CF_EXTERN_C_END
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,22 @@
#import "LNPopupLongPressGestureRecognizer.h"
#import "LNPopupInteractionPanGestureRecognizer.h"
#import "_LNPopupSwizzlingUtils.h"
#import "_LNPopupBase64Utils.hh"
#import "UIView+LNPopupSupportPrivate.h"
#import "LNPopupCustomBarViewController+Private.h"
@import ObjectiveC;
@import os.log;

#ifndef LNPopupControllerEnforceStrictClean
//visualProvider.toolbarIsSmall
static NSString* const _vPTIS = @"dmlzdWFsUHJvdmlkZXIudG9vbGJhcklzU21hbGw=";
#endif
#import <objc/runtime.h>
#import <os/log.h>

#if TARGET_OS_MACCATALYST
@import AppKit;
#endif

const NSUInteger _LNPopupPresentationStateTransitioning = 2;
CF_EXTERN_C_BEGIN

#ifndef LNPopupControllerEnforceStrictClean
//visualProvider.toolbarIsSmall
static NSString* const _vPTIS = @"dmlzdWFsUHJvdmlkZXIudG9vbGJhcklzU21hbGw=";
#endif

static const CGFloat LNPopupBarGestureHeightPercentThreshold = 0.2;
static const CGFloat LNPopupBarDeveloperPanGestureThreshold = 0;
Expand All @@ -51,7 +52,7 @@ static BOOL _LNCallDelegateObjectObjectBool(UIViewController* controller, UIView
{
if([controller.popupPresentationDelegate respondsToSelector:selector])
{
void (*msgSendObjectObjectBool)(id, SEL, id, id, BOOL) = (void*)objc_msgSend;
void (*msgSendObjectObjectBool)(id, SEL, id, id, BOOL) = reinterpret_cast<decltype(msgSendObjectObjectBool)>(objc_msgSend);
msgSendObjectObjectBool(controller.popupPresentationDelegate, selector, controller, content, animated);
return YES;
}
Expand All @@ -63,7 +64,7 @@ static BOOL _LNCallDelegateObjectBool(UIViewController* controller, SEL selector
{
if([controller.popupPresentationDelegate respondsToSelector:selector])
{
void (*msgSendObjectBool)(id, SEL, id, BOOL) = (void*)objc_msgSend;
void (*msgSendObjectBool)(id, SEL, id, BOOL) = reinterpret_cast<decltype(msgSendObjectBool)>(objc_msgSend);
msgSendObjectBool(controller.popupPresentationDelegate, selector, controller, animated);
return YES;
}
Expand Down Expand Up @@ -1058,8 +1059,7 @@ - (void)_configurePopupBarFromBottomBarModifyingGroupingIdentifier:(BOOL)modifyi
static NSString* vPTIS = nil;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
//visualProvider.toolbarIsSmall
vPTIS = _LNPopupDecodeBase64String(_vPTIS);
vPTIS = LNPopupHiddenString("visualProvider.toolbarIsSmall");
});

//visualProvider.toolbarIsSmall
Expand Down Expand Up @@ -1551,7 +1551,15 @@ - (void)_dismissPopupBarAnimated:(BOOL)animated completion:(void(^)(void))comple
// [self _clearRunningBarAnimators];
// [self _clearRunningPopupAnimators];

__weak decltype(self) weakSelf = self;

_runningBarAnimation = [[UIViewPropertyAnimator alloc] initWithDuration:0.5 dampingRatio:500 animations:^{
__strong decltype(weakSelf) self = weakSelf;
if(self == nil)
{
return;
}

_LNCallDelegateObjectBool(_containerController, @selector(popupPresentationControllerWillDismissPopupBar:animated:), animated);
[self.popupBar.customBarViewController _userFacing_viewWillDisappear:animated];

Expand All @@ -1578,7 +1586,13 @@ - (void)_dismissPopupBarAnimated:(BOOL)animated completion:(void(^)(void))comple
}];
}];

[_runningBarAnimation addCompletion:^(UIViewAnimatingPosition finalPosition) {
[_runningBarAnimation addCompletion:^(UIViewAnimatingPosition finalPosition) {
__strong decltype(weakSelf) self = weakSelf;
if(self == nil)
{
return;
}

if(finalPosition != UIViewAnimatingPositionEnd)
{
return;
Expand Down Expand Up @@ -1831,3 +1845,5 @@ - (void)_popupItem_update_standardAppearance
}

@end

CF_EXTERN_C_END
Original file line number Diff line number Diff line change
Expand Up @@ -10,35 +10,27 @@
#import "UIContextMenuInteraction+LNPopupSupportPrivate.h"
#import "LNPopupBar+Private.h"
#import "_LNPopupSwizzlingUtils.h"
#import "_LNPopupBase64Utils.hh"

#ifndef LNPopupControllerEnforceStrictClean
//_delegate_previewForHighlightingForConfiguration:
static NSString* const dPFHFCBase64 = @"X2RlbGVnYXRlX3ByZXZpZXdGb3JIaWdobGlnaHRpbmdGb3JDb25maWd1cmF0aW9uOg==";
//_delegate_contextMenuInteractionWillEndForConfiguration:presentation:
static NSString* const dCMIWEFCpBase64 = @"X2RlbGVnYXRlX2NvbnRleHRNZW51SW50ZXJhY3Rpb25XaWxsRW5kRm9yQ29uZmlndXJhdGlvbjpwcmVzZW50YXRpb246";
//_delegate_contextMenuInteractionWillDisplayForConfiguration:
static NSString* const dCMIWDFCBase64 = @"X2RlbGVnYXRlX2NvbnRleHRNZW51SW50ZXJhY3Rpb25XaWxsRGlzcGxheUZvckNvbmZpZ3VyYXRpb246";

@implementation UIContextMenuInteraction (LNPopupSupportPrivate)

+ (void)load
{
@autoreleasepool
{
//_delegate_previewForHighlightingForConfiguration:
NSString* selName = _LNPopupDecodeBase64String(dPFHFCBase64);
NSString* selName = LNPopupHiddenString("_delegate_previewForHighlightingForConfiguration:");
LNSwizzleMethod(self,
NSSelectorFromString(selName),
@selector(_ln_d_pFHFC:));

//_delegate_contextMenuInteractionWillEndForConfiguration:presentation:
selName = _LNPopupDecodeBase64String(dCMIWEFCpBase64);
selName = LNPopupHiddenString("_delegate_contextMenuInteractionWillEndForConfiguration:presentation:");
LNSwizzleMethod(self,
NSSelectorFromString(selName),
@selector(_ln_d_cMIWEFC:p:));

//_delegate_contextMenuInteractionWillDisplayForConfiguration:
selName = _LNPopupDecodeBase64String(dCMIWDFCBase64);
selName = LNPopupHiddenString("_delegate_contextMenuInteractionWillDisplayForConfiguration:");
LNSwizzleMethod(self,
NSSelectorFromString(selName),
@selector(_ln_d_cMIWDFC:));
Expand Down
Loading

0 comments on commit fb65937

Please sign in to comment.