retrive bios clock date and time

B

Bill

I have been searching google all day trying to find a way to use win32
to retrive a computer's local time from the bios clocl, rather than
the system time, in the event that someone changed the system date
(accidentally or intentionally).
I found the win32_currenttime, but using system.management classes
with wmi this parameter returns a collection with a count of zero.
msdn has information on the getsystemtime function, but says it is
part of the Provider classes which are obsolete and recomments using
system.management.

Any one know how to do this?

Bill
 
M

Morten Wennevik [C# MVP]

Hi Bill,

I believe win32_currenttime is just an abstract class for win32_localtime
and win32_localutctime.

I'm not sure this is the bios time but you can read an instance of
win32_localtime this way:

using System.Management;

....

ManagementClass mc = new ManagementClass("win32_localtime");
foreach (ManagementObject mo in mc.GetInstances())
{
Console.WriteLine(mo.GetText(TextFormat.Mof));
}

And you will get something like this:

instance of Win32_LocalTime
{
Day = 14;
DayOfWeek = 0;
Hour = 13;
Minute = 2;
Month = 6;
Quarter = 2;
Second = 50;
WeekInMonth = 3;
Year = 2009;
};
 
K

Kerem Gümrükcü

Hi Morten,

well, IMHO there is no need to do that,
since you are pretty good with DateTime,...

And if you really need to access BIOS
and need data from it, either you try
the WMI Interfaces to satisfy your needs
or your write a simple driver with IOCTL
Dispatch to poll all data you need from
systen hardware within your driver and
write back to the buffers. There is no other
way to query low-level system bios data
without crossing the ring3->ring0
boundary,...

But as said: DateTime is just fine,...even no
need for Windows API,...!

Regards

Kerem

--
--
-----------------------
Beste Grüsse / Best regards / Votre bien devoue
Kerem Gümrükcü
Latest Project: http://www.pro-it-education.de/software/deviceremover
Latest Open-Source Projects: http://entwicklung.junetz.de
-----------------------
"This reply is provided as is, without warranty express or implied."

Morten Wennevik said:
Hi Bill,

I believe win32_currenttime is just an abstract class for win32_localtime
and win32_localutctime.

I'm not sure this is the bios time but you can read an instance of
win32_localtime this way:

using System.Management;

...

ManagementClass mc = new ManagementClass("win32_localtime");
foreach (ManagementObject mo in mc.GetInstances())
{
Console.WriteLine(mo.GetText(TextFormat.Mof));
}

And you will get something like this:

instance of Win32_LocalTime
{
Day = 14;
DayOfWeek = 0;
Hour = 13;
Minute = 2;
Month = 6;
Quarter = 2;
Second = 50;
WeekInMonth = 3;
Year = 2009;
};
--
Happy Coding!
Morten Wennevik [C# MVP]


Bill said:
I have been searching google all day trying to find a way to use win32
to retrive a computer's local time from the bios clocl, rather than
the system time, in the event that someone changed the system date
(accidentally or intentionally).
I found the win32_currenttime, but using system.management classes
with wmi this parameter returns a collection with a count of zero.
msdn has information on the getsystemtime function, but says it is
part of the Provider classes which are obsolete and recomments using
system.management.

Any one know how to do this?

Bill
 
B

Ben Voigt [C++ MVP]

Bill said:
I have been searching google all day trying to find a way to use win32
to retrive a computer's local time from the bios clocl, rather than
the system time, in the event that someone changed the system date
(accidentally or intentionally).

If anyone changes the system date, the hardware real-time clock gets changed
too. Are you trying to get a date and time from a more reliable source that
the computer owner? You can make a request across the web and use
asymmetric encryption to verify that it came from the trusted source, but
the computer owner can just change your program to skip the check.

There really is no way to secure data being used in an untrusted
environment -- MMORPG companies spend millions of dollars trying and still
fail.
I found the win32_currenttime, but using system.management classes
with wmi this parameter returns a collection with a count of zero.
msdn has information on the getsystemtime function, but says it is
part of the Provider classes which are obsolete and recomments using
system.management.

Any one know how to do this?

Bill

__________ Information from ESET NOD32 Antivirus, version of virus
signature database 4153 (20090613) __________

The message was checked by ESET NOD32 Antivirus.

http://www.eset.com

__________ Information from ESET NOD32 Antivirus, version of virus signature database 4153 (20090613) __________

The message was checked by ESET NOD32 Antivirus.

http://www.eset.com
 
B

Bill

I confirmed what you say by getting the win32_localtime data. My only
other idea is to use the date of the windows swap file and compare it
with the system date. If the system date is older, then I know it was
modified by the user, but still does not get the real system date. My
purpose, as you may have guessed, is for use in the trial version of
software.
 
B

Ben Voigt [C++ MVP]

Bill said:
I confirmed what you say by getting the win32_localtime data. My only
other idea is to use the date of the windows swap file and compare it
with the system date. If the system date is older, then I know it was
modified by the user, but still does not get the real system date. My
purpose, as you may have guessed, is for use in the trial version of
software.

Ok, I suppose you want to protect your software against torrent users but
not against the three real hackers in the world who will bypass the trial
check, putting in the effort to get those last three users to pay for their
licenses just isn't worth it.

So implement a "check for updates at startup" feature, and if a trial user
tries to disable it politely inform them that doing so requires the paid
version. Then you'll get a reliable timestamp served up by your own web
host.
 
B

Bill

I like your updates suggestion. Any serious cracker would not likely
be a buyer so I am really trying to focus on potential customers. BTW,
I made the trial version such that it will continue to execute
forever, but if the end of the trial period is detected it simply
displays a nag screen with an upgrade button and then posts an expired
message in the title of the main form. My thinking is that usage
generates word-of-mouth marketing.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top