Fixed a few things that allow it to compile and run on Windows:

1) htonl() and htons() are declared in winsock.h on Windows and require ws2_32 to be linked in.
2) mingw does not have asprintf, so I changed the Qt GUI to use QString's sprintf() member function which should behave identically.
3) Windows Vista and 7 try to run any program with "patch" in the name with administrative privileges for backwards compatibility with legacy stuff, so I added a build step to the Qt app to embed a manifest. I also need to do the same thing with the cli app...
This commit is contained in:
doug 2011-12-05 03:35:33 +00:00
parent 5ea92a9731
commit 875de91fce
8 changed files with 32 additions and 3 deletions

5
Makefile.win Normal file
View File

@ -0,0 +1,5 @@
# Windows requires -lws2_32 for htons(), htonl(), etc.
# Use make -f Makefile.win to use this Makefile, which adds
# the required library to the LDFLAGS.
LDFLAGS += -lws2_32
include Makefile

View File

@ -9,6 +9,6 @@ cli_clean:
rm -f $(ROMPATCHER_EXE)
$(ROMPATCHER_EXE): $(ROMPATCHER_SRCS:%.c=%.o) $(ROMLIB_A)
$(CC) $(CFLAGS) -o $@ $< $(LDFLAGS) $(ROMLIB_A)
$(CC) $(CFLAGS) -o $@ $< $(ROMLIB_A) $(LDFLAGS)
cli/%o: cli/%.c

View File

@ -1,5 +1,9 @@
#include <stdlib.h>
#ifdef __MINGW32__
#include <winsock.h>
#else
#include <arpa/inet.h>
#endif
#include "macrompatcher.h"
RomErr GetChecksum(RomCtx *rom, uint32_t *checksum) {

View File

@ -1,4 +1,8 @@
#ifdef __MINGW32__
#include <winsock.h>
#else
#include <arpa/inet.h>
#endif
#include <stdio.h>
#include "macrompatcher.h"

View File

@ -100,8 +100,7 @@ void RomPatcher::updateChecksumUI()
uint32_t cksum;
char *cksumstr = NULL;
GetChecksum(rom, &cksum);
asprintf(&cksumstr, "Checksum: %#x", cksum);
checksum->setText(cksumstr);
checksum->setText(QString().sprintf("%#x", cksum));
free(cksumstr);
}

10
qtgui/RomPatcher.manifest Normal file
View File

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
<security>
<requestedPrivileges>
<requestedExecutionLevel level="asInvoker" />
</requestedPrivileges>
</security>
</trustInfo>
</assembly>

View File

@ -4,3 +4,8 @@ HEADERS = RomPatcher.h
CONFIG += qt
LIBS += ../lib/libmacrom.a
win32 {
QMAKE_PRE_LINK += "windres --input ../qtgui/RomPatcher.rc --output RomPatcher.res --output-format=coff"
LIBS += -lws2_32 RomPatcher.res
}

2
qtgui/RomPatcher.rc Normal file
View File

@ -0,0 +1,2 @@
#include "winuser.h"
1 RT_MANIFEST RomPatcher.manifest