elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado:


  Mostrar Mensajes
Páginas: [1]
1  Programación / .NET (C#, VB.NET, ASP) / Re: Lectura y Modificación de bytes en: 26 Abril 2015, 17:06 pm
Muchas gracias por contestar

el código funciono correctamente

una ultima pregunta para terminar este tema. al momento de insertar la textura  también necesito insertar los colores de la imagen conocidas como paletas , que van de 32 y 512 bytes , que se leen a partir del offset 20 del archivo

Código
  1. Dim textura() as byte
  2. Dim file as string
  3. Dim tamaño as long
  4. Dim ruta_textura as string
  5. Dim offset as integer
  6. Dim ruta_paleta as string
  7.  
  8. Dim paleta (32)  as byte
  9.  
  10.  
  11. file = "C:/DP00.dat"
  12. ruta_textura = "C:/Player.bin"
  13. ruta_paleta = "C:/Player.tim"
  14.  
  15.  
  16. tamaño = FileLen (ruta_textura)
  17.  
  18. ReDim textura (tamaño) as byte
  19.  
  20.  
  21. open ruta_paleta for binary as #1
  22. Get#1, 20 , paleta
  23. close#1
  24.  
  25. open ruta_textura for binary as #1
  26. Get#1, ,textura
  27. close#1
  28.  
  29. open file for binary as #1
  30. offset = 2068
  31. Put#1, offset, textura
  32. close#1
  33.  
  34. open file for binary as #1
  35. offset = 100144
  36. Put#1, offset, paleta
  37. close#1
  38.  
  39.  
  40. Msgbox"La Textura se ha insertado correctamente en el archivo",vbinformation
  41.  
  42.  


y acá en NET ando algo perdido , me podría ayudar a hacer el código ?


Código
  1. Imports System.IO


Código
  1. Dim datFilePath As String = "D:/GDC_GDJ.bin"
  2.        Dim texFilePath As String = "D:/balon rojo.bin"
  3.        Dim palFilePath As String = "D:/balon rojo.tim"
  4.  
  5.  
  6.        Dim datOffset As Integer = Val(TextBox3.Text)
  7.        Dim palOffset As Integer = Val(TextBox4.Text)
  8.  
  9.        Dim pal As Integer = 20
  10.  
  11.  
  12.        'Leyendo e insertando la Textura ----------------------------------------------------
  13.        Dim texData As Byte() = File.ReadAllBytes(texFilePath)
  14.  
  15.  
  16.        Using datStream As New FileStream(datFilePath, FileMode.Open)
  17.  
  18.            Using datWriter As New BinaryWriter(datStream)
  19.  
  20.                datWriter.Seek(offset:=datOffset, origin:=SeekOrigin.Begin)
  21.                datWriter.Write(buffer:=texData)
  22.                datWriter.Flush()
  23.  
  24.            End Using
  25.  
  26.        End Using
  27.  
  28.        'leyendo e insertando la paleta -------------------------------------------
  29.  
  30.        Dim paleta(32) As Byte
  31.  
  32.        Using datStream As New FileStream(palFilePath, FileMode.Open)
  33.  
  34.            Using datReader As New BinaryReader(datStream)
  35.  
  36.  
  37.                datStream.Seek(offset:=pal, origin:=SeekOrigin.Begin)
  38.                datStream.Read(paleta, 0, 0)
  39.                datStream.Flush()
  40.  
  41.            End Using
  42.  
  43.        End Using
  44.  
  45.        Using datStream As New FileStream(datFilePath, FileMode.Open)
  46.  
  47.            Using datwriter As New BinaryWriter(datStream)
  48.  
  49.                datwriter.Seek(offset:=palOffset, origin:=SeekOrigin.Begin)
  50.                datwriter.Write(buffer:=paleta)
  51.                datwriter.Flush()
  52.  
  53.            End Using
  54.  
  55.        End Using
  56.  
  57.  
  58.        MessageBox.Show("La Textura se ha insertado en el archivo.", "Título",
  59.                        MessageBoxButtons.OK, MessageBoxIcon.Information)
  60.  
  61.    End Sub
  62.  

aun no lo entiendo muy bien , no se si sea con BinaryReader o con cual
Muchas Gracias por todo , Saludos desde Monterrey , Mexico     :D
2  Programación / .NET (C#, VB.NET, ASP) / Lectura y Modificación de bytes en: 25 Abril 2015, 20:02 pm
Hola como están

soy nuevo y recién me registro aquí, apenas me estoy pasando a Vb.NET y no logro entender algunas cosas, maneje mucho el Vb 6.0 y se muy bien todo , pero ahora que ya estoy en NET se me dificulta un poco.

en mis ratos libres hacia aplicaciones en VB6 para juegos  y usaba este fácil código :

Código
  1. Dim textura() as byte
  2. Dim file as string
  3. Dim tamaño as long
  4. Dim ruta_textura as string
  5. Dim offset as integer
  6.  
  7. file = "C:/DP00.dat"
  8. ruta_textura = "C:/Player.bin"
  9.  
  10. tamaño = FileLen (ruta_textura)
  11.  
  12. ReDim textura (tamaño) as byte
  13.  
  14. open ruta_textura for binary as #1
  15. Get#1, ,textura
  16. close#1
  17.  
  18. open file for binary as #1
  19. offset = 2068
  20. Put#1, offset,textura
  21. close#1
  22.  
  23. Msgbox"La Textura se ha insertado correctamente en el archivo",vbinformation
  24.  

Aquí lo que leía era un toda una imagen o cualquier archivo completo y lo insertaba al otro archivo en en el offset que se le asigno  

pero en .NET no encuentro la manera de hacerlo , o por lo menos modificar aunque sea un solo byte

espero y puedan ayudarme con esto ,gracias

Mod: los códigos deben ir en etiquetas GeSHi
Páginas: [1]
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines