Compare commits
10 Commits
Author | SHA1 | Date | |
---|---|---|---|
32a254468b
|
|||
50dbda6ccc
|
|||
3fff3b487b
|
|||
297937aeb3
|
|||
ca9a116e9b
|
|||
ca637f057b
|
|||
d366c94ac8
|
|||
ce379beeb2
|
|||
2d4dffe38f
|
|||
124ef802b3
|
59
build.sh
59
build.sh
@@ -26,14 +26,19 @@ TARGET_SYSTEM=linux
|
|||||||
|
|
||||||
# CMake Settings
|
# CMake Settings
|
||||||
CMAKEDIR="${SRCDIR}/cmake"
|
CMAKEDIR="${SRCDIR}/cmake"
|
||||||
CMAKETAG="v4.0.3"
|
CMAKETAG="v4.1.1"
|
||||||
CMAKEVCS="https://gitlab.kitware.com/cmake/cmake.git"
|
CMAKEVCS="https://gitlab.kitware.com/cmake/cmake.git"
|
||||||
|
|
||||||
# LLVM Settings
|
# LLVM Settings
|
||||||
LLVMDIR="${SRCDIR}/llvm"
|
LLVMDIR="${SRCDIR}/llvm"
|
||||||
LLVMTAG="llvmorg-20.1.8"
|
LLVMTAG="llvmorg-21.1.2"
|
||||||
LLVMVCS="https://github.com/llvm/llvm-project.git"
|
LLVMVCS="https://github.com/llvm/llvm-project.git"
|
||||||
|
|
||||||
|
# Mtools Settings
|
||||||
|
MTOOLSDIR="${SRCDIR}/mtools"
|
||||||
|
MTOOLSTAG="v4.0.49"
|
||||||
|
MTOOLSVCS="https://github.com/xt-sys/mtools.git"
|
||||||
|
|
||||||
# Ninja Settings
|
# Ninja Settings
|
||||||
NINJADIR="${SRCDIR}/ninja"
|
NINJADIR="${SRCDIR}/ninja"
|
||||||
NINJATAG="v1.13.1"
|
NINJATAG="v1.13.1"
|
||||||
@@ -41,7 +46,7 @@ NINJAVCS="https://github.com/ninja-build/ninja.git"
|
|||||||
|
|
||||||
# Wine Settings
|
# Wine Settings
|
||||||
WINEDIR="${SRCDIR}/wine"
|
WINEDIR="${SRCDIR}/wine"
|
||||||
WINETAG="wine-10.12"
|
WINETAG="wine-10.15"
|
||||||
WINEVCS="https://github.com/wine-mirror/wine.git"
|
WINEVCS="https://github.com/wine-mirror/wine.git"
|
||||||
|
|
||||||
|
|
||||||
@@ -207,6 +212,48 @@ llvm_fetch()
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# This function compiles and installs MTOOLS
|
||||||
|
mtools_build()
|
||||||
|
{
|
||||||
|
local CONFIGURE_PARAMETERS=""
|
||||||
|
local EXTENSION=""
|
||||||
|
|
||||||
|
# Clean old build if necessary
|
||||||
|
[ "${CLEAN_BUILD}" -eq 1 ] && rm -rf ${MTOOLSDIR}/build-${SYSTEM_NAME}
|
||||||
|
|
||||||
|
# Additional, target-specific configuration options
|
||||||
|
case "${SYSTEM_NAME}" in
|
||||||
|
Windows)
|
||||||
|
CONFIGURE_PARAMETERS="${CONFIGURE_PARAMETERS} --host=${SYSTEM_HOST}"
|
||||||
|
EXTENSION=".exe"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
# Build Mtools
|
||||||
|
echo ">>> Building MTOOLS ..."
|
||||||
|
mkdir -p ${MTOOLSDIR}/build-${SYSTEM_NAME}
|
||||||
|
cd ${MTOOLSDIR}/build-${SYSTEM_NAME}
|
||||||
|
../configure ${CONFIGURE_PARAMETERS}
|
||||||
|
make -j ${BUILD_JOBS}
|
||||||
|
cp mtools${EXTENSION} ${BINDIR}/bin/
|
||||||
|
for TOOL in mcat mcd mcopy mdel mdir mformat minfo mlabel mmd mmove mpartition mrd mren mshowfat mtype mzip; do
|
||||||
|
cp mtools${EXTENSION} ${BINDIR}/bin/${TOOL}${EXTENSION}
|
||||||
|
done
|
||||||
|
cd ${WRKDIR}
|
||||||
|
}
|
||||||
|
|
||||||
|
# This function downloads MTOOLS from VCS
|
||||||
|
mtools_fetch()
|
||||||
|
{
|
||||||
|
if [ ! -d ${MTOOLSDIR} ]; then
|
||||||
|
echo ">>> Downloading MTOOLS ..."
|
||||||
|
git clone --depth 1 --branch ${MTOOLSTAG} ${MTOOLSVCS} ${MTOOLSDIR}
|
||||||
|
cd ${MTOOLSDIR}
|
||||||
|
apply_patches ${MTOOLSDIR##*/} ${MTOOLSTAG}
|
||||||
|
cd ${WRKDIR}
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
# This function compiles and installs NINJA
|
# This function compiles and installs NINJA
|
||||||
ninja_build()
|
ninja_build()
|
||||||
{
|
{
|
||||||
@@ -361,7 +408,7 @@ xtchain_build()
|
|||||||
echo ">>> Building XTchain tools ..."
|
echo ">>> Building XTchain tools ..."
|
||||||
mkdir -p ${BINDIR}/bin
|
mkdir -p ${BINDIR}/bin
|
||||||
mkdir -p ${BINDIR}/lib/xtchain
|
mkdir -p ${BINDIR}/lib/xtchain
|
||||||
for EXEC in bin2c exetool xtcspecc; do
|
for EXEC in bin2c diskimg exetool xtcspecc; do
|
||||||
if [ ! -e ${BINDIR}/bin/${EXEC} ]; then
|
if [ ! -e ${BINDIR}/bin/${EXEC} ]; then
|
||||||
${CCOMPILER} ${WRKDIR}/tools/${EXEC}.c -o ${BINDIR}/bin/${EXEC}
|
${CCOMPILER} ${WRKDIR}/tools/${EXEC}.c -o ${BINDIR}/bin/${EXEC}
|
||||||
fi
|
fi
|
||||||
@@ -479,6 +526,10 @@ xtchain_build
|
|||||||
wine_fetch
|
wine_fetch
|
||||||
wine_build
|
wine_build
|
||||||
|
|
||||||
|
# Download and build GNU Mtools
|
||||||
|
mtools_fetch
|
||||||
|
mtools_build
|
||||||
|
|
||||||
if [ ${BUILD_MINIMAL} -eq 0 ]; then
|
if [ ${BUILD_MINIMAL} -eq 0 ]; then
|
||||||
# Download and build LLVM
|
# Download and build LLVM
|
||||||
llvm_fetch
|
llvm_fetch
|
||||||
|
@@ -0,0 +1,13 @@
|
|||||||
|
diff --git a/lldb/source/Host/windows/MainLoopWindows.cpp b/lldb/source/Host/windows/MainLoopWindows.cpp
|
||||||
|
index c0b10797e..e971b8cfd 100644
|
||||||
|
--- a/lldb/source/Host/windows/MainLoopWindows.cpp
|
||||||
|
+++ b/lldb/source/Host/windows/MainLoopWindows.cpp
|
||||||
|
@@ -58,7 +58,7 @@ public:
|
||||||
|
// Keep trying to cancel ReadFile() until the thread exits.
|
||||||
|
do {
|
||||||
|
CancelIoEx(m_handle, /*lpOverlapped=*/NULL);
|
||||||
|
- } while (WaitForSingleObject(m_monitor_thread.native_handle(), 1) ==
|
||||||
|
+ } while (WaitForSingleObject((HANDLE)m_monitor_thread.native_handle(), 1) ==
|
||||||
|
WAIT_TIMEOUT);
|
||||||
|
m_monitor_thread.join();
|
||||||
|
}
|
@@ -0,0 +1,13 @@
|
|||||||
|
diff --git a/lldb/source/Host/windows/MainLoopWindows.cpp b/lldb/source/Host/windows/MainLoopWindows.cpp
|
||||||
|
index c0b10797e..e971b8cfd 100644
|
||||||
|
--- a/lldb/source/Host/windows/MainLoopWindows.cpp
|
||||||
|
+++ b/lldb/source/Host/windows/MainLoopWindows.cpp
|
||||||
|
@@ -58,7 +58,7 @@ public:
|
||||||
|
// Keep trying to cancel ReadFile() until the thread exits.
|
||||||
|
do {
|
||||||
|
CancelIoEx(m_handle, /*lpOverlapped=*/NULL);
|
||||||
|
- } while (WaitForSingleObject(m_monitor_thread.native_handle(), 1) ==
|
||||||
|
+ } while (WaitForSingleObject((HANDLE)m_monitor_thread.native_handle(), 1) ==
|
||||||
|
WAIT_TIMEOUT);
|
||||||
|
m_monitor_thread.join();
|
||||||
|
}
|
@@ -5,7 +5,7 @@
|
|||||||
# DEVELOPERS: Aiken Harris <harraiken91@gmail.com>
|
# DEVELOPERS: Aiken Harris <harraiken91@gmail.com>
|
||||||
|
|
||||||
# Get the absolute path to the XTchain
|
# Get the absolute path to the XTchain
|
||||||
$XTCDIR = (Get-Item -Path ".\").FullName
|
$XTCDIR = Split-Path -Parent $MyInvocation.MyCommand.Definition
|
||||||
|
|
||||||
# Read the XTchain version
|
# Read the XTchain version
|
||||||
$env:XTCVER = Get-Content "${XTCDIR}\Version"
|
$env:XTCVER = Get-Content "${XTCDIR}\Version"
|
||||||
|
355
tools/diskimg.c
Normal file
355
tools/diskimg.c
Normal file
@@ -0,0 +1,355 @@
|
|||||||
|
/**
|
||||||
|
* PROJECT: XTchain
|
||||||
|
* LICENSE: See COPYING.md in the top level directory
|
||||||
|
* FILE: tools/diskimg.c
|
||||||
|
* DESCRIPTION: Disk Image manipulation tool
|
||||||
|
* DEVELOPERS: Rafal Kupiec <belliash@codingworkshop.eu.org>
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "xtchain.h"
|
||||||
|
|
||||||
|
|
||||||
|
/* Forward references */
|
||||||
|
static void CopyData(const char *Image, long Offset, const char *SourceDir, const char *Relative);
|
||||||
|
static void CopyImageFile(const char *Image, long Offset, const char *SourceFile, const char *Relative);
|
||||||
|
static void MakeDirectory(const char *Image, long Offset, const char *Relative);
|
||||||
|
int LoadSector(const char *FileName, uint8_t *Buffer);
|
||||||
|
|
||||||
|
|
||||||
|
/* Copies a directory recursively to the image */
|
||||||
|
static void CopyData(const char *Image, long Offset, const char *SourceDir, const char *Relative)
|
||||||
|
{
|
||||||
|
char Path[2048];
|
||||||
|
struct dirent *Entry;
|
||||||
|
DIR *Directory;
|
||||||
|
struct stat Stat;
|
||||||
|
char new_rel[2048];
|
||||||
|
|
||||||
|
/* Create the directory in the image */
|
||||||
|
if(Relative[0] != '\0')
|
||||||
|
{
|
||||||
|
MakeDirectory(Image, Offset, Relative);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Open the source directory */
|
||||||
|
Directory = opendir(SourceDir);
|
||||||
|
if(!Directory)
|
||||||
|
{
|
||||||
|
/* Failed to open directory */
|
||||||
|
perror("Failed to open source directory");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Read all entries in the directory */
|
||||||
|
while((Entry = readdir(Directory)))
|
||||||
|
{
|
||||||
|
/* Skip . and .. entries */
|
||||||
|
if(strcmp(Entry->d_name, ".") == 0 || strcmp(Entry->d_name, "..") == 0)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Build the full path to the entry */
|
||||||
|
snprintf(Path, sizeof(Path), "%s%c%s", SourceDir, PATH_SEP, Entry->d_name);
|
||||||
|
|
||||||
|
/* Stat the entry */
|
||||||
|
if(stat(Path, &Stat) == -1)
|
||||||
|
{
|
||||||
|
/* Failed to stat entry */
|
||||||
|
perror("Failed to stat file or directory");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Build the relative path to the entry */
|
||||||
|
if(Relative[0] != '\0')
|
||||||
|
{
|
||||||
|
snprintf(new_rel, sizeof(new_rel), "%s/%s", Relative, Entry->d_name);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
snprintf(new_rel, sizeof(new_rel), "%s", Entry->d_name);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Copy the entry to the image */
|
||||||
|
if(S_ISDIR(Stat.st_mode))
|
||||||
|
{
|
||||||
|
/* Entry is a directory, copy it recursively */
|
||||||
|
CopyData(Image, Offset, Path, new_rel);
|
||||||
|
}
|
||||||
|
else if(S_ISREG(Stat.st_mode))
|
||||||
|
{
|
||||||
|
/* Entry is a file, copy it */
|
||||||
|
CopyImageFile(Image, Offset, Path, new_rel);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Close the directory */
|
||||||
|
closedir(Directory);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Copies a file to the image */
|
||||||
|
static void CopyImageFile(const char *Image, long Offset, const char *SourceFile, const char *Relative)
|
||||||
|
{
|
||||||
|
char Command[4096];
|
||||||
|
|
||||||
|
/* Copy the file to the image */
|
||||||
|
snprintf(Command, sizeof(Command), "mcopy -i \"%s@@%ld\" \"%s\" \"::/%s\"", Image, Offset, SourceFile, Relative);
|
||||||
|
if(system(Command) != 0)
|
||||||
|
{
|
||||||
|
/* Failed to copy file */
|
||||||
|
fprintf(stderr, "Faile to copy file '%s' to image\n", SourceFile);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Loads a sector from a file */
|
||||||
|
int LoadSector(const char *FileName, uint8_t *Buffer)
|
||||||
|
{
|
||||||
|
FILE *File;
|
||||||
|
long Size;
|
||||||
|
|
||||||
|
/* Open the file in binary mode */
|
||||||
|
File= fopen(FileName, "rb");
|
||||||
|
if(!File)
|
||||||
|
{
|
||||||
|
/* Failed to open file */
|
||||||
|
perror("Failed to open sector file");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Check the file size */
|
||||||
|
fseek(File, 0, SEEK_END);
|
||||||
|
Size = ftell(File);
|
||||||
|
fseek(File, 0, SEEK_SET);
|
||||||
|
if(Size != SECTOR_SIZE)
|
||||||
|
{
|
||||||
|
/* File is not exactly 512 bytes */
|
||||||
|
fprintf(stderr, "Error: file '%s' must be exactly 512 bytes.\n", FileName);
|
||||||
|
fclose(File);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Read sector to buffer */
|
||||||
|
if(fread(Buffer, 1, SECTOR_SIZE, File) != SECTOR_SIZE)
|
||||||
|
{
|
||||||
|
/* Failed to read sector */
|
||||||
|
perror("Failed to read sector from file");
|
||||||
|
fclose(File);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Close the file */
|
||||||
|
fclose(File);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Creates a directory in the image */
|
||||||
|
static void MakeDirectory(const char *Image, long Offset, const char *Relative)
|
||||||
|
{
|
||||||
|
char Command[4096];
|
||||||
|
|
||||||
|
/* Create the directory in the image */
|
||||||
|
snprintf(Command, sizeof(Command), "mmd -i \"%s@@%ld\" \"::/%s\"", Image, Offset, Relative);
|
||||||
|
system(Command);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Main function */
|
||||||
|
int main(int argc, char **argv)
|
||||||
|
{
|
||||||
|
FILE *File;
|
||||||
|
long FatFormat = 32;
|
||||||
|
char FormatCommand[512];
|
||||||
|
long FormatPartition = 0;
|
||||||
|
long DiskSizeBytes = 0;
|
||||||
|
long DiskSizeMB = 0;
|
||||||
|
MBR_PARTITION Partition = {0};
|
||||||
|
char Zero[SECTOR_SIZE] = {0};
|
||||||
|
uint8_t Mbr[SECTOR_SIZE] = {0};
|
||||||
|
uint8_t Vbr[SECTOR_SIZE];
|
||||||
|
const char *FileName = NULL;
|
||||||
|
const char *MbrFile = NULL;
|
||||||
|
const char *VbrFile = NULL;
|
||||||
|
const char *CopyDir = NULL;
|
||||||
|
|
||||||
|
/* Parse command line arguments */
|
||||||
|
for(int i = 1; i < argc; i++)
|
||||||
|
{
|
||||||
|
if(strcmp(argv[i], "-c") == 0 && i + 1 < argc)
|
||||||
|
{
|
||||||
|
/* Copy directory */
|
||||||
|
CopyDir = argv[++i];
|
||||||
|
}
|
||||||
|
else if(strcmp(argv[i], "-f") == 0 && i + 1 < argc)
|
||||||
|
{
|
||||||
|
/* Format partition */
|
||||||
|
FormatPartition = 1;
|
||||||
|
FatFormat = atoi(argv[++i]);
|
||||||
|
if(FatFormat != 16 && FatFormat != 32)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "Error: FAT format (-f) must be 16 or 32\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(strcmp(argv[i], "-m") == 0 && i + 1 < argc)
|
||||||
|
{
|
||||||
|
/* MBR file */
|
||||||
|
MbrFile = argv[++i];
|
||||||
|
}
|
||||||
|
else if(strcmp(argv[i], "-o") == 0 && i + 1 < argc)
|
||||||
|
{
|
||||||
|
/* Output file */
|
||||||
|
FileName = argv[++i];
|
||||||
|
}
|
||||||
|
else if(strcmp(argv[i], "-s") == 0 && i + 1 < argc)
|
||||||
|
{
|
||||||
|
/* Disk size */
|
||||||
|
DiskSizeMB = atol(argv[++i]);
|
||||||
|
}
|
||||||
|
else if(strcmp(argv[i], "-v") == 0 && i + 1 < argc)
|
||||||
|
{
|
||||||
|
/* VBR file */
|
||||||
|
VbrFile = argv[++i];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* Unknown argument */
|
||||||
|
fprintf(stderr, "Unknown argument: %s\n", argv[i]);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Check for required arguments */
|
||||||
|
if(DiskSizeMB <= 0 || FileName == NULL)
|
||||||
|
{
|
||||||
|
/* Missing required arguments, print usage */
|
||||||
|
fprintf(stderr, "Usage: %s -o <output.img> -s <size_MB> [-c <dir>] [-f 16|32] [-m <mbr.img>] [-v <vbr.img>]\n", argv[0]);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Calculate disk size in bytes */
|
||||||
|
DiskSizeBytes = DiskSizeMB * 1024 * 1024;
|
||||||
|
|
||||||
|
/* Open the output file in binary mode */
|
||||||
|
File = fopen(FileName, "wb");
|
||||||
|
if(!File) {
|
||||||
|
/* Failed to open file */
|
||||||
|
perror("Failed to open disk image file");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Write zeros to the disk image file */
|
||||||
|
for(long i = 0; i < DiskSizeBytes / SECTOR_SIZE; i++)
|
||||||
|
{
|
||||||
|
if(fwrite(Zero, 1, SECTOR_SIZE, File) != SECTOR_SIZE)
|
||||||
|
{
|
||||||
|
/* Failed to write to disk image file */
|
||||||
|
perror("Failed to write to disk image file");
|
||||||
|
fclose(File);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Load MBR if provided */
|
||||||
|
if(MbrFile)
|
||||||
|
{
|
||||||
|
if(LoadSector(MbrFile, Mbr) != 0)
|
||||||
|
{
|
||||||
|
/* Failed to load MBR from file */
|
||||||
|
perror("Failed to load MBR from file");
|
||||||
|
fclose(File);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Setup MBR partition as W95 FAT16 or FAT32 */
|
||||||
|
Partition.BootFlag = 0x80;
|
||||||
|
Partition.Type = (FatFormat == 16) ? 0x06 : 0x0B;
|
||||||
|
Partition.StartLBA = 2048;
|
||||||
|
Partition.Size = (DiskSizeBytes / SECTOR_SIZE) - 2048;
|
||||||
|
|
||||||
|
/* Write MBR */
|
||||||
|
memcpy(&Mbr[446], &Partition, sizeof(MBR_PARTITION));
|
||||||
|
Mbr[510] = 0x55;
|
||||||
|
Mbr[511] = 0xAA;
|
||||||
|
|
||||||
|
/* Write the MBR to the beginning of the disk image */
|
||||||
|
fseek(File, 0, SEEK_SET);
|
||||||
|
if(fwrite(Mbr, 1, SECTOR_SIZE, File) != SECTOR_SIZE)
|
||||||
|
{
|
||||||
|
perror("Failed to write MBR to disk image");
|
||||||
|
fclose(File);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Check if we need to format the partition */
|
||||||
|
if(FormatPartition)
|
||||||
|
{
|
||||||
|
/* Close file before calling external formatter */
|
||||||
|
fclose(File);
|
||||||
|
|
||||||
|
/* Build mformat command */
|
||||||
|
if(FatFormat == 16)
|
||||||
|
{
|
||||||
|
/* Format partition as FAT16 */
|
||||||
|
snprintf(FormatCommand, sizeof(FormatCommand),
|
||||||
|
"mformat -i %s@@%ld",
|
||||||
|
FileName, (long)(Partition.StartLBA * SECTOR_SIZE));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* Format partition as FAT32 */
|
||||||
|
snprintf(FormatCommand, sizeof(FormatCommand),
|
||||||
|
"mformat -i %s@@%ld -F",
|
||||||
|
FileName, (long)(Partition.StartLBA * SECTOR_SIZE));
|
||||||
|
}
|
||||||
|
|
||||||
|
if(system(FormatCommand) != 0)
|
||||||
|
{
|
||||||
|
/* Failed to format partition */
|
||||||
|
perror("Failed to format partition");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Reopen disk image */
|
||||||
|
File = fopen(FileName, "r+b");
|
||||||
|
if(!File) {
|
||||||
|
/* Failed to open file */
|
||||||
|
perror("Failed to reopen disk image");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Write VBR to the start of the partition, if provided */
|
||||||
|
if(VbrFile)
|
||||||
|
{
|
||||||
|
if (LoadSector(VbrFile, Vbr) != 0) {
|
||||||
|
fclose(File);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
/* Seek to the start of the partition and write VBR */
|
||||||
|
fseek(File, Partition.StartLBA * SECTOR_SIZE, SEEK_SET);
|
||||||
|
if(fwrite(Vbr, 1, SECTOR_SIZE, File) != SECTOR_SIZE)
|
||||||
|
{
|
||||||
|
/* Failed to write VBR to disk image */
|
||||||
|
perror("Failed to write VBR to disk image");
|
||||||
|
fclose(File);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fclose(File);
|
||||||
|
|
||||||
|
/* Copy files if requested */
|
||||||
|
if(CopyDir)
|
||||||
|
{
|
||||||
|
CopyData(FileName, (long)(Partition.StartLBA * SECTOR_SIZE), CopyDir, "");
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("Successfully created disk image '%s' (%ld MB) with bootable W95 FAT-%ld partition%s%s%s.\n",
|
||||||
|
FileName,
|
||||||
|
DiskSizeMB,
|
||||||
|
FatFormat,
|
||||||
|
MbrFile ? ", MBR written" : "",
|
||||||
|
VbrFile ? ", VBR written" : "",
|
||||||
|
CopyDir ? ", files copied" : "");
|
||||||
|
return 0;
|
||||||
|
}
|
@@ -167,7 +167,7 @@ int main(int argc, char *argv[])
|
|||||||
fread(&SubSystem, sizeof(unsigned short), 1, ExeFile);
|
fread(&SubSystem, sizeof(unsigned short), 1, ExeFile);
|
||||||
|
|
||||||
/* Seek back to the SubSystem field in the optional header */
|
/* Seek back to the SubSystem field in the optional header */
|
||||||
fseek(ExeFile, -sizeof(unsigned short), SEEK_CUR);
|
fseek(ExeFile, -(long)sizeof(unsigned short), SEEK_CUR);
|
||||||
|
|
||||||
/* Write the new SubSystem value */
|
/* Write the new SubSystem value */
|
||||||
fwrite(&NewSubSystem->Identifier, sizeof(unsigned short), 1, ExeFile);
|
fwrite(&NewSubSystem->Identifier, sizeof(unsigned short), 1, ExeFile);
|
||||||
|
@@ -7,12 +7,34 @@
|
|||||||
* Rafal Kupiec <belliash@codingworkshop.eu.org>
|
* Rafal Kupiec <belliash@codingworkshop.eu.org>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <dirent.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <stdint.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
|
||||||
#define _T(x) x
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
#include <windows.h>
|
||||||
|
#define PATH_SEP '\\'
|
||||||
|
#else
|
||||||
|
#define PATH_SEP '/'
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define SECTOR_SIZE 512
|
||||||
|
#define _T(x) x
|
||||||
|
|
||||||
|
typedef struct MBR_PARTITION {
|
||||||
|
uint8_t BootFlag; // 0x80 = bootable, 0x00 = non-boot
|
||||||
|
uint8_t StartCHS [3]; // CHS address
|
||||||
|
uint8_t Type; // Partition type
|
||||||
|
uint8_t EndCHS[3]; // CHS address
|
||||||
|
uint32_t StartLBA; // Start sector
|
||||||
|
uint32_t Size; // Sectors count
|
||||||
|
} MBR_PARTITION, *PMBR_PARTITION;
|
||||||
|
|
||||||
static
|
static
|
||||||
inline
|
inline
|
||||||
@@ -52,17 +74,17 @@ split_argv(const char *argv0,
|
|||||||
char **exe_ptr)
|
char **exe_ptr)
|
||||||
{
|
{
|
||||||
const char *sep = _tcsrchrs(argv0, '/', '\\');
|
const char *sep = _tcsrchrs(argv0, '/', '\\');
|
||||||
|
const char *basename_ptr_const = argv0;
|
||||||
char *dir = strdup(_T(""));
|
char *dir = strdup(_T(""));
|
||||||
const char *basename = argv0;
|
|
||||||
|
|
||||||
if(sep)
|
if(sep)
|
||||||
{
|
{
|
||||||
dir = strdup(argv0);
|
dir = strdup(argv0);
|
||||||
dir[sep + 1 - argv0] = '\0';
|
dir[sep + 1 - argv0] = '\0';
|
||||||
basename = sep + 1;
|
basename_ptr_const = sep + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
basename = strdup(basename);
|
char *basename = strdup(basename_ptr_const);
|
||||||
char *period = strchr(basename, '.');
|
char *period = strchr(basename, '.');
|
||||||
|
|
||||||
if(period)
|
if(period)
|
||||||
@@ -72,7 +94,7 @@ split_argv(const char *argv0,
|
|||||||
|
|
||||||
char *target = strdup(basename);
|
char *target = strdup(basename);
|
||||||
char *dash = strrchr(target, '-');
|
char *dash = strrchr(target, '-');
|
||||||
const char *exe = basename;
|
char *exe = basename;
|
||||||
|
|
||||||
if(dash)
|
if(dash)
|
||||||
{
|
{
|
||||||
|
@@ -14,9 +14,8 @@
|
|||||||
|
|
||||||
#include "xtchain.h"
|
#include "xtchain.h"
|
||||||
|
|
||||||
#define XTCSPECC_VERSION "1.2"
|
|
||||||
|
|
||||||
#define ARRAYSIZE(a) (sizeof(a) / sizeof((a)[0]))
|
#define XTCSPECC_VERSION "1.2"
|
||||||
|
|
||||||
typedef struct _STRING
|
typedef struct _STRING
|
||||||
{
|
{
|
||||||
@@ -77,12 +76,12 @@ enum
|
|||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
CC_STDCALL,
|
CCONV_STDCALL,
|
||||||
CC_CDECL,
|
CCONV_CDECL,
|
||||||
CC_FASTCALL,
|
CCONV_FASTCALL,
|
||||||
CC_THISCALL,
|
CCONV_THISCALL,
|
||||||
CC_EXTERN,
|
CCONV_EXTERN,
|
||||||
CC_STUB,
|
CCONV_STUB,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum
|
enum
|
||||||
@@ -257,11 +256,11 @@ OutputLine_stub(FILE *file,
|
|||||||
int bRelay = 0;
|
int bRelay = 0;
|
||||||
int bInPrototype = 0;
|
int bInPrototype = 0;
|
||||||
|
|
||||||
if(pexp->nCallingConvention != CC_STUB &&
|
if(pexp->nCallingConvention != CCONV_STUB &&
|
||||||
(pexp->uFlags & FL_STUB) == 0)
|
(pexp->uFlags & FL_STUB) == 0)
|
||||||
{
|
{
|
||||||
/* Only relay trace stdcall C functions */
|
/* Only relay trace stdcall C functions */
|
||||||
if(!gbTracing || (pexp->nCallingConvention != CC_STDCALL) ||
|
if(!gbTracing || (pexp->nCallingConvention != CCONV_STDCALL) ||
|
||||||
(pexp->uFlags & FL_NORELAY) ||
|
(pexp->uFlags & FL_NORELAY) ||
|
||||||
(pexp->strName.buf[0] == '?'))
|
(pexp->strName.buf[0] == '?'))
|
||||||
{
|
{
|
||||||
@@ -294,7 +293,7 @@ OutputLine_stub(FILE *file,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if((giArch == ARCH_X86) &&
|
if((giArch == ARCH_X86) &&
|
||||||
pexp->nCallingConvention == CC_STDCALL)
|
pexp->nCallingConvention == CCONV_STDCALL)
|
||||||
{
|
{
|
||||||
fprintf(file, "__stdcall ");
|
fprintf(file, "__stdcall ");
|
||||||
}
|
}
|
||||||
@@ -398,7 +397,7 @@ OutputLine_stub(FILE *file,
|
|||||||
}
|
}
|
||||||
fprintf(file, ");\n");
|
fprintf(file, ");\n");
|
||||||
|
|
||||||
if(pexp->nCallingConvention == CC_STUB)
|
if(pexp->nCallingConvention == CCONV_STUB)
|
||||||
{
|
{
|
||||||
fprintf(file, "\t__wine_spec_unimplemented_stub(\"%s\", __FUNCTION__);\n", pszDllName);
|
fprintf(file, "\t__wine_spec_unimplemented_stub(\"%s\", __FUNCTION__);\n", pszDllName);
|
||||||
}
|
}
|
||||||
@@ -510,8 +509,8 @@ PrintName(FILE *fileDest,
|
|||||||
fprintf(fileDest, "%.*s", nNameLength, pcName);
|
fprintf(fileDest, "%.*s", nNameLength, pcName);
|
||||||
}
|
}
|
||||||
else if(fDeco &&
|
else if(fDeco &&
|
||||||
((pexp->nCallingConvention == CC_STDCALL) ||
|
((pexp->nCallingConvention == CCONV_STDCALL) ||
|
||||||
(pexp->nCallingConvention == CC_FASTCALL)))
|
(pexp->nCallingConvention == CCONV_FASTCALL)))
|
||||||
{
|
{
|
||||||
/* Scan for a dll forwarding dot */
|
/* Scan for a dll forwarding dot */
|
||||||
pcDot = ScanToken(pcName, '.');
|
pcDot = ScanToken(pcName, '.');
|
||||||
@@ -536,9 +535,9 @@ PrintName(FILE *fileDest,
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* Print the prefix, but skip it for stdcall */
|
/* Print the prefix, but skip it for stdcall */
|
||||||
if(pexp->nCallingConvention != CC_STDCALL)
|
if(pexp->nCallingConvention != CCONV_STDCALL)
|
||||||
{
|
{
|
||||||
fprintf(fileDest, "%c", pexp->nCallingConvention == CC_FASTCALL ? '@' : '_');
|
fprintf(fileDest, "%c", pexp->nCallingConvention == CCONV_FASTCALL ? '@' : '_');
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Print the name with trailing decoration */
|
/* Print the name with trailing decoration */
|
||||||
@@ -581,8 +580,8 @@ OutputLine_def(FILE *fileDest,
|
|||||||
/* If the original name was decorated, use decoration in the forwarder as well */
|
/* If the original name was decorated, use decoration in the forwarder as well */
|
||||||
if((giArch == ARCH_X86) && ScanToken(pexp->strName.buf, '@') &&
|
if((giArch == ARCH_X86) && ScanToken(pexp->strName.buf, '@') &&
|
||||||
!ScanToken(pexp->strTarget.buf, '@') &&
|
!ScanToken(pexp->strTarget.buf, '@') &&
|
||||||
((pexp->nCallingConvention == CC_STDCALL) ||
|
((pexp->nCallingConvention == CCONV_STDCALL) ||
|
||||||
(pexp->nCallingConvention == CC_FASTCALL)) )
|
(pexp->nCallingConvention == CCONV_FASTCALL)) )
|
||||||
{
|
{
|
||||||
PrintName(fileDest, pexp, &pexp->strTarget, 1);
|
PrintName(fileDest, pexp, &pexp->strTarget, 1);
|
||||||
}
|
}
|
||||||
@@ -593,13 +592,13 @@ OutputLine_def(FILE *fileDest,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(((pexp->uFlags & FL_STUB) || (pexp->nCallingConvention == CC_STUB)) &&
|
else if(((pexp->uFlags & FL_STUB) || (pexp->nCallingConvention == CCONV_STUB)) &&
|
||||||
(pexp->strName.buf[0] == '?'))
|
(pexp->strName.buf[0] == '?'))
|
||||||
{
|
{
|
||||||
/* C++ stubs are forwarded to C stubs */
|
/* C++ stubs are forwarded to C stubs */
|
||||||
fprintf(fileDest, "=stub_function%d", pexp->nNumber);
|
fprintf(fileDest, "=stub_function%d", pexp->nNumber);
|
||||||
}
|
}
|
||||||
else if(gbTracing && ((pexp->uFlags & FL_NORELAY) == 0) && (pexp->nCallingConvention == CC_STDCALL) &&
|
else if(gbTracing && ((pexp->uFlags & FL_NORELAY) == 0) && (pexp->nCallingConvention == CCONV_STDCALL) &&
|
||||||
(pexp->strName.buf[0] != '?'))
|
(pexp->strName.buf[0] != '?'))
|
||||||
{
|
{
|
||||||
/* Redirect it to the relay-tracing trampoline */
|
/* Redirect it to the relay-tracing trampoline */
|
||||||
@@ -616,7 +615,7 @@ OutputLine_def(FILE *fileDest,
|
|||||||
{
|
{
|
||||||
fprintf(fileDest, " PRIVATE");
|
fprintf(fileDest, " PRIVATE");
|
||||||
}
|
}
|
||||||
else if(pexp->nCallingConvention == CC_EXTERN)
|
else if(pexp->nCallingConvention == CCONV_EXTERN)
|
||||||
{
|
{
|
||||||
fprintf(fileDest, " DATA");
|
fprintf(fileDest, " DATA");
|
||||||
}
|
}
|
||||||
@@ -798,28 +797,28 @@ ParseFile(char* pcStart,
|
|||||||
/* Now we should get the type */
|
/* Now we should get the type */
|
||||||
if(CompareToken(pc, "stdcall"))
|
if(CompareToken(pc, "stdcall"))
|
||||||
{
|
{
|
||||||
exp.nCallingConvention = CC_STDCALL;
|
exp.nCallingConvention = CCONV_STDCALL;
|
||||||
}
|
}
|
||||||
else if(CompareToken(pc, "cdecl") ||
|
else if(CompareToken(pc, "cdecl") ||
|
||||||
CompareToken(pc, "varargs"))
|
CompareToken(pc, "varargs"))
|
||||||
{
|
{
|
||||||
exp.nCallingConvention = CC_CDECL;
|
exp.nCallingConvention = CCONV_CDECL;
|
||||||
}
|
}
|
||||||
else if(CompareToken(pc, "fastcall"))
|
else if(CompareToken(pc, "fastcall"))
|
||||||
{
|
{
|
||||||
exp.nCallingConvention = CC_FASTCALL;
|
exp.nCallingConvention = CCONV_FASTCALL;
|
||||||
}
|
}
|
||||||
else if(CompareToken(pc, "thiscall"))
|
else if(CompareToken(pc, "thiscall"))
|
||||||
{
|
{
|
||||||
exp.nCallingConvention = CC_THISCALL;
|
exp.nCallingConvention = CCONV_THISCALL;
|
||||||
}
|
}
|
||||||
else if(CompareToken(pc, "extern"))
|
else if(CompareToken(pc, "extern"))
|
||||||
{
|
{
|
||||||
exp.nCallingConvention = CC_EXTERN;
|
exp.nCallingConvention = CCONV_EXTERN;
|
||||||
}
|
}
|
||||||
else if(CompareToken(pc, "stub"))
|
else if(CompareToken(pc, "stub"))
|
||||||
{
|
{
|
||||||
exp.nCallingConvention = CC_STUB;
|
exp.nCallingConvention = CCONV_STUB;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -986,8 +985,8 @@ ParseFile(char* pcStart,
|
|||||||
|
|
||||||
/* Handle parameters */
|
/* Handle parameters */
|
||||||
exp.nStackBytes = 0;
|
exp.nStackBytes = 0;
|
||||||
if(exp.nCallingConvention != CC_EXTERN &&
|
if(exp.nCallingConvention != CCONV_EXTERN &&
|
||||||
exp.nCallingConvention != CC_STUB)
|
exp.nCallingConvention != CCONV_STUB)
|
||||||
{
|
{
|
||||||
/* Go to next token */
|
/* Go to next token */
|
||||||
if(!(pc = NextToken(pc)))
|
if(!(pc = NextToken(pc)))
|
||||||
@@ -1069,7 +1068,7 @@ ParseFile(char* pcStart,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Handle special stub cases */
|
/* Handle special stub cases */
|
||||||
if(exp.nCallingConvention == CC_STUB)
|
if(exp.nCallingConvention == CCONV_STUB)
|
||||||
{
|
{
|
||||||
/* Check for c++ mangled name */
|
/* Check for c++ mangled name */
|
||||||
if(pc[0] == '?')
|
if(pc[0] == '?')
|
||||||
@@ -1093,7 +1092,7 @@ ParseFile(char* pcStart,
|
|||||||
}
|
}
|
||||||
exp.nStackBytes = atoi(p + 1);
|
exp.nStackBytes = atoi(p + 1);
|
||||||
exp.nArgCount = exp.nStackBytes / 4;
|
exp.nArgCount = exp.nStackBytes / 4;
|
||||||
exp.nCallingConvention = CC_STDCALL;
|
exp.nCallingConvention = CCONV_STDCALL;
|
||||||
exp.uFlags |= FL_STUB;
|
exp.uFlags |= FL_STUB;
|
||||||
for(i = 0; i < exp.nArgCount; i++)
|
for(i = 0; i < exp.nArgCount; i++)
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user