mirror of
https://github.com/jpluimers/macrompatcher.git
synced 2024-06-04 23:29:32 +00:00
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:
parent
5ea92a9731
commit
875de91fce
5
Makefile.win
Normal file
5
Makefile.win
Normal 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
|
|
@ -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
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -1,4 +1,8 @@
|
|||
#ifdef __MINGW32__
|
||||
#include <winsock.h>
|
||||
#else
|
||||
#include <arpa/inet.h>
|
||||
#endif
|
||||
#include <stdio.h>
|
||||
#include "macrompatcher.h"
|
||||
|
||||
|
|
|
@ -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
10
qtgui/RomPatcher.manifest
Normal 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>
|
|
@ -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
2
qtgui/RomPatcher.rc
Normal file
|
@ -0,0 +1,2 @@
|
|||
#include "winuser.h"
|
||||
1 RT_MANIFEST RomPatcher.manifest
|
Loading…
Reference in New Issue
Block a user