Example #1
0
char* 
PrinterDriver::AddPrinter(char* printerName)
{
	// print_server has created a spool folder with name printerName in
	// folder B_USER_PRINTERS_DIRECTORY. It can be used to store
	// settings in the folder attributes.
	DBGMSG((">%s: add_printer\n", GetDriverName()));
	DBGMSG(("\tprinter_name: %s\n", printerName));
	DBGMSG(("<%s: add_printer\n", GetDriverName()));
	
	if (fPrinterCap->Supports(PrinterCap::kProtocolClass)) {
		if (fPrinterCap->CountCap(PrinterCap::kProtocolClass) > 1) {
			AddPrinterDlg *dialog;
			dialog = new AddPrinterDlg(fPrinterData, fPrinterCap);
			if (dialog->Go() != B_OK) {
				// dialog canceled
				return NULL;
			}
		} else {
			const ProtocolClassCap* pcCap;
			pcCap = (const ProtocolClassCap*)fPrinterCap->GetDefaultCap(
				PrinterCap::kProtocolClass);
			if (pcCap != NULL) {
				fPrinterData->SetProtocolClass(pcCap->fProtocolClass);
				fPrinterData->Save();
			}
		}
	}
	return printerName;
}
//
// Get capture device summary
// Return TRUE if OK
//
BOOL	CAviCap::GetDriverInfo(CAPDRVINFO *cdi)
{

	CHECKCNCT();
	if(!cdi)	return FALSE;
	
	lstrcpy(cdi->psName,GetDriverName());
	cdi->dwInternalBufCnt= _internalBufCnt;
	cdi->dwCurBiBitCount = ((LPBITMAPINFOHEADER)_bmpInfo)->biBitCount;
	cdi->dwBiBitsCountSupported=_biBitsCountSupported;
	cdi->dwCompressed =((LPBITMAPINFOHEADER)_bmpInfo)->biCompression;
	cdi->szFrameSize.cx=(int)((LPBITMAPINFOHEADER)_bmpInfo)->biWidth;
	cdi->szFrameSize.cy=(int)((LPBITMAPINFOHEADER)_bmpInfo)->biHeight;

	
	cdi->fFormatDlgSup=_capDriverCaps.fHasDlgVideoFormat;
	cdi->fSourceDlgSup=_capDriverCaps.fHasDlgVideoSource;
	cdi->fDisplayDlgSup=_capDriverCaps.fHasDlgVideoDisplay;
    cdi->fNTSC = FALSE;//default == PAL
	
	//NB: valid NTSC formats : 640x480, 320x240, 160x120 etc.
	//	  valid PAL  formats : 768x576, 384x288, 196x144 etc.
	#define FX	 cdi->szFrameSize.cx
	if(_formats.GetSize())
	{
	for(int i=0;i<_formats.GetSize();i++)
			//any from follow			
			if(_XXXX()==320||_XXXX()==640||_XXXX()==160||_XXXX()==400)
				{cdi->fNTSC =TRUE; break;}
	}
	else
		if(FX==320||FX==640||FX==160||FX==400)
				cdi->fNTSC =TRUE;
	return TRUE;				
}
Example #3
0
EFI_STATUS
GetGOPDriverVersion(
    CHAR16 *GopVersion
)
{
    UINTN                 HandleCount;
    EFI_HANDLE            *Handles= NULL;
    UINTN                 Index;
    EFI_STATUS            Status;
    EFI_HANDLE            Child = 0;

    Status = gBS->LocateHandleBuffer(
                 ByProtocol,
                 &gEfiDriverBindingProtocolGuid,
                 NULL,
                 &HandleCount,
                 &Handles
             );
    for (Index = 0; Index < HandleCount ; Index++) {
        Status = SearchChildHandle(Handles[Index], &Child);
        if(!EFI_ERROR(Status)) {
            Status = JudgeHandleIsPCIDevice(Child, 0x02, 0x00);
            if(!EFI_ERROR(Status)) {
                return GetDriverName(Handles[Index], GopVersion);
            }
        }
    }
    return EFI_UNSUPPORTED;
}
Example #4
0
void NetClient::SendReadyToStartPacket()
{

    std::string strDName = GetDriverName();
    GfLogTrace("Sending ready to start packet\n");

    PackedBuffer msg;

    try
    {
        msg.pack_ubyte(CLIENTREADYTOSTART_PACKET);
        msg.pack_stdstring(strDName);
    }
//    catch (PackedBufferException &e)
    catch (PackedBufferException)
    {
        GfLogFatal("SendReadyToStartPacket: packed buffer error\n");
    }
    GfLogTrace("SendReadyToStartPacket: packed data length=%d\n",
            msg.length());

    ENetPacket *pPacket = enet_packet_create (msg.buffer(), 
            msg.length(), 
            ENET_PACKET_FLAG_RELIABLE);

    if (enet_peer_send (m_pServer, RELIABLECHANNEL, pPacket))
        GfLogError("SendReadyToStartPacket : enet_peer_send failed\n");
}
Example #5
0
void NetClient::ConnectToDriver(NetDriver driver)
{
    char hostName[256];
    enet_address_get_host_ip (&driver.address,hostName,256);

    if (!driver.client)
    {
        GfLogTrace("Skipping server: %s Address: %s\n",driver.name,hostName);
        return;
    }

    if (strcmp(driver.name,GetDriverName())==0)
    {
        GfLogTrace("Skipping ourself: %s Address:  %s\n",driver.name,hostName);
        return;
    }

    ENetPeer * pCurrentPeer;

    for (pCurrentPeer = m_pClient-> peers;
            pCurrentPeer < & m_pClient->peers [m_pClient->peerCount];
            ++ pCurrentPeer)
    {
        if (pCurrentPeer->state == ENET_PEER_STATE_CONNECTED)
        {
            if ((pCurrentPeer->address.host == driver.address.host)&&
                    (pCurrentPeer->address.port == driver.address.port))
            {
                GfLogTrace("Already connected to driver: %s Address: %s\n",driver.name,hostName);
                return;
            }
        }

    }

    GfLogTrace("connecting to driver: %s Address: %s\n",driver.name,hostName);

    //Connect to peer player
    //ENetPeer *pPeer = enet_host_connect (m_pClient, &driver.address, 2);



    ENetEvent event;

    if (enet_host_service (m_pClient, & event, 5000) > 0 &&
            event.type == ENET_EVENT_TYPE_CONNECT)
    {
        GfLogTrace("Successfully connected to peer\n");
        return;
    }
    else
    {
        //char hostName[256];
        //enet_address_get_host_ip (&event.peer->address,hostName,256);
        GfLogWarning("Failed to connect to peer! (%X)\n", &event.peer->address);
        return;
    }

}
Example #6
0
BMessage* 
PrinterDriver::ConfigJob(BMessage* settings)
{
	DBGMSG((">%s: config_job\n", GetDriverName()));
	DUMP_BMESSAGE(settings);
	DUMP_BNODE(fSpoolFolder);
	
	BMessage jobSettings(*settings);
	_MergeWithPreviousSettings(kAttrJobSettings, &jobSettings);
	UIDriver uiDriver(&jobSettings, fPrinterData, fPrinterCap);
	BMessage *result = uiDriver.ConfigJob();
	_WriteSettings(kAttrJobSettings, result);
	
	DUMP_BMESSAGE(result);
	DBGMSG(("<%s: config_job\n", GetDriverName()));
	return result;
}
Example #7
0
CDataLoader* CAsnCache_DataLoaderCF::CreateAndRegister(
    CObjectManager& om,
    const TPluginManagerParamTree* params) const
{
    string db_path =
        GetParam(GetDriverName(), params,
                 "DbPath", false);

    // IsDefault and Priority arguments may be specified
    return CAsnCache_DataLoader::RegisterInObjectManager(om, db_path).GetLoader();
}
Example #8
0
void 
PrinterDriver::About() 
{
	BString copyright;
	copyright = "libprint Copyright © 1999-2000 Y.Takagi\n";
	copyright << GetCopyright();
	copyright << "All Rights Reserved.";
	
	AboutBox app(GetSignature(), GetDriverName(), GetVersion(), copyright.String());
	app.Run();
}
Example #9
0
// ---------------------------------------------------------------
// PrintSpooledJob
//
// Loads the printer add-on and calls its take_job function with
// the spool file as argument.
//
// Parameters:
//    spoolFile - the path to the spool file.
//
// Returns:
//    B_OK if successful.
// ---------------------------------------------------------------
status_t 
Printer::PrintSpooledJob(const char* spoolFile)
{
	BString driver;
	status_t result = GetDriverName(&driver);
	if (result != B_OK)
		return result;

	PrintAddOnServer addOn(driver.String());
	return addOn.TakeJob(spoolFile, SpoolDir());
}
Example #10
0
/*
 * Given a display pointer and screen number, return a __DRIdriver handle.
 * Return NULL if anything goes wrong.
 */
