Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
wine
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Package registry
Container Registry
Model registry
Operate
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Alexey Alyaev
wine
Commits
d677edf9
Commit
d677edf9
authored
23 years ago
by
Hidenori Takeshima
Committed by
Alexandre Julliard
23 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Implemented EnumProcesses and EnumProcessModules.
parent
aeb56605
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
dlls/psapi/psapi_main.c
+118
-14
118 additions, 14 deletions
dlls/psapi/psapi_main.c
with
118 additions
and
14 deletions
dlls/psapi/psapi_main.c
+
118
−
14
View file @
d677edf9
...
...
@@ -21,13 +21,34 @@
#include
"winbase.h"
#include
"windef.h"
#include
"winerror.h"
#include
"wine/server.h"
#include
"wine/debug.h"
#include
"tlhelp32.h"
#include
"psapi.h"
WINE_DEFAULT_DEBUG_CHANNEL
(
psapi
);
#include
<string.h>
/***********************************************************************
* get pid from hProcess (internal)
*/
static
DWORD
get_pid_from_process_handle
(
HANDLE
hProcess
)
{
DWORD
ret
=
0
;
SERVER_START_REQ
(
get_process_info
)
{
req
->
handle
=
hProcess
;
if
(
!
wine_server_call_err
(
req
)
)
ret
=
(
DWORD
)
reply
->
pid
;
}
SERVER_END_REQ
;
return
ret
;
}
/***********************************************************************
* EmptyWorkingSet (PSAPI.@)
*/
...
...
@@ -56,12 +77,47 @@ BOOL WINAPI EnumDeviceDrivers(
*/
BOOL
WINAPI
EnumProcesses
(
DWORD
*
lpidProcess
,
DWORD
cb
,
DWORD
*
lpcbNeeded
)
{
FIXME
(
"(%p, %ld, %p): stub
\n
"
,
lpidProcess
,
cb
,
lpcbNeeded
);
if
(
lpcbNeeded
)
*
lpcbNeeded
=
0
;
return
TRUE
;
PROCESSENTRY32
pe
;
HANDLE
hSnapshot
;
BOOL
res
;
DWORD
count
;
DWORD
countMax
;
FIXME
(
"(%p, %ld, %p)
\n
"
,
lpidProcess
,
cb
,
lpcbNeeded
);
if
(
lpidProcess
==
NULL
)
cb
=
0
;
if
(
lpcbNeeded
!=
NULL
)
*
lpcbNeeded
=
0
;
hSnapshot
=
CreateToolhelp32Snapshot
(
TH32CS_SNAPPROCESS
,
0
);
if
(
hSnapshot
==
INVALID_HANDLE_VALUE
)
{
FIXME
(
"cannot create snapshot
\n
"
);
return
FALSE
;
}
count
=
0
;
countMax
=
cb
/
sizeof
(
DWORD
);
while
(
1
)
{
ZeroMemory
(
&
pe
,
sizeof
(
PROCESSENTRY32
)
);
pe
.
dwSize
=
sizeof
(
PROCESSENTRY32
);
res
=
(
count
==
0
)
?
Process32First
(
hSnapshot
,
&
pe
)
:
Process32Next
(
hSnapshot
,
&
pe
);
if
(
!
res
)
break
;
TRACE
(
"process 0x%08lx
\n
"
,(
long
)
pe
.
th32ProcessID
);
if
(
count
<
countMax
)
lpidProcess
[
count
]
=
pe
.
th32ProcessID
;
count
++
;
}
CloseHandle
(
hSnapshot
);
if
(
lpcbNeeded
!=
NULL
)
*
lpcbNeeded
=
sizeof
(
DWORD
)
*
count
;
TRACE
(
"return %lu processes
\n
"
,
count
);
return
TRUE
;
}
/***********************************************************************
...
...
@@ -70,14 +126,56 @@ BOOL WINAPI EnumProcesses(DWORD *lpidProcess, DWORD cb, DWORD *lpcbNeeded)
BOOL
WINAPI
EnumProcessModules
(
HANDLE
hProcess
,
HMODULE
*
lphModule
,
DWORD
cb
,
LPDWORD
lpcbNeeded
)
{
FIXME
(
"(hProcess=0x%08x, %p, %ld, %p): stub
\n
"
,
hProcess
,
lphModule
,
cb
,
lpcbNeeded
);
if
(
lpcbNeeded
)
*
lpcbNeeded
=
0
;
return
TRUE
;
MODULEENTRY32
me
;
HANDLE
hSnapshot
;
BOOL
res
;
DWORD
pid
;
DWORD
count
;
DWORD
countMax
;
FIXME
(
"(hProcess=0x%08x, %p, %ld, %p)
\n
"
,
hProcess
,
lphModule
,
cb
,
lpcbNeeded
);
if
(
lphModule
==
NULL
)
cb
=
0
;
if
(
lpcbNeeded
!=
NULL
)
*
lpcbNeeded
=
0
;
pid
=
get_pid_from_process_handle
(
hProcess
);
if
(
pid
==
0
)
{
FIXME
(
"no pid for hProcess 0x%08x
\n
"
,
hProcess
);
return
FALSE
;
}
hSnapshot
=
CreateToolhelp32Snapshot
(
TH32CS_SNAPMODULE
,
pid
);
if
(
hSnapshot
==
INVALID_HANDLE_VALUE
)
{
FIXME
(
"cannot create snapshot
\n
"
);
return
FALSE
;
}
count
=
0
;
countMax
=
cb
/
sizeof
(
HMODULE
);
while
(
1
)
{
ZeroMemory
(
&
me
,
sizeof
(
MODULEENTRY32
)
);
me
.
dwSize
=
sizeof
(
MODULEENTRY32
);
res
=
(
count
==
0
)
?
Module32First
(
hSnapshot
,
&
me
)
:
Module32Next
(
hSnapshot
,
&
me
);
if
(
!
res
)
break
;
TRACE
(
"module 0x%08lx
\n
"
,(
long
)
me
.
hModule
);
if
(
count
<
countMax
)
lphModule
[
count
]
=
me
.
hModule
;
count
++
;
}
CloseHandle
(
hSnapshot
);
if
(
lpcbNeeded
!=
NULL
)
*
lpcbNeeded
=
sizeof
(
HMODULE
)
*
count
;
TRACE
(
"return %lu modules
\n
"
,
count
);
return
TRUE
;
}
/***********************************************************************
...
...
@@ -217,6 +315,9 @@ DWORD WINAPI GetModuleFileNameExA(
hProcess
,
hModule
,
debugstr_a
(
lpFilename
),
nSize
);
if
(
get_pid_from_process_handle
(
hProcess
)
==
GetCurrentProcessId
()
)
return
GetModuleFileNameA
(
hModule
,
lpFilename
,
nSize
);
if
(
lpFilename
&&
nSize
)
lpFilename
[
0
]
=
'\0'
;
...
...
@@ -233,6 +334,9 @@ DWORD WINAPI GetModuleFileNameExW(
hProcess
,
hModule
,
debugstr_w
(
lpFilename
),
nSize
);
if
(
get_pid_from_process_handle
(
hProcess
)
==
GetCurrentProcessId
()
)
return
GetModuleFileNameW
(
hModule
,
lpFilename
,
nSize
);
if
(
lpFilename
&&
nSize
)
lpFilename
[
0
]
=
'\0'
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment