Jump to content
  • Advertisement
Sign in to follow this  
Hunter_Ex

Finding Device (look last post)

This topic is 4846 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 why wont this code works??
float *point;
try
{
   *point = 10;
}
catch (...) {  };



the source for this code is very old i didnt found much new stuff on the net so ill be glad if someone could give me a new code when "try-throw-catch" work that above code raises an "illegal operation" and i want it to just continue and only tell me if an error occur and not quit thx [Edited by - Hunter_Ex on August 15, 2005 7:05:54 PM]

Share this post


Link to post
Share on other sites
Advertisement
Because try/catch blocks do not catch things that are not C++ exceptions, except by vendor specific extension. There is no way in standard C++ for a catch block to trap a bad pointer write.

Share this post


Link to post
Share on other sites
okay so IN ANY WAY POSSIBLE my program must quit due to "illegal operation" ??

i really want to find a way to jump over an error :/
is it not possible?

Share this post


Link to post
Share on other sites
Quote:
Original post by Hunter_Ex
okay so IN ANY WAY POSSIBLE my program must quit due to "illegal operation" ??

i really want to find a way to jump over an error :/
is it not possible?


It's possible just platform dependant.

Share this post


Link to post
Share on other sites
okay so how would i avoid this error (continue without abort)

platform = XP PRO


try
{
device->TestCooperativeLevel();
}
catch (...) { }



device is a value but it doenst need to be a correct fixed device
it throws illegal operation..

Share this post


Link to post
Share on other sites
The only way to jump over the bad write is to check if the pointer is valid. Assuming you don't delete memory that is still being referenced that would mean the pointer is null.

float* point = 0;
// initialize point here
if (point) {
*point = 10;
}

// or:
if (!point) throw std::logic_error("Expected point");
*point = 10;

Share this post


Link to post
Share on other sites
under Windows you could use SEH (Structured Exception Handling) MSDN can tell you all about that if you ask it.

But in your particular instance checking the device pointer before using it is probably a much better solution.

Share this post


Link to post
Share on other sites
Quote:
Original post by Hunter_Ex
well but the value doesnt need to be NULL
ill check msdn


How do you acquire the device pointer? Im quite confident that you can detect an erronueous state well before getting that access violation.

Share this post


Link to post
Share on other sites
okay the device is just a random pointer from a search trough another program
and if i look beetween 1000 addresses i want to check if the address has a valid LPDIRECT3DDEVICE9

so to simplify



LPDIRECT3DDEVICE9 test;
test = (LPDIRECT3DDEVICE9)(INT)random_address;

// now i want to check if the test device is a valid render device
// if the test gives error at any device function its NOT valid otherwize valid
// i want an easier way doing this
// like for example dont quit the program everytime the device WASNT valid

// current check code
D3DXGetDriverLevel(test); // if crash it was NOT valid else its VALID'




any idea?

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!