Skip to content

Commit

Permalink
PRP with proofs. Eliminates the need for lengthy double-checking!!!
Browse files Browse the repository at this point in the history
Resource Limits dialog box to control Prime95's resource usage. See the readme.txt file for setting these options
  • Loading branch information
shafferjohn committed Sep 28, 2020
1 parent 8babf19 commit 1f07224
Show file tree
Hide file tree
Showing 245 changed files with 12,479 additions and 17,679 deletions.
3,096 changes: 3,096 additions & 0 deletions cJSON.c

Large diffs are not rendered by default.

293 changes: 293 additions & 0 deletions cJSON.h

Large diffs are not rendered by default.

579 changes: 579 additions & 0 deletions cert.c

Large diffs are not rendered by default.

192 changes: 15 additions & 177 deletions comm95b.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* Comm95b contains information used only during execution
* Comm95c contains information used during setup and execution
*
* Copyright 1995-2016 Mersenne Research, Inc. All rights reserved
* Copyright 1995-2020 Mersenne Research, Inc. All rights reserved
*
*/

Expand All @@ -17,48 +17,6 @@ int NUM_THREAD_HANDLES = 0;

/* Common routines */

/* Is this Windows 95/98 or Windows NT? */

int isWindows95 ()
{
OSVERSIONINFO info;

info.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
if (GetVersionEx (&info)) {
return (info.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS);
}
return (FALSE);
}

/* Is this Windows 2000 or a later Windows NT version? */

int isWindows2000 ()
{
OSVERSIONINFO info;

info.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
if (GetVersionEx (&info)) {
return (info.dwPlatformId == VER_PLATFORM_WIN32_NT &&
info.dwMajorVersion >= 5);
}
return (FALSE);
}

/* Is this Windows Vista or a later Windows version? */

int isWindowsVista ()
{
OSVERSIONINFO info;

info.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
if (GetVersionEx (&info)) {
return (info.dwPlatformId == VER_PLATFORM_WIN32_NT &&
info.dwMajorVersion >= 6);
}
return (FALSE);
}


/* Clear the array of active thread handles */

void clearThreadHandleArray (void)
Expand Down Expand Up @@ -135,10 +93,8 @@ void raiseAllWorkerThreadPriority (void)
/* setting affinity to run on any CPU. */

for (i = 0; i < NUM_THREAD_HANDLES; i++) {
SetThreadPriority (THREAD_HANDLES[i],
THREAD_PRIORITY_ABOVE_NORMAL);
if (! isWindows95 ())
SetThreadAffinityMask (THREAD_HANDLES[i], -1);
SetThreadPriority (THREAD_HANDLES[i], THREAD_PRIORITY_ABOVE_NORMAL);
SetThreadAffinityMask (THREAD_HANDLES[i], -1);
}
}

Expand All @@ -147,51 +103,19 @@ void raiseAllWorkerThreadPriority (void)
/* is running. This code is adapted from Microsoft's knowledge base article */
/* Q175030. */

#ifndef X86_64

/* This function uses the ToolHelp32 and PSAPI.DLL functions via */
/* explicit linking, rather than the more common implicit linking. This */
/* technique is used so that the program will be binary compatible across */
/* both Windows NT and Windows 95. (For example, implicit linking of a */
/* ToolHelp32 function would cause an EXE to fail to load and run under */
/* Windows NT.) */
#if 0 //formerly #ifndef X86_64

#include <psapi.h>
#include <tlhelp32.h>
#include <vdmdbg.h>

typedef struct {
BOOL match;
} EnumInfoStruct ;

BOOL WINAPI Enum16( DWORD dwThreadId, WORD hMod16, WORD hTask16,
PSZ pszModName, PSZ pszFileName, LPARAM lpUserDefined ) ;

