JimmahDean
JimmahDean
CC#
Created by JimmahDean on 1/23/2024 in #help
How can I detect if my app is being run on a VM?
I have an app for gathering various system information from hardware to event logs to assist in troubleshooting for the Reddit /r/TechSupport discord server. Occasionally, people run it on a VM which gives unreliable information and it is not immediately recognizable it's a VM. Is there a way to determine if the app is being run on a virtual machine?
8 replies
CC#
Created by JimmahDean on 2/9/2023 in #help
❔ P/Invoked DeviceIoControl() works in C++ but does nothing in C#.
Code is attached. I have scoured this for hours upon hours and cross checked the pointers with the working C++ version and everything matches. The call doesn't error, checking LastWin32Error, LastSystemError and LastPInvokeError all return "The operation completed successfully." and the return length of the data retrieved is the same in C# as it is in C++, even checked in ProcMon that both apps were making the same system calls and they are. The call happens successfully as it should, but zero data is retrieved in the C# version. I'm at my wits end here.
117 replies
CC#
Created by JimmahDean on 1/24/2023 in #help
❔ UWP TreeView is not stretching to fill space
7 replies
CC#
Created by JimmahDean on 12/3/2022 in #help
❔ Connecting to the system resource usage monitor database
Hello! 👋 I am attempting to read and parse the SRU db found at C:\Windows\System32\sru\srudb.dat - From what I'm found, it's an Extensible Storage Engine database, however I haven't been able to find code that actually works to connect to it. The OleDb answers all except saying I don't have the right provider installed, so maybe I just need to change the connection string to something more current, and the Isam answers I've found all fail because the page size does not match the page size of the database for all legal page sizes. I'm hoping someone more knowledgeable than I can point me in the right direction on how I might parse this. Here's the most recent failed attempt
JET_INSTANCE instance;
JET_SESID sesid;

SystemParameters.DatabasePageSize = 8192;

Api.JetCreateInstance(out instance, Guid.NewGuid().ToString());
Api.JetInit(ref instance);

JET_DBID dbid;
JET_COLUMNID columnid;
JET_TABLEID tableid;
JET_COLUMNDEF columndef = new JET_COLUMNDEF();

Api.JetBeginSession(instance, out sesid, null, null);

Api.JetAttachDatabase(sesid, @"C:\Windows\System32\sru\srudb.dat", AttachDatabaseGrbit.None);

Api.OpenDatabase(sesid, @"C:\Windows\System32\sru\srudb.dat", out dbid, OpenDatabaseGrbit.None);
JET_INSTANCE instance;
JET_SESID sesid;

SystemParameters.DatabasePageSize = 8192;

Api.JetCreateInstance(out instance, Guid.NewGuid().ToString());
Api.JetInit(ref instance);

JET_DBID dbid;
JET_COLUMNID columnid;
JET_TABLEID tableid;
JET_COLUMNDEF columndef = new JET_COLUMNDEF();

Api.JetBeginSession(instance, out sesid, null, null);

Api.JetAttachDatabase(sesid, @"C:\Windows\System32\sru\srudb.dat", AttachDatabaseGrbit.None);

Api.OpenDatabase(sesid, @"C:\Windows\System32\sru\srudb.dat", out dbid, OpenDatabaseGrbit.None);
3 replies