Merge pull request #701 from cxd4/address-truncation

[N-Rage] fixed broken FormatMemPak in 64-bit
This commit is contained in:
zilmar 2015-10-28 11:10:41 +11:00
commit 1b2568e0f2
1 changed files with 6 additions and 4 deletions

View File

@ -800,17 +800,19 @@ inline WORD CountBlocks( const unsigned char * bMemPakBinary, LPBYTE aNoteSizes
void FormatMemPak( LPBYTE aMemPak ) void FormatMemPak( LPBYTE aMemPak )
{ {
FillMemory( aMemPak, 0x100, 0xFF ); size_t iRand, n;
FillMemory(aMemPak, 0x100, 0xFF);
aMemPak[0] = 0x81; aMemPak[0] = 0x81;
// generate a valid code( i hope i can calculate it one day) // generate a valid code( i hope i can calculate it one day)
BYTE aValidCodes[] = { 0x12, 0xC5, 0x8F, 0x6F, 0xA4, 0x28, 0x5B, 0xCA }; BYTE aValidCodes[] = { 0x12, 0xC5, 0x8F, 0x6F, 0xA4, 0x28, 0x5B, 0xCA };
BYTE aCode[8]; BYTE aCode[8];
int iRand = (( (ULONG)aMemPak / 4 + (ULONG)g_strEmuInfo.hMainWindow / 4 ) % (sizeof(aValidCodes)/8) ); iRand = ((size_t)aMemPak / 4) + ((size_t)g_strEmuInfo.hMainWindow / 4);
for( int n = 0; n <8; n++ ) iRand %= sizeof(aValidCodes) / 8;
aCode[n] = aValidCodes[n+iRand]; for (n = 0; n < 8; n++)
aCode[n] = aValidCodes[n + iRand];
//---------- //----------