Skip to content

Instantly share code, notes, and snippets.

View zhangkn's full-sized avatar
❣️
https://kunnan.blog.csdn.net/

公众号:iOS逆向 zhangkn

❣️
https://kunnan.blog.csdn.net/
View GitHub Profile
@interface People : NSObject
- (People *(^)())run;
- (People *(^)())study;
- (People *(^)(NSString* name))name;
@end
@implementation People
- (People *(^)())run{
return ^{
NSLog(@"run");
return self;
typedef struct __CFUserNotification *CFUserNotificationRef;
FOUNDATION_EXTERN CFUserNotificationRef CFUserNotificationCreate ( CFAllocatorRef allocator, CFTimeInterval timeout, CFOptionFlags flags, SInt32 *error, CFDictionaryRef dictionary );
FOUNDATION_EXTERN SInt32 CFUserNotificationReceiveResponse ( CFUserNotificationRef userNotification, CFTimeInterval timeout, CFOptionFlags *responseFlags );
FOUNDATION_EXTERN CFDictionaryRef CFUserNotificationGetResponseDictionary ( CFUserNotificationRef userNotification );
//官方使用例子
SInt32 CFUserNotificationDisplayNotice(CFTimeInterval timeout, CFOptionFlags flags, CFURLRef iconURL, CFURLRef soundURL, CFURLRef localizationURL, CFStringRef alertHeader, CFStringRef alertMessage, CFStringRef defaultButtonTitle) {
CHECK_FOR_FORK();
CFUserNotificationRef userNotification;
SInt32 retval = ERR_SUCCESS;
CFMutableDictionaryRef dict = CFDictionaryCreateMutable(kCFAllocatorSystemDefault, 0, &kCFCopyStringDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
CFUserNotificationRef CFUserNotificationCreate(CFAllocatorRef allocator, CFTimeInterval timeout, CFOptionFlags flags, SInt32 *error, CFDictionaryRef dictionary) {
CHECK_FOR_FORK();
CFUserNotificationRef userNotification = NULL;
SInt32 retval = ERR_SUCCESS;
static uint16_t tokenCounter = 0;
SInt32 token = ((getpid() << 16) | (tokenCounter++));
CFStringRef sessionID = (dictionary ? CFDictionaryGetValue(dictionary, kCFUserNotificationSessionIDKey) : NULL);
mach_port_t replyPort = MACH_PORT_NULL;
if (!allocator) allocator = __CFGetDefaultAllocator();
@zhangkn
zhangkn / confuse.sh
Last active January 5, 2019 06:30
简易的混淆脚本,主要思路是把敏感方法名集中写在一个名叫func.list的文件中,逐一#define成随机字符,追加写入.h。------痛点就是一个一个手写
#!/usr/bin/env bash
TABLENAME=symbols
SYMBOL_DB_FILE="symbols"
STRING_SYMBOL_FILE="func.list"
HEAD_FILE="$PROJECT_DIR/$PROJECT_NAME/codeObfuscation.h"
export LC_CTYPE=C
#维护数据库方便日后作排重
createTable()
// 优化之后的代码
NSString *AlertHeader = [self title];
NSLog(@"sb 弹框 title :%@ message:%@",AlertHeader,[self message]);
KNKNCFUserNotificationHandler handler = KNGHandlers[AlertHeader];//获取对应的block
if (handler) {// 存在之前定义block就执行
// @{key:value,key:value...}
NSDictionary* dict = @{KNKNCFUserNotificationHandlerUIAlertControllerObjectKey:self};
id res = handler(dict);// 获取block的返回结果, 把自己传递给外界
if (res){
NSLog(@"block res: %@",res);
- (NSString *)openUDID{
if (_openUDID == nil || [_openUDID isEqualToString:@""]) {
KNKeychainItemWrapper *wrapper = [[KNKeychainItemWrapper alloc] initWithIdentifier:@"kn.openUdid"accessGroup:nil];
// 读测试
NSString *openUDID = [wrapper objectForKey:(__bridge id)kSecValueData];
NSLog(@"读出_openUDID:%@",openUDID);
if (openUDID == nil || [openUDID isEqualToString:@""])
{
//方式一:有缓存(图片所占用的内存会一直停留在程序中)
+ (UIImage *)imageNamed:(NSString *)name;//name是图片的文件名
//方式二:无缓存(图片所占用的内存会在一些特定操作后被清除)
+ (UIImage *)imageWithContentsOfFile:(NSString *)path
- (id)initWithContentsOfFile:(NSString *)path;//path是图片的全路径
@property(nonatomic,copy) NSArray *animationImages; //需要播放的序列帧图片数组(里面都是UIImage对象,会按顺序显示里面的图片)
@property(nonatomic) NSTimeInterval animationDuration;//帧动画的持续时间
@property(nonatomic) NSInteger animationRepeatCount; //帧动画的执行次数(默认是无限循环)
- (void)startAnimating;//开始执行帧动画
- (void)stopAnimating;//停止执行帧动画
- (BOOL)isAnimating;//是否正在执行帧动画
@zhangkn
zhangkn / arrayWithContentsOfFile.m
Created June 4, 2018 02:41
接下来通过代码来解析Plist文件中的数据
- (NSArray *)images
{
if (_images == nil) {
NSBundle *bundle = [NSBundle mainBundle];
NSString *path = [bundle pathForResource:@"imageData" ofType:@"plist"];
_images = [NSArray arrayWithContentsOfFile:path];
}
return _images;
}
var image = wx.createImage()
// 设置 Image 对象的 src 属性可以加载一张本地图片或网络图片,当图片加载完毕时会执行注册的 onload 回调函数,此时可以将 Image 对象绘制到 Canvas 上。
image.onload = function () {
console.log(image.width, image.height)
context.drawImage(image, 0, 0)
}
image.src = 'logo.png'