Jump to content
  • Advertisement
Sign in to follow this  
Territe

Oblivion DX Detours

This topic is 4486 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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
Advertisement
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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!