Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
6483f2f2
Commit
6483f2f2
authored
Oct 17, 2008
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
winecfg: Store the drive serial number as a number instead of a string.
parent
3b6daf25
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
27 additions
and
36 deletions
+27
-36
drive.c
programs/winecfg/drive.c
+14
-21
drivedetect.c
programs/winecfg/drivedetect.c
+4
-4
driveui.c
programs/winecfg/driveui.c
+7
-9
winecfg.h
programs/winecfg/winecfg.h
+2
-2
No files found.
programs/winecfg/drive.c
View file @
6483f2f2
...
@@ -87,20 +87,20 @@ long drive_available_mask(char letter)
...
@@ -87,20 +87,20 @@ long drive_available_mask(char letter)
return
result
;
return
result
;
}
}
BOOL
add_drive
(
const
char
letter
,
const
char
*
targetpath
,
const
char
*
label
,
const
char
*
serial
,
unsigned
int
type
)
BOOL
add_drive
(
const
char
letter
,
const
char
*
targetpath
,
const
char
*
label
,
DWORD
serial
,
unsigned
int
type
)
{
{
int
driveIndex
=
letter_to_index
(
letter
);
int
driveIndex
=
letter_to_index
(
letter
);
if
(
drives
[
driveIndex
].
in_use
)
if
(
drives
[
driveIndex
].
in_use
)
return
FALSE
;
return
FALSE
;
WINE_TRACE
(
"letter == '%c', unixpath == '%s', label == '%s', serial ==
'%s'
, type == %d
\n
"
,
WINE_TRACE
(
"letter == '%c', unixpath == '%s', label == '%s', serial ==
%08x
, type == %d
\n
"
,
letter
,
targetpath
,
label
,
serial
,
type
);
letter
,
targetpath
,
label
,
serial
,
type
);
drives
[
driveIndex
].
letter
=
toupper
(
letter
);
drives
[
driveIndex
].
letter
=
toupper
(
letter
);
drives
[
driveIndex
].
unixpath
=
strdupA
(
targetpath
);
drives
[
driveIndex
].
unixpath
=
strdupA
(
targetpath
);
drives
[
driveIndex
].
label
=
strdupA
(
label
);
drives
[
driveIndex
].
label
=
strdupA
(
label
);
drives
[
driveIndex
].
serial
=
s
trdupA
(
serial
)
;
drives
[
driveIndex
].
serial
=
s
erial
;
drives
[
driveIndex
].
type
=
type
;
drives
[
driveIndex
].
type
=
type
;
drives
[
driveIndex
].
in_use
=
TRUE
;
drives
[
driveIndex
].
in_use
=
TRUE
;
...
@@ -114,9 +114,7 @@ void delete_drive(struct drive *d)
...
@@ -114,9 +114,7 @@ void delete_drive(struct drive *d)
d
->
unixpath
=
NULL
;
d
->
unixpath
=
NULL
;
HeapFree
(
GetProcessHeap
(),
0
,
d
->
label
);
HeapFree
(
GetProcessHeap
(),
0
,
d
->
label
);
d
->
label
=
NULL
;
d
->
label
=
NULL
;
HeapFree
(
GetProcessHeap
(),
0
,
d
->
serial
);
d
->
serial
=
0
;
d
->
serial
=
NULL
;
d
->
in_use
=
FALSE
;
d
->
in_use
=
FALSE
;
}
}
...
@@ -198,20 +196,22 @@ static void set_drive_label( char letter, const char *label )
...
@@ -198,20 +196,22 @@ static void set_drive_label( char letter, const char *label )
}
}
/* set the drive serial number via a .windows-serial file */
/* set the drive serial number via a .windows-serial file */
static
void
set_drive_serial
(
char
letter
,
const
char
*
serial
)
static
void
set_drive_serial
(
char
letter
,
DWORD
serial
)
{
{
char
filename
[]
=
"a:
\\
.windows-serial"
;
char
filename
[]
=
"a:
\\
.windows-serial"
;
HANDLE
hFile
;
HANDLE
hFile
;
filename
[
0
]
=
letter
;
filename
[
0
]
=
letter
;
WINE_TRACE
(
"Putting serial number of
'%s'
into file '%s'
\n
"
,
serial
,
filename
);
WINE_TRACE
(
"Putting serial number of
%08x
into file '%s'
\n
"
,
serial
,
filename
);
hFile
=
CreateFile
(
filename
,
GENERIC_WRITE
,
FILE_SHARE_READ
,
NULL
,
hFile
=
CreateFile
(
filename
,
GENERIC_WRITE
,
FILE_SHARE_READ
,
NULL
,
CREATE_ALWAYS
,
FILE_ATTRIBUTE_NORMAL
,
NULL
);
CREATE_ALWAYS
,
FILE_ATTRIBUTE_NORMAL
,
NULL
);
if
(
hFile
!=
INVALID_HANDLE_VALUE
)
if
(
hFile
!=
INVALID_HANDLE_VALUE
)
{
{
DWORD
w
;
DWORD
w
;
WriteFile
(
hFile
,
serial
,
strlen
(
serial
),
&
w
,
NULL
);
char
buffer
[
16
];
WriteFile
(
hFile
,
"
\n
"
,
1
,
&
w
,
NULL
);
sprintf
(
buffer
,
"%X
\n
"
,
serial
);
WriteFile
(
hFile
,
buffer
,
strlen
(
buffer
),
&
w
,
NULL
);
CloseHandle
(
hFile
);
CloseHandle
(
hFile
);
}
}
}
}
...
@@ -281,15 +281,13 @@ void load_drives(void)
...
@@ -281,15 +281,13 @@ void load_drives(void)
{
{
drives
[
i
].
letter
=
'A'
+
i
;
drives
[
i
].
letter
=
'A'
+
i
;
drives
[
i
].
in_use
=
FALSE
;
drives
[
i
].
in_use
=
FALSE
;
drives
[
i
].
serial
=
0
;
HeapFree
(
GetProcessHeap
(),
0
,
drives
[
i
].
unixpath
);
HeapFree
(
GetProcessHeap
(),
0
,
drives
[
i
].
unixpath
);
drives
[
i
].
unixpath
=
NULL
;
drives
[
i
].
unixpath
=
NULL
;
HeapFree
(
GetProcessHeap
(),
0
,
drives
[
i
].
label
);
HeapFree
(
GetProcessHeap
(),
0
,
drives
[
i
].
label
);
drives
[
i
].
label
=
NULL
;
drives
[
i
].
label
=
NULL
;
HeapFree
(
GetProcessHeap
(),
0
,
drives
[
i
].
serial
);
drives
[
i
].
serial
=
NULL
;
}
}
/* work backwards through the result of GetLogicalDriveStrings */
/* work backwards through the result of GetLogicalDriveStrings */
...
@@ -297,7 +295,6 @@ void load_drives(void)
...
@@ -297,7 +295,6 @@ void load_drives(void)
{
{
char
volname
[
512
];
/* volume name */
char
volname
[
512
];
/* volume name */
DWORD
serial
;
DWORD
serial
;
char
serialstr
[
256
];
char
rootpath
[
256
];
char
rootpath
[
256
];
char
simplepath
[
3
];
char
simplepath
[
3
];
int
pathlen
;
int
pathlen
;
...
@@ -346,9 +343,7 @@ void load_drives(void)
...
@@ -346,9 +343,7 @@ void load_drives(void)
c
=
targetpath
;
c
=
targetpath
;
do
if
(
*
c
==
'\\'
)
*
c
=
'/'
;
while
(
*
c
++
);
do
if
(
*
c
==
'\\'
)
*
c
=
'/'
;
while
(
*
c
++
);
snprintf
(
serialstr
,
sizeof
(
serialstr
),
"%X"
,
serial
);
add_drive
(
*
devices
,
targetpath
,
volname
,
serial
,
get_drive_type
(
devices
[
0
])
);
WINE_TRACE
(
"serialstr: '%s'
\n
"
,
serialstr
);
add_drive
(
*
devices
,
targetpath
,
volname
,
serialstr
,
get_drive_type
(
devices
[
0
])
);
len
-=
strlen
(
devices
);
len
-=
strlen
(
devices
);
devices
+=
strlen
(
devices
);
devices
+=
strlen
(
devices
);
...
@@ -386,7 +381,7 @@ void load_drives(void)
...
@@ -386,7 +381,7 @@ void load_drives(void)
buff
[
cnt
]
=
'\0'
;
buff
[
cnt
]
=
'\0'
;
WINE_TRACE
(
"found broken symlink %s -> %s
\n
"
,
path
,
buff
);
WINE_TRACE
(
"found broken symlink %s -> %s
\n
"
,
path
,
buff
);
add_drive
(
'A'
+
i
,
buff
,
""
,
"0"
,
DRIVE_UNKNOWN
);
add_drive
(
'A'
+
i
,
buff
,
""
,
0
,
DRIVE_UNKNOWN
);
drivecount
++
;
drivecount
++
;
}
}
...
@@ -410,7 +405,6 @@ void apply_drive_changes(void)
...
@@ -410,7 +405,6 @@ void apply_drive_changes(void)
DWORD
maxComponentLength
;
DWORD
maxComponentLength
;
DWORD
fileSystemFlags
;
DWORD
fileSystemFlags
;
CHAR
fileSystemName
[
128
];
CHAR
fileSystemName
[
128
];
char
newSerialNumberText
[
32
];
int
retval
;
int
retval
;
BOOL
defineDevice
;
BOOL
defineDevice
;
...
@@ -517,8 +511,7 @@ void apply_drive_changes(void)
...
@@ -517,8 +511,7 @@ void apply_drive_changes(void)
if
(
drives
[
i
].
label
&&
strcmp
(
drives
[
i
].
label
,
volumeNameBuffer
))
if
(
drives
[
i
].
label
&&
strcmp
(
drives
[
i
].
label
,
volumeNameBuffer
))
set_drive_label
(
drives
[
i
].
letter
,
drives
[
i
].
label
);
set_drive_label
(
drives
[
i
].
letter
,
drives
[
i
].
label
);
snprintf
(
newSerialNumberText
,
sizeof
(
newSerialNumberText
),
"%X"
,
serialNumber
);
if
(
drives
[
i
].
serial
!=
serialNumber
)
if
(
drives
[
i
].
serial
&&
drives
[
i
].
serial
[
0
]
&&
strcmp
(
drives
[
i
].
serial
,
newSerialNumberText
))
set_drive_serial
(
drives
[
i
].
letter
,
drives
[
i
].
serial
);
set_drive_serial
(
drives
[
i
].
letter
,
drives
[
i
].
serial
);
set_drive_type
(
drives
[
i
].
letter
,
drives
[
i
].
type
);
set_drive_type
(
drives
[
i
].
letter
,
drives
[
i
].
type
);
...
...
programs/winecfg/drivedetect.c
View file @
6483f2f2
...
@@ -233,7 +233,7 @@ static void ensure_root_is_mapped(void)
...
@@ -233,7 +233,7 @@ static void ensure_root_is_mapped(void)
{
{
if
(
!
drives
[
letter
-
'A'
].
in_use
)
if
(
!
drives
[
letter
-
'A'
].
in_use
)
{
{
add_drive
(
letter
,
"/"
,
"System"
,
"0"
,
DRIVE_FIXED
);
add_drive
(
letter
,
"/"
,
"System"
,
0
,
DRIVE_FIXED
);
WINE_TRACE
(
"allocated drive %c as the root drive
\n
"
,
letter
);
WINE_TRACE
(
"allocated drive %c as the root drive
\n
"
,
letter
);
break
;
break
;
}
}
...
@@ -262,7 +262,7 @@ static void ensure_home_is_mapped(void)
...
@@ -262,7 +262,7 @@ static void ensure_home_is_mapped(void)
{
{
if
(
!
drives
[
letter
-
'A'
].
in_use
)
if
(
!
drives
[
letter
-
'A'
].
in_use
)
{
{
add_drive
(
letter
,
home
,
"Home"
,
"0"
,
DRIVE_FIXED
);
add_drive
(
letter
,
home
,
"Home"
,
0
,
DRIVE_FIXED
);
WINE_TRACE
(
"allocated drive %c as the user's home directory
\n
"
,
letter
);
WINE_TRACE
(
"allocated drive %c as the user's home directory
\n
"
,
letter
);
break
;
break
;
}
}
...
@@ -287,7 +287,7 @@ static void ensure_drive_c_is_mapped(void)
...
@@ -287,7 +287,7 @@ static void ensure_drive_c_is_mapped(void)
if
(
stat
(
drive_c_dir
,
&
buf
)
==
0
)
if
(
stat
(
drive_c_dir
,
&
buf
)
==
0
)
{
{
add_drive
(
'C'
,
"../drive_c"
,
"Virtual Windows Drive"
,
"0"
,
DRIVE_FIXED
);
add_drive
(
'C'
,
"../drive_c"
,
"Virtual Windows Drive"
,
0
,
DRIVE_FIXED
);
}
}
else
else
{
{
...
@@ -356,7 +356,7 @@ int autodetect_drives(void)
...
@@ -356,7 +356,7 @@ int autodetect_drives(void)
WINE_TRACE
(
"adding drive %c for %s, type %s with label %s
\n
"
,
letter
,
ent
->
mnt_dir
,
ent
->
mnt_type
,
label
);
WINE_TRACE
(
"adding drive %c for %s, type %s with label %s
\n
"
,
letter
,
ent
->
mnt_dir
,
ent
->
mnt_type
,
label
);
add_drive
(
letter
,
ent
->
mnt_dir
,
label
,
"0"
,
type
);
add_drive
(
letter
,
ent
->
mnt_dir
,
label
,
0
,
type
);
/* working_mask is a map of the drive letters still available. */
/* working_mask is a map of the drive letters still available. */
working_mask
&=
~
DRIVE_MASK_BIT
(
letter
);
working_mask
&=
~
DRIVE_MASK_BIT
(
letter
);
...
...
programs/winecfg/driveui.c
View file @
6483f2f2
...
@@ -314,9 +314,9 @@ static void on_add_click(HWND dialog)
...
@@ -314,9 +314,9 @@ static void on_add_click(HWND dialog)
char
label
[
64
];
char
label
[
64
];
LoadStringA
(
GetModuleHandle
(
NULL
),
IDS_SYSTEM_DRIVE_LABEL
,
label
,
LoadStringA
(
GetModuleHandle
(
NULL
),
IDS_SYSTEM_DRIVE_LABEL
,
label
,
sizeof
(
label
)
/
sizeof
(
label
[
0
]));
sizeof
(
label
)
/
sizeof
(
label
[
0
]));
add_drive
(
new
,
"../drive_c"
,
label
,
""
,
DRIVE_FIXED
);
add_drive
(
new
,
"../drive_c"
,
label
,
0
,
DRIVE_FIXED
);
}
}
else
add_drive
(
new
,
"/"
,
""
,
""
,
DRIVE_UNKNOWN
);
else
add_drive
(
new
,
"/"
,
""
,
0
,
DRIVE_UNKNOWN
);
fill_drives_list
(
dialog
);
fill_drives_list
(
dialog
);
...
@@ -378,7 +378,7 @@ static void update_controls(HWND dialog)
...
@@ -378,7 +378,7 @@ static void update_controls(HWND dialog)
char
*
path
;
char
*
path
;
unsigned
int
type
;
unsigned
int
type
;
char
*
label
;
char
*
label
;
char
*
serial
;
char
serial
[
16
]
;
const
char
*
device
;
const
char
*
device
;
int
i
,
selection
=
-
1
;
int
i
,
selection
=
-
1
;
LVITEM
item
;
LVITEM
item
;
...
@@ -437,7 +437,7 @@ static void update_controls(HWND dialog)
...
@@ -437,7 +437,7 @@ static void update_controls(HWND dialog)
set_text
(
dialog
,
IDC_EDIT_LABEL
,
label
);
set_text
(
dialog
,
IDC_EDIT_LABEL
,
label
);
/* set serial edit text */
/* set serial edit text */
s
erial
=
current_drive
->
serial
;
s
printf
(
serial
,
"%X"
,
current_drive
->
serial
)
;
set_text
(
dialog
,
IDC_EDIT_SERIAL
,
serial
);
set_text
(
dialog
,
IDC_EDIT_SERIAL
,
serial
);
/* TODO: get the device here to put into the edit box */
/* TODO: get the device here to put into the edit box */
...
@@ -518,10 +518,9 @@ static void on_edit_changed(HWND dialog, WORD id)
...
@@ -518,10 +518,9 @@ static void on_edit_changed(HWND dialog, WORD id)
char
*
serial
;
char
*
serial
;
serial
=
get_text
(
dialog
,
id
);
serial
=
get_text
(
dialog
,
id
);
HeapFree
(
GetProcessHeap
(),
0
,
current_drive
->
serial
);
current_drive
->
serial
=
strtoul
(
serial
,
NULL
,
16
);
current_drive
->
serial
=
serial
?
serial
:
strdupA
(
""
);
WINE_TRACE
(
"set serial to %
s
\n
"
,
current_drive
->
serial
);
WINE_TRACE
(
"set serial to %
08x
\n
"
,
current_drive
->
serial
);
/* enable the apply button */
/* enable the apply button */
SendMessage
(
GetParent
(
dialog
),
PSM_CHANGED
,
(
WPARAM
)
dialog
,
0
);
SendMessage
(
GetParent
(
dialog
),
PSM_CHANGED
,
(
WPARAM
)
dialog
,
0
);
...
@@ -760,8 +759,7 @@ DriveDlgProc (HWND dialog, UINT msg, WPARAM wParam, LPARAM lParam)
...
@@ -760,8 +759,7 @@ DriveDlgProc (HWND dialog, UINT msg, WPARAM wParam, LPARAM lParam)
current_drive
->
label
=
str
?
str
:
strdupA
(
""
);
current_drive
->
label
=
str
?
str
:
strdupA
(
""
);
str
=
get_text
(
dialog
,
IDC_EDIT_SERIAL
);
str
=
get_text
(
dialog
,
IDC_EDIT_SERIAL
);
HeapFree
(
GetProcessHeap
(),
0
,
current_drive
->
serial
);
current_drive
->
serial
=
strtoul
(
str
,
NULL
,
16
);
current_drive
->
serial
=
str
?
str
:
strdupA
(
""
);
/* TODO: we don't have a device at this point */
/* TODO: we don't have a device at this point */
...
...
programs/winecfg/winecfg.h
View file @
6483f2f2
...
@@ -98,7 +98,7 @@ struct drive
...
@@ -98,7 +98,7 @@ struct drive
char
letter
;
char
letter
;
char
*
unixpath
;
char
*
unixpath
;
char
*
label
;
char
*
label
;
char
*
serial
;
DWORD
serial
;
DWORD
type
;
/* one of the DRIVE_ constants from winbase.h */
DWORD
type
;
/* one of the DRIVE_ constants from winbase.h */
BOOL
in_use
;
BOOL
in_use
;
...
@@ -107,7 +107,7 @@ struct drive
...
@@ -107,7 +107,7 @@ struct drive
#define DRIVE_MASK_BIT(B) (1 << (toupper(B) - 'A'))
#define DRIVE_MASK_BIT(B) (1 << (toupper(B) - 'A'))
long
drive_available_mask
(
char
letter
);
long
drive_available_mask
(
char
letter
);
BOOL
add_drive
(
const
char
letter
,
const
char
*
targetpath
,
const
char
*
label
,
const
char
*
serial
,
unsigned
int
type
);
BOOL
add_drive
(
const
char
letter
,
const
char
*
targetpath
,
const
char
*
label
,
DWORD
serial
,
unsigned
int
type
);
void
delete_drive
(
struct
drive
*
pDrive
);
void
delete_drive
(
struct
drive
*
pDrive
);
void
apply_drive_changes
(
void
);
void
apply_drive_changes
(
void
);
BOOL
browse_for_unix_folder
(
HWND
dialog
,
WCHAR
*
pszPath
);
BOOL
browse_for_unix_folder
(
HWND
dialog
,
WCHAR
*
pszPath
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment