I found this website from google and I assume that here people helps with coding problems.
I am creating a badword filter to an application, but I have ran into problems. Currently I am creating a thread from the applications entry point, and the thread flow goes like this:
while(true)
{
if (!OpenClipboard(NULL))
ExitProcess(0); //TODO: Try opening clipboard again.
h = GetClipboardData(CF_TEXT); //h is HANDLE.
std::string CB_Data = (char*)h;
if(CB_Data.size() != NULL) //An attempt to check if it's not empty
{
if ( std::regex_search(CB_Data.c_str(), BADWORD_FILTER))
{
try
{
EmptyClipboard();
SetClipboardData(CF_TEXT, INFORMATION); //INFORMATION is converted to char from HANDLE. INFORMATION = "Bad word filter detected forbidden words pattern."
}
catch(...)
{
//TODO: Error logging
}
}
else if ( std::regex_search(CB_Data.c_str(), BADWORD_FILTER2))
{
try
{
EmptyClipboard();
SetClipboardData(CF_TEXT, INFORMATION); //INFORMATION is converted to char from HANDLE. INFORMATION = "Bad word filter detected forbidden words pattern."
}
catch(...)
{
//TODO: Error logging
}
EmptyClipboard();
SetClipboardData(CF_TEXT, INFORMATION); //INFORMATION is converted to char from HANDLE. INFORMATION = "Bad word filter detected forbidden words pattern."
}
}
CloseClipboard();
Sleep(1000); //Check every 1 second for the forbidden words.
}
So this application monitors clipboard from forbidden words. However, most of the time I run into an "Expression: Invalid null pointed" -error, and I am not familiar with Visual Studio debugger. I tried, but obviously didn't success very well.
Here is the error: https://i.stack.imgur.com/wACnA.png
Any help would be greatly appreciated, thank you.