Disassembling CGWindowContextCreate()?
From past few days I am trying to find out the location of CGContextRef on screen and window at Graphics Layer of OS X architecture (mostly in quartz). I think in order to create a window one must pass the location and size of that window where it should appear on display and while creation of window in-turn should call CGWindowContextCreate and thus here we can find who keeps track of cgcontext location and how it does that?
But I have very limited knowledge of disassembling. So I need some help in understanding the following assembly and in identifying its signature.
_CGWindowContextCreate:
+0 00022b33 55 pushl %ebp
+1 00022b34 89e5 movl %esp,%ebp
+3 00022b36 57 pushl %edi
+4 00022b37 56 pushl %esi
+5 00022b38 53 pushl %ebx
+6 00022b39 83ec1c subl $0x1c,%esp
+9 00022b3c e800000000 calll 0x00022b41
+14 00022b41 5b popl %ebx
+15 00022b42 8b8babcf7e00 movl 0x007ecfab(%ebx),%ecx
+21 00022b48 85c9 testl %ecx,%ecx
+23 00022b4a 7518 jne 0x00022b64
+25 00022b4c 8d832c010000 leal 0x0000012c(%ebx),%eax
+31 00022b52 89442404 movl %eax,0x04(%esp)
+35 00022b56 8d83ebc47e00 leal 0x007ec4eb(%ebx),%eax
+41 00022b5c 890424 movl %eax,(%esp)
+44 00022b5f e812017600 calll 0x00782c76 _pthread_once
+49 00022b64 e850010000 calll _CGContextCreate
+54 00022b69 89c7 movl %eax,%edi
+56 00022b6b 85c0 testl %eax,%eax
+58 00022b6d 751d jne 0x00022b8c
+60 00022b6f 8d833d977800 leal 0x0078973d(%ebx),%eax
+66 00022b75 89442404 movl %eax,0x04(%esp)
+70 00022b79 8d83fb957800 leal 0x007895fb(%ebx),%eax
+76 00022b7f 890424 movl %eax,(%esp)
+79 00022b82 e8a8dc1500 calll _CGPostError
+84 00022b87 e9d7000000 jmp 0x00022c63
+89 00022b8c c74424040c000000 movl $0x0000000c,0x04(%esp)
+97 00022b94 c7042401000000 movl $0x00000001,(%esp)
+104 00022b9b e840fd7500 calll 0x007828e0 _calloc
+109 00022ba0 89c2 movl %eax,%edx
+111 00022ba2 85c0 testl %eax,%eax
+113 00022ba4 750a jne 0x00022bb0
+115 00022ba6 893c24 movl %edi,(%esp)
+118 00022ba9 e8e7150400 calll _CGContextRelease
+123 00022bae eb5b jmp 0x00022c0b
+125 00022bb0 8b4508 开发者_JAVA技巧 movl 0x08(%ebp),%eax
+128 00022bb3 8902 movl %eax,(%edx)
+130 00022bb5 8b450c movl 0x0c(%ebp),%eax
+133 00022bb8 894204 movl %eax,0x04(%edx)
+136 00022bbb c7420800000000 movl $0x00000000,0x08(%edx)
+143 00022bc2 895714 movl %edx,0x14(%edi)
+146 00022bc5 8d8391350700 leal 0x00073591(%ebx),%eax
+152 00022bcb 89471c movl %eax,0x1c(%edi)
+155 00022bce c7471003000000 movl $0x00000003,0x10(%edi)
+162 00022bd5 8b4510 movl 0x10(%ebp),%eax
+165 00022bd8 89442404 movl %eax,0x04(%esp)
+169 00022bdc 891424 movl %edx,(%esp)
+172 00022bdf ff93abcf7e00 call *0x007ecfab(%ebx)
+178 00022be5 89c6 movl %eax,%esi
+180 00022be7 85c0 testl %eax,%eax
+182 00022be9 7524 jne 0x00022c0f
+184 00022beb 893c24 movl %edi,(%esp)
+187 00022bee e8a2150400 calll _CGContextRelease
+192 00022bf3 8d833d977800 leal 0x0078973d(%ebx),%eax
+198 00022bf9 89442404 movl %eax,0x04(%esp)
+202 00022bfd 8d8323967800 leal 0x00789623(%ebx),%eax
+208 00022c03 890424 movl %eax,(%esp)
+211 00022c06 e824dc1500 calll _CGPostError
+216 00022c0b 31ff xorl %edi,%edi
+218 00022c0d eb54 jmp 0x00022c63
+220 00022c0f 89442404 movl %eax,0x04(%esp)
+224 00022c13 893c24 movl %edi,(%esp)
+227 00022c16 e839180000 calll _CGContextSetDelegate
+232 00022c1b 893424 movl %esi,(%esp)
+235 00022c1e e8bd180000 calll _CGContextDelegateRelease
+240 00022c23 8b5510 movl 0x10(%ebp),%edx
+243 00022c26 85d2 testl %edx,%edx
+245 00022c28 7431 je 0x00022c5b
+247 00022c2a 8b8307d57c00 movl 0x007cd507(%ebx),%eax
+253 00022c30 8b00 movl (%eax),%eax
+255 00022c32 89442404 movl %eax,0x04(%esp)
+259 00022c36 8b4510 movl 0x10(%ebp),%eax
+262 00022c39 890424 movl %eax,(%esp)
+265 00022c3c e87ff57500 calll 0x007821c0 _CFDictionaryGetValue
+270 00022c41 85c0 testl %eax,%eax
+272 00022c43 7416 je 0x00022c5b
+274 00022c45 c744240800000000 movl $0x00000000,0x08(%esp)
+282 00022c4d 89442404 movl %eax,0x04(%esp)
+286 00022c51 893c24 movl %edi,(%esp)
+289 00022c54 e8d9dd1500 calll _CGContextAddFilter
+294 00022c59 89c7 movl %eax,%edi
+296 00022c5b 893c24 movl %edi,(%esp)
+299 00022c5e e88f180000 calll _CGContextRegistryAddContext
+304 00022c63 89f8 movl %edi,%eax
+306 00022c65 83c41c addl $0x1c,%esp
+309 00022c68 5b popl %ebx
+310 00022c69 5e popl %esi
+311 00022c6a 5f popl %edi
+312 00022c6b c9 leave
+313 00022c6c c3 ret
Thank you for your time and help.
CGContextRef CGWindowContextCreate(int, int, void*);
精彩评论