1818 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
1919 */
2020
21+ #include <stdarg.h>
22+ #include <stdio.h>
23+
24+ #include "windef.h"
25+ #include "winbase.h"
26+ #include "winuser.h"
27+ #include "winver.h"
28+ #include "dbghelp.h"
29+ #include "ole2.h"
30+ #include "mscoree.h"
31+ #include "corhdr.h"
32+ #include "metahost.h"
33+ #include "cordebug.h"
34+ #include "wine/list.h"
2135#include "mscoree_private.h"
2236
23- #include <winver.h>
24- #include <dbghelp.h>
37+ #include "wine/debug.h"
2538
2639typedef struct
2740{
@@ -49,7 +62,7 @@ typedef struct tagCLRTABLE
4962
5063struct tagASSEMBLY
5164{
52- int is_mapped_file ;
65+ BOOL is_mapped_file ;
5366
5467 /* mapped files */
5568 LPWSTR path ;
@@ -64,20 +77,6 @@ struct tagASSEMBLY
6477 METADATAHDR * metadatahdr ;
6578};
6679
67- static inline LPWSTR strdupW (LPCWSTR src )
68- {
69- LPWSTR dest ;
70-
71- if (!src )
72- return NULL ;
73-
74- dest = HeapAlloc (GetProcessHeap (), 0 , (lstrlenW (src ) + 1 ) * sizeof (WCHAR ));
75- if (dest )
76- lstrcpyW (dest , src );
77-
78- return dest ;
79- }
80-
8180static void * assembly_rva_to_va (ASSEMBLY * assembly , ULONG rva )
8281{
8382 if (assembly -> is_mapped_file )
@@ -115,7 +114,7 @@ static HRESULT parse_metadata_header(ASSEMBLY *assembly, DWORD *hdrsz)
115114
116115 metadatahdr = (METADATAHDR * )ptr ;
117116
118- assembly -> metadatahdr = HeapAlloc ( GetProcessHeap (), 0 , sizeof (METADATAHDR ));
117+ assembly -> metadatahdr = malloc ( sizeof (METADATAHDR ));
119118 if (!assembly -> metadatahdr )
120119 return E_OUTOFMEMORY ;
121120
@@ -195,13 +194,13 @@ HRESULT assembly_create(ASSEMBLY **out, LPCWSTR file)
195194
196195 * out = NULL ;
197196
198- assembly = HeapAlloc ( GetProcessHeap (), HEAP_ZERO_MEMORY , sizeof (ASSEMBLY ));
197+ assembly = calloc ( 1 , sizeof (ASSEMBLY ));
199198 if (!assembly )
200199 return E_OUTOFMEMORY ;
201200
202- assembly -> is_mapped_file = 1 ;
201+ assembly -> is_mapped_file = TRUE ;
203202
204- assembly -> path = strdupW (file );
203+ assembly -> path = wcsdup (file );
205204 if (!assembly -> path )
206205 {
207206 hr = E_OUTOFMEMORY ;
@@ -249,11 +248,11 @@ HRESULT assembly_from_hmodule(ASSEMBLY **out, HMODULE hmodule)
249248
250249 * out = NULL ;
251250
252- assembly = HeapAlloc ( GetProcessHeap (), HEAP_ZERO_MEMORY , sizeof (ASSEMBLY ));
251+ assembly = calloc ( 1 , sizeof (ASSEMBLY ));
253252 if (!assembly )
254253 return E_OUTOFMEMORY ;
255254
256- assembly -> is_mapped_file = 0 ;
255+ assembly -> is_mapped_file = FALSE ;
257256
258257 assembly -> data = (BYTE * )hmodule ;
259258
@@ -277,9 +276,9 @@ HRESULT assembly_release(ASSEMBLY *assembly)
277276 CloseHandle (assembly -> hmap );
278277 CloseHandle (assembly -> hfile );
279278 }
280- HeapFree ( GetProcessHeap (), 0 , assembly -> metadatahdr );
281- HeapFree ( GetProcessHeap (), 0 , assembly -> path );
282- HeapFree ( GetProcessHeap (), 0 , assembly );
279+ free ( assembly -> metadatahdr );
280+ free ( assembly -> path );
281+ free ( assembly );
283282
284283 return S_OK ;
285284}
@@ -300,3 +299,17 @@ HRESULT assembly_get_vtable_fixups(ASSEMBLY *assembly, VTableFixup **fixups, DWO
300299
301300 return S_OK ;
302301}
302+
303+ HRESULT assembly_get_native_entrypoint (ASSEMBLY * assembly , NativeEntryPointFunc * func )
304+ {
305+ if (assembly -> corhdr -> Flags & COMIMAGE_FLAGS_NATIVE_ENTRYPOINT )
306+ {
307+ * func = assembly_rva_to_va (assembly , assembly -> corhdr -> EntryPointRVA );
308+ return S_OK ;
309+ }
310+ else
311+ {
312+ * func = NULL ;
313+ return S_FALSE ;
314+ }
315+ }
0 commit comments