8
« on: December 08, 2017 »
hi all,
i send you a single Exe Patcher source where i 'm trying to display starfield effect into a window with gadgets,
i can't manage to have all the stuff at same time,
i know how to use EP_fxlib to display starfield with MP_Graphics3DWindow but not with OpenWindow() and OpenWindowedScreen()
in capture1 , you can see my main windows with an openwindowedscreen where i want to display stars ....
if i take out comments before MP_RenderWorld() and MP_Flip () i obtain an invalid memory access
thanks for your advices
in this code, you have also an example to extract a .mp3 sound from DataSection and use it with FMOD without dropping on the disk , can be usefull
IncludeFile "fmodex-min.pbi"
#FMOD_OPENMEMORY = $00000800
Enumeration
#chiptune
#scroll
#wmain
EndEnumeration
Structure FMOD_CREATESOUNDEXINFO
cbsize.i
length.i
params.i[32]
EndStructure
Global fmodsystem.i, Channel.i, i.i, j.i
Global Dim Sounds(1)
Define szFile.s
Define szOut.s
Define dwSize.l
Define lFF.l
Define Text_offsetV.i
InitSprite()
EP_InitFXLib()
OpenWindow(#wmain,150,50,500,360,"Single .EXE Dynamic patcher Jmg@2017 Esc to quit", #PB_Window_ScreenCentered)
;MP_Graphics3DWindow(150,50,50,30,"Metasploit Meterpreter Dynamic patcher Jmg@2017 Esc to quit", #PB_Window_ScreenCentered)
SetWindowColor(#wmain,RGB(14, 10, 100))
OpenWindowedScreen(WindowID(#wmain),10,120,480,180)
Text_File = TextGadget(#PB_Any, 150, 15, 290, 20, "", #PB_Text_Border)
Text_f1= TextGadget(#PB_Any, 50, 20, 30, 20, "File")
SetGadgetColor(Text_f1,#PB_Gadget_FrontColor,RGB(154, 154, 154))
SetGadgetColor(Text_f1,#PB_Gadget_BackColor,RGB(14, 10, 100))
Text_offsetC= TextGadget(#PB_Any, 50, 50, 90, 20, "Decimal Offset :")
SetGadgetColor(Text_offsetC,#PB_Gadget_BackColor,RGB(14, 10, 100))
SetGadgetColor(Text_offsetC,#PB_Gadget_FrontColor,RGB(154, 154, 154))
Text_offsetV= EditorGadget(#PB_Any, 150, 45, 90, 20)
Text_valueC=TextGadget(#PB_Any, 50, 80, 90, 20, "Decimal Value :")
SetGadgetColor(Text_valueC,#PB_Gadget_BackColor,RGB(14, 10, 100))
SetGadgetColor(Text_valueC,#PB_Gadget_FrontColor,RGB(154, 154, 154))
Text_valueV =EditorGadget(#PB_Any, 150, 75, 90, 20)
Button_SelectFile = ButtonGadget(#PB_Any, 50, 320, 140, 20, "Select File")
Button_PatchFile = ButtonGadget(#PB_Any, 310, 320, 140, 20, "Patch File")
EP_Init2DStars(200,7,1.3,0,0,640,480)
EP_2DStarsColor(1,RGB(255,0,0))
EP_2DStarsColor(2,RGB(0,255,0))
Procedure FMOD_DataSectionLoadSound(SoundId, SoundLocStart, SoundLocEnd)
Protected exinfo.FMOD_CREATESOUNDEXINFO
exinfo\cbSize = SizeOf(FMOD_CREATESOUNDEXINFO)
exinfo\Length = SoundLocEnd - SoundLocStart
FMOD_System_CreateStream(FmodSystem, SoundLocStart, #FMOD_SOFTWARE | #FMOD_OPENMEMORY, @exinfo, @Sounds(SoundId))
EndProcedure
Procedure.l Patch(file.s,location.l,byte.b)
If OpenFile(0,file)
FileSeek(0,location)
WriteData(0,@byte,1)
CloseFile(0)
ProcedureReturn 1
EndIf
EndProcedure
;----------------Init sound First Part-------------------------------------------------
first:
FMOD_System_Create(@fmodsystem)
FMOD_System_Init(fmodsystem, 32, #FMOD_INIT_NORMAL, 0)
FMOD_DataSectionLoadSound(0, ?chiptune, ?endchiptune)
FMOD_System_PlaySound(fmodsystem, #FMOD_CHANNEL_FREE, Sounds(0), 0, @channel)
Repeat
;event=WindowEvent()
; EP_2DStarsDraw()
Select WindowEvent()
Case #PB_Event_Gadget
Select EventGadget()
Case Button_SelectFile
szFile = OpenFileRequester("Select file to patch", "", "*.*", 0)
If szFile
SetGadgetText(Text_File, szFile)
Else
EndIf
Case Button_PatchFile
offValue= Val(GetGadgetText(Text_offsetV))
byteValue = Val(GetGadgetText(Text_valueV))
; Debug offValue
; Debug byteValue
Patch(szFile, offValue, byteValue )
MessageRequester("Info"," File patched successfully ! ...")
EndSelect
EndSelect
;MP_RenderWorld()
;MP_Flip ()
Until GetAsyncKeyState_(#VK_ESCAPE)
DataSection
chiptune:
IncludeBinary "chiptune1.mp3"
endchiptune:
EndDataSection