diff --git a/src/xpdev/genwrap.c b/src/xpdev/genwrap.c
index dddd7a0f71061441e2595478c06673ae61564706..0228f8a55b36ca4c2a8a0d83dcd251c2d69a13f6 100644
--- a/src/xpdev/genwrap.c
+++ b/src/xpdev/genwrap.c
@@ -478,9 +478,10 @@ double	DLLCALL	xp_timer(void)
 #else
 #ifdef _WIN32
 	LARGE_INTEGER	freq;
-	if(QueryPerformanceFrequency(&freq)) {
-		ret=QueryPerformanceCounter();
-		ret /= freq;
+	LARGE_INTEGER	tick;
+	if(QueryPerformanceFrequency(&freq) && QueryPerformanceCounter(&tick)) {
+		ret=((double)tick.HighPart*4294967296)+((double)tick.LowPart);
+		ret /= ((double)freq.HighPart*4294967296)+((double)freq.LowPart);
 	}
 	else {
 		ret=GetTickCount();