__DRIdriver *driGetDriver(Display *dpy, int scrNum)
{
   char *driverName;
   if (GetDriverName(dpy, scrNum, &driverName)) {
      __DRIdriver *ret;
      ret = OpenDriver(driverName);
      if (driverName)
     	 Xfree(driverName);
      return ret;
   }
   return NULL;
}
Example #11
0
BMessage* 
PrinterDriver::TakeJob(BFile* printJob, BMessage* settings)
{
	DBGMSG((">%s: take_job\n", GetDriverName()));
	DUMP_BMESSAGE(settings);
	DUMP_BNODE(fSpoolFolder);

	fGraphicsDriver = InstantiateGraphicsDriver(settings, fPrinterData, fPrinterCap);
	const JobData* jobData = fGraphicsDriver->GetJobData(printJob);
	if (jobData != NULL && jobData->GetShowPreview()) {
		off_t offset = printJob->Position();
		PreviewWindow *preview = new PreviewWindow(printJob, true);
		if (preview->Go() != B_OK) {
			return new BMessage('okok');
		}
		printJob->Seek(offset, SEEK_SET);
	}	
	BMessage *result = fGraphicsDriver->TakeJob(printJob);

	DUMP_BMESSAGE(result);
	DBGMSG(("<%s: take_job\n", GetDriverName()));
	return result;
}
Example #12
0
// ---------------------------------------------------------------
// GetDefaultSettings
//
// Retrieve the default configuration message from printer add-on
//
// Parameters:
//   settings, output paramter.
//
// Returns:
//    B_OK if successful or errorcode otherwise.
// ---------------------------------------------------------------
status_t 
Printer::GetDefaultSettings(BMessage& settings)
{
	BString driver;
	status_t result = GetDriverName(&driver);
	if (result != B_OK)
		return result;

	PrintAddOnServer addOn(driver.String());
	result = addOn.DefaultSettings(SpoolDir(), &settings);
	if (result == B_OK)
		AddCurrentPrinter(settings);

	return result;
}
Example #13
0
// ---------------------------------------------------------------
// ConfigurePage
//
// Handles calling the printer addon's config_page function.
//
// Parameters:
//    settings - Page settings to display. The contents of this
//               message will be replaced with the new settings
//               if the function returns success.
//
// Returns:
//    B_OK if successful or errorcode otherwise.
// ---------------------------------------------------------------
status_t 
Printer::ConfigurePage(BMessage& settings)
{
	BString driver;
	status_t result = GetDriverName(&driver);
	if (result != B_OK)
		return result;

	PrintAddOnServer addOn(driver.String());
	result = addOn.ConfigPage(SpoolDir(), &settings);
	if (result == B_OK) {
		AddCurrentPrinter(settings);
	}
	return result;
}
Example #14
0
/*
 * Exported function for querying the DRI driver for a given screen.
 *
 * The returned char pointer points to a static array that will be
 * overwritten by subsequent calls.
 */
