Registrarse

[Herramienta] [GBA] Asm compilator

Andrea

Usuario mítico
Good morning, today i would like to share with you the new and, hopefully, definitive assembler i'm working on for two days.
Download: http://www.mediafire.com/download/rv9xghst24trrmy/ASSEMBLER+v.1.0.zip
Now i'm going to explain all features in the tool:


1 - File: Simple drop-down menu containing:
- Open Rom GBA: Open the GBA ROM on which we will work
- Open Routine Asm: If we want to open a previously written asm routine, just use this simple option
- Save Routine Asm: Once you have written the routine on our tool (7), to save it just use this option
- Save Routine bin: Using this option, the tool will allow us to save the compiled routine to a * .bin file.
- Exit: Very simple, close the program.

2 - Debug: This "button", once pushed, will allow us to analyze the routine and, in case of errors, the tool will show them in the "compile" section (8).

3 - Compile: This button will allow us to enter the routine into an offset, this will be written alongside "0x", it must necessarily end with 0,4,8 or C otherwise our routine will not be inserted.

4 - Script CALLASM: A relatively useful option, this button will allow us to enter a callasm script in our ROM.
The routine offset will be specified in the "routine field" described above.
Once this is done, there will be a similar window:

There will be two buttons:
- Find Offset Free: This button will allow to find a free offset in the rom to insert our script
- Enter: Once you have written or found our offset, just tap this button to enter our script!
The script is equal to:
callasm 0xOffset+1
end
5 - Option: With this drop-down menu, are available the following options:
- Text Color: Allows us to choose the color of the text
- Background color: allows us to choose the color of the background
- Reset Colors: Allows us to restore the original colors (black text, white background)
- Static offset: Very important option! If we want to keep the same offset during multiple compilations of the same routine, we will have to tick this option.

6 - Number of line: It will tell us which line the cursor is placed on.

7 - This is the space where we write our routines

8 - Compile: In this part of the tool you will be notified of all errors and "completed" messages!
If we click on one of these errors, the tool will automatically place it in the line it contains!

If you find any kind of bugs, write it in the comments!
 
Última edición:

Andrea

Usuario mítico
Re: Asm compilator

Nueva versión de la herramienta:

Por el momento sólo hay instrucciones de bifurcación (cmp, b ...) que debería ser capaz de sumar en la próxima versión.
V.1.2
-----------------
- Se ha añadido BX comando
- Se ha añadido LSL comando
- Se ha añadido LSR comando
- Agregado de comandos NOP
- Se ha añadido EOR comando
- Se ha añadido LTMIA comando
- Se ha añadido STMIA comando
- Se ha corregido LDR de control de errores
- Almacenar Corregido error compensado LDR
- Solución de error de desbordamiento de LDR
- Añadido ShortcutKeys menú
Download:
ASM COMPILATOR 1.2
 

Andrea

Usuario mítico
Re: Asm compilator

Hola chicos :)
Hace 2-3 días que quería empezar el proyecto porque en mi opinión, parecía incómodo de usar y los botones apareció, en mi opinión, escribiendo lentamente rutina.
Así que me decidí a trabajar y hacer una herramienta sin el uso de los botones por el usuario que lo utiliza, una especie de XSE :)
Aquí está la nueva versión de la herramienta:

Libere una pequeña versión de la herramienta para preguntar si usted se siente como esta versión, y especialmente si usted los encuentra reportan errores.
Por el momento la herramienta disponde siguientes seis comandos:
PUSH
POP
LDR
MOV
SWI
BX
añadiendo comentarios usando / / o / *
depuración operación también se espera la presentación de informes de error relativo :)
Descarga:
Asm Compilator 0.1
 

Cheve

MoonLover~
Miembro de honor
Respuesta: Asm compilator

Bueno, está muy buena la herrramienta, con ésto ya no hay excusas, solo queda aprender ASM y listo, está genial y espero que sigas sacando más versiones, así me gusta más y el mouse durará mas tiempo con menos clics :p
 

Andrea

Usuario mítico
Re: Asm compilator

Hola a todos y Feliz Navidad;)
Hoy he decidido liberar la última versión de esta herramienta, después de lo cual voy a trabajar con otras herramientas para hackear y es de esperar :)

