Пример #1
0
Model ModelLoader::Load(const string &aFileName,
                               bool aNormalizeMesh /*= false*/)
{
    ResetLoader();
    
    cout << "Loading mesh " << aFileName << " ... ";
    
    FILE* pFile = fopen(aFileName.c_str(),"rb");
    
    while(!feof(pFile))
    {
        DispatchRead(pFile);
    }
    
    if(mNormals.size() == 1)
    {
        GenerateNormals();
    }

    if(aNormalizeMesh)
    {
        NormalizeMesh();
    }

	
    unsigned int GLId = FillPrimitive();
    
    fclose(pFile);
    cout << "DONE." << endl;

    Model RetVal(mVertices, mCombinedVertices,GLId);
    
    return RetVal;
}
Пример #2
0
UINT WINAPI
DokanLoop(
   PDOKAN_INSTANCE DokanInstance
	)
{
	HANDLE	device;
	char	buffer[EVENT_CONTEXT_MAX_SIZE];
	BOOL	status;
	ULONG	returnedLength;
	DWORD	result = 0;
    DWORD   lastError = 0;
	RtlZeroMemory(buffer, sizeof(buffer));

	device = CreateFile(
				GetRawDeviceName(DokanInstance->DeviceName), // lpFileName
				GENERIC_READ | GENERIC_WRITE,       // dwDesiredAccess
				FILE_SHARE_READ | FILE_SHARE_WRITE, // dwShareMode
				NULL,                               // lpSecurityAttributes
				OPEN_EXISTING,                      // dwCreationDistribution
				0,                                  // dwFlagsAndAttributes
				NULL                                // hTemplateFile
			);

	if (device == INVALID_HANDLE_VALUE) {
		DbgPrint("Dokan Error: CreateFile failed %ws: %d\n",
			GetRawDeviceName(DokanInstance->DeviceName), GetLastError());
		result = (DWORD)-1;
		_endthreadex(result);
		return result;
	}

	status = TRUE;
	while (status) {

		status = DeviceIoControl(
					device,				// Handle to device
					IOCTL_EVENT_WAIT,	// IO Control code
					NULL,				// Input Buffer to driver.
					0,					// Length of input buffer in bytes.
					buffer,             // Output Buffer from driver.
					sizeof(buffer),		// Length of output buffer in bytes.
					&returnedLength,	// Bytes placed in buffer.
					NULL                // synchronous call
					);

		if (!status) {
            lastError = GetLastError();
			DbgPrint("Ioctl failed for wait with code %d.\n", lastError);
            if (lastError == ERROR_NO_SYSTEM_RESOURCES) {
                DbgPrint("Processing will continue\n");
                status = TRUE;
                Sleep(200);
                continue;
            }
            DbgPrint("Thread will be terminated\n");
			break;
		}

		//printf("#%d got notification %d\n", (ULONG)Param, count++);

		if(returnedLength > 0) {
			PEVENT_CONTEXT context = (PEVENT_CONTEXT)buffer;
			if (context->MountId != DokanInstance->MountId) {
				DbgPrint("Dokan Error: Invalid MountId (expected:%d, acctual:%d)\n",
						DokanInstance->MountId, context->MountId);
				continue;
			}

			switch (context->MajorFunction) {
			case IRP_MJ_CREATE:
				DispatchCreate(device, context, DokanInstance);
				break;
			case IRP_MJ_CLEANUP:
				DispatchCleanup(device, context, DokanInstance);
				break;
			case IRP_MJ_CLOSE:
				DispatchClose(device, context, DokanInstance);
				break;
			case IRP_MJ_DIRECTORY_CONTROL:
				DispatchDirectoryInformation(device, context, DokanInstance);
				break;
			case IRP_MJ_READ:
				DispatchRead(device, context, DokanInstance);
				break;
			case IRP_MJ_WRITE:
				DispatchWrite(device, context, DokanInstance);
				break;
			case IRP_MJ_QUERY_INFORMATION:
				DispatchQueryInformation(device, context, DokanInstance);
				break;
			case IRP_MJ_QUERY_VOLUME_INFORMATION:
				DispatchQueryVolumeInformation(device ,context, DokanInstance);
				break;
			case IRP_MJ_LOCK_CONTROL:
				DispatchLock(device, context, DokanInstance);
				break;
			case IRP_MJ_SET_INFORMATION:
				DispatchSetInformation(device, context, DokanInstance);
				break;
			case IRP_MJ_FLUSH_BUFFERS:
				DispatchFlush(device, context, DokanInstance);
				break;
			case IRP_MJ_QUERY_SECURITY:
				DispatchQuerySecurity(device, context, DokanInstance);
				break;
			case IRP_MJ_SET_SECURITY:
				DispatchSetSecurity(device, context, DokanInstance);
				break;
			case IRP_MJ_SHUTDOWN:
				// this case is used before unmount not shutdown
				DispatchUnmount(device, context, DokanInstance);
				break;
			default:
				break;
			}

		} else {
			DbgPrint("ReturnedLength %d\n", returnedLength);
		}
	}

	CloseHandle(device);
    _endthreadex(result);

	return result;
}