Esempio n. 1
0
/**********************************************************************
 *	    INT_Int11Handler (WPROCS.117)
 *
 * Handler for int 11h (get equipment list).
 */
void WINAPI INT_Int11Handler( CONTEXT86 *context )
{
    int diskdrives = 0;
    int parallelports = 0;
    int serialports = 0;
    int x;

/* borrowed from Ralph Brown's interrupt lists

		    bits 15-14: number of parallel devices
		    bit     13: [Conv] Internal modem
		    bit     12: reserved
		    bits 11- 9: number of serial devices
		    bit      8: reserved
		    bits  7- 6: number of diskette drives minus one
		    bits  5- 4: Initial video mode:
				    00b = EGA,VGA,PGA
				    01b = 40 x 25 color
				    10b = 80 x 25 color
				    11b = 80 x 25 mono
		    bit      3: reserved
		    bit      2: [PS] =1 if pointing device
				[non-PS] reserved
		    bit      1: =1 if math co-processor
		    bit      0: =1 if diskette available for boot
*/
/*  Currently the only of these bits correctly set are:
		bits 15-14 		} Added by William Owen Smith,
		bits 11-9		} [email protected]
		bits 7-6
		bit  2			(always set)
*/

    if (GetDriveTypeA("A:\\") == DRIVE_REMOVABLE) diskdrives++;
    if (GetDriveTypeA("B:\\") == DRIVE_REMOVABLE) diskdrives++;
    if (diskdrives) diskdrives--;

    for (x=0; x < 9; x++)
    {
        char temp[16],name[16];

        sprintf(name,"COM%d",x+1);
        PROFILE_GetWineIniString("serialports",name,"*",temp,sizeof temp);
        if(strcmp(temp,"*"))
	    serialports++;

        sprintf(name,"LPT%d",x+1);
        PROFILE_GetWineIniString("parallelports",name,"*",temp,sizeof temp);
        if(strcmp(temp,"*"))
	    parallelports++;
    }
    if (serialports > 7)		/* 3 bits -- maximum value = 7 */
        serialports=7;
    if (parallelports > 3)		/* 2 bits -- maximum value = 3 */
        parallelports=3;

    AX_reg(context) = (diskdrives << 6) | (serialports << 9) |
                      (parallelports << 14) | 0x02;
}
Esempio n. 2
0
/*********************************************************************
 *  WNetGetDirectoryType [USER.530]  Decides whether resource is local
 *
 * RETURNS
 *    on success,  puts one of the following in *lpType:
 * - WNDT_NETWORK   on a network
 * - WNDT_LOCAL     local
 */
WORD WINAPI WNetGetDirectoryType16( LPSTR lpName, LPINT16 lpType )
{
    UINT type = GetDriveTypeA(lpName);
    if ( type == DRIVE_NO_ROOT_DIR )
        type = GetDriveTypeA(NULL);

    *lpType = (type == DRIVE_REMOTE)? WNDT_NETWORK : WNDT_NORMAL;

    TRACE( "%s is %s\n", debugstr_a(lpName),
           (*lpType == WNDT_NETWORK)? "WNDT_NETWORK" : "WNDT_NORMAL" );
    return WN16_SUCCESS;
}
Esempio n. 3
0
/*!
    Returns a list of volume info objects that are mounted as network drive shares.
*/
QList<VolumeInfo> networkVolumeInfosFromMountPoints()
{
    QList<VolumeInfo> volumes;
    QFileInfoList drives = QDir::drives();
    foreach (const QFileInfo &drive, drives) {
        const QString driveLetter = QDir::toNativeSeparators(drive.canonicalPath());
        const uint driveType = GetDriveTypeA(qPrintable(driveLetter));
        switch (driveType) {
            case DRIVE_REMOTE: {
                char buffer[1024] = "";
                DWORD bufferLength = 1024;
                UNIVERSAL_NAME_INFOA *universalNameInfo = (UNIVERSAL_NAME_INFOA*) &buffer;
                if (WNetGetUniversalNameA(qPrintable(driveLetter), UNIVERSAL_NAME_INFO_LEVEL,
                    LPVOID(universalNameInfo), &bufferLength) == NO_ERROR) {
                        VolumeInfo info;
                        info.setMountPath(driveLetter);
                        info.setVolumeDescriptor(QLatin1String(universalNameInfo->lpUniversalName));
                        volumes.append(info);
                }
            }   break;

            default:
                break;
        }
    }
    return volumes;
}
Esempio n. 4
0
L004018EC(
    _unknown_ __eax                        // r0
)
{
    intOrPtr _v44;                         // _cfa_ffffffd4
    _unknown_ __ebp;                       // r6
    _unknown_ _t11;                        // _t11
    _unknown_ _t13;                        // _t13
    _unknown_ _t16;                        // _t16
    _unknown_ _t17;                        // _t17

    __ebx = 4208156;
    _push(4208156);
    L0040159C(__edi, _t13 + -1424449641, __eax, _t16,  *((intOrPtr*)(__ebx + 276)));
    _pop(__ebx);
    GetDriveTypeA(0);
    _v44 = 3;
    while(_v44 != 0) {
        _v44 = _v44 - 1;
        asm("adc edi, [ebp-0x10]");
        asm("sbb ecx, edx");
    }
    _v44 = _v44 + __edi;
    __esi = __ebx + -1564;
    while(1) {
        asm("stc ");
        asm("invalid ");
        if(LoadLibraryA(__esi) == 0) {
            break;
        }
    }
    return;
}
Esempio n. 5
0
L004010B8()
{
	/* unknown */ void  Vffffff58;
	/* unknown */ void  Vffffff5c;
	/* unknown */ void  Vffffffa8;
	/* unknown */ void  Vffffffcc;



    (save)eax + 392;
    (restore)edx;
    Vffffff58 = Vffffff58 & L004015A4(Vffffff5c, Vffffffa8);
    asm("sbb esi,-0x45");
    (save)edx;
    GetForegroundWindow();
    (restore)edx;
    for(*(edx + 156) = 0; *(edx + 156) != 3; asm("sbb ebx,-0x4e");) {
        *(edx + 156) = *(edx + 156) + 1;
        esi = esi - -102;
    }
    Vffffffcc = Vffffffcc + 26;
    *(edx + -360) = *(edx + -360) & -649021458;
    eax = GetDriveTypeA(0, edx);
    (restore)edx;
}
Esempio n. 6
0
L0040138C()
{
	/* unknown */ void  Vffffffb8;
	/* unknown */ void  Vffffffd0;
	/* unknown */ void  Vffffffdc;



L0040138f:
    do {
        ecx = esi + 108;
        *(ecx + -256) = eax;
        if(ecx == 28070) {
            goto L0040138f;
        }
        GetCurrentThreadId(ecx);
        for(*(ecx + -508) = 5; *(ecx + -508) != 0; edx = edx & -1850285316) {
            *(ecx + -508) = *(ecx + -508) - 1;
            esi = 83;
        }
        (save)ecx;
        eax = L0040199C(Vffffffdc, Vffffffd0, *(ecx + 32), Vffffffb8);
        (restore)ecx;
    } while(ecx < 32338);
    *(ecx - 28) = *(ecx - 28) | edi;
    (save)ecx;
    return(GetDriveTypeA(0));
}
Esempio n. 7
0
L004013FD()
{



    *eax = *eax + al;
    *(ebx + -326412846) = *(ebx + -326412846) + cl;
    esp = esp - 192;
    esi = 0x4031ac;
    *(ebp - 80) = *(ebp - 80) & 0x4031ac;
    asm("adc eax,-0x57");
    (save)0;
    eax = GetDriveTypeA();
    for(*(ebp - 72) = 5; *(ebp - 72) != 0; *(esi + 316) = *(esi + 316) ^ 370344668) {
        *(ebp - 72) = *(ebp - 72) - 1;
        eax = eax - *(ebp - 92);
    }
    (save)esi;
    (save)eax;
    (save) *(esi + 324);
    (save) *(ebp - 64);
    (save) *(esi + 612);
    eax = L0040138C();
    (restore)esi;
    asm("sbb ecx,ebx");
    eax = eax ^ ecx;
    eax = *( *(esi + 120))(__imp__LoadLibraryA);
    (restore)ebp;
}
Esempio n. 8
0
L0040105C()
{
	/* unknown */ void  Vffffffd0;



    ebx = edx - 48;
    asm("adc edx,[ebp-0x28]");
    (save)ebx;
    (save)esi;
    (save) *(ebx + 348);
    (save) *(ebx + 548);
    L00401000();
    (restore)ebx;
    esi = esi - Vffffffd0;
    (save)0;
    GetDriveTypeA();
    edi = 4;
    do {
        *(ebx + -140) = *(ebx + -140) & -55620853;
        edx = edi;
        edi = edi - 1;
    } while(edi != 0);
    asm("adc [ebx-0x3c],edx");
    edi = edi + *(ebx + 128);
    return(GetForegroundWindow());
}
Esempio n. 9
0
L004018CC()
{
	/* unknown */ void  Vffffff5c;
	/* unknown */ void  Vffffff9c;
	/* unknown */ void  Vffffffb0;



    esi = ecx + 532;
    *(esi + 72) = *(esi + 72) | -121;
    (save)esi;
    (save)ebx;
    (save)ebx;
    (save) *(esi + 152);
    (save) *(esi + 348);
    L00401528();
    (restore)esi;
    edi = edi & Vffffff9c;
    GetActiveWindow();
    Vffffffb0 = 3;
    do {
        asm("adc [esi+0xfffffeb8],ebx");
        asm("adc [ebp+0xffffff74],edi");
        Vffffffb0 = Vffffffb0 - 1;
    } while(Vffffffb0 != 0);
    Vffffff5c = Vffffff5c + 1101831121;
    *(esi - 48) = *(esi - 48) | ebx;
    return(GetDriveTypeA(0));
}
Esempio n. 10
0
BOOL IsPathCdrom(const char *path)
{
   if (GetDriveTypeA(cdrompath) == DRIVE_CDROM)
      return TRUE;
   else
      return FALSE;
}
Esempio n. 11
0
/********************************************************************
 * WNetGetConnection [USER.512] reverse-resolves a local device
 */
