1
0
mirror of https://github.com/DxWnd/DxWnd.reloaded synced 2024-12-30 09:25:35 +01:00

v2_03_68_src

Former-commit-id: 1b94341b54585e75499f8634ae663d90aeac0be1
This commit is contained in:
gho tik 2016-10-05 12:45:56 -04:00 committed by Refael ACkermann
parent 3c0b19dc7b
commit 82aec03bcd
47 changed files with 779 additions and 93 deletions

View File

@ -152,7 +152,7 @@
#define NOWINPOSCHANGES 0x00000004 // suppress WM_WINDOWPOSCHANGING/CHANGED messages (RollerCoaster Tycoon...)
#define ANSIWIDE 0x00000008 // by default uses Widechar version of API intead od ANSI
#define NOBLT 0x00000010 // suppress blit to primary surface
//#define NOSYSTEMEMULATED 0x00000020 // forces suppression of DDSCAPS_SYSTEMMEMORY capability on emulated front & backbuffer surfaces
#define USELASTCORE 0x00000020 // Same as single core process affinity, but using the last availabe core instead of first one
#define DOFASTBLT 0x00000040 // use FastBlt to primary surface
#define AEROBOOST 0x00000080 // Optimize for AERO environment: does all stretching in sysmemory surfaces
#define QUARTERBLT 0x00000100 // Consider a screen update (to count or limit FPS) only blt operations bigger than a quarter of the whole primary surface
@ -221,6 +221,8 @@
#define HOOKDIRECTSOUND 0x00000008
#define HOOKSMACKW32 0x00000010
#define BLOCKPRIORITYCLASS 0x00000020 // blocks attempts to change the process priority class
#define CPUSLOWDOWN 0x00000040 // reduces CPU time dedicated to non time critical threads
#define CPUMAXUSAGE 0x00000080 // reduces CPU time to non time critical threads that consume more than the given ratio
// eighth flags DWORD dxw.dwFlags8:
@ -277,6 +279,7 @@ typedef struct TARGETMAP
short MaxScreenRes;
short SwapEffect;
short MaxDdrawInterface;
short SlowRatio;
}TARGETMAP;
typedef struct

View File

@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:f65c1e7993261840d66b4fed49ccf914a83f3a90b8e269f0cb9bff6464713c25
size 648704

View File

@ -1 +0,0 @@
*.{dll,exe} filter=lfs diff=lfs merge=lfs -text

View File

@ -1,66 +0,0 @@
[window]
posx=1089
posy=686
sizx=554
sizy=320
exepath=D:\Games\Moto Racer 2 (GOG)\
exportpath=D:\DxWnd\exports\
[target]
title0=Battlezone (1998)
path0=D:\Games\Battlezone\bzone.exe
launchpath0=
module0=
opengllib0=
notes0=
registry0=
ver0=0
coord0=0
flag0=-1608515533
flagg0=1241513984
flagh0=98320
flagi0=138412036
flagj0=4224
flagk0=0
flagl0=0
flagm0=0
tflag0=0
dflag0=0
posx0=150
posy0=150
sizx0=880
sizy0=660
maxfps0=0
initts0=0
winver0=0
maxres0=-1
swapeffect0=0
maxddinterface0=7
title1=Moto Racer 2 (GOG)
path1=D:\Games\Moto Racer 2 (GOG)\moto.exe
launchpath1=D:\Games\Moto Racer 2 (GOG)\moto.exe -noD3D
module1=
opengllib1=
notes1=
registry1=
ver1=0
coord1=0
flag1=681574450
flagg1=1207959680
flagh1=20
flagi1=138412036
flagj1=4224
flagk1=327680
flagl1=0
flagm1=0
tflag1=0
dflag1=0
posx1=50
posy1=50
sizx1=800
sizy1=600
maxfps1=0
initts1=0
winver1=0
maxres1=-1
swapeffect1=0
maxddinterface1=7

Binary file not shown.

View File

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:5851f8d55e160f90a240f655882cde9566c5edc132a20dff793d05746806f377
size 649216
oid sha256:3c7dbfc11581e871c2b2611baad8c24e7e904c1264771fbddf1ae438805b6817
size 651776

View File

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:0c4c24c7a4b18dbcbc807d2c4d9bdf0a8dab01a0462815c337b62a2ee56aec86
size 567296
oid sha256:a0ffb89088ea50da7077abb29aa298d730841a13f2a8b0e9882b088e0a8290c6
size 568320

View File

@ -0,0 +1,29 @@
[target]
title0=Microsoft Golf '98 trial (win)
path0=D:\Games\MSGolf98\MSGOLF98\GAME.EXE
launchpath0=
module0=
opengllib0=
notes0=
registry0=[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft]\n[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft Games]\n[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft Games\Golf '98]\n[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft Games\Golf '98\Version 1.0 Demo]\n"AppPath"="D:\\Games\\MSGolf98\\MSGOLF98"\n"InstallType"="1"\n"InstallPath"="D:\\Games\\MSGolf98\\MSGOLF98\\"\n"CDPath"="D:\\Games\\MSGolf98\\MSGOLF98"\n"Launched"="1"\n"PID"=""\n"Path"="D:\\Games\\MSGolf98\\MSGOLF98"\n"VersionType"="TrialVersion"\n"InstalledGroup"="1"\n"LangID"=dword:00000009\n
ver0=0
coord0=0
flag0=136314914
flagg0=-671088640
flagh0=1302
flagi0=1212547076
flagj0=4224
flagk0=67436544
flagl0=4
flagm0=0
tflag0=0
posx0=50
posy0=50
sizx0=0
sizy0=0
maxfps0=0
initts0=0
winver0=0
maxres0=-1
swapeffect0=0
maxddinterface0=7

View File