aquí son las funciones de esta herramienta:
Comandos disponibles:
LDR, LDRB, LDRH, MOV, STR, STRB, STRH, ADD, SUB, MUL, LSL, LSR, BX, SWI, NOP
- Capacidad para abrir todos los romaníes en todos los idiomas
- Posibilidad de guardar sus rutinas (* Asm) Escrito con la herramienta
- Posibilidad de rutina de apertura (* Asm)
- Capacidad para compilar la rutina dentro la rom
- Posibilidad de añadir comentarios en la rutina, ignoradas por el compilador
- Algunas rutinas se incluyen en la herramienta como ejemplos
- Herramienta Calculadora incluye con decimales converso esadevimale, hexadecimal-decimal
Descarga:
Asm Compilator
Esperaba que te guste :)
 

Keltill

Pinches furros
Respuesta: Asm compilator

Pinta muy muy bien, una preguntilla: Para hackers novatos, ¿El uso de ASM es mas dificil que los metodos "de toda la vida" o facilita bastante el trabajo?

Saludos y gracias por el aporte Andrea.
 
Respuesta: Asm compilator

Perdonen mi ignorancia, pero
¿Que puedo hacer con esta herramienta?
¿Que es eso de rutina ASM?
¿Para que juego funciona?

Que alguien me explique que no entendi...
 

Andrea

Usuario mítico
Re: Asm compilator

well, with this tool you wrote asn insert in to rom ASM routine. when you wrote the asm routine you are making istruction can do to the microprocessor.
The Asm are acronim of ASSEMBLY and is a low language with which the Rom has been programmed.
All pokemon games has been programmed with C ;)
 

Lunos

Enfrentando a La Organización
¡WOAH! ¡THIS IS FREAKING AWESOME!
I usually have a really hard time when trying to insert a Routine because of the hooks and change of values and stuff.
I'm definitely going to try this tool <3

Btw, @Andrea, Did you thought about posting it in PokeCommunity's Tools Section?
I'm sure you could get a really useful feedback <3
 

Andrea

Usuario mítico
Since some users have asked to me to publish the source code of this tool, here's the following:
The program was written in Visual Basic.
1. The first part of the code is a "library" where there are two functions; the first checks if the offset that we are attempting to access to enter the routine is free; the second one, instead, seeks out a free offset inside the rom.
Imports System.IO
Module Module1
Public rom As New OpenFileDialog
Public offset_f, free, start As Integer
Public listbox_click, isfree As Boolean
Public size_rom As System.IO.FileInfo
Public Sub checkfreespace(ByVal size_file As Integer)
isfree = False
free = 0 'free inizializzato a 0, quantità byte da ricercare
Dim fs As New FileStream(rom.FileName, FileMode.Open, FileAccess.ReadWrite, FileShare.ReadWrite)
fs.Position = offset_f
Do While free <= size_file 'questo offset ha 5 byte liberi
If fs.ReadByte() <> 255 Then
offset_f -= free
isfree = False 'se il byte è diverso da FF non è libero
fs.Dispose()
fs.Close()
Return
End If
offset_f += 1
If offset_f >= size_rom.Length Then
fs.Dispose()
fs.Close()
Return
End If
free += 1
Loop
fs.Dispose()
fs.Close()
offset_f -= free
isfree = True
End Sub
Public Sub findfreespace(ByVal size_file As Integer)
free = 0 'free inizializzato a 0, quantità byte da ricercare
Dim fs As New FileStream(rom.FileName, FileMode.Open, FileAccess.ReadWrite, FileShare.ReadWrite)
fs.Position = offset_f
Do While free < size_file 'trova offset con numero byte liberi
If fs.ReadByte() = 255 Then
free += 1 'aggiungo +1 a free
Else
free = 0 'altrimenti lo setto a 0
End If
If offset_f >= size_rom.Length Then
fs.Dispose()
fs.Close()
Return
End If
offset_f += 1
Loop
fs.Dispose()
fs.Close()
offset_f -= free 'trovo l'offset effettivo
End Sub

End Module
2. The second part of the code focuses on managing the main interface of the tool:
Imports System.IO
Public Class Form1
Public first As Integer
Dim compilazione As Boolean
Dim s As String = String.Empty
Dim routine As New OpenFileDialog
Dim save_routine As New SaveFileDialog
Dim save_bin As New SaveFileDialog
Dim sizee As System.IO.FileInfo

