PDA

View Full Version : ExSetTimerResolution, I need help...



NEOAethyr
05-10-2011, 11:44 PM
ExSetTimerResolution, I need a way of changing it.

The type of examples that I can take:
Ahk, vb, js, rundll32 and asm.
Everything else I either won't understand or won't beable to compile unless it's gcc.

I really need to beable to change this setting, I already have experience with what it does.

If you don't have an example that I can actually use, perhaps you could compile a ver that has some sort of user control?
Like a cmd tail'ed ver...

W1zzard
05-11-2011, 09:20 PM
this is for kernel mode drivers only, not normal user space programs. what are you trying to do?

NEOAethyr
05-12-2011, 01:25 AM
This ended up working in ahk script as long as the program stays resident, which is fine by me.



;Quantum timer resolution
;DllCall("ntdll.dll\NtSetTimerResolution", UInt, 156000) ;15.600 ms
;DllCall("ntdll.dll\NtSetTimerResolution", UInt, 100000) ;10.000 ms
;DllCall("ntdll.dll\NtSetTimerResolution", UInt, 10000) ;1.000 ms
DllCall("ntdll.dll\NtSetTimerResolution", UInt, 5000) ;0.500 ms


Not quite the same, but it's less timing stuff to deal with and it gets pretty much what I wanted as a user mod.
I would like the kernel ver though but this is fine.
At least now I know how to use it.
Perhaps it's possible to use a kernel export for the kernel ver instead now I don't know, I'll have to dig around and see what exact file has the ptr.

I want it as a user mod, so I can adjust the timing of the quantum time slices in finer detail.
Prob is, if a program defines lower then what I'm setting, say it sets 2.5ms like opera does, and I set 15.6ms as in stock.
The 2.5ms overrides the larger.
Which does suck, but I can force a max value...
Good enough for most pc stuff.
This went in my network monitor app..., as another mod thing.

I'm also thinking of making a clock app that uses diff sized gears(it's just a #...) based of planet alignments and etc etc, it's something that's in the back of my mind and positioning of planets type stuff, this was the reason I looked it up to begin with.
It's something I've been thinking about for a few weeks.

W1zzard
05-12-2011, 01:33 AM
messing with the timer = bad idea(tm)

microsoft has a detailed document on it: Timers, Timer Resolution, and Development of Efficient Code

maybe queryperformancecounter() is what you are looking for? it has some gotchas too, but works well on vista+ systems

NEOAethyr
05-12-2011, 01:43 AM
Yep I know ;), it can slow certain things down by not giving it enough cpu time.

If this were the kernel ver of the timer I would assume I would need to adjust the way the clock it's self is updated.
Otherwise, say if my timer was 2x faster, my clock would run 2x fast too.

But with this user ver, I don't need to adjust those other timings, I think there's a least a handful of them, saw them in some forum when looking up info on this stuff.

I experimented with this along time ago, with a dreamcast emulator.
But with this api I'm not allowed to force a min value, just the max, so I can't slow it down more then what the apps asks for.

I did notice some apps mess with this "global"(user) timer already.
Windows dreamscene makes it 1ms.
Opera sets 2.5ms.

I'm just setting it to it's supposed min, 0.5ms.
Which should be fine for most things on the pc, on my x6.
I'll make it adjustable so I can change it on the fly.

I would slow it down if I were to run into anything that needed more cpu speed then what I had.
Maybe even make it detect such apps and compare then to the cpu speed in mhz, that might not be worth it though, don't know yet (there wouldn't be many apps that I would need to slow it down for anyways).


Btw...
Do you know of a way to get a higher res then that?
This is nice and all but this is nothing really compared to how fast I've gotten it on win2k3 with a diff app that had direct i/o to whatever it was modding.




;Code Timer for Debugging...
;DllCall("QueryPerformanceCounter", "Int64*", CounterBefore) ;External Var, CPU Tick Timer
;StartTime := A_TickCount ;Internal Var, MS Timer
;Sleep 1000
;ElapsedTime_ms := (A_TickCount - StartTime)
;DllCall("QueryPerformanceCounter", "Int64*", CounterAfter)
;ElapsedTime_pc := (CounterAfter - CounterBefore)
;ToolTip, %ElapsedTime_pc% Ticks`n%ElapsedTime_ms% ms


I've already used the performance timer before for timing, it's good for that.
But it's not what I needed though :)...