mirror of https://github.com/x64dbg/GleeBug
added handler for 'ReturnType'
added handler for the parameter 'ReturnType' inConvertFileOffsetToVA(), ConvertVAtoFileOffset() and ConvertVAtoFileOffsetEx()
This commit is contained in:
parent
951852bab1
commit
9f16d36504
|
|
@ -567,21 +567,35 @@ public:
|
||||||
mappedFiles.erase(found);
|
mappedFiles.erase(found);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
////
|
||||||
ULONG_PTR ConvertFileOffsetToVA(ULONG_PTR FileMapVA, ULONG_PTR AddressToConvert, bool ReturnType)
|
///
|
||||||
|
// ConvertFileOffsetToVA - converts FileOffset to a virtual addresses
|
||||||
|
// checks if PE file is valid and if memory is accessible
|
||||||
|
// Returns: converted VA
|
||||||
|
// or NULL if conversion has failed.
|
||||||
|
//
|
||||||
|
ULONG_PTR ConvertFileOffsetToVA(
|
||||||
|
ULONG_PTR FileMapVA, // [in] Pointer to the mapped file content. It's either StaticFileLoad function or Windows API for file mapping.
|
||||||
|
ULONG_PTR AddressToConvert, // [in] physical address/file offset
|
||||||
|
bool ReturnType // [in] if true: add the FileMapVA to the return value
|
||||||
|
)
|
||||||
{
|
{
|
||||||
auto found = mappedFiles.find(FileMapVA);
|
auto found = mappedFiles.find(FileMapVA);
|
||||||
|
|
||||||
if(found == mappedFiles.end())
|
if(found == mappedFiles.end())
|
||||||
__debugbreak(); //return 0;
|
__debugbreak(); //return 0;
|
||||||
|
|
||||||
if(!found->second.pe->IsValidPe())
|
if(!found->second.pe->IsValidPe())
|
||||||
__debugbreak(); //return 0;
|
__debugbreak(); //return 0;
|
||||||
|
|
||||||
auto offset = found->second.pe->ConvertOffsetToRva( uint32( AddressToConvert ) );
|
// convert: FileOffset -> VA
|
||||||
|
auto offset = found->second.pe->ConvertOffsetToRva(
|
||||||
|
uint32( AddressToConvert )
|
||||||
|
);
|
||||||
|
|
||||||
if (offset == INVALID_VALUE)
|
if (offset == INVALID_VALUE)
|
||||||
return 0;
|
return 0
|
||||||
|
else
|
||||||
|
return ReturnType ? FileMapVA + offset : offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
////
|
////
|
||||||
|
|
@ -594,7 +608,7 @@ public:
|
||||||
ULONG_PTR ConvertVAtoFileOffset(
|
ULONG_PTR ConvertVAtoFileOffset(
|
||||||
ULONG_PTR FileMapVA, // [in] Pointer to the mapped file content. It's either StaticFileLoad function or Windows API for file mapping.
|
ULONG_PTR FileMapVA, // [in] Pointer to the mapped file content. It's either StaticFileLoad function or Windows API for file mapping.
|
||||||
ULONG_PTR AddressToConvert, // [in] Virtual address to convert to a physical address.
|
ULONG_PTR AddressToConvert, // [in] Virtual address to convert to a physical address.
|
||||||
bool ReturnType // [in] Add the FileMapVA return value?
|
bool ReturnType // [in] if true: add the FileMapVA to the return value
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
return ConvertVAtoFileOffsetEx(
|
return ConvertVAtoFileOffsetEx(
|
||||||
|
|
@ -615,7 +629,7 @@ public:
|
||||||
ULONG_PTR ImageBase, // [in] ImageBase of the mapped file
|
ULONG_PTR ImageBase, // [in] ImageBase of the mapped file
|
||||||
ULONG_PTR AddressToConvert, // [in] Virtual address to convert to a physical address.
|
ULONG_PTR AddressToConvert, // [in] Virtual address to convert to a physical address.
|
||||||
bool AddressIsRVA, // [in] true => AddressToConvert is relative virtual address
|
bool AddressIsRVA, // [in] true => AddressToConvert is relative virtual address
|
||||||
bool ReturnType // [in] Add the FileMapVA return value?
|
bool ReturnType // [in] if true: add the FileMapVA to the return value
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
auto found = mappedFiles.find(FileMapVA);
|
auto found = mappedFiles.find(FileMapVA);
|
||||||
|
|
@ -630,12 +644,15 @@ public:
|
||||||
AddressToConvert :
|
AddressToConvert :
|
||||||
AddressToConvert - ImageBase;
|
AddressToConvert - ImageBase;
|
||||||
|
|
||||||
|
// convert: VA -> FileOffset
|
||||||
auto offset = found->second.pe->ConvertRvaToOffset(
|
auto offset = found->second.pe->ConvertRvaToOffset(
|
||||||
uint32( RVA_ToConvert )
|
uint32( RVA_ToConvert )
|
||||||
);
|
);
|
||||||
|
|
||||||
if (offset == INVALID_VALUE)
|
if (offset == INVALID_VALUE)
|
||||||
return 0;
|
return 0
|
||||||
|
else
|
||||||
|
return ReturnType ? FileMapVA + offset : offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue