Update rres
This commit is contained in:
parent
3c5dec7f24
commit
f492eb5f2b
3 changed files with 32 additions and 21 deletions
6
rres/cgo.go
Normal file
6
rres/cgo.go
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
package rres
|
||||||
|
|
||||||
|
/*
|
||||||
|
#cgo CFLAGS: -std=gnu99 -Wno-unused-result -Wno-implicit-function-declaration -Wno-deprecated-declarations
|
||||||
|
*/
|
||||||
|
import "C"
|
|
@ -567,7 +567,7 @@ int UnpackResourceChunk(rresResourceChunk *chunk)
|
||||||
};
|
};
|
||||||
crypto_argon2_inputs inputs = {
|
crypto_argon2_inputs inputs = {
|
||||||
.pass = (const uint8_t *)rresGetCipherPassword(), // User password
|
.pass = (const uint8_t *)rresGetCipherPassword(), // User password
|
||||||
.pass_size = 16, // Password length
|
.pass_size = strlen(rresGetCipherPassword()), // Password length
|
||||||
.salt = salt, // Salt for the password
|
.salt = salt, // Salt for the password
|
||||||
.salt_size = 16
|
.salt_size = 16
|
||||||
};
|
};
|
||||||
|
@ -642,7 +642,7 @@ int UnpackResourceChunk(rresResourceChunk *chunk)
|
||||||
};
|
};
|
||||||
crypto_argon2_inputs inputs = {
|
crypto_argon2_inputs inputs = {
|
||||||
.pass = (const uint8_t *)rresGetCipherPassword(), // User password
|
.pass = (const uint8_t *)rresGetCipherPassword(), // User password
|
||||||
.pass_size = 16, // Password length
|
.pass_size = strlen(rresGetCipherPassword()), // Password length
|
||||||
.salt = salt, // Salt for the password
|
.salt = salt, // Salt for the password
|
||||||
.salt_size = 16
|
.salt_size = 16
|
||||||
};
|
};
|
||||||
|
|
13
rres/rres.h
13
rres/rres.h
|
@ -136,6 +136,8 @@
|
||||||
#ifndef RRES_H
|
#ifndef RRES_H
|
||||||
#define RRES_H
|
#define RRES_H
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
// Function specifiers in case library is build/used as a shared library (Windows)
|
// Function specifiers in case library is build/used as a shared library (Windows)
|
||||||
// NOTE: Microsoft specifiers to tell compiler that symbols are imported/exported from a .dll
|
// NOTE: Microsoft specifiers to tell compiler that symbols are imported/exported from a .dll
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
|
@ -178,6 +180,8 @@
|
||||||
#define RRES_LOG(...)
|
#define RRES_LOG(...)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// On Windows, MAX_PATH is limited to 256 by default,
|
||||||
|
// on Linux, it could go up to 4096
|
||||||
#define RRES_MAX_FILENAME_SIZE 1024
|
#define RRES_MAX_FILENAME_SIZE 1024
|
||||||
|
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
|
@ -891,7 +895,7 @@ rresCentralDir rresLoadCentralDirectory(const char *fileName)
|
||||||
|
|
||||||
RRES_LOG("RRES: CDIR: Central Directory file entries count: %i\n", dir.count);
|
RRES_LOG("RRES: CDIR: Central Directory file entries count: %i\n", dir.count);
|
||||||
|
|
||||||
unsigned char *ptr = chunkData.raw;
|
unsigned char *ptr = (unsigned char *)chunkData.raw;
|
||||||
dir.entries = (rresDirEntry *)RRES_CALLOC(dir.count, sizeof(rresDirEntry));
|
dir.entries = (rresDirEntry *)RRES_CALLOC(dir.count, sizeof(rresDirEntry));
|
||||||
|
|
||||||
for (unsigned int i = 0; i < dir.count; i++)
|
for (unsigned int i = 0; i < dir.count; i++)
|
||||||
|
@ -1054,7 +1058,7 @@ static rresResourceChunkData rresLoadResourceChunkData(rresResourceChunkInfo inf
|
||||||
rresResourceChunkData chunkData = { 0 };
|
rresResourceChunkData chunkData = { 0 };
|
||||||
|
|
||||||
// CRC32 data validation, verify packed data is not corrupted
|
// CRC32 data validation, verify packed data is not corrupted
|
||||||
unsigned int crc32 = rresComputeCRC32(data, info.packedSize);
|
unsigned int crc32 = rresComputeCRC32((unsigned char *)data, info.packedSize);
|
||||||
|
|
||||||
if ((rresGetDataType(info.type) != RRES_DATA_NULL) && (crc32 == info.crc32)) // Make sure chunk contains data and data is not corrupted
|
if ((rresGetDataType(info.type) != RRES_DATA_NULL) && (crc32 == info.crc32)) // Make sure chunk contains data and data is not corrupted
|
||||||
{
|
{
|
||||||
|
@ -1070,8 +1074,9 @@ static rresResourceChunkData rresLoadResourceChunkData(rresResourceChunkInfo inf
|
||||||
for (unsigned int i = 0; i < chunkData.propCount; i++) chunkData.props[i] = ((unsigned int *)data)[i + 1];
|
for (unsigned int i = 0; i < chunkData.propCount; i++) chunkData.props[i] = ((unsigned int *)data)[i + 1];
|
||||||
}
|
}
|
||||||
|
|
||||||
chunkData.raw = RRES_MALLOC(info.baseSize);
|
int rawSize = info.baseSize - sizeof(int) - (chunkData.propCount*sizeof(int));
|
||||||
memcpy(chunkData.raw, ((unsigned char *)data) + sizeof(int) + (chunkData.propCount*sizeof(int)), info.baseSize);
|
chunkData.raw = RRES_MALLOC(rawSize);
|
||||||
|
memcpy(chunkData.raw, ((unsigned char *)data) + sizeof(int) + (chunkData.propCount*sizeof(int)), rawSize);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue