Add ic + icc* tests for objc ##tests

This commit is contained in:
pancake 2020-03-30 01:54:21 +02:00 committed by radare
parent 090450401f
commit 513de59576
6 changed files with 168 additions and 1 deletions

View File

@ -987,6 +987,7 @@ fs classes
"f method._JNIEnv.CallStaticObjectMethod(_jclass*,__jmethodID*,_...) = 0x60ea"
"f method._JNIEnv.CallStaticIntMethod(_jclass*,__jmethodID*,_...) = 0x695e"
"f method._JNIEnv.CallStaticVoidMethod(_jclass*,__jmethodID*,_...) = 0x697c"
"td struct _JNIEnv { char empty[0];};"
"f class.SystemClassLoaderInjector = 0x699c"
"f method.SystemClassLoaderInjector.inject(_JNIEnv*,__jobject*,__jstring*,__jstring*) = 0x74f8"
"f method.SystemClassLoaderInjector.findBaseDexClassloader(_JNIEnv*,__jobject*) = 0x699c"
@ -999,29 +1000,38 @@ fs classes
"f method.SystemClassLoaderInjector.appendArray(_JNIEnv*,__jobject*,__jobject*) = 0x6e5c"
"f method.SystemClassLoaderInjector.injectInAliyunOs(_JNIEnv*,__jobject*,__jstring*,__jstring*) = 0x6f68"
"f method.SystemClassLoaderInjector.injectBelowApiLevel14(_JNIEnv*,__jobject*,__jstring*,__jstring*) = 0x720c"
"td struct SystemClassLoaderInjector { char empty[0];};"
"f class.std = 0x886c"
"f method.std.terminate() = 0x9470"
"f method.std.uncaught_exception() = 0x886c"
"f method.std.unexpected() = 0x9494"
"f method.std.set_terminate(void_(*)()) = 0x94ac"
"f method.std.set_unexpected(void_(*)()) = 0x94c8"
"td struct std { char empty[0];};"
"f class.std::exception = 0x8884"
"f method.std::exception.~exception() = 0x8884"
"f method.std::exception.what()_const = 0x88f4"
"td struct std::exception { char empty[0];};"
"f class.std::bad_exception = 0x889c"
"f method.std::bad_exception.~bad_exception() = 0x889c"
"f method.std::bad_exception.what()_const = 0x8904"
"td struct std::bad_exception { char empty[0];};"
"f class.cxxabiv1::__forced_unwind = 0x88c4"
"f method.__cxxabiv1::__forced_unwind.~__forced_unwind() = 0x88c4"
"td struct __cxxabiv1::__forced_unwind { char empty[0];};"
"f class.cxxabiv1::__foreign_exception = 0x88dc"
"f method.__cxxabiv1::__foreign_exception.~__foreign_exception() = 0x88dc"
"td struct __cxxabiv1::__foreign_exception { char empty[0];};"
"f class.eh_globals_init = 0x8984"
"f method.__eh_globals_init.~__eh_globals_init() = 0x8984"
"td struct __eh_globals_init { char empty[0];};"
"f class.cxxabiv1 = 0x943c"
"f method.__cxxabiv1.__terminate(void_(*)()) = 0x943c"
"f method.__cxxabiv1.__unexpected(void_(*)()) = 0x9488"
"td struct __cxxabiv1 { char empty[0];};"
"f class.cxxabiv1::__fundamental_type_info = 0x94e4"
"f method.__cxxabiv1::__fundamental_type_info.~__fundamental_type_info() = 0x94e4"
"td struct __cxxabiv1::__fundamental_type_info { char empty[0];};"
"f class.std::type_info = 0x97bc"
"f method.std::type_info.~type_info() = 0x97bc"
"f method.std::type_info.__is_pointer_p()_const = 0x97d4"
@ -1029,19 +1039,23 @@ fs classes
"f method.std::type_info.__do_catch(std::type_info_const*,_void**,_unsigned_int)_const = 0x9854"
"f method.std::type_info.__do_upcast(__cxxabiv1::__class_type_info_const*,_void**)_const = 0x97e4"
"f method.std::type_info.operator==(std::type_info_const&)_const = 0x9808"
"td struct std::type_info { char empty[0];};"
"f class.cxxabiv1::__pointer_type_info = 0x9528"
"f method.__cxxabiv1::__pointer_type_info.__is_pointer_p()_const = 0x9528"
"f method.__cxxabiv1::__pointer_type_info.~__pointer_type_info() = 0x9530"
"f method.__cxxabiv1::__pointer_type_info.__pointer_catch(__cxxabiv1::__pbase_type_info_const*,_void**,_unsigned_int)_const = 0x9574"
"td struct __cxxabiv1::__pointer_type_info { char empty[0];};"
"f class.cxxabiv1::__pbase_type_info = 0x9dd0"
"f method.__cxxabiv1::__pbase_type_info.~__pbase_type_info() = 0x9df0"
"f method.__cxxabiv1::__pbase_type_info.__do_catch(std::type_info_const*,_void**,_unsigned_int)_const = 0x9e34"
"f method.__cxxabiv1::__pbase_type_info.__pointer_catch(__cxxabiv1::__pbase_type_info_const*,_void**,_unsigned_int)_const = 0x9dd0"
"td struct __cxxabiv1::__pbase_type_info { char empty[0];};"
"f class.cxxabiv1::__si_class_type_info = 0x95f4"
"f method.__cxxabiv1::__si_class_type_info.~__si_class_type_info() = 0x95f4"
"f method.__cxxabiv1::__si_class_type_info.__do_find_public_src(int,_void_const*,___cxxabiv1::__class_type_info_const*,_void_const*)_const = 0x9638"
"f method.__cxxabiv1::__si_class_type_info.__do_dyncast(int,___cxxabiv1::__class_type_info::__sub_kind,___cxxabiv1::__class_type_info_const*,_void_const*,___cxxabiv1::__class_type_info_const*,_void_const*,___cxxabiv1::__class_type_info::__dyncast_result&)_const = 0x969c"
"f method.__cxxabiv1::__si_class_type_info.__do_upcast(__cxxabiv1::__class_type_info_const*,_void_const*,___cxxabiv1::__class_type_info::__upcast_result&)_const = 0x977c"
"td struct __cxxabiv1::__si_class_type_info { char empty[0];};"
"f class.cxxabiv1::__class_type_info = 0x9868"
"f method.__cxxabiv1::__class_type_info.~__class_type_info() = 0x98d8"
"f method.__cxxabiv1::__class_type_info.__do_upcast(__cxxabiv1::__class_type_info_const*,_void_const*,___cxxabiv1::__class_type_info::__upcast_result&)_const = 0x991c"
@ -1049,22 +1063,28 @@ fs classes
"f method.__cxxabiv1::__class_type_info.__do_upcast(__cxxabiv1::__class_type_info_const*,_void**)_const = 0x9868"
"f method.__cxxabiv1::__class_type_info.__do_find_public_src(int,_void_const*,___cxxabiv1::__class_type_info_const*,_void_const*)_const = 0x98c4"
"f method.__cxxabiv1::__class_type_info.__do_dyncast(int,___cxxabiv1::__class_type_info::__sub_kind,___cxxabiv1::__class_type_info_const*,_void_const*,___cxxabiv1::__class_type_info_const*,_void_const*,___cxxabiv1::__class_type_info::__dyncast_result&)_const = 0x998c"
"td struct __cxxabiv1::__class_type_info { char empty[0];};"
"f class.gnu_cxx = 0x9ec4"
"f method.__gnu_cxx.__verbose_terminate_handler() = 0x9ec4"
"f method.__gnu_cxx.__throw_concurrence_lock_error() = 0x12780"
"f method.__gnu_cxx.__throw_concurrence_unlock_error() = 0x127c8"
"td struct __gnu_cxx { char empty[0];};"
"f class.gnu_cxx::__concurrence_lock_error = 0x126b0"
"f method.__gnu_cxx::__concurrence_lock_error.what()_const = 0x126b0"
"f method.__gnu_cxx::__concurrence_lock_error.~__concurrence_lock_error() = 0x126f8"
"td struct __gnu_cxx::__concurrence_lock_error { char empty[0];};"
"f class.gnu_cxx::__concurrence_unlock_error = 0x126c0"
"f method.__gnu_cxx::__concurrence_unlock_error.what()_const = 0x126c0"
"f method.__gnu_cxx::__concurrence_unlock_error.~__concurrence_unlock_error() = 0x126d0"
"td struct __gnu_cxx::__concurrence_unlock_error { char empty[0];};"
"f class.std::bad_cast = 0x12bc8"
"f method.std::bad_cast.~bad_cast() = 0x12bd8"
"f method.std::bad_cast.what()_const = 0x12bc8"
"td struct std::bad_cast { char empty[0];};"
"f class.std::bad_typeid = 0x12c1c"
"f method.std::bad_typeid.~bad_typeid() = 0x12c2c"
"f method.std::bad_typeid.what()_const = 0x12c1c"
"td struct std::bad_typeid { char empty[0];};"
EOF
CMDS=ic*
RUN

