Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

open_files does find out doc files opened by ms office word on windows. #542

Open
tomqyp opened this issue Oct 3, 2014 · 5 comments
Open

Comments

@tomqyp
Copy link

tomqyp commented Oct 3, 2014

open_files does find out doc files opened by ms office word on windows. Is that "Skip handles" code block missed anything?
I tried Sysinternals handle.exe, that can get it.

@giampaolo
Copy link
Owner

open_files() on Windows is broken and I'll probably remove it in the next major version

@tomqyp
Copy link
Author

tomqyp commented Dec 2, 2014

Open_files on Windows is very useful, if you don't want to fix it, at least, please keep it.

@amolvaikar
Copy link

@giampaolo

I investigated this a bit and it seems that this condition is responsible for the doc files getting missed:

handle.GrantedAccess == 0x0012019f

I noticed on a different open_files related defect you had mentioned that you are unable to recollect the original source of these access permissions related code:
#340 (comment)

By any chance, was it this source:
http://www.kernelmode.info/forum/viewtopic.php?f=10&t=195

Further, I think I have been able to find what the particular code 0x0012019f stands for with the help of this blog:
https://www.eldos.com/forum/read.php?FID=13&TID=2769
and the actual winnt.h
The access permissions that form this value are:
STANDARD_RIGHTS_WRITE 20000
FILE_WRITE_DATA 0002
FILE_WRITE_ATTRIBUTES 0100
FILE_WRITE_EA 0010
FILE_APPEND_DATA 0004
SYNCHRONIZE 100000
FILE_READ_EA 0008
FILE_READ_DATA 0001
FILE_READ_ATTRIBUTES 0080

so basically referring to the winnt.h, 0x0012019f seems to stand for:
FILE_GENERIC_READ|FILE_GENERIC_WRITE
Other hex values too can be figured out similarly, I will do so when time permits.

Meanwhile, after I recompiled the latest psutil after removing the check for 0x0012019f, I was able to get the document in my listing, now need to check if that causes any hangs on some other processes though. Will try to run the test suite and let you know.

Comments? Thoughts?
And yes, please do not remove this API.
Lastly, thank you for psutil.

@amolvaikar
Copy link

Ran the tests.
Here is the summary and the two failures I got:

======================================================================
FAIL: test_halfway_terminated_process (__main__.TestProcess)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "test\test_psutil.py", line 2025, in test_halfway_terminated_process
    self.fail("NoSuchProcess exception not raised for %r" % name)
AssertionError: NoSuchProcess exception not raised for 'num_ctx_switches'

======================================================================
FAIL: test_fetch_all (__main__.TestFetchAllProcesses)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "test\test_psutil.py", line 2227, in test_fetch_all
    self.fail(''.join(failures))
AssertionError:     
    ======================================================================
    FAIL: test_connections (proc=psutil.Process(pid=1472), ret=[pconn(fd=-1, family=2, type=2, laddr=('10.0.2.15', 1900), raddr=(), status='NONE'), pconn(fd=-1, family=2, type=2, laddr=('127.0.0.1', 1900), raddr=(), status='NONE'), pconn(fd=-1, family=2, type=2, laddr=('0.0.0.0', 3702), raddr=(), status='NONE'), pconn(fd=-1, family=2, type=2, laddr=('0.0.0.0', 3702), raddr=(), status='NONE'), pconn(fd=-1, family=2, type=2, laddr=('0.0.0.0', 54042), raddr=(), status='NONE'), pconn(fd=-1, family=2, type=2, laddr=('10.0.2.15', 54945), raddr=(), status='NONE'), pconn(fd=-1, family=2, type=2, laddr=('127.0.0.1', 54946), raddr=(), status='NONE'), pconn(fd=-1, family=23, type=2, laddr=('::1', 1900), raddr=(), status='NONE'), pconn(fd=-1, family=23, type=2, laddr=('fe80::8427:f3c6:d887:925e', 1900), raddr=(), status='NONE'), pconn(fd=-1, family=23, type=2, laddr=('::', 3702), raddr=(), status='NONE'), pconn(fd=-1, family=23, type=2, laddr=('::', 3702), raddr=(), status='NONE'), pconn(fd=-1, family=23, type=2, laddr=('::', 54043), raddr=(), status='NONE'), pconn(fd=-1, family=23, type=2, laddr=('fe80::8427:f3c6:d887:925e', 54943), raddr=(), status='NONE'), pconn(fd=-1, family=23, type=2, laddr=('::1', 54944), raddr=(), status='NONE')]))
    ----------------------------------------------------------------------
    Traceback (most recent call last):
      File "test\test_psutil.py", line 2213, in test_fetch_all
        meth(ret)
      File "test\test_psutil.py", line 2344, in connections
        self.assertEqual(len(ret), len(set(ret)))
      File "e:\python279\lib\unittest\case.py", line 513, in assertEqual
        assertion_func(first, second, msg=msg)
      File "e:\python279\lib\unittest\case.py", line 506, in _baseAssertEqual
        raise self.failureException(msg)
    AssertionError: 14 != 12    
    ======================================================================
    FAIL: test_memory_info_ex (proc=psutil.Process(pid=0, name='System Idle Process'), ret=pextmem(num_page_faults=0, peak_wset=0, wset=12288, peak_paged_pool=0, paged_pool=0, peak_nonpaged_pool=0, nonpaged_pool=0, pagefile=0, peak_pagefile=0, private=0)))
    ----------------------------------------------------------------------
    Traceback (most recent call last):
      File "test\test_psutil.py", line 2213, in test_fetch_all
        meth(ret)
      File "test\test_psutil.py", line 2326, in memory_info_ex
        assert ret.peak_wset >= ret.wset, ret
    AssertionError: pextmem(num_page_faults=0, peak_wset=0, wset=12288, peak_paged_pool=0, paged_pool=0, peak_nonpaged_pool=0, nonpaged_pool=0, pagefile=0, peak_pagefile=0, private=0)

----------------------------------------------------------------------
Ran 182 tests in 4.705s

FAILED (failures=2, skipped=79)

@mrjefftang
Copy link
Collaborator

I'm wondering if the file mask should just be exposed at the Python layer so people can mix and match the appropriate masks to ignore for their systems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants