How to get a list of SCSI-Disks in C/C++ under Linux? - c++

i need to get a list or any other enumerable class with info about any connected SCSI-disks, with info just like /proc/scsi/sg/devices
Please help me and thanks in advance

You've basically named a solution in your question -- just open /proc/scsi/sg/devices and read from it.

Related

How to find the size of log files using EvtQuery function?

I've been working on windows log collection for a while. Can somebody please help me how to find the size of windows logs (Security, Application, System, etc) and also how to get the number of events that has been inserted into it. I need to access them using C++. There's a windows function EvtQuery to execute the query in C++.
I'm able to fetch the contents written in the log file. But how do I get the file size and the number of events which are not fields inside it?
Please refer the link to find details on the EvtQuery function:
https://learn.microsoft.com/en-us/windows/desktop/api/winevt/nf-winevt-evtquery
Please help
Thank you.
You Could use a combination of GetFileSizeEx to get the file size of the log and GetNumberOfEventLogRecords to retrieve the number of records in the specified event log.

MacOS - how to get process user/owner with PID using C/C++?

I have been using proc_info.h and similar files to get information about my processes like paths, ppids, names, etc. Now I need to get the user's who own those processes using C/C++. How can I do this? in proc_info.h I see the struct called proc_regioninfo which has a member pri_user_tag which might be what I am looking for but I'm cant figure out how to populate a struct of ````proc_regioninfo```. I've looked everywhere online and can't find an answer.
I've been digging around in this part of my file system trying to find stuff: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift-migrator/sdks/MacOSX.sdk/usr/include so maybe that will help you find things.
this question How to programatically get uid from pid in osx using c++? has an answer but I can't figure out how to install libproc-dev like the person suggests, nor can my system figure out what to do with #include <proc/readproc.h>.
If you have any idea I would greatly appreciate it!
So as it turns out you don't really get usernames through pid's at all. Here is my solution and it should work for anyone else with in this situation.
If you have PIDs from a sysctl call then you already have kinfostructs in which case you can just use these lines of code to access the information in that struct:
#include <pwd.h>
#include <sysctl.h>
struct passwd *pwd = getpwuid(kinfostructs[i].kp_eproc.e_ucred.cr_uid);
printf("username: %s\n",pwd->pw_name);
I can't format the actual source code in a way that they (stackoverflow) will let me post it. If you want the actual source code I used just ask me for it.
If you are using XCode (to what your digging in the file systems hints at) and if it is an option to write a mixed Objective-C / C++ - app, you could use Objective-C's NSProcessInfo-object, which provides features like userName of fullUserName . A way how to use NSProcessInfo is described in this SO answer. Hope it helps.

How to read a .shd file in C++?

I am creating a project in c++ for getting JobSettings of a job in a queue from .shd file.Can anyone please suggest me which API is used for reading .shd file?
If you're talking about the shadow file from the Windows spooler, take a look at this site and code accordingly - http://www.undocprint.org/formats/winspool/shd
Please note that this format is undocumented and so could change ever so often.

File Signature Validation

I Have used a utility written by Mark Russinovich, it is used to validate the file signature.
Any one have ideas how this can be done, i know it is not a simple code, but just i need some hints, APIs, steps, A guide map, Just to go in the correct direction.
I read too much a bout the cryptAPIs, then I read too much about the certAPIs, but i cannot get any thing useful to simply link a given file with the (unknown to me) data stored in the windows.
if any can help me in this issue please help, thanks a lot.
You should read about Authenticode.

Make CreateProcess get stdin from a string

Pretty simple, but can't really find anything on how to do this. Anyone have any tips or helpful links? thanks!
Maybe you want an anonymous pipe.
If so, I'd suggest you have a look at Creating a Child Process with Redirected Input and Output on MSDN.