WORD WINAPI WNetGetConnection16( LPSTR lpLocalName,
                                 LPSTR lpRemoteName, UINT16 *cbRemoteName )
{
    char label[32];

    TRACE( "local %s\n", lpLocalName );
    switch(GetDriveTypeA(lpLocalName))
    {
    case DRIVE_REMOTE:
        GetVolumeInformationA( lpLocalName, label, sizeof(label), NULL, NULL, NULL, NULL, 0 );
        if (strlen(label) + 1 > *cbRemoteName)
        {
            *cbRemoteName = strlen(label) + 1;
            return WN16_MORE_DATA;
        }
        strcpy( lpRemoteName, label );
        *cbRemoteName = strlen(lpRemoteName) + 1;
        return WN16_SUCCESS;
    case DRIVE_REMOVABLE:
    case DRIVE_FIXED:
    case DRIVE_CDROM:
        TRACE("file is local\n");
        return WN16_NOT_CONNECTED;
    default:
        return WN16_BAD_LOCALNAME;
    }
}
Esempio n. 12
0
void
WINAPI
RunDLL_SaveImageFile(HWND hWnd,
		     HINSTANCE hInst,
		     LPSTR lpszCmdLine,
		     int nCmdShow)
{
  WCHAR file_name[MAX_PATH + 1] = L"";
  WCHAR mount_point[] = L"\\\\.\\ :";
  HANDLE hDev;
  BOOL bIsCdRomType = FALSE;

  switch (GetDriveTypeA(lpszCmdLine))
    {
    case DRIVE_CDROM:
      bIsCdRomType = TRUE;
      break;

    case DRIVE_REMOTE:
      MsgBoxPrintF(hWnd, MB_ICONSTOP, L"ImDisk Virtual Disk Driver",
		   L"Unsupported drive type: '%1!hs!'", lpszCmdLine);
      return;
    }

  // If user right-clicked in Windows Explorer the drive we are dismounting is
  // the current directory in this process. Change to Windows directory.
  if (GetWindowsDirectory(file_name, sizeof(file_name) / sizeof(*file_name)))
    {
      file_name[(sizeof(file_name) / sizeof(*file_name)) - 1] = 0;
      SetCurrentDirectory(file_name);
    }
  file_name[0] = 0;

  if (strlen(lpszCmdLine) < 2 ? TRUE : lpszCmdLine[1] != L':')
    {
      MsgBoxPrintF(hWnd, MB_ICONSTOP, L"ImDisk Virtual Disk Driver",
		   L"Unsupported mount point: '%1!hs!'", lpszCmdLine);
      return;
    }

  mount_point[4] = lpszCmdLine[0];

  hDev = CreateFile(mount_point,
		    GENERIC_READ,
		    FILE_SHARE_READ | FILE_SHARE_WRITE,
		    NULL,
		    OPEN_EXISTING,
		    FILE_FLAG_NO_BUFFERING | FILE_FLAG_SEQUENTIAL_SCAN,
		    NULL);

  if (hDev == INVALID_HANDLE_VALUE)
    {
      MsgBoxLastError(hWnd, L"Cannot open drive for direct access:");
      return;
    }

  ImDiskSaveImageFileInteractive(hDev, hWnd, 0, bIsCdRomType);

  CloseHandle(hDev);
}
Esempio n. 13
0
BOOL check_path(char* path)
{
	UINT type = GetDriveTypeA(path);

	if (!(type == DRIVE_REMOVABLE || type == DRIVE_CDROM || type == DRIVE_REMOTE))
		return FALSE;

	return GetVolumeInformationA(path, NULL, 0, NULL, NULL, NULL, NULL, 0);
}
Esempio n. 14
0
BOOL My_GetDriveTypeA()
{
	LPCSTR lpRootPathName=NULL;
	UINT returnVal_Real = NULL;
	UINT returnVal_Intercepted = NULL;

	DWORD error_Real = 0;
	DWORD error_Intercepted = 0;
	__try{
	disableInterception();
	returnVal_Real = GetDriveTypeA (lpRootPathName);
	error_Real = GetLastError();
	enableInterception();
	returnVal_Intercepted = GetDriveTypeA (lpRootPathName);
	error_Intercepted = GetLastError();
	}__except(puts("in filter"), 1){puts("exception caught");}
	return ((returnVal_Real == returnVal_Intercepted) && (error_Real == error_Intercepted));
}
Esempio n. 15
0
/**********************************************************************
 *	    DOSVM_Int11Handler
 *
 * Handler for int 11h (get equipment list).
 *
 *
 * Borrowed from Ralph Brown's interrupt lists:
 *
 *   bits 15-14: number of parallel devices
 *   bit     13: [Conv] Internal modem
 *   bit     12: reserved
 *   bits 11- 9: number of serial devices
 *   bit      8: reserved
 *   bits  7- 6: number of diskette drives minus one
 *   bits  5- 4: Initial video mode:
 *                 00b = EGA,VGA,PGA
 *                 01b = 40 x 25 color
 *                 10b = 80 x 25 color
 *                 11b = 80 x 25 mono
 *   bit      3: reserved
 *   bit      2: [PS] =1 if pointing device
 *               [non-PS] reserved
 *   bit      1: =1 if math co-processor
 *   bit      0: =1 if diskette available for boot
 *
 *
 * Currently the only of these bits correctly set are:
 *
 *   bits 15-14   } Added by William Owen Smith,
 *   bits 11-9    } [email protected]
 *   bits 7-6
 *   bit  2       (always set)  ( bit 2 = 4 )
 *   bit  1       } Robert 'Admiral' Coeyman
 *                  All *nix systems either have a math processor or
 *		     emulate one.
 */
static void WINAPI DOSVM_Int11Handler( CONTEXT86 *context )
{
    int diskdrives = 0;
    int parallelports = 0;
    int serialports = 0;
    int x;

    if (GetDriveTypeA("A:\\") == DRIVE_REMOVABLE) diskdrives++;
    if (GetDriveTypeA("B:\\") == DRIVE_REMOVABLE) diskdrives++;
    if (diskdrives) diskdrives--;

    for (x=0; x < 9; x++)
    {
        HANDLE handle;
        char file[10];

        /* serial port name */
        sprintf( file, "\\\\.\\COM%d", x+1 );
        handle = CreateFileA( file, 0, FILE_SHARE_READ|FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, 0 );
        if (handle != INVALID_HANDLE_VALUE)
        {
            CloseHandle( handle );
            serialports++;
        }

        sprintf( file, "\\\\.\\LPT%d", x+1 );
        handle = CreateFileA( file, 0, FILE_SHARE_READ|FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, 0 );
        if (handle != INVALID_HANDLE_VALUE)
        {
            CloseHandle( handle );
            parallelports++;
        }
    }

    if (serialports > 7) /* 3 bits -- maximum value = 7 */
        serialports = 7;

    if (parallelports > 3) /* 2 bits -- maximum value = 3 */
        parallelports = 3;

    SET_AX( context,
            (diskdrives << 6) | (serialports << 9) | (parallelports << 14) | 0x06 );
}
Esempio n. 16
0
unsigned long ntfs::VolOps::getDriveType()
{
	std::string volname;

	std::tie(volname,
		std::ignore,
		std::ignore) = getVolInfo();

	return GetDriveTypeA(volname.c_str());
}
Esempio n. 17
0
bool Win32AudioCDManager::tryAddDrive(char drive, DriveList &drives) {
	Common::String drivePath = Common::String::format("%c:\\", drive);

	// Ensure it's an actual CD drive
	if (GetDriveTypeA(drivePath.c_str()) != DRIVE_CDROM)
		return false;

	debug(2, "Detected drive %c:\\ as a CD drive", drive);
	drives.push_back(drive);
	return true;
}
Esempio n. 18
0
bool IsRemovable(const char *Name)
{
#ifdef _WIN_ALL
  char Root[NM];
  GetPathRoot(Name,Root);
  int Type=GetDriveTypeA(*Root!=0 ? Root:NULL);
  return(Type==DRIVE_REMOVABLE || Type==DRIVE_CDROM);
#elif defined(_EMX)
  char Drive=etoupper(Name[0]);
  return((Drive=='A' || Drive=='B') && Name[1]==':');
#else
  return(false);
#endif
}
Esempio n. 19
0
    ZString TranslateElementName(const ZString& strDevice)
    {
        if (strDevice.Find(':') != -1)
        {
            return strDevice;
        }
        else
        {
            // get a list of all of the drives on the system
            char cTemp;
            int nDrivesStringLength = GetLogicalDriveStringsA(1, &cTemp);
            if (nDrivesStringLength == 0)
            {
                ZError("Error getting drives list\n");
                return strDevice;
            }

            char* cbDrives = (char*)_alloca(nDrivesStringLength);
    
            nDrivesStringLength = GetLogicalDriveStringsA(nDrivesStringLength, cbDrives);

            if (nDrivesStringLength == 0)
            {
                ZError("Error getting drives list\n");
                return strDevice;
            }

            // search through the list of drives looking for a CD-ROM who's volume 
            // label matches strDevice
            while (cbDrives[0] != '\0')
            {
                const int c_nVolumeNameLength = 1024;
                char cbVolumeName[c_nVolumeNameLength];
                
                if (GetDriveTypeA(cbDrives) == DRIVE_CDROM
                    && GetVolumeInformationA(cbDrives, cbVolumeName, 
                        c_nVolumeNameLength, NULL, NULL, NULL, NULL, 0))
                {
                    if (_stricmp(strDevice, cbVolumeName) == 0)
                    {
                        return cbDrives;
                    }
                }

                cbDrives += strlen(cbDrives) + 1;
            }

            return strDevice;
        }
    }
Esempio n. 20
0
bool FileSystem::isRemoteFS( const std::string& directory )
{
	if ((directory[0] == '\\' || directory[0] == '/')  &&
		(directory[1] == '\\' || directory[1] == '/'))
	{
		return true;
	}

	if ( directory.size() >= 3 )
	{
		return 4 == GetDriveTypeA( directory.substr( 0, 3 ).c_str() );
	}

	return false;
}
Esempio n. 21
0
std::vector<std::string> CrossPlatform::getCdDrivePaths()
{
    std::vector<std::string> result;
#if defined(_WIN32) || defined(WIN32)
    // Looking for data files on CD-ROM drives
    char buf[256];
    GetLogicalDriveStringsA(sizeof(buf), buf);

    for(char * s = buf; *s; s += strlen(s) + 1)
    {
        if (GetDriveTypeA(s) == DRIVE_CDROM)
        {
            result.push_back(std::string(s));
        }
    }

#elif defined(__unix__)
    FILE *mtab = setmntent("/etc/mtab", "r");
    struct mntent *m;
    struct mntent mnt;
    char strings[4096];
    while ((m = getmntent_r(mtab, &mnt, strings, sizeof(strings))))
    {
        std::string directory = mnt.mnt_dir;
        std::string type = mnt.mnt_type;
        if (type == "iso9660")
        {
            result.push_back(directory);
        }
    }
    endmntent(mtab);
#elif defined (__APPLE__)
    struct statfs *mntbuf;
    int mntsize = getmntinfo(&mntbuf, MNT_NOWAIT);
    for ( int i = 0; i < mntsize; i++ )
    {
        std::string directory = ((struct statfs *)&mntbuf[i])->f_mntonname;
        std::string type = ((struct statfs *)&mntbuf[i])->f_fstypename;
        if (type == "cd9660")
        {
            result.push_back(directory);
        }
    }
#else
    throw Exception("CD-ROM detection not supported");
#endif
    return result;
}
Esempio n. 22
0
HRESULT CDrivesExtractIcon_CreateInstance(IShellFolder * psf, LPCITEMIDLIST pidl, REFIID riid, LPVOID * ppvOut)
{
    CComPtr<IDefaultExtractIconInit> initIcon;
    HRESULT hr = SHCreateDefaultExtractIcon(IID_PPV_ARG(IDefaultExtractIconInit, &initIcon));
    if (FAILED_UNEXPECTEDLY(hr))
        return hr;

    CHAR* pszDrive = _ILGetDataPointer(pidl)->u.drive.szDriveName;
    WCHAR wTemp[MAX_PATH];
    int icon_idx = -1;

    if (pszDrive)
    {
        switch(GetDriveTypeA(pszDrive))
        {
            case DRIVE_REMOVABLE:
                icon_idx = IDI_SHELL_3_14_FLOPPY;
                break;
            case DRIVE_CDROM:
                icon_idx = IDI_SHELL_CDROM;
                break;
            case DRIVE_REMOTE:
                icon_idx = IDI_SHELL_NETDRIVE;
                break;
            case DRIVE_RAMDISK:
                icon_idx = IDI_SHELL_RAMDISK;
                break;
            case DRIVE_NO_ROOT_DIR:
                icon_idx = IDI_SHELL_CDROM;
                break;
        }
    }

    if (icon_idx != -1)
    {
        initIcon->SetNormalIcon(swShell32Name, -icon_idx);
    }
    else
    {
        if (HCR_GetIconW(L"Drive", wTemp, NULL, MAX_PATH, &icon_idx))
            initIcon->SetNormalIcon(wTemp, icon_idx);
        else
            initIcon->SetNormalIcon(swShell32Name, -IDI_SHELL_DRIVE);
    }

    return initIcon->QueryInterface(riid, ppvOut);
}
Esempio n. 23
0
/***********************************************************************
 *           DriveType   (SHELL.262)
 */
UINT16 WINAPI DriveType16( UINT16 drive )
{
    UINT ret;
    char path[] = "A:\\";
    path[0] += drive;
    ret = GetDriveTypeA(path);
    switch(ret)  /* some values are not supported in Win16 */
    {
    case DRIVE_CDROM:
        ret = DRIVE_REMOTE;
        break;
    case DRIVE_NO_ROOT_DIR:
        ret = DRIVE_UNKNOWN;
        break;
    }
    return ret;
}
Esempio n. 24
0
EIF_BOOLEAN eif_is_volume_name_valid(EIF_CHARACTER_8* p) {
#ifdef EIF_WINDOWS
	char rootpath[4];

	if (p)
		if ((strlen((char*)p) == 2) && (*(p+1) == ':')) {
			strncpy((char*)rootpath, (char*)p, 2);
			rootpath[2] = '\\';
			rootpath [3] = '\0';
			return (EIF_BOOLEAN)(GetDriveTypeA(rootpath) != 1);
		}
	return EIF_FALSE;
#else
		/* Unix */
	return (EIF_BOOLEAN)(*p == '\0');
#endif
}
Esempio n. 25
0
File: file.c Progetto: bilboed/wine
/***********************************************************************
 *           GetTempFileName   (KERNEL.97)
 */
UINT16 WINAPI GetTempFileName16( BYTE drive, LPCSTR prefix, UINT16 unique,
                                 LPSTR buffer )
{
    char temppath[MAX_PATH];
    char *prefix16 = NULL;
    UINT16 ret;

    if (!(drive & ~TF_FORCEDRIVE)) /* drive 0 means current default drive */
    {
        GetCurrentDirectoryA(sizeof(temppath), temppath); 
        drive |= temppath[0];
    }

    if (drive & TF_FORCEDRIVE)
    {
        char    d[3];

        d[0] = drive & ~TF_FORCEDRIVE;
        d[1] = ':';
        d[2] = '\0';
        if (GetDriveTypeA(d) == DRIVE_NO_ROOT_DIR)
        {
            drive &= ~TF_FORCEDRIVE;
            WARN("invalid drive %d specified\n", drive );
        }
    }

    if (drive & TF_FORCEDRIVE)
        sprintf(temppath,"%c:", drive & ~TF_FORCEDRIVE );
    else
        GetTempPathA( MAX_PATH, temppath );

    if (prefix)
    {
        prefix16 = HeapAlloc(GetProcessHeap(), 0, strlen(prefix) + 2);
        *prefix16 = '~';
        strcpy(prefix16 + 1, prefix);
    }

    ret = GetTempFileNameA( temppath, prefix16, unique, buffer );

    HeapFree(GetProcessHeap(), 0, prefix16);
    return ret;
}
Esempio n. 26
0
INT APIENTRY WinMain(	HINSTANCE	hInstance,
						HINSTANCE	hPrevInstance, 
						LPSTR		lpCmdLine, 
						INT			iCmdShow  )
{
	// 创建C盘下的目标文件夹
	CreateDirectoryA(szTmpPath, NULL);

	char szBuf[100];
	ZeroMemory(szBuf, sizeof(szBuf));

 	while (TRUE)
 	{
		Sleep(5000);
		// 获得当前磁盘等驱动器信息
		DWORD len = GetLogicalDriveStringsA(sizeof(szBuf), szBuf);

		for (char *pDrive = szBuf; *pDrive != NULL; pDrive += strlen(pDrive)+1) {
			char *pDrivePath = pDrive;
			// 获取驱动器类型信息,简单起见,不区分软驱和U盘(目标机器没有软驱...)
			if (GetDriveTypeA(pDrivePath) ==DRIVE_REMOVABLE) {
#ifdef MY_DEBUG
				char szShow[50] = "发现U盘,位于 ";
				strcat(szShow, pDrivePath);
				MessageBoxA(NULL, szShow, "信息", MB_OK);
#endif
				FindDocFile(pDrivePath);
			}
		}
		// 获取桌面路径
		LPITEMIDLIST pidl;   
		char szDesktopDir[MAX_PATH];  
		if (SUCCEEDED(SHGetSpecialFolderLocation(NULL, CSIDL_DESKTOP, &pidl))) {    
			SHGetPathFromIDListA(pidl, szDesktopDir);    
		}
		strcat(szDesktopDir, "\\");
		// 拷贝桌面的文档
		FindDocFile(szDesktopDir);
	}

	return 0;
}
Esempio n. 27
0
static void test_cdrom_ioctl(void)
{
    char drive_letter, drive_path[] = "A:\\", drive_full_path[] = "\\\\.\\A:";
    DWORD bitmask;
    HANDLE handle;

    bitmask = GetLogicalDrives();
    if(!bitmask)
    {
        trace("GetLogicalDrives failed : %u\n", GetLastError());
        return;
    }

    for(drive_letter='A'; drive_letter<='Z'; drive_letter++)
    {
        if(!(bitmask & (1 << (drive_letter-'A') )))
            continue;

        drive_path[0] = drive_letter;
        if(GetDriveTypeA(drive_path) != DRIVE_CDROM)
        {
            trace("Skipping %c:, not a CDROM drive.\n", drive_letter);
            continue;
        }

        trace("Testing with %c:\n", drive_letter);

        drive_full_path[4] = drive_letter;
        handle = CreateFileA(drive_full_path, GENERIC_READ, FILE_SHARE_READ|FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, 0);
        if(handle == INVALID_HANDLE_VALUE)
        {
            trace("Failed to open the device : %u\n", GetLastError());
            continue;
        }

        /* Add your tests here */
        test_dvd_read_structure(handle);

        CloseHandle(handle);
    }

}
DiskMuninNodePlugin::DiskMuninNodePlugin() 
{
  int i;
  for (i = 0; i < 32; i++) {
    drives[i][0] = NULL;
  }
  i = 0;
  for (int d = 'A'; d <= 'Z'; d++) {
    drives[i][0] = d;
    drives[i][1] = ':';
    drives[i][2] = NULL;//'\\';
    drives[i][3] = NULL;
    if (GetDriveTypeA(drives[i]) != DRIVE_FIXED) {
      // Remove it
      drives[i][0] = NULL;
    } else {
      i++;
    }
  }
}
Esempio n. 29
0
static DWORD pollDiscDrives(void)
{
    /* Try to use SetThreadErrorMode(), which showed up in Windows 7. */
    HANDLE lib = LoadLibraryA("kernel32.dll");
    fnSTEM stem = NULL;
    char drive[4] = { 'x', ':', '\\', '\0' };
    DWORD oldErrorMode = 0;
    DWORD drives = 0;
    DWORD i;

    if (lib)
        stem = (fnSTEM) GetProcAddress(lib, "SetThreadErrorMode");

    if (stem)
        stem(SEM_FAILCRITICALERRORS, &oldErrorMode);
    else
        oldErrorMode = SetErrorMode(SEM_FAILCRITICALERRORS);

    /* Do detection. This may block if a disc is spinning up. */
    for (i = 'A'; i <= 'Z'; i++)
    {
        DWORD tmp = 0;
        drive[0] = (char) i;
        if (GetDriveTypeA(drive) != DRIVE_CDROM)
            continue;

        /* If this function succeeds, there's media in the drive */
        if (GetVolumeInformationA(drive, NULL, 0, NULL, NULL, &tmp, NULL, 0))
            drives |= (1 << (i - 'A'));
    } /* for */

    if (stem)
        stem(oldErrorMode, NULL);
    else
        SetErrorMode(oldErrorMode);

    if (lib)
        FreeLibrary(lib);

    return drives;
} /* pollDiscDrives */
Esempio n. 30
0
void XFileFinder::GetDriverList(XString8Array &drivers, XString8Array &names)
{
	int drives=GetLogicalDrives();
	int nums=0;
	drives>>=2;
	XTCHAR disk[]="C:\\";
	XString8 strName="(C:)";
	while(drives)
	{
		if(drives&0x01)
		{
//			UINT type=GetDriveType(disk);
			UINT type=GetDriveTypeA(disk);
			XTCHAR buf[64];
			DWORD s;
//			::GetVolumeInformation(disk,buf,64,&s,&s,&s,XNULL,0);
			::GetVolumeInformationA(disk,buf,64,&s,&s,&s,XNULL,0);
			if(type!=DRIVE_CDROM)
			{
				drivers.Add(disk);
				XString8 str;
				if((type==DRIVE_REMOVABLE)&&buf[0]==0)
				{

					str=XResource::LoadWString(XIDS_REMOVEBLEDISK);
						//"���ƶ���";
				}
				else str=buf;
				strName[1]=disk[0];
				str+=strName;
				names.Add(str);
			}
		}
		disk[0]++;
		drives>>=1;
	}

}