#define Remote #include once "windows.bi" #include once "crt.bi" #include once "fbgfx.bi" #include once "vbcompat.bi" #include once "Modules\InputBox.bas" #Include once "win\mmsystem.bi" dim shared as integer POTS(255) dim shared as ubyte POTPOS dim shared as integer ptr PPOTS dim shared as any ptr CMPROC dim shared as hwnd CMDWND dim shared as handle HTHREAD dim shared as integer DETOURED,ISMAIN ' ***** For Debug ONLY ***** #define NewLine chr$(13,10)+" >> " #ifdef CtlMyDebug #include once "includes\debug.inc" #include once "MyTDT\console.bas" dim shared as string ctlDebugFile scope CtlDebugFile = date+"_"+time for CNT as integer = 0 to len(CtlDebugFile)-1 if CtlDebugFile[CNT] < asc("0") or CtlDebugFile[CNT] > asc("9") then CtlDebugFile[CNT] = asc("_") end if next CNT CtlDebugFile = "ctlDebug_"+CtlDebugFile+".txt" end scope #endif #macro cCout(what) #ifdef CtlMyDebug scope if DETOURED then MutexLock(COUTMUTEX) sStrBuff += time$ & ": " & WHAT & chr$(13,10) if CONWND then Console.Print(sStrBuff) 'printf("%s",LINETOOUT) #ifdef CtlOutputDebug dim as any ptr COUTFILE = CreateFile(CtlDebugFile,GENERIC_READ or GENERIC_WRITE, _ FILE_SHARE_READ or FILE_SHARE_WRITE,null,OPEN_ALWAYS,null,null) SetFilePointer(COUTFILE,0,null,FILE_END) dim as integer TMPWRITE if DETOURED then WriteFile_ORG(COUTFILE,strptr(sStrBuff),len(sStrBuff),@TMPWRITE,null) else WriteFile(COUTFILE,strptr(sStrBuff),len(sStrBuff),@TMPWRITE,null) end if CloseHandle(COUTFILE) if DETOURED then MutexUnlock(COUTMUTEX) #endif sStrBuff = "" end if end scope #endif #endmacro #macro cCout1(what) #ifdef CtlMyDebug 'puts time$ & ": " & WHAT '& chr$(13,10) if CONWND then Console.Print(time$ & ": " & WHAT & chr$(13,10)) end if #endif #endmacro #macro cCout2(what) #ifdef CtlMyDebug scope #ifdef CtlOutputDebug open CtlDebugFile for append as #80 print #80,time$ & ": " & WHAT close #80 #endif end scope #endif #endmacro declare Sub Remote_Start(ORGTHREAD as integer) ' ************************************************************** ' ************************************************************** ' ************************************************************** 'SetProcessAffinityMask(GetCurrentProcess,1) CreatePreDetours() ThreadCreate(cast(any ptr,@Remote_Start),cast(any ptr,GetCurrentThreadID)) sleepex 250,1 dim shared as ubyte SSZ(&hA1DB60) #if 0 sub MemoryCheck(ID as any ptr) dim as ubyte MYBYTE dim as ubyte ptr OFFS = cast(any ptr,&h00400000 + &h57000) SetThreadPriority(GetCurrentThread,THREAD_PRIORITY_LOWEST) do sleepex 1000,1 Cout("Address: 0x0045DD67 = " & _ *cptr(ubyte ptr,&h0045DD67) & " / " & hex$(GetModuleHandle(null))) loop #if 0 do sleepex 1,1 for CNT as integer = 0 to ubound(SSZ)-1 MYBYTE = OFFS[CNT] if MYBYTE = 64 then SSZ(CNT)=64 elseif SSZ(CNT) then if MYBYTE >0 andalso SSZ(CNT)<>MYBYTE then SSZ(CNT) = 0 Cout("Address: 0x"+hexptr(OFFS+CNT)+" = " & MYBYTE) end if end if next CNT loop #endif end sub #endif Sub Remote_Start(ORGTHREAD as integer) export SetThreadPriority(GetCurrentThread,THREAD_PRIORITY_TIME_CRITICAL) 'messagebox(null,"Starting...","Starting...",MB_SYSTEMMODAL) 'THREADID = GetCurrentThreadId() 'MAINMODULE = GetModuleHandle(null) 'GetModuleHandleEx(4,cast(any ptr,@Remote_Start),@APPMODULE) chdir(exepath) HTHREAD = OpenThread(THREAD_ALL_ACCESS,false,ORGTHREAD) 'messagebox(null,"Starting...","Starting...",MB_SYSTEMMODAL) 'sleepex 1,1 'SuspendThread(HTHREAD) #ifdef CtlMyDebug ISMAIN = 1 'FindWindow("MF-SDG R4",null)<>0 CONWND = Console.Create(80,25) Console.Option(co.ControlBreakOff) Console.Option(co.CloseButtonTerminate) Console.Option(co.EndWithConsoleOn) Console.Title("Debug console") if ISMAIN then SetWindowPos(CONWND,0,16,0,0,0,SWP_NOSIZE or SWP_NOZORDER) else SetWindowPos(CONWND,0,16,500,0,0,SWP_NOSIZE or SWP_NOZORDER) end if 'ShowWindow(CONWND,SW_HIDE) #ifdef CtlOutputDebug open ctlDebugFile for output as #80:close #80 #endif #endif #ifdef CtlDebugMessages ccout("----------------- "+date$+" Starting -----------------") #endif #ifdef CtlDebugDetourCreation ccout("Creating Detours...") #endif CreateDetours() #ifdef CtlDebugMessages ccout("Resuming...") #endif 'StartExceptions() 'ResumeThread(HTHREAD) SetThreadPriority(GetCurrentThread,THREAD_PRIORITY_HIGHEST) timeBeginPeriod(0) #ifdef EnableNetPlay hStart() #endif #ifdef MemoryCheck ThreadCreate(@MemoryCheck,null) #endif 'messagebox(null,"Press To Quit","Rally",MB_OK) 'SetProcessAffinityMask(GetCurrentProcess,65535) end sub