Skip to content

Instantly share code, notes, and snippets.

View ytlvy's full-sized avatar

Yt ytlvy

View GitHub Profile
@ytlvy
ytlvy / Invoker.h
Created November 11, 2015 06:17 — forked from 123nobody/Invoker.h
#import <Foundation/Foundation.h>
@interface Invoker : NSObject
+ ( NSValue * ) invoke:( SEL ) selector onTarget:( id ) target, ...;
@end
- (void)keyboardWillShow:(NSNotification *)notification
{
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:[notification.userInfo[UIKeyboardAnimationDurationUserInfoKey] doubleValue]];
[UIView setAnimationCurve:[notification.userInfo[UIKeyboardAnimationCurveUserInfoKey] integerValue]];
[UIView setAnimationBeginsFromCurrentState:YES];
// do something
[UIView commitAnimations];
@ytlvy
ytlvy / UISegmentedControl+Flat.h
Created November 11, 2015 06:16 — forked from 123nobody/UISegmentedControl+Flat.h
Set UISegmentedControl to iOS 7 style.
//
// UISegmentedControl+Flat.h
//
// Created by 魏哲 on 14-2-28.
//
#import <UIKit/UIKit.h>
@interface UISegmentedControl (Flat)
@ytlvy
ytlvy / UIButton+Extensions.h
Created November 11, 2015 06:16 — forked from 123nobody/UIButton+Extensions.h
Making UIButton's hit area larger than the default hit area
@interface UIButton (Extensions)
@property(nonatomic, assign) UIEdgeInsets hitTestEdgeInsets;
@end
@ytlvy
ytlvy / DYLD_INTERPOSE
Created October 7, 2015 13:06
利用 DYLD_INTERPOSE 宏 完成OS X系统函数hook
// 演示代码
// #import <mach-o/dyld-interposing.h>
// from dyld-interposing.h
#define DYLD_INTERPOSE(_replacement,_replacee) __attribute__((used)) static struct{ const void* replacement; const void* replacee; } _interpose_##_replacee __attribute__ ((section ("__DATA,__interpose"))) = { (const void*)(unsigned long)&_replacement, (const void*)(unsigned long)&_replacee };
ssize_t hacked_write(int fildes, const void *buf, size_t nbyte)
{
printf("[++++]into hacked_write---by piaoyun");
return write(fildes, buf, nbyte);
}
@ytlvy
ytlvy / getRsp
Created October 7, 2015 13:01
OSX裸函数应用实战
//
// main.m
// debug
//
// Created by piao on 15/7/20.
// Copyright (c) 2015年 piao. All rights reserved.
//
#import <Foundation/Foundation.h>
@ytlvy
ytlvy / getLR
Created October 7, 2015 12:57
iOS裸函数应用实战
//
// main.c
// iOS_ARM
//
// Created by piao on 15/7/21.
// Copyright (c) 2015年 __MyCompanyName__. All rights reserved.
//
#if defined (__arm64__) /*|| defined (__aarch64__)*/
@ytlvy
ytlvy / checkArch.m
Created October 7, 2015 12:48
__arm64__ 、__arm__宏判断平台架构
// 参考官方判断方法:http://www.opensource.apple.com/source/cctools/cctools-870/include/mach/arm/thread_status.h
void checkArch(){
#if defined (__arm64__)/* || defined (__aarch64__) */
printf("[PiaoYun]running 64-bit [__arm64__ arch]\n");
#elif defined(__arm64__)
printf("[PiaoYun]runing 32-bit [__arm__ arch]\n");
#else
#error [PiaoYun]Unknown arch
#endif
}
@ytlvy
ytlvy / parameter_dig.m
Created October 7, 2015 11:24
armv7、arm64传参研究
////////////////////////////////////////////////////////////////////////
/// armv7传参研究
////////////////////////////////////////////////////////////////////////
//---------------------------------------------------------------------
int func(int a, int b, int c, int d, int e, int f)
{
int ret = a + b + c + d + e + f;
return ret;
}
_func:
@ytlvy
ytlvy / xnu 内存读写模块
Last active October 8, 2015 13:53
xnu 内存读写模块
#include <mach/host_info.h>
#include <mach/mach_host.h>
#include <mach/shared_region.h>
#include <mach/mach.h>
#include <mach-o/dyld.h>
#include <stdlib.h>
#include <stdio.h>
#import <dlfcn.h>