Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-fonts
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
Aleksandr Isakov
wine-fonts
Commits
e608d65c
Commit
e608d65c
authored
Jan 21, 2017
by
Michael Müller
Committed by
Vitaly Lipatov
Jul 30, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
winedbg: Print process arguments in info threads.
parent
5323f956
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
105 additions
and
2 deletions
+105
-2
info.c
programs/winedbg/info.c
+105
-2
No files found.
programs/winedbg/info.c
View file @
e608d65c
...
...
@@ -628,6 +628,103 @@ WCHAR* fetch_thread_description(DWORD tid)
return
desc
;
}
static
BOOL
read_process_memory
(
HANDLE
process
,
const
void
*
ptr
,
void
*
buffer
,
SIZE_T
length
)
{
SIZE_T
read
;
return
ReadProcessMemory
(
process
,
ptr
,
buffer
,
length
,
&
read
)
&&
(
read
==
length
);
}
static
BOOL
get_process_cmdline
(
HANDLE
process
,
PEB
*
peb
,
UNICODE_STRING
*
cmdline
)
{
RTL_USER_PROCESS_PARAMETERS
*
params
;
if
(
!
read_process_memory
(
process
,
&
peb
->
ProcessParameters
,
&
params
,
sizeof
(
params
)))
return
FALSE
;
if
(
!
read_process_memory
(
process
,
&
params
->
CommandLine
,
cmdline
,
sizeof
(
*
cmdline
)))
return
FALSE
;
return
TRUE
;
}
static
BOOL
get_process_cmdline_wow64
(
HANDLE
process
,
PEB
*
peb
,
UNICODE_STRING
*
cmdline
)
{
DWORD
params
;
struct
{
USHORT
Length
;
USHORT
MaximumLength
;
DWORD
Buffer
;
}
cmdline32
;
/* &peb->ProcessParameters */
if
(
!
read_process_memory
(
process
,
(
char
*
)
peb
+
0x10
,
&
params
,
sizeof
(
params
)))
return
FALSE
;
/* ¶ms->CommandLine */
if
(
!
read_process_memory
(
process
,
(
char
*
)(
DWORD_PTR
)
params
+
0x40
,
&
cmdline32
,
sizeof
(
cmdline32
)))
return
FALSE
;
cmdline
->
Length
=
cmdline32
.
Length
;
cmdline
->
MaximumLength
=
cmdline32
.
MaximumLength
;
cmdline
->
Buffer
=
(
WCHAR
*
)(
DWORD_PTR
)
cmdline32
.
Buffer
;
return
TRUE
;
}
static
char
*
get_process_args
(
DWORD
pid
)
{
PROCESS_BASIC_INFORMATION
info
;
BOOL
self_wow64
,
process_wow64
;
UNICODE_STRING
cmdline
;
WCHAR
*
tempW
=
NULL
;
char
*
args
=
NULL
;
HANDLE
process
;
DWORD
len
;
BOOL
ret
;
if
(
!
(
process
=
OpenProcess
(
PROCESS_QUERY_INFORMATION
|
PROCESS_VM_READ
,
FALSE
,
pid
)))
return
FALSE
;
if
(
NtQueryInformationProcess
(
process
,
ProcessBasicInformation
,
&
info
,
sizeof
(
info
),
NULL
))
goto
done
;
IsWow64Process
(
GetCurrentProcess
(),
&
self_wow64
);
if
(
!
IsWow64Process
(
process
,
&
process_wow64
))
goto
done
;
if
(
process_wow64
==
self_wow64
)
ret
=
get_process_cmdline
(
process
,
info
.
PebBaseAddress
,
&
cmdline
);
else
if
(
!
self_wow64
&&
process_wow64
)
ret
=
get_process_cmdline_wow64
(
process
,
info
.
PebBaseAddress
,
&
cmdline
);
else
ret
=
FALSE
;
/* can't read process args of 64-bit process with 32-bit winedbg */
if
(
!
ret
)
goto
done
;
/* protect against malicious content */
if
(
cmdline
.
Length
>
4096
||
(
cmdline
.
Length
&
1
))
goto
done
;
if
(
!
(
tempW
=
HeapAlloc
(
GetProcessHeap
(),
HEAP_ZERO_MEMORY
,
cmdline
.
Length
+
2
)))
goto
done
;
if
(
!
read_process_memory
(
process
,
cmdline
.
Buffer
,
tempW
,
cmdline
.
Length
))
goto
done
;
if
(
!
(
len
=
WideCharToMultiByte
(
CP_ACP
,
0
,
tempW
,
-
1
,
NULL
,
0
,
NULL
,
NULL
)))
goto
done
;
if
(
!
(
args
=
HeapAlloc
(
GetProcessHeap
(),
0
,
len
)))
goto
done
;
if
(
!
WideCharToMultiByte
(
CP_ACP
,
0
,
tempW
,
-
1
,
args
,
len
,
NULL
,
NULL
))
{
HeapFree
(
GetProcessHeap
(),
0
,
args
);
args
=
NULL
;
}
done:
HeapFree
(
GetProcessHeap
(),
0
,
tempW
);
CloseHandle
(
process
);
return
args
;
}
void
info_win32_threads
(
void
)
{
HANDLE
snap
=
CreateToolhelp32Snapshot
(
TH32CS_SNAPTHREAD
,
0
);
...
...
@@ -657,6 +754,7 @@ void info_win32_threads(void)
{
PROCESSENTRY32W
pcs_entry
;
const
WCHAR
*
exename
;
char
*
args
;
p
=
dbg_get_process
(
entry
.
th32OwnerProcessID
);
if
(
p
)
...
...
@@ -666,8 +764,13 @@ void info_win32_threads(void)
else
exename
=
L""
;
dbg_printf
(
"%08lx%s %ls
\n
"
,
entry
.
th32OwnerProcessID
,
p
?
" (D)"
:
""
,
exename
);
dbg_printf
(
"%08lx%s %ls
\n
"
,
entry
.
th32OwnerProcessID
,
p
?
" (D)"
:
""
,
exename
);
args
=
get_process_args
(
entry
.
th32OwnerProcessID
);
if
(
args
)
{
dbg_printf
(
"
\t
[%s]
\n
"
,
args
);
HeapFree
(
GetProcessHeap
(),
0
,
args
);
}
lastProcessId
=
entry
.
th32OwnerProcessID
;
}
dbg_printf
(
"
\t
%08lx %4ld%s "
,
...
...
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