Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


6.7 source loadlibrary

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Source
View previous topic :: View next topic  
Author Message
kyle.kwp
How do I cheat?
Reputation: 0

Joined: 28 Nov 2017
Posts: 6

PostPosted: Tue Nov 28, 2017 1:33 am    Post subject: 6.7 source loadlibrary Reply with quote

Hi, I am trying to modify

the code in the newkernelhandler.pas

initialization part, loadlibrary.

it looks like I can only load win32 libraries.

can I load custom dll ?

I'v spent 8hours on trying to make "loadlibrary("mydll.dll")" work but

debugger always give me 0 (failed to load).

for example,
Code:
myVar:=LoadLibrary(pchar(CheatEngineDir+'\win64\myDLL.dll')); 


doesn't work ..[/code]

ofc, I defined myVar as THandle above

_________________
kwp
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 457

Joined: 09 May 2003
Posts: 25262
Location: The netherlands

PostPosted: Tue Nov 28, 2017 1:40 am    Post subject: Reply with quote

is cheat engine compiled as 64 bit?
is your dll compiled as 64-bit ?
does your dll import other dlls? and if so, can they be found ?

_________________
Do not ask me about online cheats. I don't know any and wont help finding them.

Like my help? Join me on Patreon so i can keep helping
Back to top
View user's profile Send private message MSN Messenger
kyle.kwp
How do I cheat?
Reputation: 0

Joined: 28 Nov 2017
Posts: 6

PostPosted: Tue Nov 28, 2017 12:27 pm    Post subject: Reply with quote

cheat engine compiled - 64bit
dll compiled - 64bit
my dll doesn't import other dll.

I forgot to mention dll I was trying to load was written with c++.

after the post, I made dll with pascal, it was successfully loaded

I used dumpbin /export to check pe headers it looks like
headers from dll written with pascal and written with c++, they are different -.-

but loadlibrary can be used for kernel32.dll or dbghelp.dll...

I took string-mix(?) eg) __(name)@20 into consideration by defining .def file and calling conventions

anyways.. dll written with pascal works great but it's pain in the ass to write everything from scratch something originally written in c++ ...

is there anyway to load c++ written dll


Dark Byte wrote:
is cheat engine compiled as 64 bit?
is your dll compiled as 64-bit ?
does your dll import other dlls? and if so, can they be found ?

_________________
kwp
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 457

Joined: 09 May 2003
Posts: 25262
Location: The netherlands

PostPosted: Wed Nov 29, 2017 1:10 pm    Post subject: Reply with quote

Try compiling it as C instead of C++
_________________
Do not ask me about online cheats. I don't know any and wont help finding them.

Like my help? Join me on Patreon so i can keep helping
Back to top
View user's profile Send private message MSN Messenger
kyle.kwp
How do I cheat?
Reputation: 0

Joined: 28 Nov 2017
Posts: 6

PostPosted: Fri Dec 01, 2017 1:13 am    Post subject: Reply with quote

Dark Byte wrote:
Try compiling it as C instead of C++


I'v tried and failed

I cannot even load dbk32.dll,APIHOOK,d3dhook.dll

all other dlls such as kernel32,ntdll, etc are loaded fine.

maybe it's my computer or lazarus compiler problem

so weird cannot load c/c++ custom made dlls

Crying or Very sad

_________________
kwp
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 457

Joined: 09 May 2003
Posts: 25262
Location: The netherlands

PostPosted: Fri Dec 01, 2017 4:52 am    Post subject: Reply with quote

Are you on a normal windows system or on an emulator like Wine ?

You're sure you're debugging loadlibrary and not the loadplugin code ?

_________________
Do not ask me about online cheats. I don't know any and wont help finding them.

Like my help? Join me on Patreon so i can keep helping
Back to top
View user's profile Send private message MSN Messenger
kyle.kwp
How do I cheat?
Reputation: 0

Joined: 28 Nov 2017
Posts: 6

PostPosted: Fri Dec 01, 2017 1:58 pm    Post subject: Reply with quote

Dark Byte wrote:
Are you on a normal windows system or on an emulator like Wine ?

You're sure you're debugging loadlibrary and not the loadplugin code ?



Code:
program test1212;
 uses windows, Classes,sysutils;

type TReadProcessMemory=function(hProcess: THandle; lpBaseAddress, lpBuffer: Pointer; nSize: DWORD; var lpNumberOfBytesRead: PTRUINT): BOOL; stdcall;

var
      WindowsKernel: Thandle;

      krpm: TReadProcessMemory;

begin



WindowsKernel:=LoadLibrary(pchar('phyDLL.dll'));

Pointer(krpm):=GetProcAddress(WindowsKernel,'krpm');



end.


this simple Program runs but while debugging, windowsKernel points to 0

but if I use LoadLibrary(pchar('kernel32.dll'));, it points to proper address

in this case phyDLL.dll is C++/C dll which cannot be loaded .
any other pascal written dll can be loaded.
[/code]

_________________
kwp
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 457

Joined: 09 May 2003
Posts: 25262
Location: The netherlands

PostPosted: Fri Dec 01, 2017 3:07 pm    Post subject: Reply with quote

you are sure ce is compiled as 64-bit ? because what you describe is exactly that. (also, don't compile your dll as 'managed')
_________________
Do not ask me about online cheats. I don't know any and wont help finding them.

Like my help? Join me on Patreon so i can keep helping
Back to top
View user's profile Send private message MSN Messenger
kyle.kwp
How do I cheat?
Reputation: 0

Joined: 28 Nov 2017
Posts: 6

PostPosted: Fri Dec 01, 2017 9:16 pm    Post subject: Reply with quote

Dark Byte wrote:
you are sure ce is compiled as 64-bit ? because what you describe is exactly that. (also, don't compile your dll as 'managed')


yes. project option - compiler option target-OS 64bit, target cpu-x86_64 (both in CE and my test delphi app), running with administration priv

yes c++ dll, I am not using clr, I even tried pragma managed push off method + no clr support option. dll is compiled in 64 bit as well.


I am gonna try to simulate the same on the other machine as well .

I am using 3.0.2 fpc, 1.6.4 lazarus windows 10 64bit

loadlibrary only loads system32 subsystem dll written by ms, or pascal written dll -.-

you don't have this issue right? loadlibrary in lazarus

of course, I can load every dll using loadlibrary in c++ program using ms visual studio. it only happens with lazarus, pascal language.


(edit) by the what I am trying to achieve is, direct rpm/wpm physical memory through vulnerable asus driver, I'v already made export functions in dll form, I just want to replace default rpm/wpm in CE by loading dll in newKernelHandler. as kernel rwpm given in CE has to be run in test sign mode or need a certificate.

_________________
kwp
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 457

Joined: 09 May 2003
Posts: 25262
Location: The netherlands

PostPosted: Sat Dec 02, 2017 3:58 am    Post subject: Reply with quote

check in the taskmanager that your program is actually 64 bit (or make sure sizeof(pointer) is 8 )

do you test your c++ app by copying the dll to the corresponding location just like in pascal ? (could be that the dll only works if some other file is present in that folder)

do you give full paths to the files, or do you use relative paths or based on a variable. (if based on a var, print out the final path, could be missing a path selerator)

are you compiling using unicode ?
you mentioned something about Delphi earlier and , if you meant the new one(after 7), that one tends to force your code to unicode, so it would likely be calling loadlibraryW and pchar converts it to ascii

_________________
Do not ask me about online cheats. I don't know any and wont help finding them.

Like my help? Join me on Patreon so i can keep helping
Back to top
View user's profile Send private message MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Source All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites