I've got a question about typecasting. The next two lines of C code, do not give any error: Code: IMAGE_DOS_HEADER * image_dos_header = (IMAGE_DOS_HEADER *) pMem; fseek(fHandle, image_dos_header->e_lfanew, SEEK_SET); And this line does give an error: Code: fseek(fHandle, (IMAGE_DOS_HEADER *)pMem->e_lfanew, SEEK_SET); The error is 'error: request for member `e_lfanew' in something not a structure or union' Hmm? I used the exact same cast as in the other line. Somebody got an idea on this one?
nvmind guys(or girls) i found it out by myself: Code: fseek(fHandle, ((IMAGE_DOS_HEADER *)pMem)->e_lfanew, SEEK_SET); only 1 line of code and it works now, i just needed to make sure the compiler evaluated the typecast after making it using these '(' ')' chars
In the second example, you're not casting pMem, you're casting pMem->e_lfanew. EDIT: Woops, you found it while I was posting.