80
test/new/db/cmd/cmd_tc Normal file
View File

@ -0,0 +1,80 @@
NAME=tc
FILE=../bins/mach0/objc-employee
CMDS=.ic*;ts
EXPECT=<<EOF
Employee
NSString
EOF
RUN
NAME=tc2
FILE=../bins/mach0/objc-employee
CMDS=icc*
EXPECT=<<EOF
typedef struct class_Employee {
uint64_t _padding; // 0
struct NSString* _username; // 8
struct NSString* _firstName; // 16
uint64_t _wideWord; // 24
short _shortWord; // 32
} Employee;
EOF
RUN
NAME=tc3
FILE=../bins/mach0/objc-employee
CMDS=ic*
EXPECT=<<EOF
fs classes
"f class.Employee = 0x100001ae0"
"f super.Employee.NSObject = 0"
"f method.Employee.helloWorld = 0x100001ae0"
"f method.Employee.sayHello = 0x100001b10"
"f method.Employee.p0 = 0x100001b40"
"f method.Employee.p1 = 0x100001b60"
"f method.Employee.p2 = 0x100001b80"
"f method.Employee.p3 = 0x100001ba0"
"f method.Employee.base = 0x100001bc0"
"f method.Employee.username = 0x100001c10"
"f method.Employee.setUsername: = 0x100001c40"
"f method.Employee.firstName = 0x100001c80"
"f method.Employee.setFirstName: = 0x100001cb0"
"f method.Employee.shortWord = 0x100001cf0"
"f method.Employee.wideWord = 0x100001d10"
"f method.class.Employee.sayHello = 0x100001be0"
"f field.Employee._padding = 0x100003328"
"f field.Employee.Employee::(ivar)_username = 0x00003330"
"f field.Employee.Employee::(ivar)_firstName = 0x00003338"
"f field.Employee.Employee::(ivar)_wideWord = 0x00003340"
"f field.Employee.Employee::(ivar)_shortWord = 0x00003328"
"f field.Employee.Employee::(property)username = 0x00000000"
"f field.Employee.Employee::(property)firstName = 0x00000000"
"f field.Employee.Employee::(property)shortWord = 0x00000000"
"f field.Employee.Employee::(property)wideWord = 0x00000000"
"td struct Employee { uint64_t _padding; struct NSString* _username; struct NSString* _firstName; uint64_t _wideWord; short _shortWord; void* username; void* firstName; void* shortWord; void* wideWord;};"
EOF
RUN
NAME=tc4
FILE=../bins/mach0/objc-employee
CMDS=.ic*;tc
EXPECT=<<EOF
struct Employee {
uint64_t _padding;
struct NSString *_username;
struct NSString *_firstName;
uint64_t _wideWord;
int16_t _shortWord;
void *username;
void *firstName;
void *shortWord;
void *wideWord;
};
struct NSString {
void *p0;
size_t p1;
char *str;
int len;
};
EOF
RUN

