 |
Cheat Engine The Official Site of Cheat Engine
|
View previous topic :: View next topic |
Author |
Message |
lr0 How do I cheat?
Reputation: 0
Joined: 05 Jun 2011 Posts: 3
|
Posted: Sun Jun 05, 2011 3:53 pm Post subject: Visual Basic 2010 Adress with .dll |
|
|
Hey,
I want to create a Trainer in VB but i got a little Problem.
I need to know how to read out a pointer like server.dll+5512CC (Offset: 1BC).
I could easily read out a pointer with no .dll as adresses like 5DAE12CC (Offset: 1BC) with this function: ReadLongPointer(hl2proc, "&H5DAE12CC" "&H1BC", 4)
So if any one could help me how to read out an pointer with an dll. adress please answer.
greets
Description: |
|
Filesize: |
20.95 KB |
Viewed: |
14156 Time(s) |

|
|
|
Back to top |
|
 |
Dark Byte Site Admin
Reputation: 470
Joined: 09 May 2003 Posts: 25794 Location: The netherlands
|
|
Back to top |
|
 |
FLiNG Newbie cheater
Reputation: 0
Joined: 09 Apr 2011 Posts: 19
|
Posted: Sun Jun 05, 2011 6:10 pm Post subject: |
|
|
I don't know much about VB, but here is the code for C#, I think it should be easy to convert to VB
Code: | using System.Diagnostics;
string processname = "whatever it is";
public int GetTargetAddress(string modulename, int offset)
{
Process[] pname = Process.GetProcessesByName(processname);
string ProcIDstring = pname[0].Id.ToString();
UInt32 ProcID = System.Convert.ToUInt32(ProcIDstring);
Process proc = Process.GetProcessById((int)ProcID);
IntPtr gameBase = IntPtr.Zero;
foreach (System.Diagnostics.ProcessModule Module in proc.Modules)
{
if (Module.ModuleName.Contains(modulename))
gameBase = Module.BaseAddress;
}
int TargetAddress = (int)gameBase + offset;
return TargetAddress;
}
|
Here is how to use it:
Code: | int MyAddress = GetTargetAddress("server.dll", 0x1BC); |
sorry if the C# code doesn't help you at all.
|
|
Back to top |
|
 |
atom0s Moderator
Reputation: 205
Joined: 25 Jan 2006 Posts: 8587 Location: 127.0.0.1
|
Posted: Sun Jun 05, 2011 9:37 pm Post subject: |
|
|
ETNWind wrote: | I don't know much about VB, but here is the code for C#, I think it should be easy to convert to VB
Code: | using System.Diagnostics;
string processname = "whatever it is";
public int GetTargetAddress(string modulename, int offset)
{
Process[] pname = Process.GetProcessesByName(processname);
string ProcIDstring = pname[0].Id.ToString();
UInt32 ProcID = System.Convert.ToUInt32(ProcIDstring);
Process proc = Process.GetProcessById((int)ProcID);
IntPtr gameBase = IntPtr.Zero;
foreach (System.Diagnostics.ProcessModule Module in proc.Modules)
{
if (Module.ModuleName.Contains(modulename))
gameBase = Module.BaseAddress;
}
int TargetAddress = (int)gameBase + offset;
return TargetAddress;
}
|
Here is how to use it:
Code: | int MyAddress = GetTargetAddress("server.dll", 0x1BC); |
sorry if the C# code doesn't help you at all. |
Your code is a bit overkill as you are pulling the process twice even though you already have it. You also don't need to define a variable (TargetAddress) if you are just going to return it on the next line, you can just return the (int)gameBase + offset.
Heres another way you can do it as well using Linq:
Code: |
public static IntPtr targetAddress(String processName, String moduleName, int nOffset)
{
try
{
ProcessModule module = ((from Process p in Process.GetProcessesByName(processName)
from ProcessModule m in p.Modules
where m.ModuleName.ToLower() == moduleName.ToLower()
select m).FirstOrDefault() as ProcessModule);
return new IntPtr(module.BaseAddress.ToInt32() + nOffset);
}
catch { return IntPtr.Zero; }
}
|
Example:
Code: | IntPtr lpAddress = targetAddress("notepad", "kernel32.dll", 0x1234); |
In VB.NET: (I used an online converter for this, so no idea if this will work or not.)
Code: |
Public Shared Function targetAddress(ByVal processName As String, ByVal moduleName As String, ByVal nOffset As Integer) As IntPtr
Try
Dim module As ProcessModule = from
Dim p As Process
Process.GetProcessesByName(processName)
Dim ProcessModule As from
m
Dim where As p.Modules
(m.ModuleName.ToLower = moduleName.ToLower)
Dim m As select
CType(FirstOrDefault,ProcessModule)
Return New IntPtr((module.BaseAddress.ToInt32 + nOffset))
Catch As System.Exception
Return IntPtr.Zero
End Try
End Function |
_________________
- Retired. |
|
Back to top |
|
 |
FLiNG Newbie cheater
Reputation: 0
Joined: 09 Apr 2011 Posts: 19
|
Posted: Mon Jun 06, 2011 12:11 am Post subject: |
|
|
To Wiccaan
I know my code is overkill, thanks for your code. But I can't use Linq because it is not supported by .NET 2.0.
Pulling the process twice because I don't know how to convert Process[] to Process, so I decided to get the process by name first then get the ProcessID and get the process again using the ProcessID.
There must be a better way doing this, but I still can't figure out.
Thanks for your comment.
|
|
Back to top |
|
 |
Krähne Expert Cheater
Reputation: 0
Joined: 06 Jun 2010 Posts: 108 Location: Inside of my Kernel
|
Posted: Mon Jun 06, 2011 1:56 am Post subject: |
|
|
ETNWind wrote: | To Wiccaan
I know my code is overkill, thanks for your code. But I can't use Linq because it is not supported by .NET 2.0.
Pulling the process twice because I don't know how to convert Process[] to Process, so I decided to get the process by name first then get the ProcessID and get the process again using the ProcessID.
There must be a better way doing this, but I still can't figure out.
Thanks for your comment. |
Try something like:
Code: | //[System.Runtime.InteropServices.DllImport("kernel32.dll", SetLastError = true, CallingConvention = System.Runtime.InteropServices.CallingConvention.Winapi)]
//[return: System.Runtime.InteropServices.MarshalAs(System.Runtime.InteropServices.UnmanagedType.Bool)]
//private static extern bool IsWow64Process([System.Runtime.InteropServices.In] IntPtr hProcess, [System.Runtime.InteropServices.Out] out bool lpSystemInfo);
private static IntPtr targetAddress(string PName, string MName, uint OffSet)
{
IntPtr ModuleBaseAddress = IntPtr.Zero;
Process[] GameProcess = Process.GetProcessesByName(PName);
ProcessModuleCollection ProcessModuleCollection = GameProcess[0].Modules;
for (int i = 0; i < ProcessModuleCollection.Count; i++)
{
ProcessModule myProcessModule = ProcessModuleCollection[i];
if (myProcessModule.ModuleName.ToLower() == MName.ToLower())
{
ModuleBaseAddress = myProcessModule.BaseAddress;
break;
}
}
/* I also know that is not the correct way for know the System's arquitecture, but...
* With the Win32 API (IsWow64Process) on W7x64 i get everytime that the process is x86 (Even compiling for x64).
* However, if you still want use it, modify the condition (Change IntPTr.Size == 8 for isWow64), uncomment the DllImport lines and...
* Add this lines after the 4th line:
* Boolean IsWow64 = false;
* IsWow64Process(GameProcess[0].Handle, out IsWow64);
*/
if (IntPtr.Size == 8) //IsWow64
return new IntPtr(ModuleBaseAddress.ToInt64() + OffSet); //For x64 Systems
else
return new IntPtr(ModuleBaseAddress.ToInt32() + OffSet); //For x86 Systems
} |
Gruß.
_________________
Excuse me if you don't understand what I just said, but "english" isn't my native language. |
|
Back to top |
|
 |