Private Sub findfreespace_aligned(ByVal size_file As Integer)
offset_f = System.Convert.ToInt32(ToolStripTextBox1.Text, 16) 'converto l'offset in decimale
start = 0 'offset copia per trovare l'offset di partenza allineato
free = 0 'free inizializzato a 0, quantità byte da ricercare
Dim fs As New FileStream(rom.FileName, FileMode.Open, FileAccess.ReadWrite, FileShare.ReadWrite)
fs.Position = offset_f
Do While free < size_file 'trova offset con numero byte liberi
If fs.ReadByte() = 255 Then 'se trovo FF
If offset_f Mod 4 = 0 Then 'controllo se l'offset è allineato
If start = 0 Then start = offset_f 'se è 0 inserisco l'offset
End If
If start <> 0 Then free += 1
Else
start = 0
free = 0 'altrimenti lo setto a 0
End If
If offset_f >= size_rom.Length Then
fs.Dispose()
fs.Close()
Return
End If
offset_f += 1
Loop
fs.Dispose()
fs.Close()
ToolStripTextBox1.Text = Convert.ToString(start, 16) 'lo metto nella textbox
offset_f = start
End Sub

Private Sub EsciToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles EsciToolStripMenuItem.Click
End
End Sub

Private Sub inserisci_routine()
Dim fs As New FileStream(rom.FileName, FileMode.Open, FileAccess.ReadWrite, FileShare.ReadWrite)
Dim fs_routine As New FileStream(Application.StartupPath & "\temp.bin", FileMode.Open, FileAccess.ReadWrite, FileShare.ReadWrite)
fs.Position = offset_f
Dim i As Integer = 0
fs_routine.Position = i
For i = 0 To sizee.Length - 1
fs.WriteByte(fs_routine.ReadByte()) 'leggo il byte e successivamente lo scrivo
Next
fs_routine.Dispose()
fs_routine.Close()
fs.Dispose()
fs.Close()
ListBox1.Items.Add("Routine asm compilata correttamente all'offset 0x" & ToolStripTextBox1.Text)
listbox_click = False
End Sub
Private Sub compila_routine()
listbox_click = True
compilazione = False
If Not My.Computer.FileSystem.FileExists(Application.StartupPath & "\as.exe") Then 'controllo se è presente l'assemblatore
MsgBox("ASSEMBLER: Assemblatore 'AS.EXE' mancante")
Else
If Not My.Computer.FileSystem.FileExists(Application.StartupPath & "\objcopy.exe") Then 'controllo se è presente l'objcopy
MsgBox("ASSEMBLER: 'OBJCOPY.EXE' mancante")
Else
If Not My.Computer.FileSystem.FileExists(Application.StartupPath & "\thumb.bat") Then 'controllo se è presente il file batch
MsgBox("ASSEMBLER: File 'THUMB.BAT' mancante")
Else
If Not My.Computer.FileSystem.FileExists(Application.StartupPath & "\temp.asm") Then 'controllo se è presente il file batch
MsgBox("ASSEMBLER: 'TEMP.ASM' mancante")
Else
If RichTextBox1.Text = "" Then
MsgBox("ASSEMBLER: Nessuna routine asm scritta")
Else
If RichTextBox1.Lines(RichTextBox1.Lines.Count - 1) <> "" Then RichTextBox1.Text += vbNewLine 'aggiungo nuova linea se mancante
System.IO.File.WriteAllText(Application.StartupPath & "\temp.asm", RichTextBox1.Text)
Dim bat As New ProcessStartInfo(Application.StartupPath & "\thumb.bat")
bat.RedirectStandardError = True
bat.RedirectStandardOutput = True
bat.CreateNoWindow = True
bat.WindowStyle = ProcessWindowStyle.Hidden
bat.UseShellExecute = False
bat.Arguments = "temp.asm"
Dim process As Process = process.Start(bat)
Dim output As String = process.StandardError.ReadToEnd()
Dim errore As Integer = 0 'numero di errori nella routine
Dim strList As New List(Of String)
Using reader As New StringReader(output) 'lista di stringhe
While reader.Peek() <> -1
strList.Add(reader.ReadLine())
errore += 1 'aggiungo +1 ad errore
End While
End Using
For i As Integer = 1 To errore - 1
ListBox1.Items.Add(strList(i)) 'aggiungi
Next
If output = "" Then
compilazione = True
listbox_click = False
End If
sizee = My.Computer.FileSystem.GetFileInfo(Application.StartupPath & "\temp.bin")
End If
End If
End If
End If
End If
End Sub
Private Sub ColoreTestoToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ColoreTestoToolStripMenuItem.Click
Dim colore As ColorDialog = New ColorDialog
colore.Color = RichTextBox1.ForeColor
If colore.ShowDialog = Windows.Forms.DialogResult.OK Then RichTextBox1.ForeColor = colore.Color
End Sub

