1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
--- src/load_psm.cpp 2006/10/29 08:04:52 272
+++ src/load_psm.cpp 2006/12/23 22:46:28 870
@@ -85,6 +85,10 @@
BYTE samplemap[MAX_SAMPLES];
UINT nPatterns;
+ pfh->id = bswapLE32(pfh->id);
+ pfh->len = bswapLE32(pfh->len);
+ pfh->listid = bswapLE32(pfh->listid);
+
// Chunk0: "PSM ",filesize,"FILE"
if (dwMemLength < 256) return FALSE;
if (pfh->id == PSM_ID_OLD)
@@ -109,6 +113,11 @@
while (dwMemPos+8 < dwMemLength)
{
PSMCHUNK *pchunk = (PSMCHUNK *)(lpStream+dwMemPos);
+
+ pchunk->id = bswapLE32(pchunk->id);
+ pchunk->len = bswapLE32(pchunk->len);
+ pchunk->listid = bswapLE32(pchunk->listid);
+
if ((pchunk->len >= dwMemLength - 8) || (dwMemPos + pchunk->len + 8 > dwMemLength)) break;
dwMemPos += 8;
PUCHAR pdata = (PUCHAR)(lpStream+dwMemPos);
@@ -142,6 +151,13 @@
m_nSamples++;
MODINSTRUMENT *pins = &Ins[m_nSamples];
PSMSAMPLE *psmp = (PSMSAMPLE *)pdata;
+
+ psmp->smpid = bswapLE32(psmp->smpid);
+ psmp->length = bswapLE32(psmp->length);
+ psmp->loopstart = bswapLE32(psmp->loopstart);
+ psmp->loopend = bswapLE32(psmp->loopend);
+ psmp->samplerate = bswapLE32(psmp->samplerate);
+
smpnames[m_nSamples] = psmp->smpid;
memcpy(m_szNames[m_nSamples], psmp->samplename, 31);
m_szNames[m_nSamples][31] = 0;
@@ -193,6 +209,11 @@
while (dwMemPos + 8 < dwSongEnd)
{
PSMCHUNK *pchunk = (PSMCHUNK *)(lpStream+dwMemPos);
+
+ pchunk->id = bswapLE32(pchunk->id);
+ pchunk->len = bswapLE32(pchunk->len);
+ pchunk->listid = bswapLE32(pchunk->listid);
+
dwMemPos += 8;
if ((pchunk->len > dwSongEnd) || (dwMemPos + pchunk->len > dwSongEnd)) break;
PUCHAR pdata = (PUCHAR)(lpStream+dwMemPos);
@@ -251,6 +272,11 @@
for (UINT nPat=0; nPat<nPatterns; nPat++)
{
PSMPATTERN *pPsmPat = (PSMPATTERN *)(lpStream+patptrs[nPat]+8);
+
+ pPsmPat->size = bswapLE32(pPsmPat->size);
+ pPsmPat->name = bswapLE32(pPsmPat->name);
+ pPsmPat->rows = bswapLE16(pPsmPat->rows);
+
ULONG len = *(DWORD *)(lpStream+patptrs[nPat]+4) - 12;
UINT nRows = pPsmPat->rows;
if (len > pPsmPat->size) len = pPsmPat->size;
|