diff options
| author | SND\weimingzhi_cp <SND\weimingzhi_cp@e17a0e51-4ae3-4d35-97c3-1a29b211df97> | 2009-08-22 15:36:58 +0000 |
|---|---|---|
| committer | SND\weimingzhi_cp <SND\weimingzhi_cp@e17a0e51-4ae3-4d35-97c3-1a29b211df97> | 2009-08-22 15:36:58 +0000 |
| commit | c5f4fc1beaaa5adc6f0d49185a1461cf9899666d (patch) | |
| tree | 2ab92bded998f36c09e271519a17f9f684ecb35c /libpcsxcore/misc.c | |
| parent | c9b34c524d3fea849eef4066b8fa77497c1b2597 (diff) | |
| download | pcsxr-c5f4fc1beaaa5adc6f0d49185a1461cf9899666d.tar.gz | |
git-svn-id: https://pcsxr.svn.codeplex.com/svn/pcsxr@27238 e17a0e51-4ae3-4d35-97c3-1a29b211df97
Diffstat (limited to 'libpcsxcore/misc.c')
| -rw-r--r-- | libpcsxcore/misc.c | 34 |
1 files changed, 17 insertions, 17 deletions
diff --git a/libpcsxcore/misc.c b/libpcsxcore/misc.c index f1392299..980d2fc1 100644 --- a/libpcsxcore/misc.c +++ b/libpcsxcore/misc.c @@ -339,28 +339,28 @@ int CheckCdrom() { } static int PSXGetFileType(FILE *f) { - unsigned long current; - u32 mybuf[2048]; - EXE_HEADER *exe_hdr; - FILHDR *coff_hdr; + unsigned long current; + u8 mybuf[2048]; + EXE_HEADER *exe_hdr; + FILHDR *coff_hdr; - current = ftell(f); - fseek(f,0L,SEEK_SET); - fread(mybuf,2048,1,f); - fseek(f,current,SEEK_SET); + current = ftell(f); + fseek(f, 0L, SEEK_SET); + fread(mybuf, 2048, 1, f); + fseek(f, current, SEEK_SET); - exe_hdr = (EXE_HEADER *)mybuf; - if (memcmp(exe_hdr->id,"PS-X EXE",8)==0) - return PSX_EXE; + exe_hdr = (EXE_HEADER *)mybuf; + if (memcmp(exe_hdr->id, "PS-X EXE", 8) == 0) + return PSX_EXE; - if (mybuf[0]=='C' && mybuf[1]=='P' && mybuf[2]=='E') - return CPE_EXE; + if (mybuf[0] == 'C' && mybuf[1] == 'P' && mybuf[2] == 'E') + return CPE_EXE; - coff_hdr = (FILHDR *)mybuf; - if (coff_hdr->f_magic == 0x0162) - return COFF_EXE; + coff_hdr = (FILHDR *)mybuf; + if (SWAPu16(coff_hdr->f_magic) == 0x0162) + return COFF_EXE; - return INVALID_EXE; + return INVALID_EXE; } /* TODO Error handling - return integer for each error case below, defined in an enum. Pass variable on return */ |
