I'm working on a program, which collects some statistics about processes, which are running on the system.
I've got a code, which retrieves some routine information, such as executable file version, publisher and so on.
The code works fine for me until I open lsass.exe. When I try to open file for reading, CreateFile fails with error ERROR_FILE_NOT_FOUND.
Here is the code:
auto FileHandle
= CreateFile(file_to_process.c_str(), // C:\Windows\System32\lsass.exe
GENERIC_READ,
FILE_SHARE_DELETE|FILE_SHARE_READ|FILE_SHARE_WRITE,
NULL,
OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL,
NULL);
if ( INVALID_HANDLE_VALUE == FileHandle )
{
int err_v = GetLastError(); // ERROR_FILE_NOT_FOUND
}
This code is a part of a system service, which is running with 'SYSTEM' privileges.