void checkPauseListCallback (void)
{
OSVERSIONINFO osver;
HINSTANCE hInstLib = NULL;
HINSTANCE hInstLib2 = NULL;
BOOL bFlag;
LPDWORD lpdwPIDs = NULL;
DWORD dwSize, dwSize2, dwIndex;
char szFileName[ MAX_PATH ];

// ToolHelp Function Pointers.

HANDLE (WINAPI *lpfCreateToolhelp32Snapshot)(DWORD,DWORD);
BOOL (WINAPI *lpfProcess32First)(HANDLE,LPPROCESSENTRY32);
BOOL (WINAPI *lpfProcess32Next)(HANDLE,LPPROCESSENTRY32);

// PSAPI Function Pointers.

BOOL (WINAPI *lpfEnumProcesses)(DWORD *, DWORD, DWORD *);
BOOL (WINAPI *lpfEnumProcessModules)(HANDLE, HMODULE*, DWORD, LPDWORD);
DWORD (WINAPI *lpfGetModuleFileNameEx)(HANDLE, HMODULE, LPTSTR, DWORD);

// VDMDBG Function Pointers.

INT (WINAPI *lpfVDMEnumTaskWOWEx)(DWORD, TASKENUMPROCEX, LPARAM);

// Check to see if were running under Windows95 or Windows NT.

osver.dwOSVersionInfoSize = sizeof( osver );
Expand All @@ -201,35 +125,6 @@ void checkPauseListCallback (void)

if ( osver.dwPlatformId == VER_PLATFORM_WIN32_NT ) {

// Load library and get the procedures explicitly. We do
// this so that we don't have to worry about modules using
// this code failing to load under Windows 95, because
// it can't resolve references to the PSAPI.DLL.

hInstLib = LoadLibraryA( "PSAPI.DLL" );
if ( hInstLib == NULL ) goto ntdone;
hInstLib2 = LoadLibraryA( "VDMDBG.DLL" );
if ( hInstLib2 == NULL ) goto ntdone;

// Get procedure addresses.

lpfEnumProcesses = (BOOL(WINAPI *)(DWORD *,DWORD,DWORD*))
GetProcAddress( hInstLib, "EnumProcesses" );
lpfEnumProcessModules = (BOOL(WINAPI *)(HANDLE, HMODULE *,
DWORD, LPDWORD)) GetProcAddress( hInstLib,
"EnumProcessModules" );
lpfGetModuleFileNameEx =(DWORD (WINAPI *)(HANDLE, HMODULE,
LPTSTR, DWORD )) GetProcAddress( hInstLib,
"GetModuleFileNameExA" );
lpfVDMEnumTaskWOWEx =(INT(WINAPI *)( DWORD, TASKENUMPROCEX,
LPARAM))GetProcAddress( hInstLib2,
"VDMEnumTaskWOWEx" );
if ( lpfEnumProcesses == NULL ||
lpfEnumProcessModules == NULL ||
lpfGetModuleFileNameEx == NULL ||
lpfVDMEnumTaskWOWEx == NULL)
goto ntdone;

// Call the PSAPI function EnumProcesses to get all of the
// ProcID's currently in the system.
// NOTE: In the documentation, the third parameter of
Expand All @@ -252,8 +147,7 @@ void checkPauseListCallback (void)
lpdwPIDs = (LPDWORD)
HeapAlloc (GetProcessHeap(), 0, dwSize2);
if (lpdwPIDs == NULL) goto ntdone;
if (!lpfEnumProcesses (lpdwPIDs, dwSize2, &dwSize))
goto ntdone;
if (!EnumProcesses (lpdwPIDs, dwSize2, &dwSize)) goto ntdone;
} while (dwSize == dwSize2);

// How many ProcID's did we get?
Expand All @@ -279,18 +173,14 @@ void checkPauseListCallback (void)
// because this will be the .EXE module for which we
// will retrieve the full path name in a second.

if (!lpfEnumProcessModules (hProcess, &hMod,
sizeof (hMod), &dwSize2)) {
if (!EnumProcessModules (hProcess, &hMod, sizeof (hMod), &dwSize2)) {
CloseHandle (hProcess);
continue;
}

// Get Full pathname:

if (!lpfGetModuleFileNameEx (hProcess,
hMod,
szFileName,
sizeof (szFileName))) {
if (!GetModuleFileNameEx (hProcess, hMod, szFileName, sizeof (szFileName))) {
CloseHandle (hProcess);
continue;
}
Expand All @@ -301,60 +191,20 @@ void checkPauseListCallback (void)
// still call the enum func with the ProcID.

isInPauseList (szFileName);

// Did we just bump into an NTVDM?

if (_stricmp (szFileName+(strlen(szFileName)-9),
"NTVDM.EXE")==0) {
EnumInfoStruct sInfo;

// Enum the 16-bit stuff.

lpfVDMEnumTaskWOWEx (lpdwPIDs[dwIndex],
(TASKENUMPROCEX) Enum16,
(LPARAM) &sInfo);
}
}
ntdone: if (lpdwPIDs) HeapFree (GetProcessHeap(), 0, lpdwPIDs);
if (hInstLib) FreeLibrary (hInstLib);
if (hInstLib2) FreeLibrary (hInstLib2);
return;
}

// If Windows 95:
// If Windows 32-bit:

else if (osver.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS) {
HANDLE hSnapShot = NULL;
PROCESSENTRY32 procentry;

hInstLib = LoadLibraryA ("Kernel32.DLL");
if (hInstLib == NULL) goto done95;

// Get procedure addresses.
// We are linking to these functions of Kernel32
// explicitly, because otherwise a module using
// this code would fail to load under Windows NT,
// which does not have the Toolhelp32
// functions in the Kernel 32.

lpfCreateToolhelp32Snapshot=
(HANDLE(WINAPI *)(DWORD,DWORD))
GetProcAddress( hInstLib,
"CreateToolhelp32Snapshot" );
lpfProcess32First=
(BOOL(WINAPI *)(HANDLE,LPPROCESSENTRY32))
GetProcAddress( hInstLib, "Process32First" );
lpfProcess32Next=
(BOOL(WINAPI *)(HANDLE,LPPROCESSENTRY32))
GetProcAddress( hInstLib, "Process32Next" );
if( lpfProcess32Next == NULL ||
lpfProcess32First == NULL ||
lpfCreateToolhelp32Snapshot == NULL ) goto done95;

// Get a handle to a Toolhelp snapshot of the systems processes.

hSnapShot = lpfCreateToolhelp32Snapshot (
TH32CS_SNAPPROCESS, 0);
hSnapShot = CreateToolhelp32Snapshot (TH32CS_SNAPPROCESS, 0);
if (hSnapShot == INVALID_HANDLE_VALUE) {
hSnapShot = NULL;
goto done95;
Expand All @@ -363,7 +213,7 @@ ntdone: if (lpdwPIDs) HeapFree (GetProcessHeap(), 0, lpdwPIDs);
// Get the first process' information.

procentry.dwSize = sizeof (PROCESSENTRY32);
bFlag = lpfProcess32First (hSnapShot, &procentry);
bFlag = Process32First (hSnapShot, &procentry);

// While there are processes, keep looping.

Expand All @@ -374,13 +224,12 @@ ntdone: if (lpdwPIDs) HeapFree (GetProcessHeap(), 0, lpdwPIDs);
isInPauseList (procentry.szExeFile);

procentry.dwSize = sizeof(PROCESSENTRY32);
bFlag = lpfProcess32Next (hSnapShot, &procentry);
bFlag = Process32Next (hSnapShot, &procentry);
}

// Free the library.

done95: if (hInstLib) FreeLibrary (hInstLib);
if (hSnapShot) CloseHandle (hSnapShot);
done95: if (hSnapShot) CloseHandle (hSnapShot);
return;
}

Expand All @@ -389,15 +238,6 @@ done95: if (hInstLib) FreeLibrary (hInstLib);
return;
}


BOOL WINAPI Enum16 (DWORD dwThreadId, WORD hMod16, WORD hTask16,
PSZ pszModName, PSZ pszFileName, LPARAM lpUserDefined)
{
EnumInfoStruct *psInfo = (EnumInfoStruct *) lpUserDefined;
isInPauseList (pszFileName);
return (FALSE);
}

#else

/* The 64-bit version does not need to dynamically load DLLs. */
Expand Down Expand Up @@ -480,16 +320,14 @@ void checkPauseListCallback (void)
// because this will be the .EXE module for which we
// will retrieve the full path name in a second.

if (!EnumProcessModules (hProcess, &hMod,
sizeof (hMod), &dwSize2)) {
if (!EnumProcessModules (hProcess, &hMod, sizeof (hMod), &dwSize2)) {
CloseHandle (hProcess);
continue;
}

// Get Full pathname:

if (!GetModuleFileNameEx (hProcess, hMod, szFileName,
sizeof (szFileName))) {
if (!GetModuleFileNameEx (hProcess, hMod, szFileName, sizeof (szFileName))) {
CloseHandle (hProcess);
continue;
}
Expand Down
5 changes: 1 addition & 4 deletions comm95b.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
/* Common definitions in Prime95, Saver95, and NTPrime */
/* Common definitions in Prime95 and NTPrime */

int isWindows95 ();
int isWindows2000 ();
int isWindowsVista ();

Loading

0 comments on commit 1f07224

Please sign in to comment.