File tree Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Original file line number Diff line number Diff line change 12
12
#include <stdlib.h>
13
13
#include <string.h>
14
14
#include <stdint.h>
15
+ #if TARGET_OS_WIN32
16
+ #include <Windows.h>
17
+ #include <Psapi.h>
18
+ #else
15
19
#include <dlfcn.h>
20
+ #endif
16
21
#if __has_include (< os /assumes .h > )
17
22
#include <os/assumes.h>
18
23
#else
@@ -245,7 +250,26 @@ void _Block_use_RR( void (*retain)(const void *),
245
250
void (* release )(const void * )) {
246
251
_Block_retain_object = retain ;
247
252
_Block_release_object = release ;
253
+ #if TARGET_OS_WIN32
254
+ HANDLE hProcess = GetCurrentProcess ();
255
+ HMODULE hModule [1024 ];
256
+ DWORD cbNeeded = 0 ;
257
+
258
+ if (!EnumProcessModules (hProcess , hModule , sizeof (hModule ), & cbNeeded ))
259
+ return ;
260
+ if (cbNeeded > sizeof (hModule ))
261
+ return ;
262
+
263
+ for (unsigned I = 0 ; I < (cbNeeded / sizeof (HMODULE )); ++ I ) {
264
+ _Block_destructInstance =
265
+ (void (* )(const void * ))GetProcAddress (hModule [I ],
266
+ "objc_destructInstance" );
267
+ if (_Block_destructInstance )
268
+ break ;
269
+ }
270
+ #else
248
271
_Block_destructInstance = dlsym (RTLD_DEFAULT , "objc_destructInstance" );
272
+ #endif
249
273
}
250
274
251
275
// Called from CF to indicate MRR. Newer version uses a versioned structure, so we can add more functions
You can’t perform that action at this time.
0 commit comments