Results 1 to 9 of 9
  1. #1
    Crash's Avatar
    Join Date
    Aug 2009
    Gender
    male
    Location
    JAville
    Posts
    2,881
    Reputation
    163
    Thanks
    3,291
    My Mood
    Sleepy

    Little bit of D3D hooking help

    EDIT : I'm using ID3DXFont just so you know.

    I have a menu and it works fine, for about 60 seconds... the text disappears/box disappears/crosshair disappears.

    I'm thinking of a few ways to do this. They don't work too well because it takes about 10 seconds to re-hook which is inconvenient.

    Here are the ways I've done so far :

    1. Have a reporter variable(boolean) that sets it to true at the end of the hook func and then in an infinite loop in a thread it sets it to false and sets a timer variable to zero and the reporter variable to false again. If the reported variable is false in the infinite loop, the timer variable is set up one. After the timer variable is 100, it re-hooks because endscene wasn't drawing. The only problem is going ingame, it freezes when you hit start and endscene is frozen or something like that, then when it re-hooks the game ends. Here is what it looks like in code form:
    Code:
    //endscene func :
    ...{
    
    //Drawing stuff here
    
    report = true;
    }
    
    //Thread
    
    ...{
    
    //Key checking in here
    
    if(report){
        timer = 0;
        report = false;
    } else {
        timer++;
        if(timer > 100){//This is the same thing I use at the start to hook without he RemoveDetour part
            RemoveDetour((PBYTE)myEndScene, (PBYTE)endscene);
            //Get endscene here
            oEndScene = (tEndScene)(DetourFunction((PBYTE)endscene, (PBYTE)myEndScene, 5));
            timer = 0;
        }
    }
    
    Sleep(10);
    
    }
    2 : Use the return value of DrawText() (it returns the height of the drawn text if it succeeds and returns 0 if it fails) to check if it fails at drawing. Once again, it fails when I go ingame because it isn't drawing.

    3 : Re-hook :
    Code:
    if(GetModuleHandle("d3d9.dll") != NULL){
        //Hook stuffs
    }
    The problem with this ? No problem when going ingame
    Sadly, it doesn't re-hook when the text disappears out/ingame because ES is drawing.

    Anybody know how to get around this ? The ingame part is really annoying... (I will put your name in the credits if you can help me out)

  2. #2
    Void's Avatar
    Join Date
    Sep 2009
    Gender
    male
    Location
    Inline.
    Posts
    3,198
    Reputation
    205
    Thanks
    1,445
    My Mood
    Mellow
    Well, whenever I try hooking functions in like mid-execution, nothing ever happens. When I try opening the test environment and hook after everything is done loading, the function doesn't seem to get hooked and it won't draw anything... I think.

    I'll test it later when I get on a real computer..

    What game is this for anyway?

  3. #3
    why06's Avatar
    Join Date
    Jul 2009
    Gender
    male
    Location
    IBM
    Posts
    4,304
    Reputation
    170
    Thanks
    2,203
    My Mood
    Flirty
    u could do all that, or u could just hook reset as well.
    Code:
    oReset = (tReset)(DetourFunction((PBYTE)reset, (PBYTE)myReset, 5));
    make sure u reset ur font pointer to like so:

    {
    font->onLostDevice();
    reset();
    font->onResetDevice();
    }

    And btw try initializing ur font with the device inside the hooked function, that usually causes less bugs

    PS: its nothing wrong with ur detour, its just that the device reset and ur font did not reset with it. u should never have to rehook a d3d function under normal conditions.
    Last edited by why06; 06-14-2010 at 07:54 AM.

    "Every gun that is made, every warship launched, every rocket fired signifies, in the final sense, a theft from those who hunger and are not fed, those who are cold and are not clothed. This world in arms is not spending money alone. It is spending the sweat of its laborers, the genius of its scientists, the hopes of its children. The cost of one modern heavy bomber is this: a modern brick school in more than 30 cities. It is two electric power plants, each serving a town of 60,000 population. It is two fine, fully equipped hospitals. It is some fifty miles of concrete pavement. We pay for a single fighter plane with a half million bushels of wheat. We pay for a single destroyer with new homes that could have housed more than 8,000 people. This is, I repeat, the best way of life to be found on the road the world has been taking. This is not a way of life at all, in any true sense. Under the cloud of threatening war, it is humanity hanging from a cross of iron."
    - Dwight D. Eisenhower

  4. #4
    Dave84311's Avatar
    Join Date
    Dec 2005
    Gender
    male
    Location
    The Wild Wild West
    Posts
    35,837
    Reputation
    5782
    Thanks
    41,292
    My Mood
    Devilish
    Quote Originally Posted by why06 View Post
    u could do all that, or u could just hook reset as well.
    Code:
    oReset = (tReset)(DetourFunction((PBYTE)reset, (PBYTE)myReset, 5));
    make sure u reset ur font pointer to like so:

    {
    font->onLostDevice();
    reset();
    font->onResetDevice();
    }

    And btw try initializing ur font with the device inside the hooked function, that usually causes less bugs
    And bingo was his nameo.





    THE EYE OF AN ADMINISTRATOR IS UPON YOU. ANY WRONG YOU DO IM GONNA SEE, WHEN YOU'RE ON MPGH, LOOK BEHIND YOU, 'CAUSE THATS WHERE IM GONNA BE


    "First they ignore you. Then they laugh at you. Then they fight you. Then you lose.” - Dave84311

    HAVING VIRTUAL DETOX

  5. The Following User Says Thank You to Dave84311 For This Useful Post:

    mwb1234 (06-14-2010)

  6. #5
    Crash's Avatar
    Join Date
    Aug 2009
    Gender
    male
    Location
    JAville
    Posts
    2,881
    Reputation
    163
    Thanks
    3,291
    My Mood
    Sleepy
    Quote Originally Posted by Dave84311 View Post

    And bingo was his nameo.
    But I did that...

    By reset() do you mean (device)->reset();

    I'll try that and see if it works.

    Here is my reset :

    Code:
    	p_font->OnLostDevice();
    	p_line->OnLostDevice();
    
    	pDevice->Reset(PresentationParams);//Going to try it
    
    	p_font->OnResetDevice();
    	p_line->OnResetDevice();
    
    	return (HRESULT)oReset(pDevice, pPresentationParameters);
    Last edited by Crash; 06-14-2010 at 08:20 AM.

  7. #6
    Void's Avatar
    Join Date
    Sep 2009
    Gender
    male
    Location
    Inline.
    Posts
    3,198
    Reputation
    205
    Thanks
    1,445
    My Mood
    Mellow
    If you hooked reset, you can't use your device to call it. Use the one returned from the detour function.

  8. The Following User Says Thank You to Void For This Useful Post:

    why06 (06-14-2010)

  9. #7
    mwb1234's Avatar
    Join Date
    May 2009
    Gender
    male
    Posts
    460
    Reputation
    7
    Thanks
    65
    Quote Originally Posted by Dave84311 View Post

    And bingo was his nameo.
    Funny Dave. /yea

  10. #8
    Crash's Avatar
    Join Date
    Aug 2009
    Gender
    male
    Location
    JAville
    Posts
    2,881
    Reputation
    163
    Thanks
    3,291
    My Mood
    Sleepy
    This is what I have now. I think this is what why meant.

    Code:
    p_font->OnLostDevice();
    p_line->OnLostDevice();
    
    HRESULT hreturn = oReset(pDevice, pPresentationParameters);
    
    p_font->OnResetDevice();
    p_line->OnResetDevice();
    
    return hreturn;
    You gotta be kidding me... it still doesn't work. The text disappears after 50 - 60 seconds...

    EDIT : This is for Combat Arms, and I am hooking reset correctly because I alt+tabbed out and went back in and the message box that I put in the function popped up. The text still goes away sadly..

    EDIT 2: Tried LPD3DXFONT instead and it went away, yet again.
    Last edited by Crash; 06-14-2010 at 10:06 AM.

  11. #9
    why06's Avatar
    Join Date
    Jul 2009
    Gender
    male
    Location
    IBM
    Posts
    4,304
    Reputation
    170
    Thanks
    2,203
    My Mood
    Flirty
    do u have an msn, it would be easier if I could look @ the whole thing.

    "Every gun that is made, every warship launched, every rocket fired signifies, in the final sense, a theft from those who hunger and are not fed, those who are cold and are not clothed. This world in arms is not spending money alone. It is spending the sweat of its laborers, the genius of its scientists, the hopes of its children. The cost of one modern heavy bomber is this: a modern brick school in more than 30 cities. It is two electric power plants, each serving a town of 60,000 population. It is two fine, fully equipped hospitals. It is some fifty miles of concrete pavement. We pay for a single fighter plane with a half million bushels of wheat. We pay for a single destroyer with new homes that could have housed more than 8,000 people. This is, I repeat, the best way of life to be found on the road the world has been taking. This is not a way of life at all, in any true sense. Under the cloud of threatening war, it is humanity hanging from a cross of iron."
    - Dwight D. Eisenhower

Similar Threads

  1. Need a little bit of help
    By Chickente in forum Combat Arms Mod Discussion
    Replies: 6
    Last Post: 01-08-2011, 08:20 PM
  2. A little bit help?
    By LeoCooper in forum Combat Arms Hack Coding / Programming / Source Code
    Replies: 10
    Last Post: 06-19-2010, 08:54 AM
  3. warrock helps hus a little bit.
    By SHadyDAGGER in forum WarRock - International Hacks
    Replies: 3
    Last Post: 01-26-2008, 11:46 AM
  4. Please... Help me with this D3D Hook!
    By nukeist_ in forum C++/C Programming
    Replies: 7
    Last Post: 12-22-2007, 08:02 PM
  5. Need help like right now with my d3d hook!
    By nukeist_ in forum C++/C Programming
    Replies: 0
    Last Post: 12-21-2007, 02:25 PM