"Andrew Talbot" Andrew.Talbot@talbotville.com wrote:
#define IMAGE_FIRST_SECTION(ntheader) \
- ((PIMAGE_SECTION_HEADER)((LPBYTE)&((PIMAGE_NT_HEADERS)(ntheader))->OptionalHeader + \
((PIMAGE_NT_HEADERS)(ntheader))->FileHeader.SizeOfOptionalHeader))
- ((PIMAGE_SECTION_HEADER)((LPBYTE)&((PIMAGE_NT_HEADERS)(UINT32)(ntheader))->OptionalHeader + \
((PIMAGE_NT_HEADERS)(UINT32)(ntheader))->FileHeader.SizeOfOptionalHeader))
UINT32 is not a 64-bit safe type. Please use ULONG_PTR instead.
Dmitry Timoshkov wrote:
UINT32 is not a 64-bit safe type. Please use ULONG_PTR instead.
Yes, I don't want to copy the way a certain other organization implemented its version. ;)
Thanks,
-- Andy.
Dmitry Timoshkov wrote:
"Andrew Talbot" Andrew.Talbot@talbotville.com wrote:
#define IMAGE_FIRST_SECTION(ntheader) \
((PIMAGE_SECTION_HEADER)((LPBYTE)&((PIMAGE_NT_HEADERS)(ntheader))->OptionalHeader
- \
((PIMAGE_NT_HEADERS)(ntheader))->FileHeader.SizeOfOptionalHeader))
((PIMAGE_SECTION_HEADER)((LPBYTE)&((PIMAGE_NT_HEADERS)(UINT32)(ntheader))->OptionalHeader
- \
((PIMAGE_NT_HEADERS)(UINT32)(ntheader))->FileHeader.SizeOfOptionalHeader))
UINT32 is not a 64-bit safe type. Please use ULONG_PTR instead.
actually, this would be better written as: ((PIMAGE_SECTION_HEADER)(DWORD_PTR)((LPCBYTE)&((const IMAGE_NT_HEADERS*)(ntheader))->OptionalHeader + \ ((const IMAGE_NT_HEADERS*)(ntheader))->FileHeader.SizeOfOptionalHeader))
Eric Pouech wrote:
actually, this would be better written as: ((PIMAGE_SECTION_HEADER)(DWORD_PTR)((LPCBYTE)&((const IMAGE_NT_HEADERS*)(ntheader))->OptionalHeader + \ ((const IMAGE_NT_HEADERS*)(ntheader))->FileHeader.SizeOfOptionalHeader))
Hi Eric,
I'm not seeing too many LPCBYTEs in the code base, but I reckon const BYTE * fits the bill. Why do you prefer DWORD_PTR over ULONG_PTR?
Thanks,
-- Andy.
Andrew Talbot wrote:
Eric Pouech wrote:
actually, this would be better written as: ((PIMAGE_SECTION_HEADER)(DWORD_PTR)((LPCBYTE)&((const IMAGE_NT_HEADERS*)(ntheader))->OptionalHeader + \ ((const IMAGE_NT_HEADERS*)(ntheader))->FileHeader.SizeOfOptionalHeader))
Hi Eric,
I'm not seeing too many LPCBYTEs in the code base, but I reckon const BYTE * fits the bill. Why do you prefer DWORD_PTR over ULONG_PTR?
nothing against ULONG_PTR, more likely, my proposal only has one ugly ULONG_PTR cast, while they were two
nothing against ULONG_PTR, more likely, my proposal only has one ugly ULONG_PTR cast, while they were two
I like your style! :)
-- Andy.