ntdll: Move fixup_imports to avoid forward declarations.
This commit is contained in:
parent
0f0bf58663
commit
f5fc925f0e
|
@ -705,57 +705,6 @@ static NTSTATUS create_module_activation_context( LDR_MODULE *module )
|
|||
}
|
||||
|
||||
|
||||
/****************************************************************
|
||||
* fixup_imports
|
||||
*
|
||||
* Fixup all imports of a given module.
|
||||
* The loader_section must be locked while calling this function.
|
||||
*/
|
||||
static NTSTATUS fixup_imports( WINE_MODREF *wm, LPCWSTR load_path )
|
||||
{
|
||||
int i, nb_imports;
|
||||
const IMAGE_IMPORT_DESCRIPTOR *imports;
|
||||
WINE_MODREF *prev;
|
||||
DWORD size;
|
||||
NTSTATUS status;
|
||||
ULONG_PTR cookie;
|
||||
|
||||
if (!(wm->ldr.Flags & LDR_DONT_RESOLVE_REFS)) return STATUS_SUCCESS; /* already done */
|
||||
wm->ldr.Flags &= ~LDR_DONT_RESOLVE_REFS;
|
||||
|
||||
if (!(imports = RtlImageDirectoryEntryToData( wm->ldr.BaseAddress, TRUE,
|
||||
IMAGE_DIRECTORY_ENTRY_IMPORT, &size )))
|
||||
return STATUS_SUCCESS;
|
||||
|
||||
nb_imports = 0;
|
||||
while (imports[nb_imports].Name && imports[nb_imports].FirstThunk) nb_imports++;
|
||||
|
||||
if (!nb_imports) return STATUS_SUCCESS; /* no imports */
|
||||
|
||||
if (!create_module_activation_context( &wm->ldr ))
|
||||
RtlActivateActivationContext( 0, wm->ldr.ActivationContext, &cookie );
|
||||
|
||||
/* Allocate module dependency list */
|
||||
wm->nDeps = nb_imports;
|
||||
wm->deps = RtlAllocateHeap( GetProcessHeap(), 0, nb_imports*sizeof(WINE_MODREF *) );
|
||||
|
||||
/* load the imported modules. They are automatically
|
||||
* added to the modref list of the process.
|
||||
*/
|
||||
prev = current_modref;
|
||||
current_modref = wm;
|
||||
status = STATUS_SUCCESS;
|
||||
for (i = 0; i < nb_imports; i++)
|
||||
{
|
||||
if (!(wm->deps[i] = import_dll( wm->ldr.BaseAddress, &imports[i], load_path )))
|
||||
status = STATUS_DLL_NOT_FOUND;
|
||||
}
|
||||
current_modref = prev;
|
||||
if (wm->ldr.ActivationContext) RtlDeactivateActivationContext( 0, cookie );
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
* is_dll_native_subsystem
|
||||
*
|
||||
|
@ -885,6 +834,57 @@ static void free_tls_slot( LDR_MODULE *mod )
|
|||
}
|
||||
|
||||
|
||||
/****************************************************************
|
||||
* fixup_imports
|
||||
*
|
||||
* Fixup all imports of a given module.
|
||||
* The loader_section must be locked while calling this function.
|
||||
*/
|
||||
static NTSTATUS fixup_imports( WINE_MODREF *wm, LPCWSTR load_path )
|
||||
{
|
||||
int i, nb_imports;
|
||||
const IMAGE_IMPORT_DESCRIPTOR *imports;
|
||||
WINE_MODREF *prev;
|
||||
DWORD size;
|
||||
NTSTATUS status;
|
||||
ULONG_PTR cookie;
|
||||
|
||||
if (!(wm->ldr.Flags & LDR_DONT_RESOLVE_REFS)) return STATUS_SUCCESS; /* already done */
|
||||
wm->ldr.Flags &= ~LDR_DONT_RESOLVE_REFS;
|
||||
|
||||
if (!(imports = RtlImageDirectoryEntryToData( wm->ldr.BaseAddress, TRUE,
|
||||
IMAGE_DIRECTORY_ENTRY_IMPORT, &size )))
|
||||
return STATUS_SUCCESS;
|
||||
|
||||
nb_imports = 0;
|
||||
while (imports[nb_imports].Name && imports[nb_imports].FirstThunk) nb_imports++;
|
||||
|
||||
if (!nb_imports) return STATUS_SUCCESS; /* no imports */
|
||||
|
||||
if (!create_module_activation_context( &wm->ldr ))
|
||||
RtlActivateActivationContext( 0, wm->ldr.ActivationContext, &cookie );
|
||||
|
||||
/* Allocate module dependency list */
|
||||
wm->nDeps = nb_imports;
|
||||
wm->deps = RtlAllocateHeap( GetProcessHeap(), 0, nb_imports*sizeof(WINE_MODREF *) );
|
||||
|
||||
/* load the imported modules. They are automatically
|
||||
* added to the modref list of the process.
|
||||
*/
|
||||
prev = current_modref;
|
||||
current_modref = wm;
|
||||
status = STATUS_SUCCESS;
|
||||
for (i = 0; i < nb_imports; i++)
|
||||
{
|
||||
if (!(wm->deps[i] = import_dll( wm->ldr.BaseAddress, &imports[i], load_path )))
|
||||
status = STATUS_DLL_NOT_FOUND;
|
||||
}
|
||||
current_modref = prev;
|
||||
if (wm->ldr.ActivationContext) RtlDeactivateActivationContext( 0, cookie );
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
* alloc_module
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue