Click here to Skip to main content
15,905,322 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: How can Fix Window size as Maximize? Pin
Le@rner4-Apr-08 23:14
Le@rner4-Apr-08 23:14 
QuestionRe: How can Fix Window size as Maximize? [modified] Pin
rp_suman4-Apr-08 23:42
rp_suman4-Apr-08 23:42 
QuestionHow come I can WM_CLOSE an out-of-process Notepad but can't get it to display a WM_CHAR? Pin
glyfyx4-Apr-08 16:12
glyfyx4-Apr-08 16:12 
AnswerRe: How come I can WM_CLOSE an out-of-process Notepad but can't get it to display a WM_CHAR? Pin
Dr. Emmett Brown4-Apr-08 16:50
Dr. Emmett Brown4-Apr-08 16:50 
AnswerRe: How come I can WM_CLOSE an out-of-process Notepad but can't get it to display a WM_CHAR? Pin
glyfyx4-Apr-08 17:28
glyfyx4-Apr-08 17:28 
GeneralPE file format + relocations Pin
zildjohn014-Apr-08 15:20
zildjohn014-Apr-08 15:20 
GeneralRe: PE file format + relocations Pin
zildjohn016-Apr-08 11:58
zildjohn016-Apr-08 11:58 
GeneralRe: PE file format + relocations Pin
Stephen Hewitt6-Apr-08 18:47
Stephen Hewitt6-Apr-08 18:47 
This program will list all the addresses in "Kernel32.dll" that would need relocating if it didn't load at its preferred base address:
// Relocations.cpp : Defines the entry point for the console application.
//
 
#include "stdafx.h"
#include <iostream>
#include <windows.h>
using namespace std;
 
int main(int argc, char* argv[])
{
	// First get the DOS header.
	char *pBase = (char*)GetModuleHandle("kernel32.dll");
	PIMAGE_DOS_HEADER pDOS = (PIMAGE_DOS_HEADER)pBase;
	assert(pDOS->e_magic == IMAGE_DOS_SIGNATURE);
 
	// Get the NT headers.
	PIMAGE_NT_HEADERS pNT = (PIMAGE_NT_HEADERS)(pBase + pDOS->e_lfanew);
	assert(pNT->Signature == IMAGE_NT_SIGNATURE);
 
	// Now get the "optional" header.
	PIMAGE_OPTIONAL_HEADER pOpt = &(IMAGE_OPTIONAL_HEADER)(pNT->OptionalHeader);
	assert(pOpt->Magic == IMAGE_NT_OPTIONAL_HDR32_MAGIC);
 
	// Get a pointer to the relocation table and its size.
	PIMAGE_DATA_DIRECTORY pRelocDD = &(pOpt->DataDirectory[IMAGE_DIRECTORY_ENTRY_BASERELOC]);
	DWORD SizeOfRelocs = pRelocDD->Size;
	PIMAGE_BASE_RELOCATION pReloc = (PIMAGE_BASE_RELOCATION)(pBase + pRelocDD->VirtualAddress);
 
	for (DWORD ToGo = SizeOfRelocs; ToGo>0; /*Empty*/)
	{
		WORD *pRelocArray = (WORD*)(pReloc + 1);
		DWORD NumRelocs = (pReloc->SizeOfBlock - sizeof(IMAGE_BASE_RELOCATION)) / sizeof(WORD);
 
		for (DWORD i=0; i<NumRelocs; ++i)
		{
			WORD val = pRelocArray[i];
			WORD Type = val >> 12;
			WORD RVA = val & 0x0FFF;
 
			cout << hex << "Type = " << Type << ", Address = " << (DWORD)(pBase + pReloc->VirtualAddress + RVA) << endl;
		}
 
		ToGo -= pReloc->SizeOfBlock;
		pReloc = (PIMAGE_BASE_RELOCATION)((char*)pReloc + pReloc->SizeOfBlock);
	}
 
	return 0;
}


See here[^] for for information.

Steve

QuestionSend a program to another PC & execute it there ..... Pin
tina->newcoder4-Apr-08 9:17
tina->newcoder4-Apr-08 9:17 
GeneralRe: Send a program to another PC & execute it there ..... Pin
David Crow4-Apr-08 9:54
David Crow4-Apr-08 9:54 
GeneralRe: Send a program to another PC & execute it there ..... Pin
led mike4-Apr-08 11:20
led mike4-Apr-08 11:20 
GeneralRe: Send a program to another PC & execute it there ..... Pin
Eytukan5-Apr-08 7:52
Eytukan5-Apr-08 7:52 
GeneralRe: Send a program to another PC & execute it there ..... Pin
Hamid_RT7-Apr-08 20:54
Hamid_RT7-Apr-08 20:54 
GeneralCStatic-Derived class: painting background Pin
42884-Apr-08 6:53
42884-Apr-08 6:53 
GeneralRe: CStatic-Derived class: painting background Pin
Nitheesh George4-Apr-08 7:06
Nitheesh George4-Apr-08 7:06 
GeneralRe: CStatic-Derived class: painting background Pin
Gary R. Wheeler6-Apr-08 1:45
Gary R. Wheeler6-Apr-08 1:45 
GeneralRe: CStatic-Derived class: painting background Pin
led mike4-Apr-08 7:09
led mike4-Apr-08 7:09 
GeneralRe: CStatic-Derived class: painting background Pin
42884-Apr-08 7:28
42884-Apr-08 7:28 
GeneralRe: CStatic-Derived class: painting background Pin
led mike4-Apr-08 7:59
led mike4-Apr-08 7:59 
GeneralRe: CStatic-Derived class: painting background Pin
42884-Apr-08 8:33
42884-Apr-08 8:33 
GeneralRe: CStatic-Derived class: painting background Pin
Hamid_RT7-Apr-08 20:52
Hamid_RT7-Apr-08 20:52 
GeneralRe: CStatic-Derived class: painting background Pin
42888-Apr-08 7:23
42888-Apr-08 7:23 
GeneralRe: CStatic-Derived class: painting background Pin
Hamid_RT8-Apr-08 8:00
Hamid_RT8-Apr-08 8:00 
QuestionA very basic question about ODBC Pin
Joseph Marzbani4-Apr-08 5:34
Joseph Marzbani4-Apr-08 5:34 
GeneralRe: A very basic question about ODBC Pin
David Crow4-Apr-08 6:04
David Crow4-Apr-08 6:04 

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.