const char *glXGetScreenDriver (Display *dpy, int scrNum) {
   static char ret[32];
   char *driverName;
   if (GetDriverName(dpy, scrNum, &driverName)) {
      int len;
      if (!driverName)
	 return NULL;
      len = strlen (driverName);
      if (len >= 31)
	 return NULL;
      memcpy (ret, driverName, len+1);
      Xfree(driverName);
      return ret;
   }
   return NULL;
}
Example #15
0
/*
* Some UEFI firmwares (like HPQ EFI from HP notebooks) have DiskIo protocols
* opened BY_DRIVER (by Partition driver in HP case) even when no file system
* is produced from this DiskIo. This then blocks our FS driver from connecting
* and producing file systems.
* To fix it we disconnect drivers that connected to DiskIo BY_DRIVER if this
* is a partition volume and if those drivers did not produce file system.
*/
static VOID DisconnectBlockingDrivers(VOID) {
    EFI_STATUS Status;
    UINTN HandleCount = 0, Index, OpenInfoIndex, OpenInfoCount;
    EFI_HANDLE *Handles = NULL;
    CHAR16 *DevicePathString;
    EFI_FILE_IO_INTERFACE *Volume;
    EFI_BLOCK_IO *BlockIo;
    EFI_OPEN_PROTOCOL_INFORMATION_ENTRY *OpenInfo;

    // Get all DiskIo handles
    Status = BS->LocateHandleBuffer(ByProtocol, &DiskIoProtocol, NULL, &HandleCount, &Handles);
    if (EFI_ERROR(Status) || (HandleCount == 0))
        return;

    // Check every DiskIo handle
    for (Index = 0; Index < HandleCount; Index++) {
        // If this is not partition - skip it.
        // This is then whole disk and DiskIo
        // should be opened here BY_DRIVER by Partition driver
        // to produce partition volumes.
        Status = BS->HandleProtocol(Handles[Index], &BlockIoProtocol, (VOID **)&BlockIo);
        if (EFI_ERROR(Status))
            continue;
        if ((BlockIo->Media == NULL) || (!BlockIo->Media->LogicalPartition))
            continue;

        // If SimpleFileSystem is already produced - skip it, this is ok
        Status = BS->HandleProtocol(Handles[Index], &FileSystemProtocol, (VOID **)&Volume);
        if (Status == EFI_SUCCESS)
            continue;

        DevicePathString = DevicePathToStr(DevicePathFromHandle(Handles[Index]));
        Print(L"%N\r[ INFO ] Probing %d devices... [%d] %s", HandleCount, Index + 1, DevicePathString);
        FreePool(DevicePathString);

        // If no SimpleFileSystem on this handle but DiskIo is opened BY_DRIVER
        // then disconnect this connection
        Status = BS->OpenProtocolInformation(Handles[Index], &DiskIoProtocol, &OpenInfo, &OpenInfoCount);
        if (EFI_ERROR(Status)) {
            Print(L"%H\n[ WARN ] Could not get DiskIo protocol: %r\n", Status);
            FreePool(DevicePathString);
            continue;
        }

        if (OpenInfoCount > 0)
            Print(L"%N\n[ INFO ] Disconnecting %d drivers...", OpenInfoCount);

        for (OpenInfoIndex = 0; OpenInfoIndex < OpenInfoCount; OpenInfoIndex++) {
            if ((OpenInfo[OpenInfoIndex].Attributes & EFI_OPEN_PROTOCOL_BY_DRIVER) == EFI_OPEN_PROTOCOL_BY_DRIVER) {
                Print(L"%N\r[ INFO ] Disconnecting %d drivers... [%d] %s", OpenInfoCount, OpenInfoIndex+1, GetDriverName(OpenInfo[OpenInfoIndex].AgentHandle));
                Status = BS->DisconnectController(Handles[Index], OpenInfo[OpenInfoIndex].AgentHandle, NULL);
                if (EFI_ERROR(Status)) {
                    Print(L"%H\n[ WARN ] Could not disconnect driver: %r\n", Status);
                }
            }
        }
        FreePool(OpenInfo);
    }
    FreePool(Handles);
}
//General connection method
BOOL	CAviCap::_connect2Driver(int indx)
{
	CHECKWIN();	
	if(indx<0||indx>_totalDrv())
		{
		TRACE("CAviCap Window connection failed: illegal driver index\n");
		iLastError=CAP_ILLEGAL_DRIVERID;
		return FALSE;
		}
	 AfxGetApp( )-> DoWaitCursor( 1 );
	
	//connect via VFW
	BOOL ret=capDriverConnect(GetSafeHwnd(), indx);
	checkQuit();
		
	if(ret)
	{
	//starts gathering of driver information
	 	_curDriver=indx;
		if(!_getCaps()||
		   !_getSetup()||
		   !_getStatus()||
		   !_getFormat())
		   	{
		   	iLastError=CAP_INIT_FAILED;
		   	ret=FALSE;
			}
		else
			{
			//try to make window unvisible befor testing
			BOOL vsbl=IsWindowVisible();
			if(vsbl)	ShowWindow(SW_HIDE);
	
			//Slow or fast connection?
			if(!m_DoQuickConnection) {
			 //OK. We have enough time to test driver :-)
			 UP_THR();

			 #ifdef	ON_CONNECT_TEST_BIBITSCOUNT
				_testBiBitsCount();
			 #endif
			 checkQuit();

			 #ifdef ON_CONNECT_CHECK_VALIDFORMATS
				_testValidFormats();
			 #endif
			 checkQuit();

			 #ifdef DEFAULT_FORCE_SINGLE_FRAME
				_testInternalBuffers();
			 #endif
			 checkQuit();
			 DN_THR();
			}
			//else skip testing
				
		// Setup default capture parameters
		// OPTIONAL
		#ifdef DEFAULT_FORCE_SINGLE_FRAME
			capSetCallbackOnFrame(GetSafeHwnd(),(LPVOID)_1FrameCallbackProc);
			_1FrameCallBackInstalled = TRUE;
		#else
			capSetCallbackOnFrame(GetSafeHwnd(), _defaultFrameCallbackProc);
			capPreviewRate(GetSafeHwnd(), _previewRate);
		#endif
		
		#ifdef DEFAULT_USED_DOSMEMORY
			_captureParms.wNumVideoRequested=1;
			_captureParms.fUsingDOSMemory=TRUE;
		#endif	

		#ifdef DEFAULT_STEP_CAPTUREAT2X
			_captureParms.fStepCaptureAt2x=TRUE;
			_captureParms.wStepCaptureAverageFrames=3;
		#endif
		
		_captureParms.dwRequestMicroSecPerFrame=20000;
		_captureParms.fYield = TRUE;
		capCaptureSetSetup (GetSafeHwnd(), &_captureParms, sizeof CAPTUREPARMS);
		capCaptureGetSetup (GetSafeHwnd(), &_captureParms, sizeof CAPTUREPARMS);		

		if(vsbl)	ShowWindow(SW_SHOW); //restore
		}//end else
		
	}
	else
	{
	AfxGetApp( )-> DoWaitCursor( 0 );
	TRACE("Connection to Capure Driver Failed\n");
	iLastError=CAP_CONNECTION_FAILED;
	return FALSE;
	}
	 
	if(ret) TRACE("Connected to <%s: %s>\n",GetDriverName(),GetDriverVer());

	else	  TRACE("Connection (phase 2) to Capure Driver Failed\n");
	
	if(!ret)	Disconnect();
	
	return ret;
}
Example #17
0
/**
 *  Funktion zum Auslesen des Treibernamens.
 *
 *  @return liefert den Treibernamen zurück
 */
