Module: wine Branch: master Commit: 4bed3d231e96687efbdba3ff4c96fbbdfe450ba8 URL: http://source.winehq.org/git/wine.git/?a=commit;h=4bed3d231e96687efbdba3ff4c...
Author: Sebastian Lackner sebastian@fds-team.de Date: Fri Feb 26 06:11:26 2016 +0100
winedevice: Use LdrFindEntryForAddress to find LDR_MODULE address.
Signed-off-by: Sebastian Lackner sebastian@fds-team.de Signed-off-by: Alexandre Julliard julliard@winehq.org
---
programs/winedevice/device.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-)
diff --git a/programs/winedevice/device.c b/programs/winedevice/device.c index ef1e1ef..43963b6 100644 --- a/programs/winedevice/device.c +++ b/programs/winedevice/device.c @@ -50,15 +50,18 @@ static DRIVER_EXTENSION driver_extension; /* find the LDR_MODULE corresponding to the driver module */ static LDR_MODULE *find_ldr_module( HMODULE module ) { - LIST_ENTRY *entry, *list = &NtCurrentTeb()->Peb->LdrData->InMemoryOrderModuleList; + LDR_MODULE *ldr; + ULONG_PTR magic;
- for (entry = list->Flink; entry != list; entry = entry->Flink) + LdrLockLoaderLock( 0, NULL, &magic ); + if (LdrFindEntryForAddress( module, &ldr )) { - LDR_MODULE *ldr = CONTAINING_RECORD(entry, LDR_MODULE, InMemoryOrderModuleList); - if (ldr->BaseAddress == module) return ldr; - if (ldr->BaseAddress > (void *)module) break; + WARN( "module not found for %p\n", module ); + ldr = NULL; } - return NULL; + LdrUnlockLoaderLock( 0, magic ); + + return ldr; }
/* load the driver module file */