Finding Device (look last post)

Started by
21 comments, last by Hunter_Ex 18 years, 8 months ago
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]
Blekinge Institute of Technology
Twitter [twitter]devmoon[/twitter]
Homepage http://devmoon.se
Stream http://twitch.tv/devmoon
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.
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?
Blekinge Institute of Technology
Twitter [twitter]devmoon[/twitter]
Homepage http://devmoon.se
Stream http://twitch.tv/devmoon
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.
HardDrop - hard link shell extension."Tread softly because you tread on my dreams" - Yeats
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..
Blekinge Institute of Technology
Twitter [twitter]devmoon[/twitter]
Homepage http://devmoon.se
Stream http://twitch.tv/devmoon
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 hereif (point) {    *point = 10;}// or:if (!point) throw std::logic_error("Expected point");*point = 10;
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.
HardDrop - hard link shell extension."Tread softly because you tread on my dreams" - Yeats
well but the value doesnt need to be NULL
ill check msdn
Blekinge Institute of Technology
Twitter [twitter]devmoon[/twitter]
Homepage http://devmoon.se
Stream http://twitch.tv/devmoon
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.
HardDrop - hard link shell extension."Tread softly because you tread on my dreams" - Yeats
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 codeD3DXGetDriverLevel(test); // if crash it was NOT valid else its VALID'


any idea?
Blekinge Institute of Technology
Twitter [twitter]devmoon[/twitter]
Homepage http://devmoon.se
Stream http://twitch.tv/devmoon

This topic is closed to new replies.

Advertisement