Jump to content
sqlvb2012

Help needed for vb

Recommended Posts

sqlvb2012

this decompile code have error in method 4 & 5 please any one correct it

    <DllImport("kernel32.dll", EntryPoint:="CreateFile")> _    Public Shared Function CreateFile(ByVal string0 As String, ByVal uint0 As UInt32, ByVal uint1 As UInt32, ByVal p3 As IntPtr, ByVal uint2 As UInt32, ByVal uint3 As UInt32, ByVal p6 As IntPtr) As IntPtr    End Function    <DllImport("kernel32.dll", EntryPoint:="CreateFileMapping")> _    Public Shared Function CreateFileMapping(ByVal p0 As IntPtr, ByVal p1 As IntPtr, ByVal uint0 As UInt32, ByVal uint1 As UInt32, ByVal uint2 As UInt32, ByVal string0 As String) As IntPtr    End Function    <DllImport("kernel32.dll", EntryPoint:="MapViewOfFile")> _    Public Shared Function MapViewOfFile(ByVal p0 As IntPtr, ByVal uint0 As UInt32, ByVal uint1 As UInt32, ByVal uint2 As UInt32, ByVal uint3 As UInt32) As IntPtr    End Function    <DllImport("kernel32.dll", EntryPoint:="UnmapViewOfFile")> _    Public Shared Function UnmapViewOfFile(ByVal IntPtr) As Boolean    End Function    <DllImport("kernel32.dll", EntryPoint:="CloseHandle")> _    Public Shared Function CloseHandle(ByVal IntPtr) As Boolean    End FunctionPrivate Sub NamedMethod(obj1 As Object)Dim bytes As Byte() = Encoding.Unicode.GetBytes("caead3afc3a1da0b36a83c8d0019f46cf2c5695d25fbd177c1eeb8925f4e1feb4f19fd44106a6042d34fa8f53dedf781e5cd0bf1663847521ac13c9d7f03a8304")        Dim buffer2 As Byte() = Encoding.Unicode.GetBytes("0831899bee0144021716817b7969cb3156cec08ddd446b9081a83b8813d94fdc99ff4b52d81571cfc2919bab95548cf8c1927a603d0898e9b8727ecf880b4e")        Dim path As String = CStr(obj1)        If File.Exists(System.IO.Path.ChangeExtension(path, "bak")) Then            File.Delete(path)            File.Copy(System.IO.Path.ChangeExtension(path, "bak"), path)        Else            File.Copy(path, IO.Path.ChangeExtension(path, "bak"))        End If        Dim length As Long = New FileInfo(path).Length        Dim ptr As IntPtr = Main.CreateFile(path, &H10000000, 0, IntPtr.Zero, 3, &H80, IntPtr.Zero)        Dim ptr2 As IntPtr = Main.CreateFileMapping(ptr, IntPtr.Zero, &H40, 0, 0, Nothing)        Dim ptr3 As IntPtr = Main.MapViewOfFile(ptr2, 2, 0, 0, 0)        Dim flag As Boolean = False        Try            Me.Method4(ptr3, length, bytes, buffer2)            flag = True        Catch obj2 As Exception        End Try                Main.UnmapViewOfFile(ptr3)        Main.CloseHandle(ptr2)        Main.CloseHandle(ptr)        Me.Method1(Cursors.Arrow)        If Not flag Then            MessageBox.Show(Me, "Error!")        Else            MessageBox.Show(Me, "Done!")        End If        Me.tbSolutionFile.Enabled = True    End SubPrivate Sub Method4(ByVal ptr1 As IntPtr, ByVal num1 As Long, ByVal buffer2 As Byte(), ByVal buffer1 As Byte())    Dim num As Integer    Do While (num = Me.Method5(DirectCast(ptr1, Byte*), num1, buffer2) <> -1)        Marshal.Copy(buffer1, 0, DirectCast((DirectCast(ptr1, Void*) + num), IntPtr), buffer1.Length)    LoopEnd SubPrivate Function Method5(ByRef numPtr1 As Byte, ByVal num1 As Long, ByVal buffer1 As Byte()) As Integer    Dim index As Integer = 0    Dim i As Integer    For i = 0 To num1 - 1        If (numPtr1(i) = buffer1(index)) Then            If (index = (buffer1.Length - 1)) Then                Return (i - index)            End If            index += 1        Else            index = 0        End If    Next i    Return -1End Function

thanks in advance
Best Regards
sqlvb2012

Edited by sqlvb2012

Share this post


Link to post
Share on other sites
Loop_DE_Loopz

hey bro,


is that .NET?


Share this post


Link to post
Share on other sites
Loop_DE_Loopz

Me.Method4(ptr3, length, bytes, buffer2)

 

Private Sub Method4(ByVal ptr1 As IntPtr,

 

that will be the first one....


and the 2nd:

 

Method5(ByRef numPtr1 As Byte

 

Me.Method5(DirectCast(ptr1, Byte*

Share this post


Link to post
Share on other sites
CybotX

it looks like vb 6.0


Share this post


Link to post
Share on other sites
sqlvb2012

vb .net


error because pointer and unsafe code cannot handle in vb .net how can handle unsafe code in vb.net


 


method in c#(no error)



private unsafe void Method4(IntPtr ptr1, long num1, byte[] buffer2, byte[] buffer1)
{
int num;
while ((num = this.Method5((byte*)ptr1, num1, buffer2)) != -1)
{
Marshal.Copy(buffer1, 0, (IntPtr)((((int)(void*)ptr1) + num)), buffer1.Length);
}
}

private unsafe int Method5(byte* numPtr1, long num1, byte[] buffer1)
{
int index = 0;
for (int i = 0; i < num1; i++)
{
if (numPtr1[i] == buffer1[index])
{
if (index == (buffer1.Length - 1))
{
return (i - index);
}
index++;
}
else
{
index = 0;
}
}
return -1;
}

how can handle in vb .net


Edited by sqlvb2012

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×

Important Information

Guidelines