Private Sub ColoreSfondoToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ColoreSfondoToolStripMenuItem.Click
Dim colore As ColorDialog = New ColorDialog
colore.Color = RichTextBox1.ForeColor
If colore.ShowDialog = Windows.Forms.DialogResult.OK Then RichTextBox1.BackColor = colore.Color
End Sub

Private Sub ApriRomGBAGBAToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ApriRomGBAGBAToolStripMenuItem.Click
ListBox1.Items.Clear()
rom.Title = "Apri ROM GBA"
rom.FileName = ""
rom.Filter = "ROM GBA (*.GBA)|*.gba"
If rom.ShowDialog = Windows.Forms.DialogResult.OK Then
size_rom = My.Computer.FileSystem.GetFileInfo(rom.FileName)
enablemenu()
Else
disable()
End If
End Sub
Private Sub enablemenu()
XToolStripMenuItem.Enabled = True
CompilaToolStripMenuItem.Enabled = True
ToolStripTextBox1.Enabled = True
InserireScriptCALLASMToolStripMenuItem.Enabled = True
End Sub
Private Sub disable()
XToolStripMenuItem.Enabled = False
CompilaToolStripMenuItem.Enabled = False
ToolStripTextBox1.Text = ""
ToolStripTextBox1.Enabled = False
InserireScriptCALLASMToolStripMenuItem.Enabled = False
End Sub
Private Sub ReimpostaColoriToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ReimpostaColoriToolStripMenuItem.Click
RichTextBox1.BackColor = Color.White
RichTextBox1.ForeColor = Color.Black
End Sub

Private Sub RichTextBox1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles RichTextBox1.Click
LineaToolStripMenuItem.Text = RichTextBox1.GetLineFromCharIndex(RichTextBox1.SelectionStart) + 1
End Sub

Private Sub RichTextBox1_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles RichTextBox1.KeyUp
LineaToolStripMenuItem.Text = RichTextBox1.GetLineFromCharIndex(RichTextBox1.SelectionStart) + 1
End Sub

Private Sub RichTextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RichTextBox1.TextChanged
LineaToolStripMenuItem.Text = RichTextBox1.GetLineFromCharIndex(RichTextBox1.SelectionStart) + 1
End Sub

Private Sub ApriRoutineAsmASMToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ApriRoutineAsmASMToolStripMenuItem.Click
routine.Title = "Apri Routine ASM"
routine.FileName = ""
routine.Filter = "Routine ASM (*.asm)|*.asm"
If routine.ShowDialog = Windows.Forms.DialogResult.OK Then
RichTextBox1.LoadFile(routine.FileName, RichTextBoxStreamType.PlainText)
End If
End Sub

Private Sub SalvaRoutineAsmASMToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SalvaRoutineAsmASMToolStripMenuItem.Click
save_routine.Title = "Salva Routine ASM"
save_routine.FileName = ""
save_routine.Filter = "Routine ASM (*.asm)|*.asm"
If RichTextBox1.Text = "" Then
MsgBox("ASSEMBLER: NESSUNA ROUTINE ASM SCRITTA")
Else
If save_routine.ShowDialog = Windows.Forms.DialogResult.OK Then
RichTextBox1.SaveFile(save_routine.FileName, RichTextBoxStreamType.PlainText)
End If
End If
End Sub

Private Sub SalvaRoutineBinBINToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SalvaRoutineBinBINToolStripMenuItem.Click
compila_routine()
If compilazione = True Then 'se la compilazione è avvenuta senza errori
save_routine.Title = "Salva file bin"
save_routine.FileName = ""
save_routine.Filter = "File bin (*.BIN)|*.bin"
If save_routine.ShowDialog = Windows.Forms.DialogResult.OK Then
System.IO.File.Copy(Application.StartupPath & "\temp.bin", save_routine.FileName)
End If
End If
End Sub

