相关疑难解决方法(0)

从getsectbyname崩溃读取字节

更新:回答下面的问题,感谢格雷格帕克的指针......

我在这里上传了一个示例项目,但我也会对其进行描述:https://github.com/tewha/getsectbyname-crash

我从我的(仅64位)可执行文件中崩溃,但从Xcode运行时却没有.但是,如果我从终端仪器运行它,它会崩溃.

不是 Debug vs. Release配置问题; 在终端中运行Debug可执行文件也崩溃了.从Xcode运行Release可执行文件.

我正在尝试从Mach-O可执行文件中读取一个链接到app的可执行部分CREATE_INFOPLIST_SECTION_IN_BINARY = YES.

const struct section_64 *plistSection = getsectbyname("__TEXT", "__info_plist");
NSLog(@"Found a section %s, %s", plistSection->segname, plistSection->sectname);
void *ptr = ((void *)plistSection->addr);
uint64_t size = plistSection->size;

NSLog(@"It has %zd bytes at %tx", size, plistSection->addr);
NSLog(@"Allocating %zd bytes", size);
void *buffer = malloc(size);
NSLog(@"Moving %zd bytes", size);
NSLog(@"(Crashes when doing the memmove.)");
memmove(buffer, ptr, size);
NSLog(@"Freeing %zd bytes", size);
free(buffer); …
Run Code Online (Sandbox Code Playgroud)

macos mach-o

11
推荐指数
1
解决办法
631
查看次数

从命令行工具中检索info.plist文件

使用以下步骤,我可以将info.plist嵌入到命令行工具中.

http://developer.apple.com/library/mac/#documentation/Security/Conceptual/CodeSigningGuide/Procedures/Procedures.html

我知道如何plist从.bundle中检索文件,但我不知道如何在单文件工具中执行相同操作.

我已经将info.plist嵌入到命令行工具中,以便我可以将版本存储在其中.有谁知道我如何在运行时检索它,以便我可以确定正在运行的版本?

谢谢

cocoa objective-c

8
推荐指数
1
解决办法
3285
查看次数

标签 统计

cocoa ×1

mach-o ×1

macos ×1

objective-c ×1