FLiNG Newbie cheater
Reputation: 0
Joined: 09 Apr 2011 Posts: 19
|
Posted: Mon Jun 06, 2011 6:00 am Post subject: |
|
|
Thanks both Krähne and Wiccaan
Here is my simplified code
Code: | using System.Diagnostics;
string processname = "whatever it is";
public int GetTargetAddress(string modulename, int offset)
{
Process[] pname = Process.GetProcessesByName(processname);
IntPtr gameBase = IntPtr.Zero;
try
{
foreach (System.Diagnostics.ProcessModule Module in pname[0].Modules)
{
if (Module.ModuleName.Contains(modulename))
gameBase = Module.BaseAddress;
}
return (int)gameBase + offset;
}
catch (Exception)
{
return 0;
}
} |
EXAMPLE:
Code: | int MyAddress = GetTargetAddress("server.dll", 0x1BC); |
Here is the VB code, tested:
Code: | Private processname As String = "what ever it is"
Public Function GetTargetAddress(ByVal modulename As String, ByVal offset As Integer) As Integer
Dim pname As Process() = Process.GetProcessesByName(processname)
Dim gameBase As IntPtr = IntPtr.Zero
Try
For Each [Module] As System.Diagnostics.ProcessModule In pname(0).Modules
If [Module].ModuleName.Contains(modulename) Then
gameBase = [Module].BaseAddress
End If
Next
Return CInt(gameBase) + offset
Catch generatedExceptionName As Exception
Return 0
End Try
End Function |
EXAMPLE:
Code: | Dim MyAddress As Integer = GetTargetAddress("server.dll", &H1BC) |
If there are something I can improve, let me know, thank you.
|
|
Back to top |
|
 |
lr0 How do I cheat?
Reputation: 0
Joined: 05 Jun 2011 Posts: 3
|
Posted: Mon Jun 06, 2011 8:04 am Post subject: |
|
|
ETNWind wrote: | Thanks both Krähne and Wiccaan
Here is my simplified code
Code: | using System.Diagnostics;
string processname = "whatever it is";
public int GetTargetAddress(string modulename, int offset)
{
Process[] pname = Process.GetProcessesByName(processname);
IntPtr gameBase = IntPtr.Zero;
try
{
foreach (System.Diagnostics.ProcessModule Module in pname[0].Modules)
{
if (Module.ModuleName.Contains(modulename))
gameBase = Module.BaseAddress;
}
return (int)gameBase + offset;
}
catch (Exception)
{
return 0;
}
} |
EXAMPLE:
Code: | int MyAddress = GetTargetAddress("server.dll", 0x1BC); |
Here is the VB code, tested:
Code: | Private processname As String = "what ever it is"
Public Function GetTargetAddress(ByVal modulename As String, ByVal offset As Integer) As Integer
Dim pname As Process() = Process.GetProcessesByName(processname)
Dim gameBase As IntPtr = IntPtr.Zero
Try
For Each [Module] As System.Diagnostics.ProcessModule In pname(0).Modules
If [Module].ModuleName.Contains(modulename) Then
gameBase = [Module].BaseAddress
End If
Next
Return CInt(gameBase) + offset
Catch generatedExceptionName As Exception
Return 0
End Try
End Function |
EXAMPLE:
Code: | Dim MyAddress As Integer = GetTargetAddress("server.dll", &H1BC) |
If there are something I can improve, let me know, thank you. |
Hey thx for all ya answers.
But your code doesnt work for me.
If i use TextBox1.Text = (GetTargetAddress("server.dll", &H5512CC))
I just get a wierd adress like "469631420".
Maybe u misunderstood me but cheat engine tells me that server.dll+5512CC = an adress like 1C5312CC or the adress in the picture.
Or did i do anything wrong please help me by answering to my thread.
greets
|
|
Back to top |
|
 |
Krähne Expert Cheater
Reputation: 0
Joined: 06 Jun 2010 Posts: 108 Location: Inside of my Kernel
|
Posted: Mon Jun 06, 2011 8:41 am Post subject: |
|
|
lr0 wrote: | ETNWind wrote: | Thanks both Krähne and Wiccaan
Here is my simplified code
Code: | using System.Diagnostics;
string processname = "whatever it is";
public int GetTargetAddress(string modulename, int offset)
{
Process[] pname = Process.GetProcessesByName(processname);
IntPtr gameBase = IntPtr.Zero;
try
{
foreach (System.Diagnostics.ProcessModule Module in pname[0].Modules)
{
if (Module.ModuleName.Contains(modulename))
gameBase = Module.BaseAddress;
}
return (int)gameBase + offset;
}
catch (Exception)
{
return 0;
}
} |
EXAMPLE:
Code: | int MyAddress = GetTargetAddress("server.dll", 0x1BC); |
Here is the VB code, tested:
Code: | Private processname As String = "what ever it is"
Public Function GetTargetAddress(ByVal modulename As String, ByVal offset As Integer) As Integer
Dim pname As Process() = Process.GetProcessesByName(processname)
Dim gameBase As IntPtr = IntPtr.Zero
Try
For Each [Module] As System.Diagnostics.ProcessModule In pname(0).Modules
If [Module].ModuleName.Contains(modulename) Then
gameBase = [Module].BaseAddress
End If
Next
Return CInt(gameBase) + offset
Catch generatedExceptionName As Exception
Return 0
End Try
End Function |
EXAMPLE:
Code: | Dim MyAddress As Integer = GetTargetAddress("server.dll", &H1BC) |
If there are something I can improve, let me know, thank you. |
Hey thx for all ya answers.
But your code doesnt work for me.
If i use TextBox1.Text = (GetTargetAddress("server.dll", &H5512CC))
I just get a wierd adress like "469631420".
Maybe u misunderstood me but cheat engine tells me that server.dll+5512CC = an adress like 1C5312CC or the adress in the picture.
Or did i do anything wrong please help me by answering to my thread.
greets |
¬¬
Quote: | Decimal: 469631420
Hexadecimal: 1BFE01BC |
Gruß.
_________________
Excuse me if you don't understand what I just said, but "english" isn't my native language. |
|
Back to top |
|
 |
