mscoree: Call native DllEntryPoint when it is defined in COR header.

Signed-off-by: Paul Gofman <gofmanp@gmail.com>
Signed-off-by: Vincent Povirk <vincent@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Paul Gofman 2016-01-30 04:36:49 +03:00 committed by Alexandre Julliard
parent 5dea748c5b
commit 98d5c4a90f
4 changed files with 39 additions and 8 deletions

View File

@ -314,3 +314,17 @@ HRESULT assembly_get_vtable_fixups(ASSEMBLY *assembly, VTableFixup **fixups, DWO
return S_OK;
}
HRESULT assembly_get_native_entrypoint(ASSEMBLY *assembly, NativeEntryPointFunc *func)
{
if (assembly->corhdr->Flags & COMIMAGE_FLAGS_NATIVE_ENTRYPOINT)
{
*func = assembly_rva_to_va(assembly, assembly->corhdr->EntryPointRVA);
return S_OK;
}
else
{
*func = NULL;
return S_FALSE;
}
}

View File

@ -1254,18 +1254,31 @@ __int32 WINAPI _CorExeMain(void)
BOOL WINAPI _CorDllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
{
ASSEMBLY *assembly=NULL;
HRESULT hr;
TRACE("(%p, %d, %p)\n", hinstDLL, fdwReason, lpvReserved);
switch (fdwReason)
hr = assembly_from_hmodule(&assembly, hinstDLL);
if (SUCCEEDED(hr))
{
case DLL_PROCESS_ATTACH:
NativeEntryPointFunc NativeEntryPoint=NULL;
assembly_get_native_entrypoint(assembly, &NativeEntryPoint);
if (fdwReason == DLL_PROCESS_ATTACH)
{
if (!NativeEntryPoint)
DisableThreadLibraryCalls(hinstDLL);
FixupVTable(hinstDLL);
break;
case DLL_PROCESS_DETACH:
/* FIXME: clean up the vtables */
break;
FixupVTable_Assembly(hinstDLL,assembly);
}
assembly_release(assembly);
/* FIXME: clean up the vtables on DLL_PROCESS_DETACH */
if (NativeEntryPoint)
return NativeEntryPoint(hinstDLL, fdwReason, lpvReserved);
}
else
ERR("failed to read CLR headers, hr=%x\n", hr);
return TRUE;
}

View File

@ -36,11 +36,14 @@ typedef struct _VTableFixup {
typedef struct tagASSEMBLY ASSEMBLY;
typedef BOOL (WINAPI *NativeEntryPointFunc)(HINSTANCE, DWORD, LPVOID);
extern HRESULT assembly_create(ASSEMBLY **out, LPCWSTR file) DECLSPEC_HIDDEN;
extern HRESULT assembly_from_hmodule(ASSEMBLY **out, HMODULE hmodule) DECLSPEC_HIDDEN;
extern HRESULT assembly_release(ASSEMBLY *assembly) DECLSPEC_HIDDEN;
extern HRESULT assembly_get_runtime_version(ASSEMBLY *assembly, LPSTR *version) DECLSPEC_HIDDEN;
extern HRESULT assembly_get_vtable_fixups(ASSEMBLY *assembly, VTableFixup **fixups, DWORD *count) DECLSPEC_HIDDEN;
extern HRESULT assembly_get_native_entrypoint(ASSEMBLY *assembly, NativeEntryPointFunc *func) DECLSPEC_HIDDEN;
/* Mono embedding */
typedef struct _MonoDomain MonoDomain;

View File

@ -3549,6 +3549,7 @@ typedef enum ReplacesCorHdrNumericDefines
COMIMAGE_FLAGS_32BITREQUIRED = 0x00000002,
COMIMAGE_FLAGS_IL_LIBRARY = 0x00000004,
COMIMAGE_FLAGS_STRONGNAMESIGNED = 0x00000008,
COMIMAGE_FLAGS_NATIVE_ENTRYPOINT= 0x00000010,
COMIMAGE_FLAGS_TRACKDEBUGDATA = 0x00010000,
COR_VERSION_MAJOR_V2 = 2,