int PE_(read_dos_header)(RBuffer *b, PE_(image_dos_header) *header) {
	st64 o_addr = r_buf_seek (b, 0, R_BUF_CUR);
	if (r_buf_seek (b, 0, R_BUF_SET) < 0) {
		return -1;
	}
	header->e_magic = r_buf_read_le16 (b);
	header->e_cblp = r_buf_read_le16 (b);
	header->e_cp = r_buf_read_le16 (b);
	header->e_crlc = r_buf_read_le16 (b);
	header->e_cparhdr = r_buf_read_le16 (b);
	header->e_minalloc = r_buf_read_le16 (b);
	header->e_maxalloc = r_buf_read_le16 (b);
	header->e_ss = r_buf_read_le16 (b);
	header->e_sp = r_buf_read_le16 (b);
	header->e_csum = r_buf_read_le16 (b);
	header->e_ip = r_buf_read_le16 (b);
	header->e_cs = r_buf_read_le16 (b);
	header->e_lfarlc = r_buf_read_le16 (b);
	header->e_ovno = r_buf_read_le16 (b);
	int i;
	for (i = 0; i < 4; i++) {
		header->e_res[i] = r_buf_read_le16 (b);
	}
	header->e_oemid = r_buf_read_le16 (b);
	header->e_oeminfo = r_buf_read_le16 (b);
	for (i = 0; i < 10; i++) {
		header->e_res2[i] = r_buf_read_le16 (b);
	}
	header->e_lfanew = r_buf_read_le32 (b);
	if (r_buf_seek (b, o_addr, R_BUF_SET) < 0) {
		return -1;
	}
	return sizeof (PE_(image_dos_header));
}
int PE_(read_dos_header)(RBuffer *b, PE_(image_dos_header) *header) {
	st64 o_addr = r_buf_seek (b, 0, R_BUF_CUR);
	if (r_buf_seek (b, 0, R_BUF_SET) < 0) {
		return -1;
	}
	header->e_magic = r_buf_read_le16 (b);
	header->e_cblp = r_buf_read_le16 (b);
	header->e_cp = r_buf_read_le16 (b);
	header->e_crlc = r_buf_read_le16 (b);
	header->e_cparhdr = r_buf_read_le16 (b);
	header->e_minalloc = r_buf_read_le16 (b);
	header->e_maxalloc = r_buf_read_le16 (b);
	header->e_ss = r_buf_read_le16 (b);
	header->e_sp = r_buf_read_le16 (b);
	header->e_csum = r_buf_read_le16 (b);
	header->e_ip = r_buf_read_le16 (b);
	header->e_cs = r_buf_read_le16 (b);
	header->e_lfarlc = r_buf_read_le16 (b);
	header->e_ovno = r_buf_read_le16 (b);
	int i;
	for (i = 0; i < 4; i++) {
		header->e_res[i] = r_buf_read_le16 (b);
	}
	header->e_oemid = r_buf_read_le16 (b);
	header->e_oeminfo = r_buf_read_le16 (b);
	for (i = 0; i < 10; i++) {
		header->e_res2[i] = r_buf_read_le16 (b);
	}
	header->e_lfanew = r_buf_read_le32 (b);
	if (r_buf_seek (b, o_addr, R_BUF_SET) < 0) {
		return -1;
	}
	return sizeof (PE_(image_dos_header));
}