diff --git a/Cheat Engine/CEFuncProc.pas b/Cheat Engine/CEFuncProc.pas index 53c3aff9..e992e213 100644 --- a/Cheat Engine/CEFuncProc.pas +++ b/Cheat Engine/CEFuncProc.pas @@ -1101,6 +1101,10 @@ begin try getprocaddressptr:=pointer(symhandler.getAddressFromName('Kernel32!GetProcAddress',true)); except +{$ifdef cpu64} + if not processhandler.is64Bit then + raise exception.create('Dll injection failed: symbol lookup error'); +{$endif} GetProcAddressPtr:=GetProcAddress(h,'GetProcAddress'); end; @@ -1110,6 +1114,10 @@ begin LoadLibraryPtr:=pointer(symhandler.getAddressFromName('Kernel32!LoadLibraryA',true)); except //failed getting the address of LoadLibraryA, use old method + {$ifdef cpu64} + if not processhandler.is64Bit then + raise exception.create('Dll injection failed: symbol lookup error'); + {$endif} LoadLibraryPtr:=GetProcAddress(h,'LoadLibraryA'); end; diff --git a/Cheat Engine/LuaHandler.pas b/Cheat Engine/LuaHandler.pas index 9ce15285..49878ee7 100644 --- a/Cheat Engine/LuaHandler.pas +++ b/Cheat Engine/LuaHandler.pas @@ -2858,11 +2858,22 @@ begin end; function reinitializeSymbolhandler(L: PLua_state): integer; cdecl; +var waittilldone: boolean; begin + if lua_gettop(L)>=1 then + waittilldone:=lua_toboolean(L,1) + else + waittilldone:=true; + lua_pop(L, lua_gettop(L)); result:=0; + + symhandler.reinitialize(true); - symhandler.waitforsymbolsloaded; + + if waitTillDone then + symhandler.waitforsymbolsloaded; + end; function enumModules(L:PLua_state): integer; cdecl; diff --git a/Cheat Engine/bin/main.lua b/Cheat Engine/bin/main.lua index 2f98ad72..22b8c002 100644 --- a/Cheat Engine/bin/main.lua +++ b/Cheat Engine/bin/main.lua @@ -106,7 +106,7 @@ enumModules(processid OPTIONAL): getAddress(string, local OPTIONAL): returns the address of a symbol. Can be a modulename or an export. set Local to true if you wish to querry the symboltable of the ce process getModuleSize(modulename): Returns the size of a given module (Use getAddress to get the base address) -reinitializeSymbolhandler(): reinitializes the symbolhandler. E.g when new modules have been loaded +reinitializeSymbolhandler(waittilldone: BOOLEAN OPTIONAL, default=TRUE): reinitializes the symbolhandler. E.g when new modules have been loaded reinitializeDotNetSymbolhandler(modulename OPTIONAL): Reinitializes only the DotNet part of the symbol list. (E.g After an ILCode has been JITed) (6.4+) errorOnLookupFailure(state): If set to true (default) address lookups in stringform will raise an error if it can not be looked up. This includes symbolnames that are not defined and pointers that are bad. If set to false it will return 0 in those cases diff --git a/Cheat Engine/d3dhookUnit.pas b/Cheat Engine/d3dhookUnit.pas index c4f8d525..1bbad87e 100644 --- a/Cheat Engine/d3dhookUnit.pas +++ b/Cheat Engine/d3dhookUnit.pas @@ -366,6 +366,7 @@ type TD3DHook=class(TObject) private + hooked: boolean; fonKeyDown: TD3DKeyDownEvent; fonclick: TD3DClickEvent; sharename: string; @@ -459,7 +460,8 @@ function safed3dhook(size: integer=16*1024*1024; hookwindow: boolean=true): TD3D implementation -uses frmautoinjectunit, autoassembler, MainUnit, frmSaveSnapshotsUnit, frmsnapshothandlerUnit; +uses frmautoinjectunit, autoassembler, MainUnit, frmSaveSnapshotsUnit, + frmsnapshothandlerUnit, symbolhandler; procedure TD3DMessageHandler.handleSnapshot; begin @@ -1490,27 +1492,31 @@ begin messagehandler.Free; end; + if hooked then + begin - beginCommandListUpdate; + beginCommandListUpdate; - for i:=0 to commandlist.Count-1 do - if commandlist[i]<>nil then - TD3DHook_RenderObject(commandlist[i]).free; + for i:=0 to commandlist.Count-1 do + if commandlist[i]<>nil then + TD3DHook_RenderObject(commandlist[i]).free; - //make sure all commands are gone: - if commandlist.count>0 then - renderCommandList^[0].command:=integer(rcIgnored); + //make sure all commands are gone: + if commandlist.count>0 then + renderCommandList^[0].command:=integer(rcIgnored); - endCommandListUpdate; + endCommandListUpdate; - beginTextureUpdate; + beginTextureUpdate; - for i:=0 to textures.Count-1 do - if textures[i]<>nil then - TD3DHook_Texture(textures[i]).Free; + for i:=0 to textures.Count-1 do + if textures[i]<>nil then + TD3DHook_Texture(textures[i]).Free; - endTextureUpdate; + endTextureUpdate; + + end; UnmapViewOfFile(shared); closehandle(fmhandle); @@ -1618,6 +1624,8 @@ begin //now inject the dll + symhandler.reinitialize; + symhandler.waitforsymbolsloaded(true, 'kernel32.dll'); if processhandler.is64Bit then injectdll(cheatenginedir+'d3dhook64.dll') else @@ -1713,6 +1721,8 @@ begin end; + hooked:=true; + end; function safed3dhook(size: integer=16*1024*1024; hookwindow: boolean=true): TD3DHook; diff --git a/Cheat Engine/frmExeTrainerGeneratorUnit.pas b/Cheat Engine/frmExeTrainerGeneratorUnit.pas index cf62d56b..7dea33e3 100644 --- a/Cheat Engine/frmExeTrainerGeneratorUnit.pas +++ b/Cheat Engine/frmExeTrainerGeneratorUnit.pas @@ -540,7 +540,7 @@ begin s:=lowercase(mainform.frmLuaTableScript.assemblescreen.Text); cbSpeedhack.checked:=pos('speedhack_',s)>0; - cbXMPlayer.checked:=pos('xmplayer_',s)>0; + cbXMPlayer.checked:=(pos('xmplayer_',s)>0) or (pos('xmplayer.',s)>0); cbKernelDebug.checked:=pos('dbk_',s)>0; cbD3DHook.checked:=pos('created3dhook',s)>0; diff --git a/Cheat Engine/symbolhandler.pas b/Cheat Engine/symbolhandler.pas index 794c0e6d..156ee41e 100644 --- a/Cheat Engine/symbolhandler.pas +++ b/Cheat Engine/symbolhandler.pas @@ -2339,6 +2339,8 @@ begin {$endif} //check the symbols +// if (symbolloaderthread<>nil) then + if (symbolloaderthread<>nil) then begin diff --git a/Cheat Engine/trainergenerator.pas b/Cheat Engine/trainergenerator.pas index 7d2b898c..f05caf26 100644 --- a/Cheat Engine/trainergenerator.pas +++ b/Cheat Engine/trainergenerator.pas @@ -1157,9 +1157,17 @@ begin if rbStopWhenAttached.checked then begin - l.add('function onOpenProcess(processid)'); + + + l.add('function onOpenProcess_xmplayer(processid)'); l.add(' xmplayer.stop()'); + l.add(' if xmplayer_originalOnOpenProcess~=nil then'); + l.add(' xmplayer_originalOnOpenProcess(processid)'); + l.add(' end'); l.add('end'); + + l.add('xmplayer_originalOnOpenProcess=onOpenProcess'); + l.add('onOpenProcess=onOpenProcess_xmplayer'); end else begin @@ -1251,6 +1259,18 @@ begin l.add('D3DHook.position=5'); + l.add(''); + l.add('function D3DHook.UpdatePosition()'); + l.add(' if D3DHook.position==2 then --Top Right'); + l.add(' SetD3DMenuPosition(h.Width-BackgroundSprite.Width, 0)'); + l.add(' elseif D3DHook.position==3 then --Bottom Left'); + l.add(' SetD3DMenuPosition(0, h.Height-BackgroundSprite.Height)'); + l.add(' elseif D3DHook.position==4 then --Bottom Right'); + l.add(' SetD3DMenuPosition(h.Width-BackgroundSprite.Width, h.Height-BackgroundSprite.Height)'); + l.add(' elseif D3DHook.position==5 then --Center'); + l.add(' SetD3DMenuPosition((h.Width / 2)-(BackgroundSprite.Width / 2), (h.Height / 2)-(BackgroundSprite.Height/2))'); + l.add(' end'); + l.add('end'); l.add(''); l.add('function onOpenProcess()'); l.add(' if (D3DHook.oldOnOpenProcess~=nil) then'); @@ -1381,19 +1401,13 @@ begin l.add(''); l.add(' end'); //end of for loop - l.add(' SetD3DMenuPosition(0,0) --initialize the background sprite (Top Right)'); - - l.add(' if D3DHook.position==2 then --Top Right'); - l.add(' SetD3DMenuPosition(h.Width-BackgroundSprite.Width, 0)'); - l.add(' elseif D3DHook.position==3 then --Bottom Left'); - l.add(' SetD3DMenuPosition(0, h.Height-BackgroundSprite.Height)'); - l.add(' elseif D3DHook.position==4 then --Bottom Right'); - l.add(' SetD3DMenuPosition(h.Width-BackgroundSprite.Width, h.Height-BackgroundSprite.Height)'); - l.add(' elseif D3DHook.position==5 then --Center'); - l.add(' SetD3DMenuPosition((h.Width / 2)-(BackgroundSprite.Width / 2), (h.Height / 2)-(BackgroundSprite.Height/2))'); - l.add(' end'); - - + l.add(''); + l.add(' D3DHook.UpdatePosition()'); + l.add(' --create a timer to update the position'); + l.add(' local t=createTimer()'); + l.add(' t.OnTimer=D3DHook.UpdatePosition'); + l.add(' t.Interval=2000 --every 2 seconds'); + l.add(' t.Enabled=true'); l.add(''); l.add(' if D3DHook.hasCheckbox then'); l.add(' h.OnClick=D3DHookSpriteClick');