Another look at HPET High Precision Event Timer

Discussion in 'Videocards - NVIDIA GeForce Drivers Section' started by Bukkake, Sep 18, 2012.

  1. pipes

    pipes Member Guru

    Messages:
    182
    Likes Received:
    0
    GPU:
    Rtx 4080 frostbite
    file path is this: C:\Windows\System32\SetTimerResolutionService.exe
     
  2. mbk1969

    mbk1969 Ancient Guru

    Messages:
    15,606
    Likes Received:
    13,615
    GPU:
    GF RTX 4070
    Is it actual file path? If it is try in cmd.exe:

    SetTimerResolutionService.exe -uninstall

    SetTimerResolutionService.exe -install

    i.e. re-register service... (And then start it manually.)
     
    Last edited: Feb 28, 2013
  3. pipes

    pipes Member Guru

    Messages:
    182
    Likes Received:
    0
    GPU:
    Rtx 4080 frostbite
    same problem :-(
     
  4. mbk1969

    mbk1969 Ancient Guru

    Messages:
    15,606
    Likes Received:
    13,615
    GPU:
    GF RTX 4070
    Sorry... By now I don`t have a clue what is heppening... If 'eurika' will happen I will PM you. Lets not flood this thread with support posts...
     

  5. pipes

    pipes Member Guru

    Messages:
    182
    Likes Received:
    0
    GPU:
    Rtx 4080 frostbite
    Now work thank you so much.
    I have change directory from system32 to desktop and now work
     
  6. dnottis

    dnottis Master Guru

    Messages:
    695
    Likes Received:
    0
    GPU:
    EVGA SSC 970 GTX 4GB
    I put the file SetTimerResolutionService.exe in C:\Users\xxxxx\SetTimerResolutionService. open CMD as admin, change to directory its in, run SetTimerResolutionService.exe -install

    installed. If you go into services it's there and running, even after reboot. .488 ms if I open it in the other tool. You either have something with security too high or are doing something wrong. You cannot move or delete the file so put it somewhere out of the way...

    BTW - thanks mbk1969 works perfectly here.

    [​IMG]
     
  7. Major Melchett

    Major Melchett Ancient Guru

    Messages:
    2,452
    Likes Received:
    0
    GPU:
    R9 280X @ 1100/1500
    I was having the same issue, I couldn't get it to run from that directory and had to do 3 things.

    1st. I uninstalled the file using SetTimerResolutionService -uninstall via CMD line and I then deleted the file from the system32 folder.

    2nd. After unzipping the file again I had to rezipp/unzipp it myself as it was flagged/blocked as a file from another computer (windows 8 does this) - simple process, just zip the file up and extract it again.

    3rd. I then placed the file in my utilities folder I have from all my messing about stuff, so I pointed the CMD line like so.

    cd\Program Files (x86)\Utilities\Set Timer Resolution
    Then I simply pasted in the command "SetTimerResolutionService -install"

    Soon as I did that, it started without issue - it seems it won't work from within the system32 folder..
     
    Last edited: Feb 28, 2013
  8. mbk1969

    mbk1969 Ancient Guru

    Messages:
    15,606
    Likes Received:
    13,615
    GPU:
    GF RTX 4070
    Guys, problem is solved... Do not test moderator`s patience.
     
  9. mbk1969

    mbk1969 Ancient Guru

    Messages:
    15,606
    Likes Received:
    13,615
    GPU:
    GF RTX 4070
    There is group policy setting that forces internet explorer to attach special flag to files loaded from 'outside'. That`s how OS recognizes such files.
     
    Last edited: Feb 28, 2013
  10. WhiteLightning

    WhiteLightning Don Illuminati Staff Member

    Messages:
    30,789
    Likes Received:
    3,961
    GPU:
    Inno3d RTX4070
    Thanks for sharing mbk1969 :thumbup:
     

  11. Von Dach

    Von Dach Master Guru

    Messages:
    625
    Likes Received:
    5
    GPU:
    NV560Ti @900/2394 ATI4890
    https://www.virustotal.com/en/file/...a6c68223d1378d47203af7c96c5e13339b8/analysis/
    http://virusscan.jotti.org/en/scanr...4742/d9315cecfc49e9a94aa38df7856136c76e9c3eb7

    I'm pretty sure it is a false positive and that you are honest but why so much increase in size (15KB to 70KB) between SetTimerResolutionService.exe and SetTimerResolutionService(2).exe (plus the false positive)? What changed in-between?
     
  12. mbk1969

    mbk1969 Ancient Guru

    Messages:
    15,606
    Likes Received:
    13,615
    GPU:
    GF RTX 4070
    First thought on pipes`s problem with service start failure was that his OS lacks required C++ libraries (redistributable). So I re-build exe file with those libraries linked statically. Here goes increased size. (If virus scanners didn`t find anything suspicious in first version then question is - what is suspicious in MS C++ library?)

    When i find a C# example of system service I put it here as a source with NtSetTimerResolution call injection... I can upload current C++ sources to mediafire, but only men with VisualStudio or something could build them...

    Von Dach, I have an idea about your optimization thread. I am using now in my daily development work the PowerShell. It is coolest thing with cool script language which was developed by MS namely for IT management tasks. So it is easy to use for manipulating registry, system services, files etc... We can try to use it in your optimization thread.
     
    Last edited: Mar 1, 2013
  13. pipes

    pipes Member Guru

    Messages:
    182
    Likes Received:
    0
    GPU:
    Rtx 4080 frostbite
    Only works well in another folder that is not system32
     
  14. mbk1969

    mbk1969 Ancient Guru

    Messages:
    15,606
    Likes Received:
    13,615
    GPU:
    GF RTX 4070
    Code:
    // http://www.codeproject.com/Articles/14353/Creating-a-Basic-Windows-Service-in-C
    
    using System;
    using System.Diagnostics;
    using System.Runtime.InteropServices;
    using System.ServiceProcess;
    using System.ComponentModel;
    using System.Configuration.Install;
    
    namespace WindowsService
    {
        class WindowsService : ServiceBase
        {
            /// <summary>
            /// Public Constructor for WindowsService.
            /// - Put all of your Initialization code here.
            /// </summary>
            public WindowsService()
            {
                this.ServiceName = "STR";
                this.EventLog.Log = "Application";
                
                // These Flags set whether or not to handle that specific
                //  type of event. Set to true if you need it, false otherwise.
                this.CanStop = true;
    
                this.CanHandlePowerEvent = false;
                this.CanHandleSessionChangeEvent = false;
                this.CanPauseAndContinue = false;
                this.CanShutdown = false;
            }
    
            /// <summary>
            /// The Main Thread: This is where your Service is Run.
            /// </summary>
            static void Main()
            {
                ServiceBase.Run(new WindowsService());
            }
    
            /// <summary>
            /// Dispose of objects that need it here.
            /// </summary>
            /// <param name="disposing">Whether or not disposing is going on.</param>
            protected override void Dispose(bool disposing)
            {
                base.Dispose(disposing);
            }
    
            [DllImport("ntdll.dll", SetLastError=true)]
            static extern int NtSetTimerResolution(uint DesiredResolution, bool SetResolution, out uint CurrentResolution);
    
            [DllImport("ntdll.dll", SetLastError=true)]
            static extern int NtQueryTimerResolution(out uint MinimumResolution, out uint MaximumResolution, out uint ActualResolution);
    
            /// <summary>
            /// OnStart(): Put startup code here
            ///  - Start threads, get inital data, etc.
            /// </summary>
            /// <param name="args"></param>
            protected override void OnStart(string[] args)
            {
                base.OnStart(args);
    
                uint CurrentResolution = 0;
                uint MininumResolution = 0;
                uint MaximumResolution = 0;
    
                NtQueryTimerResolution(out MininumResolution, out MaximumResolution, out CurrentResolution);
    
                bool SetResolution = true;
                uint DesiredResolution = MaximumResolution;
    
                NtSetTimerResolution(DesiredResolution, SetResolution, out CurrentResolution);
    
                this.EventLog.WriteEntry(String.Format("Minimum={0}; Maximum={1}; Current={2}", MininumResolution, MaximumResolution, CurrentResolution));
    
            }
    
            /// <summary>
            /// OnStop(): Put your stop code here
            /// - Stop threads, set final data, etc.
            /// </summary>
            protected override void OnStop()
            {
                base.OnStop();
            }
    
            /// <summary>
            /// OnCustomCommand(): If you need to send a command to your
            ///   service without the need for Remoting or Sockets, use
            ///   this method to do custom methods.
            /// </summary>
            /// <param name="command">Arbitrary Integer between 128 & 256</param>
            protected override void OnCustomCommand(int command)
            {
                //  A custom command can be sent to a service by using this method:
                //#  int command = 128; //Some Arbitrary number between 128 & 256
                //#  ServiceController sc = new ServiceController("NameOfService");
                //#  sc.ExecuteCommand(command);
    
                base.OnCustomCommand(command);
            }
        }
    
        [RunInstaller(true)]
        public class WindowsServiceInstaller : Installer
        {
            /// <summary>
            /// Public Constructor for WindowsServiceInstaller.
            /// - Put all of your Initialization code here.
            /// </summary>
            public WindowsServiceInstaller()
            {
                ServiceProcessInstaller serviceProcessInstaller = 
                                   new ServiceProcessInstaller();
                ServiceInstaller serviceInstaller = new ServiceInstaller();
    
                //# Service Account Information
                serviceProcessInstaller.Account = ServiceAccount. LocalService;
                serviceProcessInstaller.Username = null;
                serviceProcessInstaller.Password = null;
    
                //# Service Information
                serviceInstaller.DisplayName = "Set Timer Resolution Service";
                serviceInstaller.StartType = ServiceStartMode.Automatic;
    
                //# This must be identical to the WindowsService.ServiceBase name
                //# set in the constructor of WindowsService.cs
                serviceInstaller.ServiceName = "STR";
    
                this.Installers.Add(serviceProcessInstaller);
                this.Installers.Add(serviceInstaller);
            }
        }
    
    }
    OK. Here it is - C# source of set timer resolution service for DIYers. Taken from http://www.codeproject.com/Articles/14353/Creating-a-Basic-Windows-Service-in-C

    Installation
    (do not forget to uninstall C++ version of service before installing new)

    You could install the service though the InstallUtil.exe process that comes with the .NET Framework:

    InstallUtil /i SetTimerResolutionService.exe

    Uninstallation

    InstallUtil /u SetTimerResolutionService.exe

    updated: logging event with info on service`s start
     
    Last edited: Mar 1, 2013
  15. mbk1969

    mbk1969 Ancient Guru

    Messages:
    15,606
    Likes Received:
    13,615
    GPU:
    GF RTX 4070
    You should know that placing user stuff in system32 folder is bad idea.
     

  16. -Tj-

    -Tj- Ancient Guru

    Messages:
    18,103
    Likes Received:
    2,606
    GPU:
    3080TI iChill Black
    So what are you all debating here?

    How to Automatically start purchased timer resolution tool?


    More on topic, I've deleted setPlatformTimer and re-enabled dynamic tick like suggested in 1st post and i dont have any issues in BF3.. Weird, played multiple games and all run fine, guess this dynamic tick + HPET on in Windows doesnt work so good..
     
  17. mbk1969

    mbk1969 Ancient Guru

    Messages:
    15,606
    Likes Received:
    13,615
    GPU:
    GF RTX 4070
    Instead purchased tool we developed our own tool. Open source movement! (Even two tools - console app and system service.)
     
  18. Von Dach

    Von Dach Master Guru

    Messages:
    625
    Likes Received:
    5
    GPU:
    NV560Ti @900/2394 ATI4890
    That's answered my question again, I see no problem there.

    Optimization: if you feel inspired by anything in there don't hesitate to grab whatever you want for your own stuff and community!

    PowerShell: if we need it to be installed it may be a issue for someone like me who uninstall it from Windows Features but if what you do become a must-have I'll sure re-install it.

    You are welcome to post that stuff in that thread or to start your own, your choice my friend.
     
    Last edited: Mar 2, 2013
  19. mbk1969

    mbk1969 Ancient Guru

    Messages:
    15,606
    Likes Received:
    13,615
    GPU:
    GF RTX 4070
    PowerShell is integrated into Windows 7 (PS ver2) & 8 (PS ver3) by default. There is shortcut in start menu. PS is like cmd.exe shell but much more advanced. Beside old cmd stuff it has builtin commands (with 'verb-noun' naming pattern such as Get-Process, Stop-Process) - aka comandlets, - and it has script language, and it has direct access to all .Net framework class library. PowerShell can be installed on Vista and XP along with .Net framework and WinRM (remoting management).

    http://en.wikipedia.org/wiki/Windows_PowerShell


    OK. I will dive into your optimization thread suggestions...
     
    Last edited: Mar 2, 2013
  20. Mineria

    Mineria Ancient Guru

    Messages:
    5,540
    Likes Received:
    701
    GPU:
    Asus RTX 3080 Ti
    The purchased version can simply be added as a startup task with " -max -hide " parameters.
     

Share This Page