@ -0,0 +1,30 @@
[target]
title0=NHL 2002
path0=D:\Games\NHL 2002\nhl2002.exe
launchpath0=
module0=
opengllib0=
notes0=
registry0=
ver0=7
coord0=0
flag0=681574499
flagg0=1476395008
flagh0=528
flagi0=136314884
flagj0=1073746048
flagk0=327680
flagl0=0
flagm0=0
tflag0=0
dflag0=0
posx0=50
posy0=50
sizx0=800
sizy0=600
maxfps0=0
initts0=0
winver0=0
maxres0=-1
swapeffect0=0
maxddinterface0=7

View File

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:fa29fd8235aa5d5495b9c746b2136881651c5b6b20eff49fd3b8066af4b02d32
oid sha256:37885dbe85ab16b1b2cf2c3b076fabcab8e7b4449805b687e6bf407f3d16fcf2
size 54784

View File

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:56c095298d34bb02e98bacc0a6003ad912dc590311f9b83e0e855e5da5109ec2
oid sha256:1cdc266999665fbf022cd1853a03180d854014a4be9436b0b9faeaa6b8244aea
size 55808

View File

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:cdec1b4fb66b410c4d83bad4c9d12d9195bb1b1dc4dba15a11123d320bd09fc4
oid sha256:aa3872f2e46abbb3f7eba695aeee5e2b93a454be8d56f8beaf63c06921910730
size 56320

View File

@ -1106,4 +1106,8 @@ fix: force clipper now builds a clipper for the real primary surface (useful whe
v2.03.67
fix: D3D7 hooks to make NBA2002 working
fix: better virtual color depth settings to allow "Moto Racer 2" believe it is running on a fake 16bpp desktop
fix: GUI placement coordinates are not saved when terminating in minimized or maximized state
fix: GUI placement coordinates are not saved when terminating in minimized or maximized state
v2.03.68
add: options to limit the cpu usage of program threads, either inconditionally ("CPU slow down") or only for CPU consuming threads ("CPU max usage").
fix: some logging details

240
dll/cpulimit.cpp Normal file
View File

@ -0,0 +1,240 @@
#include <windows.h>
#include <tlhelp32.h>
#include <tchar.h>
#include "dxwnd.h"
#include "dxwcore.hpp"
#define MAX_THREAD_ARRAY 40
// forward declarations
BOOL SlowCpuSpeed(DWORD, DWORD, int);
BOOL LimitCpuUsage(DWORD, DWORD, int);
DWORD WINAPI CpuSlow(LPVOID lpThreadParameter)
{
int iSlowDownRatio = dxw.SlowRatio;
DWORD dwOwnerPID = GetCurrentProcessId();
DWORD dwOwnerThread = GetCurrentThreadId();
OutTrace("starting CPUSlow dwOwnerPID=%x Ratio=1:%d\n", dwOwnerPID, iSlowDownRatio);
if(!dwOwnerPID) return FALSE;
if(iSlowDownRatio < 1) return FALSE;
Sleep(100);
while(TRUE) SlowCpuSpeed(dwOwnerPID, dwOwnerThread, iSlowDownRatio);
return TRUE;
}
DWORD WINAPI CpuLimit(LPVOID lpThreadParameter)
{
int iSlowDownRatio = dxw.SlowRatio;
DWORD dwOwnerPID = GetCurrentProcessId();
DWORD dwOwnerThread = GetCurrentThreadId();
OutTrace("starting CPULimit dwOwnerPID=%x Ratio=1:%d\n", dwOwnerPID, iSlowDownRatio);
if(!dwOwnerPID) return FALSE;
if(iSlowDownRatio < 1) return FALSE;
//while(TRUE)
return LimitCpuUsage(dwOwnerPID, dwOwnerThread, iSlowDownRatio);
}
BOOL SlowCpuSpeed(DWORD dwOwnerPID, DWORD dwOwnerThread, int iSlowDownRatio)
{
HANDLE hThreadSnap = INVALID_HANDLE_VALUE;
THREADENTRY32 te32;
HANDLE SuspThreads[MAX_THREAD_ARRAY];
int iThreadIndex, iNumThreads;
// Take a snapshot of all running threads
hThreadSnap = CreateToolhelp32Snapshot( TH32CS_SNAPTHREAD, 0 );
if(hThreadSnap == INVALID_HANDLE_VALUE) {
OutTrace("LimitCpuUsage: CreateToolhelp32Snapshot ERROR err=%d\n", GetLastError());
return FALSE;
}
// Fill in the size of the structure before using it.
te32.dwSize = sizeof(THREADENTRY32);
// Retrieve information about the first thread, and exit if unsuccessful
if(!Thread32First(hThreadSnap, &te32)){
OutTrace("Thread32First ERROR: err=%d\n", GetLastError()); // Show cause of failure
CloseHandle(hThreadSnap); // Must clean up the snapshot object!
return FALSE;
}
// Now walk the thread list of the system,
// and stop each low-priority thread
iThreadIndex = 0;
do {
if((te32.th32OwnerProcessID == dwOwnerPID) && (te32.th32ThreadID != dwOwnerThread)){
if (te32.tpBasePri < THREAD_PRIORITY_TIME_CRITICAL) {
HANDLE hThread = OpenThread(THREAD_SUSPEND_RESUME, FALSE, te32.th32ThreadID);
SuspendThread(hThread);
SuspThreads[iThreadIndex++] = hThread;
}
}
} while(Thread32Next(hThreadSnap, &te32) && (iThreadIndex<MAX_THREAD_ARRAY));
iNumThreads = iThreadIndex;
// Don't forget to clean up the snapshot object.
CloseHandle(hThreadSnap);
Sleep(iSlowDownRatio);
// Now resume all suspended threads
for(iThreadIndex=0; iThreadIndex<iNumThreads; iThreadIndex++) {
ResumeThread(SuspThreads[iThreadIndex]);
CloseHandle(SuspThreads[iThreadIndex]);
}
//Sleep(Percentage);
Sleep(1);
return TRUE;
}
typedef struct{
DWORD tid;
HANDLE hThread;
//ULARGE_INTEGER LastUsed;
DWORD LastUsed;
signed long DeltaUsed;
BOOL Suspended;
} ThreadDesc_Type;
#define DELTA_TIME 2
BOOL LimitCpuUsage(DWORD dwOwnerPID, DWORD dwOwnerThread, int iSlowDownRatio)
{
HANDLE hThreadSnap = INVALID_HANDLE_VALUE;
THREADENTRY32 te32;
ThreadDesc_Type ProcessThreads[MAX_THREAD_ARRAY];
int iThreadIndex, iNumThreads;
int cycle;
FILETIME CreationTime, ExitTime, KernelTime, UserTime;
//ULARGE_INTEGER iKernelTime, iUserTime;
DWORD iKernelTime, iUserTime;
DWORD iTimeLimit = (100000 * DELTA_TIME);
DWORD iTimeSlot = (100000 * DELTA_TIME) /iSlowDownRatio;
OutTrace("LimitCpuUsage: TimeLimit=%ld TimeSlot=%ld\n", iTimeLimit, iTimeSlot);
// Fill in the size of the structure before using it.
te32.dwSize = sizeof(THREADENTRY32);
for(int i=0; i<MAX_THREAD_ARRAY; i++) {
ProcessThreads[i].LastUsed = 0;
ProcessThreads[i].DeltaUsed = 0;
ProcessThreads[i].Suspended = FALSE;
ProcessThreads[i].hThread = NULL;
ProcessThreads[i].tid = 0;
}
iNumThreads = 0;
for(cycle=0; TRUE; cycle++){
if(cycle == 0){
// Take a snapshot of all running threads
hThreadSnap = CreateToolhelp32Snapshot( TH32CS_SNAPTHREAD, 0 );
if(hThreadSnap == INVALID_HANDLE_VALUE) {
OutTrace("LimitCpuUsage: CreateToolhelp32Snapshot ERROR err=%d\n", GetLastError());
return FALSE;
}
// Retrieve information about the first thread, and exit if unsuccessful
if(!Thread32First(hThreadSnap, &te32)){
OutTrace("LimitCpuUsage: Thread32First ERROR err=%d\n", GetLastError()); // Show cause of failure
CloseHandle(hThreadSnap); // Must clean up the snapshot object!
return FALSE;
}
iThreadIndex = iNumThreads;
// Now walk the thread list of the system threads,
// and take a snapshot of each target low-priority thread
do {
if( (te32.th32OwnerProcessID == dwOwnerPID) &&
(te32.th32ThreadID != dwOwnerThread) &&
(te32.tpBasePri < THREAD_PRIORITY_TIME_CRITICAL)) {
// find threads already listed
BOOL IsListed = FALSE;
for(int j=0; j<iNumThreads; j++){
if(te32.th32ThreadID == ProcessThreads[j].tid){
IsListed = TRUE;
break;
}
}
// if not in the list, add
if(!IsListed){
HANDLE hThread = OpenThread(THREAD_SUSPEND_RESUME|THREAD_QUERY_INFORMATION, FALSE, te32.th32ThreadID);
if(!GetThreadTimes(hThread, &CreationTime, &ExitTime, &KernelTime, &UserTime)) continue;
iUserTime = UserTime.dwLowDateTime;
iKernelTime = KernelTime.dwLowDateTime;
ProcessThreads[iThreadIndex].hThread = hThread;
ProcessThreads[iThreadIndex].LastUsed = iUserTime + iKernelTime;
//OutTrace("Tid[%d]=%x init time=%d\n", iThreadIndex, hThread, ProcessThreads[iThreadIndex].LastUsed);
iThreadIndex++;
}
}
} while(Thread32Next(hThreadSnap, &te32) && (iThreadIndex<MAX_THREAD_ARRAY));
iNumThreads = iThreadIndex;
//OutTrace("Got %d threads\n", iNumThreads);
}
// Don't forget to clean up the snapshot object.
CloseHandle(hThreadSnap);
if(cycle > 100) cycle=0; // every 100 cyces forces a thread list refresh
Sleep(DELTA_TIME);
for(iThreadIndex=0; iThreadIndex<iNumThreads; iThreadIndex++) {
ThreadDesc_Type *t = &ProcessThreads[iThreadIndex];
if (t->hThread == NULL) continue; // skip terminated ones
if(!GetThreadTimes(t->hThread, &CreationTime, &ExitTime, &KernelTime, &UserTime)) {
//OutTrace("Tid[%d]=%x died at %d\n", iThreadIndex, t->hThread, __LINE__);
//CloseHandle(t->hThread);
t->hThread = NULL;
continue;
}
if (t->Suspended) {
t->DeltaUsed -= iTimeSlot;
//OutTrace("Tid[%d]=%x suspended delta=%ld\n", iThreadIndex, t->hThread, t->DeltaUsed);
if(t->DeltaUsed < 0) {
if (ResumeThread(t->hThread)== -1){
//OutTrace("Tid[%d]=%x died at %d\n", iThreadIndex, t->hThread, __LINE__);
//CloseHandle(t->hThread);
t->hThread = NULL;
continue;
}
t->Suspended = FALSE;
}
}
else {
iUserTime = UserTime.dwLowDateTime;
iKernelTime = KernelTime.dwLowDateTime;
t->DeltaUsed = t->DeltaUsed + (iUserTime + iKernelTime) - t->LastUsed;
t->LastUsed = iUserTime + iKernelTime;
//OutTrace("Tid[%d]=%x active delta=%ld\n", iThreadIndex, t->hThread, t->DeltaUsed);
if (t->DeltaUsed > (signed long)iTimeLimit) {
//OutTrace("Tid[%d]=%x stopped last=%ld\n", iThreadIndex, t->hThread, t->DeltaUsed);
if (SuspendThread(t->hThread)== -1) {
//OutTrace("Tid[%d]=%x died at %d\n", iThreadIndex, t->hThread, __LINE__);
//CloseHandle(t->hThread);
t->hThread = NULL;
continue;
}
t->Suspended = TRUE;
t->DeltaUsed -= iTimeSlot;
}
}
}
}
// should never go here ....
OutTrace("end of cycle\n");
for(int i=0; i<MAX_THREAD_ARRAY; i++) {
HANDLE hThread = ProcessThreads[i].hThread;
if(hThread){
if(ProcessThreads[i].Suspended) ResumeThread(hThread);
CloseHandle(hThread);
}
}
return TRUE;
}

View File

@ -33,6 +33,8 @@ GetWindowLong_Type pGetWindowLong;
SetWindowLong_Type pSetWindowLong;
extern LRESULT CALLBACK MessageHook(int, WPARAM, LPARAM);
extern DWORD WINAPI CpuLimit(LPVOID);
extern DWORD WINAPI CpuSlow(LPVOID);
typedef char *(*Geterrwarnmessage_Type)(unsigned long, unsigned long);
typedef int (*Preparedisasm_Type)(void);
@ -102,7 +104,7 @@ static char *Flag4Names[32]={
static char *Flag5Names[32]={
"DIABLOTWEAK", "CLEARTARGET", "NOWINPOSCHANGES", "ANSIWIDE",
"NOBLT", "**", "DOFASTBLT", "AEROBOOST",
"NOBLT", "USELASTCORE", "DOFASTBLT", "AEROBOOST",
"QUARTERBLT", "NOIMAGEHLP", "BILINEARFILTER", "REPLACEPRIVOPS",
"REMAPMCI", "TEXTUREHIGHLIGHT", "TEXTUREDUMP", "TEXTUREHACK",
"TEXTURETRANSP", "NORMALIZEPERFCOUNT", "HYBRIDMODE", "GDICOLORCONV",
@ -124,7 +126,7 @@ static char *Flag6Names[32]={
static char *Flag7Names[32]={
"LIMITDDRAW", "DISABLEDISABLEALTTAB", "FIXCLIPPERAREA", "HOOKDIRECTSOUND",
"HOOKSMACKW32", "BLOCKPRIORITYCLASS", "", "",
"HOOKSMACKW32", "BLOCKPRIORITYCLASS", "CPUSLOWDOWN", "CPUMAXUSAGE",
"", "", "", "",
"", "", "", "",
"", "", "", "",
@ -192,8 +194,8 @@ static void OutTraceHeader(FILE *fp)
for(i=0, dword=dxw.dwFlags4; i<32; i++, dword>>=1) if(dword & 0x1) fprintf(fp, "%s ", Flag4Names[i]);
for(i=0, dword=dxw.dwFlags5; i<32; i++, dword>>=1) if(dword & 0x1) fprintf(fp, "%s ", Flag5Names[i]);
for(i=0, dword=dxw.dwFlags6; i<32; i++, dword>>=1) if(dword & 0x1) fprintf(fp, "%s ", Flag6Names[i]);
for(i=0, dword=dxw.dwFlags7; i<32; i++, dword>>=1) if(dword & 0x1) fprintf(fp, "%s ", Flag6Names[i]);
for(i=0, dword=dxw.dwFlags8; i<32; i++, dword>>=1) if(dword & 0x1) fprintf(fp, "%s ", Flag6Names[i]);
for(i=0, dword=dxw.dwFlags7; i<32; i++, dword>>=1) if(dword & 0x1) fprintf(fp, "%s ", Flag7Names[i]);
for(i=0, dword=dxw.dwFlags8; i<32; i++, dword>>=1) if(dword & 0x1) fprintf(fp, "%s ", Flag8Names[i]);
for(i=0, dword=dxw.dwTFlags; i<32; i++, dword>>=1) if(dword & 0x1) fprintf(fp, "%s ", TFlagNames[i]);
fprintf(fp, "***\n");
}
@ -964,21 +966,34 @@ void DisableIME()
#endif
}
void SetSingleProcessAffinity(void)
void SetSingleProcessAffinity(BOOL first)
{
int i;
DWORD ProcessAffinityMask, SystemAffinityMask;
if(!GetProcessAffinityMask(GetCurrentProcess(), &ProcessAffinityMask, &SystemAffinityMask))
OutTraceE("GetProcessAffinityMask: ERROR err=%d\n", GetLastError());
OutTraceDW("Process affinity=%x\n", ProcessAffinityMask);
for (i=0; i<(8 * sizeof(DWORD)); i++){
if (ProcessAffinityMask & 0x1) break;
ProcessAffinityMask >>= 1;
if(first){
for (i=0; i<(8 * sizeof(DWORD)); i++){
if (ProcessAffinityMask & 0x1) break;
ProcessAffinityMask >>= 1;
}
OutTraceDW("First process affinity bit=%d\n", i);
ProcessAffinityMask = 0x1;
for (; i; i--) ProcessAffinityMask <<= 1;
OutTraceDW("Process affinity=%x\n", ProcessAffinityMask);
}
else {
for (i=0; i<(8 * sizeof(DWORD)); i++){
if (ProcessAffinityMask & 0x80000000) break;
ProcessAffinityMask <<= 1;
}
i = 31 - i;
OutTraceDW("Last process affinity bit=%d\n", i);
ProcessAffinityMask = 0x1;
for (; i; i--) ProcessAffinityMask <<= 1;
OutTraceDW("Process affinity=%x\n", ProcessAffinityMask);
}
OutTraceDW("First process affinity bit=%d\n", i);
ProcessAffinityMask &= 0x1;
for (; i; i--) ProcessAffinityMask <<= 1;
OutTraceDW("Process affinity=%x\n", ProcessAffinityMask);
if (!SetProcessAffinityMask(GetCurrentProcess(), ProcessAffinityMask))
OutTraceE("SetProcessAffinityMask: ERROR err=%d\n", GetLastError());
}
@ -1293,6 +1308,8 @@ void HookInit(TARGETMAP *target, HWND hwnd)
}
if (dxw.dwFlags4 & LIMITSCREENRES) OutTrace("HookInit: max resolution=%s\n", (dxw.MaxScreenRes<6)?Resolutions[dxw.MaxScreenRes]:"unknown");
if (dxw.dwFlags7 & LIMITDDRAW) OutTrace("HookInit: max supported IDidrectDrawInterface=%d\n", dxw.MaxDdrawInterface);
if (dxw.dwFlags7 & CPUSLOWDOWN) OutTrace("HookInit: CPU slowdown ratio 1:%d\n", dxw.SlowRatio);
if (dxw.dwFlags7 & CPUMAXUSAGE) OutTrace("HookInit: CPU maxusage ratio 1:%d\n", dxw.SlowRatio);
}
{
@ -1368,7 +1385,8 @@ void HookInit(TARGETMAP *target, HWND hwnd)
HookSysLibsInit(); // this just once...
base=GetModuleHandle(NULL);
if (dxw.dwFlags3 & SINGLEPROCAFFINITY) SetSingleProcessAffinity();
if (dxw.dwFlags3 & SINGLEPROCAFFINITY) SetSingleProcessAffinity(TRUE);
if (dxw.dwFlags5 & USELASTCORE) SetSingleProcessAffinity(FALSE);
if (dxw.dwFlags4 & INTERCEPTRDTSC) AddVectoredExceptionHandler(1, Int3Handler); // 1 = first call, 0 = call last
if (dxw.dwFlags1 & HANDLEEXCEPTIONS) HookExceptionHandler();
if (dxw.dwTFlags & OUTIMPORTTABLE) DumpImportTable(base);
@ -1438,6 +1456,13 @@ void HookInit(TARGETMAP *target, HWND hwnd)
if (dxw.dwFlags4 & ENABLETIMEFREEZE)
CreateThread(NULL, 0, TimeFreezePoller, NULL, 0, NULL);
if(dxw.dwFlags7 & CPUSLOWDOWN)
CreateThread(NULL, 0, CpuSlow, NULL, 0, NULL);
else
if(dxw.dwFlags7 & CPUMAXUSAGE)
CreateThread(NULL, 0, CpuLimit, NULL, 0, NULL);
}
LPCSTR ProcToString(LPCSTR proc)

View File

@ -133,6 +133,8 @@ void dxwCore::InitTarget(TARGETMAP *target)
iRatioX = iSizX ? iSizX : 800;
iRatioY = iSizY ? iSizY : 600;
SlowRatio = target->SlowRatio;
GDIEmulationMode = GDIMODE_NONE; // default
if (dwFlags2 & GDISTRETCHED) GDIEmulationMode = GDIMODE_STRETCHED;
if (dwFlags3 & GDIEMULATEDC) GDIEmulationMode = GDIMODE_EMULATED;

View File

@ -173,6 +173,7 @@ public: // simple data variables
short FakeVersionId;
short Coordinates;
short MaxScreenRes;
short SlowRatio;
HDC RealHDC;
HDC VirtualHDC;
int GDIEmulationMode;

Binary file not shown.

View File

@ -27,7 +27,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "TlHelp32.h"
#define VERSION "2.03.67"
#define VERSION "2.03.68"
#define DDTHREADLOCK 1
//#define LOCKTHREADS

Binary file not shown.

View File

@ -241,6 +241,10 @@
RelativePath=".\comdlg32.cpp"
>
</File>
<File
RelativePath=".\cpulimit.cpp"
>
</File>
<File
RelativePath=".\d3dtexture.cpp"
>

View File

@ -0,0 +1,29 @@
[target]
title0=Betrayal in Antara
path0=D:\Games\Betrayal in Antara\ANTARAR.EXE
launchpath0=
module0=
opengllib0=
notes0=
registry0=
ver0=0
coord0=0
flag0=681574434
flagg0=1207959552
flagh0=20
flagi0=138412036
flagj0=4224
flagk0=65536
flagl0=0
flagm0=0
tflag0=0
posx0=50
posy0=50
sizx0=800
sizy0=600
maxfps0=0
initts0=0
winver0=0
maxres0=-1
swapeffect0=0
maxddinterface0=7

View File

@ -0,0 +1,29 @@
[target]
title0=Blood 2 the Chosen
path0=D:\Games\Blood2\CLIENT.EXE
launchpath0=D:\Games\Blood2\BLOOD2.EXE
module0=
opengllib0=
notes0=
registry0=
ver0=0
coord0=0
flag0=136315042
flagg0=1207959552
flagh0=20
flagi0=138412036
flagj0=4224
flagk0=65536
flagl0=0
flagm0=0
tflag0=0
posx0=50
posy0=50
sizx0=1200
sizy0=900
maxfps0=0
initts0=0
winver0=0
maxres0=-1
swapeffect0=0
maxddinterface0=7

View File

@ -0,0 +1,29 @@
[target]
title0=Bugs Bunny Lost In Time
path0=D:\Games\Bugs.Bunny.Lost.In.Time\bin\bugs.exe
launchpath0=
module0=
opengllib0=
notes0=
registry0=
ver0=7
coord0=0
flag0=681574434
flagg0=1209139200
flagh0=20
flagi0=138412036
flagj0=4224
flagk0=98304
flagl0=0
flagm0=0
tflag0=0
posx0=50
posy0=50
sizx0=800
sizy0=600
maxfps0=0
initts0=0
winver0=0
maxres0=-1
swapeffect0=0
maxddinterface0=7

View File

@ -0,0 +1,29 @@
[target]
title0=Gooka The Mystery of Janatris
path0=D:\Games\Gooka The Mystery of Janatris\Gooka\gooka2.exe
launchpath0=
module0=
opengllib0=
notes0=
registry0=
ver0=0
coord0=0
flag0=136315394
flagg0=1207959552
flagh0=20
flagi0=138412038
flagj0=4224
flagk0=268500992
flagl0=8
flagm0=0
tflag0=0
posx0=50
posy0=50
sizx0=800
sizy0=600
maxfps0=0
initts0=0
winver0=0
maxres0=-1
swapeffect0=0
maxddinterface0=7

View File

@ -0,0 +1,29 @@
[target]
title0=Microsoft Golf '98 trial (win)
path0=D:\Games\MSGolf98\MSGOLF98\GAME.EXE
launchpath0=
module0=
opengllib0=
notes0=
registry0=[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft]\n[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft Games]\n[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft Games\Golf '98]\n[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft Games\Golf '98\Version 1.0 Demo]\n"AppPath"="D:\\Games\\MSGolf98\\MSGOLF98"\n"InstallType"="1"\n"InstallPath"="D:\\Games\\MSGolf98\\MSGOLF98\\"\n"CDPath"="D:\\Games\\MSGolf98\\MSGOLF98"\n"Launched"="1"\n"PID"=""\n"Path"="D:\\Games\\MSGolf98\\MSGOLF98"\n"VersionType"="TrialVersion"\n"InstalledGroup"="1"\n"LangID"=dword:00000009\n
ver0=0
coord0=0
flag0=136314914
flagg0=-671088640
flagh0=1302
flagi0=1212547076
flagj0=4224
flagk0=67436544
flagl0=4
flagm0=0
tflag0=0
posx0=50
posy0=50
sizx0=0
sizy0=0
maxfps0=0
initts0=0
winver0=0
maxres0=-1
swapeffect0=0
maxddinterface0=7

30
exports.new/NHL 2002.dxw Normal file
View File

@ -0,0 +1,30 @@
[target]
title0=NHL 2002
path0=D:\Games\NHL 2002\nhl2002.exe
launchpath0=
module0=
opengllib0=
notes0=
registry0=
ver0=7
coord0=0
flag0=681574499
flagg0=1476395008
flagh0=528
flagi0=136314884
flagj0=1073746048
flagk0=327680
flagl0=0
flagm0=0
tflag0=0
dflag0=0
posx0=50
posy0=50
sizx0=800
sizy0=600
maxfps0=0
initts0=0
winver0=0
maxres0=-1
swapeffect0=0
maxddinterface0=7

View File

@ -0,0 +1,35 @@
[target]
title0=No Respect (1.1)
path0=D:\Games\No Respect\nr11.exe
launchpath0=
module0=
opengllib0=
notes0=
registry0=
ver0=0
coord0=0
flag0=681574434
flagg0=1207959552
flagh0=20
flagi0=138412036
flagj0=4224
flagk0=327680
tflag0=0
initx0=0
inity0=0
minx0=0
miny0=0
maxx0=0
maxy0=0
posx0=50
posy0=50
sizx0=800
sizy0=600
maxfps0=0
initts0=0
winver0=0
maxres0=-1
swapeffect0=0
flagl0=0
flagm0=0
maxddinterface0=7

View File

@ -0,0 +1,32 @@
[target]
title0=No Respect
path0=D:\Games\No Respect\NR.EXE
launchpath0=
module0=
opengllib0=
notes0=
registry0=
ver0=0
coord0=0
flag0=136314914
flagg0=1207959552
flagh0=20
flagi0=138412036
flagj0=4224
flagk0=327680
tflag0=0
initx0=0
inity0=0
minx0=0
miny0=0
maxx0=0
maxy0=0
posx0=50
posy0=50
sizx0=800
sizy0=600
maxfps0=0
initts0=0
winver0=0
maxres0=-1
swapeffect0=0

View File

@ -0,0 +1,29 @@
[target]
title0=Phantasmagoria 2
path0=D:\Games\Phantasmagoria 2\SIERRAW.EXE
launchpath0=
module0=
opengllib0=
notes0=
registry0=
ver0=0
coord0=0
flag0=681574434
flagg0=1207959552
flagh0=20
flagi0=138412036
flagj0=4224
flagk0=65536
flagl0=0
flagm0=0
tflag0=0
posx0=50
posy0=50
sizx0=800
sizy0=600
maxfps0=0
initts0=0
winver0=0
maxres0=-1
swapeffect0=0
maxddinterface0=7

29
exports.new/Silver.dxw Normal file
View File

@ -0,0 +1,29 @@
[target]
title0=Silver
path0=D:\Games\Silver\silver.exe
launchpath0=
module0=
opengllib0=
notes0=
registry0=
ver0=0
coord0=0
flag0=136314998
flagg0=1207959552
flagh0=20
flagi0=138412036
flagj0=4224
flagk0=268500992
flagl0=0
flagm0=0
tflag0=0
posx0=50
posy0=50
sizx0=800
sizy0=600
maxfps0=0
initts0=0
winver0=0
maxres0=-1
swapeffect0=0
maxddinterface0=7

View File

@ -0,0 +1,30 @@
[target]
title0=The Hobbit(TM) Demo
path0=D:\Games\The Hobbit(TM) Demo\MeridianDemo.exe
launchpath0=
module0=
opengllib0=
notes0=
registry0=
ver0=8
coord0=0
flag0=136315426
flagg0=1207959552
flagh0=20
flagi0=138412036
flagj0=4224
flagk0=65536
flagl0=0
flagm0=0
tflag0=0
dflag0=0
posx0=50
posy0=50
sizx0=800
sizy0=600
maxfps0=0
initts0=0
winver0=0
maxres0=-1
swapeffect0=0
maxddinterface0=7

View File

@ -0,0 +1,30 @@
[target]
title0=Urban Chaos
path0=D:\Games\Urban Chaos\fallen.exe
launchpath0=
module0=
opengllib0=
notes0=
registry0=
ver0=0
coord0=0
flag0=136314914
flagg0=1207959552
flagh0=20
flagi0=138412036
flagj0=4224
flagk0=65536
flagl0=0
flagm0=0
tflag0=0
dflag0=0
posx0=50
posy0=50
sizx0=800
sizy0=600
maxfps0=0
initts0=0
winver0=0
maxres0=-1
swapeffect0=0
maxddinterface0=7

30
exports.new/Weird War.dxw Normal file
View File

@ -0,0 +1,30 @@
[target]
title0=Weird War
path0=D:\Games\Weird War\WeirdWar.exe
launchpath0=
module0=
opengllib0=
notes0=
registry0=
ver0=0
coord0=0
flag0=681574434
flagg0=1207959552
flagh0=20
flagi0=138412036
flagj0=4224
flagk0=65536
flagl0=0
flagm0=0
tflag0=0
dflag0=0
posx0=50
posy0=50
sizx0=800
sizy0=600
maxfps0=0
initts0=0
winver0=0
maxres0=-1
swapeffect0=0
maxddinterface0=7

View File

@ -30,6 +30,7 @@ void CTabCompat::DoDataExchange(CDataExchange* pDX)
DDX_Check(pDX, IDC_FAKEVERSION, cTarget->m_FakeVersion);
DDX_LBIndex(pDX, IDC_LISTFAKE, cTarget->m_FakeVersionId);
DDX_Check(pDX, IDC_SINGLEPROCAFFINITY, cTarget->m_SingleProcAffinity);
DDX_Check(pDX, IDC_USELASTCORE, cTarget->m_UseLastCore);
DDX_Check(pDX, IDC_HANDLEEXCEPTIONS, cTarget->m_HandleExceptions);
DDX_Check(pDX, IDC_LIMITRESOURCES, cTarget->m_LimitResources);
DDX_Check(pDX, IDC_SUPPRESSIME, cTarget->m_SuppressIME);

View File

@ -37,10 +37,13 @@ void CTabTiming::DoDataExchange(CDataExchange* pDX)
DDX_Check(pDX, IDC_INTERCEPTRDTSC, cTarget->m_InterceptRDTSC);
DDX_Check(pDX, IDC_STRETCHTIMERS, cTarget->m_StretchTimers);
DDX_Check(pDX, IDC_NORMALIZEPERFCOUNT, cTarget->m_NormalizePerfCount);
DDX_Check(pDX, IDC_CPUSLOWDOWN, cTarget->m_CPUSlowDown);
DDX_Check(pDX, IDC_CPUMAXUSAGE, cTarget->m_CPUMaxUsage);
DDX_Check(pDX, IDC_QUARTERBLT, cTarget->m_QuarterBlt);
DDX_Check(pDX, IDC_FINETIMING, cTarget->m_FineTiming);
DDX_Check(pDX, IDC_TIMEFREEZE, cTarget->m_EnableTimeFreeze);
DDX_Text(pDX, IDC_MAXFPS, cTarget->m_MaxFPS);
DDX_Text(pDX, IDC_SLOWRATIO, cTarget->m_SlowRatio);
DDX_LBIndex(pDX, IDC_LISTTS, cTarget->m_InitTS);
//{{AFX_DATA_MAP(CTabTiming)
// NOTE: the ClassWizard will add DDX and DDV calls here

View File

@ -23,6 +23,7 @@ CTargetDlg::CTargetDlg(CWnd* pParent /*=NULL*/)
//{{AFX_DATA_INIT(CTargetDlg)
m_DXVersion = 0;
m_MaxDdrawInterface = 6;
m_SlowRatio = 2;
m_Coordinates = 0;
m_DxEmulationMode = 3; // default: emulated
m_DxFilterMode = 0; // default: ddraw filtering
@ -88,6 +89,7 @@ CTargetDlg::CTargetDlg(CWnd* pParent /*=NULL*/)
//m_ForceRGBtoYUV = FALSE;
m_LimitScreenRes = FALSE;
m_SingleProcAffinity = FALSE;
m_UseLastCore = FALSE;
m_LimitResources = FALSE;
m_CDROMDriveType = FALSE;
m_HideCDROMEmpty = FALSE;
@ -195,6 +197,8 @@ CTargetDlg::CTargetDlg(CWnd* pParent /*=NULL*/)
m_TimeStretch = FALSE;
m_StretchTimers = FALSE;
m_NormalizePerfCount = FALSE;
m_CPUSlowDown = FALSE;
m_CPUMaxUsage = FALSE;
m_QuarterBlt = FALSE;
m_FineTiming = FALSE;
m_EnableTimeFreeze = FALSE;

View File

@ -35,6 +35,7 @@ public:
int m_TextureHandling;
int m_SonProcessMode;
int m_MaxDdrawInterface;
int m_SlowRatio;
BOOL m_HookDI;
BOOL m_HookDI8;
BOOL m_EmulateRelMouse;
@ -151,6 +152,8 @@ public:
BOOL m_TimeStretch;
BOOL m_StretchTimers;
BOOL m_NormalizePerfCount;
BOOL m_CPUSlowDown;
BOOL m_CPUMaxUsage;
BOOL m_QuarterBlt;
BOOL m_FineTiming;
BOOL m_EnableTimeFreeze;
@ -227,6 +230,7 @@ public:
BOOL m_LockSysColors;
BOOL m_LockReservedPalette;
BOOL m_SingleProcAffinity;
BOOL m_UseLastCore;
BOOL m_WireFrame;
BOOL m_NoTextures;
BOOL m_BlackWhite;

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -184,6 +184,7 @@ void SetTargetFromDlg(TARGETMAP *t, CTargetDlg *dlg)
if(dlg->m_DXVersion > 1) dlg->m_DXVersion += 5;
t->dxversion = dlg->m_DXVersion;
t->MaxDdrawInterface = dlg->m_MaxDdrawInterface+1;
t->SlowRatio = dlg->m_SlowRatio;
t->coordinates = dlg->m_Coordinates;
t->flags = 0;
t->flags2 = 0;
@ -348,6 +349,7 @@ void SetTargetFromDlg(TARGETMAP *t, CTargetDlg *dlg)
//if(dlg->m_ForceRGBtoYUV) t->flags3 |= RGB2YUV;
if(dlg->m_LimitScreenRes) t->flags4 |= LIMITSCREENRES;
if(dlg->m_SingleProcAffinity) t->flags3 |= SINGLEPROCAFFINITY;
if(dlg->m_UseLastCore) t->flags5 |= USELASTCORE;
if(dlg->m_SaveLoad) t->flags |= SAVELOAD;
if(dlg->m_SlowDown) t->flags |= SLOWDOWN;
if(dlg->m_BlitFromBackBuffer) t->flags |= BLITFROMBACKBUFFER;
@ -413,6 +415,8 @@ void SetTargetFromDlg(TARGETMAP *t, CTargetDlg *dlg)
if(dlg->m_TimeStretch) t->flags2 |= TIMESTRETCH;
if(dlg->m_StretchTimers) t->flags4 |= STRETCHTIMERS;
if(dlg->m_NormalizePerfCount) t->flags5 |= NORMALIZEPERFCOUNT;
if(dlg->m_CPUSlowDown) t->flags7 |= CPUSLOWDOWN;
if(dlg->m_CPUMaxUsage) t->flags7 |= CPUMAXUSAGE;
if(dlg->m_QuarterBlt) t->flags5 |= QUARTERBLT;
if(dlg->m_FineTiming) t->flags4 |= FINETIMING;
if(dlg->m_ReleaseMouse) t->flags4 |= RELEASEMOUSE;
@ -461,6 +465,7 @@ static void SetDlgFromTarget(TARGETMAP *t, CTargetDlg *dlg)
{
dlg->m_DXVersion = t->dxversion;
dlg->m_MaxDdrawInterface = t->MaxDdrawInterface-1;
dlg->m_SlowRatio = t->SlowRatio;
if(dlg->m_DXVersion > 6) dlg->m_DXVersion -= 5;
dlg->m_Coordinates = t->coordinates;
dlg->m_FilePath = t->path;
@ -584,6 +589,7 @@ static void SetDlgFromTarget(TARGETMAP *t, CTargetDlg *dlg)
//dlg->m_ForceYUVtoRGB = t->flags3 & YUV2RGB ? 1 : 0;
dlg->m_LimitScreenRes = t->flags4 & LIMITSCREENRES ? 1 : 0;
dlg->m_SingleProcAffinity = t->flags3 & SINGLEPROCAFFINITY ? 1 : 0;
dlg->m_UseLastCore = t->flags5 & USELASTCORE ? 1 : 0;
dlg->m_LimitResources = t->flags2 & LIMITRESOURCES ? 1 : 0;
dlg->m_CDROMDriveType = t->flags3 & CDROMDRIVETYPE ? 1 : 0;
dlg->m_HideCDROMEmpty = t->flags4 & HIDECDROMEMPTY ? 1 : 0;
@ -669,6 +675,8 @@ static void SetDlgFromTarget(TARGETMAP *t, CTargetDlg *dlg)
dlg->m_TimeStretch = t->flags2 & TIMESTRETCH ? 1 : 0;
dlg->m_StretchTimers = t->flags4 & STRETCHTIMERS ? 1 : 0;
dlg->m_NormalizePerfCount = t->flags5 & NORMALIZEPERFCOUNT ? 1 : 0;
dlg->m_CPUSlowDown = t->flags7 & CPUSLOWDOWN ? 1 : 0;
dlg->m_CPUMaxUsage = t->flags7 & CPUMAXUSAGE ? 1 : 0;
dlg->m_QuarterBlt = t->flags5 & QUARTERBLT ? 1 : 0;
dlg->m_FineTiming = t->flags4 & FINETIMING ? 1 : 0;
dlg->m_ReleaseMouse = t->flags4 & RELEASEMOUSE ? 1 : 0;
@ -802,6 +810,9 @@ static void SaveConfigItem(TARGETMAP *TargetMap, PRIVATEMAP *PrivateMap, int i,
sprintf_s(key, sizeof(key), "maxddinterface%i", i);
sprintf_s(val, sizeof(val), "%i", TargetMap->MaxDdrawInterface);
WritePrivateProfileString("target", key, val, InitPath);
sprintf_s(key, sizeof(key), "slowratio%i", i);
sprintf_s(val, sizeof(val), "%i", TargetMap->SlowRatio);
WritePrivateProfileString("target", key, val, InitPath);
free(EscBuf);
EscBuf = NULL;
@ -873,6 +884,8 @@ static void ClearTarget(int i, char *InitPath)
WritePrivateProfileString("target", key, 0, InitPath);
sprintf_s(key, sizeof(key), "maxddinterface%i", i);
WritePrivateProfileString("target", key, 0, InitPath);
sprintf_s(key, sizeof(key), "slowratio%i", i);
WritePrivateProfileString("target", key, 0, InitPath);
}
static int LoadConfigItem(TARGETMAP *TargetMap, PRIVATEMAP *PrivateMap, int i, char *InitPath)
@ -977,6 +990,9 @@ static int LoadConfigItem(TARGETMAP *TargetMap, PRIVATEMAP *PrivateMap, int i, c
// -------
sprintf_s(key, sizeof(key), "maxddinterface%i", i);
TargetMap->MaxDdrawInterface = GetPrivateProfileInt("target", key, 7, InitPath);
// -------
sprintf_s(key, sizeof(key), "slowratio%i", i);
TargetMap->SlowRatio = GetPrivateProfileInt("target", key, 1, InitPath);
if (!gbDebug){
// clear debug flags

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.