Menú

Mostrar Mensajes

Esta sección te permite ver todos los mensajes escritos por este usuario. Ten en cuenta que sólo puedes ver los mensajes escritos en zonas a las que tienes acceso en este momento.

Mostrar Mensajes Menú

Mensajes - Miseryk

#151
Hola, estaba tratando de hacer algo mientras me topé con un problema, tal vez parezca tonto o quizá nunca necesité algo así.

Lo que quiero lograr, es encontrar la posición con respecto a un index de un Split.

Code:

Form:
Código (vb) [Seleccionar]

Option Explicit

Private Sub Form_Load()
Call ConfigArray

Call Stuff

End
End Sub



Module:
Código (vb) [Seleccionar]

Option Explicit

Public MyByteArray() As Byte
Public Const StrByteArray As String = "255,254,253,0,252,0,0,0,251,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,250,0,0,0,0,0,0," & _
                                     "0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,249,0," & _
                                     "0,0,3,4,248,3,0,247,246,5,6,2,245,244,5,6,243,242,7,241,8,240,9,10,239,9,11,12,8,238,11," & _
                                     "13,13,10,237,8,236,14,8,9,235,13,8,7,13,8,7,234,233,8,12,10,232,14,231,15,15,230,229,0,0,0," & _
                                     "0,0,0,0,228,227,226,16,5,2,17,18,5,2,17,18,5,2,17,18,225,224,4,18,223,2,17,18,222,19,18," & _
                                     "18,20,2,17,18,21,22,221,18,220,2,17,18,21,22,219,18,23,2,17,18,5,2,218,18,16,2,17,18,21,22," & _
                                     "217,18,19,2,17,18,21,22,216,218,23,2,17,18,21,22,215,18,20,2,17"
Public MaxArray As Integer

Public Sub ConfigArray()
Dim i As Integer

MaxArray = UBound(Split(StrByteArray, ","))
ReDim MyByteArray(0 To MaxArray) As Byte

For i = 0 To MaxArray
   MyByteArray(i) = Split(StrByteArray, ",")(i)
Next i
End Sub

Public Sub Stuff()
Dim i As Integer
Dim CurrentByte As Byte
Dim found As Long
Dim CurrentPos As Long

For i = 0 To MaxArray
   If i = 5 Then
       'Ejemplo, index 5 -> 255,254,253,0,252,0,
       CurrentByte = MyByteArray(i)
       CurrentPos = Aca quiero obtener la posicion del index 5
   End If
Next i
End Sub


CurrentPos = Aca quiero obtener la posicion del index 5, que sería 19

Alguna idea o algún comando mágico que me retorne la posición según el index?
#152
Tenés que hookear DX9 o la versión que tenga.

Luego en myDrawIndexedPrimitive podés poner:

Código (cpp) [Seleccionar]

DrawCrosshair(pDevice, 10, 1, COLOR__BLUE);


Código (cpp) [Seleccionar]

D3DCOLOR COLOR__BLUE = D3DCOLOR_ARGB(255, 0, 0, 255);

void DrawCrosshair(LPDIRECT3DDEVICE9 pDevice, int size, int strong,  D3DCOLOR xcolor)
{
/*
New 05/03/2013
*/
D3DVIEWPORT9 viewPort;

float ScreenCenterX = 0.0f;
float ScreenCenterY = 0.0f;

pDevice->GetViewport(&viewPort);
ScreenCenterX = (float)viewPort.Width / 2;
ScreenCenterY = (float)viewPort.Height / 2;

D3DRECT rec2 = { (ScreenCenterX-size), ScreenCenterY, (ScreenCenterX+size), (ScreenCenterY+strong)};
D3DRECT rec3 = { ScreenCenterX, (ScreenCenterY-size), (ScreenCenterX+strong), (ScreenCenterY+size)};
pDevice->Clear(1, &rec2, D3DCLEAR_TARGET, xcolor, 1000,  0);
pDevice->Clear(1, &rec3, D3DCLEAR_TARGET, xcolor, 100,  0);
/*
New 05/03/2013
*/

/*
int iCenterX = GetSystemMetrics( 0 ) / 2;
int iCenterY = GetSystemMetrics( 1 ) / 2;
if( iCenterX < 20 && iCenterY < 20 )
{
iCenterX = ( GetSystemMetrics( 0 ) / 2 );
iCenterY = ( GetSystemMetrics( 1 ) / 2 );
}
D3DRECT rec2 = { iCenterX- size, iCenterY, iCenterX+ size, iCenterY+ strong};
D3DRECT rec3 = { iCenterX, iCenterY- size, iCenterX+ strong,iCenterY+ size};
pDevice->Clear(1, &rec2, D3DCLEAR_TARGET, xcolor, 1000,  0);
pDevice->Clear(1, &rec3, D3DCLEAR_TARGET, xcolor, 100,  0);
*/
}


