Training
×

RslMain

RslMain is called in various places:
  • When a process starts using an RSL, RslMain is called with the RSL_PROCESS_ATTACH reason – in this case, RslMain is not called again with a RSL_THREAD_ATTACH reason. If RslMain returns FALSE, the process is aborted. If the RSL has been loaded by LoadRtLibrary and RslMain returns FALSE, then the call to LoadRtLibrary fails.
  • Add code that initializes whatever is needed for all threads in this process.
  • When a new thread is created, RslMain is called with the RSL_THREAD_ATTACH reason.
  • Add code that initializes whatever is needed for an individual thread in that process
  • When a thread is deleted, RslMain is called with the RSL_THREAD_DETACH reason.
  • Add code that cleans up things created for the thread. Note that this code only executes if the thread deletes itself or returns at the end of the function.
  • When a process stops using an RSL, RslMain is called with the RSL_PROCESS_DETACH reason.
  • Add code that cleans up things created for this process. There may be threads still executing in this process and RslMain will not be called for these threads with reason RSL_THREAD_DETACH.