Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
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-cw
Commits
256290f7
Commit
256290f7
authored
Jul 05, 2016
by
Hugh McMaster
Committed by
Alexandre Julliard
Jul 05, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
regedit: Parse command-line input using Unicode.
Signed-off-by:
Hugh McMaster
<
hugh.mcmaster@outlook.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
d44ec680
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
53 additions
and
123 deletions
+53
-123
Makefile.in
programs/regedit/Makefile.in
+1
-1
main.c
programs/regedit/main.c
+3
-6
regedit.c
programs/regedit/regedit.c
+49
-116
No files found.
programs/regedit/Makefile.in
View file @
256290f7
MODULE
=
regedit.exe
APPMODE
=
-mwindows
-mno-cygwin
APPMODE
=
-mwindows
-m
unicode
-m
no-cygwin
IMPORTS
=
advapi32
DELAYIMPORTS
=
shlwapi shell32 comdlg32 comctl32 user32 gdi32
...
...
programs/regedit/main.c
View file @
256290f7
...
...
@@ -30,7 +30,7 @@
WCHAR
g_pszDefaultValueName
[
64
];
BOOL
ProcessCmdLine
(
LPSTR
lpCmdL
ine
);
BOOL
ProcessCmdLine
(
WCHAR
*
cmdl
ine
);
static
const
WCHAR
hkey_local_machine
[]
=
{
'H'
,
'K'
,
'E'
,
'Y'
,
'_'
,
'L'
,
'O'
,
'C'
,
'A'
,
'L'
,
'_'
,
'M'
,
'A'
,
'C'
,
'H'
,
'I'
,
'N'
,
'E'
,
0
};
static
const
WCHAR
hkey_users
[]
=
{
'H'
,
'K'
,
'E'
,
'Y'
,
'_'
,
'U'
,
'S'
,
'E'
,
'R'
,
'S'
,
0
};
...
...
@@ -134,15 +134,12 @@ static BOOL TranslateChildTabMessage(MSG *msg)
return
TRUE
;
}
int
APIENTRY
WinMain
(
HINSTANCE
hInstance
,
HINSTANCE
hPrevInstance
,
LPSTR
lpCmdLine
,
int
nCmdShow
)
int
WINAPI
wWinMain
(
HINSTANCE
hInstance
,
HINSTANCE
hPrevInstance
,
LPWSTR
lpCmdLine
,
int
nCmdShow
)
{
MSG
msg
;
HACCEL
hAccel
;
if
(
ProcessCmdLine
(
lpCmdLine
))
{
if
(
ProcessCmdLine
(
GetCommandLineW
()
))
{
return
0
;
}
...
...
programs/regedit/regedit.c
View file @
256290f7
...
...
@@ -18,10 +18,11 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <windows.h>
#include <shellapi.h>
#include "wine/unicode.h"
#include "regproc.h"
static
const
char
*
usage
=
...
...
@@ -59,43 +60,41 @@ typedef enum {
ACTION_ADD
,
ACTION_EXPORT
,
ACTION_DELETE
}
REGEDIT_ACTION
;
static
BOOL
PerformRegAction
(
REGEDIT_ACTION
action
,
char
**
argv
,
int
*
i
)
static
BOOL
PerformRegAction
(
REGEDIT_ACTION
action
,
WCHAR
**
argv
,
int
*
i
)
{
switch
(
action
)
{
case
ACTION_ADD
:
{
char
*
filename
=
argv
[
*
i
];
WCHAR
*
filename
=
argv
[
*
i
];
WCHAR
hyphen
[]
=
{
'-'
,
0
};
FILE
*
reg_file
;
if
(
filename
[
0
])
{
char
*
realname
=
NULL
;
if
(
!
strcmpW
(
filename
,
hyphen
))
reg_file
=
stdin
;
else
{
int
size
;
WCHAR
*
realname
=
NULL
;
WCHAR
rb_mode
[]
=
{
'r'
,
'b'
,
0
};
if
(
strcmp
(
filename
,
"-"
)
==
0
)
size
=
SearchPathW
(
NULL
,
filename
,
NULL
,
0
,
NULL
,
NULL
);
if
(
size
>
0
)
{
reg_file
=
stdin
;
realname
=
HeapAlloc
(
GetProcessHeap
(),
0
,
size
*
sizeof
(
WCHAR
));
size
=
SearchPathW
(
NULL
,
filename
,
NULL
,
size
,
realname
,
NULL
);
}
else
if
(
size
==
0
)
{
int
size
;
size
=
SearchPathA
(
NULL
,
filename
,
NULL
,
0
,
NULL
,
NULL
);
if
(
size
>
0
)
{
realname
=
HeapAlloc
(
GetProcessHeap
(),
0
,
size
);
size
=
SearchPathA
(
NULL
,
filename
,
NULL
,
size
,
realname
,
NULL
);
}
if
(
size
==
0
)
{
fprintf
(
stderr
,
"regedit: File not found
\"
%s
\"
(%d)
\n
"
,
filename
,
GetLastError
());
exit
(
1
);
}
reg_file
=
fopen
(
realname
,
"rb"
);
if
(
reg_file
==
NULL
)
{
perror
(
""
);
fprintf
(
stderr
,
"regedit: Can't open file
\"
%s
\"\n
"
,
filename
);
exit
(
1
);
}
fprintf
(
stderr
,
"regedit: File not found
\"
%ls
\"
(%d)
\n
"
,
filename
,
GetLastError
());
exit
(
1
);
}
reg_file
=
_wfopen
(
realname
,
rb_mode
);
if
(
reg_file
==
NULL
)
{
WCHAR
regedit
[]
=
{
'r'
,
'e'
,
'g'
,
'e'
,
'd'
,
'i'
,
't'
,
0
};
_wperror
(
regedit
);
fprintf
(
stderr
,
"regedit: Can't open file
\"
%ls
\"\n
"
,
filename
);
exit
(
1
);
}
import_registry_file
(
reg_file
);
if
(
realname
)
...
...
@@ -106,29 +105,17 @@ static BOOL PerformRegAction(REGEDIT_ACTION action, char **argv, int *i)
}
break
;
}
case
ACTION_DELETE
:
{
WCHAR
*
reg_key_nameW
=
GetWideString
(
argv
[
*
i
]);
delete_registry_key
(
reg_key_nameW
);
HeapFree
(
GetProcessHeap
(),
0
,
reg_key_nameW
);
case
ACTION_DELETE
:
delete_registry_key
(
argv
[
*
i
]);
break
;
}
case
ACTION_EXPORT
:
{
char
*
filename
=
argv
[
*
i
];
WCHAR
*
filenameW
;
filenameW
=
GetWideString
(
filename
);
if
(
filenameW
[
0
])
{
char
*
reg_key_name
=
argv
[
++
(
*
i
)];
WCHAR
*
reg_key_nameW
;
WCHAR
*
filename
=
argv
[
*
i
];
WCHAR
*
key_name
=
argv
[
++
(
*
i
)];
reg_key_nameW
=
GetWideString
(
reg_key_name
);
export_registry_key
(
filenameW
,
reg_key_nameW
,
REG_FORMAT_4
);
HeapFree
(
GetProcessHeap
(),
0
,
reg_key_nameW
);
}
else
{
export_registry_key
(
filenameW
,
NULL
,
REG_FORMAT_4
);
}
HeapFree
(
GetProcessHeap
(),
0
,
filenameW
);
if
(
key_name
&&
*
key_name
)
export_registry_key
(
filename
,
key_name
,
REG_FORMAT_4
);
else
export_registry_key
(
filename
,
NULL
,
REG_FORMAT_4
);
break
;
}
default:
...
...
@@ -139,76 +126,24 @@ static BOOL PerformRegAction(REGEDIT_ACTION action, char **argv, int *i)
return
TRUE
;
}
static
char
*
get_token
(
char
*
input
,
char
**
next
)
{
char
*
ch
=
input
;
char
*
str
;
while
(
*
ch
&&
isspace
(
*
ch
))
ch
++
;
str
=
ch
;
if
(
*
ch
==
'"'
)
{
ch
++
;
str
=
ch
;
for
(;;)
{
while
(
*
ch
&&
(
*
ch
!=
'"'
))
ch
++
;
if
(
!*
ch
)
break
;
if
(
*
(
ch
-
1
)
==
'\\'
)
{
ch
++
;
continue
;
}
break
;
}
}
else
{
while
(
*
ch
&&
!
isspace
(
*
ch
))
ch
++
;
}
if
(
*
ch
)
{
*
ch
=
0
;
ch
++
;
}
*
next
=
ch
;
return
str
;
}
BOOL
ProcessCmdLine
(
LPSTR
lpCmdLine
)
BOOL
ProcessCmdLine
(
WCHAR
*
cmdline
)
{
char
*
s
=
lpCmdLine
;
char
**
argv
;
char
*
tok
;
int
argc
=
0
,
i
=
1
;
WCHAR
**
argv
;
int
argc
,
i
;
REGEDIT_ACTION
action
=
ACTION_ADD
;
if
(
!*
lpCmdLine
)
return
FALSE
;
argv
=
CommandLineToArgvW
(
cmdline
,
&
argc
);
while
(
*
s
)
{
if
(
isspace
(
*
s
))
i
++
;
s
++
;
}
s
=
lpCmdLine
;
argv
=
HeapAlloc
(
GetProcessHeap
(),
0
,
i
*
sizeof
(
char
*
));
if
(
!
argv
)
return
FALSE
;
for
(
i
=
0
;
*
s
;
i
++
)
if
(
argc
==
1
)
{
tok
=
get_token
(
s
,
&
s
);
argv
[
i
]
=
HeapAlloc
(
GetProcessHeap
(),
0
,
strlen
(
tok
)
+
1
);
strcpy
(
argv
[
i
],
tok
);
argc
++
;
LocalFree
(
argv
);
return
FALSE
;
}
for
(
i
=
0
;
i
<
argc
;
i
++
)
for
(
i
=
1
;
i
<
argc
;
i
++
)
{
if
(
argv
[
i
][
0
]
!=
'/'
&&
argv
[
i
][
0
]
!=
'-'
)
break
;
/* No flags specified. */
...
...
@@ -219,7 +154,7 @@ BOOL ProcessCmdLine(LPSTR lpCmdLine)
if
(
argv
[
i
][
1
]
&&
argv
[
i
][
2
]
&&
argv
[
i
][
2
]
!=
':'
)
break
;
/* This is a file path beginning with '/'. */
switch
(
toupper
(
argv
[
i
][
1
]))
switch
(
toupper
W
(
argv
[
i
][
1
]))
{
case
'?'
:
fprintf
(
stderr
,
usage
);
...
...
@@ -241,7 +176,7 @@ BOOL ProcessCmdLine(LPSTR lpCmdLine)
/* ignored */
;
break
;
default:
fprintf
(
stderr
,
"regedit: Invalid switch [%s]
\n
"
,
argv
[
i
]);
fprintf
(
stderr
,
"regedit: Invalid switch [%
l
s]
\n
"
,
argv
[
i
]);
exit
(
1
);
}
}
...
...
@@ -265,9 +200,7 @@ BOOL ProcessCmdLine(LPSTR lpCmdLine)
for
(;
i
<
argc
;
i
++
)
PerformRegAction
(
action
,
argv
,
&
i
);
for
(
i
=
0
;
i
<
argc
;
i
++
)
HeapFree
(
GetProcessHeap
(),
0
,
argv
[
i
]);
HeapFree
(
GetProcessHeap
(),
0
,
argv
);
LocalFree
(
argv
);
return
TRUE
;
}
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