Click here to Skip to main content
15,914,013 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: CRecordSet->MoveFirst() exception Pin
Scozturk18-Jul-04 7:23
professionalScozturk18-Jul-04 7:23 
GeneralRe: CRecordSet->MoveFirst() exception Pin
Alexander Wiseman18-Jul-04 9:05
Alexander Wiseman18-Jul-04 9:05 
GeneralLOGPEN Pin
Trollslayer18-Jul-04 6:47
mentorTrollslayer18-Jul-04 6:47 
GeneralRe: LOGPEN Pin
Trollslayer18-Jul-04 8:37
mentorTrollslayer18-Jul-04 8:37 
GeneralRe: LOGPEN Pin
Alexander Wiseman18-Jul-04 9:06
Alexander Wiseman18-Jul-04 9:06 
GeneralRe: LOGPEN - resource usage warning Pin
PJ Arends18-Jul-04 9:06
professionalPJ Arends18-Jul-04 9:06 
GeneralRe: LOGPEN Pin
Alexander Wiseman18-Jul-04 8:56
Alexander Wiseman18-Jul-04 8:56 
GeneralGet a pointer from an RVA Pin
Toni7818-Jul-04 6:43
Toni7818-Jul-04 6:43 
template <class T> LPVOID GetPtrFromRVA( DWORD rva, T* pNTHeader, PBYTE imageBase ) // 'T' = PIMAGE_NT_HEADERS 
{
	PIMAGE_SECTION_HEADER pSectionHdr;
	INT delta;
		
	pSectionHdr = GetEnclosingSectionHeader( rva, pNTHeader );
	if ( !pSectionHdr )
		return 0;

	delta = (INT)(pSectionHdr->VirtualAddress-pSectionHdr->PointerToRawData);
	return (PVOID) ( imageBase + rva - delta );
}


These lines of code were taken from Matt Pietrek's PEDump (http://www.wheaty.net/[^]). This function takes an RVA and gives you an actual memory address where this RVA is located.
imageBase - is the image base where the PE file being viewed is mapped.
pSectionHdr - is a pointer to a section where the rva falls in.
Now I don't understand the last line of the function. Wouldn't imageBase + rva be enough? Why would we factor in this delta variable? On top of that, pSectionHdr->VirtualAddress and pSectionHdr->PointerToRawData point at the same information but in two different contexts. The VirtualAddress is the RVA of the section and PointerToRawData is the file offset of the section. Therefore, the load offset cannot always be the same as the file offset.

// Afterall, I realized that even my comment lines have bugs

If the sun were to blow up, it would take us 7-8 minutes to realize it.
GeneralRe: Get a pointer from an RVA Pin
bikram singh19-Jul-04 12:55
bikram singh19-Jul-04 12:55 
GeneralProblem Creating a server on the local PC using CAsyncSocket Pin
femi ashiru18-Jul-04 6:42
femi ashiru18-Jul-04 6:42 
GeneralRe: Problem Creating a server on the local PC using CAsyncSocket Pin
valikac18-Jul-04 13:59
valikac18-Jul-04 13:59 
GeneralDirectory Date/Time Pin
Atlence18-Jul-04 4:04
Atlence18-Jul-04 4:04 
GeneralRe: Directory Date/Time Pin
Toni7818-Jul-04 7:32
Toni7818-Jul-04 7:32 
GeneralRe: Directory Date/Time Pin
Atlence18-Jul-04 14:19
Atlence18-Jul-04 14:19 
GeneralRe: Directory Date/Time Pin
Atlence2-Apr-05 12:55
Atlence2-Apr-05 12:55 
GeneralRe: Directory Date/Time Pin
Toni7829-Apr-05 13:30
Toni7829-Apr-05 13:30 
GeneralRe: Directory Date/Time Pin
Toni789-May-05 6:42
Toni789-May-05 6:42 
GeneralDialog Problem Pin
Kunal Shetye18-Jul-04 2:44
Kunal Shetye18-Jul-04 2:44 
GeneralRe: Dialog Problem Pin
Alexander Wiseman18-Jul-04 3:22
Alexander Wiseman18-Jul-04 3:22 
GeneralRe: Dialog Problem Pin
Kunal Shetye18-Jul-04 8:27
Kunal Shetye18-Jul-04 8:27 
GeneralRe: Dialog Problem Pin
Bob Stanneveld18-Jul-04 3:24
Bob Stanneveld18-Jul-04 3:24 
QuestionDevice Contexts usage? Pin
0v3rloader17-Jul-04 23:02
0v3rloader17-Jul-04 23:02 
AnswerRe: Device Contexts usage? Pin
Jörgen Sigvardsson18-Jul-04 0:07
Jörgen Sigvardsson18-Jul-04 0:07 
GeneralRe: Device Contexts usage? Pin
0v3rloader18-Jul-04 0:27
0v3rloader18-Jul-04 0:27 
GeneralRe: Device Contexts usage? Pin
Jörgen Sigvardsson18-Jul-04 0:35
Jörgen Sigvardsson18-Jul-04 0:35 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.