Skip to content

PhantomDelay is a precise delay function that uses the Windows high resolution performance counter to pause your program for a specified number of seconds.

Notifications You must be signed in to change notification settings

EvilBytecode/PhantomDelay

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

5 Commits
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

PhantomDelay πŸ‘»

🧳 Overview

The PhantomDelay function provides a way to introduce a precise delay in your program, measured in seconds. It's useful when you need your program to wait for a specific amount of time without using common functions like Sleep, which might not offer as precise control. This function uses the high-resolution performance counter provided by Windows (QueryPerformanceCounter) to measure time, making it more accurate than typical timer functions.

βš™οΈ How It Works

  1. High-Resolution Timer: It uses the QueryPerformanceCounter function, which retrieves the current value of the high-resolution performance counter. This counter provides precise time measurements, making the delay highly accurate.
  2. Frequency: It uses the QueryPerformanceFrequency function to determine the frequency of the performance counter, which allows it to calculate the exact number of counts needed for the specified number of seconds.
  3. Looping until Time Elapsed: The function enters a loop that keeps checking the counter until the specified time has passed. Once the desired time is reached, the loop ends, and the program continues.

πŸ“ How to Use

1. Include the Header

To use the PhantomDelay function in your code, you need to include the phantom_delay.h header file.

#include "phantom_delay.h"

2. Call the Function

Call the PhantomDelay function and pass the number of seconds you want the program to wait.

Example:

#include "phantom_delay.h"

int main() {
    stealth::PhantomDelay(5);
    return 0;
}

πŸ—ΊοΈ Flow Diagram

graph TD
    A[Start] --> B[Query performance frequency]
    B --> C[Record start time]
    C --> D[Check current time]
    D --> E{Time elapsed?}
    E -- No --> D
    E -- Yes --> F[Exit loop]
    F --> G[Program continues]
Loading

🌟 Key Benefits

  • High Precision: The delay is accurate because it uses a high-resolution performance counter.
  • Simple and Fast: The function is lightweight and easy to implement in any project.

πŸ“œ License

This project is licensed under the MIT License.

About

PhantomDelay is a precise delay function that uses the Windows high resolution performance counter to pause your program for a specified number of seconds.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages