Sign in to follow this  
Territe

Oblivion DX Detours

Recommended Posts

Hey Everyone, as in the subject, just playing with DX Detours. I took the code from this article here http://www.gamedev.net/community/forums/topic.asp?topic_id=359794&PageSize=25&WhichPage=2 Thanks Muhammad Anyway rewrote it to use detours instead of hooks, mainly becuase hooks as presented in that article dont work in several applications. My Goal was to create an overlay message for Oblivion that would display updates for various tasks my computer was doing while I waste away my life playing the game. Strange thing is, when Oblivion is first loaded, sure enough the overlay works, however once it loads the initial screen, several odd thigns happen. The text on buttons become blocks, my overlay disapears, and sadness overcomes me... I will give the source here, its really just the stuff Muhammad did only parts are re written to work with detours. If anyone has oblivion and cares to test this out for me just to make sure i am not insane that would be great =) Or more importantly if you have any insight as to why this is happening. I will admit that i re-wrote this in all of 30 mins and haven't looked into the kind of stuff oblivion might do. but its late so I thought if anyone has some ideas i would appricate it. Source and Binaries Detours.zip Thanks again =) [Edited by - Territe on April 3, 2006 10:12:46 PM]

Share this post


Link to post
Share on other sites
Thanks, although my guess is the problem will be the same.

I have changed the code around a bit and found the drawing primitives works just fine, its drawing the text that causes the issues...

Anyone see a glaring problem in the following code that might lead to a hiccup? Any input is appricated.


STDMETHOD(EndScene)(THIS)
{

LPD3DXFONT m_font;
D3DXCreateFont( m_device, 20, 0, FW_BOLD, 0, FALSE, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE, TEXT("Arial"), &m_font );
D3DCOLOR fontColor = D3DCOLOR_ARGB(255,255,0,0);

// Create a rectangle to indicate where on the screen it should be drawn
RECT rct;
rct.left=2;
rct.right=780;
rct.top=10;
rct.bottom=rct.top+20; //There is a plus between the top and 20, it just isn't showing in this post.


// Draw some text
m_font->DrawText(NULL, "Hello World", -1, &rct, DT_LEFT|DT_NOCLIP , fontColor );



return m_device->EndScene();
}



Some Shots to show you what is happening.

This is with the Text Being Drawn...
Free Image Hosting at www.ImageShack.us
Free Image Hosting at www.ImageShack.us
Free Image Hosting at www.ImageShack.us

And here is with the primitive...
Free Image Hosting at www.ImageShack.us
Free Image Hosting at www.ImageShack.us

So As is clear, its somthing to do with the font... if anyone has any ideas please let me know =).

Share this post


Link to post
Share on other sites
Well after many fruitless attempts i have given up on the DX method.

Instad I pulled out the good ol IDA and found the ingame message functions and just used those..

Although i am still very interested in why the overlay text doesn't work, i am happy with these results.

The one problem with the current method i am using is that it uses direct addressing to the message function, which means natrually if there is a patch released its a possiblity that the address will change, so i would like to try to find a way to use DX still.

Message Text using internal Oblivion Message Functions
Free Image Hosting at www.ImageShack.us


If anyone wants the code to the message function as seen here let me know.

P.S. Still looking for input on the DX Detour!!

Share this post


Link to post
Share on other sites
Quote:
Instad I pulled out the good ol IDA and found the ingame message functions and just used those..

Nice! How did you go about finding these? What adresses are they located at?

