PDA

View Full Version : Error 430 - C# .dll - Reference VBA



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 :)

Kenneth Hobs
10-29-2016, 06:52 AM
I am not very good at c# so I can't help much with that.

I have used vb.net to make a com visible DLL. Maybe how I did it and used it would help. http://www.vbaexpress.com/forum/showthread.php?45316-How-to-call-use-DLL-via-vba-macro

As for needing MDAC, I doubt that is the case. One normally uses it for ADO routines. When using that, I would normally use Microsoft ActiveX Data Objects Library 2.8 library, msado28.tlb.

Sodruza
10-29-2016, 07:11 AM
This can be cool. I also have the function working on VB.net. But for some reason, when i tried to create the DLL with VB.net, visual basic was like "the DLL was create successfully at : ******XX"
=> i go to ******XX => it s empty (facepalm)


Seriously, i m going full crazy.... But i aint gonna give up!

Thanks for your answer.

Kenneth Hobs
10-29-2016, 08:08 AM
Did you view the link specific to c# that I referenced? http://www.geeksengine.com/article/create-dll.html

Sodruza
10-29-2016, 08:15 AM
Yeah i saw that before to post anything on the forum.
I can even tell you that it worked and i could do my first basics functions. but for some reasons, when i try to do something harder it doesnt work :/