/
githubmirror
/
x64dbg
Обзор
Документация
Войти
/
githubmirror
/
x64dbg
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
development
src/dbg/msgqueue.cpp
64 строки
2 KB
Duncan Ogilvie
Rename MESSAGE_STACK to MESSAGE_QUEUE to reflect reality
22 июл 2025, 16:07
22 июл 2025, 16:07
a1ad4c0
Код
Авторство
О чём код?
#include "msgqueue.h" // Allocate a message stack MESSAGE_QUEUE* MsgAllocQueue() { return new MESSAGE_QUEUE(); } // Free a message stack void MsgFreeQueue(MESSAGE_QUEUE* Stack) { ASSERT_NONNULL(Stack); // Update termination variable Stack->Destroy = true; // Notify each thread for(int i = 0; i < Stack->WaitingCalls + 1; i++) //TODO: found crash here on exit { MESSAGE newMessage; Stack->msgs.enqueue(newMessage); } // Delete allocated structure //delete Stack; } // Add a message to the stack bool MsgSend(MESSAGE_QUEUE* Stack, int Msg, duint Param1, duint Param2) { if(Stack->Destroy) return false; MESSAGE newMessage; newMessage.msg = Msg; newMessage.param1 = Param1; newMessage.param2 = Param2; // Asynchronous send Stack->msgs.enqueue(newMessage); return true; } // Get a message from the stack (will return false when there are no messages) bool MsgGet(MESSAGE_QUEUE* Stack, MESSAGE* Msg) { if(Stack->Destroy) return false; // Don't increment the wait count because this does not wait return Stack->msgs.try_dequeue(*Msg); } // Wait for a message on the specified stack void MsgWait(MESSAGE_QUEUE* Stack, MESSAGE* Msg) { if(Stack->Destroy) return; // Increment/decrement wait count InterlockedIncrement((volatile long*)&Stack->WaitingCalls); Stack->msgs.wait_dequeue(*Msg); InterlockedDecrement((volatile long*)&Stack->WaitingCalls); }