한 걸음씩..

드라이버 사용 기간 제한 하기! (시간 함수 사용) 본문

프로그래밍

드라이버 사용 기간 제한 하기! (시간 함수 사용)

반엘 2013. 7. 21. 09:00

#define TwoSeconds (2*1000*1000*10)

#define AlmostTwoSeconds (TwoSeconds - 1)

NTSTATUS HJGetTime( CSHORT LimitYear, CSHORT LimitMonth )

{

        LARGE_INTEGER Time;

        TIME_FIELDS TimeFields;


        //

        //  Get the current system time, and map it into a time field record.

        //

        KeQuerySystemTime( &Time );

        ExSystemTimeToLocalTime( &Time, &Time );

 

        //

        //  Always add almost two seconds to round up to the nearest double second.

        //

        Time.QuadPart = Time.QuadPart + AlmostTwoSeconds;

        (VOID)RtlTimeToTimeFields( &Time, &TimeFields );

 

        //

        //  Now simply copy over the information

        //

         DbgPrint( "Year:%d, Month:%d, Day:%d \n", TimeFields.Year, TimeFields.Month, TimeFields.Day );

         if( (TimeFields.Year > LimitYear) || (TimeFields.Month > LimitMonth) )

         {

              return STATUS_UNSUCCESSFUL; 

         }

 

         return STATUS_SUCCESS;

}