Skip to content

Commit

Permalink
DllBlock: fix compatibility with Transparent Flyout and Sogou Pinyin (#…
Browse files Browse the repository at this point in the history
…415)

* DllBlock: fix GetDllExportName when dealing with resource DLLs

* DllBlock: block Translucent Flyouts from loading
  • Loading branch information
dinhngtu authored May 24, 2024
1 parent 7e0f2ca commit 22db2f5
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions NanaZip.Shared/DllBlock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ namespace
else if (!::_stricmp(dllName, "ExplorerPatcher.IA-32.dll")) {
return true;
}
else if (!::_stricmp(dllName, "TFMain64.dll")) {
// Translucent Flyouts
return true;
}
return false;
}

Expand All @@ -53,16 +57,16 @@ namespace
if (ntHdr->Signature != IMAGE_NT_SIGNATURE || ntHdr->OptionalHeader.NumberOfRvaAndSizes < IMAGE_DIRECTORY_ENTRY_EXPORT)
return false;
const IMAGE_DATA_DIRECTORY* dirExport = &(ntHdr->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_EXPORT]);
if (dirExport->Size < sizeof(IMAGE_EXPORT_DIRECTORY) || !CheckExtents(viewSize, dirExport->VirtualAddress, sizeof(IMAGE_EXPORT_DIRECTORY))) {
if (dirExport->Size < sizeof(IMAGE_EXPORT_DIRECTORY) || !dirExport->VirtualAddress || !CheckExtents(viewSize, dirExport->VirtualAddress, sizeof(IMAGE_EXPORT_DIRECTORY))) {
return false;
}
const IMAGE_EXPORT_DIRECTORY* exports = reinterpret_cast<const IMAGE_EXPORT_DIRECTORY*>(base + dirExport->VirtualAddress);
// we don't know the export directory name size so assume that at least 256 bytes after the name are safe
if (!CheckExtents(viewSize, exports->Name, ARRAYSIZE(dllName))) {
if (!exports->Name || !CheckExtents(viewSize, exports->Name, ARRAYSIZE(dllName))) {
return false;
}
const char* name = base + exports->Name;
if (strcpy_s(dllName, name)) {
if (strncpy_s(dllName, name, _TRUNCATE)) {
return false;
}
return true;
Expand Down

0 comments on commit 22db2f5

Please sign in to comment.