-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathblackList.c
37 lines (34 loc) · 1.01 KB
/
blackList.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include "stdafx.h"
#include "blackList.h"
#include <shlwapi.h>
WCHAR* wBlackList = NULL;
WCHAR* LoadBlackList() {
if(wBlackList)
free(wBlackList);
HANDLE hFile = CreateFile(BlackListFile, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, 0);
if(hFile == INVALID_HANDLE_VALUE) {
return NULL;
}
LARGE_INTEGER sz;
if(!GetFileSizeEx(hFile, &sz) || sz.HighPart != 0) {
//ErrorReport(L"processing black list");
MessageBox(NULL, L"Black list ignored", NULL, MB_OK);
CloseHandle(hFile);
return wBlackList = NULL;
}
if(sz.LowPart & 1) {
MessageBox(NULL, L"Black list is not unicode", NULL, MB_OK);
CloseHandle(hFile);
return wBlackList = NULL;
}
char* bList = malloc(sz.LowPart+2);
DWORD read;
ReadFile(hFile, bList, sz.LowPart, &read, NULL);
WCHAR* wList = (LPWSTR)bList;
wList[sz.LowPart] = '\0';
CloseHandle(hFile);
return wBlackList = wList;
}
BOOL InBlackList(WCHAR* message) {
return wBlackList && wBlackList[3] != '\0' && StrStr(wBlackList, message) != NULL;
}