Last active
July 20, 2018 08:29
-
-
Save hexagit/dd8b09a67ed1627ae82da552e4106cf9 to your computer and use it in GitHub Desktop.
アクセス違反でゲームエンジンが落ちないようにしよう!構造化例外時に呼ばれる
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// とくに意味のない適当な関数 | |
void Exec() | |
{ | |
PrintScope scope("Exec"); | |
// 例外がいっぱい | |
ExceptionFactory::AccessViolation(); | |
//ExceptionFactory::DivideByZero(); | |
//ExceptionFactory::StackOverflow(); | |
} | |
// 構造化例外時に呼ばれる | |
void SE_TransFunc(unsigned int code, struct _EXCEPTION_POINTERS *ep) | |
{ | |
PrintScope scope("SE_TransFunc"); | |
// 適当に処理 | |
} | |
// メイン | |
int main(int argc, char *argv[]) | |
{ | |
// 構造化例外時に呼び出す関数を登録 | |
_set_se_translator(SE_TransFunc); | |
{ | |
PrintScope scope("Main"); | |
try { | |
PrintScope scope("Try"); | |
Exec(); | |
std::cout << "おわり" << std::endl; | |
} | |
catch( ... ) { | |
PrintScope scope("Catch"); | |
} | |
} | |
// デバッグ実行で、終了しないように無限ループ | |
for(;;)Sleep(1); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment