我正在某些应用程序中注入一个dylib以获得某些期望的行为.
我能够正确地连接平面C API.一旦我注入了dylib,我会在符号表中查看并使用我的函数地址更新其条目,然后调用原始函数.
因此,符号名称对我来说很重要.
我的问题是C++名称修改.我们如何挂钩名称已被破坏的C++函数.我读了堆栈溢出的一些地方,可以用mach_override挂钩c ++代码,但没有示例或引用.
有些人可以举例说明如何实现C++的挂钩吗?
编辑:
我用$ c++filt -n _ZN10WindowData12GetCGContextEv作为例子并得到了输出WindowData::GetCGContext()
像这样......
typedef void* (*WindowData_GetCGContextProcPtr)(void* inObj);
static WindowData_GetCGContextProcPtr gWindowDataGetCGContextProcPtr = NULL;
void* try_WindowDataGetCGContextProcPtr(void* inObj)
{
printf("try_WindowDataGetCGContextProcPtr \n");
return gWindowDataGetCGContextProcPtr(inObj);
}
Run Code Online (Sandbox Code Playgroud)
现在,我想要修补此方法.
gWindowDataGetCGContextProcPtr = (WindowData_GetCGContextProcPtr)Patch((const void*)&WindowData::GetCGContext, (const void*)&try_WindowDataGetCGContextProcPtr);
Run Code Online (Sandbox Code Playgroud)
此修补程序提供编译错误.
error: 'WindowData' has not been declared
error: 'GetCGContext' was not declared in this scope
Run Code Online (Sandbox Code Playgroud)
我是怎么解决的?
我想在堆栈上按64位地址,如下所示,
__asm("pushq $0x1122334455667788");
Run Code Online (Sandbox Code Playgroud)
但我得到编译错误,我只能按照以下方式推送,
__asm("pushq $0x11223344");
Run Code Online (Sandbox Code Playgroud)
有人能帮助我理解我的错误吗?
我是集会的新手,所以如果我的问题听起来很愚蠢,请原谅.
我正在尝试识别Quartz框架的私有api.我有一堆私有私有API的列表,但没有他们的签名.
我想将其中一个放在桌面上进行讨论,以便我们可以了解如何进行逆向工程以找到正确的签名.
void CGContextDrawImages(????);
我从下面的装配中得到了它
_CGContextDrawImages:
+0 0008986a 55 pushl %ebp
+1 0008986b 89e5 movl %esp,%ebp
+3 0008986d 57 pushl %edi
+4 0008986e 56 pushl %esi
+5 0008986f 53 pushl %ebx
+6 00089870 81ecbc010000 subl $0x000001bc,%esp
+12 00089876 e800000000 calll 0x0008987b
+17 0008987b 5b popl %ebx
+18 0008987c 8b4508 movl 0x08(%ebp),%eax
+21 0008987f 85c0 testl %eax,%eax
+23 00089881 740c je 0x0008988f
+25 00089883 8b4508 movl 0x08(%ebp),%eax
+28 00089886 81780854585443 cmpl $0x43545854,0x08(%eax)
+35 0008988d 7424 je 0x000898b3
+37 0008988f 8b5508 movl …Run Code Online (Sandbox Code Playgroud) 我们是否有可能看到xib/nib文件后面生成的源代码(我知道它们是xml文件)?我听说过NIBTOOL,但我相信它不再可用,或者被其他一些我找不到的工具所取代.有谁知道吗?
非常感谢您的回复.
我已经开发了注射系统并且已经连接了一些石英API,以便在Mac OS X上为窗口创建一些很好的效果.例如,当用户在窗口中将颜色设置为红色时,它是红色光泽的红色.
但是,当我注入已经运行的应用程序时,由于窗口已经被绘制,我无法给出所需的效果.所以,我正在寻找石英/核心图形中的东西,这可以让我重绘整个窗口或一些技术,这可以让我发送一些事件/调用一些功能,这将使系统重新整个窗口.
我的意思是窗口上的每个东西都要再次绘制,这样我的钩子API就会执行,以便创建正确的效果,阴影和颜色.这里创建和绘制窗口的顺序非常重要.
我使用的技术类似于注入和设置,注入代码是C/C++代码.
有谁知道如何实现这一目标?
我正在尝试阅读有关Dock的信息并检索应用程序及其在Dock上的位置.
任何人都可以给我一个如何做到这一点的指针?
编辑:从〜/ Library/Preferences/com.apple.dock.plist,我可以获得与静态(固定)应用程序和文件夹相关的所有信息,但不能获取有关已启动和最小化应用程序切片的信息.
对于已启动的应用,我们可以使用NSWorkspace.
最大的问题仍然是应用瓷砖最小化?
我试图找到一个Carbon API,它可以从窗口id给我WindowRef,并且我想要有windowref的界面?
编辑:我发现API extern WindowRef HIWindowFromCGWindowID(CGWindowID inWindowID); 但我无法使用它.我已经包含了碳标头,并且还将其框架添加到项目中.HI apis还需要其他东西吗?
任何帮助表示赞赏.感谢您的时间.
我在Boost Library中遇到了一段代码,用于offset_ptr.在boost/interprocess/offset_ptr.hpp下
typedef PointedType * pointer;
...
//!Constructor from other pointer.
//!Never throws.
template <class T>
offset_ptr(T *ptr)
{ pointer p (ptr); (void)p; this->set_offset(p); }
Run Code Online (Sandbox Code Playgroud)
我想知道什么是声明(void)p; 呢?
我有一个dylib,我可以通过注入mac os x加载.构造函数调用运行良好.
__attribute__((constructor))
static void initialize()
Run Code Online (Sandbox Code Playgroud)
但析构函数不会被调用?因此资源初始化泄漏.
__attribute__((destructor))
static void destroy()
Run Code Online (Sandbox Code Playgroud)
我对STL不是很了解,我看到很少的帖子与我的要求类似并且感到困惑.所以,我需要一些关于以下代码的建议.
SomeStruct someStruct(identifier);
std::vector<SomeStruct*>::iterator it = std::find_if(vWrapper.begin(), vWrapper.end(), SomeStruct::Find_SomeStruct(&someStruct));
if(it != vWrapper.end())
{
...
delete *it;
it = vWrapper.erase(it);
}
Run Code Online (Sandbox Code Playgroud)
我试图基于标识符查看向量,然后删除指向存储在向量中的对象的指针.
我看到了帖子.它使用for循环并重新分配迭代器.此外,没有帖子使用find_if()然后删除和擦除.
我是以正确的方式做到的吗?
macos ×8
c++ ×4
cocoa ×3
objective-c ×2
assembly ×1
boost ×1
c ×1
cocoa-touch ×1
disassembly ×1
dock ×1
dylib ×1
gcc ×1
hook ×1
iphone ×1
macos-carbon ×1
stl ×1
templates ×1
x86-64 ×1
xib ×1