float *point;
try
{
*point = 10;
}
catch (...) { };
Finding Device (look last post)
hey why wont this code works??
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]
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?
i really want to find a way to jump over an error :/
is it not possible?
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.
okay so how would i avoid this error (continue without abort)
platform = XP PRO
device is a value but it doenst need to be a correct fixed device
it throws illegal operation..
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..
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.
But in your particular instance checking the device pointer before using it is probably a much better solution.
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.
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
any idea?
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?
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement