1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-09 13:22:24 +03:00

0027350: Support for Universal Windows Platform

- Toolchain file to configure a Visual Studio generator for a Windows 10 Universal Application was added (CMake).
- There is no support for environment variables in UWP.
- SID is not supported (were excluded).
- Windows registry is not supported (were excluded).
- Mess with usage of Unicode/ANSI was corrected.
- Added sample to check UWP functionality.
- Excluded usage of methods with Unicode characters where it is possible.
- Minor corrections to allow building OCAF (except TKVCAF) and DE (except VRML and XDE)
- Building of unsupported modules for UWP platform is off by default .
- Checking of DataExchange functionality was added to XAML (UWP) sample.
- Added information about UWP to the documentation.
- Update of results of merge with issue 27801
This commit is contained in:
ski
2016-08-12 18:38:48 +03:00
committed by abv
parent f3ec3b372c
commit 742cc8b01d
69 changed files with 1526 additions and 639 deletions

View File

@@ -33,7 +33,6 @@ class OSD_File;
class OSD_FileIterator;
class OSD_Directory;
class OSD_DirectoryIterator;
class OSD_Chronometer;
class OSD_Timer;
class OSD_Printer;
class OSD_Host;

View File

@@ -136,10 +136,15 @@ static inline __int64 EncodeFILETIME (PFILETIME pFt)
//=======================================================================
void OSD_Chronometer::GetProcessCPU (Standard_Real& UserSeconds, Standard_Real& SystemSeconds)
{
#ifndef OCCT_UWP
FILETIME ftStart, ftExit, ftKernel, ftUser;
::GetProcessTimes (GetCurrentProcess(), &ftStart, &ftExit, &ftKernel, &ftUser);
UserSeconds = 0.0000001 * EncodeFILETIME (&ftUser);
SystemSeconds = 0.0000001 * EncodeFILETIME (&ftKernel);
#else
UserSeconds = 0.0;
SystemSeconds = 0.0;
#endif
}
//=======================================================================
@@ -148,10 +153,15 @@ void OSD_Chronometer::GetProcessCPU (Standard_Real& UserSeconds, Standard_Real&
//=======================================================================
void OSD_Chronometer::GetThreadCPU (Standard_Real& UserSeconds, Standard_Real& SystemSeconds)
{
#ifndef OCCT_UWP
FILETIME ftStart, ftExit, ftKernel, ftUser;
::GetThreadTimes (GetCurrentThread(), &ftStart, &ftExit, &ftKernel, &ftUser);
UserSeconds = 0.0000001 * EncodeFILETIME (&ftUser);
SystemSeconds = 0.0000001 * EncodeFILETIME (&ftKernel);
#else
UserSeconds = 0.0;
SystemSeconds = 0.0;
#endif
}
#endif /* _WIN32 */

View File

@@ -84,6 +84,7 @@ char name[] = "/tmp/CSFXXXXXX";
#include <OSD_Protection.hxx>
#include <Standard_ProgramError.hxx>
#include <TCollection_ExtendedString.hxx>
#include <NCollection_String.hxx>
#include <OSD_WNT_1.hxx>
@@ -110,7 +111,7 @@ OSD_Directory :: OSD_Directory ( const OSD_Path& Name ) :
} // end constructor ( 2 )
void OSD_Directory :: Build (const OSD_Protection& Protect ) {
void OSD_Directory :: Build (const OSD_Protection& Protect) {
TCollection_AsciiString dirName;
@@ -118,15 +119,15 @@ void OSD_Directory :: Build (const OSD_Protection& Protect ) {
if ( dirName.IsEmpty () )
Standard_ProgramError :: Raise (
TEXT( "OSD_Directory :: Build (): incorrect call - no directory name" )
);
Standard_ProgramError :: Raise ( "OSD_Directory :: Build (): incorrect call - no directory name");
TCollection_ExtendedString dirNameW(dirName);
if ( Exists () || CreateDirectoryW ( (const wchar_t*) dirNameW.ToExtString (), NULL ) )
SetProtection ( Protect );
else
if (Exists() || CreateDirectoryW((const wchar_t*)dirNameW.ToExtString(), NULL)) {
#ifndef OCCT_UWP
SetProtection(Protect);
#else
(void)Protect;
#endif
} else
_osd_wnt_set_error ( myError, OSD_WDirectory );
@@ -136,7 +137,10 @@ OSD_Directory OSD_Directory :: BuildTemporary () {
OSD_Directory retVal;
OSD_Protection prt;
OSD_Path dirPath ( tctmpnam ( NULL ) );
wchar_t* aName = _wtmpnam(NULL);
NCollection_String aFolder(aName != NULL ? aName : L"");
OSD_Path dirPath(aFolder.ToCString());
retVal.SetPath ( dirPath );
retVal.Build ( prt );

View File

@@ -239,7 +239,7 @@ Standard_Boolean OSD_DirectoryIterator :: More () {
// make wchar_t string from UTF-8
TCollection_ExtendedString wcW(wc);
myHandle = FindFirstFileW ((const wchar_t*)wcW.ToExtString(), (PWIN32_FIND_DATAW)myData);
myHandle = FindFirstFileExW ((const wchar_t*)wcW.ToExtString(), FindExInfoStandard, (PWIN32_FIND_DATAW)myData, FindExSearchNameMatch, NULL, 0);
if ( myHandle == INVALID_HANDLE_VALUE )

View File

@@ -162,6 +162,8 @@ Standard_Integer OSD_Disk::Error()const{
#include <OSD_OSDError.hxx>
#include <OSD_Path.hxx>
#include <Standard_ProgramError.hxx>
#include <NCollection_String.hxx>
#include <TCollection_ExtendedString.hxx>
#include <windows.h>
@@ -170,14 +172,22 @@ void _osd_wnt_set_error ( OSD_Error&, OSD_WhoAmI, ... );
static void __fastcall _osd_wnt_set_disk_name ( TCollection_AsciiString&, const OSD_Path& );
OSD_Disk :: OSD_Disk () {
TCHAR cwd[ MAX_PATH ];
GetCurrentDirectory ( MAX_PATH, cwd );
cwd[ 3 ] = TEXT( '\x00' );
DiskName = cwd;
DWORD aBuffLen = GetCurrentDirectoryW(0, NULL);
wchar_t* aBuff = new wchar_t[size_t(aBuffLen) + 1];
GetCurrentDirectoryW(aBuffLen, aBuff);
aBuff[aBuffLen - 1] = (aBuff[aBuffLen - 2] == L'\\') ? L'\0' : L'\\';
aBuff[aBuffLen] = L'\0';
if (aBuffLen > 3 && aBuff[0] != L'\\')
{
aBuff[3] = L'\0';
NCollection_String aFolder(aBuff);
DiskName = aFolder.ToCString();
delete[] aBuff;
}
else
{
DiskName = "";
}
} // end constructor ( 1 )
OSD_Disk :: OSD_Disk ( const OSD_Path& Name ) {
@@ -223,8 +233,8 @@ Standard_Integer OSD_Disk :: DiskSize () {
ULARGE_INTEGER lpTotalNumberOfBytes; // receives the number of bytes on disk
ULARGE_INTEGER lpTotalNumberOfFreeBytes;// receives the free bytes on disk
if (!GetDiskFreeSpaceEx (DiskName.ToCString (),
TCollection_ExtendedString DiskNameW(DiskName);
if (!GetDiskFreeSpaceExW ((const wchar_t*)DiskNameW.ToExtString(),
&lpFreeBytesAvailableToCaller,
&lpTotalNumberOfBytes,
&lpTotalNumberOfFreeBytes))
@@ -261,8 +271,8 @@ Standard_Integer OSD_Disk :: DiskFree () {
ULARGE_INTEGER lpTotalNumberOfFreeBytes;// receives the free bytes on disk
// if ( !GetDiskFreeSpace ( DiskName.ToCString (), &dwSpC, &dwBpS, &dwFC, &dwC ) )
if (!GetDiskFreeSpaceEx (DiskName.ToCString (),
TCollection_ExtendedString DiskNameW(DiskName);
if (!GetDiskFreeSpaceExW((const wchar_t*)DiskNameW.ToExtString(),
&lpFreeBytesAvailableToCaller,
&lpTotalNumberOfBytes,
&lpTotalNumberOfFreeBytes))
@@ -349,26 +359,26 @@ static void __fastcall _osd_wnt_set_disk_name ( TCollection_AsciiString& result,
dir = path.Trek ();
if ( ( j = dir.UsefullLength () ) > 2 &&
dir.Value ( 1 ) == TEXT( '|' ) &&
dir.Value ( 2 ) == TEXT( '|' )
dir.Value ( 1 ) == '|' &&
dir.Value ( 2 ) == '|'
) {
dir.SetValue ( 1, TEXT( '\\' ) );
dir.SetValue ( 2, TEXT( '\\' ) );
dir.SetValue ( 1, '\\');
dir.SetValue ( 2, '\\');
for ( i = 3, k = 0; i <= j; ++i )
if ( dir.Value ( i ) == TEXT( '|' ) ) {
if ( dir.Value ( i ) == '|') {
if ( k == 0 ) {
dir.SetValue ( i, TEXT( "\\" ) );
dir.SetValue ( i, '\\');
++k;
continue;
} // end if
dir.SetValue ( i, TEXT( "\\" ) );
dir.SetValue ( i, '\\');
break;
} /* end if */
@@ -381,14 +391,14 @@ static void __fastcall _osd_wnt_set_disk_name ( TCollection_AsciiString& result,
else {
dir += TEXT( "\\" );
dir += '\\';
dir += path.Name ();
dir += path.Extension ();
} // end else
}
if ( dir.Value ( dir.UsefullLength () ) != TEXT( '\\' ) ) dir += TEXT( "\\" );
if ( dir.Value ( dir.UsefullLength () ) != '\\') dir += '\\';
result = dir;
@@ -398,7 +408,7 @@ badPath:
} // end else
} else result += TEXT( "/" );
} else result += '/';
} // end _osd_set_disk_name

View File

@@ -246,7 +246,9 @@ Standard_Integer OSD_Environment::Error() const
#pragma warning( disable : 4700 )
#endif
#ifndef OCCT_UWP
static void __fastcall _set_error ( OSD_Error&, DWORD );
#endif
OSD_Environment :: OSD_Environment () {
@@ -276,6 +278,7 @@ void OSD_Environment :: SetValue ( const TCollection_AsciiString& Value ) {
TCollection_AsciiString OSD_Environment::Value()
{
#ifndef OCCT_UWP
myValue.Clear();
SetLastError (ERROR_SUCCESS);
@@ -306,6 +309,10 @@ TCollection_AsciiString OSD_Environment::Value()
}
myValue = aValue.ToCString();
return myValue;
#else
myValue = "";
return myValue;
#endif
}
void OSD_Environment :: SetName ( const TCollection_AsciiString& name ) {
@@ -322,14 +329,18 @@ TCollection_AsciiString OSD_Environment :: Name () const {
void OSD_Environment::Build()
{
#ifndef OCCT_UWP
NCollection_Utf8String aSetVariable = NCollection_Utf8String(myName.ToCString()) + "=" + myValue.ToCString();
_wputenv (aSetVariable.ToUtfWide().ToCString());
#endif
}
void OSD_Environment::Remove()
{
#ifndef OCCT_UWP
NCollection_Utf8String aSetVariable = NCollection_Utf8String(myName.ToCString()) + "=";
_wputenv (aSetVariable.ToUtfWide().ToCString());
#endif
}
Standard_Boolean OSD_Environment :: Failed () const {
@@ -355,6 +366,7 @@ Standard_Integer OSD_Environment :: Error () const {
} // end OSD_Environment :: Error
#ifndef OCCT_UWP
static void __fastcall _set_error ( OSD_Error& err, DWORD code ) {
DWORD errCode;
@@ -377,5 +389,6 @@ static void __fastcall _set_error ( OSD_Error& err, DWORD code ) {
err.SetValue ( errCode, OSD_WEnvironment, buffer );
} // end _set_error
#endif
#endif

View File

@@ -449,6 +449,7 @@ void OSD_Error::Perror() {
#include <TCollection_ExtendedString.hxx>
#include <windows.h>
#include <Strsafe.h>
typedef struct _error_table {
@@ -570,82 +571,60 @@ OSD_Error :: OSD_Error () :
void OSD_Error :: Perror () {
Standard_Character buff[ 32 ];
Standard_CString ptr;
wchar_t buff[32];
lstrcpy ( buff, "Error ( " );
StringCchCopyW(buff, _countof(buff), L"Error ( ");
switch ( myCode ) {
case OSD_WDirectoryIterator:
ptr = "OSD_DirectoryIterator";
StringCchCatW(buff, _countof(buff), L"OSD_DirectoryIterator");
break;
case OSD_WDirectory:
ptr = "OSD_Directory";
StringCchCatW(buff, _countof(buff), L"OSD_Directory");
break;
case OSD_WFileIterator:
ptr = "OSD_FileIterator";
StringCchCatW(buff, _countof(buff), L"OSD_FileIterator");
break;
case OSD_WFile:
ptr = "OSD_File";
StringCchCatW(buff, _countof(buff), L"OSD_File");
break;
case OSD_WFileNode:
ptr = "OSD_FileNode";
StringCchCatW(buff, _countof(buff), L"OSD_FileNode");
break;
case OSD_WHost:
ptr = "OSD_Host";
StringCchCatW(buff, _countof(buff), L"OSD_Host");
break;
case OSD_WProcess:
ptr = "OSD_Environment";
StringCchCatW(buff, _countof(buff), L"OSD_Environment");
break;
case OSD_WEnvironmentIterator:
ptr = "OSD_EnvironmentIterator";
StringCchCatW(buff, _countof(buff), L"OSD_EnvironmentIterator");
break;
case OSD_WEnvironment:
ptr = "OSD_Environment";
StringCchCatW(buff, _countof(buff), L"OSD_Environment");
break;
case OSD_WDisk:
ptr = "OSD_Disk";
StringCchCatW(buff, _countof(buff), L"OSD_Disk");
break;
default:
ptr = "Unknown";
StringCchCatW(buff, _countof(buff), L"Unknown");
} // end switch
lstrcat ( buff, ptr );
lstrcat ( buff, " )" );
std::cerr << buff;
StringCchCatW(buff, _countof(buff), L" )");
std::wcerr << buff;
std::cerr << myMessage.ToCString() << std::endl << std::flush;

View File

@@ -839,6 +839,8 @@ void OSD_File::Rewind() {
# include <tchar.h>
#endif // _INC_TCHAR
#include <Strsafe.h>
#if defined(__CYGWIN32__) || defined(__MINGW32__)
#define VAC
#endif
@@ -858,15 +860,16 @@ void OSD_File::Rewind() {
#define OPEN_APPEND 2
void _osd_wnt_set_error ( OSD_Error&, OSD_WhoAmI, ... );
#ifndef OCCT_UWP
PSECURITY_DESCRIPTOR __fastcall _osd_wnt_protection_to_sd ( const OSD_Protection&, BOOL, wchar_t* = NULL );
BOOL __fastcall _osd_wnt_sd_to_protection (
PSECURITY_DESCRIPTOR, OSD_Protection&, BOOL
);
BOOL __fastcall _osd_print (const Standard_PCharacter, const wchar_t* );
static int __fastcall _get_buffer(HANDLE, Standard_PCharacter&, DWORD, BOOL, BOOL);
#endif
static void __fastcall _test_raise ( HANDLE, Standard_CString );
static Standard_Integer __fastcall _get_line (Standard_PCharacter& buffer, DWORD dwBuffSize, LONG& theSeekPos);
static int __fastcall _get_buffer ( HANDLE, Standard_PCharacter&, DWORD, BOOL, BOOL );
static DWORD __fastcall _get_access_mask ( OSD_SingleProtection );
static DWORD __fastcall _get_dir_access_mask ( OSD_SingleProtection prt );
static HANDLE __fastcall _open_file ( Standard_CString, OSD_OpenMode, DWORD, LPBOOL = NULL );
@@ -942,7 +945,9 @@ int OSD_File::Capture(int theDescr) {
}
void OSD_File::Rewind() {
SetFilePointer( myFileHandle, 0, NULL, FILE_BEGIN );
LARGE_INTEGER aDistanceToMove = { 0 };
aDistanceToMove.QuadPart = 0;
SetFilePointerEx(myFileHandle, aDistanceToMove, NULL, FILE_BEGIN);
}
// protect against occasional use of myFileHande in Windows code
@@ -952,9 +957,7 @@ void OSD_File::Rewind() {
// Build a file if it doesn't exist or create again if it already exists
// ---------------------------------------------------------------------
void OSD_File :: Build (
const OSD_OpenMode Mode, const OSD_Protection& Protect
) {
void OSD_File :: Build ( const OSD_OpenMode Mode, const OSD_Protection& Protect) {
TCollection_AsciiString fName;
@@ -980,8 +983,11 @@ void OSD_File :: Build (
_osd_wnt_set_error ( myError, OSD_WFile );
else {
#ifndef OCCT_UWP
SetProtection ( Protect );
#else
(void)Protect;
#endif
myIO |= FLAG_FILE;
} // end else
@@ -1027,9 +1033,7 @@ void OSD_File :: Open (const OSD_OpenMode Mode, const OSD_Protection& /*Protect*
// Append to an existing file
// ---------------------------------------------------------------------
void OSD_File :: Append (
const OSD_OpenMode Mode, const OSD_Protection& Protect
) {
void OSD_File :: Append ( const OSD_OpenMode Mode, const OSD_Protection& Protect) {
BOOL fNew = FALSE;
TCollection_AsciiString fName;
@@ -1059,8 +1063,11 @@ void OSD_File :: Append (
Seek ( 0, OSD_FromEnd );
} else {
SetProtection ( Protect );
#ifndef OCCT_UWP
SetProtection ( Protect );
#else
(void)Protect;
#endif
myIO |= FLAG_FILE;
} // end else
@@ -1170,12 +1177,13 @@ void OSD_File :: ReadLine (
} else if ( dwDummy != 0 ) { // end-of-file reached ?
if ( peekChar != '\n' ) // if we did not get a <CR><LF> sequence
// adjust file position
SetFilePointer (myFileHandle, -1, NULL, FILE_CURRENT);
if (peekChar != '\n') // if we did not get a <CR><LF> sequence
{
// adjust file position
LARGE_INTEGER aDistanceToMove = { 0 };
aDistanceToMove.QuadPart = -1;
SetFilePointerEx(myFileHandle, aDistanceToMove, NULL, FILE_CURRENT);
}
} else
myIO |= FLAG_EOF;
@@ -1183,13 +1191,15 @@ void OSD_File :: ReadLine (
} else if ( aSeekPos != 0 )
{
SetFilePointer (myFileHandle, aSeekPos, NULL, FILE_CURRENT);
LARGE_INTEGER aDistanceToMove = { 0 };
aDistanceToMove.QuadPart = aSeekPos;
SetFilePointerEx(myFileHandle, aDistanceToMove, NULL, FILE_CURRENT);
}
} // end else
} else if ( myIO & FLAG_SOCKET || myIO & FLAG_PIPE || myIO & FLAG_NAMED_PIPE ) {
#ifndef OCCT_UWP
dwBytesRead = (DWORD)_get_buffer (myFileHandle, cBuffer,
(DWORD)NByte, TRUE, myIO & FLAG_SOCKET);
@@ -1241,7 +1251,7 @@ void OSD_File :: ReadLine (
delete [] cDummyBuffer ;
} // end else
#endif
} else
RAISE( "OSD_File :: ReadLine (): incorrect call - file is a directory" );
@@ -1360,8 +1370,10 @@ void OSD_File :: Seek (
RAISE( "OSD_File :: Seek (): invalid parameter" );
} // end switch
LARGE_INTEGER aDistanceToMove, aNewFilePointer = { 0 };
aDistanceToMove.QuadPart = Offset;
if (SetFilePointer (myFileHandle, (LONG)Offset, NULL, dwMoveMethod) == 0xFFFFFFFF)
if (!SetFilePointerEx(myFileHandle, aDistanceToMove, &aNewFilePointer, dwMoveMethod))
_osd_wnt_set_error ( myError, OSD_WFile );
@@ -1464,9 +1476,13 @@ typedef struct _osd_wnt_key {
void OSD_File::BuildTemporary () {
OSD_Protection prt;
HKEY hKey;
TCHAR tmpPath[ MAX_PATH ];
wchar_t tmpPath[ MAX_PATH ];
BOOL fOK = FALSE;
// Windows Registry not supported by UWP
#ifndef OCCT_UWP
HKEY hKey;
OSD_WNT_KEY regKey[ 2 ] = {
{ HKEY_LOCAL_MACHINE,
@@ -1488,25 +1504,25 @@ typedef struct _osd_wnt_key {
DWORD dwType;
DWORD dwSize = 0;
if ( RegQueryValueEx (
hKey, "TEMP", NULL, &dwType, NULL, &dwSize
if ( RegQueryValueExW (
hKey, L"TEMP", NULL, &dwType, NULL, &dwSize
) == ERROR_SUCCESS
) {
LPTSTR kVal = ( LPTSTR )HeapAlloc (
wchar_t* kVal = (wchar_t*)HeapAlloc (
GetProcessHeap (), HEAP_ZERO_MEMORY | HEAP_GENERATE_EXCEPTIONS,
dwSize + sizeof ( TCHAR )
dwSize + sizeof (wchar_t)
);
RegQueryValueEx ( hKey, "TEMP", NULL, &dwType, ( LPBYTE )kVal, &dwSize );
RegQueryValueExW ( hKey, L"TEMP", NULL, &dwType, ( LPBYTE )kVal, &dwSize );
if ( dwType == REG_EXPAND_SZ )
ExpandEnvironmentStrings ( kVal, tmpPath, MAX_PATH );
ExpandEnvironmentStringsW ( kVal, tmpPath, MAX_PATH );
else
lstrcpy ( tmpPath, kVal );
StringCchCopyW (tmpPath, _countof(tmpPath), kVal);
HeapFree ( GetProcessHeap (), 0, ( LPVOID )kVal );
fOK = TRUE;
@@ -1520,15 +1536,21 @@ typedef struct _osd_wnt_key {
if ( fOK ) break;
} // end for
#else
if (GetTempPathW(_countof(tmpPath), tmpPath))
fOK = TRUE;
#endif
if ( !fOK ) StringCchCopyW(tmpPath, _countof(tmpPath), L"./");
if ( !fOK ) lstrcpy ( tmpPath, "./" );
GetTempFileName ( tmpPath, "CSF", 0, tmpPath );
GetTempFileNameW ( tmpPath, L"CSF", 0, tmpPath );
if ( IsOpen() )
Close();
SetPath ( OSD_Path ( tmpPath ) );
char tmpPathA[MAX_PATH];
WideCharToMultiByte(CP_UTF8, 0, tmpPath, -1, tmpPathA, sizeof(tmpPathA), NULL, NULL);
SetPath(OSD_Path(tmpPathA));
Build ( OSD_ReadWrite, prt );
} // end OSD_File :: BuildTemporary
@@ -1598,8 +1620,12 @@ void OSD_File :: UnLock () {
LARGE_INTEGER aSize;
aSize.QuadPart = Size();
if (!UnlockFile (myFileHandle, 0, 0, aSize.LowPart, aSize.HighPart))
OVERLAPPED anOverlappedArea;
anOverlappedArea.Offset = 0;
anOverlappedArea.OffsetHigh = 0;
if (!UnlockFileEx(myFileHandle, 0, aSize.LowPart, aSize.HighPart,&anOverlappedArea))
_osd_wnt_set_error ( myError, OSD_WFile );
ImperativeFlag = Standard_False;
@@ -1651,9 +1677,8 @@ Standard_Size OSD_File::Size()
// --------------------------------------------------------------------------
// Print contains of a file
// --------------------------------------------------------------------------
void OSD_File :: Print ( const OSD_Printer& WhichPrinter ) {
void OSD_File :: Print ( const OSD_Printer& WhichPrinter) {
#ifndef OCCT_UWP
if (myFileHandle != INVALID_HANDLE_VALUE)
RAISE( "OSD_File :: Print (): incorrect call - file opened" );
@@ -1668,9 +1693,10 @@ void OSD_File :: Print ( const OSD_Printer& WhichPrinter ) {
(const wchar_t*)fNameW.ToExtString () ) )
_osd_wnt_set_error ( myError, OSD_WFile );
#else
(void)WhichPrinter;
#endif
} // end OSD_File :: Print
// --------------------------------------------------------------------------
// Test if a file is open
// --------------------------------------------------------------------------
@@ -1687,6 +1713,7 @@ Standard_Boolean OSD_File :: IsOpen () const {
#define __leave return retVal
#endif
#ifndef OCCT_UWP
PSECURITY_DESCRIPTOR __fastcall _osd_wnt_protection_to_sd (
const OSD_Protection& prot, BOOL fDir, wchar_t* fName
) {
@@ -1945,6 +1972,7 @@ leave: ; // added for VisualAge
return retVal;
} // end _osd_wnt_protection_to_sd */
#endif
#if defined(__CYGWIN32__) || defined(__MINGW32__)
#undef __try
@@ -1954,17 +1982,13 @@ leave: ; // added for VisualAge
static void __fastcall _test_raise ( HANDLE hFile, Standard_CString str ) {
Standard_Character buff[ 64 ];
if (hFile == INVALID_HANDLE_VALUE) {
TCollection_AsciiString buff = "OSD_File :: ";
buff += str;
buff += " (): wrong access";
if (hFile == INVALID_HANDLE_VALUE) {
strcpy ( buff, "OSD_File :: " );
strcat ( buff, str );
strcat ( buff, " (): wrong access" );
Standard_ProgramError :: Raise ( buff );
} // end if
Standard_ProgramError::Raise(buff.ToCString());
} // end if
} // end _test_raise
@@ -2006,6 +2030,7 @@ static Standard_Integer __fastcall _get_line (Standard_PCharacter& buffer, DWORD
return dwBuffSize;
} // end _get_line
#ifndef OCCT_UWP
static int __fastcall _get_buffer (
HANDLE hChannel,
Standard_PCharacter& buffer,
@@ -2283,7 +2308,7 @@ static DWORD __fastcall _get_dir_access_mask ( OSD_SingleProtection prt ) {
return retVal;
} // end _get_dir_access_mask
#endif
static HANDLE __fastcall _open_file (
Standard_CString fName,
OSD_OpenMode oMode,
@@ -2324,12 +2349,24 @@ static HANDLE __fastcall _open_file (
// make wide character string from UTF-8
TCollection_ExtendedString fNameW(fName, Standard_True);
#ifndef OCCT_UWP
retVal = CreateFileW (
(const wchar_t*) fNameW.ToExtString(), dwDesiredAccess,
FILE_SHARE_READ | FILE_SHARE_WRITE,
NULL, dwCreationDistribution, FILE_ATTRIBUTE_NORMAL, NULL
);
#else
CREATEFILE2_EXTENDED_PARAMETERS pCreateExParams = {};
pCreateExParams.dwSize = sizeof(CREATEFILE2_EXTENDED_PARAMETERS);
pCreateExParams.dwFileAttributes = FILE_ATTRIBUTE_NORMAL;
pCreateExParams.lpSecurityAttributes = NULL;
pCreateExParams.hTemplateFile = NULL;
retVal = CreateFile2 (
(const wchar_t*) fNameW.ToExtString(), dwDesiredAccess,
FILE_SHARE_READ | FILE_SHARE_WRITE,
dwCreationDistribution, &pCreateExParams
);
#endif
if ( retVal == INVALID_HANDLE_VALUE &&
dwOptions == OPEN_APPEND &&
GetLastError () == ERROR_FILE_NOT_FOUND
@@ -2337,12 +2374,24 @@ static HANDLE __fastcall _open_file (
dwCreationDistribution = CREATE_ALWAYS;
#ifndef OCCT_UWP
retVal = CreateFileW (
(const wchar_t*) fNameW.ToExtString(), dwDesiredAccess,
FILE_SHARE_READ | FILE_SHARE_WRITE,
NULL, dwCreationDistribution, FILE_ATTRIBUTE_NORMAL, NULL
);
#else
CREATEFILE2_EXTENDED_PARAMETERS pCreateExParams2 = {};
pCreateExParams2.dwSize = sizeof(CREATEFILE2_EXTENDED_PARAMETERS);
pCreateExParams2.dwFileAttributes = FILE_ATTRIBUTE_NORMAL;
pCreateExParams2.lpSecurityAttributes = NULL;
pCreateExParams2.hTemplateFile = NULL;
retVal = CreateFile2(
(const wchar_t*)fNameW.ToExtString(), dwDesiredAccess,
FILE_SHARE_READ | FILE_SHARE_WRITE,
dwCreationDistribution, &pCreateExParams2
);
#endif
*fNew = TRUE;
@@ -2357,7 +2406,6 @@ Standard_Integer __fastcall _get_file_type (
) {
Standard_Integer retVal = 0;
DWORD dwType;
int fileType;
fileType = (fileHandle == INVALID_HANDLE_VALUE ?
@@ -2375,10 +2423,11 @@ Standard_Integer __fastcall _get_file_type (
{
// make wide character string from UTF-8
TCollection_ExtendedString fNameW(fName, Standard_True);
dwType = GetFileAttributesW ( (const wchar_t*) fNameW.ToExtString() );
if ( dwType != 0xFFFFFFFF )
retVal = dwType & FILE_ATTRIBUTE_DIRECTORY ? FLAG_DIRECTORY : FLAG_FILE;
WIN32_FILE_ATTRIBUTE_DATA aFileInfo;
if (GetFileAttributesExW((const wchar_t*)fNameW.ToExtString(), GetFileExInfoStandard, &aFileInfo))
retVal = aFileInfo.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY ? FLAG_DIRECTORY : FLAG_FILE;
else
@@ -2410,6 +2459,8 @@ Standard_Integer __fastcall _get_file_type (
#define __leave return retVal
#endif
#ifndef OCCT_UWP
// None of the existing security APIs are supported in a UWP applications
BOOL __fastcall _osd_wnt_sd_to_protection (
PSECURITY_DESCRIPTOR pSD, OSD_Protection& prot, BOOL fDir
) {
@@ -2495,13 +2546,14 @@ leave: ; // added for VisualAge
return retVal;
} // end _osd_wnt_sd_to_protection
#endif
#if defined(__CYGWIN32__) || defined(__MINGW32__)
#undef __try
#undef __finally
#undef __leave
#endif
#ifndef OCCT_UWP
static OSD_SingleProtection __fastcall _get_protection ( DWORD mask ) {
OSD_SingleProtection retVal;
@@ -2717,6 +2769,7 @@ static OSD_SingleProtection __fastcall _get_protection_dir ( DWORD mask ) {
return retVal;
} // end _get_protection_dir
#endif
#if defined(__CYGWIN32__) || defined(__MINGW32__)
#define __try
@@ -2724,6 +2777,7 @@ static OSD_SingleProtection __fastcall _get_protection_dir ( DWORD mask ) {
#define __leave return fOK
#endif
#ifndef OCCT_UWP
BOOL __fastcall _osd_print (const Standard_PCharacter pName, const wchar_t* fName ) {
BOOL fOK, fJob;
@@ -2802,6 +2856,7 @@ leave: ; // added for VisualAge
return fOK;
} // end _osd_print
#endif
#if defined(__CYGWIN32__) || defined(__MINGW32__)
#undef __try

View File

@@ -317,7 +317,7 @@ Standard_Boolean OSD_FileIterator :: More () {
// make wchar_t string from UTF-8
TCollection_ExtendedString wcW(wc);
myHandle = FindFirstFileW ((const wchar_t*)wcW.ToExtString(), (PWIN32_FIND_DATAW)myData);
myHandle = FindFirstFileExW((const wchar_t*)wcW.ToExtString(), FindExInfoStandard, (PWIN32_FIND_DATAW)myData, FindExSearchNameMatch, NULL, 0);
if ( myHandle == INVALID_HANDLE_VALUE )

View File

@@ -363,6 +363,11 @@ Standard_Integer OSD_FileNode::Error()const{
//----------------------------------------------------------------------------
#define STRICT
#ifdef NONLS
#undef NONLS
#endif
#include <windows.h>
#include <OSD_FileNode.hxx>
#include <OSD_Protection.hxx>
#include <Quantity_Date.hxx>
@@ -375,13 +380,18 @@ Standard_Integer OSD_FileNode::Error()const{
# include <tchar.h>
#endif // _INC_TCHAR
#include <Strsafe.h>
#define TEST_RAISE( arg ) _test_raise ( fName, ( arg ) )
#define RAISE( arg ) Standard_ProgramError :: Raise ( ( arg ) )
#ifndef OCCT_UWP
// None of the existing security APIs are supported in a UWP applications
PSECURITY_DESCRIPTOR __fastcall _osd_wnt_protection_to_sd ( const OSD_Protection&, BOOL, wchar_t* = NULL );
BOOL __fastcall _osd_wnt_sd_to_protection (
PSECURITY_DESCRIPTOR pSD, OSD_Protection& prot, BOOL
);
#endif
Standard_Integer __fastcall _get_file_type ( Standard_CString, HANDLE );
void _osd_wnt_set_error ( OSD_Error&, OSD_WhoAmI, ... );
@@ -447,12 +457,14 @@ Standard_Boolean OSD_FileNode::Exists () {
// make wide character string from UTF-8
TCollection_ExtendedString fNameW(fName);
if ( GetFileAttributesW ( (const wchar_t*) fNameW.ToExtString () ) == 0xFFFFFFFF ) {
if ( GetLastError () != ERROR_FILE_NOT_FOUND )
_osd_wnt_set_error ( myError, OSD_WFileNode, fName.ToCString () );
WIN32_FILE_ATTRIBUTE_DATA aFileInfo;
if ( !GetFileAttributesExW((const wchar_t*)fNameW.ToExtString(), GetFileExInfoStandard, &aFileInfo)) {
if ( GetLastError () != ERROR_FILE_NOT_FOUND )
_osd_wnt_set_error(myError, OSD_WFileNode, (const wchar_t*)fNameW.ToExtString());
} else
retVal = Standard_True;
@@ -480,9 +492,7 @@ void OSD_FileNode::Remove () {
case FLAG_FILE:
if ( !DeleteFileW ( (const wchar_t*) fNameW.ToExtString () ) )
_osd_wnt_set_error ( myError, OSD_WFileNode, fName.ToCString () );
_osd_wnt_set_error ( myError, OSD_WFileNode, (const wchar_t*)fNameW.ToExtString());
break;
case FLAG_DIRECTORY:
@@ -492,16 +502,11 @@ void OSD_FileNode::Remove () {
// ne pas detruire un repertoire no vide.
if ( !RemoveDirectoryW ( (const wchar_t*) fNameW.ToExtString () ) )
_osd_wnt_set_error ( myError, OSD_WFileNode, fName.ToCString () );
_osd_wnt_set_error ( myError, OSD_WFileNode, (const wchar_t*)fNameW.ToExtString());
break;
default:
RAISE( TEXT( "OSD_FileNode :: Remove ():"
" invalid file type - neither file nor directory" ) );
RAISE("OSD_FileNode :: Remove (): invalid file type - neither file nor directory");
} // end switch
} // end OSD_FileNode :: Remove
@@ -533,9 +538,7 @@ void OSD_FileNode::Move ( const OSD_Path& NewPath ) {
MOVEFILE_REPLACE_EXISTING | MOVEFILE_COPY_ALLOWED
)
)
_osd_wnt_set_error ( myError, OSD_WFileNode,
fName.ToCString (), fNameDst.ToCString () );
_osd_wnt_set_error(myError, OSD_WFileNode, (const wchar_t*)fNameW.ToExtString(), (const wchar_t*)fNameDstW.ToExtString());
break;
case FLAG_DIRECTORY:
@@ -544,17 +547,11 @@ void OSD_FileNode::Move ( const OSD_Path& NewPath ) {
(const wchar_t*) fNameW.ToExtString (), (const wchar_t*) fNameDstW.ToExtString ()
)
)
_osd_wnt_set_error ( myError, OSD_WFileNode,
fName.ToCString (), fNameDst.ToCString () );
_osd_wnt_set_error(myError, OSD_WFileNode, (const wchar_t*)fNameW.ToExtString(), (const wchar_t*)fNameDstW.ToExtString());
break;
default:
RAISE( TEXT( "OSD_FileNode :: Move (): "
"invalid file type - neither file nor directory" ) );
RAISE("OSD_FileNode :: Move (): invalid file type - neither file nor directory");
} // end switch
} // end OSD_FileNode :: Move
@@ -580,11 +577,14 @@ void OSD_FileNode::Copy ( const OSD_Path& ToPath ) {
switch (_get_file_type (fName.ToCString(), INVALID_HANDLE_VALUE)) {
case FLAG_FILE:
if (!CopyFileW ((const wchar_t*)fNameW.ToExtString (),
(const wchar_t*)fNameDstW.ToExtString (), FALSE ))
_osd_wnt_set_error (myError, OSD_WFileNode,
fName.ToCString (), fNameDst.ToCString ());
#ifndef OCCT_UWP
if (!CopyFileW((const wchar_t*)fNameW.ToExtString(),
(const wchar_t*)fNameDstW.ToExtString(), FALSE))
#else
if (CopyFile2((const wchar_t*)fNameW.ToExtString (),
(const wchar_t*)fNameDstW.ToExtString (), FALSE ) != S_OK)
#endif
_osd_wnt_set_error(myError, OSD_WFileNode, (const wchar_t*)fNameW.ToExtString(), (const wchar_t*)fNameDstW.ToExtString());
break;
case FLAG_DIRECTORY:
@@ -593,22 +593,21 @@ void OSD_FileNode::Copy ( const OSD_Path& ToPath ) {
(const wchar_t*)fNameW.ToExtString (), (const wchar_t*)fNameDstW.ToExtString ()
)
)
_osd_wnt_set_error (
myError, OSD_WFileNode, fName.ToCString (), fNameDst.ToCString ()
);
_osd_wnt_set_error(myError, OSD_WFileNode, (const wchar_t*)fNameW.ToExtString(), (const wchar_t*)fNameDstW.ToExtString());
break;
default:
RAISE( TEXT( "OSD_FileNode :: Copy ():"
" invalid file type - neither file nor directory" ) );
RAISE("OSD_FileNode :: Copy (): invalid file type - neither file nor directory");
} // end switch
} // end OSD_FileNode :: Copy
// None of the existing security APIs are supported in a UWP applications
#ifndef OCCT_UWP
//=======================================================================
//function : Protection
//purpose :
@@ -671,8 +670,7 @@ void OSD_FileNode::SetProtection ( const OSD_Protection& Prot ) {
(const wchar_t*) fNameW.ToExtString (), DACL_SECURITY_INFORMATION, pSD
)
)
_osd_wnt_set_error ( myError, OSD_WFileNode, fName.ToCString () );
_osd_wnt_set_error ( myError, OSD_WFileNode, (const wchar_t*)fNameW.ToExtString());
if ( pSD != NULL )
@@ -680,6 +678,46 @@ void OSD_FileNode::SetProtection ( const OSD_Protection& Prot ) {
} // end OSD_FileNode :: SetProtection
#else /* UWP stub */
#include <io.h>
//=======================================================================
//function : Protection
//purpose :
//=======================================================================
OSD_Protection OSD_FileNode::Protection ()
{
TCollection_AsciiString fName;
myPath.SystemName ( fName );
TCollection_ExtendedString fNameW(fName);
OSD_SingleProtection aProt = OSD_None;
if (_waccess_s ((const wchar_t*)fNameW.ToExtString(), 6))
aProt = OSD_RW;
else if (_waccess_s ((const wchar_t*)fNameW.ToExtString(), 2))
aProt = OSD_W;
else if (_waccess_s ((const wchar_t*)fNameW.ToExtString(), 4))
aProt = OSD_R;
// assume full access for system and none for everybody
OSD_Protection retVal (OSD_RWXD, aProt, aProt, OSD_None);
return retVal;
} // end OSD_FileNode :: Protection
//=======================================================================
//function : SetProtection
//purpose :
//=======================================================================
void OSD_FileNode::SetProtection ( const OSD_Protection& /*Prot*/ )
{
} // end OSD_FileNode :: SetProtection
#endif
//=======================================================================
//function : AccessMoment
//purpose :
@@ -714,8 +752,7 @@ Quantity_Date OSD_FileNode::AccessMoment () {
);
}
else
_osd_wnt_set_error ( myError, OSD_WFileNode, fName.ToCString () );
_osd_wnt_set_error ( myError, OSD_WFileNode, (const wchar_t*)fNameW.ToExtString());
return retVal;
@@ -755,8 +792,7 @@ Quantity_Date OSD_FileNode::CreationMoment () {
);
}
else
_osd_wnt_set_error ( myError, OSD_WFileNode, fName.ToCString () );
_osd_wnt_set_error ( myError, OSD_WFileNode, (const wchar_t*)fNameW.ToExtString());
return retVal;
@@ -809,26 +845,30 @@ Standard_Integer OSD_FileNode::Error () const {
void _osd_wnt_set_error ( OSD_Error& err, OSD_WhoAmI who, ... ) {
DWORD errCode;
Standard_Character buffer[ 2048 ];
wchar_t buffer[2048];
va_list arg_ptr;
va_start ( arg_ptr, who);
errCode = GetLastError ();
if ( !FormatMessage (
FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_ARGUMENT_ARRAY,
if ( !FormatMessageW (
FORMAT_MESSAGE_FROM_SYSTEM,
0, errCode, MAKELANGID( LANG_NEUTRAL, SUBLANG_NEUTRAL ),
buffer, 2048, &arg_ptr
)
) {
sprintf ( buffer, "error code %d", (Standard_Integer)errCode );
StringCchPrintfW(buffer, _countof(buffer), L"error code %d", (Standard_Integer)errCode);
SetLastError ( errCode );
} // end if
err.SetValue ( errCode, who, buffer );
char aBufferA[2048];
WideCharToMultiByte(CP_UTF8, 0, buffer, -1, aBufferA, sizeof(aBufferA), NULL, NULL);
err.SetValue(errCode, who, aBufferA);
va_end ( arg_ptr );
@@ -851,11 +891,23 @@ static BOOL __fastcall _get_file_time (
HANDLE hFile = INVALID_HANDLE_VALUE;
__try {
if ( ( hFile = CreateFileW ((const wchar_t*) fName, 0, 0,
NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL)
) == INVALID_HANDLE_VALUE
) __leave;
#ifndef OCCT_UWP
if ((hFile = CreateFileW((const wchar_t*)fName, 0, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL)
) == INVALID_HANDLE_VALUE
)
#else
CREATEFILE2_EXTENDED_PARAMETERS pCreateExParams = {};
pCreateExParams.dwSize = sizeof(CREATEFILE2_EXTENDED_PARAMETERS);
pCreateExParams.dwFileAttributes = FILE_ATTRIBUTE_NORMAL;
pCreateExParams.lpSecurityAttributes = NULL;
pCreateExParams.hTemplateFile = NULL;
if ((hFile = CreateFile2(
(const wchar_t*)fName, NULL, NULL,
OPEN_EXISTING, &pCreateExParams)
) == INVALID_HANDLE_VALUE
)
#endif
__leave;
if ( !GetFileTime ( hFile, &ftCreationTime, NULL, &ftLastWriteTime ) ) __leave;
@@ -890,17 +942,12 @@ leave: ; // added for VisualAge
#endif
static void __fastcall _test_raise ( TCollection_AsciiString fName, Standard_CString str ) {
Standard_Character buff[ 64 ];
if ( fName.IsEmpty () ) {
strcpy ( buff, "OSD_FileNode :: " );
strcat ( buff, str );
strcat ( buff, " (): wrong access" );
TCollection_AsciiString buff = "OSD_FileNode :: ";
buff += str;
buff += " (): wrong access";
Standard_ProgramError :: Raise ( buff );
Standard_ProgramError::Raise(buff.ToCString());
} // end if
} // end _test_raise

View File

@@ -57,13 +57,14 @@ public:
//! Copies <me> to another FileNode
Standard_EXPORT void Copy (const OSD_Path& ToPath);
// None of the existing security APIs are supported in a UWP applications
//! Returns access mode of <me>.
Standard_EXPORT OSD_Protection Protection();
//! Changes protection of the FileNode
Standard_EXPORT void SetProtection (const OSD_Protection& Prot);
//! Returns last write access.
//! On UNIX, AccessMoment and CreationMoment return the
//! same value.

View File

@@ -200,7 +200,7 @@ static TCollection_AsciiString interAddr;
static Standard_Integer memSize;
OSD_Host :: OSD_Host () {
#ifndef OCCT_UWP
DWORD nSize;
Standard_Character szHostName[ MAX_COMPUTERNAME_LENGTH + 1 ];
char* hostAddr = 0;
@@ -280,7 +280,7 @@ OSD_Host :: OSD_Host () {
if ( fInit )
myName = hostName;
#endif
} // end constructor
TCollection_AsciiString OSD_Host :: SystemVersion () {

View File

@@ -57,7 +57,7 @@ void OSD_MemInfo::Update()
{
myCounters[anIter] = Standard_Size(-1);
}
#ifndef OCCT_UWP
#if defined(_WIN32)
#if (_WIN32_WINNT >= 0x0500)
MEMORYSTATUSEX aStatEx;
@@ -167,6 +167,7 @@ void OSD_MemInfo::Update()
myCounters[MemHeapUsage] = aStats.size_in_use;
}
#endif
#endif
}
// =======================================================================

View File

@@ -30,13 +30,14 @@
#endif
#endif
#ifdef _WIN32
#if defined(_WIN32) && !defined(OCCT_UWP)
namespace {
// for a 64-bit app running under 64-bit Windows, this is FALSE
static bool isWow64()
{
typedef BOOL (WINAPI *LPFN_ISWOW64PROCESS) (HANDLE , PBOOL);
BOOL bIsWow64 = FALSE;
HMODULE aKern32Module = GetModuleHandleW(L"kernel32");
LPFN_ISWOW64PROCESS aFunIsWow64 = (aKern32Module == NULL) ? (LPFN_ISWOW64PROCESS )NULL
: (LPFN_ISWOW64PROCESS)GetProcAddress(aKern32Module, "IsWow64Process");
@@ -62,11 +63,14 @@ Standard_Integer OSD_Parallel::NbLogicalProcessors()
#ifdef _WIN32
// GetSystemInfo() will return the number of processors in a data field in a SYSTEM_INFO structure.
SYSTEM_INFO aSysInfo;
#ifndef OCCT_UWP
if ( isWow64() )
{
typedef BOOL (WINAPI *LPFN_GSI)(LPSYSTEM_INFO );
HMODULE aKern32 = GetModuleHandleW(L"kernel32");
LPFN_GSI aFuncSysInfo = (LPFN_GSI )GetProcAddress(aKern32, "GetNativeSystemInfo");
// So, they suggest 32-bit apps should call this instead of the other in WOW64
if ( aFuncSysInfo != NULL )
{
@@ -81,6 +85,9 @@ Standard_Integer OSD_Parallel::NbLogicalProcessors()
{
GetSystemInfo(&aSysInfo);
}
#else
GetNativeSystemInfo(&aSysInfo);
#endif
aNumLogicalProcessors = aSysInfo.dwNumberOfProcessors;
#else
// These are the choices. We'll check number of processors online.

View File

@@ -210,7 +210,7 @@ OSD_Process :: OSD_Process () {
Standard_Integer OSD_Process::Spawn (const TCollection_AsciiString& cmd,
const Standard_Boolean ShowWindow /* = Standard_True */) {
#ifndef OCCT_UWP
STARTUPINFO si;
PROCESS_INFORMATION pi;
DWORD aRes = 0;
@@ -248,6 +248,11 @@ Standard_Integer OSD_Process::Spawn (const TCollection_AsciiString& cmd,
} // end else
return aRes;
#else
(void)cmd;
(void)ShowWindow;
return 0;
#endif
} // end OSD_Process :: Spawn
void OSD_Process :: TerminalType ( TCollection_AsciiString& Name ) {
@@ -273,6 +278,7 @@ Quantity_Date OSD_Process :: SystemDate () {
TCollection_AsciiString OSD_Process :: UserName ()
{
#ifndef OCCT_UWP
Standard_PCharacter pBuff = new char[UNLEN + 1];
DWORD dwSize = UNLEN + 1;
TCollection_AsciiString retVal;
@@ -287,10 +293,13 @@ TCollection_AsciiString OSD_Process :: UserName ()
}
delete [] pBuff;
return retVal;
#else
return "";
#endif
} // end OSD_Process :: UserName
Standard_Boolean OSD_Process :: IsSuperUser () {
#ifndef OCCT_UWP
Standard_Boolean retVal = FALSE;
PSID pSIDadmin;
HANDLE hProcessToken = INVALID_HANDLE_VALUE;
@@ -327,7 +336,9 @@ Standard_Boolean OSD_Process :: IsSuperUser () {
if ( pTKgroups != NULL ) FreeTokenInformation ( pTKgroups );
return retVal;
#else
return FALSE;
#endif
} // end OSD_Process :: IsSuperUser
Standard_Integer OSD_Process :: ProcessId () {
@@ -337,9 +348,8 @@ Standard_Integer OSD_Process :: ProcessId () {
} // end OSD_Process :: ProcessId
OSD_Path OSD_Process :: CurrentDirectory () {
OSD_Path anCurrentDirectory;
#ifndef OCCT_UWP
DWORD dwSize = PATHLEN + 1;
Standard_WideChar* pBuff = new wchar_t[dwSize];
@@ -353,6 +363,7 @@ OSD_Path OSD_Process :: CurrentDirectory () {
_osd_wnt_set_error ( myError, OSD_WProcess );
delete[] pBuff;
#endif
return anCurrentDirectory;
} // end OSD_Process :: CurrentDirectory

View File

@@ -184,13 +184,15 @@ void OSD_SharedLibrary::Destroy() {
#endif
#include <windows.h>
#include <OSD_Path.hxx>
#include <OSD_SharedLibrary.hxx>
#include <TCollection_AsciiString.hxx>
#include <TCollection_ExtendedString.hxx>
static DWORD lastDLLError;
static Standard_Character errMsg[ 1024 ];
static wchar_t errMsg[1024];
static char errMsgA[1024];
OSD_SharedLibrary :: OSD_SharedLibrary () {
@@ -224,7 +226,13 @@ void OSD_SharedLibrary :: SetName ( const Standard_CString aName ) {
name = path.Name ();
name.AssignCat ( path.Extension () );
myHandle = GetModuleHandle ( name.ToCString () );
#ifndef OCCT_UWP
myHandle = GetModuleHandle(name.ToCString());
#else
TCollection_ExtendedString nameW(name);
myHandle = LoadPackagedLibrary ((const wchar_t*)nameW.ToExtString(), NULL );
FreeLibrary ((HMODULE) myHandle);
#endif
} // end OSD_SharedLibrary :: SetName
@@ -238,15 +246,17 @@ Standard_Boolean OSD_SharedLibrary :: DlOpen ( const OSD_LoadMode /*Mode*/ ) {
Standard_Boolean retVal = Standard_True;
if ( ( myHandle ) == NULL &&
( myHandle = ( HINSTANCE )LoadLibraryEx (
myName, NULL, LOAD_WITH_ALTERED_SEARCH_PATH
) ) == NULL
) {
lastDLLError = GetLastError ();
retVal = Standard_False;
if ( myHandle == NULL ) {
#ifndef OCCT_UWP
myHandle = (HINSTANCE)LoadLibraryEx(myName, NULL, LOAD_WITH_ALTERED_SEARCH_PATH);
#else
TCollection_ExtendedString myNameW(myName);
myHandle = (HINSTANCE)LoadPackagedLibrary((const wchar_t*)myNameW.ToExtString(), NULL);
#endif
if ( myHandle == NULL ) {
lastDLLError = GetLastError ();
retVal = Standard_False;
}
} // end if
return retVal;
@@ -273,13 +283,14 @@ void OSD_SharedLibrary :: DlClose () const {
Standard_CString OSD_SharedLibrary :: DlError () const {
FormatMessage (
FormatMessageW (
FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_ARGUMENT_ARRAY,
0, lastDLLError, MAKELANGID( LANG_NEUTRAL, SUBLANG_NEUTRAL ), errMsg, 1024, ( va_list* )&myName
0, lastDLLError, MAKELANGID( LANG_NEUTRAL, SUBLANG_NEUTRAL ),
errMsg, 1024, ( va_list* )&myName
);
return errMsg;
WideCharToMultiByte(CP_UTF8, 0, errMsg, -1, errMsgA, sizeof(errMsgA), NULL, NULL);
return errMsgA;
} // end OSD_SharedLibrary :: DlError
void OSD_SharedLibrary :: Destroy () {

View File

@@ -42,7 +42,6 @@ static inline Standard_Real GetWallClockTime ()
}
#else
//------------------- Windows NT ------------------
#define STRICT
@@ -62,7 +61,11 @@ static inline Standard_Real GetWallClockTime ()
LARGE_INTEGER time;
return isOk && QueryPerformanceCounter (&time) ?
(Standard_Real)time.QuadPart / (Standard_Real)freq.QuadPart :
#ifndef OCCT_UWP
0.001 * GetTickCount();
#else
0.001 * GetTickCount64();
#endif
}
#endif /* _WIN32 */

View File

@@ -23,9 +23,14 @@
/***/
#include <OSD_WNT_1.hxx>
#include <Strsafe.h>
#include <wchar.h>
#include <stdlib.h>
#include <Standard_Macro.hxx>
/***/
#ifndef OCCT_UWP
static void Init ( void );
/***/
class Init_OSD_WNT { // provides initialization
@@ -37,6 +42,7 @@ class Init_OSD_WNT { // provides initialization
}; // end Init_OSD_WNT
static Init_OSD_WNT initOsdWnt;
#endif
/***/
static BOOL fInit = FALSE;
static PSID* predefinedSIDs;
@@ -59,6 +65,8 @@ static RESPONSE_DIR_PROC _response_dir_proc;
#define SID_WORLD 7
#define SID_NULL 8
/***/
#ifndef OCCT_UWP
// None of the existing security APIs are supported in a UWP applications
/******************************************************************************/
/* Function : AllocSD */
/* Purpose : Allocates and initializes security identifier */
@@ -597,7 +605,7 @@ void FreeAce ( PVOID pACE ) {
HeapFree ( hHeap, 0, pACE );
} /* end FreeAce */
#endif
#define WILD_CARD L"/*.*"
#define WILD_CARD_LEN ( sizeof ( WILD_CARD ) )
@@ -697,23 +705,24 @@ retry:
retVal = CreateDirectoryW ( newDir, NULL );
if ( retVal || ( !retVal && GetLastError () == ERROR_ALREADY_EXISTS ) ) {
size_t anOldDirLength;
StringCchLengthW (oldDir, sizeof(oldDir) / sizeof(oldDir[0]), &anOldDirLength);
if ( ( pFD = ( PWIN32_FIND_DATAW )HeapAlloc (
hHeap, 0, sizeof ( WIN32_FIND_DATAW )
)
) != NULL &&
( pName = ( LPWSTR )HeapAlloc (
hHeap, 0, lstrlenW ( oldDir ) + WILD_CARD_LEN +
sizeof ( L'\x00' )
)
(
pName = (LPWSTR)HeapAlloc(
hHeap, 0, anOldDirLength + WILD_CARD_LEN +
sizeof(L'\x00')
)
) != NULL
) {
lstrcpyW ( pName, oldDir );
lstrcatW ( pName, WILD_CARD );
StringCchCopyW (pName, sizeof(pName) / sizeof(pName[0]), oldDir);
StringCchCatW (pName, sizeof(pName), WILD_CARD);
retVal = TRUE;
fFind = ( hFindFile = FindFirstFileW ( pName, pFD ) ) != INVALID_HANDLE_VALUE;
fFind = ( hFindFile = FindFirstFileExW(pName, FindExInfoStandard, pFD, FindExSearchNameMatch, NULL, 0) ) != INVALID_HANDLE_VALUE;
while ( fFind ) {
@@ -721,28 +730,35 @@ retry:
pFD -> cFileName[ 0 ] != L'.' &&
pFD -> cFileName[ 1 ] != L'.'
) {
if ( ( pFullNameSrc = ( LPWSTR )HeapAlloc (
hHeap, 0,
lstrlenW ( oldDir ) + lstrlenW ( pFD -> cFileName ) +
sizeof ( L'/' ) + sizeof ( L'\x00' )
)
) == NULL ||
( pFullNameDst = ( LPWSTR )HeapAlloc (
hHeap, 0,
lstrlenW ( newDir ) + lstrlenW ( pFD -> cFileName ) +
sizeof ( L'/' ) + sizeof ( L'\x00' )
)
) == NULL
) break;
lstrcpyW ( pFullNameSrc, oldDir );
lstrcatW ( pFullNameSrc, L"/" );
lstrcatW ( pFullNameSrc, pFD -> cFileName );
size_t anOldDirLength2;
size_t aNewDirLength;
size_t aFileNameLength;
lstrcpyW ( pFullNameDst, newDir );
lstrcatW ( pFullNameDst, L"/" );
lstrcatW ( pFullNameDst, pFD -> cFileName );
StringCchLengthW (oldDir, sizeof(oldDir) / sizeof(oldDir[0]), &anOldDirLength2);
StringCchLengthW (newDir, sizeof(newDir) / sizeof(newDir[0]), &aNewDirLength);
StringCchLengthW (pFD->cFileName, sizeof(pFD->cFileName) / sizeof(pFD->cFileName[0]), &aFileNameLength);
if ( (pFullNameSrc = (LPWSTR)HeapAlloc(
hHeap, 0,
anOldDirLength2 + aFileNameLength +
sizeof(L'/') + sizeof(L'\x00')
)
) == NULL ||
(pFullNameDst = (LPWSTR)HeapAlloc(
hHeap, 0,
aNewDirLength + aFileNameLength +
sizeof(L'/') + sizeof(L'\x00')
)
) == NULL
) break;
StringCchCopyW (pFullNameSrc, sizeof(pFullNameSrc) / sizeof(pFullNameSrc[0]), oldDir);
StringCchCatW (pFullNameSrc, sizeof(pFullNameSrc) / sizeof(pFullNameSrc[0]), L"/");
StringCchCatW (pFullNameSrc, sizeof(pFullNameSrc) / sizeof(pFullNameSrc[0]), pFD->cFileName);
StringCchCopyW (pFullNameDst, sizeof(pFullNameDst) / sizeof(pFullNameDst[0]), newDir);
StringCchCatW (pFullNameDst, sizeof(pFullNameDst) / sizeof(pFullNameDst[0]), L"/");
StringCchCatW (pFullNameDst, sizeof(pFullNameDst) / sizeof(pFullNameDst[0]), pFD->cFileName);
if ( pFD -> dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY ) {
@@ -862,22 +878,24 @@ BOOL CopyDirectory ( LPCWSTR dirSrc, LPCWSTR dirDst ) {
if ( retVal || ( !retVal && GetLastError () == ERROR_ALREADY_EXISTS ) ) {
size_t aDirSrcLength;
StringCchLengthW (dirSrc, sizeof(dirSrc) / sizeof(dirSrc[0]), &aDirSrcLength);
if ( ( pFD = ( PWIN32_FIND_DATAW )HeapAlloc (
hHeap, 0, sizeof ( WIN32_FIND_DATAW )
)
) != NULL &&
( pName = ( LPWSTR )HeapAlloc (
hHeap, 0, lstrlenW ( dirSrc ) + WILD_CARD_LEN +
hHeap, 0, aDirSrcLength + WILD_CARD_LEN +
sizeof ( L'\x00' )
)
) != NULL
) {
lstrcpyW ( pName, dirSrc );
lstrcatW ( pName, WILD_CARD );
StringCchCopyW (pName, sizeof(pName) / sizeof(pName[0]), dirSrc);
StringCchCatW (pName, sizeof(pName) / sizeof(pName[0]), WILD_CARD);
retVal = TRUE;
fFind = ( hFindFile = FindFirstFileW ( pName, pFD ) ) != INVALID_HANDLE_VALUE;
fFind = (hFindFile = FindFirstFileExW(pName, FindExInfoStandard, pFD, FindExSearchNameMatch, NULL, 0)) != INVALID_HANDLE_VALUE;
while ( fFind ) {
@@ -885,28 +903,36 @@ BOOL CopyDirectory ( LPCWSTR dirSrc, LPCWSTR dirDst ) {
pFD -> cFileName[ 0 ] != L'.' &&
pFD -> cFileName[ 1 ] != L'.'
) {
size_t aDirSrcLength2;
size_t aDirDstLength;
size_t aFileNameLength;
StringCchLengthW (dirSrc, sizeof(dirSrc) / sizeof(dirSrc[0]), &aDirSrcLength2);
StringCchLengthW (dirDst, sizeof(dirDst) / sizeof(dirDst[0]), &aDirDstLength);
StringCchLengthW (pFD -> cFileName, sizeof(pFD -> cFileName) / sizeof(pFD -> cFileName[0]), &aFileNameLength);
if ( ( pFullNameSrc = ( LPWSTR )HeapAlloc (
hHeap, 0,
lstrlenW ( dirSrc ) + lstrlenW ( pFD -> cFileName ) +
aDirSrcLength2 + aFileNameLength +
sizeof ( L'/' ) + sizeof ( L'\x00' )
)
) == NULL ||
( pFullNameDst = ( LPWSTR )HeapAlloc (
hHeap, 0,
lstrlenW ( dirDst ) + lstrlenW ( pFD -> cFileName ) +
aDirDstLength + aFileNameLength +
sizeof ( L'/' ) + sizeof ( L'\x00' )
)
) == NULL
) break;
lstrcpyW ( pFullNameSrc, dirSrc );
lstrcatW ( pFullNameSrc, L"/" );
lstrcatW ( pFullNameSrc, pFD -> cFileName );
lstrcpyW ( pFullNameDst, dirDst );
lstrcatW ( pFullNameDst, L"/" );
lstrcatW ( pFullNameDst, pFD -> cFileName );
StringCchCopyW (pFullNameSrc, sizeof(pFullNameSrc) / sizeof(pFullNameSrc[0]), dirSrc);
StringCchCatW (pFullNameSrc, sizeof(pFullNameSrc) / sizeof(pFullNameSrc[0]), L"/");
StringCchCatW (pFullNameSrc, sizeof(pFullNameSrc) / sizeof(pFullNameSrc[0]), pFD->cFileName);
StringCchCopyW (pFullNameDst, sizeof(pFullNameDst) / sizeof(pFullNameDst[0]), dirDst);
StringCchCatW (pFullNameDst, sizeof(pFullNameDst) / sizeof(pFullNameDst[0]), L"/");
StringCchCatW (pFullNameDst, sizeof(pFullNameDst) / sizeof(pFullNameDst[0]), pFD->cFileName);
if ( pFD -> dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY ) {
@@ -915,7 +941,11 @@ BOOL CopyDirectory ( LPCWSTR dirSrc, LPCWSTR dirDst ) {
} else {
retry:
retVal = CopyFileW ( pFullNameSrc, pFullNameDst, FALSE );
#ifndef OCCT_UWP
retVal = CopyFileW(pFullNameSrc, pFullNameDst, FALSE);
#else
retVal = (CopyFile2(pFullNameSrc, pFullNameDst, FALSE) == S_OK) ? TRUE : FALSE;
#endif
if ( ! retVal ) {
if ( _response_dir_proc != NULL ) {

View File

@@ -24,8 +24,13 @@
#ifdef NOUSER
#undef NOUSER
#endif
#ifdef NONLS
#undef NONLS
#endif
#include <windows.h>
#include <Strsafe.h>
#ifndef STATUS_FLOAT_MULTIPLE_FAULTS
// <ntstatus.h>
#define STATUS_FLOAT_MULTIPLE_FAULTS (0xC00002B4L)
@@ -72,7 +77,9 @@ static Standard_Mutex THE_SIGNAL_MUTEX;
static LONG __fastcall _osd_raise ( DWORD, LPSTR );
static BOOL WINAPI _osd_ctrl_break_handler ( DWORD );
#ifndef OCCT_UWP
static LONG _osd_debug ( void );
#endif
//# define _OSD_FPX ( _EM_INVALID | _EM_DENORMAL | _EM_ZERODIVIDE | _EM_OVERFLOW | _EM_UNDERFLOW )
# define _OSD_FPX ( _EM_INVALID | _EM_DENORMAL | _EM_ZERODIVIDE | _EM_OVERFLOW )
@@ -86,7 +93,9 @@ static LONG CallHandler (DWORD dwExceptionCode,
ptrdiff_t ExceptionInformation0)
{
Standard_Mutex::Sentry aSentry (THE_SIGNAL_MUTEX); // lock the mutex to prevent simultaneous handling
static char buffer[ 2048 ];
static wchar_t buffer[2048];
int flterr = 0;
buffer[0] = '\0' ;
@@ -95,47 +104,47 @@ static LONG CallHandler (DWORD dwExceptionCode,
switch ( dwExceptionCode ) {
case EXCEPTION_FLT_DENORMAL_OPERAND:
// cout << "CallHandler : EXCEPTION_FLT_DENORMAL_OPERAND:" << endl ;
lstrcpyA ( buffer, "FLT DENORMAL OPERAND" );
StringCchCopyW (buffer, _countof(buffer), L"FLT DENORMAL OPERAND");
flterr = 1 ;
break ;
case EXCEPTION_FLT_DIVIDE_BY_ZERO:
// cout << "CallHandler : EXCEPTION_FLT_DIVIDE_BY_ZERO:" << endl ;
lstrcpyA ( buffer, "FLT DIVIDE BY ZERO" );
StringCchCopyW (buffer, _countof(buffer), L"FLT DIVIDE BY ZERO");
flterr = 1 ;
break ;
case EXCEPTION_FLT_INEXACT_RESULT:
// cout << "CallHandler : EXCEPTION_FLT_INEXACT_RESULT:" << endl ;
lstrcpyA ( buffer, "FLT INEXACT RESULT" );
StringCchCopyW (buffer, _countof(buffer), L"FLT INEXACT RESULT");
flterr = 1 ;
break ;
case EXCEPTION_FLT_INVALID_OPERATION:
// cout << "CallHandler : EXCEPTION_FLT_INVALID_OPERATION:" << endl ;
lstrcpyA ( buffer, "FLT INVALID OPERATION" );
StringCchCopyW (buffer, _countof(buffer), L"FLT INVALID OPERATION");
flterr = 1 ;
break ;
case EXCEPTION_FLT_OVERFLOW:
// cout << "CallHandler : EXCEPTION_FLT_OVERFLOW:" << endl ;
lstrcpyA ( buffer, "FLT OVERFLOW" );
StringCchCopyW (buffer, _countof(buffer), L"FLT OVERFLOW");
flterr = 1 ;
break ;
case EXCEPTION_FLT_STACK_CHECK:
// cout << "CallHandler : EXCEPTION_FLT_STACK_CHECK:" << endl ;
lstrcpyA ( buffer, "FLT STACK CHECK" );
StringCchCopyW (buffer, _countof(buffer), L"FLT STACK CHECK");
flterr = 1 ;
break ;
case EXCEPTION_FLT_UNDERFLOW:
// cout << "CallHandler : EXCEPTION_FLT_UNDERFLOW:" << endl ;
lstrcpyA ( buffer, "FLT UNDERFLOW" );
StringCchCopyW (buffer, _countof(buffer), L"FLT UNDERFLOW");
flterr = 1 ;
break ;
case STATUS_FLOAT_MULTIPLE_TRAPS:
// cout << "CallHandler : EXCEPTION_FLT_UNDERFLOW:" << endl ;
lstrcpyA ( buffer, "FLT MULTIPLE TRAPS (possible overflow in conversion of double to integer)" );
StringCchCopyW (buffer, _countof(buffer), L"FLT MULTIPLE TRAPS (possible overflow in conversion of double to integer)");
flterr = 1 ;
break ;
case STATUS_FLOAT_MULTIPLE_FAULTS:
// cout << "CallHandler : EXCEPTION_FLT_UNDERFLOW:" << endl ;
lstrcpyA ( buffer, "FLT MULTIPLE FAULTS" );
StringCchCopyW (buffer, _countof(buffer), L"FLT MULTIPLE FAULTS");
flterr = 1 ;
break ;
case STATUS_NO_MEMORY:
@@ -144,89 +153,92 @@ static LONG CallHandler (DWORD dwExceptionCode,
Raise ( "MEMORY ALLOCATION ERROR ( no room in the process heap )" );
case EXCEPTION_ACCESS_VIOLATION:
// cout << "CallHandler : EXCEPTION_ACCESS_VIOLATION:" << endl ;
wsprintf ( buffer, "%s%s%s0x%.8p%s%s%s", "ACCESS VIOLATION",
fMsgBox ? "\n" : " ", "at address ",
StringCchPrintfW (buffer, _countof(buffer), L"%s%s%s0x%.8p%s%s%s", L"ACCESS VIOLATION",
fMsgBox ? L"\n" : L" ", L"at address ",
ExceptionInformation1 ,
" during '",
ExceptionInformation0 ? "WRITE" : "READ",
"' operation");
L" during '",
ExceptionInformation0 ? L"WRITE" : L"READ",
L"' operation");
break;
case EXCEPTION_ARRAY_BOUNDS_EXCEEDED:
// cout << "CallHandler : EXCEPTION_ARRAY_BOUNDS_EXCEEDED:" << endl ;
lstrcpyA ( buffer, "ARRAY BOUNDS EXCEEDED" );
StringCchCopyW (buffer, _countof(buffer), L"ARRAY BOUNDS EXCEEDED");
break;
case EXCEPTION_DATATYPE_MISALIGNMENT:
// cout << "CallHandler : EXCEPTION_DATATYPE_MISALIGNMENT:" << endl ;
lstrcpyA ( buffer, "DATATYPE MISALIGNMENT" );
StringCchCopyW (buffer, _countof(buffer), L"DATATYPE MISALIGNMENT");
break;
case EXCEPTION_ILLEGAL_INSTRUCTION:
// cout << "CallHandler : EXCEPTION_ILLEGAL_INSTRUCTION:" << endl ;
lstrcpyA ( buffer, "ILLEGAL INSTRUCTION" );
StringCchCopyW (buffer, _countof(buffer), L"ILLEGAL INSTRUCTION");
break;
case EXCEPTION_IN_PAGE_ERROR:
// cout << "CallHandler : EXCEPTION_IN_PAGE_ERROR:" << endl ;
lstrcpyA ( buffer, "IN_PAGE ERROR" );
StringCchCopyW (buffer, _countof(buffer), L"IN_PAGE ERROR");
break;
case EXCEPTION_INT_DIVIDE_BY_ZERO:
// cout << "CallHandler : EXCEPTION_INT_DIVIDE_BY_ZERO:" << endl ;
lstrcpyA ( buffer, "INTEGER DIVISION BY ZERO" );
StringCchCopyW (buffer, _countof(buffer), L"INTEGER DIVISION BY ZERO");
break;
case EXCEPTION_INT_OVERFLOW:
// cout << "CallHandler : EXCEPTION_INT_OVERFLOW:" << endl ;
lstrcpyA ( buffer, "INTEGER OVERFLOW" );
StringCchCopyW (buffer, _countof(buffer), L"INTEGER OVERFLOW");
break;
case EXCEPTION_INVALID_DISPOSITION:
// cout << "CallHandler : EXCEPTION_INVALID_DISPOSITION:" << endl ;
lstrcpyA ( buffer, "INVALID DISPOSITION" );
StringCchCopyW (buffer, _countof(buffer), L"INVALID DISPOSITION");
break;
case EXCEPTION_NONCONTINUABLE_EXCEPTION:
// cout << "CallHandler : EXCEPTION_NONCONTINUABLE_EXCEPTION:" << endl ;
lstrcpyA ( buffer, "NONCONTINUABLE EXCEPTION" );
StringCchCopyW (buffer, _countof(buffer), L"NONCONTINUABLE EXCEPTION");
break;
case EXCEPTION_PRIV_INSTRUCTION:
// cout << "CallHandler : EXCEPTION_PRIV_INSTRUCTION:" << endl ;
lstrcpyA ( buffer, "PRIVELEGED INSTRUCTION ENCOUNTERED" );
StringCchCopyW (buffer, _countof(buffer), L"PRIVELEGED INSTRUCTION ENCOUNTERED");
break;
case EXCEPTION_STACK_OVERFLOW:
// cout << "CallHandler : EXCEPTION_STACK_OVERFLOW:" << endl ;
#if defined( _MSC_VER ) && ( _MSC_VER >= 1300 )
#if defined( _MSC_VER ) && ( _MSC_VER >= 1300 ) && !defined(OCCT_UWP)
// try recovering from stack overflow: available in MS VC++ 7.0
if (!_resetstkoflw())
lstrcpyA ( buffer, "Unrecoverable STACK OVERFLOW" );
StringCchCopyW (buffer, _countof(buffer), L"Unrecoverable STACK OVERFLOW");
else
#endif
lstrcpyA ( buffer, "STACK OVERFLOW" );
StringCchCopyW (buffer, _countof(buffer), L"STACK OVERFLOW");
break;
default:
wsprintf( buffer, "unknown exception code 0x%x, params 0x%p 0x%p",
StringCchPrintfW (buffer, _countof(buffer), L"unknown exception code 0x%x, params 0x%p 0x%p",
dwExceptionCode, ExceptionInformation1, ExceptionInformation0 );
} // end switch
// provide message to the user with possibility to stop
int idx = lstrlenA ( buffer );
size_t idx;
StringCchLengthW (buffer, _countof(buffer),&idx);
if ( idx && fMsgBox && dwExceptionCode != EXCEPTION_NONCONTINUABLE_EXCEPTION ) {
// reset FP operations before message box, otherwise it may fail to show up
_fpreset();
_clearfp();
#ifndef OCCT_UWP
MessageBeep ( MB_ICONHAND );
int aChoice = ::MessageBox (0, buffer, "OCCT Exception Handler", MB_ABORTRETRYIGNORE | MB_ICONSTOP);
int aChoice = ::MessageBoxW (0, buffer, L"OCCT Exception Handler", MB_ABORTRETRYIGNORE | MB_ICONSTOP);
if (aChoice == IDRETRY)
{
_osd_debug();
DebugBreak();
} else if (aChoice == IDABORT)
exit(0xFFFF);
#endif
}
// reset FPE state
@@ -237,7 +249,10 @@ static LONG CallHandler (DWORD dwExceptionCode,
_controlfp ( 0, _OSD_FPX ) ; // JR add :
// cout << "OSD::WntHandler _controlfp( 0, _OSD_FPX ) " << hex << _controlfp(0,0) << dec << endl ;
}
return _osd_raise ( dwExceptionCode, buffer );
char aBufferA[2048];
WideCharToMultiByte(CP_UTF8, 0, buffer, -1, aBufferA, sizeof(aBufferA), NULL, NULL);
return _osd_raise(dwExceptionCode, aBufferA);
}
//=======================================================================
@@ -292,7 +307,9 @@ static void SIGWntHandler (int signum, int sub_code)
cout << "SIGWntHandler unexpected signal : " << signum << endl ;
break ;
}
#ifndef OCCT_UWP
DebugBreak ();
#endif
}
#endif
@@ -348,7 +365,7 @@ void OSD::SetSignal (const Standard_Boolean theFloatingSignal)
Standard_Mutex::Sentry aSentry (THE_SIGNAL_MUTEX); // lock the mutex to prevent simultaneous handling
LPTOP_LEVEL_EXCEPTION_FILTER aPreviousFilter;
OSD_Environment env (TEXT("CSF_DEBUG_MODE"));
OSD_Environment env ("CSF_DEBUG_MODE");
TCollection_AsciiString val = env.Value();
if (!env.Failed())
{
@@ -377,8 +394,9 @@ void OSD::SetSignal (const Standard_Boolean theFloatingSignal)
// Set Ctrl-C and Ctrl-Break handler
fCtrlBrk = Standard_False;
#ifndef OCCT_UWP
SetConsoleCtrlHandler (&_osd_ctrl_break_handler, TRUE);
#endif
#ifdef _MSC_VER
// _se_translator_function pOldSeFunc =
_set_se_translator (TranslateSE);
@@ -401,11 +419,11 @@ void OSD::SetSignal (const Standard_Boolean theFloatingSignal)
void OSD::ControlBreak () {
if ( fCtrlBrk ) {
fCtrlBrk = Standard_False;
OSD_Exception_CTRL_BREAK :: Raise ( TEXT( "*** INTERRUPT ***" ) );
OSD_Exception_CTRL_BREAK :: Raise ( "*** INTERRUPT ***" );
}
} // end OSD :: ControlBreak
#if !defined(__MINGW32__) && !defined(__CYGWIN32__)
#ifndef OCCT_UWP
//============================================================================
//==== _osd_ctrl_break_handler
//============================================================================
@@ -418,7 +436,7 @@ static BOOL WINAPI _osd_ctrl_break_handler ( DWORD dwCode ) {
return TRUE;
} // end _osd_ctrl_break_handler
#endif
//============================================================================
//==== _osd_raise
//============================================================================
@@ -487,6 +505,7 @@ static LONG __fastcall _osd_raise ( DWORD dwCode, LPSTR msg )
//============================================================================
//==== _osd_debug
//============================================================================
#ifndef OCCT_UWP
LONG _osd_debug ( void ) {
LONG action ;
@@ -525,7 +544,7 @@ LONG _osd_debug ( void ) {
if ( ( hEvent = CreateEvent ( &sa, TRUE, FALSE, NULL ) ) == NULL ) __leave;
wsprintf ( cmdLine, keyValue, GetCurrentProcessId (), hEvent );
StringCchPrintf(cmdLine, _countof(cmdLine), keyValue, GetCurrentProcessId(), hEvent);
ZeroMemory ( &si, sizeof ( STARTUPINFO ) );
@@ -569,8 +588,9 @@ LONG _osd_debug ( void ) {
return action ;
} // end _osd_debug
#endif
#endif
#endif
#else
//---------- All Systems except Windows NT : ----------------------------------