0

I have a driver that I haven't made and I manual map it. Say the function is ManualMap(); as an example.

That function gets called everytime I run my program. It's basically in main();

Now what I want to do is to make that function only be called once every session. So if PC was restarted, that function will be called, if u run the program again during the same pc session, it won't run the function. Now if you restart PC, the function will be called when you run the program.

bool main(){
    if (has_run_before_during_this_session()){
        return;
    }
    ManualMap();
    Save_Something_To_Run_Check_Next_Time();
}
mkrieger1
  • 19,194
  • 5
  • 54
  • 65
Clinkz MTA
  • 15
  • 6

1 Answers1

1

You will have to use canary. The simplest way to do this is to create a file on disk each time you run ManualMap().

Then you need to make sure that when your computer is started that file gets deleted. This will be OS-dependent. You create a script that will delete the file and then make sure it runs on startup (Windows, Linux).

TCvD
  • 600
  • 2
  • 8
  • Thank you, good way of doing it. But I'd want another suggestion – Clinkz MTA Dec 03 '20 at 11:05
  • You need to check for some footprint taht `ManualMap()` makes. Does it load a driver? Check for that. – TCvD Dec 03 '20 at 11:18
  • It loads a driver, and I don't have driver source, I just have to load it, and it must only be loaded once, otherwise will BSOD – Clinkz MTA Dec 03 '20 at 14:59
  • You can then check the list of currently loaded drivers. If it's there then don't load it again. Does that work? – TCvD Dec 03 '20 at 15:02
  • 1
    Checking for currently loaded drivers was the best solution. Here's an example on how to check for loaded drivers list, then just check for the specific driver u're looking for. https://stackoverflow.com/questions/751100/checking-if-a-particular-device-driver-is-loaded Thank you so much @Tomo Ceferin – Clinkz MTA Dec 03 '20 at 15:36