Click here to Skip to main content
15,892,537 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: A QUESTION Pin
Kiran Pinjala2-Sep-06 0:28
Kiran Pinjala2-Sep-06 0:28 
Questionstatic varible? Pin
jalsa G1-Sep-06 22:57
jalsa G1-Sep-06 22:57 
AnswerRe: static varible? Pin
toxcct2-Sep-06 0:12
toxcct2-Sep-06 0:12 
AnswerRe: static varible? Pin
Jun Du2-Sep-06 6:13
Jun Du2-Sep-06 6:13 
QuestionDisabling a group of radio buttons Pin
cv_k3n1-Sep-06 21:57
cv_k3n1-Sep-06 21:57 
AnswerRe: Disabling a group of radio buttons Pin
Tony Hill2-Sep-06 4:55
mveTony Hill2-Sep-06 4:55 
Questionself modifying program Pin
blue_rabbit1-Sep-06 21:52
blue_rabbit1-Sep-06 21:52 
AnswerRe: self modifying program Pin
Stephen Hewitt1-Sep-06 22:22
Stephen Hewitt1-Sep-06 22:22 
blue_rabbit wrote:
DWORD **pfuncAdd = (DWORD **)px;//get address of vtable of class x
DWORD **pfakefunAdd = (DWORD **)px;//get address of vtable of class fake

The underlined variable should be pfake.

As for the access violation error, the page which contains the virtual table will be read-only. Try something like this (not tested):
// Get the address of the memory location we're going to modify.
DWORD *pAddress = &((*pfuncAdd)[0]);
 
// Attempt to make the page containing the address writable.
DWORD OldProtection;
BOOL OK = VirtualProtect(pAddress, sizeof(LPVOID), PAGE_WRITECOPY, &OldProtection);
if (OK)
{
    // Make the modification.
    *pAddress = (*pfakefunAdd)[0];
 
    // Set the page's protection back to previous value.
    DWORD Dummy;
    VirtualProtect(pAddress, sizeof(LPVOID), OldProtection, &Dummy);
}


Finally, why do you want to do such a thing? Such hackery is, in general, a bad idea.

PS: It would be nice if you went to some effort to make your code readable (for example, indentation and blank lines between sections of code).

Steve

GeneralRe: self modifying program Pin
blue_rabbit4-Sep-06 21:52
blue_rabbit4-Sep-06 21:52 
QuestionAdd Reference (static library) Pin
sawerr1-Sep-06 21:17
sawerr1-Sep-06 21:17 
QuestionSocket programming doubt Pin
Kiran Pinjala1-Sep-06 20:26
Kiran Pinjala1-Sep-06 20:26 
AnswerRe: Socket programming doubt Pin
Mila0252-Sep-06 3:02
Mila0252-Sep-06 3:02 
QuestionGetModuleFileName Pin
dipali_be20031-Sep-06 19:38
dipali_be20031-Sep-06 19:38 
AnswerRe: GetModuleFileName Pin
Waldermort1-Sep-06 20:14
Waldermort1-Sep-06 20:14 
GeneralRe: GetModuleFileName Pin
dipali_be20031-Sep-06 20:41
dipali_be20031-Sep-06 20:41 
GeneralRe: GetModuleFileName Pin
toxcct2-Sep-06 0:14
toxcct2-Sep-06 0:14 
QuestionMessage Box Pin
radhika281-Sep-06 19:36
radhika281-Sep-06 19:36 
GeneralRe: Message Box Pin
_AnsHUMAN_ 1-Sep-06 19:41
_AnsHUMAN_ 1-Sep-06 19:41 
GeneralRe: Message Box Pin
radhika281-Sep-06 19:47
radhika281-Sep-06 19:47 
GeneralRe: Message Box Pin
Hamid_RT1-Sep-06 20:04
Hamid_RT1-Sep-06 20:04 
GeneralRe: Message Box Pin
_AnsHUMAN_ 1-Sep-06 20:05
_AnsHUMAN_ 1-Sep-06 20:05 
GeneralRe: Message Box Pin
radhika281-Sep-06 20:17
radhika281-Sep-06 20:17 
GeneralRe: Message Box Pin
_AnsHUMAN_ 1-Sep-06 20:21
_AnsHUMAN_ 1-Sep-06 20:21 
GeneralRe: Message Box Pin
Hamid_RT1-Sep-06 20:28
Hamid_RT1-Sep-06 20:28 
AnswerRe: Message Box Pin
Divyang Mithaiwala1-Sep-06 21:33
Divyang Mithaiwala1-Sep-06 21:33 

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.