--- threaded-port-scanner-1.3/main.c.orig	2011-03-21 16:22:38.000000000 +0100
+++ threaded-port-scanner-1.3/main.c	2023-11-05 23:34:08.561231500 +0100
@@ -20,6 +20,8 @@
 #include <string.h>
 #ifdef WIN32
 #include <windows.h>
+#include <process.h>
+#include "pathtools.h"
 #else
 #include <unistd.h>
 #include <sys/times.h>
@@ -29,11 +31,15 @@
 
 extern long int bestPortsArray[];
 
+#define BINDIR					"/mingw$$/bin"
+#define OUI_FILENAME			"/mingw$$/share/port-scanner/oui.txt"
+#define PORT_RES_FILENAME		"/mingw$$/share/port-scanner/port-numbers.txt"
+
+static char arp_path[PATH_MAX];
+
 #define SLEEP_TIME_MSEC			5
 #define MAX_PORT_STANDARD		1024
-#define ARP_TABLE_FILENAME		"./arp_table.txt"
-#define OUI_FILENAME			"./oui.txt"
-#define PORT_RES_FILENAME		"./port-numbers.txt"
+#define ARP_TABLE_FILENAME		"arp_table.txt"
 
 #define OPTIONS_ALL_PORTS		0x00000001
 #define OPTIONS_RESOLVE_PORTS	0x00000002
@@ -505,7 +511,9 @@
 void resolve_MAC(char *mac)
 {
 	int i;
-	char *p, *b = read_file(OUI_FILENAME);
+	char *oui_path = single_path_relocation(BINDIR, OUI_FILENAME);
+	char *p, *b = read_file(oui_path);
+	free(oui_path);
 	mac[8] = 0;
 	for (i = 0; i < 8; i++) if (mac[i] >= 'a' && mac[i] <= 'f') mac[i] &= 0xDF;
 	p = strstr(b, mac);
@@ -530,13 +538,13 @@
 	strcpy(ips, net_get_aip(IP));
 
 #ifdef WIN32
-	sprintf(buff, "arp -a %s > "ARP_TABLE_FILENAME, ips);
+	sprintf(buff, "arp -a %s > %s", ips, arp_path);
 #else
 	sprintf(buff, "arp -a | grep %s | awk '{ print $4 }' > "ARP_TABLE_FILENAME, ips);
 #endif
 	r = system(buff);
 
-	b = read_file(ARP_TABLE_FILENAME);
+	b = read_file(arp_path);
 #ifdef WIN32
 	p = strstr(b, ips);
 #else
@@ -564,11 +572,7 @@
 	}
 	free(b);
 
-#ifdef WIN32
-	system("erase "ARP_TABLE_FILENAME);
-#else
-	r = system("rm "ARP_TABLE_FILENAME);
-#endif
+	DeleteFile(arp_path);
 }
 
 int main(int argc, char *argv[])
@@ -583,9 +587,17 @@
 
 	parse_arguments(argc, argv);
 
+	{
+		GetTempPath(PATH_MAX, arp_path);
+		strcat(arp_path, ARP_TABLE_FILENAME);
+		_itoa(_getpid(), &arp_path[strlen(arp_path)], 10);
+	}
+
 	print_config();
 
-	if (options & OPTIONS_RESOLVE_PORTS) port_res_file = read_file(PORT_RES_FILENAME);
+	char *ports_path = single_path_relocation(BINDIR, PORT_RES_FILENAME);
+	if (options & OPTIONS_RESOLVE_PORTS) port_res_file = read_file(ports_path);
+	free(ports_path);
 	scanner();
 	if (options & OPTIONS_RESOLVE_PORTS) free(port_res_file);
 	if (options & OPTIONS_RESOLVE_MAC) print_MAC();
diff -Naur orig/Makefile threaded-port-scanner-1.3/Makefile
--- orig/Makefile	2011-03-03 15:09:51.000000000 +0100
+++ threaded-port-scanner-1.3/Makefile	2015-03-15 21:37:31.182078300 +0100
@@ -1,14 +1,17 @@
 CXX := gcc
 CXXFLAGS := -std=gnu99 -O2 -Wall -ggdb
     
-OBJECTS	:= main.o net.o
+OBJECTS	:= main.o net.o pathtools.o
     
 pscan: $(OBJECTS)
-	$(CXX) $(OBJECTS) -o pscan
+	$(CXX) $(OBJECTS) -lws2_32 -o pscan
     
-main.o: main.c
+main.o: main.c pathtools.h
 	$(CXX) $(INCLUDES) $(CXXFLAGS) -c main.c -o main.o
     
 net.o: net.c
 	$(CXX) $(CXXFLAGS) -c net.c -o net.o
 
+pathtools.o: pathtools.c pathtools.h
+	$(CXX) $(CXXFLAGS) -c pathtools.c -o pathtools.o
+