Private Sub ListBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListBox1.SelectedIndexChanged
If listbox_click = True Then
get_line_number()
If first <= RichTextBox1.Lines.Count Then
RichTextBox1.Select(RichTextBox1.GetFirstCharIndexFromLine(first - 1) + RichTextBox1.Lines(first - 1).Length, 0)
RichTextBox1.Focus()
LineaToolStripMenuItem.Text = RichTextBox1.GetLineFromCharIndex(RichTextBox1.SelectionStart) + 1
End If
'posiziono il cursore nella linea in cui è presente l'errore
'ottengo il numero del carattere della linea, a questo aggiungo la lunghezza della linea stessa
End If
End Sub

Private Sub get_line_number()
Dim i As Integer = 0
first = 0
While (s <> ":")
s = GetChar(ListBox1.Items(ListBox1.SelectedIndex).ToString(), 10 + i)
If (s <> ":") Then i += 1
End While
Dim mask As Integer = 1
While (i > 0)
s = GetChar(ListBox1.Items(ListBox1.SelectedIndex).ToString(), 10 + i - 1)
i -= 1
first += Convert.ToInt16(s) * mask
mask *= 10
End While
End Sub

Private Sub ToolStripTextBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles ToolStripTextBox1.KeyPress
If Not "1234567890abcdefABCDEF".Contains(Char.ToUpper(e.KeyChar)) AndAlso e.KeyChar <> vbBack Then e.Handled = True
End Sub

Private Sub DebugToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DebugToolStripMenuItem.Click
ListBox1.Items.Clear()
compila_routine()
If compilazione = True Then
ListBox1.Items.Add("La routine non contiene errori!")
End If
End Sub

Private Sub OffsetStaticoToolStripMenuItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)

End Sub

Private Sub OffsetStaticoToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OffsetStaticoToolStripMenuItem.Click
If OffsetStaticoToolStripMenuItem.Checked = True Then
OffsetStaticoToolStripMenuItem.Checked = False
Else
OffsetStaticoToolStripMenuItem.Checked = True
End If
End Sub

Private Sub InserireScriptCALLASM1ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles InserireScriptCALLASMToolStripMenuItem.Click
If IO.File.Exists(rom.FileName) = True Then
If ToolStripTextBox1.Text = "" Then
MsgBox("ASSEMBLER: Offset routine non specificato")
Else
Form2.Show()
End If
Else
MsgBox("ASSEMBLER: La ROM, a cui si sta cercando di accedere, è inesistente")
End If
End Sub

Private Sub CompilaToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CompilaToolStripMenuItem.Click
If IO.File.Exists(rom.FileName) = True Then 'controllo se la rom è esistente
If ToolStripTextBox1.Text = "" Then
MsgBox("ASSEMBLER: Nessun offset specificato")
Else
ListBox1.Items.Clear()
offset_f = System.Convert.ToInt32(ToolStripTextBox1.Text, 16) 'converto l'offset in decimale
If offset_f Mod 4 = 0 Then 'controllo se l'offset è allineato
If OffsetStaticoToolStripMenuItem.Checked = True Then 'controllo se l'offset è statico
compila_routine()
If compilazione = True Then
If (offset_f + sizee.Length - 1) > size_rom.Length Then 'se l'offset supera l'offset della fine della rom
MsgBox("ASSEMBLER: Impossibile compilare la routine, spazio insufficente")
Else
inserisci_routine() 'inserisco la routine
End If
End If
Else
compila_routine() 'se è libero sovrascrivo i byte
If compilazione = True Then
checkfreespace(sizee.Length) 'altrimenti controllo se l'offset è libero
If (offset_f + sizee.Length - 1) > size_rom.Length Then 'se l'offset supera l'offset della fine della rom
MsgBox("ASSEMBLER: Impossibile compilare la routine, spazio insufficente")
Else
If isfree = False Then 'se non è libero chiedo all'utente se vuole sovrascrivere i byte
Dim risp As MsgBoxResult = MsgBox("L'offset corrente non è libero, vuoi sovrascrivere i byte?", MsgBoxStyle.YesNo, "ASSEMBLER")
If risp = MsgBoxResult.Yes Then ' User chose Yes.
inserisci_routine() 'se risponde sì inserisco la routine
Else
risp = MsgBox("Vuoi che il programma inserisca la routine in un offset libero?", MsgBoxStyle.YesNo, "ASSEMBLER")
If risp = MsgBoxResult.Yes Then ' User chose Yes.
findfreespace_aligned(sizee.Length - 1) 'cerco l'offset
If offset_f >= size_rom.Length Then 'se l'offset supera l'offset della fine della rom
MsgBox("ASSEMBLER: Impossibile trovare un offset libero, spazio insufficente")
Else
ToolStripTextBox1.Text = Convert.ToString(offset_f, 16) 'lo metto nella textbox
offset_f = System.Convert.ToInt32(ToolStripTextBox1.Text, 16) 'converto l'offset in decimale
inserisci_routine() 'inserisco la routine
End If
End If
End If
Else
inserisci_routine() 'inserisco la routine
End If
End If
End If
End If
Else
MsgBox("ASSEMBLER: L'offset deve terminare con 0,4,8 o C")
End If
End If
Else
MsgBox("ASSEMBLER: La ROM, a cui si sta cercando di accedere, è inesistente")
End If
End Sub
End Class
3. Finally, the last part of the code manages the interface to insert a callasm script in the ROM:
Imports System.IO
Public Class Form2
Dim callasm(5) As Byte '6 byte per script callasm, [23][4 byte XX XX XX 08] [02]

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
listbox_click = True
If TextBox1.Text = "" Then
MsgBox("ASSEMBLER: Nessun offset specificato")
Else
Form1.ListBox1.Items.Clear()
offset_f = System.Convert.ToInt32(TextBox1.Text, 16) 'converto l'offset in decimale
checkfreespace(6) 'controllo se l'offset è libero
If (offset_f + 6) <= size_rom.Length Then
If isfree = False Then 'se non è libero chiedo all'utente se vuole sovrascrivere i byte
Dim risp As MsgBoxResult = MsgBox("L'offset corrente non è libero, vuoi sovrascrivere i byte?", MsgBoxStyle.YesNo, "ASSEMBLER")
If risp = MsgBoxResult.Yes Then ' User chose Yes.
write_callasm() 'se è libero sovrascrivo i byte
Else 'se risponde non chiedo se vuole cercare un nuovo offset libero
risp = MsgBox("Vuoi che il programma inserisca lo script in un offset libero?", MsgBoxStyle.YesNo, "ASSEMBLER")
If risp = MsgBoxResult.Yes Then ' User chose Yes.
offset_f = System.Convert.ToInt32(TextBox1.Text, 16) 'converto l'offset in decimale
findfreespace(6) 'cerco l'offset
TextBox1.Text = Convert.ToString(offset_f, 16)
write_callasm() 'se è libero sovrascrivo i byte
End If
End If
Else
write_callasm() 'se è libero sovrascrivo i byte
End If
Else
MsgBox("ASSEMBLER: Impossibile inserire lo script, spazio insufficente")
End If
End If
End Sub

Private Sub write_callasm()
offset_f = System.Convert.ToInt32(Form1.ToolStripTextBox1.Text, 16) 'offset routine asm
Dim offset As Integer = System.Convert.ToInt32(TextBox1.Text, 16) 'converto l'offset in decimale
Dim fs As New FileStream(rom.FileName, FileMode.Open, FileAccess.ReadWrite, FileShare.ReadWrite)
fs.Position = offset
callasm(0) = 35 'CALLASM
callasm(1) = offset_f + 1 And 255
callasm(2) = (offset_f + 1 >> 8) And 255
callasm(3) = (offset_f + 1 >> 16) And 255
callasm(4) = 8 'ROM
callasm(5) = 2 'END SCRIPT
For i As Integer = 0 To 5
fs.WriteByte(callasm(i)) 'write script
Next
fs.Dispose()
fs.Close()
Form1.ListBox1.Items.Add("Script inserito correttamente all'offset 0x" & TextBox1.Text)
listbox_click = False
Me.Close() 'chiudo il form una volta inserito lo script
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If TextBox1.Text = "" Then
offset_f = 0 'se è vuoto parto dall'offset 0
Else
offset_f = System.Convert.ToInt32(TextBox1.Text, 16) 'converto l'offset in decimale
End If
findfreespace(6) 'cerco l'offset
If offset_f + 6 > size_rom.Length Then 'se l'offset +6 allora non metto l'offset
TextBox1.Text = ""
Else
TextBox1.Text = Convert.ToString(offset_f, 16)
End If
End Sub

Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
If Not "1234567890abcdefABCDEF".Contains(Char.ToUpper(e.KeyChar)) AndAlso e.KeyChar <> vbBack Then e.Handled = True
End Sub

End Class
Hope you will be useful for developing your own tools!
 
Arriba