/* drive_exists: * Checks whether the specified drive is valid. */ static int drive_exists(int x) { #ifdef ALLEGRO_DOS /* DOS implementation */ unsigned int old; int ret = FALSE; __dpmi_regs r; /* get actual drive */ r.h.ah = 0x19; __dpmi_int(0x21, &r); old = r.h.al; /* see if drive x is assigned as a valid drive */ r.h.ah = 0x0E; r.h.dl = x; __dpmi_int(0x21, &r); r.h.ah = 0x19; __dpmi_int(0x21, &r); if (r.h.al == x) { /* ok, now check if it is a logical drive or not... */ r.x.ax = 0x440E; r.h.bl = x+1; __dpmi_int(0x21, &r); if ((r.x.flags & 1) || /* call failed */ (r.h.al == 0) || /* has no logical drives */ (r.h.al == (x+1))) /* not a logical drive */ ret = TRUE; } /* now we set the old drive */ r.h.ah = 0x0E; r.h.dl = old; __dpmi_int(0x21, &r); return ret; #elif defined ALLEGRO_WINDOWS /* Windows implementation */ return GetLogicalDrives() & (1 << x); #elif defined ALLEGRO_MPW /* MacOs implementation */ return GetLogicalDrives() & (1 << x); #else /* unknown platform */ return TRUE; #endif }
OP_STATUS WindowsOpFolderLister::Construct(const uni_char* path, const uni_char* pattern) { m_find_handle = INVALID_HANDLE_VALUE; RETURN_IF_ERROR(m_path_pattern.Set(path)); if (!m_path_pattern.Length() || m_path_pattern[m_path_pattern.Length() - 1] != '\\') { RETURN_IF_ERROR(m_path_pattern.Append("\\")); } m_path = OP_NEWA(uni_char, m_path_pattern.Length() + MAX_PATH + 1); if (m_path == NULL) return OpStatus::ERR_NO_MEMORY; m_path_length = m_path_pattern.Length(); uni_strcpy(m_path, m_path_pattern.CStr()); RETURN_IF_ERROR(m_path_pattern.Append(pattern)); if (!m_path_pattern.Compare(UNI_L("\\*"))) { if ((m_drives = GetLogicalDrives()) == 0) return OpStatus::ERR; } else if (m_path_pattern[0] == '\\' && m_path_pattern[1] != '\\') // remove \ before drive name if present but not from network paths { m_path_pattern.Delete(0, 1); } return OpStatus::OK; }
int CUpdateBase::GetUDisk(char pDiskName[], int len) { DWORD MaxDriveSet; DWORD drive; TCHAR szDrvName[33]; int count = 0; MaxDriveSet = GetLogicalDrives();//GetLogicalDrives for (drive = 0; drive < 32; drive++) { if ( MaxDriveSet & (1 << drive) ) { DWORD temp = 1<<drive; _stprintf(szDrvName, _T("%c:\\"), 'A'+drive);//szDrvName if(GetDriveType(szDrvName)== DRIVE_REMOVABLE && (drive > 1)) { pDiskName[count++] = 'A'+ (char)drive; if(count >= len) { break; } } } } return count; }
void CMountPoints::GetDriveVolumes() { m_drive.SetSize(32); DWORD drives= GetLogicalDrives(); int i; DWORD mask= 0x00000001; for (i=0; i < 32; i++, mask <<= 1) { CString volume; if ((drives & mask) != 0) { CString s; s.Format(_T("%c:\\"), i + _T('A')); BOOL b= m_va.GetVolumeNameForVolumeMountPoint(s, volume.GetBuffer(_MAX_PATH), _MAX_PATH); volume.ReleaseBuffer(); if (!b) { TRACE(_T("GetVolumeNameForVolumeMountPoint(%s) failed.\n"), s); volume.Empty(); } } m_drive[i]= volume; } }
void CIRC::FindDrives(void) { char szDrive[MSG_SIZE]="", szVolumeName[MSG_SIZE]="", szFileSystem[MSG_SIZE]=""; DWORD dwDrives=0, dwSerial, dwMask=1, dwDamn1, dwDamn2; int iTemp=65; SendMessage("Start of drive listing"); dwDrives = GetLogicalDrives(); for(int i=0; i<26; i++) { if((dwDrives & dwMask)) { sprintf(szDrive, "%c:\\", iTemp); GetVolumeInformation(szDrive, szVolumeName, MSG_SIZE, &dwSerial, &dwDamn1, &dwDamn2, szFileSystem, MSG_SIZE); sprintf(szDrive, "%c:\\ %s %s", iTemp, szVolumeName, szFileSystem); SendMessage(szDrive); memset(szDrive, 0, MSG_SIZE); memset(szVolumeName, 0, MSG_SIZE); memset(szFileSystem, 0, MSG_SIZE); } iTemp+=1; dwMask *= 2; } SendMessage("End of drive listing"); }
//================================================================================================================ vector<string> CGlobal::GetAvailableDrives() { DWORD bitmask = GetLogicalDrives(); vector<string> drivesAvailable; vector<string> driveList; //Can add the rest of the alphabet. driveList.push_back("a:"); driveList.push_back("b:"); driveList.push_back("c:"); driveList.push_back("d:"); driveList.push_back("e:"); driveList.push_back("f:"); driveList.push_back("g:"); driveList.push_back("h:"); driveList.push_back("i:"); for (int i = 0; i < driveList.size(); i++) { string drive = driveList[i]; if ((bitmask & (1 << i)) == 0) //Shift bitmask and if 0 drive is free { // Free and does not exist in the system } else { drivesAvailable.push_back(drive); } } return drivesAvailable; }
L00401324() { /* unknown */ void Vffffff88; /* unknown */ void Vffffffc8; edi = 0x4030f0; ecx = eax; esi = esi | eax; GetCurrentProcessId(); for(*(edi - 68) = 3; *(edi - 68) != 0; asm("sbb esi,edx");) { *(edi - 68) = *(edi - 68) - 1; *(edi + 240) = *(edi + 240) | -78; } asm("adc dword [ebp+0xffffff68],+0x71"); (save)edi; (save) *(edi + 280); (save)Vffffffc8; (save) *(edi + 740); (save) *(edi + 668); L0040112C(); (restore)edi; ebx = ebx + Vffffff88; return(GetLogicalDrives()); }
static int frontend_win32_parse_drive_list(void *data, bool load_content) { #ifdef HAVE_MENU file_list_t *list = (file_list_t*)data; enum msg_hash_enums enum_idx = load_content ? MENU_ENUM_LABEL_FILE_DETECT_CORE_LIST_PUSH_DIR : MSG_UNKNOWN; size_t i = 0; unsigned drives = GetLogicalDrives(); char drive[] = " :\\"; for (i = 0; i < 32; i++) { drive[0] = 'A' + i; if (drives & (1 << i)) menu_entries_append_enum(list, drive, msg_hash_to_str(MENU_ENUM_LABEL_FILE_DETECT_CORE_LIST_PUSH_DIR), enum_idx, FILE_TYPE_DIRECTORY, 0, 0); } #endif return 0; }
void get_disk_info_all(){ DWORD dwNumBytesForDriveStrings; char DriveStrings[255]; char* dp = DriveStrings; dwNumBytesForDriveStrings = GetLogicalDriveStrings(254,dp); if (dwNumBytesForDriveStrings != 0) { /* GetLogicalDriveStringsIs supported on this platform */ while (*dp != 0) { output_drive_info(dp); dp = strchr(dp,0) +1; } } else { /* GetLogicalDriveStrings is not supported (some old W95) */ DWORD dwDriveMask = GetLogicalDrives(); int nDriveNum; char drivename[]="A:\\"; /*printf("DriveName95 DriveType BytesAvail BytesTotal BytesTotalFree\n");*/ for (nDriveNum = 0; dwDriveMask != 0;nDriveNum++) { if (dwDriveMask & 1) { drivename[0]='A'+ nDriveNum; output_drive_info(drivename); } dwDriveMask = dwDriveMask >> 1; } } }
/* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % % I s M a g i c k C o n f l i c t % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % IsMagickConflict() returns true if the image format conflicts with a logical % drive (.e.g. X:). % % The format of the IsMagickConflict method is: % % MagickBooleanType IsMagickConflict(const char *magick) % % A description of each parameter follows: % % o magick: Specifies the image format. % */ MagickExport MagickBooleanType NTIsMagickConflict(const char *magick) { assert(magick != (char *) NULL); if (strlen(magick) > 1) return(MagickFalse); return((GetLogicalDrives() & (1 << ((toupper((int) (*magick)))-'A'))) != 0); }
static void playlist_loaddir_get_driveinfos(void) { DWORD drivesbits,i,vlen; loaddir_clear_driveinfos(0); drivesbits=GetLogicalDrives(); if(!drivesbits) return; i=LOADDIR_FIRSTDRIVE; drivesbits>>=LOADDIR_FIRSTDRIVE; do{ if(drivesbits&1){ mpxplay_drivemap_info_t *di=&drivemap_infos[i]; di->type=pds_chkdrive(i); loaddir_build_drivename(i,di->drivename); if((i>=2) || (di->type!=DRIVE_TYPE_FLOPPY)){ if(di->type==DRIVE_TYPE_NETWORK){ vlen=LOADDIR_DRIVE_VOLUMENAME_LEN; WNetGetConnection(di->drivename,&di->volumename[0],&vlen); } if((di->type!=DRIVE_TYPE_NETWORK) || !di->volumename[0]) pds_drive_getvolumelabel(i,&di->volumename[0],LOADDIR_DRIVE_VOLUMENAME_LEN); } if(loaddir_lastvaliddrive<i) loaddir_lastvaliddrive=i; } drivesbits>>=1; i++; }while(i<LOADDIR_MAX_LOCAL_DRIVES); loaddir_diskdrives_mount_localdisks(); }
static void GetCryptKey(uint32_t* cryptKey, unsigned numElements) { char volName[] = "C:\\"; int index = 0; DWORD logicalDrives = GetLogicalDrives(); for (int i = 0; i < 32; ++i) { if (logicalDrives & (1 << i)) { volName[0] = ('C' + i); DWORD volSerialNum = 0; BOOL result = GetVolumeInformation( volName, //LPCTSTR lpRootPathName, NULL, //LPTSTR lpVolumeNameBuffer, 0, //DWORD nVolumeNameSize, &volSerialNum, //LPDWORD lpVolumeSerialNumber, NULL, //LPDWORD lpMaximumComponentLength, NULL, //LPDWORD lpFileSystemFlags, NULL, //LPTSTR lpFileSystemNameBuffer, 0 //DWORD nFileSystemNameSize ); cryptKey[index] = (cryptKey[index] ^ volSerialNum); index = (++index) % numElements; } } }
void CTreeFileCtrl::DisplayDrives(HTREEITEM hParent, BOOL bUseSetRedraw) { CWaitCursor c; //Speed up the job by turning off redraw if (bUseSetRedraw) SetRedraw(FALSE); //Remove any items currently in the tree DeleteAllItems(); //Enumerate the drive letters and add them to the tree control DWORD dwDrives = GetLogicalDrives(); DWORD dwMask = 1; for (int i=0; i<32; i++) { if (dwDrives & dwMask) { CString sDrive; sDrive.Format(_T("%c:\\"), i + _T('A')); InsertFileItem(sDrive, sDrive, hParent); } dwMask <<= 1; } if (bUseSetRedraw) SetRedraw(TRUE); }
const std::deque<VolumeInfo> CVolumeEnumerator::enumerateVolumesImpl() { std::deque<VolumeInfo> volumes; const auto oldErrorMode = SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX); EXEC_ON_SCOPE_EXIT([oldErrorMode]() {SetErrorMode(oldErrorMode);}); DWORD drives = GetLogicalDrives(); if (drives == 0) { qInfo() << "GetLogicalDrives() returned an error:" << ErrorStringFromLastError(); return volumes; } for (char driveLetter = 'A'; drives != 0 && driveLetter <= 'Z'; ++driveLetter, drives >>= 1) { if ((drives & 0x1) == 0) continue; const auto volumeInfo = volumeInfoForDriveLetter(QString(driveLetter) + QStringLiteral(":\\")); if (!volumeInfo.isEmpty()) volumes.push_back(volumeInfo); } return volumes; }
static int do_paths(int sel) { path_sel *paths = new path_sel(); paths->add_item(getenv("HOME")); #ifdef RAINE_UNIX int pipe_opened = 0; FILE *f = fopen("/etc/mtab","r"); if (!f) { // Darwin doesn't seem to have a file for that, so let's use popen... f = popen("mount","r"); pipe_opened = 1; } if (f) { char buff[2048]; while (!feof(f)) { fgets(buff,2048,f); if (strncmp(buff,"/dev/",5)) // keep only the /dev entries continue; char *s1 = strchr(buff,' '); if (!s1) continue; char *s2 = strchr(s1+1,' '); if (!s2) continue; *s2 = 0; if (!strcmp(s1+1,"on")) { // darwin speciality, just ignore it s1 = s2; s2 = strchr(s1+1,'('); if (!s2) continue; s2[-1] = 0; } paths->add_item(s1+1); } if (pipe_opened) pclose(f); else fclose(f); } #else // windows paths->add_item(getenv("PROGRAMFILES")); paths->add_item(getenv("USERPROFILE")); int drives = GetLogicalDrives(); int n; char path[3]; strcpy(path,"x:"); for (n=0; n<32; n++) { if (drives & (1<<n)) { path[0]=65+n; paths->add_item(path); } } #endif selected_path = -1; TMenu *menu = new TPathDlg((char*)_("Path selection"),paths->get_menu()); menu->execute(); if (selected_path >= 0) dlg->set_dir((char*)paths->get_menu()[selected_path].label); delete menu; delete paths; return 0; }
char *Bgetsystemdrives(void) { #ifdef _WIN32 char *str, *p; DWORD drv, mask; int number=0; drv = GetLogicalDrives(); if (drv == 0) return NULL; for (mask=1; mask<0x8000000l; mask<<=1) { if ((drv&mask) == 0) continue; number++; } str = p = (char *)malloc(1 + (3*number)); if (!str) return NULL; number = 0; for (mask=1; mask<0x8000000l; mask<<=1, number++) { if ((drv&mask) == 0) continue; *(p++) = 'A' + number; *(p++) = ':'; *(p++) = 0; } *(p++) = 0; return str; #else // Perhaps have Unix OS's put /, /home/user, and /mnt/* in the "drives" list? return NULL; #endif }
ULONG DiskDriveQueryDeviceMap(VOID) { #ifndef _WIN64 PROCESS_DEVICEMAP_INFORMATION deviceMapInfo; #else PROCESS_DEVICEMAP_INFORMATION_EX deviceMapInfo; #endif memset(&deviceMapInfo, 0, sizeof(deviceMapInfo)); if (NT_SUCCESS(NtQueryInformationProcess( NtCurrentProcess(), ProcessDeviceMap, &deviceMapInfo, sizeof(deviceMapInfo), NULL ))) { return deviceMapInfo.Query.DriveMap; } else { return GetLogicalDrives(); } }
char CFileManager::GetFirstNextDriveLetter( bool first ){ if( first ){ FirstNext=0; DriveLetterMask = GetLogicalDrives(); } else FirstNext++; char creturn = 0; for( int n=FirstNext;n<32;n++ ){ if( ((DriveLetterMask & (1 << n )) > 0) ){ creturn = 'A'; creturn += n; FirstNext=n; return creturn; } } return creturn; }
L0040112C() { /* unknown */ void Vffffffa4; /* unknown */ void Vffffffc0; L0040112f: esi = edi - 48; ebx = ebx | ecx; if(esi < 18273) { goto L0040112f; } GetLogicalDrives(); for(*(esi + 372) = 0; *(esi + 372) != 5; *(esi + -148) = *(esi + -148) + ecx) { *(esi + 372) = *(esi + 372) + 1; if(esi <= 31395) { goto L0040112B; } } edx = edx & *(esi + 208); (save)esi; L004012B0( *(esi + 36), Vffffffc0, *(esi + 312), Vffffffa4); (restore)esi; eax = ecx; eax = esi + 1968; L0040118e: LoadLibraryA(eax); if(eax != 0) { goto L0040118e; } }
void ScanDrives ( void (CPROC*Process)(uintptr_t user, CTEXTSTR letter, int flags) , uintptr_t user ) { #ifdef WIN32 # ifdef UNDER_CE Process( user, WIDE(""), SFF_DRIVE ); # else uint32_t drives; int i; drives = GetLogicalDrives(); for( i = 0; i < 26; i++ ) { TEXTCHAR name[2]; name[1] = 0; if( drives & ( 1 << i ) ) { name[0] = 'A' + i; if( Process ) Process( user, name, SFF_DRIVE ); } } # endif #endif }
L004014D0() { /* unknown */ void eax; /* unknown */ void Vffffffd0; /* unknown */ void Vffffffd8; /* unknown */ void Vfffffffc; eax = 0x403020; L00401938(esi, Vfffffffc, esi, ecx); (restore)eax; ecx = ecx & -118; ebx = ebx ^ Vfffffffc; (save)eax; GetCommandLineA(); (restore)eax; Vffffffd8 = 5; do { Vffffffd0 = Vffffffd0 + -1547170621; edx = edx | Vffffffd8; Vffffffd8 = Vffffffd8 - 1; } while(Vffffffd8 != 0); ebx = ebx | *(eax + 716); asm("sbb dword [ebp-0x3c],+0x78"); return(GetLogicalDrives(eax)); }
static NTSTATUS lsvol_dev(PWSTR DeviceName) { NTSTATUS Result; PWCHAR VolumeListBuf, VolumeListBufEnd; SIZE_T VolumeListSize; DWORD LogicalDrives; WCHAR Drive[3] = L"\0:"; Result = FspToolGetVolumeList(DeviceName, &VolumeListBuf, &VolumeListSize); if (!NT_SUCCESS(Result)) return Result; VolumeListBufEnd = (PVOID)((PUINT8)VolumeListBuf + VolumeListSize); LogicalDrives = GetLogicalDrives(); for (PWCHAR P = VolumeListBuf, VolumeName = P; VolumeListBufEnd > P; P++) if (L'\0' == *P) { Drive[0] = FspToolGetDriveLetter(&LogicalDrives, VolumeName); info("%-4S%S", Drive[0] ? Drive : L"", VolumeName); VolumeName = P + 1; } MemFree(VolumeListBuf); return STATUS_SUCCESS; }
static BOOL FillDriveList() { DRIVE_INFO di; TCHAR chDrive = TEXT('A'); DWORD dwDrives = GetLogicalDrives(); // This failing is not fatal to this function // Make sure the partition table is up to date afs_status_t nStatus; int nResult = ReadPartitionTable(&nStatus); ASSERT(nResult); while (dwDrives) { if (dwDrives & 1) { memset(&di, 0, sizeof(di)); if (GetDriveInfo(chDrive, di)) { FASTLISTADDITEM ai = { 0, di.nImage, IMAGE_NOIMAGE, di.szRootDir, di.bDisabled, di.dwFlags }; HLISTITEM hItem = FastList_AddItem(m_hDriveList, &ai); FastList_SetItemText(m_hDriveList, hItem, 1, di.szVolName); FastList_SetItemText(m_hDriveList, hItem, 2, di.szSize); } } chDrive++; dwDrives >>= 1; } return TRUE; }
BOOL CSysInfo::getLogicalDrives( CLogicalDriveList *pMyList) { CLogicalDrive cLogicalDrive; UINT uIndex; DWORD dwValue; CString csDrive; // First, try WMI if (m_wmiInfo.GetLogicalDrives( pMyList)) return TRUE; // Last, use GetLogicalDrives API pMyList->RemoveAll(); if ((dwValue = GetLogicalDrives()) != 0) { for (uIndex=0; uIndex<=26; uIndex++) { // Check if the logical drive uIndex really exists if (dwValue & 1) { // Yes => Construct the root directory csDrive.Format( _T( "%c:\\"), 'A'+uIndex); // Check if this is a local Hard Disk cLogicalDrive.RetrieveDriveInfo( csDrive); // Add the logical drive to the list pMyList->AddTail( cLogicalDrive); } // Bit shift the logical drives mask dwValue >>= 1; } } return TRUE; }
/* opendir implementation which emulates a virtual root with the drive letters presented as directories. */ UNFS3_WIN_DIR *win_opendir(const char *name) { wchar_t *winpath; UNFS3_WIN_DIR *ret; ret = malloc(sizeof(UNFS3_WIN_DIR)); if (!ret) { logmsg(LOG_CRIT, "win_opendir: Unable to allocate memory"); return NULL; } if (!strcmp("/", name)) { /* Emulate root */ ret->stream = NULL; ret->currentdrive = 0; ret->logdrives = GetLogicalDrives(); } else { winpath = intpath2winpath(name); if (!winpath) { free(ret); errno = EINVAL; return NULL; } ret->stream = _wopendir(winpath); free(winpath); if (ret->stream == NULL) { free(ret); ret = NULL; } } return ret; }
void *vlc_opendir_wrapper( const char *psz_path ) { vlc_DIR *p_dir = NULL; DIR *p_real_dir = NULL; if ( psz_path == NULL || psz_path[0] == '\0' || (psz_path[0] == '\\' && psz_path[1] == '\0') ) { /* Special mode to list drive letters */ p_dir = malloc( sizeof(vlc_DIR) ); if( !p_dir ) return NULL; p_dir->p_real_dir = NULL; p_dir->i_drives = GetLogicalDrives(); return (void *)p_dir; } p_real_dir = opendir( psz_path ); if ( p_real_dir == NULL ) return NULL; p_dir = malloc( sizeof(vlc_DIR) ); if( !p_dir ) { _wclosedir( p_real_dir ); return NULL; } p_dir->p_real_dir = p_real_dir; p_dir->b_insert_back = ( psz_path[1] == ':' && psz_path[2] == '\\' && psz_path[3] =='\0' ); return (void *)p_dir; }
/* pick the first available drive, starting with E: drive must be able to store two chars (e.g. "F:") */ char *get_default_mount_point(char *mount_point) { DWORD mask, drive_bit; char drive_char; mount_point[0] = '\0'; mask = GetLogicalDrives(); if (mask != 0) { /* scan for an available drive (0 bit) */ drive_bit = 1 << 4; /* E: */ drive_char = 'E'; while (drive_char <= 'Z' && (mask & drive_bit)) { drive_bit <<= 1; drive_char++; } if (drive_char <= 'Z') { mount_point[0] = drive_char; mount_point[1] = ':'; mount_point[2] = '\0'; } } /* will return empty string on error/no available drives the program will either set a user-specified drive or abort later */ return mount_point; }
ui32 getDrives(){ #if defined(_WIN32)||defined(_WIN_32) return GetLogicalDrives(); #endif // _WIN_32 }
///////////////////////////////////////////////////////////////////////////// // CDriverBox message handlers //创建控件时调用,该函数中查找所有可用的驱动器 //并将其名称保存到列表字符列表中和加入到显示列表中 void CDriverBox::PreSubclassWindow() { // TODO: Add your specialized code here and/or call the base class CComboBox::PreSubclassWindow(); DWORD drives=GetLogicalDrives(); int nums=0; drives>>=2; char disk[]=_T("c:\\"); while(drives) { if(drives&0x01) { UINT type=GetDriveType(disk); if(type==DRIVE_FIXED||type==DRIVE_REMOTE) { disk[2]=0; AddString(disk); m_drvList.AddTail(disk); disk[2]='\\'; } } disk[0]++; drives>>=1; } }
int getDriveNumberFromLetter(char lookingforname) { unsigned long driveMask = GetLogicalDrives(); int i = 0; ULONG pID; while (driveMask != 0) { if (driveMask & 1) { // the "A" in drivename will get incremented by the # of bits // we've shifted char drivename[] = "\\\\.\\A:\\"; drivename[4] += i; if (checkDriveType(drivename, &pID)) { if (lookingforname == drivename[4]) { return pID; } } } driveMask >>= 1; ++i; } return -1; }