Sodruza
10-29-2016, 03:29 AM
Hello guys,
Last week i asked how to deal with offsets through VBA and SamT told me to create a dll thanks to c# (since i have the function in C#) and put it as reference in VBA. I did it, but i get the error 430. I googled how to fix the error 430 and i have been told to install MDAC 2.5. I tried to install MDAC2.5 but it led to a fail, same problem with the last version of MDAC.... I hope you guys might know a trick to get through this problem.
Here are my codes, in case you wanna check :
-1 Library from C#
using System;using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;
using System.Diagnostics;
namespace DotNetLibrary2
{
public class DotNetClass
{
[DllImport("kernel32.dll", SetLastError = true)]
static extern bool ReadProcessMemory(IntPtr hProcess, IntPtr lpBaseAddress, byte[] lpBuffer, int dwSize, int lpNumberOfBytesRead);
public int GetPointedAddr2offs(String TheGame, IntPtr BaseAddr, int Offs1, int Offs2)
{
IntPtr H = Process.GetProcessesByName(TheGame)[0].Handle;
int Ptr = 0;
byte[] TempBuf = new byte[5];
ReadProcessMemory(H, BaseAddr, TempBuf, 4, 0);
Ptr = BitConverter.ToInt32(TempBuf, 0) + Offs1;
ReadProcessMemory(H, (IntPtr)Ptr, TempBuf, 4, 0);
Ptr = BitConverter.ToInt32(TempBuf, 0) + Offs2;
return Ptr;
}
}
}
2- VBA code :
Sub TestDotNetCall()
Dim TheGame As String, BaseAddress As LongPtr, Offset1 As Long, Offset2 As Long, Result As Long
Dim testClass As New DotNetClass
TheGame = "PlantsVsZombies"
BaseAddress = &H73D7E8
Offset1 = &H868
Offset2 = &H5578
Result = testClass.GetPointedAddr2offs(TheGame, BaseAddress, Offset1, Offset2)
MsgBox Result
End Sub
I do my memory hacking tests on worthless games, because i do not want to damage something important.
Looking forwards to hearing from you guys :)
Last week i asked how to deal with offsets through VBA and SamT told me to create a dll thanks to c# (since i have the function in C#) and put it as reference in VBA. I did it, but i get the error 430. I googled how to fix the error 430 and i have been told to install MDAC 2.5. I tried to install MDAC2.5 but it led to a fail, same problem with the last version of MDAC.... I hope you guys might know a trick to get through this problem.
Here are my codes, in case you wanna check :
-1 Library from C#
using System;using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;
using System.Diagnostics;
namespace DotNetLibrary2
{
public class DotNetClass
{
[DllImport("kernel32.dll", SetLastError = true)]
static extern bool ReadProcessMemory(IntPtr hProcess, IntPtr lpBaseAddress, byte[] lpBuffer, int dwSize, int lpNumberOfBytesRead);
public int GetPointedAddr2offs(String TheGame, IntPtr BaseAddr, int Offs1, int Offs2)
{
IntPtr H = Process.GetProcessesByName(TheGame)[0].Handle;
int Ptr = 0;
byte[] TempBuf = new byte[5];
ReadProcessMemory(H, BaseAddr, TempBuf, 4, 0);
Ptr = BitConverter.ToInt32(TempBuf, 0) + Offs1;
ReadProcessMemory(H, (IntPtr)Ptr, TempBuf, 4, 0);
Ptr = BitConverter.ToInt32(TempBuf, 0) + Offs2;
return Ptr;
}
}
}
2- VBA code :
Sub TestDotNetCall()
Dim TheGame As String, BaseAddress As LongPtr, Offset1 As Long, Offset2 As Long, Result As Long
Dim testClass As New DotNetClass
TheGame = "PlantsVsZombies"
BaseAddress = &H73D7E8
Offset1 = &H868
Offset2 = &H5578
Result = testClass.GetPointedAddr2offs(TheGame, BaseAddress, Offset1, Offset2)
MsgBox Result
End Sub
I do my memory hacking tests on worthless games, because i do not want to damage something important.
Looking forwards to hearing from you guys :)