Rémi Bernon (@rbernon) commented about dlls/ntdll/loader.c:
RtlEnterCriticalSection( &loader_section );
- /* check if the module itself is invalid to return the proper error */
- if (!get_modref( module )) ret = STATUS_DLL_NOT_FOUND;
- else if ((exports = RtlImageDirectoryEntryToData( module, TRUE,
IMAGE_DIRECTORY_ENTRY_EXPORT, &exp_size )))
- wm = get_modref( module );
- if (!wm) ret = STATUS_DLL_NOT_FOUND;
- else {
void *proc = name ? find_named_export( module, exports, exp_size, name->Buffer, -1, NULL )
: find_ordinal_export( module, exports, exp_size, ord - exports->Base, NULL );
if (proc)
prev = current_modref;
current_modref = wm;
I think you can simplify this a bit, by doing `if ((current_modref = get_modref(...)))`, after saving its previous value, and restoring it before leaving the CS.
Then I'm not sure what side effects this could have, and maybe it'd be better to have this specific change separate from the rest?