View File

@ -25,4 +25,3 @@ tfc rax ms (rcx, rdx, r8, r9, stack);
tfc rax swift (rdi, rsi, rdx, rcx, r8, r9, xmm0, xmm1, xmm2, xmm3, xmm4, r13, r12);
EOF
RUN

20
test/src/objc/employee.h Normal file
View File

@ -0,0 +1,20 @@
#import <Foundation/Foundation.h>
@interface Employee : NSObject
//property declaration
@property (retain) NSString* username;
@property (retain) NSString *firstName;
@property (readonly) short shortWord;
@property (readonly) uint64_t wideWord;
// @private NSString *lastName;
// @private (retain, nonatomic) NSString* name;
// methods
+ sayHello;
// + (void)loadTableData:(int);
//method declaration
- (void) helloWorld;
- (void*)p0;
- (void*)p1;
- (void*)p2;
- (void*)p3;
@end

18
test/src/objc/employee.m Normal file
View File

@ -0,0 +1,18 @@
#include "employee.h"
@implementation Employee
-(void)helloWorld{
NSLog(@"Hello World");
}
- sayHello {
NSLog(@"Hello Instance");
}
- (void*)p0 { return &_username; }
- (void*)p1 { return &_firstName; }
- (void*)p2 { return &_shortWord; }
- (void*)p3 { return &_wideWord; }
- (void*)base { return self; }
+ sayHello {
NSLog(@"Hello Class");
}
@end

30
test/src/objc/hello.m Normal file
View File

@ -0,0 +1,30 @@
#import <Foundation/Foundation.h>
#include "employee.h"
int main(int argc, const char * argv[]){
@autoreleasepool{
NSLog(@"Hello World Objective-C");
Employee *ins = [[Employee alloc] init];
[ins sayHello];
[Employee sayHello];
printf ("base %p\n", ins);
void *base = ins;
printf ("iii %p _username\n", [ins p0] - base);
printf ("iii %p _firstName\n", [ins p1] - base);
printf ("iii %p _shortWord\n", [ins p2] - base);
printf ("iii %p _wideWord\n", [ins p3] - base);
unsigned char *p = (void*)ins;
int i;
for (i = 0; i< 32; i++) {
printf ("%02x ", p[i]);
}
printf ("\n");
NSString *s = @"HELLO NSSTRING";
printf ("%p\n", s);
asm("int3");
}
return 0;
}