Ése es parte de un hack que hice para el Killing Floor :P
#153
Sí, es mejor VarType, no lo hice así porque tenía pereza de crear constantes y asignarles ese número :D :D :D
#154
Gracias por su ayuda, creo que así está bien:

Modulo:
Código (vb) [Seleccionar]

Option Explicit

Public Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (pDst As Any, pSrc As Any, ByVal ByteLen As Long)
Public Declare Function VirtualProtect Lib "kernel32" (lpAddress As Any, ByVal dwSize As Long, ByVal flNewProtect As Long, lpflOldProtect As Long) As Long

Public Const PAGE_EXECUTE_READWRITE As Long = &H40&

Public Function GetMem(ByVal lpAddr As Long, ByVal pData As Long, ByVal dlen As Long) As Boolean
Dim lngOldProtect   As Long

If 0 = VirtualProtect(ByVal lpAddr, dlen, PAGE_EXECUTE_READWRITE, lngOldProtect) Then
   Exit Function
End If

CopyMemory ByVal pData, ByVal lpAddr, dlen
VirtualProtect ByVal lpAddr, dlen, lngOldProtect, lngOldProtect

GetMem = True
End Function

Public Function PutMem(ByVal lpAddr As Long, ByVal pData As Long, ByVal dlen As Long) As Boolean
Dim lngOldProtect   As Long

If 0 = VirtualProtect(ByVal lpAddr, dlen, PAGE_EXECUTE_READWRITE, lngOldProtect) Then
   Exit Function
End If

CopyMemory ByVal lpAddr, ByVal pData, dlen
VirtualProtect ByVal lpAddr, dlen, lngOldProtect, lngOldProtect

PutMem = True
End Function


Código (vb) [Seleccionar]

Option Explicit

'http://msdn.microsoft.com/en-us/library/aa263420(v=vs.60).aspx

'http://www.codeguru.com/vb/gen/vb_misc/algorithms/article.php/c7495/How-Visual-Basic-6-Stores-Data.htm

'http://msdn.microsoft.com/en-us/library/windows/desktop/ms221627(v=vs.85).aspx
'http://msdn.microsoft.com/en-us/library/windows/desktop/ms221069(v=vs.85).aspx
'http://www.roblocher.com/whitepapers/oletypes.aspx

Private Sub Form_Load()
Dim ESI(3 To 6) As Variant
Dim EDI(3 To 6) As Variant

Dim i As Byte

ESI(3) = "2NE1" '255 '32767 '2147483647
ESI(4) = "CL"
ESI(5) = "THE BADDEST FEMALE"
ESI(6) = "This is for all my bad girls around the world, Not bad meaning bad but bad meaning good u know, Let's light it up and let it burn like we don't care, Let em know how it feels damn good to be bad"

'For i = LBound(ESI) To UBound(ESI)
'    MsgBox i & ": " & (ESI(i) = EDI(i)) & vbCrLf & ESI(i) & " = " & EDI(i) & vbCrLf & "ESI: &H" & Hex(VarPtr(ESI(i))) & vbCrLf & "EDI: &H" & Hex(VarPtr(EDI(i)))
'Next i
'Stop

'Call PutMem(VarPtr(EDI(LBound(EDI))), VarPtr(ESI(LBound(ESI))), GetSizeArray(ESI))
Call PutMem(VarPtr(EDI(LBound(EDI))), VarPtr(ESI(LBound(ESI))), GetSizeArray(ESI)) '60 tmb

For i = LBound(ESI) To UBound(ESI)
   MsgBox i & ": " & (ESI(i) = EDI(i)) & vbCrLf & ESI(i) & " = " & EDI(i) & vbCrLf & "ESI: &H" & Hex(VarPtr(ESI(i))) & vbCrLf & "EDI: &H" & Hex(VarPtr(EDI(i)))
Next i
End
End Sub

Private Function GetSizeArray(ByRef vArray)
Dim BaseBytes As Byte

'MsgBox TypeName(vArray)

Select Case TypeName(vArray)
   Case "Byte()"
       BaseBytes = 1
   Case "Boolean()", "Integer()"
       BaseBytes = 2
   Case "Long()", "Single()"
       BaseBytes = 4
   Case "Double()", "Currency()", "Date()"
       BaseBytes = 8
   Case "Variant()"
       'The variant is 16 bytes large.
       'It has 2 bytes to describe the type of data it is storing, 6 reserved bytes, and 8 bytes to store the data (each block represents a byte).
       BaseBytes = 16
   Case "String()"
       BaseBytes = 4 'ReadMem del VarPtr está el Address al string con su len 4 bytes antes
End Select

GetSizeArray = BaseBytes * (UBound(vArray) - LBound(vArray) + 1)
End Function
#155
Ya la había visto esa página, pero no funciona como dice ahí, ya que el string son 4 bytes, porque hace referencia a un puntero y no a la longitud del mismo, con hacer mov eax, [strvar] está moviendo el puntero del str hacia eax, lo mismo que hace StrPtr supongo.
#156
Tu dices algo así?

Código (vb) [Seleccionar]

Dim i As Integer

For i = 0 To (List1.ListCount -1)
    Label1(i).Caption = List1.List(i)
Next i
#157
Estaba tratando de mover memoria entre arrays.

Hice este ejemplo, tal vez puedan mejorarlo y/o ayudame con Variant :P

Código (vb) [Seleccionar]

Modulo:
Public Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" _
       (pDst As Any, pSrc As Any, ByVal ByteLen As Long)

Form:
Private Sub Form_Load()
Dim ESI(3 To 6) As Variant
Dim EDI(3 To 6) As Variant

ESI(3) = "asdasdasdasdsd12312331231asdasd" '255 '32767 '2147483647
ESI(4) = ESI(3)
ESI(5) = ESI(3)
ESI(6) = ESI(3)

EDI(3) = 0
EDI(4) = EDI(3)
EDI(5) = EDI(3)
EDI(6) = EDI(3)

CopyMemory EDI(LBound(EDI)), ESI(LBound(ESI)), GetSizeArray(ESI)

Dim i As Byte

For i = LBound(ESI) To UBound(ESI)
   MsgBox i & ": " & (ESI(i) = EDI(i)) & vbCrLf & "&H" & Hex(VarPtr(ESI(i)))
Next i

End
End Sub

Private Function GetSizeArray(ByRef vArray)
Dim BaseBytes As Byte

'MsgBox TypeName(vArray)

Select Case TypeName(vArray)
   Case "Byte()"
       BaseBytes = 1
   Case "Boolean()", "Integer()"
       BaseBytes = 2
   Case "Long()", "Single()"
       BaseBytes = 4
   Case "Double()", "Currency()", "Date()"
       BaseBytes = 8
   Case "Variant()"
       BaseBytes = 0 'DUNNO
   Case "String()"
       BaseBytes = 4 'ReadMem del VarPtr está el Address al string con su len 4 bytes antes
End Select

GetSizeArray = BaseBytes * (UBound(vArray) - LBound(vArray) + 1)
End Function


Edit:
Se podría tomar como un reto *-)
#158
Yo usualmente uso una función que tiene un juego llamado Argentum Online:

Código (vb) [Seleccionar]

Public Function RandomNumber(ByVal LowerBound As Long, ByVal UpperBound As Long) As Long
    'Initialize randomizer
    Randomize Timer
   
    'Generate random number
    RandomNumber = (UpperBound - LowerBound) * Rnd + LowerBound
End Function


Se usa como: var = RandomNumber(1,9)
#159
Hola, me interesa ese tema, me podrías decir a qué te refieres exactamente?; y si es posible un ejemplo con resultado, a ver si puedo ayudar en algo. (Y)
#160
Programación C/C++ / [Resuelto] C++ + ASM
19 Abril 2012, 05:24 AM
Hola, en C++ abrí una etiqueta asm como __asm{}, en la cual dentro quise hacer lo siguiente:

__asm
{
    .... //CÓDIGO

   mov dword ptr [ebx], RetFakeSinPrologo
   .... //MÁS CÓDIGO

RetFakeSinPrologo:
  jmp eax

  .... //MÁS CÓDIGO
}

En la línea del mov dword obtengo el error: "error C2415: improper operand type", en ASM puedo hacerlo así, acá hay alguna forma de lograr éso?

Desde ya muchas gracias.