Decrypt_On_Execute markers in multi-threaded applications
Posted: Thu Oct 16, 2008 10:26 am
We have noticed that Decrypt_On_Execute marker does not work in mutli-threaded applications.
The condition when it does not work is when marker is placed in the thread and this marker is being executed my few thread simultaneously.
If you are sure that some code inside your application does not execute by few threads, you may place marker without any risk and worries!
The following code shows how occur a problem with Decrypt_On_Execute marker.
The condition when it does not work is when marker is placed in the thread and this marker is being executed my few thread simultaneously.
If you are sure that some code inside your application does not execute by few threads, you may place marker without any risk and worries!
The following code shows how occur a problem with Decrypt_On_Execute marker.
Code: Select all
// Threads call back function
UINT WINAPI Worker()
{
while (WaitForSingleObject(m_hExitEvent, 0) == WAIT_TIMEOUT) {
#include "decrypt_on_execute_begin.inc"
Sleep(rand() / 100);
#include "decrypt_on_execute_end.inc"
}
return 0;
}
// This function creates few threads that simultaneously execute same threads call back function
LRESULT OnCreate(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
{
m_hExitEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
for (UINT tid, x = 0; x < THREAD_COUNT; x++) {
m_hTreads[x] = (HANDLE) _beginthreadex(NULL, 0, _Worker, this, 0, &tid);
}
return 0;
}