La funcion es un putmem x bytes, lo que hace es insertar X bytes a una posicion de memoria indicada, esta funcion que hice
es identica a las funciones:
Declare Sub PutMem1 Lib "msvbvm60" (Ptr As Any, ByVal NewVal As Byte)
Declare Sub PutMem2 Lib "msvbvm60" (Ptr As Any, ByVal NewVal As Integer)
Declare Sub PutMem4 Lib "msvbvm60" (Ptr As Any, ByVal NewVal As Long)
Declare Sub PutMem8 Lib "msvbvm60" (Ptr As Any, ByVal NewVal As Currency)
salvo que esta se pueden insertar cualquier cantidad de bytes, que es el tercer parametro el numero de bytes que uno debe
de indicar a insertar, tambien hay que tomar en cuenta como estan almacenados los bytes en la memoria eso es si es microprocesador de uno es little o big...
Option Explicit
Private Declare Function CallWindowProc Lib "USER32" Alias "CallWindowProcW" (ByVal lpPrevWndFunc As Long, ByVal hwnd As Long, ByVal msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Private Sub Form_Load()
' By RHL no quitar texto
Dim test As String: test = "Test de XXXXXX en inline asm!"
Dim newp As String: newp = "PUTMEM"
Dim A As Long:A = &H101010
Dim B As Byte:B = &H20
Call vASM_PUTMEMx(VarPtr(A), VarPtr(B), 1)
MsgBox A
Call vASM_PUTMEMx(StrPtr(test) + 16, StrPtr(newp), 12)
MsgBox test
End Sub
'Declare Sub PutMemx Lib "msvbvm60" (ptr As Any, ByVal newval As Byte)
Private Sub vASM_PUTMEMx(ByVal ptr As Long, ByVal newval As Long, ByVal nB As Long)
Dim Acode(25) As Byte: Acode(25) = &HC3
Acode(17) = &H8A: Acode(18) = &H10: Acode(19) = &H88: Acode(20) = &H17
Acode(21) = &H40: Acode(22) = &H47: Acode(23) = &HE2: Acode(24) = &HF8
Dim i As Long
' MOV EAX,OFFSET newval
' MOV EDI,OFFSET ptr
' XOR ECX,ECX
' MOV ECX,nB
'INI: MOV DL,[EAX]
' MOV [EDI], DL
' INC EAX
' INC EDI
' LOOP INI
Acode(0) = &HB8
i = LongToByte(newval, Acode(), i + 1)
Acode(5) = &HBF
i = LongToByte(ptr, Acode(), i + 1)
Acode(10) = &H33: Acode(11) = &HC9
Acode(12) = &HB9
i = LongToByte(nB, Acode(), i + 3)
Call CallWindowProc(ByVal VarPtr(Acode(0)), 0&, 0&, 0&, 0&)
End Sub
'by BlackZeroX
Private Function LongToByte(ByVal lLong As Long, ByRef bReturn() As Byte, Optional i As Integer = 0) As Long
bReturn(i) = lLong And &HFF
bReturn(i + 1) = (lLong And &HFF00&) \ &H100
bReturn(i + 2) = (lLong And &HFF0000) \ &H10000
bReturn(i + 3) = (lLong And &HFF000000) \ &H1000000
LongToByte = i + 4
End Function
' By RHL no quitar texto
en vb los caracteres estan en unicode osea dos bytes por caracteres