Microsoft Compiled HTML Help File
application/vnd.ms-htmlhelp
Magic Bytes
Offset: 0
49 54 53 46
Microsoft Compiled HTML Help (CHM) is a proprietary binary file format developed by Microsoft for the delivery of structured online documentation. It serves as the primary system for software help manuals, electronic books, and integrated application assistance within the Windows operating system. Although now considered a legacy standard, CHM files support active scripting and external links, which can present potential security vulnerabilities if users execute files originating from untrusted or unknown sources.
Validation Code
How to validate .chm files in Python
Python
def is_chm(file_path: str) -> bool:
"""Check if file is a valid CHM by magic bytes."""
signature = bytes([0x49, 0x54, 0x53, 0x46])
with open(file_path, "rb") as f:
return f.read(4) == signature
How to validate .chm files in Node.js
Node.js
function isCHM(buffer: Buffer): boolean {
const signature = Buffer.from([0x49, 0x54, 0x53, 0x46]);
return buffer.subarray(0, 4).equals(signature);
}
Go
func IsCHM(data []byte) bool {
signature := []byte{0x49, 0x54, 0x53, 0x46}
if len(data) < 4 {
return false
}
return bytes.Equal(data[:4], signature)
}
API Endpoint
GET
/api/v1/chm
curl https://filesignature.org/api/v1/chm