Add support for SN compilers (#4)

* More kernel32 functions implemented poorly

* fix a smattering of issues to make cc1n64 work

* fix issues breaking psyq aspsx

* Return lowercase Windows paths if uppercase path doesnt exist

* Add SetStdHandle

* Add super naive FormatMessageA

* Case insensitive file matching

* PR comments

* Adding CompareString* + SetEnvironmentVariableA functions

Co-authored-by: Ash Wolf <ninji@wuffs.org>
Co-authored-by: Simon Lindholm <simon.lindholm10@gmail.com>
This commit is contained in:
Mark Street
2022-07-03 15:27:48 +01:00
committed by GitHub
parent 5c1f8ca7c8
commit b9f6c4c64e
4 changed files with 379 additions and 28 deletions

View File

@@ -145,6 +145,7 @@ bool wibo::Executable::loadPE(FILE *file) {
// Build buffer
imageSize = header32.sizeOfImage;
imageBuffer = mmap((void *) header32.imageBase, header32.sizeOfImage, PROT_READ|PROT_WRITE|PROT_EXEC, MAP_ANONYMOUS|MAP_FIXED|MAP_PRIVATE, -1, 0);
memset(imageBuffer, 0, header32.sizeOfImage);
if (imageBuffer == MAP_FAILED) {
perror("Image mapping failed!");
imageBuffer = 0;
@@ -164,11 +165,11 @@ bool wibo::Executable::loadPE(FILE *file) {
DEBUG_LOG("Section %d: name=%s addr=%x size=%x (raw=%x) ptr=%x\n", i, name, section.virtualAddress, section.virtualSize, section.sizeOfRawData, section.pointerToRawData);
void *sectionBase = (void *) (header32.imageBase + section.virtualAddress);
if (section.sizeOfRawData > 0) {
if (section.pointerToRawData > 0 && section.sizeOfRawData > 0) {
// Grab this data
long savePos = ftell(file);
fseek(file, section.pointerToRawData, SEEK_SET);
fread(sectionBase, section.virtualSize, 1, file);
fread(sectionBase, section.sizeOfRawData, 1, file);
fseek(file, savePos, SEEK_SET);
}