瀏覽代碼

Use freopen() instead of low level API calls to redirect stdin & stdout to opened console window to fix crash on 64bit build. Closes #999.

Lasse Öörni 10 年之前
父節點
當前提交
12bac51e78
共有 1 個文件被更改,包括 3 次插入12 次删除
  1. 3 12
      Source/Urho3D/Core/ProcessUtils.cpp

+ 3 - 12
Source/Urho3D/Core/ProcessUtils.cpp

@@ -143,18 +143,9 @@ void OpenConsoleWindow()
         return;
         return;
 
 
     AllocConsole();
     AllocConsole();
-
-    HANDLE hOut = GetStdHandle(STD_OUTPUT_HANDLE);
-    int hCrt = _open_osfhandle((size_t)hOut, _O_TEXT);
-    FILE* outFile = _fdopen(hCrt, "w");
-    setvbuf(outFile, NULL, _IONBF, 1);
-    *stdout = *outFile;
-
-    HANDLE hIn = GetStdHandle(STD_INPUT_HANDLE);
-    hCrt = _open_osfhandle((size_t)hIn, _O_TEXT);
-    FILE* inFile = _fdopen(hCrt, "r");
-    setvbuf(inFile, NULL, _IONBF, 128);
-    *stdin = *inFile;
+    
+    freopen("CONIN$", "r", stdin);
+    freopen("CONOUT$", "w", stdout);
 
 
     consoleOpened = true;
     consoleOpened = true;
 #endif
 #endif