heres one by Filax sometime back, it requires winblitz3d as it is but you could pull it apart for the patching code, not sure if it will work with the latest version of blitz3d.
;
; WB3D_CreateWindow example
; By Kevin Poole.
; were using external winapi styles
Include "../../../WB3DStyles.bb"
; setup gfx mode.
Graphics3D 640,480,16,2
; install winblitz3d.
Global RuntimeWindow_hWnd = WB3D_InitializeGUI(SystemProperty("AppHwnd"),10,10,500,500)
WB3D_SetQuitMessage "WinBlitz3D 3D/GUI","Sure To Quit"
WB3D_HideGadget RuntimeWindow_hWnd
; create winapi window, setting its title, and position on screen. use default style creation.
MyWindow = WB3D_CreateWindow("WB3D_CreateWindow Example",200,100,275,275,0,WS_VISIBLE Or WS_SYSMENU Or WS_CAPTION)
; cleanup any old creation events, its better to do this before we enter the main
; event loop, when some gadgets are created they generate events.
WB3D_FlushEvents
LoadExe = WB3D_CreateButton("Open blitz exe to hack",10,10,250,25,MyWindow,0)
WB3D_DefaultGadgetFont LoadExe
Listbox = WB3D_CreateListBox(10,40,250,190,MyWindow,0)
; setup out quit flag, and loop until the flag is set.
QUIT = 0
While Not QUIT = 1
; generate an internal blitz event
Flip
; get an event of the event queue.
event = WB3D_WaitEvent()
Select event
Case WB3D_EVENT_GADGET
selected = WB3D_EventSource()
Select selected
Case LoadExe
Filename$ = WB3D_OpenFileRequest("Open file","",example_file_ext$,WB3D_GetGadgetText(example_init_filename))
WB3D_ClearGadgetItems Listbox
If Filename$<> "" Then
fil=OpenFile(Filename$)
WB3D_AddGadgetItem Listbox,"Opening executable file",0,0
If fil
siz=FileSize(Filename$)
For i=0 To siz
byt=ReadByte(fil)
If Frst
If scnd
If byt=$8B
pos=i-1
Exit
Else
scnd=False
If byt<>$CA frst=False
EndIf
ElseIf byt=$10
scnd=True
Else
If byt<>$CA Frst=False
EndIf
ElseIf byt=$CA
Frst=True
EndIf
Next
WB3D_AddGadgetItem Listbox,"Patching executable file",0,0
SeekFile fil,pos
WriteByte fil,$00
WB3D_AddGadgetItem Listbox,"Process completed",0,0
CloseFile fil
WB3D_AddGadgetItem Listbox,"Close file",0,0
EndIf
EndIf
End Select
Case WB3D_EVENT_KEYPRESS
; wb_eventdata holds the key code that was pressed.
keypressed = WB3D_EventData()
Select keypressed
Case WB3D_KEY_ESCAPE
; set the flag to leave the loop.
QUIT = 1
End Select
Case WB3D_EVENT_WINDOW_CLOSE
; wb3d_eventsource hold the handle to the window that close button was selected
window = WB3D_EventSource()
Select window
Case MyWindow
; set the flag to leave the loop.
QUIT = 1
End Select
End Select
Wend
; use notify using external winapi constants.
WB3D_EndGUI()
EndGraphics
End
|