Esempio n. 1
0
// ////////////////////////////////////////////////////////////////////////////
SQLRETURN DriverConnect(SQLHDBC ConnectionHandle,
                        const std::string &InConnectionString, SQLUSMALLINT DriverCompletion,
                        OdbcThrowFlags::Flags throw_flags)
{
    return(DriverConnect(ConnectionHandle, NULL, InConnectionString,
                         DriverCompletion, throw_flags));
}
Esempio n. 2
0
// ////////////////////////////////////////////////////////////////////////////
SQLRETURN DriverConnect(SQLHDBC ConnectionHandle, SQLHWND WindowHandle,
                        const std::string &InConnectionString, SQLUSMALLINT DriverCompletion,
                        OdbcThrowFlags::Flags throw_flags)
{
    std::string OutConnectionString;

    return(DriverConnect(ConnectionHandle, WindowHandle, InConnectionString,
                         OutConnectionString, DriverCompletion, throw_flags));
}
Esempio n. 3
0
// ////////////////////////////////////////////////////////////////////////////
SQLRETURN DriverConnect(SQLHDBC ConnectionHandle, SQLCHAR *InConnectionString,
                        SQLSMALLINT StringLength1, SQLCHAR *OutConnectionString,
                        SQLSMALLINT BufferLength, SQLSMALLINT *StringLength2Ptr,
                        SQLUSMALLINT DriverCompletion, OdbcThrowFlags::Flags throw_flags)
{
    return(DriverConnect(ConnectionHandle, NULL, InConnectionString,
                         StringLength1, OutConnectionString, BufferLength, StringLength2Ptr,
                         DriverCompletion, throw_flags));
}
Esempio n. 4
0
//--------------------------------------------------------------------
//
// Main
//
//--------------------------------------------------------------------
int main( int argc, char *argv[] )
{
	char	input[256];

	//
	// Print title
	//
	printf("\nDevice Object Security Demo V1.0\n");
	printf("Copyright (C) 1998 Mark Russinovich\n");
	printf("http://www.ntinternals.com\n\n");

	printf("This program demonstrates default device object security and\n"
		"the secsys driver, which removes Everyone R/W access from its\n"
		"device object.\n\n");

	//
	// get NT version
	//
	if( GetVersion() >= 0x80000000 ) {
		printf("Not running on Windows NT.\n");
		return -1;
	}

	//
	// Connect to driver
	//
	if( !DriverConnect()) {

		DriverDisconnect();
		return -1;
	}

	printf("SecSys driver is loaded. View its (\\device\\secsys.sys)\n"
		"permissions with Winobj and then press enter to have\n"
		"Everyone R/W access removed: ");
	fflush( stdout );
	gets( input );

	//
	// Tell the driver to remove world R/W
	//
	CallDriver( SECDEMO_IOCTL, NULL, 0, NULL, 0 );

	printf("\nEveryone R/W permission removed. View new permissions with\n"
		"Winobj (close and reselect the secsys device properties) and\n"
		"then press enter to end: ");
	fflush( stdout );
	gets( input );

	DriverDisconnect();
	return 0;
}
Esempio n. 5
0
// ////////////////////////////////////////////////////////////////////////////
SQLRETURN DriverConnect(SQLHDBC ConnectionHandle, SQLHWND WindowHandle,
                        const std::string &InConnectionString, std::string &OutConnectionString,
                        SQLUSMALLINT DriverCompletion, OdbcThrowFlags::Flags throw_flags)
{
    CheckStringArgInLengthDomain<SQLSMALLINT>(InConnectionString,
            "InConnectionString", "::SQLDriverConnect");

    SQLRETURN                                      return_code;
    MLB::Utility::IncrementalBuffer<SQLCHAR, 4096> buffer;

    throw_flags = MLB::Utility::EnumFlagAnd(throw_flags,
                                            static_cast<OdbcThrowFlags::Flags>(~(OdbcThrowFlags::SuccessWithInfo)));

    for ( ; ; ) {
        SQLSMALLINT actual_len;
        return_code = DriverConnect(ConnectionHandle, WindowHandle,
                                    reinterpret_cast<SQLCHAR *>(
                                        const_cast<char *>(InConnectionString.c_str())),
                                    static_cast<SQLSMALLINT>(InConnectionString.size()),
                                    reinterpret_cast<SQLCHAR *>(buffer.GetPtr()),
                                    buffer.GetAllocationCountAsType<SQLSMALLINT>(), &actual_len,
                                    DriverCompletion, throw_flags);
        if (return_code == SQL_SUCCESS) {
            std::string(reinterpret_cast<const char *>(buffer.GetPtr()),
                        actual_len).swap(OutConnectionString);
            break;
        }
        else if (return_code == SQL_SUCCESS_WITH_INFO) {
            //	::SQLDriverConnect() returns 'SQL_SUCCESS_WITH_INFO' for reasons
            //	other than to do with insufficient length of returned strings...
            if (!buffer.SetCount(actual_len, false))
                break;
        }
    }

    return(return_code);
}