const char* VideoSDL::GetName() const
{
    return GetDriverName();
}
Example #18
0
static
VOID
AddDiskToList(
    HANDLE FileHandle,
    ULONG DiskNumber)
{
    DISK_GEOMETRY DiskGeometry;
    SCSI_ADDRESS ScsiAddress;
    PDISKENTRY DiskEntry;
    IO_STATUS_BLOCK Iosb;
    NTSTATUS Status;
    PPARTITION_SECTOR Mbr;
    PULONG Buffer;
    LARGE_INTEGER FileOffset;
    WCHAR Identifier[20];
    ULONG Checksum;
    ULONG Signature;
    ULONG i;
    PLIST_ENTRY ListEntry;
    PBIOSDISKENTRY BiosDiskEntry;
    ULONG LayoutBufferSize;
    PDRIVE_LAYOUT_INFORMATION NewLayoutBuffer;

    Status = NtDeviceIoControlFile(FileHandle,
                                   NULL,
                                   NULL,
                                   NULL,
                                   &Iosb,
                                   IOCTL_DISK_GET_DRIVE_GEOMETRY,
                                   NULL,
                                   0,
                                   &DiskGeometry,
                                   sizeof(DISK_GEOMETRY));
    if (!NT_SUCCESS(Status))
    {
        return;
    }

    if (DiskGeometry.MediaType != FixedMedia &&
        DiskGeometry.MediaType != RemovableMedia)
    {
        return;
    }

    Status = NtDeviceIoControlFile(FileHandle,
                                   NULL,
                                   NULL,
                                   NULL,
                                   &Iosb,
                                   IOCTL_SCSI_GET_ADDRESS,
                                   NULL,
                                   0,
                                   &ScsiAddress,
                                   sizeof(SCSI_ADDRESS));
    if (!NT_SUCCESS(Status))
    {
        return;
    }

    Mbr = (PARTITION_SECTOR*)RtlAllocateHeap(RtlGetProcessHeap(),
                                             0,
                                             DiskGeometry.BytesPerSector);
    if (Mbr == NULL)
    {
        return;
    }

    FileOffset.QuadPart = 0;
    Status = NtReadFile(FileHandle,
                        NULL,
                        NULL,
                        NULL,
                        &Iosb,
                        (PVOID)Mbr,
                        DiskGeometry.BytesPerSector,
                        &FileOffset,
                        NULL);
    if (!NT_SUCCESS(Status))
    {
        RtlFreeHeap(RtlGetProcessHeap(), 0, Mbr);
        DPRINT1("NtReadFile failed, status=%x\n", Status);
        return;
    }
    Signature = Mbr->Signature;

    /* Calculate the MBR checksum */
    Checksum = 0;
    Buffer = (PULONG)Mbr;
    for (i = 0; i < 128; i++)
    {
        Checksum += Buffer[i];
    }
    Checksum = ~Checksum + 1;

    swprintf(Identifier, L"%08x-%08x-A", Checksum, Signature);
    DPRINT("Identifier: %S\n", Identifier);

    DiskEntry = RtlAllocateHeap(RtlGetProcessHeap(),
                                HEAP_ZERO_MEMORY,
                                sizeof(DISKENTRY));
    if (DiskEntry == NULL)
    {
        return;
    }

//    DiskEntry->Checksum = Checksum;
//    DiskEntry->Signature = Signature;
    DiskEntry->BiosFound = FALSE;

    /* Check if this disk has a valid MBR */
    if (Mbr->BootCode[0] == 0 && Mbr->BootCode[1] == 0)
        DiskEntry->NoMbr = TRUE;
    else
        DiskEntry->NoMbr = FALSE;

    /* Free Mbr sector buffer */
    RtlFreeHeap(RtlGetProcessHeap(), 0, Mbr);

    ListEntry = BiosDiskListHead.Flink;
    while (ListEntry != &BiosDiskListHead)
    {
        BiosDiskEntry = CONTAINING_RECORD(ListEntry, BIOSDISKENTRY, ListEntry);
        /* FIXME:
         *   Compare the size from bios and the reported size from driver.
         *   If we have more than one disk with a zero or with the same signatur
         *   we must create new signatures and reboot. After the reboot,
         *   it is possible to identify the disks.
         */
        if (BiosDiskEntry->Signature == Signature &&
            BiosDiskEntry->Checksum == Checksum &&
            !BiosDiskEntry->Recognized)
        {
            if (!DiskEntry->BiosFound)
            {
                DiskEntry->BiosDiskNumber = BiosDiskEntry->DiskNumber;
                DiskEntry->BiosFound = TRUE;
                BiosDiskEntry->Recognized = TRUE;
            }
            else
            {
            }
        }
        ListEntry = ListEntry->Flink;
    }

    if (!DiskEntry->BiosFound)
    {
#if 0
        RtlFreeHeap(ProcessHeap, 0, DiskEntry);
        return;
#else
        DPRINT1("WARNING: Setup could not find a matching BIOS disk entry. Disk %d is not be bootable by the BIOS!\n", DiskNumber);
#endif
    }

    InitializeListHead(&DiskEntry->PrimaryPartListHead);
    InitializeListHead(&DiskEntry->LogicalPartListHead);

    DiskEntry->Cylinders = DiskGeometry.Cylinders.QuadPart;
    DiskEntry->TracksPerCylinder = DiskGeometry.TracksPerCylinder;
    DiskEntry->SectorsPerTrack = DiskGeometry.SectorsPerTrack;
    DiskEntry->BytesPerSector = DiskGeometry.BytesPerSector;

    DPRINT("Cylinders %I64u\n", DiskEntry->Cylinders);
    DPRINT("TracksPerCylinder %I64u\n", DiskEntry->TracksPerCylinder);
    DPRINT("SectorsPerTrack %I64u\n", DiskEntry->SectorsPerTrack);
    DPRINT("BytesPerSector %I64u\n", DiskEntry->BytesPerSector);

    DiskEntry->SectorCount.QuadPart = DiskGeometry.Cylinders.QuadPart *
                                      (ULONGLONG)DiskGeometry.TracksPerCylinder *
                                      (ULONGLONG)DiskGeometry.SectorsPerTrack;

    DiskEntry->SectorAlignment = DiskGeometry.SectorsPerTrack;
    DiskEntry->CylinderAlignment = DiskGeometry.SectorsPerTrack * DiskGeometry.TracksPerCylinder;

    DPRINT1("SectorCount: %I64u\n", DiskEntry->SectorCount);
    DPRINT1("SectorAlignment: %lu\n", DiskEntry->SectorAlignment);
    DPRINT1("CylinderAlignment: %lu\n", DiskEntry->CylinderAlignment);

    DiskEntry->DiskNumber = DiskNumber;
    DiskEntry->Port = ScsiAddress.PortNumber;
    DiskEntry->Bus = ScsiAddress.PathId;
    DiskEntry->Id = ScsiAddress.TargetId;

    GetDriverName(DiskEntry);

    InsertAscendingList(&DiskListHead, DiskEntry, DISKENTRY, ListEntry, DiskNumber);

    /* Allocate a layout buffer with 4 partition entries first */
    LayoutBufferSize = sizeof(DRIVE_LAYOUT_INFORMATION) +
                       ((4 - ANYSIZE_ARRAY) * sizeof(PARTITION_INFORMATION));
    DiskEntry->LayoutBuffer = RtlAllocateHeap(RtlGetProcessHeap(),
                                              HEAP_ZERO_MEMORY,
                                              LayoutBufferSize);
    if (DiskEntry->LayoutBuffer == NULL)
    {
        DPRINT1("Failed to allocate the disk layout buffer!\n");
        return;
    }

    for (;;)
    {
        DPRINT1("Buffer size: %lu\n", LayoutBufferSize);
        Status = NtDeviceIoControlFile(FileHandle,
                                       NULL,
                                       NULL,
                                       NULL,
                                       &Iosb,
                                       IOCTL_DISK_GET_DRIVE_LAYOUT,
                                       NULL,
                                       0,
                                       DiskEntry->LayoutBuffer,
                                       LayoutBufferSize);
        if (NT_SUCCESS(Status))
            break;

        if (Status != STATUS_BUFFER_TOO_SMALL)
        {
            DPRINT1("NtDeviceIoControlFile() failed (Status: 0x%08lx)\n", Status);
            return;
        }

        LayoutBufferSize += 4 * sizeof(PARTITION_INFORMATION);
        NewLayoutBuffer = RtlReAllocateHeap(RtlGetProcessHeap(),
                                            HEAP_ZERO_MEMORY,
                                            DiskEntry->LayoutBuffer,
                                            LayoutBufferSize);
        if (NewLayoutBuffer == NULL)
        {
            DPRINT1("Failed to reallocate the disk layout buffer!\n");
            return;
        }

        DiskEntry->LayoutBuffer = NewLayoutBuffer;
    }

    DPRINT1("PartitionCount: %lu\n", DiskEntry->LayoutBuffer->PartitionCount);

#ifdef DUMP_PARTITION_TABLE
    DumpPartitionTable(DiskEntry);
#endif

    if (DiskEntry->LayoutBuffer->PartitionEntry[0].StartingOffset.QuadPart != 0 &&
        DiskEntry->LayoutBuffer->PartitionEntry[0].PartitionLength.QuadPart != 0 &&
        DiskEntry->LayoutBuffer->PartitionEntry[0].PartitionType != 0)
    {
        if ((DiskEntry->LayoutBuffer->PartitionEntry[0].StartingOffset.QuadPart / DiskEntry->BytesPerSector) % DiskEntry->SectorsPerTrack == 0)
        {
            DPRINT("Use %lu Sector alignment!\n", DiskEntry->SectorsPerTrack);
        }
        else if (DiskEntry->LayoutBuffer->PartitionEntry[0].StartingOffset.QuadPart % (1024 * 1024) == 0)
        {
            DPRINT1("Use megabyte (%lu Sectors) alignment!\n", (1024 * 1024) / DiskEntry->BytesPerSector);
        }
        else
        {
            DPRINT1("No matching alignment found! Partition 1 starts at %I64u\n", DiskEntry->LayoutBuffer->PartitionEntry[0].StartingOffset.QuadPart);
        }
    }
    else
    {
        DPRINT1("No valid partition table found! Use megabyte (%lu Sectors) alignment!\n", (1024 * 1024) / DiskEntry->BytesPerSector);
    }


    if (DiskEntry->LayoutBuffer->PartitionCount == 0)
    {
        DiskEntry->NewDisk = TRUE;
        DiskEntry->LayoutBuffer->PartitionCount = 4;

        for (i = 0; i < 4; i++)
            DiskEntry->LayoutBuffer->PartitionEntry[i].RewritePartition = TRUE;
    }
    else
    {
        for (i = 0; i < 4; i++)
        {
            AddPartitionToDisk(DiskNumber, DiskEntry, i, FALSE);
        }

        for (i = 4; i < DiskEntry->LayoutBuffer->PartitionCount; i += 4)
        {
            AddPartitionToDisk(DiskNumber, DiskEntry, i, TRUE);
        }
    }

    ScanForUnpartitionedDiskSpace(DiskEntry);
}
Example #19
0
/**
 *  Funktion zum Auslesen des Treibernamens.
 *
 *  @return liefert den Treibernamen zurück
 *
 *  @author FloSoft
 */
const char* VideoWinAPI::GetName(void) const
{
    return GetDriverName();
}
Example #20
0
/** 
 *  Funktion zum Auslesen des Treibernamens.
 *
 *  @return liefert den Treibernamen zurück
 *
 *  @author FloSoft
 */
const char *AudioSDL::GetName(void) const
{
	return GetDriverName();
}