(sorry i can't help with the DX thing)

Share this post


Link to post
Share on other sites
Quote:
If anyone wants the code to the message function as seen here let me know.


Well, I don't know if I'd be able to make some use of it in C#, but I know for certain that it would also be of much use to several other addicted people, including myself [smile] So, if you could share it, please go ahead. Should be interesting to see how it's done even if I might not be able to use it.

Quote:
P.S. Still looking for input on the DX Detour!!


On the font issue, I'm guessing that using the LPD3DXFONT somehow messes things up. I'm not 100% sure how those fonts work under the hood, but I believe they use some kind of caching mechanism and it might be that somehow this caching corrupts the Oblivion font. But that's just plain guessing.

As an alternative, you could use bitmap fonts on a sprite helper to do your text rendering.

Share this post


Link to post
Share on other sites
I'm thinking the font drawing is changing some renderstates that Oblivion is relying on. Try capturing the current state with a state block and restoring it after you render the font.

Share this post


Link to post
Share on other sites
Same as Jamesw : it defenitely looks like a render states problem (the alpha blending seems to be of when the Oblivion text is rendered)

In the article you linked, Muhammad gave a little warning on renderstates : you should backup all the render states as they are before you modify them, and you restore them after drawing your overlay stuff.

A little :

// creation
IDirect3DStateBlock9 * pStateBlockBackup;
d3dDevice->CreateStateBlock(D3DSBT_ALL, &pStateBlockBackup);

// backup
pStateBlockBackup->Capture();

// do your stuff here ...

// restore
pStateBlockBackup->Restore();

Might solve the problem

Share this post


Link to post
Share on other sites
Thanks for all the input guys, sadly none of it worked =P (i didn't try the gif font method)

This is the code i used, and it produced the same results as before...

IDirect3DStateBlock9 * pStateBlockBackup;
m_device->CreateStateBlock(D3DSBT_ALL, &pStateBlockBackup);
pStateBlockBackup->Capture();
LPD3DXFONT m_font;
D3DXCreateFont( m_device, 20, 0, FW_BOLD, 0, FALSE, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE, TEXT("Arial"), &m_font );
D3DCOLOR fontColor = D3DCOLOR_ARGB(255,255,0,0);

// Create a rectangle to indicate where on the screen it should be drawn
RECT rct;
rct.left=2;
rct.right=780;
rct.top=10;
rct.bottom=rct.top+20;
m_font->DrawText(NULL, "Hello World", -1, &rct, DT_LEFT|DT_NOCLIP , fontColor );
pStateBlockBackup->Apply();

return m_device->EndScene();



Its really not a big issue at this point, the only big disatvantage to using the ingame message system is its single line, so each line of text recieved has to be sent one at a time, but it works for now =).

I finished a trillian plugin that takes advantage of it you can download it here, i will release the source once i finish a few more touch ups in the code, if you find any bugs let me know.




SS of Trillian Plugin communicating with Oblivion.
Free Image Hosting at www.ImageShack.us

The plugin is set to accept only private messages, so things like group chats or irc shouldn't be sent through.

The package has two files.
OblivionMessage.dll - This is the trillian plugin file, it loads the message catch into trillian.
OMessageLoader.dll - This is the message detour DLL, whenever there is a message this DLL is sent into oblivion and executes the message call with the provided text. The DLL uses shared memory to accomplish the task, so far it works rather well.

There is overhead in the fact that it reloads/unloads the dll each time a message is sent, i am planning on changing this to a speicific function call which will be directly addressed once the function is loaded, however for now this works.

Oblivion Message Plugins

Code is comming...

Still looking for a fix to the DX problem though so i might be able to display multiple lines.

Share this post


Link to post
Share on other sites
hehe, the original intent was to see if i wanted to exit full screen to talk to the person =).

The reply could prove more difficult since the only place i have found ingame where you can give input would be in the (~) console. But i am sure tis very possible to do it from there, although i would just as soon figure out the problem with DX and make a little overlay. to communicate with.

Share this post


Link to post
Share on other sites
Quote:
Original post by Territe
Thanks for all the input guys, sadly none of it worked =P (i didn't try the gif font method)

This is the code i used, and it produced the same results as before...
*** Source Snippet Removed ***

Still looking for a fix to the DX problem though so i might be able to display multiple lines.

- If the game is using a pure device, all GetX calls won't work, which also means state blocks won't work IIRC. So, is it a pure device?

If it is, create a render state table, texture stage state table, etc and cache all state changes through the corresponding calls (SetRenderState, SetTextureStageState, etc).

- It's a bad idea to create the font every frame in EndScene. Create it on device creation/reset and use it afterwards.

Share this post


Link to post
Share on other sites
Quote:
Original post by Muhammad Haggag
- If the game is using a pure device, all GetX calls won't work, which also means state blocks won't work IIRC. So, is it a pure device?

If it is, create a render state table, texture stage state table, etc and cache all state changes through the corresponding calls (SetRenderState, SetTextureStageState, etc).


StateBlocks works with pure device. I have written a D3D hook system with plugins by my own. One of this plugins is a custom post filter extensions. To make sure that the states that are changed during the postfilter work are reset to the right values I use a StateBlock.

Share this post


Link to post
Share on other sites
Sorry to steal the thread...

Could anyone point me to an article that explains what you are doing? I've always wanted to draw some stuff over counter strike: source.

Thanks.

Share this post


Link to post
Share on other sites
Quote:
Original post by Smit
Sorry to steal the thread...

Could anyone point me to an article that explains what you are doing? I've always wanted to draw some stuff over counter strike: source.

Thanks.
The original thread has some links and useful information in it.

Share this post


Link to post
Share on other sites
Quote:
Original post by Evil Steve
Quote:
Original post by Smit
Sorry to steal the thread...

Could anyone point me to an article that explains what you are doing? I've always wanted to draw some stuff over counter strike: source.

Thanks.
The original thread has some links and useful information in it.


Thanks :)

Does anyone know if this type of thing is considered bannable by Valves Anti Cheat (VAC) system? I can think of several uses for it (Game MSN client, like XFire but with the MSN network). XFire never seems to get anyone banned, is it using overlays or another method?

Share this post


Link to post
Share on other sites
Thanks again for the input guys i will try a few more of those things when i get home and let you know the results.

I was thinking that perhaps a DX input detour could be used to handle the replies, since i know a few of the keys are not used in oblivion.

As for you question about Xfire, it would be my guess that it is an overlay, I am not sure how else it would work in a full screen situation and not have DX lose focus when you are clicking on it. But not positive here.

So not sure on VAC either, but iirc can't VAC detect if you have hitboxes being rendered? which is often accomplished using detours anyway so... not sure but i would think it could detect such a detour.

I will continue to work on this, thanks again guys.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this