EndScene detour question menu

User Tag List

Results 1 to 5 of 5
  1. #1
    bad6oy30's Avatar Member Authenticator enabled
    Reputation
    1
    Join Date
    Dec 2010
    Posts
    41
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    EndScene detour question

    So I've moved from out-of-process to in-process, and it's pretty damn cool. I detoured D3D9 EndScene with a wrapper DLL, that was all well and good, but now I want to get rid of the proxy and do a "live" detour.

    One thing I don't understand... if you know the pointer to the IDirect3DDevice9, then you can get the pointer to the virtual EndScene method. After that, you overwrite the virtual method pointer with the addr of your hook function. Your function does the extra work, then calls the original pointer, casted to the same signature.

    But I see all the asm in the detour examples, and I don't understand it... why is it necessary?

    EndScene detour question
  2. #2
    Azzie2k8's Avatar Member
    Reputation
    11
    Join Date
    Apr 2009
    Posts
    190
    Thanks G/R
    0/0
    Trade Feedback
    1 (100%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by bad6oy30 View Post
    So I've moved from out-of-process to in-process, and it's pretty damn cool. I detoured D3D9 EndScene with a wrapper DLL, that was all well and good, but now I want to get rid of the proxy and do a "live" detour.

    One thing I don't understand... if you know the pointer to the IDirect3DDevice9, then you can get the pointer to the virtual EndScene method. After that, you overwrite the virtual method pointer with the addr of your hook function. Your function does the extra work, then calls the original pointer, casted to the same signature.

    But I see all the asm in the detour examples, and I don't understand it... why is it necessary?
    Because basicly what is done is that you do not overwrite the original function but write a jump in the first few bytes of the original function.
    This jump goes to your detoured function in which you most likely jump back to where you left in the original function.

    All this is obviously done in assembler since you are messing with memory.

    I am not a pro at this and I might be wrong but I think this thread is very interesting for you

    http://www.mmowned.com/forums/world-...-codecave.html

  3. #3
    _Mike's Avatar Contributor
    Reputation
    310
    Join Date
    Apr 2008
    Posts
    531
    Thanks G/R
    0/2
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by bad6oy30 View Post
    One thing I don't understand... if you know the pointer to the IDirect3DDevice9, then you can get the pointer to the virtual EndScene method. After that, you overwrite the virtual method pointer with the addr of your hook function. Your function does the extra work, then calls the original pointer, casted to the same signature.

    But I see all the asm in the detour examples, and I don't understand it... why is it necessary?
    It's not. Most people here just don't have a clue what "virtual method" means. Haven't you noticed that almost everyone here who claims to code in C++ could just as well compile their code as C?

    Just overwrite the VMT entry and be done with it. Easy, clean and efficient. And it makes it so much cleaner to do hook chains if you ever want to do that.

    Originally Posted by Azzie2k8 View Post
    Because basicly what is done is that you do not overwrite the original function but write a jump in the first few bytes of the original function.
    This jump goes to your detoured function in which you most likely jump back to where you left in the original function.
    What? Writing new data to a function is not overwriting it?
    If you want to do this then at least use the hotpatch padding. There's no need to destroy the original function.

  4. #4
    Azzie2k8's Avatar Member
    Reputation
    11
    Join Date
    Apr 2009
    Posts
    190
    Thanks G/R
    0/0
    Trade Feedback
    1 (100%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by _Mike View Post
    It's not. Most people here just don't have a clue what "virtual method" means. Haven't you noticed that almost everyone here who claims to code in C++ could just as well compile their code as C?

    Just overwrite the VMT entry and be done with it. Easy, clean and efficient. And it makes it so much cleaner to do hook chains if you ever want to do that.


    What? Writing new data to a function is not overwriting it?
    If you want to do this then at least use the hotpatch padding. There's no need to destroy the original function.
    Damn I need to read the full post before posting sorry

  5. #5
    bad6oy30's Avatar Member Authenticator enabled
    Reputation
    1
    Join Date
    Dec 2010
    Posts
    41
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for the link and info!

    Maybe the EndScene vtable pointer is Warden-watched? But the device object is API constructed... the object pointer is non-static, and I thought Warden only watched static regions.

    Maybe we'll see a big explanation by tomorrow
    Last edited by bad6oy30; 02-23-2011 at 05:40 PM.

Similar Threads

  1. Replies: 1
    Last Post: 12-12-2011, 02:31 AM
  2. Replies: 11
    Last Post: 01-06-2011, 02:59 PM
  3. C# Troubleshooting my endscene detour 3.3.5 (12340)
    By opulent in forum WoW Memory Editing
    Replies: 11
    Last Post: 07-26-2010, 05:00 AM
  4. Grabbing the DX device in endscene detour
    By ggg898 in forum WoW Memory Editing
    Replies: 0
    Last Post: 09-08-2009, 06:41 AM
All times are GMT -5. The time now is 08:43 PM. Powered by vBulletin® Version 4.2.3
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved. User Alert System provided by Advanced User Tagging (Pro) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
Google Authenticator verification provided by Two-Factor Authentication (Free) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
Digital Point modules: Sphinx-based search