windows-nt/Source/XPSP1/NT/inetsrv/iis/svcs/dbgext/findmod.cxx
2020-09-26 16:20:57 +08:00

106 lines
1.7 KiB
C++
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*++
Copyright (c) 1995-1997 Microsoft Corporation
Module Name:
findmod.cxx
Abstract:
Locates module in the debugee containing a specific address.
Author:
Keith Moore (keithmo) 12-Nov-1997
Revision History:
--*/
#include "inetdbgp.h"
typedef struct _ENUM_CONTEXT {
ULONG_PTR ModuleAddress;
PMODULE_INFO ModuleInfo;
BOOLEAN Successful;
} ENUM_CONTEXT, *PENUM_CONTEXT;
BOOLEAN
CALLBACK
FmpEnumProc(
IN PVOID Param,
IN PMODULE_INFO ModuleInfo
)
{
PENUM_CONTEXT context;
context = (PENUM_CONTEXT)Param;
if( context->ModuleAddress >= ModuleInfo->DllBase &&
context->ModuleAddress < ( ModuleInfo->DllBase + ModuleInfo->SizeOfImage ) ) {
CopyMemory(
context->ModuleInfo,
ModuleInfo,
sizeof(*ModuleInfo)
);
context->Successful = TRUE;
}
return !context->Successful;
} // FmpEnumProc
BOOLEAN
FindModuleByAddress(
IN ULONG_PTR ModuleAddress,
OUT PMODULE_INFO ModuleInfo
)
/*++
Routine Description:
Finds a module in the debugee that contains the specified address.
Arguments:
ModuleAddress - The module address to search for.
ModuleInfo - If successful, receives information describing the
module found.
Return Value:
BOOLEAN - TRUE if successful, FALSE otherwise.
--*/
{
BOOLEAN result;
ENUM_CONTEXT context;
context.ModuleAddress = ModuleAddress;
context.ModuleInfo = ModuleInfo;
context.Successful = FALSE;
result = EnumModules(
FmpEnumProc,
(PVOID)&context
);
if( result ) {
result = context.Successful;
}
return result;
} // FindModuleByAddress