lr0 How do I cheat?
Reputation: 0
Joined: 05 Jun 2011 Posts: 3
|
Posted: Mon Jun 06, 2011 8:47 am Post subject: |
|
|
Krähne wrote: | lr0 wrote: | ETNWind wrote: | Thanks both Krähne and Wiccaan
Here is my simplified code
Code: | using System.Diagnostics;
string processname = "whatever it is";
public int GetTargetAddress(string modulename, int offset)
{
Process[] pname = Process.GetProcessesByName(processname);
IntPtr gameBase = IntPtr.Zero;
try
{
foreach (System.Diagnostics.ProcessModule Module in pname[0].Modules)
{
if (Module.ModuleName.Contains(modulename))
gameBase = Module.BaseAddress;
}
return (int)gameBase + offset;
}
catch (Exception)
{
return 0;
}
} |
EXAMPLE:
Code: | int MyAddress = GetTargetAddress("server.dll", 0x1BC); |
Here is the VB code, tested:
Code: | Private processname As String = "what ever it is"
Public Function GetTargetAddress(ByVal modulename As String, ByVal offset As Integer) As Integer
Dim pname As Process() = Process.GetProcessesByName(processname)
Dim gameBase As IntPtr = IntPtr.Zero
Try
For Each [Module] As System.Diagnostics.ProcessModule In pname(0).Modules
If [Module].ModuleName.Contains(modulename) Then
gameBase = [Module].BaseAddress
End If
Next
Return CInt(gameBase) + offset
Catch generatedExceptionName As Exception
Return 0
End Try
End Function |
EXAMPLE:
Code: | Dim MyAddress As Integer = GetTargetAddress("server.dll", &H1BC) |
If there are something I can improve, let me know, thank you. |
Hey thx for all ya answers.
But your code doesnt work for me.
If i use TextBox1.Text = (GetTargetAddress("server.dll", &H5512CC))
I just get a wierd adress like "469631420".
Maybe u misunderstood me but cheat engine tells me that server.dll+5512CC = an adress like 1C5312CC or the adress in the picture.
Or did i do anything wrong please help me by answering to my thread.
greets |
¬¬
Quote: | Decimal: 469631420
Hexadecimal: 1BFE01BC |
Gruß. |
Thx Thx works great with Hex(GetTargetAddress("server.dll", &HXXXX)
|
|
Back to top |
|
 |
atom0s Moderator
Reputation: 205
Joined: 25 Jan 2006 Posts: 8587 Location: 127.0.0.1
|
Posted: Mon Jun 06, 2011 1:25 pm Post subject: |
|
|
ETNWind wrote: | To Wiccaan
I know my code is overkill, thanks for your code. But I can't use Linq because it is not supported by .NET 2.0.
Pulling the process twice because I don't know how to convert Process[] to Process, so I decided to get the process by name first then get the ProcessID and get the process again using the ProcessID.
There must be a better way doing this, but I still can't figure out.
Thanks for your comment. |
Process[] is an enumerable list, meaning you can index it. Beings that its a list of Process, when you index it specifically you will get a single Process instance in return. So:
Code: | Process[] pname = Process.GetProcessesByName(processname);
Process proc = pname[0]; |
Now proc is a single instance of the first found process with the given name. (Granted this has no error checking and can fail/throw an exception!)
As for using .NET 2.0, you should upgrade to VS2010 express, it's free just like the others have been. .NET 4.0 has tons of improvements and new features that are great.
_________________
- Retired. |
|
Back to top |
|
 |
|
|
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
|
|