'================================================================= '===== DEBUGGER FOR FREEBASIC === (C) 2006-2017 Laurent GRAS ===== '================================================================= #Define fbdebuggerversion "V 2.92" '#Define fulldbg_prt 'uncomment to get more information '#Define dbg_prt2 dbg_prt 'used temporary for debugging fbdebugger, should be commented to avoid unuseful outputs #Include Once "windows.bi" #Include Once "win\commctrl.bi" #Include Once "win\commdlg.bi" #Include Once "win\wingdi.bi" #Include Once "win\richedit.bi" #Include Once "win\tlhelp32.bi" #Include Once "win\shellapi.bi" #Include Once "win\psapi.bi" #Include Once "file.bi" 'define data 64bit/32bit #Ifdef __FB_64BIT__ #Define regip rip #Define regbp rbp #Define regsp rsp #Define ver3264 "(64bit) " #Else #Define regip eip #Define regbp ebp #Define regsp esp #Define ver3264 "(32bit) " #EndIf #Define MAXSRCSIZE 500000 'max source size #Define MAX_STAB_SZ 60000 'max stabs string '20/07/2014 ' if they are not already defined #Ifndef EXCEPTION_DEBUG_EVENT #Define EXCEPTION_DEBUG_EVENT 1 #define CREATE_THREAD_DEBUG_EVENT 2 #define CREATE_PROCESS_DEBUG_EVENT 3 #define EXIT_THREAD_DEBUG_EVENT 4 #define EXIT_PROCESS_DEBUG_EVENT 5 #define LOAD_DLL_DEBUG_EVENT 6 #define UNLOAD_DLL_DEBUG_EVENT 7 #define OUTPUT_DEBUG_STRING_EVENT 8 #define RIP_EVENT 9 ''' DUPLICATE #define DBG_CONTINUE &h00010002 #define DBG_TERMINATE_THREAD &h40010003 #define DBG_TERMINATE_PROCESS &h40010004 #define DBG_CONTROL_C &h40010005 #define DBG_CONTROL_BREAK &h40010008 #EndIf ' DBG_EXCEPTION_NOT_HANDLED = &H80010001 #Define EXCEPTION_GUARD_PAGE_VIOLATION &H80000001 #Define EXCEPTION_NO_MEMORY &HC0000017 #Define EXCEPTION_FLOAT_DENORMAL_OPERAND &HC000008D #Define EXCEPTION_FLOAT_DIVIDE_BY_ZERO &HC000008E #Define EXCEPTION_FLOAT_INEXACT_RESULT &HC000008F #Define EXCEPTION_FLOAT_INVALID_OPERATION &HC0000090 #Define EXCEPTION_FLOAT_OVERFLOW &HC0000091 #Define EXCEPTION_FLOAT_STACK_CHECK &HC0000092 #Define EXCEPTION_FLOAT_UNDERFLOW &HC0000093 #Define EXCEPTION_INTEGER_DIVIDE_BY_ZERO &HC0000094 #Define EXCEPTION_INTEGER_OVERFLOW &HC0000095 #Define EXCEPTION_PRIVILEGED_INSTRUCTION &HC0000096 #Define EXCEPTION_CONTROL_C_EXIT &HC000013A 'take l char form a string and complete with spaces if needed #Define fmt(t,l) Left(t,l)+Space(l-Len(t))+" " #Define fmt2(t,l) Left(t,l)+Space(l-Len(t)) #Define UM_CHECKSTATECHANGE (WM_USER + 100) 'for checkboxes #define UM_FOCUSSRC (WM_USER + 101) 'for focus source #define RGBA_R( c ) ( c Shr 16 And 255 ) #define RGBA_G( c ) ( c Shr 8 And 255 ) #define RGBA_B( c ) ( c And 255 ) 'for use of htmlhelp #Ifndef HH_DISPLAY_TOPIC #Define HH_DISPLAY_TOPIC 0000 #Define HH_HELP_CONTEXT 0015 #EndIf 'for use show char at a given position #Define AFFMAX 40 #Define AFFMAX2 AFFMAX*2 #Define RECUPMAX 1000 #Define TYPESTD 16 ''upper limit for standard type, now 16 for boolean 20/08/2015 'buttons main screen Const IDBUTSTEP = 101 Const IDBUTSTEPP = 102 Const IDBUTSTEPM = 103 Const IDBUTAUTO = 104 Const IDBUTRUN = 105 Const IDBUTSTOP = 106 Const IDBUTMINI = 107 Const IDBUTFREE = 108 Const IDBUTTOOL = 109 Const IDBUTFILE = 110 Const IDBUTRRUNE = 111 Const IDBUTATTCH = 112 Const IDBUTKILL = 113 Const IDNOTES = 114 Const IDLSTEXE = 115 Const IDFASTRUN = 116 Const IDEXEMOD = 117 Const IDBUTSTEPB = 118 Const IDBUTSTEPT = 119 Const IDWATCH1 = 120 Const IDWATCH2 = 121 Const IDWATCH3 = 122 Const IDWATCH4 = 123 Const IDBRKVAR = 124 Const IDCURLIG = 125 Const IDBMKCMB = 126 Const IDDUMP = 127 Const ENLRSRC =130 Const ENLRVAR =131 Const ENLRMEM =132 Const IDVCLPSE =133 Const IDVEXPND =134 Const IDFNDTXUP =135 Const IDFNDTXDW =136 Const IDFNDTXCS =137 Const IDRICHWIN =200 Const IDNOTEWIN =201 Const IDSTATUS =202 ' ID for TAB Const TAB1=210 Const TAB2=211 Const TVIEW1=220 Const TVIEW2=221 Const TVIEW3=222 Const TVIEW4=223 ' ID for dump ' ID for menu source Const IDSETBRK =500 Const IDSETBRT =501 Const IDMNGBRK =502 Const IDCONTHR =503 'used also with button Const IDFNDTXT =504 Const IDTGLBMK =505 Const IDNXTBMK =506 Const IDPRVBMK =507 Const IDADDNOT =508 Const IDGOTO =509 Const IDSHWVAR =510 Const IDSETWVAR=511 Const IDACCLINE=512 Const IDFCSSRC =513 Const IDLINEADR=514 Const IDBRKENB =515 Const IDTHRDAUT=516 'automatic execution alternating threads Const IDLINEASM=517 Const IDPROCASM=518 Const IDREGS =519 '25/08/2015 Const IDSETBRKC=520 '03/09/2015 Const IDCHGBRKC=521 '03/09/2015 Const IDRSTBRKC=522 '03/09/2015 'ID for menu var Const IDVARDMP =530 Const IDVAREDT =531 Const IDVARBRK =532 Const IDSELIDX =533 Const IDSHSTRG =534 Const IDSHWEXP =535 Const IDSETWTCH=536 Const IDSETWTTR=537 Const IDCHGZSTR=538 Const IDCALLINE=539 Const IDLSTVARA=540 'list all proc/variables Const IDLSTVARS=541 'list only selected and below Const IDPBCKTRK=542 'backtraking from proc/var Const IDPCHNING=543 'chaining from proc/var Const IDSHCHAR =544 'show character in a string at a selected position '03/11/2014 Const IDCLBVARA=545 'copy to clipboard all procs/vars '28/11/2014 Const IDCLBVARS=546 'copy to clipboard selected var Const IDPTDUMP =547 'dump deferenced data Const IDFNDVAR =548 'find proc or var in proc/var ''tracking array 2016/06/02 Const IDTRCKIDX0=1500 ''variable used as index Const IDTRCKIDX1=1501 Const IDTRCKIDX2=1502 Const IDTRCKIDX3=1503 Const IDTRCKIDX4=1504 Const IDTRCKARR =1510 ''associate var indexes to an array Const IDTRCKRST =1511 ''reset all 'ID for proc Const IDRSTPRC =550 'reset proc follow Const IDSETPRC =551 'set proc follow Const IDSORTPRC=552 'toggle sort by module name / proc name Const IDASMPRC =553 'listing of asm code of a proc 'ID for thread Const IDTHRDCHG=560 'select thread Const IDLOCPRC =561 'locate proc (also used in menu var and proc) Const IDTHRDKLL=562 'kill thread Const IDEXCLINE=563 'show next executed line Const IDCREATHR=564 'show line creating thread Const IDTHRDLST=565 'list threads Const IDSHWPROC=566 'show proc in proc/var Const IDSHPRSRC=567 'show proc in source Const IDTBCKTRK=568 'backtracking Const IDTCHNING=569 'chaining Const IDTHRDEXP=570 'expand one thread Const IDTHRDCOL=571 'collapse all threads Const IDPRCRADR=572 'addr about running proc start,end stack 'ID for tools Const IDCMDLPRM=580 Const IDDBGHELP=581 Const IDINFOS =582 Const IDABOUT =583 Const IDFILEIDE=584 Const IDQCKEDT =585 Const IDCMPNRUN=586 Const IDWINMSG =587 Const IDSHWBDH =588 Const IDCLIPBRD=589 Const IDDELLOG =590 Const IDSHWLOG =591 Const IDSHENUM =592 Const IDCMPINF =593 Const IDJITDBG =594 Const IDTUTO =595 Const IDLSTDLL =596 Const IDHIDLOG =597 Const IDLSTSHC =598 Const IDFRTIMER=599 'ID for watched var Const IDWCHVAR =620 Const IDWCHDMP =621 Const IDWCHDEL =622 Const IDSTWTCH1=623 Const IDSTWTCH2=624 Const IDSTWTCH3=625 Const IDSTWTCH4=626 Const IDWCHSTG =627 Const IDWCHSHW =628 Const IDWCHEDT =629 Const IDWCHTTGL=630 Const IDWCHTTGA=631 Const IDWCHDALL=632 ' for proc_find / thread Const KFIRST=1 Const KLAST=2 ' when select a var for proc/var or set watched Const PROCVAR=1 Const WATCHED=2 'for dissassembly Const KLINE=1 Const KPROC=2 Const KPROG=3 Const KSPROC=3 Union pointeurs pxxx As Any Ptr pinteger As Integer Ptr puinteger As UInteger Ptr psingle As Single Ptr pdouble As Double Ptr plinteger As LongInt Ptr pulinteger As ULongInt Ptr pbyte As Byte Ptr pubyte As UByte Ptr pshort As Short Ptr pushort As UShort Ptr pstring As String Ptr pzstring As ZString Ptr pwstring As WString Ptr End Union Union valeurs vinteger As Integer vuinteger As UInteger vsingle As Single vdouble As Double vlinteger As LongInt vulinteger As ULongInt vbyte As Byte vubyte As UByte vshort As Short vushort As UShort 'vstring as string 'vzstring as zstring 'vwstring as wstring End Union ' DATA STAB Type udtstab stabs As Integer code As UShort nline As UShort ad As UInteger End Type Enum 'type udt/redim/dim TYUDT TYRDM TYDIM End Enum Enum 'type of running RTRUN RTSTEP RTAUTO RTOFF RTFRUN RTFREE RTEND End Enum Enum NODLL DLL End Enum ' TO CREATE CLASSNAME / tooltips ------------- Dim Shared fb_szAppName As String fb_szAppName="DEBUGGER" Dim Shared fb_hinstance As HINSTANCE Dim Shared fb_hToolTip As HWND Dim Shared crc_table(255) As Integer 'for checksum Dim Shared flaglog As Byte=0 ' flag for dbg_prt 0 --> no output / 1--> only screen / 2-->only file / 3 --> both Dim Shared flagtrace As Byte ' flag for trace mode : 1 proc / +2 line Dim Shared flagverbose As Byte ' flag for verbose mode Dim Shared flagmain As Byte ' flag for first main Dim Shared flagattach As Byte ' flag for attach Dim Shared flagtooltip As Integer =TRUE 'TRUE=activated/FALSE=DESACTIVATED Dim Shared flagrestart As Integer=-1 'flag to indicate restart in fact number of bas files to avoid to reload those files Dim Shared flagwtch As Integer =0 'flag =0 clean watched / 1 no cleaning in case of restart Dim Shared flagfollow As Integer =FALSE 'flag to follow next executed line on focus window Dim Shared flagkill As Integer =FALSE 'flag if killing process to avoid freeze in thread_del Dim Shared flagtuto As Integer 'flag for tutorial -1=no tuto / 2=let execution then return at value 1 / 1=tutorial so no possible command Dim Shared As Integer flagmodule,flagunion 'flag for dwarf Dim Shared As Long dwlastprc,dwlastlnb 'to manage end of proc Dim Shared compinfo As String 'information about compilation Dim Shared hattach As HANDLE 'handle to signal attchement done Dim Shared jitprev As String Dim Shared fasttimer As Double 'GCC Dim Shared As Byte gengcc ' flag for compiled with gcc ReDim Shared As String Trans() Dim Shared As String stringarray 'END GCC Dim Shared As Integer autostep=200 'delay for auto step Enum 'code stop CSSTEP=0 CSCURSOR CSBRKTEMPO CSBRK CSBRKV CSBRKM CSHALTBU CSACCVIOL CSNEWTHRD CSEXCEP '19/05/2014 End Enum Dim Shared stopcode As Integer Dim Shared stoplibel(20) As String*17 =>{"","cursor","tempo break","break","Break var","Break mem"_ ,"Halt by user","Access violation","New thread","Exception"} '19/05/2014 Dim Shared stringadr As Integer ' ------------------------------------------------- Dim Shared pinfo As PROCESS_INFORMATION Dim Shared windmain As HWND Dim Shared tviewcur As HWND 'TV1 ou TV2 ou TV3 Dim Shared tviewvar As HWND 'running proc/var Dim Shared tviewprc As HWND 'all proc Dim Shared tviewthd As HWND 'all threads Dim Shared tviewwch As HWND 'watched variables Dim Shared dbgstatus As HWND Dim Shared recsav As RECT 'save windmain sizes 'for dump Dim Shared listview1 As HWND Dim Shared lvnbcol As Integer Dim Shared lvtyp As Integer =1 Dim Shared hcurline As HWND 'current line Dim Shared butstep As HWND Dim Shared butstepp As HWND Dim Shared butstept As HWND Dim Shared butstepb As HWND Dim Shared butstepm As HWND Dim Shared butcont As HWND Dim Shared Butexemod As HWND Dim Shared butauto As HWND Dim Shared butrun As HWND Dim Shared butfastrun As HWND Dim Shared butstop As HWND Dim Shared butmini As HWND Dim Shared butfree As HWND Dim Shared Buttool As HWND Dim Shared Butfile As HWND Dim Shared Butrrune As HWND Dim Shared Butlstexe As HWND Dim Shared Butattch As HWND Dim Shared Butkill As HWND Dim Shared butenlrsrc As HWND Dim Shared butenlrvar As HWND Dim Shared butnotes As HWND Dim Shared butenlrmem As HWND Dim Shared dbgEdit1 As HWND 'for notes Dim Shared dbgrichedit As HWND 'for rich edit current ''''' dim shared timerid1 as integer 'not used if 2 threads Dim Shared menuRoot As HMENU Dim Shared menuedit As HMENU 'popup menu with richedit Dim Shared menuedit2 As HMENU 'popup sub menu with richedit Dim Shared menuvar As HMENU 'popup menu var/proc Dim Shared menuvar2 As HMENU 'popup sub menu var/proc watched Dim Shared menuvar3 As HMENU 'popup sub menu var/proc copy to log '28/11/2014 Dim Shared menuvar4 As HMENU 'popup sub menu var/proc copy to clipboard Dim Shared menuvar5 As HMENU 'popup sub menu for array tracking ''2016/06/15 Dim Shared menutools As HMENU 'popup menu tools Dim Shared menuproc As HMENU 'popup menu proc Dim Shared menuthread As HMENU 'popup menu thread Dim Shared menuwatch As HMENU 'popup menu watch 'dim shared as integer mnubm 'THREAD Type tthread hd As HANDLE 'handle id As UInteger 'ident pe As Integer 'flag if true indicates proc end sv As Integer 'sav line od As Integer 'previous line nk As UInteger 'for naked proc, stack and used as flag st As Integer 'to keep starting line tv As HTREEITEM 'to keep handle of thread item plt As HTREEITEM 'to keep handle of last proc of thread in proc/var tview ptv As HTREEITEM 'to keep handle of last proc of thread in thread tview exc As Integer 'to indicate execution in case of auto 1=yes, 0=no End Type Const THREADMAX=50 Dim Shared thread(THREADMAX) As tthread Dim Shared threadnb As Integer =-1 Dim Shared threadcur As Integer Dim Shared threadprv As Integer 'previous thread used when mutexunlock released thread or after thread create Dim Shared threadsel As Integer 'thread selected by user, used to send a message if not equal current Dim Shared threadaut As Integer 'number of threads for change when auto executing Dim Shared threadcontext As HANDLE Dim Shared threadhs As HANDLE 'handle thread to resume Dim Shared dbgprocid As Integer 'pinfo.dwProcessId : debugged process id Dim Shared dbgthreadID As Integer 'pinfo.dwThreadId : debugged thread id Dim Shared dbghand As HANDLE 'debugged proc handle Dim Shared dbghthread As HANDLE 'debuggee thread handle Dim Shared dbghfile As HANDLE 'debugged file handle Dim Shared prun As Integer 'indicateur process running Dim Shared curlig As Integer 'current line Dim Shared curtab As UShort =0 'associated wih curlig Dim Shared shwtab As UShort =0 'tab showed could be different of curtab ' compiler,commandline for compilation and for debug Dim Shared As String fbcexe,cmdlfbc,ideexe Dim Shared exename As ZString *300 'debuggee executable Dim Shared exedate As Double 'serial date Dim Shared savexe(9) As String 'last 10 exe, 0=more recent Dim Shared cmdexe(9) As String 'last 10 exe 'SOURCES Const MAXSRC=200 'max 200 sources Dim Shared dbgsrc As String 'current source Dim Shared dbgmaster As Integer 'index master source if include Dim Shared dbgmain As Integer 'index main source proc entry point, to update dbgsrc see load_sources Dim Shared source(MAXSRC) As String 'source names Dim Shared srccomp(MAXSRC) As Long 'flag to keep the used compil option (gas=0, gcc=1, gcc+dwarf=2) Dim Shared sourcenb As Integer =-1 'number of src Dim Shared As String compdir 'compil directory (dwarf) Dim Shared richedit(MAXSRC) As HWND 'one for each tab Dim Shared clrrichedit As Integer=&hFFFFFF 'background color Dim Shared clrcurline As Integer=&hFF0000 'current line color, default blue Dim Shared clrkeyword As Integer=&hFF8040 'keyword color (highlight), default Dim Shared clrtmpbrk As Integer=&h04A0FB 'current line color, default orange Dim Shared clrperbrk As Integer=&hFF 'permanent breakpoint default red (used also when access violation) Dim Shared As Byte runtype =RTOFF 'running type 07/12/2014 Dim Shared dsptyp As Integer=0 'type of display Dim Shared dspofs As Integer=4 'type offset current line source : 2->3/ 4->5 Dim Shared dspsize As Integer 'number of lines of the source window Dim Shared dspwidth As Integer 'max width in characters Dim Shared breakcpu As Integer =&hCC Dim Shared As String dwln '(dwarf) line read Dim Shared As Integer dwff '(dwarf) freefile '===== DLL Type tdll As HANDLE hdl 'handle to close As UInteger bse 'base address As HTREEITEM tv 'item treeview to delete As Integer gblb 'index/number in global var table As Integer gbln As Integer lnb 'index/number in line As Integer lnn As String fnm 'full name End Type Const DLLMAX=300 Dim Shared As tdll dlldata(DLLMAX) Dim Shared As Integer dllnb 'use index base 1 '===================== proc (sub or function) ============================ Const PROCMAX=20000 'in sources Enum KMODULE=0 'used with IDSORTPRC KPROCNM End Enum Type tproc nm As String 'name db As UInteger 'lower address fn As UInteger 'upper line address ed As UInteger 'upper proc end 18/08/2015 sr As UShort 'source index nu As Long 'line number to quick access lastline As Long 'last line of proc (use when dwarf data) ''2016/03/24 vr As UInteger 'lower index variable upper (next proc) -1 rv As Integer 'return value type pt As Long 'counter pointer for return value (** -> 2) rvadr As Integer 'offset for return value adr (for now only dwarf) 19/08/2015 tv As HTREEITEM 'in tview2 st As Byte 'state followed = not checked End Type Dim Shared proc(PROCMAX) As tproc Dim Shared procnb As Integer Dim Shared As UInteger procsv,procad,procin,procsk,proccurad,procregsp,procfn,procbot,proctop,procsort Const PROCRMAX=50000 'Running proc Type tprocr sk As UInteger 'stack idx As UInteger 'index for proc tv As HTREEITEM 'index for treeview 'lst as uinteger 'future array in LIST cl As Integer 'calling line thid As Integer 'idx thread vr As Integer 'lower index running variable upper (next proc) -1 End Type Dim Shared procr(PROCRMAX) As tprocr,procrnb As Integer 'list of running proc 'line ============================================== Const LINEMAX=100000 Type tline ad As UInteger nu As Integer sv As Byte pr As UShort hp As Integer hn As Integer End Type Dim Shared As Integer linenb,rlineold 'numbers of lines, index of previous executed line (rline) Dim Shared As Integer linenbprev 'used for dll Dim Shared rline(LINEMAX) As tline 'DIM ARRAY ========================================= Const ARRMAX=1500 Type tnlu lb As UInteger ub As UInteger End Type Type tarr 'five dimensions max dm As UInteger nlu(5) As tnlu End Type Dim Shared arr(ARRMAX) As tarr,arrnb As Integer 'var ============================= Const VARMAX=20000 'CAUTION 3000 elements taken for globals Const VGBLMAX=3000 'max globals Const KBLOCKIDX=100 'max displayed lines inside index selection Type tvrb nm As String 'name typ As Integer 'type adr As Integer 'address or offset mem As UByte 'scope arr As tarr Ptr 'pointer to array def pt As long 'pointer End Type Dim Shared vrbloc As Integer 'pointer of loc variables or components (init VGBLMAX+1) Dim Shared vrbgbl As Integer 'pointer of globals or components Dim Shared vrbgblprev As Integer 'for dll, previous value of vrbgbl, initial 1 Dim Shared vrbptr As Integer Ptr 'equal @vrbloc or @vrbgbl Dim Shared vrb(VARMAX) As tvrb Const VRRMAX=100000 Type tvrr ad As UInteger 'address tv As HTREEITEM 'tview handle vr As Integer 'variable if >0 or component if <0 ini As UInteger 'dyn array address (structure) or initial address in array gofs As UInteger 'global offset to optimise access ix(4) As Integer '5 index max in case of array arrid As integer 'index in array tracking for automatic tracking ''2016/06/02 End Type Dim Shared vrr(VRRMAX) As tvrr Dim Shared vrrnb As UInteger '' tracking an array, displaying value using variables as indexes ''2016/06/02 '' ex array1(i,j) when i or j change the corresponding value of array1 is displayed Type ttrckarr typ As UByte ''type or lenght ??? memadr As UInteger ''adress in memory iv As UInteger ''vrr index used when deleting proc idx As Integer ''array variable index in vrr ''bname as string End Type Const TRCKARRMAX=4 ''2016/07/26 Dim Shared As ttrckarr trckarr(TRCKARRMAX) 'UDT ============================== Type tudt nm As String 'name of udt lb As Integer 'lower limit for components ub As Integer 'upper lg As Integer 'lenght en As Integer 'flag if enum 1 or 0 index As Integer 'dwarf what As Integer 'dwarf udt/pointer/array typ As Integer 'dwarf dimnb As Long 'dwarf bounds(5) As UInteger 'dwarf End Type Type tcudt nm As String 'name of components or text for enum Union typ As Integer 'type Val As Integer 'value for enum End Union ofs As UInteger 'offset ofb As UInteger 'rest offset bits lg As UInteger 'lenght arr As tarr Ptr 'arr ptr pt As long End Type Const TYPEMAX=80000,CTYPEMAX=100000 'CAUTION : TYPEMAX is the type for bitfield so the real limit is typemax-1 Dim Shared udt(TYPEMAX) As tudt,udtidx As Integer Dim Shared cudt(CTYPEMAX) As tcudt,cudtnb As Integer,cudtnbsav As Integer 'in case of module or DLL the udt number is initialized each time Dim Shared As Integer udtcpt,udtmax 'current, max cpt 'dwarf management Dim Shared As Long udtbeg,cudtbeg,locbeg,vrbbeg,prcbeg 'excluded lines for procs added in dll (DllMain and tmp$x) Const EXCLDMAX=10 Type texcld db As UInteger fn As UInteger End Type Dim Shared As Long excldnb Dim Shared As texcld excldlines(EXCLDMAX) udt(0).nm="Unknown" '12/07/2015 #Ifdef __FB_64BIT__ udt(1).nm="long":udt(1).lg=Len(Long) #Else udt(1).nm="Integer":udt(1).lg=Len(Integer) #EndIf udt(2).nm="Byte":udt(2).lg=Len(Byte) udt(3).nm="Ubyte":udt(3).lg=Len(UByte) udt(4).nm="Zstring":udt(4).lg=Len(Integer)'4 12/07/2015 udt(5).nm="Short":udt(5).lg=Len(Short) udt(6).nm="Ushort":udt(6).lg=Len(UShort) udt(7).nm="Void":udt(7).lg=Len(Integer)'4 12/07/2015 udt(7).index=7'dwarf '12/07/2015 #Ifdef __FB_64BIT__ udt(8).nm="Ulong":udt(8).lg=Len(ULong) #Else udt(8).nm="Uinteger":udt(8).lg=Len(UInteger) #EndIf '12/07/2015 #Ifdef __FB_64BIT__ udt(9).nm="Integer":udt(9).lg=Len(Integer) #Else udt(9).nm="Longint":udt(9).lg=Len(LongInt) #EndIf '12/07/2015 #Ifdef __FB_64BIT__ udt(10).nm="Uinteger":udt(10).lg=Len(UInteger) #Else udt(10).nm="Ulongint":udt(10).lg=Len(ULongInt) #EndIf udt(11).nm="Single":udt(11).lg=Len(Single) udt(12).nm="Double":udt(12).lg=Len(Double) udt(13).nm="String":udt(13).lg=Len(String) udt(14).nm="Fstring":udt(14).lg=Len(Integer)'4 12/07/2015 udt(15).nm="fb_Object":udt(15).lg=Len(UInteger) udt(16).nm="Boolean": '20/082015 boolean For i As Integer =0 To TYPESTD:udt(i).what=1:Next '(dwarf) 20/08/2015 boolean 'BREAK ON LINE Const BRKMAX=10 'breakpoint index zero for "run to cursor" Type breakol isrc As UShort 'source index nline As UInteger 'num line for display index As Integer 'index for rline ad As UInteger 'address typ As Byte 'type normal=1 /temporary=0, 3 or 4 =disabled counter As UInteger 'counter to control the number of times the line should be executed before stopping 02/09/2015 cntrsav As UInteger 'to reset if needed the initial value of the counter '03/09/2015 End Type Dim Shared brkol(BRKMAX) As breakol,brknb As Byte Dim Shared As String brkexe(9,BRKMAX) 'to save breakpoints by session 'break on var Type tbrkv typ As Integer 'type of variable adr As UInteger 'address arr As UInteger 'adr if dyn array ivr As Integer 'variable index psk As Integer 'stack proc Val As valeurs 'value vst As String 'value as string tst As Byte=1 'type of comparison (1 to 6) ttb As Byte 'type of comparison (16 to 0) txt As String 'name and value just for brkv_box End Type Dim Shared brkv As tbrkv Dim Shared brkv2 As tbrkv 'copie for use inside brkv_box Dim Shared brkvhnd As HWND 'handle 'BOOKMARK Type tbmk nline As Integer 'bookmark line ntab As Integer 'bookmark tab number, =-1 --> empty End Type Const BMKMAX=10 Dim Shared As tbmk bmk(BMKMAX) Dim Shared As HWND bmkh 'handle combo Dim Shared As Integer bmkcpt 'bmk counter 'WATCH Const WTCHMAIN=3 Const WTCHMAX=9 Const WTCHALL=9999999 Type twtch hnd As HWND 'handle tvl As HTREEITEM 'tview handle adr As UInteger 'memory address typ As Integer 'type for var_sh2 pnt As Integer 'nb pointer ivr As Integer 'index vrr psk As Integer 'stk procr or -1 (empty)/-2 (memory)/-3 (non-existent local var)/-4 (session) lbl As String 'name & type,etc arr As UInteger 'ini for dyn arr tad As Integer 'additionnal type old As String 'keep previous value for tracing idx As Integer 'index proc only for local var dlt As Integer 'delta on stack only for local var vnb As Integer 'number of level vnm(10) As String 'name of var or component vty(10) As String 'type Var As Integer 'array=1 / no array=0 End Type Dim Shared wtch(WTCHMAX) As twtch Dim Shared wtchcpt As Integer 'counter of watched value, used for the menu Dim Shared hwtchbx As HWND 'handle Dim Shared wtchidx As Integer 'index for delete Dim Shared wtchexe(9,WTCHMAX) As String 'watched var (no memory for next execution) Dim Shared wtchnew As Integer 'to keep index after creating new watched 'For findtext Dim Shared chkcase As Integer 'flag match case Dim Shared sfind As String 'string to find Dim Shared stext As String 'string under cursor or selected by user Dim Shared hfindbx As HWND 'hwnd find zone 'for save box Dim Shared savebx As HWND 'just little yes/cancel box 'for help box Dim Shared helpbx As HWND Dim Shared helptyp As Byte '1=help,2=infos ' or dump Dim Shared hdumpbx As HWND 'hwnd dump zone Dim Shared dumplig As Integer =1 'nb lines(1 or xx) Dim Shared dumpadr As UInteger 'address for dump Dim Shared dumpdec As Integer =0 'value dump dec=0 or hexa=50 Dim Shared copybeg As Integer 'address beginning/end for copying to clipboard Dim Shared copyend As Integer Dim Shared copycol As Integer 'column for copying to clipboard ' input_box Dim Shared inputval As ZString *25 Dim Shared inputtyp As Byte 'focus box Dim Shared focusbx As HWND 'tutorial box Dim Shared tutobx As HWND 'bitmap buttons Dim Shared bmb(23) As HBITMAP 'TAB Dim Shared As HWND htab1,htab2 'index box Const INDEXBOXMAX=9 ''2016/02/07 Dim Shared hindexbx(INDEXBOXMAX) As HWND Dim Shared autoupd(INDEXBOXMAX) As BOOLEAN ' For size font Const KSIZE8=8 Const KSIZE10=10 Const KSIZE12=12 'font handle Dim Shared As HFONT fonthdl Dim Shared As HFONT fontbold Dim Shared As Integer fontsize=KSIZE8 Dim Shared As String fontname fontname="Courier new" 'show/expand Const SHWEXPMAX=10 'max shwexp boxes Const VRPMAX=5000 'max elements in each treeview Type tshwexp Dim bx As HWND 'handle pointed value box Dim tv As HWND 'corresponding tree view Dim nb As Integer 'number of elements tvrp Dim dl As Integer 'delta x size of type Dim lb As HWND 'handle of the delta label End Type Type tvrp nm As String 'name ty As Integer 'type pt As Integer 'is pointer ad As UInteger 'address tl As HTREEITEM 'line in treeview 'iv As Integer 'index of variables End Type Dim Shared As Integer shwexpnb 'current number of show/expand box Dim Shared As tshwexp shwexp(1 To SHWEXPMAX) 'data for show/expand Dim Shared As tvrp vrp(SHWEXPMAX,VRPMAX) 'VAR FIND Type tvarfind ty As Integer pt As Integer nm As String 'var name or description when not a variable pr As Integer 'index of running var parent (if no parent same as ivr) ad As UInteger iv As Integer 'index of running var tv As HWND 'handle treeview tl As HTREEITEM 'handle line End Type Dim Shared As tvarfind varfind 'HIGH LIGHTING keywords Type tmodif lg As Integer ps As Integer End Type Dim Shared As Integer hgltmax Dim Shared As Integer hgltpt=0 ReDim Shared hgltdata() As tmodif Dim Shared As Integer hgltflag=FALSE 'shortcuts Const SHCUTMAX=130 '2016/06/15 Const VSHIFT=&hF00000 Const VALT =&hF0000 Const VCTRL =&hF000 Type tshcut As Integer sccur As HMENU scmenu As Integer scidnt End Type Dim Shared As tshcut shcut(SHCUTMAX) Dim Shared As Integer shcutnb 'Backtracking Type tbcktrk As Integer bcw As Integer frw End Type Dim Shared As Integer bcktrkpr Dim Shared As HWND bcktrkbx '================ DECLARATIONS ======================================================== Declare Function fb_Toolbar (hwnd As HWND,id As Integer,NumBtns As Integer,Text As String,Bstyles As Integer Ptr =0, _ img As Any Ptr =0,imgidx As Integer Ptr =0,bx As Integer =0,by As Integer =0,Style As Integer =0,ExStyle As Integer =0) As HWND Declare Function fb_edit(text As String,form1 As HWND,id As Integer,x As Integer, _ y As Integer,w As Integer,h As Integer,ByVal s As Integer = 0,ByVal ex As Integer = -1) As HWND Declare Function fb_editw(text As WString,form1 As HWND,id As Integer,x As Integer, _ y As Integer,w As Integer,h As Integer,ByVal s As Integer = 0,ByVal ex As Integer = -1) As HWND Declare Function fb_Label(Text As String,hWnd As HWND,id As Integer=0,X As Integer=0,Y As Integer=0, _ W As Integer=0,H As Integer=0,ByVal Style As Integer=0,ByVal Exstyle As Integer=-1) As HWND Declare Function fb_Form(t As String,x As Integer =0,y As Integer =0,w As Integer =250,h As Integer =150,s As Integer =0,ex As Integer =0) As HWND Declare Sub fb_show(hwnd As HWND) Declare Function fb_RichEdit (t As String,h As HWND,i As Integer,x As Integer,y As Integer,w As Integer,h As Integer,s As Integer=0,x As Integer=-1) As HWND Declare Function fb_Status (text As String,hand As HWND,id As Integer) As HWND Declare Function WinMain ( ByVal hInstance As HINSTANCE, _ ByVal hPrevInstance As Integer, _ szCmdLine As String, _ ByVal iCmdShow As Integer ) As Integer Declare Function fb_button(a As String,ByVal hwnd As HWND,ByVal i As Integer=0, ByVal x As Integer =0 _ ,ByVal y As Integer =0,ByVal w As Integer =0, ByVal h As Integer =0,s As Integer =0,es As Integer =-1) As HWND Declare Function fb_CreateTooltips(hControl As HWND, Text As String,Title As String, ToolIcon As Integer) As HWND Declare Function fb_ModStyle(hWnd As HWND, dwAdd As Integer=0, dwRemove As Integer=0, bEx As Integer =0) As Integer Declare Function fb_UpDown (hWnd As HWND,X As Integer,Y As Integer,W As Integer,H As Integer,Lo As Integer,Hi As Integer,uStart As Integer=0) As HWND Declare Function fb_message (title As String ,text As String,style As Integer=0) As Integer Declare Function fb_Treeview(hwnd As HWND,id As Integer,x As Integer,y As Integer,w As Integer,h As Integer,s As Integer =0,ex As Integer =-1) As HWND Declare Function fb_Group(t As String,H As HWND,i As Integer,x As Integer,y As Integer,w As Integer,h As Integer,s As Integer =0,e As Integer =0) As HWND Declare Function fb_Checkbox(t As String,H As HWND,i As Integer=0,x As Integer=0,y As Integer=0,w As Integer=0,h As Integer=0,s As Integer =0,e As Integer =0) As HWND Declare Function fb_radio(t As String,H As HWND,i As Integer=0,x As Integer=0,y As Integer=0,w As Integer=0,h As Integer=0,s As Integer =0,e As Integer =0) As HWND Declare Function fb_combobox(H As HWND,i As Integer,x As Integer,y As Integer,w As Integer,h As Integer,s As Integer =0,e As Integer =-1) As HWND Declare Function fb_listbox(H As HWND,i As Integer,x As Integer,y As Integer,w As Integer,h As Integer,s As Integer =0,e As Integer =-1) As HWND Declare Function fb_datepick(H As HWND,i As Integer,x As Integer,y As Integer,w As Integer,h As Integer,s As Integer =0,e As Integer =-1) As HWND Declare Function fb_listview(H As HWND,i As Integer,x As Integer,y As Integer,w As Integer,h As Integer,s As Integer =0,e As Integer =-1) As HWND Declare Function fb_MDialog (DPro As Any Ptr,title As String,hWnd As HWND,X As Integer,Y As Integer,W As Integer,H As Integer,Style As Integer=0,Exstyle As Integer=0) As Integer Declare Function fb_Dialog (DPro As Any Ptr,title As String,hWnd As HWND,X As Integer,Y As Integer,W As Integer,H As Integer,Style As Integer=0,Exstyle As Integer=0) As HWND Declare Function fb_Tab (As HWND,As Integer,As Integer,As Integer,As Integer,As Integer,As Integer=0,As Integer=0) As HWND Declare Sub tab_add(As Integer,As hwnd,As String) Declare Sub exrichedit(As Integer) Declare Function wait_debug() As Integer Declare Sub load_sources(As Integer) Declare Sub save_source() Declare Sub log_show() Declare Sub log_hide() Declare Function Tree_AddItem(hParent As HTREEITEM,Text As String,hInsAfter As HTREEITEM,hTV As HWND) As HTREEITEM Declare Sub dbg_return(a As Integer,l As Integer) Declare Sub menu_set() Declare Sub ide_launch() Declare Sub sel_line(l As Integer,c As Integer=0,d As Integer=0,As HWND=dbgrichedit,As Integer=TRUE) Declare Sub brk_set(t As Integer) Declare Sub brk_color(As Integer) Declare Sub brk_apply() Declare Sub exe_mod() Declare Sub dump_set(h As HWND) Declare Sub bmk_tgl() Declare Sub bmk_goto(As Integer) Declare Sub notes_add() Declare Sub start_pgm(p As Any Ptr) Declare Sub dsp_hide(t As Integer) Declare Sub but_enable() Declare Sub menu_enable() Declare Function brk_manage (ByVal hWnd As HWND,ByVal Msg As UInteger,ByVal wparam As Integer,ByVal lParam As Integer) As Integer Declare Sub watch_set() Declare Sub watch_sh(aff As Integer=WTCHALL) Declare Sub watch_sel(As Integer) Declare Sub watch_del(As Integer=WTCHALL) Declare Sub watch_exch(As Integer) Declare Function watch_find()As Integer Declare Sub watch_array() Declare Function watch_box(ByVal hWnd As HWND,ByVal Msg As UInteger,ByVal wparam As Integer,ByVal lParam As Integer) As Integer Declare Sub watch_add(As Integer,As Integer =-1) Declare Sub watch_trace(As Integer=WTCHALL) Declare Sub watch_addtr Declare Sub brkv_set(a As Integer) Declare Sub proc_expcol(t As Integer) Declare Sub var_dump(As HWND,ptd As Long =0) Declare Sub setvpdmp() Declare Sub dump_sh() Declare Function wtext() As String Declare Sub frground() Declare Function fb_GetFileName(Title As String, Filt As String,Flag As Integer,hWnd As HWND,Flags As Integer,InitialDr As String) As String Declare Function find_box(ByVal hWnd As HWND,ByVal Msg As UInteger,ByVal wparam As Integer,ByVal lParam As Integer) As Integer Declare Function input_box(ByVal hWnd As HWND,ByVal Msg As UInteger,ByVal wparam As Integer,ByVal lParam As Integer) As Integer Declare Function save_box(ByVal hWnd As HWND,ByVal Msg As UInteger,ByVal wparam As Integer,ByVal lParam As Integer) As Integer Declare Function dump_box(ByVal hWnd As HWND,ByVal Msg As UInteger,ByVal wparam As Integer,ByVal lParam As Integer) As Integer Declare Function settings_box(ByVal hWnd As HWND,ByVal Msg As UInteger,ByVal wparam As Integer,ByVal lParam As Integer) As Integer Declare Function brkv_box(ByVal hWnd As HWND,ByVal Msg As UInteger,ByVal wparam As Integer,ByVal lParam As Integer) As Integer Declare Function help_box(ByVal hWnd As HWND,ByVal Msg As UInteger,ByVal wparam As Integer,ByVal lParam As Integer) As Integer Declare Function edit_box(ByVal hWnd As HWND,ByVal Msg As UInteger,ByVal wparam As Integer,ByVal lParam As Integer) As Integer Declare Function index_box(ByVal hWnd As HWND,ByVal Msg As UInteger,ByVal wparam As Integer,ByVal lParam As Integer) As Integer Declare Function attach_box(ByVal hWnd As HWND,ByVal Msg As UInteger,ByVal wparam As Integer,ByVal lParam As Integer) As Integer Declare Function shwexp_box(ByVal hWnd As HWND,ByVal Msg As UInteger,ByVal wparam As Integer,ByVal lParam As Integer) As Integer Declare Function jit_box(ByVal hWnd As HWND,ByVal Msg As UInteger,ByVal wparam As Integer,ByVal lParam As Integer) As Integer Declare Function focus_box(ByVal hWnd As HWND,ByVal Msg As UInteger,ByVal wparam As Integer,ByVal lParam As Integer) As Integer Declare Function tuto_box(ByVal hWnd As HWND,ByVal Msg As UInteger,ByVal wparam As Integer,ByVal lParam As Integer) As Integer Declare Function bcktrk_box(ByVal hWnd As HWND,ByVal Msg As UInteger,ByVal wparam As Integer,ByVal lParam As Integer) As Integer Declare Sub shwexp_det(As Integer,As UInteger,As Integer,As HTREEITEM,As Integer) Declare Function shwexp_ini(As Integer,As String,As UInteger,As Integer,As Integer) As Integer Declare Sub shwexp_new(As HWND) Declare Sub shwexp_del() Declare Sub shwexp_arrange() Declare Sub var_tip(As Integer) Declare Function prep_var(t As String) As String Declare Function prep_debug(As String) As String Declare Sub treat_file(f As String) Declare Sub ini_read() Declare Sub crc_init() Declare Function crc_string(txt As String) As Integer Declare Function crc_file(fname As String) As String Declare Sub winmsg() Declare Sub dechexbin() Declare Sub line_goto() Declare Sub dump_update(As NMITEMACTIVATE Ptr)'NMLISTVIEW '20/11/2014 Declare Sub dump_sel(lvp As NMITEMACTIVATE Ptr) Declare Sub show_context() Declare Sub cutup_udt(As String) Declare Sub cutup_enum(As String) Declare Sub cutup_1(As String,As UInteger,As Integer=0) Declare Sub cutup_2(As String,As Byte) Declare Function cutup_proc(As String) As String Declare Function cutup_op (As String) As String Declare Function cutup_array(As String,As Integer,As Byte) As Integer Declare Function cutup_scp(As Byte,As UInteger,deltadll As Integer=0) As Integer Declare Sub cutup_retval(As Integer,As String) Declare Function Common_exist(As UInteger) As Integer Declare Sub dbg_prt (As String) Declare Sub var_iniudt(As UInteger,As UInteger,As HTREEITEM,As UInteger,As UByte)'09/07/2015 Declare Function var_sh2(As Integer,As UInteger, As UByte=0,As String="") As String Declare Function var_add(As String,As Integer,As Integer)As String Declare Sub gest_brk(As UInteger) Declare Sub debug_extract(As UInteger,As String,As Long=NODLL) Declare Function name_extract(As String) As String Declare Sub brk_del(As Integer) Declare Sub proc_new() Declare Sub proc_watch(As Integer) Declare Sub proc_end() Declare Sub globals_load(As Integer=0) Declare Sub ini_write() Declare Sub proc_sh() Declare Sub proc_activ(As HTREEITEM) Declare Sub proc_flw(As Byte) Declare Sub thread_check(As HTREEITEM) Declare Function proc_find(As Integer,As Byte) As Integer Declare Function proc_verif(As UShort) As Byte Declare Sub var_ini(As UInteger, As Integer , As Integer) Declare Sub var_sh() Declare Sub fastrun() Declare Sub proc_del(As Integer,As Integer=1) Declare Sub proc_newfast() Declare Function proc_retval(As Integer) As String Declare Function fb_Set_Font (Font As String,Size As Integer,Bold As Integer=0,Italic As Integer=0,Underline As Integer=0,StrikeThru As Integer=0) As HFONT Declare Function proc_name(ad As UInteger) As String Declare Sub proc_loc() Declare Sub proc_update() Declare Function fb_LoadBMP (F As String,i As Integer=0) As HBITMAP Declare Sub dsp_size() Declare Function excep_lib(As Integer) As String Declare Sub dbg_attach(p As Any Ptr) Declare Sub string_sh(As HWND) Declare Sub thread_change(As Integer=-1) Declare Function enum_find(As Integer,As Integer) As String Declare Function var_find2(As HWND) As Integer Declare Sub enum_check(As Integer) Declare Sub enum_show(As HWND) Declare Sub font_change(As String="",As Integer=0) Declare Sub drag_exe(As handle) Declare Function kill_process(As String) As Integer Declare Sub dsp_sizecalc() Declare Sub compinfo_sh() 'Declare Function messageboxw Lib "libuser32" Alias "MessageBoxW" (ByVal As HWND, ByVal As LPCWSTR, ByVal As LPCWSTR, ByVal As UINT) As Integer 'Declare Function setwindowtextw Lib "libuser32" Alias "SetWindowTextW" (ByVal As HWND, ByVal As LPCWSTR) As BOOL 'Declare Function CreateWindowExW Lib "libuser32" Alias "CreateWindowExW" (ByVal As DWORD, _ ' ByVal As LPCWSTR, ByVal As LPCWSTR, ByVal As DWORD, ByVal As Integer, ByVal As Integer, _ ' ByVal As Integer, ByVal As Integer, ByVal As HWND, ByVal As HMENU, ByVal As HINSTANCE, ByVal As LPVOID) As HWND Declare Sub exe_sav(exename As String,cmdline As String) Declare Sub dsp_access(shwtab As Integer) Declare Sub dsp_noaccess() Declare Sub help_manage(As Integer=0) 'replace help_start Declare Function var_search(pproc As Integer,text() As String,vnb As Integer,varr As Integer,As Integer=0) As Integer Declare Function var_sh1(As Integer) As String Declare Sub watch_sav() Declare Sub brk_sav() Declare Function fb_FontDlg (As HWND) As Integer Declare Function color_change(As Integer) As Integer Declare Sub hglt_lines(As Integer,As Integer) Declare Sub hglt_data(nline As Integer,src As Integer, datas() As tmodif, cptk As Integer) Declare Sub translate_gcc(As String) Declare Sub zstringbyte_exchange() Declare Sub proc_loccall(typ As Integer=1) Declare Sub thread_kill() Declare Sub thread_execline(As Integer,As Integer=0) Declare Sub line_adr Declare Sub thread_expcol(As Integer) Declare Sub thread_text(As Integer=-1) Declare Sub thread_procloc(As Integer) Declare Sub procvar_list(As Integer=0) Declare Sub surround(hdl As HWND,x As Integer=-1,y As Integer=0,w As Integer=0,h As Integer=0) Declare Sub decode_help(dData As HELPINFO Pointer) Declare Sub str_replace(strg As String,srch As String, repl As String) Declare Function dll_name(FileHandle As HANDLE,t As Integer =1 )As String Declare Sub shcut_display(As Integer,As HWND,As HWND,As HWND,As HWND) Declare Function shcut_txt(As Integer,As Integer) As String Declare Function shcut_check(As Integer,As Integer)As Integer Declare Function menu_gettxt(As HMENU,As Integer) As String Declare Sub menu_update(As Integer,As String="") Declare Function parse_typeope(As long)As String Declare Function dissassemble(hedit As HWND,scop As Integer)As Integer Declare Sub bcktrk_proc(prr As Integer,ByRef bcktrk As tbcktrk,typ As Integer,lblcur As HWND,lblprev As HWND,lblnext As HWND,butprev As HWND,butnext As HWND) Declare Sub bcktrk_close() Declare Sub bcktrk_launch(pr As Integer,typ As Integer) Declare Sub bx_closing() Declare Function dw_extract(As String,As UInteger) As Long Declare Sub char_sh(tv As HWND) '03/11/2014 Declare Sub regs_data(thd As handle,reg_values() As String) '25/08/2015 Declare Function procvar_box(ByVal hWnd As HWND,ByVal Msg As UInteger,ByVal wparam As Integer,ByVal lParam As Integer) As Integer Declare Sub array_tracking(t As short) ''2016/06/15 Declare Sub array_tracking_remove Declare Function local_exist As Long Declare sub dw_lastline_procs(reinit As Long=0) '======================================== 'To avoid multiple launching If CreateSemaphore(0, 0, 1,"FBdebugger" )<>0 And GetLastError() = ERROR_ALREADY_EXISTS Then If fb_message("Starting FBdebugger","An other occurence is already running."+Chr(13)+"Continue ?", _ MB_YESNO Or MB_ICONQUESTION Or MB_SYSTEMMODAL Or MB_DEFBUTTON1) = IDNO Then End 1 End If End WinMain( Cast(HINSTANCE,GetModuleHandle( 0 )),0, Command, SW_NORMAL ) '================================================= private sub fb_win() Dim As Integer l Dim As Long pstatus(4)={120,220,470,700,-1} '08/04/2014 520-->470 add 670 Dim As UInteger tabstop=8 windmain = fb_Form ( "DEBUG "+ver3264, 0, 0,900, 590)',WS_MINIMIZEBOX or WS_CAPTION Or WS_SYSMENU) DragAcceptFiles(windmain, TRUE) butstep = fb_button("",windmain, IDBUTSTEP, 8, 0, 30, 26) fb_CreateTooltips(butstep, "[S]tep by step ", "FBDEBUGGER",0) fb_ModStyle(butstep,BS_BITMAP) 'add BS_BITMAP 'bmb(0)=LoadImage(fb_hinstance,"step.bmp",IMAGE_BITMAP,23,19,LR_LOADFROMFILE) kept for example bmb(0)=Loadbitmap(fb_hinstance,Cast(LPSTR,MAKEINTRESOURCE(1000))) SendMessage(butstep, BM_SETIMAGE, IMAGE_BITMAP, Cast(LPARAM,bmb(0))) butcont = fb_button("",windmain,IDCONTHR, 40, 0, 30, 26)' >+ 18 fb_CreateTooltips(butcont, "Run to [C]ursor", "",0) fb_ModStyle(butcont,BS_BITMAP) bmb(1)=Loadbitmap(fb_hinstance,Cast(LPSTR,MAKEINTRESOURCE(1001))) SendMessage(butcont, BM_SETIMAGE, IMAGE_BITMAP, Cast(LPARAM,bmb(1))) butstepp = fb_button("",windmain,IDBUTSTEPP, 72, 0, 30, 26)' >+ 18 fb_CreateTooltips(butstepp, "Step [O]ver sub/func", "",0) fb_ModStyle(butstepp,BS_BITMAP) bmb(2)=Loadbitmap(fb_hinstance,Cast(LPSTR,MAKEINTRESOURCE(1002))) SendMessage(butstepp, BM_SETIMAGE, IMAGE_BITMAP, Cast(LPARAM,bmb(2))) butstept = fb_button("",windmain,IDBUTSTEPT, 104, 0, 30, 26) fb_CreateTooltips(butstept, "[T]op next called sub/func", "",0) fb_ModStyle(butstept,BS_BITMAP) bmb(22)=Loadbitmap(fb_hinstance,Cast(LPSTR,MAKEINTRESOURCE(1022))) SendMessage(butstept, BM_SETIMAGE, IMAGE_BITMAP, Cast(LPARAM,bmb(22))) butstepb = fb_button("",windmain,IDBUTSTEPB, 136, 0, 30, 26) fb_CreateTooltips(butstepb, "[B]ottom current sub/func", "",0) fb_ModStyle(butstepb,BS_BITMAP) bmb(23)=Loadbitmap(fb_hinstance,Cast(LPSTR,MAKEINTRESOURCE(1023))) SendMessage(butstepb, BM_SETIMAGE, IMAGE_BITMAP, Cast(LPARAM,bmb(23))) butstepm = fb_button("",windmain,IDBUTSTEPM, 168, 0, 30, 26) fb_CreateTooltips(butstepm, "[E]xit current sub/func", "",0) fb_ModStyle(butstepm,BS_BITMAP) bmb(3)=Loadbitmap(fb_hinstance,Cast(LPSTR,MAKEINTRESOURCE(1003))) SendMessage(butstepm, BM_SETIMAGE, IMAGE_BITMAP, Cast(LPARAM,bmb(3))) butauto = fb_button("AUTO", windmain,IDBUTAUTO, 200, 0, 30, 26) fb_CreateTooltips(butauto, "Step [A]utomatically, stopped by [H]alt", "",0) fb_ModStyle(butauto,BS_BITMAP) bmb(4)=Loadbitmap(fb_hinstance,Cast(LPSTR,MAKEINTRESOURCE(1004))) SendMessage(butauto, BM_SETIMAGE, IMAGE_BITMAP, Cast(LPARAM,bmb(4))) butrun = fb_button("RUN",windmain, IDBUTRUN, 232, 0, 30, 26) fb_CreateTooltips(butrun, "[R]un, stopped by [H]alt", "",0) fb_ModStyle(butrun,BS_BITMAP) bmb(5)=Loadbitmap(fb_hinstance,Cast(LPSTR,MAKEINTRESOURCE(1005))) SendMessage(butrun, BM_SETIMAGE, IMAGE_BITMAP, Cast(LPARAM,bmb(5))) butstop = fb_button("HALT",windmain, IDBUTSTOP, 264, 0, 30, 26) fb_CreateTooltips(butstop, "[H]alt running pgm", "",0) fb_ModStyle(butstop,BS_BITMAP) bmb(6)=Loadbitmap(fb_hinstance,Cast(LPSTR,MAKEINTRESOURCE(1006))) SendMessage(butstop, BM_SETIMAGE, IMAGE_BITMAP, Cast(LPARAM,bmb(6))) butmini = fb_button("MINI",windmain, IDBUTMINI,296, 0, 30, 26) fb_CreateTooltips(butmini, "Mini window", "",0) fb_ModStyle(butmini,BS_BITMAP) bmb(7)=Loadbitmap(fb_hinstance,Cast(LPSTR,MAKEINTRESOURCE(1007))) SendMessage(butmini, BM_SETIMAGE, IMAGE_BITMAP, Cast(LPARAM,bmb(7))) butfree = fb_button("free",windmain, IDBUTFREE,392, 0, 30, 26) fb_CreateTooltips(butfree, "Release debugged prgm", "",0) fb_ModStyle(butfree,BS_BITMAP) bmb(8)=Loadbitmap(fb_hinstance,Cast(LPSTR,MAKEINTRESOURCE(1008))) SendMessage(butfree, BM_SETIMAGE, IMAGE_BITMAP, Cast(LPARAM,bmb(8))) Butkill = fb_button("KILL",windmain, IDBUTKILL,424, 0, 30, 26) fb_CreateTooltips(Butkill, "CAUTION [K]ill process", "",0) fb_ModStyle(butkill,BS_BITMAP) bmb(9)=Loadbitmap(fb_hinstance,Cast(LPSTR,MAKEINTRESOURCE(1009))) SendMessage(butkill, BM_SETIMAGE, IMAGE_BITMAP, Cast(LPARAM,bmb(9))) Butrrune = fb_button("EXE>>",windmain, IDBUTRRUNE,466, 0, 30, 26) fb_CreateTooltips(Butrrune, "Restart debugging (exe)", "",0) fb_ModStyle(butrrune,BS_BITMAP) bmb(10)=Loadbitmap(fb_hinstance,Cast(LPSTR,MAKEINTRESOURCE(1010))) SendMessage(butrrune, BM_SETIMAGE, IMAGE_BITMAP, Cast(LPARAM,bmb(10))) Butlstexe = fb_button("EXE>>",windmain, IDLSTEXE,498, 0, 30, 26) fb_CreateTooltips(Butlstexe, "Last 10 exe(s)", "",0) fb_ModStyle(Butlstexe,BS_BITMAP) bmb(11)=Loadbitmap(fb_hinstance,Cast(LPSTR,MAKEINTRESOURCE(1011))) SendMessage(Butlstexe, BM_SETIMAGE, IMAGE_BITMAP, Cast(LPARAM,bmb(11))) Butattch = fb_button("ATT>>",windmain, IDBUTATTCH,530, 0, 30, 26) fb_CreateTooltips(Butattch, "Attach running program", "",0) fb_ModStyle(butattch,BS_BITMAP) bmb(12)=Loadbitmap(fb_hinstance,Cast(LPSTR,MAKEINTRESOURCE(1012))) SendMessage(butattch, BM_SETIMAGE, IMAGE_BITMAP, Cast(LPARAM,bmb(12))) Butfile = fb_button("FILE",windmain, IDBUTFILE,562, 0, 30, 26) fb_CreateTooltips(Butfile, "Select EXE/BAS", "",0) fb_ModStyle(butfile,BS_BITMAP) bmb(13)=Loadbitmap(fb_hinstance,Cast(LPSTR,MAKEINTRESOURCE(1013))) SendMessage(butfile, BM_SETIMAGE, IMAGE_BITMAP, Cast(LPARAM,bmb(13))) butnotes=fb_button("NOTES",windmain, IDNOTES,600,0, 30, 26) fb_CreateTooltips(butnotes,"Open or close notes", "",0) fb_ModStyle(butnotes,BS_BITMAP) bmb(14)=Loadbitmap(fb_hinstance,Cast(LPSTR,MAKEINTRESOURCE(1014))) SendMessage(butnotes, BM_SETIMAGE, IMAGE_BITMAP, Cast(LPARAM,bmb(14))) Buttool = fb_button("TOOLS",windmain, IDBUTTOOL,632, 0, 30, 26) fb_CreateTooltips(Buttool, "Some usefull....Tools", "",0) fb_ModStyle(buttool,BS_BITMAP) bmb(15)=Loadbitmap(fb_hinstance,Cast(LPSTR,MAKEINTRESOURCE(1015))) SendMessage(buttool, BM_SETIMAGE, IMAGE_BITMAP, Cast(LPARAM,bmb(15))) Butexemod = fb_button("EXE MOD",windmain, IDEXEMOD,360, 0, 30, 26) fb_CreateTooltips(Butexemod, "CAUTION [M]odify execution, continue with line under cursor", "",0) fb_ModStyle(Butexemod,BS_BITMAP) bmb(16)=Loadbitmap(fb_hinstance,Cast(LPSTR,MAKEINTRESOURCE(1016))) SendMessage(Butexemod, BM_SETIMAGE, IMAGE_BITMAP, Cast(LPARAM,bmb(16))) Butfastrun = fb_button("Fast Run",windmain, IDFASTRUN,328, 0, 30, 26) fb_CreateTooltips(Butfastrun, "CAUTION [F]AST Run to cursor", "",0) fb_ModStyle(Butfastrun,BS_BITMAP) bmb(17)=Loadbitmap(fb_hinstance,Cast(LPSTR,MAKEINTRESOURCE(1017))) SendMessage(Butfastrun, BM_SETIMAGE, IMAGE_BITMAP, Cast(LPARAM,bmb(17))) butenlrsrc = fb_button("Source",windmain, ENLRSRC,690, 0, 30, 26) fb_CreateTooltips(butenlrsrc,"Enlarge/reduce source", "",0) fb_ModStyle(butenlrsrc,BS_BITMAP) bmb(18)=Loadbitmap(fb_hinstance,Cast(LPSTR,MAKEINTRESOURCE(1018))) SendMessage(butenlrsrc, BM_SETIMAGE, IMAGE_BITMAP, Cast(LPARAM,bmb(18))) butenlrvar = fb_button("VarProc",windmain, ENLRVAR,720, 0, 30, 26) fb_CreateTooltips(butenlrvar, "Enlarge/reduce proc/var", "",0) fb_ModStyle(butenlrvar,BS_BITMAP) bmb(19)=Loadbitmap(fb_hinstance,Cast(LPSTR,MAKEINTRESOURCE(1019))) SendMessage(butenlrvar, BM_SETIMAGE, IMAGE_BITMAP, Cast(LPARAM,bmb(19))) butenlrmem = fb_button("Memory",windmain,ENLRMEM,750,0, 30, 26) fb_CreateTooltips(butenlrmem, "Enlarge/reduce dump memory", "",0) fb_ModStyle(butenlrmem,BS_BITMAP) bmb(20)=Loadbitmap(fb_hinstance,Cast(LPSTR,MAKEINTRESOURCE(1020))) SendMessage(butenlrmem, BM_SETIMAGE, IMAGE_BITMAP, Cast(LPARAM,bmb(20))) bmb(21)=Loadbitmap(fb_hinstance,Cast(LPSTR,MAKEINTRESOURCE(1021))) 'if notes changes ' next line just to see it works 'fb_createtooltips(dbgEdit1, "See your source", "",0) 'TimerID1 = SetTimer (windmain, 1,10,NULL) 'not used if 2 threads hTab2 = fb_Tab(windmain,TAB2,478,43,315,25) fonthdl=fb_Set_Font(fontname,fontsize,,TRUE) fontbold=fb_Set_Font(fontname,fontsize,FW_SEMIBOLD,TRUE) 'in bold tviewvar = fb_Treeview (windmain,TVIEW1,478,65,315,365) 'procr/var Dim dwStyle As Long =GetWindowLong(tviewvar, GWL_STYLE) ''2017/07/27 SetWindowLong(tviewvar,GWL_STYLE,dwStyle Or TVS_INFOTIP) SendMessage(tviewvar,WM_SETFONT,Cast(WPARAM,fonthdl),0) tviewcur=tviewvar tab_add(0,htab2,"Proc/var") tviewprc = fb_Treeview (windmain,TVIEW2,478,65,315,365) 'procr SendMessage(tviewprc,WM_SETFONT,Cast(WPARAM,fonthdl),0) dwStyle=GetWindowLong(tviewprc, GWL_STYLE) SetWindowLong(tviewprc,GWL_STYLE,dwStyle Or TVS_CHECKBOXES) ShowWindow(tviewprc,SW_HIDE) tab_add(1,htab2,"Procrs") tviewthd = fb_Treeview (windmain,TVIEW3,478,65,315,365) 'thread SendMessage(tviewthd,WM_SETFONT,Cast(WPARAM,fonthdl),0) dwStyle=GetWindowLong(tviewthd, GWL_STYLE) SetWindowLong(tviewthd,GWL_STYLE,dwStyle Or TVS_CHECKBOXES) ShowWindow(tviewthd,SW_HIDE) tab_add(2,htab2,"Threads") tviewwch = fb_Treeview (windmain,TVIEW4,478,65,315,365) 'watch SendMessage(tviewwch,WM_SETFONT,Cast(WPARAM,fonthdl),0) ShowWindow(tviewwch,SW_HIDE) tab_add(3,htab2,"Watched var") hTab1 = fb_Tab(windmain,TAB1,3,43,475,25) tab_add(0,htab1,"Sources") For i As Integer=0 To MAXSRC richedit(i) = fb_RichEdit("fb Edit Box",windmain,IDRICHWIN,3,65,475,363)',WS_CHILD or WS_VISIBLE or ES_WANTRETURN or WS_VSCROLL or WS_HSCROLL or ES_MULTILINE or ES_AUTOVSCROLL or ES_AUTOHSCROLL or ES_READONLY) SendMessage(richedit(i),WM_SETFONT,Cast(WPARAM,fonthdl),0) SendMessage(richedit(i),EM_SETEVENTMASK,0,ENM_KEYEVENTS Or ENM_MOUSEEVENTS) sendmessage(richedit(i),EM_SETTABSTOPS,1,Cast(LPARAM,@tabstop)) sendmessage(richedit(i),EM_SETBKGNDCOLOR,0,clrrichedit) ShowWindow(richedit(i),SW_HIDE) Next dbgrichedit=richedit(0) 'used to put margins 'SendMessage( dbgrichedit, EM_SETMARGINS, EC_LEFTMARGIN, 70 ) ShowWindow(dbgrichedit,SW_SHOW) ''setWindowText(dbgrichedit,"Source") hcurline = fb_Label("Current line:",windmain,IDCURLIG,3,28,790,16) fb_CreateTooltips(hcurline, "Click here to go to current line", "",0) 'bookmark handle bmkh = fb_combobox(windmain,IDBMKCMB,3,430,790,100) wtch(0).hnd = fb_Label("Watch 1",windmain,IDWATCH1,3,448,395,16) wtch(1).hnd = fb_Label("Watch 2",windmain,IDWATCH2,398,448,395,16) wtch(2).hnd = fb_Label("Watch 3",windmain,IDWATCH3,3,464,395,16) wtch(3).hnd = fb_Label("Watch 4",windmain,IDWATCH4,398,464,395,16) For l=0 To 3 fb_CreateTooltips(wtch(l).hnd, "Left Click to Select"+Chr(13)+"Right Click to Reset", "",0) Next brkvhnd=fb_Label("Break on var",windmain,IDBRKVAR,3,480,790,16) fb_CreateTooltips(brkvhnd, "Click on to reset", "",0) dbgEdit1 = fb_edit("",windmain,IDNOTEWIN,3,430,790,143,WS_CHILD Or _ ES_WANTRETURN Or WS_VSCROLL Or WS_HSCROLL Or ES_MULTILINE Or ES_AUTOVSCROLL Or ES_AUTOHSCROLL ) 'or ES_READONLY) fb_ModStyle(dbgEdit1,0,WS_EX_NOPARENTNOTIFY,1) dbgstatus=fb_Status ("No Program",windmain, IDSTATUS) SendMessage(dbgstatus,SB_SETPARTS,5,Cast(LPARAM,@pstatus(0))) '08/04/2014 4-->5 listview1=fb_listview(windmain,IDDUMP,3,496,790,37) dump_set(listview1) menu_set() but_enable() 'some buttons disabled as no running prgm menu_enable() 'disable some options EnableMenuItem(menutools,IDHIDLOG,MF_GRAYED) 'redrawwindow(windmain,0,0,0) #Ifdef __FB_64BIT__ If Dir(ExePath+"\objdump.exe")="" Then fb_message("FBDEBUGGER 64BIT","Don't forget : objdump.exe must be in the same directory as fbdebugger"_ +Chr(13)+"it's necessary for extracting debugging data"+Chr(13)+"otherwise no debugging could be possible") #EndIf '-------------- pour test toolbar ------------------------------- 'dim as string tbText = "||Open|Save||New|Options|About||Exit" 'dim as integer ImIdx(9)={STD_FILEOPEN,STD_PROPERTIES,STD_COPY,STD_FILENEW,STD_HELP,STD_DELETE,IDB_STD_SMALL_COLOR} 'fb_TOOLBAR(windmain,900,6,"-",0,HINST_COMMCTRL,@ImIdx(0)) 'fb_TOOLBAR(windmain,900,4,tbText,,,,20,15) 'dim as integer Btnstyles(7)={0,TBSTYLE_CHECK,TBSTYLE_CHECKGROUP,TBSTYLE_CHECKGROUP,TBSTYLE_CHECKGROUP,0} 'dim bm AS HBITMAP 'bm=LoadImage(fb_hinstance,"step_over.bmp",IMAGE_BITMAP,23,19,LR_LOADFROMFILE) 'fb_TOOLBAR(windmain,900,1,"-",@Btnstyles(0),bm) 'DeleteObject(cast(HGDIOBJ,bm)) a rajouter en fin de proc '----------------- fin test toolbar --------------------------------- dsp_size() fb_show(windmain) ini_read() 'where find FBC.exe If Command<>"" Then treat_file("") 'case command line exe see treat_file End Sub '======================================================= 'Syntax: ' HWND = fb_TOOLBAR(HWND,ID,NumBtns,Text$="",BtnStyles=0,HBITMAP=0,ImgIndex=0,BtnWidth=0,BtnHeig 'ht=0,Style=0,ExStyle=0) ' ' HWND - Parent Handle ' ID - Toolbar control ID - each button will be consecutively ' numbered following this number. ' NumBtns - Number of buttons on the toolbar ' Text$ - An optional string of names for the buttons ' In the format of name1|name2 each separated by a | ' Each additional | will place separators (spaces) ' between those buttons name1|||name2 will place 2 ' spaces between names 1 and 2. ' BtnStyles - Optional array specifying the style of each button. ' HBITMAP - Optional handle to a bitmap to be placed on each button. ' ImgIndex - An optional array specifying the order the bitmaps are ' placed on the buttons. The default will be in the order ' the bitmap is supplied in. This also allows use of ' windows built in images. ' Special note: The last entry in the index when using the ' built in images should be the image list. ' i.e. IDB_STD_LARGE_COLOR Check the WIn API Help and the ' example for the available options. For the HBITMAP enter ' HINST_COMMCTRL. ' BtnWidth - The width and height of each button. This only has an effect ' BtnHeight if no text is being used. In which case the ??? name ' determines the button width. ' Style - Optional Styles and extended styles for the toolbar. ' ExStyle '------------------------------------------------------------------------------- 'Example #1 The minimum needed for a standard button bar with text labels '------------------------------------------------------------------------------- ' HWND = FB_TOOLBAR(HWND,ID,4,"OPEN|SAVE|SETUP|QUIT") '------------------------------------------------------------------------------- 'Example #2 The minimum needed for a standard button bar with text labels and ' built in windows icons. '------------------------------------------------------------------------------- 'tbText$ = "||Open|Save||New|Options|About||Exit" 'SET ImIdx[] 'STD_FILEOPEN,STD_FILESAVE,STD_COPY,STD_FILENEW,STD_HELP,STD_DELETE,IDB_STD_SMALL_COLOR 'END SET ' ' HWND = fb_TOOLBAR(Form1,ID,6,tbText$,0,HINST_COMMCTRL,ImIdx) 'autre exemple ' SET Btnstyles[] ' 0,TBSTYLE_CHECK,TBSTYLE_CHECKGROUP,TBSTYLE_CHECKGROUP,TBSTYLE_CHECKGROUP,0 ' END SET ' RAW tbText$ ' tbText$ = "||Open|Save||New|Options|About||Exit" ' RAW bm AS HBITMAP ' bm = fb_LOADBMP("testtool.bmp",0,1) ' hToolBar = fb_TOOLBAR(Form1,ID_Toolbar,6,tbText$,Btnstyles,bm) '====================================================================== private function fb_Toolbar (hwnd As HWND,id As Integer,NumBtns As Integer,Text As String,Bstyles As Integer Ptr,img As Any Ptr,imgidx As Integer Ptr,bx As Integer,by As Integer,Style As Integer,ExStyle As Integer) As HWND Dim a As HWND Dim As TBBUTTON tbb(50) '=callocate(NumBtns+20,sizeof(TBBUTTON)) Dim As TBADDBITMAP tbbitmap=(0,0) Static As BITMAP bm Dim seppos As Integer=0, absidx As Integer=0, index As Integer=0 ,txtlen As Integer=Len(Text) If Style=0 Then Style=WS_CHILD Or WS_BORDER A=CreateWindowEx(ExStyle,TOOLBARCLASSNAME,"",Style,0,0,0,0,hwnd,Cast(HMENU,id),fb_hInstance,NULL) SendMessage(A,TB_BUTTONSTRUCTSIZE,SizeOf(TBBUTTON),0) SendMessage(A,WM_SETFONT,Cast(WPARAM,GetStockObject(DEFAULT_GUI_FONT)),0) If bx<>0 And by<>0 Then SendMessage(A,TB_SETBUTTONSIZE,0,MAKELONG(bx,by)) While absidxAsc("-") Then Dim titles As String *1000 'callocate(2+txtlen,sizeof(char)) absidx=0 For index=0 To txtlen If Text[index]=Asc("|") Then If Text[index+1]=Asc("|") Or titles[0]=0 Then Continue For titles[absidx]=0 Else titles[absidx]=Text[index] End If absidx+=1 Next SendMessage(A,TB_ADDSTRING,0,Cast(LPARAM,StrPtr(titles))) ''inutile free(titles) End If SendMessage(A,TB_AUTOSIZE, 0, 0) ShowWindow(A,SW_SHOW) '''inutile deallocate tbb Return A End Function '======================================================= private function fb_edit(Text As String,hWnd As HWND,id As Integer,X As Integer,Y As Integer,W As Integer,H As Integer,ByVal Style As Integer,ByVal Exstyle As Integer) As HWND Dim A As HWND If Style=0 Then Style = WS_CHILD Or WS_VISIBLE Or ES_WANTRETURN Or _ WS_VSCROLL Or ES_MULTILINE Or ES_AUTOVSCROLL Or ES_AUTOHSCROLL End If If Exstyle=-1 Then Exstyle = WS_EX_CLIENTEDGE End If A = CreateWindowEx(Exstyle,"edit",Text, Style, _ X, Y, W, H,hWnd,Cast(HMENU,id),fb_hInstance,NULL) SendMessage(A,WM_SETFONT,Cast(WPARAM,GetStockObject(DEFAULT_GUI_FONT)),0) Return A End Function private function fb_editw(Text As WString,hWnd As HWND,id As Integer,X As Integer,Y As Integer,W As Integer,H As Integer,ByVal Style As Integer,ByVal Exstyle As Integer) As HWND Dim A As HWND If Style=0 Then Style = WS_CHILD Or WS_VISIBLE Or ES_WANTRETURN Or _ WS_VSCROLL Or ES_MULTILINE Or ES_AUTOVSCROLL Or ES_AUTOHSCROLL End If If Exstyle=-1 Then Exstyle = WS_EX_CLIENTEDGE End If A = CreateWindowExW(Exstyle,WStr("edit"),Text, Style, _ X, Y, W, H,hWnd,Cast(HMENU,id),fb_hInstance,NULL) SendMessage(A,WM_SETFONT,Cast(WPARAM,fonthdl),0) Return A End Function Private function fb_MDialog (DPro As Any Ptr,title As String,hWnd As HWND,X As Integer,Y As Integer,W As Integer,H As Integer,Style As Integer,Exstyle As Integer) As Integer Dim lpdt As DLGTEMPLATE Ptr Dim lpw As Short Ptr Dim ret As Integer lpdt=Callocate(256+(Len(title)*2),1) If Style=0 Then ' or DS_MODALFRAME lpdt->style=WS_POPUP Or WS_SYSMENU _ Or WS_CAPTION Else lpdt->style=Style End If lpdt->dwExtendedStyle=Exstyle Or WS_EX_TOOLWINDOW lpdt->cdit=0 lpdt->x =X lpdt->y =Y lpdt->cx=W lpdt->cy=H ' lpw=lpdt+len(DLGTEMPLATE) lpw=Cast(Short Ptr,lpdt+1) *lpw=0 :lpw+=1 'no menu *lpw=0 :lpw+=1 'no class, standard class MultiByteToWideChar(CP_ACP,0,StrPtr(title),-1,lpw,Len(title)+1) ret=DialogBoxIndirectParam(fb_hInstance,ByVal lpdt,hwnd,Cast( DLGPROC,dpro),0) DeAllocate(lpdt) Function=ret End Function '=========== modeless ================================= private function fb_Dialog (DPro As Any Ptr,title As String,hWnd As HWND,X As Integer,Y As Integer,W As Integer,H As Integer,Style As Integer,Exstyle As Integer) As HWND Dim lpdt As DLGTEMPLATE Ptr Dim lpw As Short Ptr Dim ret As HWND lpdt=Callocate(256+(Len(title)*2),1) If Style=0 Then lpdt->style=WS_POPUP Or WS_SYSMENU Or ws_border _ Or WS_CAPTION Or WS_VISIBLE Else lpdt->style=Style End If lpdt->dwExtendedStyle=Exstyle Or WS_EX_TOOLWINDOW lpdt->cdit=0 lpdt->x =X lpdt->y =Y lpdt->cx=W lpdt->cy=H lpw=Cast(Short Ptr,lpdt+1) *lpw=0 :lpw+=1 'no menu *lpw=0 :lpw+=1 'no class, standard class MultiByteToWideChar(CP_ACP,0,strptr(title),-1,lpw,Len(title)+1) ret=createDialogIndirectParam(fb_hInstance,ByVal lpdt,hwnd,Cast( DLGPROC,dpro),0) DeAllocate(lpdt) Return ret End Function '=============================================================== private function fb_Label(Text As String,hWnd As HWND,id As Integer,X As Integer,Y As Integer,W As Integer,H As Integer,ByVal Style As Integer,ByVal Exstyle As Integer) As HWND Dim A As HWND,size As SIZEL Ptr If Style=0 Then Style=WS_CHILD Or SS_NOTIFY Or SS_LEFTNOWORDWRAP Or WS_VISIBLE End If If Exstyle=-1 Then Exstyle = WS_EX_CLIENTEDGE End If A = CreateWindowEx(Exstyle,"static",Text,Style,X,Y,W,H,hWnd,Cast(HMENU,id),fb_hInstance,NULL) SendMessage(A,WM_SETFONT,Cast(WPARAM,GetStockObject(DEFAULT_GUI_FONT)),0) If W=0 Then 'size=GetTextSize(Text,A) MoveWindow(A,X,Y,size->cx,size->cy,TRUE) End If Return A End Function '===================================================================== private function fb_Form(Title As String,X As Integer,Y As Integer,W As Integer,H As Integer,Style As Integer,Exstyle As Integer) As HWND Dim A As HWND If Style=0 Then Style= WS_MINIMIZEBOX Or _ WS_SIZEBOX Or _ WS_CAPTION Or _ WS_MAXIMIZEBOX Or _ WS_POPUP Or _ WS_SYSMENU Or _ WS_CLIPCHILDREN End If A = CreateWindowEx(Exstyle,fb_szAppName,title,Style,X,Y,W,H, _ NULL,0,fb_hInstance,0) SendMessage(A,WM_SETFONT,Cast(WPARAM,GetStockObject(DEFAULT_GUI_FONT)),0) Return A End Function '======================================== private function fb_Tab (hWnd As HWND, id As Integer,X As Integer _ ,Y As Integer,W As Integer,H As Integer,Style As Integer,StyleEx As Integer) As HWND Dim hMainTab As HWND If Style=0 Then Style=WS_CHILD Or WS_VISIBLE Or WS_TABSTOP Or WS_CLIPSIBLINGS Or TCS_TABS Or TCS_SINGLELINE Or TCS_FOCUSONBUTTONDOWN hMainTab=CreateWindowEx(StyleEx,WC_TABCONTROL,NULL,Style,X,Y,W,H,hWnd,Cast(HMENU,id),fb_hInstance,NULL) If hMainTab=0 Then Return NULL SendMessage(hMainTab,WM_SETFONT,Cast(WPARAM,GetStockObject(DEFAULT_GUI_FONT)),0) Return hMainTab End Function private sub tab_add(i As Integer,htab As hwnd,Nm As String) 'image as HIMAGELIST à voir mettre param im Dim ttc_item As TC_ITEM Clear ttc_item,0,SizeOf(ttc_item) 'Insert tabs in the tab control... ttc_item.mask=TCIF_TEXT ttc_item.iImage=-1 'If image<>NULL then ' ttc_item.mask = TCIF_TEXT Or TCIF_IMAGE ' ttc_item.iImage=im 'End if ttc_item.pszText=StrPtr(Nm) ttc_item.lParam=0 SendMessage(htab,TCM_INSERTITEM,i,Cast(LPARAM,@ttc_item)) 'If image then SendMessage(hMainTab,TCM_SETIMAGELIST,0,image) End Sub '============================================= private function fb_RichEdit(Text As String,hWnd As HWND,id As Integer,X As Integer,Y As Integer,W As Integer, _ H As Integer,Style As Integer,Exstyle As Integer) As HWND If LoadLibrary("RICHED20.DLL")=0 Then fb_message("LOADLIBRARY ERROR","riched20.dll",MB_SYSTEMMODAL) End If Dim A As HWND If Style=0 Then ' or WS_CLIPSIBLINGS Style=WS_CHILD Or WS_VISIBLE Or ES_NOHIDESEL Or ES_READONLY Or _ WS_HSCROLL Or WS_VSCROLL Or ES_MULTILINE Or _ ES_AUTOVSCROLL Or ES_AUTOHSCROLL Or ES_WANTRETURN End If If Exstyle=-1 Then Exstyle=WS_EX_CLIENTEDGE End If A=CreateWindowEx(Exstyle,"RichEdit20a",NULL,Style,X,Y,W,H,hWnd,Cast(HMENU,id),fb_hInstance,NULL) '''SetWindowRTFText(A,Text) SendMessage(A,WM_SETFONT,Cast(WPARAM,GetStockObject(DEFAULT_GUI_FONT)),0) Function=A End Function '============================================= private function fb_Group (Text As String,hWnd As HWND,id As Integer,X As Integer,Y As Integer,W As Integer,H As Integer,Style As Integer,Exstyle As Integer) As HWND Dim A As HWND If Style=0 Then Style=BS_GROUPBOX Or WS_CHILD Or WS_VISIBLE End If A = CreateWindowEx(Exstyle,"button",Text,Style,X,Y,W,H,hWnd,Cast(HMENU,id),fb_hInstance,NULL) SendMessage(A,WM_SETFONT,Cast(WPARAM,GetStockObject(ANSI_VAR_FONT)),0) ''SYSTEM_FONT DEFAULT_GUI_FONT Function=A End Function '===================================================================== private function fb_Checkbox(Text As String,hWnd As HWND,id As Integer,X As Integer,Y As Integer,W As Integer,H As Integer,Style As Integer,Exstyle As Integer) As HWND Dim A As HWND If Style=0 Then Style=WS_CHILD Or WS_VISIBLE Or BS_AUTOCHECKBOX Or WS_TABSTOP End If A = CreateWindowEx(Exstyle,"button",Text,Style,X,Y,W,H,hWnd,Cast(HMENU,id),fb_hInstance,NULL) SendMessage(A,WM_SETFONT,Cast(WPARAM,GetStockObject(DEFAULT_GUI_FONT)),0) Return A End Function '===================================================================== private function fb_radio(Text As String,hWnd As HWND,id As Integer,X As Integer,Y As Integer,W As Integer,H As Integer,Style As Integer,Exstyle As Integer) As HWND Dim A As HWND If Style=0 Then Style=WS_CHILD Or WS_VISIBLE Or BS_AUTORADIOBUTTON Or WS_TABSTOP End If A = CreateWindowEx(Exstyle,"button",Text,Style,X,Y,W,H,hWnd,Cast(HMENU,id),fb_hInstance,NULL) SendMessage(A,WM_SETFONT,Cast(WPARAM,GetStockObject(DEFAULT_GUI_FONT)),0) Return A End Function '===================================================================== private function fb_combobox(hWnd As HWND,id As Integer,X As Integer,Y As Integer,W As Integer,H As Integer,Style As Integer,Exstyle As Integer) As HWND Dim A As HWND If Style=0 Then 'cbs_simple cbs_dropdown list or CBS_SORT Style=WS_CHILD Or WS_VISIBLE Or CBS_DROPDOWNLIST Or WS_VSCROLL Or WS_TABSTOP End If If Exstyle=-1 Then Exstyle=WS_EX_CLIENTEDGE End If A = CreateWindowEx(Exstyle,"Combobox",NULL,Style,X,Y,W,H,hWnd,Cast(HMENU,id),fb_hInstance,NULL) SendMessage(A,WM_SETFONT,Cast(WPARAM,GetStockObject(DEFAULT_GUI_FONT)),0) Return A End Function '===================================================================== private function fb_listbox(hWnd As HWND,id As Integer,X As Integer,Y As Integer,W As Integer,H As Integer,Style As Integer,Exstyle As Integer) As HWND Dim A As HWND If Style=0 Then Style=LBS_STANDARD Or WS_CHILD Or WS_VISIBLE Or WS_HSCROLL Or WS_VSCROLL Or WS_TABSTOP End If If Exstyle=-1 Then Exstyle=WS_EX_CLIENTEDGE End If A = CreateWindowEx(Exstyle,"listbox",NULL,Style,X,Y,W,H,hWnd,Cast(HMENU,id),fb_hInstance,NULL) SendMessage(A,WM_SETFONT,Cast(WPARAM,GetStockObject(DEFAULT_GUI_FONT)),0) Return A End Function '===================================================================== private function fb_datepick(hWnd As HWND,id As Integer,X As Integer,Y As Integer,W As Integer,H As Integer,Style As Integer,Exstyle As Integer) As HWND Dim A As HWND If Style=0 Then Style=WS_CHILD Or WS_TABSTOP Or WS_VISIBLE Or DTS_LONGDATEFORMAT End If If Exstyle=-1 Then Exstyle=WS_EX_CLIENTEDGE End If A = CreateWindowEx(Exstyle,"SysDateTimePick32",NULL,Style,X,Y,W,H,hWnd,Cast(HMENU,id),fb_hInstance,NULL) SendMessage(A,WM_SETFONT,Cast(WPARAM,GetStockObject(DEFAULT_GUI_FONT)),0) Function=A End Function '=================== private function fb_UpDown (hWnd As HWND,X As Integer,Y As Integer,W As Integer,H As Integer,Lo As Integer,Hi As Integer,uStart As Integer) As HWND Dim As HWND UpDn Dim As HWND Buddy Dim As Integer Style = WS_CHILD Or WS_VISIBLE Or WS_TABSTOP Or ES_NUMBER Or ES_LEFT Or ES_AUTOHSCROLL Buddy=CreateWindowEx(WS_EX_CLIENTEDGE,"edit",0,Style,X,Y,W,H,hWnd,0,fb_hInstance,NULL) SendMessage(buddy,WM_SETFONT,Cast(WPARAM,GetStockObject(DEFAULT_GUI_FONT)),0) 'just for 16 bit 'UpDn=CreateUpDownControl(WS_CHILD or WS_VISIBLE or WS_TABSTOP or WS_BORDER or _ ' UDS_ARROWKEYS or UDS_SETBUDDYINT or UDS_ALIGNRIGHT, _ ' X,Y,W,H,hWnd,0,fb_hInstance,Buddy,Hi,Lo,uStart) 'for 32 bits range updn=CreateWindowEx(0,UPDOWN_CLASS,0, _ WS_CHILD Or WS_VISIBLE Or WS_TABSTOP Or WS_BORDER Or _ UDS_ARROWKEYS Or UDS_SETBUDDYINT Or UDS_ALIGNRIGHT Or UDS_WRAP Or UDS_NOTHOUSANDS, _ 0,0,0,0,hwnd,0,fb_hInstance,NULL) SendMessage(updn,UDM_SETBUDDY,Cast(WPARAM,buddy),0) SendMessage(updn,UDM_SETRANGE32,lo,hi) SendMessage(updn,UDM_SETPOS32,0,ustart) Return UpDn End Function '===================================================================== private function fb_listview(hWnd As HWND,id As Integer,X As Integer,Y As Integer,W As Integer,H As Integer,Style As Integer,Exstyle As Integer) As HWND Dim A As HWND,i As Integer, lvStyle As Integer Dim lvCol As LVCOLUMN If Style=0 Then Style=WS_CHILD Or WS_TABSTOP Or WS_VISIBLE Or LVS_REPORT Or LVS_SINGLESEL Or LVS_SHOWSELALWAYS Or WS_BORDER 'or LVS_NOCOLUMNHEADER If Exstyle=-1 Then Exstyle=0 A = CreateWindowEx(Exstyle,"SysListView32",NULL,Style,X,Y,W,H,hWnd,Cast(HMENU,id),fb_hInstance,NULL) 'SendMessage(A,WM_SETFONT,Cast(WPARAM,GetStockObject(ANSI_FIXED_FONT)),0)' DEFAULT_GUI_FONT 19/11/2014 SendMessage(A,WM_SETFONT,Cast(WPARAM,fb_Set_Font("Courier New",8)),0)'19/11/2014 lvStyle = SendMessage(a,LVM_GETEXTENDEDLISTVIEWSTYLE, 0, 0) lvStyle = lvStyle Or LVS_EX_GRIDLINES Or LVS_EX_FULLROWSELECT Or LVS_EX_ONECLICKACTIVATE SendMessage(A,LVM_SETEXTENDEDLISTVIEWSTYLE,0,ByVal lvStyle) Return A End Function private sub Trackbar_buddy(htrackbar As HWND ,orient As Integer =1,hlvt As String ="",hrvb As String ="") 'orient : 1 --> horizontal (default), 2 --> vertical Dim As HWND hwndBuddy Dim As HWND hwnd=getparent(htrackbar) Dim As Integer style1=WS_CHILD Or WS_VISIBLE,style2=WS_CHILD Or WS_VISIBLE Const staticWidth = 50 Const staticHeight = 20 If orient=1 Then '''' For horizontal Trackbar. style1=style1 Or SS_RIGHT style2=style2 Or SS_LEFT Else style1=style1 Or SS_CENTER style2=style1 EndIf If hlvt<>"" Then hwndBuddy = CreateWindowEx(0, "STATIC", hlvt,style1, _ 0, 0, staticWidth, staticHeight, hwnd, NULL, fb_hInstance, NULL) SendMessage(hwndBuddy,WM_SETFONT,Cast(WPARAM,GetStockObject(ANSI_FIXED_FONT)),0) SendMessage(htrackbar, TBM_SETBUDDY, TRUE, Cast(LPARAM,hwndBuddy)) End If '------------------------------------------------- If hrvb<>"" Then hwndBuddy = CreateWindowEx(0, "STATIC", hrvb, style2, _ 0, 0, staticWidth, staticHeight, hwnd, NULL, fb_hInstance, NULL) SendMessage(hwndBuddy,WM_SETFONT,Cast(WPARAM,GetStockObject(ANSI_FIXED_FONT)),0) SendMessage(htrackbar, TBM_SETBUDDY, FALSE, Cast(LPARAM,hwndBuddy)) End If End Sub private function fb_setcolor(h As HWND,s As Integer,c As Integer,d As Integer) As Integer '''#define WM_USER &h0400 '''#define EM_SETCHARFORMAT 1092 'wm_user+68 ''#define CFM_COLOR &h40000000 ''#define SCF_SELECTION 1 ''#define SCF_WORD 2 ''#define SCF_DEFAULT 0 ''#define SCF_ALL 4 ''#define CFE_AUTOCOLOR 1073741824 Dim lpcharformat As CHARFORMAT,selt As Integer Select Case s Case 0 selt=0 'set to the default format Case 1 selt=SCF_ALL 'Applies the formatting to all text in the control. Case 2 selt=SCF_SELECTION 'Applies the formatting to the current selection. Case 3 selt=SCF_WORD Or SCF_SELECTION 'Applies the formatting to the selected word or words. End Select lpcharformat.cbsize=Len(charformat) lpcharformat.crtextcolor=c lpcharformat.dwmask= CFM_UNDERLINE Or CFM_BOLD Or CFM_COLOR Or CFM_ITALIC If d=1 Then lpcharformat.dweffects=CFE_AUTOCOLOR ElseIf d=2 Then lpcharformat.dweffects=CFE_UNDERLINE Or CFE_BOLD 'Or STRIKEOUT' ElseIf d=3 Then ' lpcharformat.dweffects=CFE_ITALIC End If If sendmessage(h,EM_SETCHARFORMAT,selt,Cast(LPARAM,@lpcharformat))=0 Then fb_message("ERROR","Set color format") Return FALSE Else Return TRUE End If End Function '============================================= private function fb_Status (Text As String, hWnd As HWND, ID As Integer) As HWND 'Return CreateStatusWindow(WS_CHILD Or WS_BORDER Or WS_VISIBLE ,Text,hWnd,ID) ' Or CCS_TOP or or SBS_SIZEGRIP '23/08/2015 '======== return CreateWindowEx(0,STATUSCLASSNAME,text,SBARS_SIZEGRIP or WS_CHILD or WS_VISIBLE, 0, 0, 0, 0, hwnd,Cast (HMENU,id),fb_hInstance,NULL) '======== End Function '============================================== private sub fb_show (hwnd As HWND) RedrawWindow(hwnd,ByVal 0,0,0) ShowWindow(hwnd,SW_SHOW) End Sub '============================================== private function fb_ModStyle(hWnd As HWND, dwAdd As Integer, dwRemove As Integer, bEx As Integer) As Integer Dim dwstyle As UInteger Dim dwnewstyle As UInteger SetLastError(0) If bex Then dwStyle = GetWindowLong(hWnd,GWL_EXSTYLE) dwNewStyle = (dwStyle And (Not dwRemove)) Or dwAdd SetWindowLong(hWnd, GWL_EXSTYLE,dwNewStyle) Else dwStyle = GetWindowLong(hWnd,GWL_STYLE) dwNewStyle = (dwStyle And (Not dwRemove)) Or dwAdd SetWindowLong(hWnd, GWL_STYLE,dwNewStyle) End If SetWindowPos(hWnd,NULL,0,0,0,0,SWP_NOMOVE Or SWP_NOSIZE Or SWP_NOZORDER Or SWP_FRAMECHANGED) If GetLastError() = 0 Then Return TRUE Else Return FALSE End If End Function '============================================== private function fb_button (Text As String,ByVal hWnd As HWND,ByVal id As Integer,ByVal X As Integer,ByVal Y As Integer,ByVal W As Integer,ByVal H As Integer, Style As Integer, Exstyle As Integer) As HWND Dim A As HWND If Style=0 Then Style=(WS_CHILD Or WS_VISIBLE Or BS_MULTILINE Or BS_PUSHBUTTON Or WS_TABSTOP) End If If Exstyle=-1 Then Exstyle=WS_EX_STATICEDGE End If A = CreateWindowEx(Exstyle,"button",Text,Style, X, Y, W, H,hWnd,Cast (HMENU,id) ,fb_hInstance,NULL) SendMessage(A,WM_SETFONT,Cast(WPARAM,GetStockObject(DEFAULT_GUI_FONT)),0) If W=0 Then Dim hdc As HDC hdc=GetDC(A) Dim vsize As SIZEL GetTextExtentPoint32(hdc,Text,Len(Text),@vsize) ReleaseDC(A,hdc) MoveWindow(A,X,Y,vsize.cx+(vsize.cx*0.5),vsize.cy+(vsize.cy*0.32),TRUE) End If Return A End Function '=================================================================== private function fb_message(title As String ,text As String,style As Integer) As Integer If title="" Then Return MessageBox(GetActiveWindow(),text," ",style) Else Return MessageBox(GetActiveWindow(),text,title,style) End If End Function '=================================================== private function fb_Treeview(hWnd As HWND,id As Integer,X As Integer,Y As Integer,W As Integer,H As Integer,Style As Integer,Exstyle As Integer) As HWND Dim A As HWND If Style=0 Then Style=WS_VISIBLE Or WS_CHILD Or TVS_HASLINES Or TVS_HASBUTTONS Or TVS_LINESATROOT Or TVS_SHOWSELALWAYS End If If Exstyle-1 Then Exstyle=WS_EX_CLIENTEDGE End If A =CreateWindowEx(Exstyle,WC_TREEVIEW,NULL,Style,X,Y,W,H,hWnd,Cast(HMENU,id),fb_hinstance,NULL) 'SendMessage(A,WM_SETFONT,GetStockObject(DEFAULT_GUI_FONT),0) SendMessage(A,WM_SETFONT,Cast(WPARAM,GetStockObject(ANSI_FIXED_FONT)),0) Return A End Function '========================================================================= private function fb_CreateTooltips(hControl As HWND, Text As String, Title As String, ToolIcon As Integer) As HWND 'Create tooltip class fb_htooltip must be global Dim Balloon As TOOLINFO Dim ttStyle As Integer Dim hwnd As HWND If fb_htooltip=NULL Then hwnd=getparent(hcontrol) If hwnd=NULL Then hWnd = GetActiveWindow() 'Create the tooltip class (GetWindowLong(hWnd,GWL_HINSTANCE) utilisable à la place de getmodu...) ttStyle = 0 '64 for balloon tips 0 -->rectangle fb_hToolTip = CreateWindowEx(0,"ToolTips_Class32","",ttStyle,0,0,0,0,hWnd,0,GetModuleHandle(0),0) If fb_htooltip=NULL Then Exit Function 'Set up the tool tips SendMessage(fb_hToolTip, TTM_SETMAXTIPWIDTH, 0 , 180) SendMessage(fb_hToolTip, TTM_SETDELAYTIME, TTDT_INITIAL ,400) SendMessage(fb_hToolTip, TTM_SETDELAYTIME, TTDT_RESHOW ,600) End If 'Set structure Balloon.cbSize = Len(TOOLINFO) Balloon.uFlags = TTF_IDISHWND Or TTF_SUBCLASS Balloon.hwnd = hwnd Balloon.uId = Cast(UInteger,hControl) Balloon.lpszText = StrPtr(Text) Balloon.hinst = fb_HINSTANCE 'Send message SendMessage(fb_hToolTip, TTM_ADDTOOL, 0,Cast(LPARAM,@Balloon)) 'Add a title If Len(Title) > 0 Then SendMessage(fb_hToolTip, 1056, ToolIcon,Cast(LPARAM,StrPtr(title))) End If 'Return handle Return fb_hToolTip End Function '------------------------------------------------------------------------ private sub fb_UpdateTooltip(hToolTip As HWND, hControl As HWND, Text As String, Title As String, ToolIcon As Integer) Dim Balloon As TOOLINFO 'set structure Balloon.cbSize = Len(TOOLINFO) 'Balloon.hwnd = getparent(hcontrol) Balloon.uFlags = TTF_IDISHWND' OR TTF_SUBCLASS Balloon.uId = Cast(UInteger,hControl) Balloon.lpszText = StrPtr(Text) 'Balloon.hinst = fb_HINSTANCE 'send message to update text SendMessage(hToolTip, TTM_UPDATETIPTEXT, 0, Cast(LPARAM,@Balloon )) 'add a title If Len(Title) > 0 Then '1056 SendMessage(hToolTip, 1056, ToolIcon, Cast(LPARAM,StrPtr(Title)) ) End If End Sub '============================================================== private function fb_find(d As Integer,s As String) As Integer Dim ftext As FINDTEXT,range As CHARRANGE,ret As Integer Dim nbl As Integer,nbc As Integer,mov As Integer sendmessage(dbgrichedit,EM_EXGETSEL,0, Cast(LPARAM,@range)) 'get pos cursor nbl=sendmessage(dbgrichedit,EM_GETLINECOUNT,0,0)-1' number of lines (zero based) nbc=sendmessage(dbgrichedit,EM_LINEINDEX ,nbl,0) ' nb of char except last line nbc+=sendmessage(dbgrichedit,EM_LINELENGTH,nbc,0) 'total of char (added last line) If d Then 'bottom direction ftext.chrg.cpmin=range.cpmax ftext.chrg.cpmax=nbc mov=1 'FR_DOWN Else 'top ftext.chrg.cpmin=range.cpmin ftext.chrg.cpmax=0 mov=0 'FR_DOWN End If ftext.lpstrText=StrPtr(s) ret=sendmessage(dbgrichedit,EM_FINDTEXT,mov+chkcase,Cast(LPARAM,@ftext)) If ret=-1 Then 'not found If d Then range.cpmin=0:range.cpmax=0 sendmessage(dbgrichedit,EM_EXSETSEL,0,Cast(LPARAM,@range)) 'restart top Return SetWindowText(hfindbx, "Bottom reached go to top") Else range.cpmin=nbc :range.cpmax=nbc sendmessage(dbgrichedit,EM_EXSETSEL,0,Cast(LPARAM,@range)) 'restart bottom Return SetWindowText(hfindbx, "Top reached go to bottom") End If Else range.cpmin=ret range.cpmax=ret+Len(s) sendmessage(dbgrichedit,EM_EXSETSEL,0,Cast(LPARAM,@range)) 'inverse Return SetWindowText(hfindbx, "Findtext (Circular)") End If End Function '===================================================== 'example getfilename("Essai choississez un fichier","Tous *.*|*.*|test *.txt|*.txt;*.jpg||",0,0,0,"freebasic\") private function fb_GetFileName(Title As String, Filt As String,Flag As Integer,hWnd As HWND,Flags As Integer,InitialDr As String) As String Dim As OPENFILENAME vOpenFilename Dim filter As ZString *500 Dim filename As ZString *2000 Dim Extension As String *256 Dim Counter As Integer Dim initialdir As ZString *500 filter=filt initialdir=initialdr Clear filename,,2000 ' RAZ zone : memset(&OpenFileName,0,sizeof(OpenFileName)) For Counter=0 To Len(Filter) If Filter[Counter]=Asc("|") Then Extension[Counter]=0 Else Extension[Counter]=Filter[Counter] End If Next 'CmDlgHook=SetWindowsHookEx(WH_CBT,(HOOKPROC)SBProc,(HINSTANCE)NULL,GetCurrentThreadId()) vOpenFileName.lStructSize=SizeOf(OPENFILENAME) vOpenFileName.hwndOwner=hWnd vOpenFileName.hInstance=0 vOpenFileName.lpstrFilter=Cast(lpstr,@Extension) vOpenFileName.lpstrTitle=StrPtr(title) vOpenFileName.nMaxFile=2000 vOpenFileName.nMaxFileTitle=0 vOpenFileName.lpstrFile=@filename vOpenFileName.lpstrFileTitle=NULL vOpenFileName.lpstrCustomFilter=0 vOpenFileName.nMaxCustFilter=0 vOpenFileName.nFilterIndex=0 vOpenFileName.lpstrInitialDir=@(InitialDir) vOpenFileName.nFileOffset=0 vOpenFileName.nFileExtension=0 vOpenFileName.lpstrDefExt=0 vOpenFileName.lCustData=0 vOpenFileName.lpfnHook=0 vOpenFileName.lpTemplateName=0 If Flags=0 Then vOpenFileName.Flags = OFN_HIDEREADONLY Or OFN_CREATEPROMPT Or OFN_EXPLORER 'or OFN_ALLOWMULTISELECT Else vOpenFileName.Flags = Flags Or OFN_EXPLORER End If If GetopenFileName(@vOpenFileName) Then counter=0 Do If filename[counter]=0 Then If filename[counter+1]=0 Then Exit Do filename[counter]=Asc("|") End If counter+=1 Loop End If Return filename End Function private sub dsp_sizecalc() 'calculate the maximum number of lines displayed in the window Dim As HDC hdc Dim As RECT wndRect Dim As Integer rectheight Dim As TEXTMETRIC tm 'get height of window SendMessage( dbgrichedit, EM_GETRECT, 0 , Cast(LPARAM,@wndrect)) rectheight = wndrect.bottom - wndrect.top 'get height of font being used hdc = GetDC( dbgrichedit ) If hdc=0 Then dspsize=10:Exit Sub 'not very good selectobject(hdc,fonthdl) GetTextMetrics( hdc, @tm ) ReleaseDC( dbgrichedit, hdc ) 'use height of font and height of rich edit control dspsize=rectheight\tm.tmHeight dspwidth=(wndrect.right - wndrect.left)\tm.tmAveCharWidth-4 End Sub Private sub thread_rsm() WriteProcessMemory(dbghand,Cast(LPVOID,rLine(thread(threadcur).sv).ad),@rLine(thread(threadcur).sv).sv,1,0) 'restore old value for execution resumethread(threadhs) End Sub '============================================= private function WndProc ( ByVal hWnd As HWND, _ ByVal message As Integer, _ ByVal wParam As Integer, _ ByVal lParam As Integer ) As Integer WndProc=0 Static x As Integer,y As Integer,pnt As Point,hbrsh As HBRUSH If flagtuto=1 Then If message<>WM_DESTROY Then Return DefWindowProc( hWnd, message, wParam, lParam ) ElseIf flagtuto=2 Then flagtuto=1 EndIf Select Case message Case WM_CREATE Case WM_LBUTTONDOWN 'only if mini screen If dsptyp>99 Then SetCapture(windmain) x = LoWord(lParam) y = HiWord(lParam) End If Case WM_MOUSEMOVE If wParam = MK_LBUTTON And dsptyp>99 Then GetCursorPos(@pnt) SetWindowPos(windmain, 0, pnt.x - x, pnt.y - y, 0, 0, SWP_NOSIZE Or SWP_NOZORDER) End If Case WM_LBUTTONUP ReleaseCapture() Case WM_CONTEXTMENU ' right click GetCursorPos(@pnt) If wparam=dbgrichedit Then TrackPopupMenuEx(menuedit, TPM_LEFTALIGN Or TPM_RIGHTBUTTON, pnt.x, pnt.y, hWnd,ByVal NULL) PostMessage(windmain, WM_NULL, 0, 0) ElseIf wparam=tviewvar Then TrackPopupMenuEx(menuvar, TPM_LEFTALIGN Or TPM_RIGHTBUTTON, pnt.x, pnt.y, hWnd,ByVal NULL) PostMessage(windmain, WM_NULL, 0, 0) ElseIf wparam=tviewprc Then TrackPopupMenuEx(menuproc, TPM_LEFTALIGN Or TPM_RIGHTBUTTON, pnt.x, pnt.y, hWnd,ByVal NULL) PostMessage(windmain, WM_NULL, 0, 0) ElseIf wparam=tviewthd Then TrackPopupMenuEx(menuthread, TPM_LEFTALIGN Or TPM_RIGHTBUTTON, pnt.x, pnt.y, hWnd,ByVal NULL) PostMessage(windmain, WM_NULL, 0, 0) ElseIf wparam=tviewwch Then If wtchcpt Then TrackPopupMenuEx(menuwatch, TPM_LEFTALIGN Or TPM_RIGHTBUTTON, pnt.x, pnt.y, hWnd,ByVal NULL) PostMessage(windmain, WM_NULL, 0, 0) Else fb_message("Context menu for watched var list","Watched var list is empty"+Chr(13)+"Nothing to do") End If ElseIf wparam=listview1 And prun Then If hdumpbx=0 Then fb_Dialog(@dump_box,"Manage dump",windmain,283,25,120,150) PostMessage(windmain, WM_NULL, 0, 0) End If Else 'Erase watch ? For i As Integer =0 To WTCHMAIN If wparam=wtch(i).hnd Then watch_del(i):Exit For Next End If Case WM_KEYDOWN Dim As Integer sccheck=wparam+(getkeystate(VK_CONTROL) And &h8000)/&h8000*&hF000+(getkeystate(VK_MENU) And &h8000)/&h8000*&hF0000+(getkeystate(VK_SHIFT) And &h8000)/&h8000*&hF00000 For i As Integer =0 To shcutnb-1 If sccheck=shcut(i).sccur Then If GetMenuState(shcut(i).scmenu,shcut(i).scidnt,MF_BYCOMMAND)=0 Then SendMessage(windmain,WM_COMMAND,makelong(shcut(i).scidnt,BN_CLICKED),0):Return TRUE'NULL'TRUE 2017/07/15 true replaced by null EndIf Exit For EndIf Next Case WM_DROPFILES drag_exe(Cast(handle,wParam)) Case WM_COMMAND Select Case LoWord(wparam) Case IDBUTSTEP 'STEP stopcode=0 bcktrk_close SetFocus(windmain) 'just to lose focus thread_rsm() Case IDBUTSTEPP 'STEP+ over procin=procsk runtype=RTRUN but_enable() bcktrk_close SetFocus(windmain) thread_rsm() Case IDBUTSTEPM 'STEP- out If (threadcur<>0 andalso proc_find(thread(threadcur).id,KLAST)<>proc_find(thread(threadcur).id,KFIRST)) _ OrElse (threadcur=0 AndAlso proc(procr(proc_find(thread(0).id,KLAST)).idx).nm<>"main") Then 'impossible to go out first proc of thread, constructore for shared 22/12/2015 procad=procsv runtype=RTRUN but_enable() End If bcktrk_close SetFocus(windmain) thread_rsm() Case IDBUTSTEPB 'STEP at bottom of proc If rline(thread(threadcur).sv).ad<>proc(procsv).fn Then 'if current line is end of proc simple step procbot=procsv runtype=RTRUN but_enable() EndIf bcktrk_close SetFocus(windmain) thread_rsm() Case IDBUTSTEPT 'STEP at top of proc If rline(thread(threadcur).sv).ad<>proc(procsv).fn Then 'if current line is end of proc simple step proctop=TRUE runtype=RTRUN but_enable() EndIf bcktrk_close SetFocus(windmain) thread_rsm() Case IDBUTAUTO,IDTHRDAUT 'simple and multi thread auto threadaut=0 If LoWord(wparam)=IDTHRDAUT Then For i As Integer =0 To threadnb If thread(i).exc Then threadaut+=1 Next If threadaut<2 Then fb_message("Automatic execution","Not enough selected thread so normal auto") EndIf runtype=RTAUTO but_enable() bcktrk_close SetFocus(windmain) thread_rsm() Case IDBUTRUN runtype=RTRUN but_enable() bcktrk_close SetFocus(windmain) fasttimer=Timer thread_rsm() Case IDFASTRUN bcktrk_close but_enable() SetFocus(windmain) fastrun() Case IDBUTSTOP If runtype=RTFREE Or runtype=RTFRUN Then runtype=RTFRUN 'to treat free as fast For i As Integer = 1 To linenb 'restore every breakpoint WriteProcessMemory(dbghand,Cast(LPVOID,rline(i).ad),@breakcpu,1,0) Next Else runtype=RTSTEP:procad=0:procin=0:proctop=FALSE:procbot=0 EndIf Stopcode=CSHALTBU SetFocus(dbgrichedit) Case IDBUTMINI If dsptyp>99 Then 'set full screen dsptyp-=100 DeleteObject(Cast(HGDIOBJ,hbrsh)) fb_ModStyle (windmain,WS_MAXIMIZEBOX Or WS_MINIMIZEBOX Or WS_SIZEBOX Or WS_CAPTION Or WS_SYSMENU, 0,FALSE) SetWindowPos(windmain,HWND_NOTOPMOST,recsav.left,recsav.top,recsav.right-recsav.left,recsav.bottom-recsav.top,SWP_NOACTIVATE)' OR SWP_NOSIZE OR SWP_NOMOVE Else 'set mini screen dsptyp+=100 GetWindowRect(windmain,@recsav) fb_ModStyle (windmain,0,WS_MAXIMIZEBOX Or WS_MINIMIZEBOX Or WS_SIZEBOX Or WS_CAPTION Or WS_SYSMENU, FALSE) hbrsh=createsolidbrush(&h0000FF) 'red background 'changed for 64bit 'SetClassLong(windmain,GCL_HBRBACKGROUND,Cast(Long,hbrsh)) SetClassLongPtr(windmain,GCLP_HBRBACKGROUND,Cast(Long_Ptr,hbrsh)) SetWindowPos(windmain,HWND_TOPMOST,50,50,456,45,SWP_NOACTIVATE ) ' OR SWP_NOSIZE OR SWP_NOMOVE End If SetFocus(windmain) Case IDBUTTOOL GetCursorPos(@pnt) If Dir(ExePath+"\dbg_log_file.txt")="" Then 'the file can be deleted by user outside EnableMenuItem(menutools,IDSHWLOG,MF_GRAYED) EnableMenuItem(menutools,IDDELLOG,MF_GRAYED) Else EnableMenuItem(menutools,IDSHWLOG,MF_ENABLED) EnableMenuItem(menutools,IDDELLOG,MF_ENABLED) End If TrackPopupMenuEx(menutools, TPM_LEFTALIGN Or TPM_RIGHTBUTTON, pnt.x, pnt.y, hWnd,ByVal NULL) PostMessage(windmain, WM_NULL, 0, 0) SetFocus(windmain) Case IDBUTFILE treat_file("£$_NO$FILE_$£") 'hope that nobody uses a such name ;-) SetFocus(windmain) Case IDRICHWIN 'click sur dbgrichEdit prévoir remettre ligne en cours 'tester pour uniquement mouse sur client area Case IDNOTEWIN If HiWord(wparam)=EN_CHANGE Then If SendMessage(dbgedit1,EM_GETMODIFY,0,0) Then SendMessage(butnotes,BM_SETIMAGE,IMAGE_BITMAP,Cast(LPARAM,bmb(21))) EndIf EndIf 'SetFocus(windmain) Case IDBUTRRUNE 'restart exe Dim As Double dtempo=FileDateTime(exename) If exedate<>0 AndAlso exedate=dtempo Then flagrestart=sourcenb EndIf If wtchcpt Then flagwtch=1 treat_file(exename) Case IDLSTEXE 'last 10 EXE(s) GetCursorPos(@pnt) Dim exelist As HMENU exelist = CreatepopupMenu() For i As Byte =0 To 9 If savexe(i)<>"" Then AppendMenu(exelist, MF_STRING,1200+i,savexe(i)):If i=0 Then AppendMenu(exelist, MF_SEPARATOR, 0, "") Next TrackPopupMenuEx(exelist, TPM_LEFTALIGN Or TPM_RIGHTBUTTON, pnt.x, pnt.y, hWnd,ByVal NULL) destroymenu(exelist) PostMessage(windmain, WM_NULL, 0, 0) Case 1200 To 1209 exename=savexe(LoWord(wparam)-1200) treat_file(exename) Case IDBUTATTCH 'attach running process If prun AndAlso kill_process("Trying to attach but debuggee still running")=FALSE Then 'nothing to do but better algo Else GetCursorPos(@pnt) fb_MDialog(@attach_box,"Attachment to a running process",windmain,pnt.x-300,pnt.y,100,150) End If Case IDBUTFREE If fb_message("FREE","Release debugged prgm",MB_YESNO Or MB_ICONQUESTION)=IDYES Then For i As Integer = 1 To linenb 'restore old instructions WriteProcessMemory(dbghand,Cast(LPVOID,rline(i).ad),@rLine(i).sv,1,0) Next runtype=RTFREE but_enable() thread_rsm() End If Case IDBUTKILL 'kill process kill_process("Terminate immediatly no saved data, other option Release") Case IDCMDLPRM 'open settings fb_MDialog(@settings_box,"Settings",windmain,50,25,337,196) Case IDABOUT '24/08/2015 If fb_message("FB DEBUGGER "+ver3264,"Debugger for FreeBASIC (only Win32/64)"+Chr(13)+Chr(13)+fbdebuggerversion+" / "+__DATE__+Chr(13)+"(C) L.GRAS sarg @ aliceadsl . fr"+Chr(13)+Chr(13) _ +"Select YES for accessing to the dedicated page on the forum"+Chr(13)+"http://www.freebasic.net/forum/viewtopic.php?f=8&t=13935",MB_YESNO)=IDYES Then Shell "start http://www.freebasic.net/forum/viewtopic.php?f=8""&t""=13935" EndIf Case IDCMPINF compinfo_sh Case IDINFOS If helpbx=0 Then helptyp=2:fb_Dialog(@help_box,"PROCESS LIST",windmain,2,2,400,250) Case IDLSTDLL If helpbx=0 Then helptyp=7:fb_Dialog(@help_box,"DLLS LIST",windmain,2,2,400,250) Case IDLSTSHC If helpbx=0 Then helptyp=8:fb_Dialog(@help_box,"SHORTCUT KEYS LIST",windmain,2,2,400,250) Case IDDBGHELP help_manage Case IDFILEIDE ide_launch() Case IDQCKEDT If prun AndAlso kill_process("If YES debuggee is killed then Quick edit is started")=FALSE Then 'nothing to do but better algo Else If dbgsrc="" OrElse Dir(dbgsrc)="" Then fb_message("Quick internal Editor","No file !!!") Else sendmessage(dbgrichedit,EM_SETREADONLY,FALSE,0) dsp_hide(1) fb_Dialog(@save_box,"Quick edit",windmain,283,25,150,25) setfocus(dbgrichedit) sendmessage(dbgrichedit,EM_HIDESELECTION,1,0) sendmessage(dbgrichedit,EM_SETSEL,1,1) End If EndIf Case IDCLIPBRD sendmessage(dbgedit1,EM_SETSEL,0,-1) sendmessage(dbgedit1,WM_COPY,0,0) sendmessage(dbgedit1,EM_SETSEL,-1,0) Case IDDELLOG 'delete log file if exists Dim savflog As Integer=flaglog 'save see below flaglog=flaglog And 1 'change the value but keeps screen output dbg_prt(" $$$$___CLOSE ALL___$$$$ ") 'close the file if needed Kill (ExePath+"\dbg_log_file.txt") 'delete it flaglog=savflog 'restore the value to keep the use of file log Case IDSHWLOG log_show Case IDHIDLOG log_hide Case IDSHENUM If helpbx=0 Then helptyp=6:fb_Dialog(@help_box,"LIST ENUMS",windmain,2,2,260,250) Case IDCMPNRUN 'recompil bas then run If source(dbgmain)="" Then treat_file("£$_NO$FILE_$£") Else treat_file(source(dbgmain)) EndIf Case IDWINMSG winmsg() Case IDSHWBDH dechexbin() Case IDFRTIMER fb_message("Fast run timer","Elapsed Time : "+Str(fasttimer)) Case IDJITDBG fb_MDialog(@jit_box,"Set/reset JIT debugger",windmain,283,25,325,60) Case IDTUTO 'If tutobx=0 Then fb_Dialog(@tuto_box,"Tutorial",windmain,20,280,325,60) fb_message("Tutorial","Sorry, work in progress !!!") Case IDSETBRK 'set breakpoint brk_set(1) Case IDSETBRT 'set tempo brkp brk_set(2) Case IDSETBRKC 'set brkp with counter '03/09/2015 brk_set(3) Case IDCHGBRKC 'change value brkp with counter '03/09/2015 brk_set(7) Case IDRSTBRKC 'reset brkp with counter '03/09/2015 brk_set(8) Case IDBRKENB 'enable/disable brkp brk_set(4) Case IDMNGBRK fb_MDialog(@brk_manage,"Manage breakpoints",windmain,500,8,330,170) Case IDCONTHR 'run to cursor SetFocus(windmain) brk_set(9) Case IDEXEMOD 'modify execution from cursor exe_mod() Case IDSHWVAR var_tip(PROCVAR) Case IDSETWVAR var_tip(WATCHED) Case IDFNDTXT If hfindbx=0 Then 'findtext not active ? stext=wtext() 'selected text or ascii text near cursor fb_Dialog(@find_box,"Findtext (Circular)",windmain,283,25,100,25) End If Case IDACCLINE 'dsp_access(shwtab) dsp_noaccess Case IDFCSSRC If focusbx=0 Then fb_Dialog(@focus_box,"Focus on some lines from source",windmain,2,2,400,260) EndIf Case IDTGLBMK bmk_tgl() Case IDNXTBMK bmk_goto(TRUE) 'move forward Case IDPRVBMK bmk_goto(FALSE)'move backward Case IDCURLIG 'label exrichedit(curtab) sel_line(curlig-1) Case IDBMKCMB 'click on bookmark area If HiWord(wparam)=CBN_SELCHANGE Then 'move to bmk x=sendmessage(bmkh,CB_GETCURSEL,0,0) x=sendmessage(bmkh,CB_GETITEMDATA,x,0) If bmk(x).ntab<>shwtab Then exrichedit(bmk(x).ntab) 'change tab sel_line(bmk(x).nline-1)'select line EndIf Case IDADDNOT 'add notes notes_add() Case IDGOTO 'goto line line_goto Case IDLINEADR 'line address (in memory) line_adr Case IDLINEASM 'dissassembly line in source If helpbx=0 Then helptyp=9:fb_Dialog(@help_box,"Dissassembly line",windmain,2,2,400,250) Case IDPROCASM 'dissassembly proc from line in source If helpbx=0 Then helptyp=10:fb_Dialog(@help_box,"Dissassembly proc",windmain,2,2,400,250) Case IDREGS 'show processor registers for current thread If helpbx=0 Then helptyp=12:fb_Dialog(@help_box,"Show registers",windmain,2,2,400,250) '25/08/2015 Case ENLRSRC 'enlarge source dsp_hide(1) Case ENLRVAR 'enlarge proc/var dsp_hide(2) Case IDNOTES 'open or close notes If dsptyp<>0 And dsptyp<>3 Then dsp_hide(dsptyp)'cancel full source or mem or var dsp_hide(3) Case ENLRMEM 'enlarge dump dsp_hide(4) Case IDVCLPSE 'collapse proc/var proc_expcol(TVE_COLLAPSE) Case IDLSTVARA 'list all var in log procvar_list() Case IDLSTVARS'list selected var in log procvar_list(1) Case IDCLBVARA 'clipboard all '28/11/2014 procvar_list(2) Case IDCLBVARS 'clipboard selected var procvar_list(3) Case IDPTDUMP 'dump pointed data var_dump(tviewvar,1) Case IDFNDVAR 'find text proc or var in proc/var tree If hfindbx=0 Then 'findtext not active ? also used in source fb_Dialog(@procvar_box,"Find any text (sensitive!!)",windmain,140,25,100,25) End If Case IDVEXPND 'expand proc_expcol(TVE_EXPAND) Case IDSELIDX 'select index in proc/var fb_Dialog(@index_box,"Index selection",windmain,25,25,500,250) ''2016/02/07 Case IDSTWTCH1,IDSTWTCH2,IDSTWTCH3,IDSTWTCH4 'exchange watch 0 to 3 watch_exch(LoWord(wparam)-IDSTWTCH1) Case IDWCHDEL'delete watch on cursor from watched watch_del(watch_find()) Case IDWCHDALL'delete all watches If fb_message("Delete watched vars","Delete all",MB_YESNO Or MB_ICONQUESTION)=IDYES Then watch_del() EndIf Case IDWCHVAR'show in proc:var window from watched watch_sel(watch_find()) Case IDWCHTTGL 'toggle trace watch_trace(watch_find()) Case IDWCHTTGA 'cancel all traces watch_trace() Case IDWCHDMP'dump for watched var_dump(tviewwch) Case IDWCHSTG'shw string from watched string_sh(tviewwch) Case IDWCHSHW'shw/exp from watched shwexp_new(tviewwch) Case IDWCHEDT'edit from watched If var_find2(tviewwch)<>-1 Then 'not local non-existent fb_MDialog(@edit_box,"Edit var value (Be carefull)",windmain,283,25,350,50) End If Case IDSETWTCH 'set watched first free slot If var_find2(tviewvar)<>-1 Then watch_set() Case IDTRCKIDX0 To IDTRCKRST ''2016/07/26 array_tracking(LoWord(wparam)) Case IDSETWTTR 'set watched + trace watch_addtr Case IDVARDMP 'var dump var_dump(tviewvar) Case IDSHSTRG 'show z/w/string string_sh(tviewvar) Case IDSHCHAR '03/11/2014 char_sh(tviewvar) Case IDCHGZSTR zstringbyte_exchange() Case IDVAREDT 'edit var value If var_find2(tviewvar)<>-1 Then fb_MDialog(@edit_box,"Edit var value (Be carefull)",windmain,283,25,350,50) Case IDSHWEXP 'show and expand variables shwexp_new(tviewvar) Case IDVARBRK 'break on var value brkv_set(1) Case IDRSTPRC 'reset all proc proc_flw(1) Case IDSETPRC 'set all proc proc_flw(2) Case IDSORTPRC procsort=1-procsort:proc_sh 'toggle type of sort and update display Case IDASMPRC If helpbx=0 Then helptyp=11:fb_Dialog(@help_box,"Dissassembly proc",windmain,2,2,400,250) Case IDLOCPRC 'locate proc proc_loc() Case IDCALLINE 'locate calling line proc_loccall(1) Case IDPBCKTRK'backtracking from proc/var proc_loccall(2) Case IDPCHNING'chaining from proc/var proc_loccall(3) Case IDSHWPROC 'locate proc in proc/var treeview thread_procloc(1) Case IDSHPRSRC 'locate proc in source thread_procloc(2) Case IDTBCKTRK 'backtracking (from thread) thread_procloc(3) Case IDTCHNING 'chaining (from thread) thread_procloc(4) Case IDPRCRADR 'information about running proc thread_procloc(5) Case IDTHRDCHG 'change next executed thread thread_change Case IDTHRDKLL 'kill a thread thread_kill Case IDEXCLINE 'show line thread_execline(1) Case IDCREATHR 'show line creating thread thread_execline(2) Case IDTHRDLST If helpbx=0 Then helptyp=1:fb_Dialog(@help_box,"THREADS LIST",windmain,2,2,260,250) Case IDTHRDEXP thread_expcol(TVE_EXPAND) Case IDTHRDCOL thread_expcol(TVE_COLLAPSE) Case IDFNDTXUP fb_find(0,sfind) Case IDFNDTXDW fb_find(1,sfind) Case IDWATCH1,IDWATCH2,IDWATCH3,IDWATCH4 watch_sel(LoWord(wparam)-IDWATCH1) 'check adr then select watched variable inside proc/var Case IDBRKVAR 'update break on var If brkv.adr<>0 Then brkv_set(2) End Select Case WM_HELP decode_help(Cast(HELPINFO Ptr,lparam)) Case WM_NOTIFY If LoWord(wparam)=IDDUMP Then 'Dim lvp2 As NMLISTVIEW Ptr 'lvp2=Cast(NMLISTVIEW Ptr,lparam) 'click on one column so can change the value in memory Dim lvp As NMITEMACTIVATE Ptr If dumpadr<>0 And prun Then '23/11/2014 lvp=Cast(NMITEMACTIVATE Ptr,lparam) If lvp->hdr.code = LVN_COLUMNCLICK Then dump_sel(lvp) ElseIf lvp->hdr.code=CULng(NM_CLICK) Then 'remove culng when fix done in commctrl.bi dump_update(lvp) EndIf EndIf 'If lvp->hdr.code =&hFFFFFF94 And dumpadr<>0 And prun Then dump_update(lvp2)'LVN_COLUMNCLICK ElseIf LoWord(wparam)=TAB1 Then Dim pnotify As NMHDR Ptr,wnot As Integer pnotify=Cast(NMHDR Ptr,lparam) If pnotify->code=TCN_SELCHANGE Then wnot=sendmessage(htab1,TCM_GETCURSEL,0,0) exrichedit(wnot) 'change tab and richedit End If ElseIf LoWord(wparam)=TAB2 Then Dim pnotify As NMHDR Ptr,wnot As Integer pnotify=Cast(NMHDR Ptr,lparam) If pnotify->code=TCN_SELCHANGE Then wnot=sendmessage(htab2,TCM_GETCURSEL,0,0) ShowWindow(tviewcur,SW_HIDE) Select Case wnot Case 0 'proc/var tviewcur=tviewvar SetFocus(dbgrichedit) Case 1 'procrs tviewcur=tviewprc proc_sh() SetFocus(tviewprc) Case 2 'threads tviewcur=tviewthd SetFocus(dbgrichedit) Case 3 'watched var tviewcur=tviewwch SetFocus(dbgrichedit) End Select ShowWindow(tviewcur,SW_SHOW) End If ElseIf LoWord(wparam)=TVIEW1 Then '' 2017/07/18 Dim pnotify As NMHDR Ptr =Cast(NMHDR Ptr,lparam) Dim As TVHITTESTINFO ht If pnotify->code=CULng(TVN_KEYDOWN) Then 'remove culng when fix done in commctrl.bi Dim pnotify2 As TV_KEYDOWN Ptr =Cast(TV_KEYDOWN Ptr,lparam) Dim As Integer sccheck=pnotify2->wvkey+(getkeystate(VK_CONTROL) And &h8000)/&h8000*&hF000+(getkeystate(VK_MENU) And &h8000)/&h8000*&hF0000+(getkeystate(VK_SHIFT) And &h8000)/&h8000*&hF00000 For i As Integer =0 To shcutnb-1 ''checking if shortcut If sccheck=shcut(i).sccur AndAlso shcut(i).scmenu=menuvar Then If GetMenuState(shcut(i).scmenu,shcut(i).scidnt,MF_BYCOMMAND)=0 Then ''active option ? SendMessage(windmain,WM_COMMAND,makelong(shcut(i).scidnt,BN_CLICKED),0):Return TRUE EndIf Exit For EndIf Next ElseIf pnotify->code=CULng(TVN_GETINFOTIP) And (getkeystate(VK_CONTROL) And &h8000) Then '' to show/expand var automatically when overing a variable 2017/07/27 Dim pnotify2 As NMTVGETINFOTIP Ptr=Cast(NMTVGETINFOTIP Ptr,lparam) SendMessage(tviewvar,TVM_SELECTITEM,TVGN_CARET,Cast(lparam,pnotify2->hitem))''change selection shwexp_new(tviewvar) End If ElseIf LoWord(wparam)=TVIEW4 Then '' 2017/07/18 Dim pnotify As NMHDR Ptr =Cast(NMHDR Ptr,lparam) Dim As TVHITTESTINFO ht If pnotify->code=CULng(TVN_KEYDOWN) Then 'remove culng when fix done in commctrl.bi Dim pnotify2 As TV_KEYDOWN Ptr =Cast(TV_KEYDOWN Ptr,lparam) Dim As Integer sccheck=pnotify2->wvkey+(getkeystate(VK_CONTROL) And &h8000)/&h8000*&hF000+(getkeystate(VK_MENU) And &h8000)/&h8000*&hF0000+(getkeystate(VK_SHIFT) And &h8000)/&h8000*&hF00000 For i As Integer =0 To shcutnb-1 ''checking if shortcut If sccheck=shcut(i).sccur AndAlso shcut(i).scmenu=menuwatch Then If GetMenuState(shcut(i).scmenu,shcut(i).scidnt,MF_BYCOMMAND)=0 Then ''active option ? SendMessage(windmain,WM_COMMAND,makelong(shcut(i).scidnt,BN_CLICKED),0):Return TRUE EndIf Exit For EndIf Next End If ElseIf LoWord(wparam)=TVIEW2 Then Dim pnotify As NMHDR Ptr =Cast(NMHDR Ptr,lparam) Dim As TVHITTESTINFO ht If pnotify->code=CULng(NM_CLICK) Then 'remove culng when fix done in commctrl.bi Dim As Integer dwpos = GetMessagePos() ht.pt.x = LoWord(dwpos) ht.pt.y = HiWord(dwpos) MapWindowPoints(HWND_DESKTOP, pnotify->hwndFrom, @ht.pt, 1) sendmessage(tviewprc,TVM_HITTEST,0,Cast(LPARAM,@ht)) If(TVHT_ONITEMSTATEICON And ht.flags) Then PostMessage(hWnd, UM_CHECKSTATECHANGE, 2, Cast(LPARAM,ht.hItem)) '2=tviewprc End If ElseIf pnotify->code=CULng(NM_DBLCLK) Then 'check double click then show the beginning of the selected proc in source proc_loc ElseIf pnotify->code=CULng(TVN_KEYDOWN) Then Dim pnotify2 As TV_KEYDOWN Ptr =Cast(TV_KEYDOWN Ptr,lparam)'' 2017/07/18 '' Dim As Integer sccheck=pnotify2->wvkey+(getkeystate(VK_CONTROL) And &h8000)/&h8000*&hF000+(getkeystate(VK_MENU) And &h8000)/&h8000*&hF0000+(getkeystate(VK_SHIFT) And &h8000)/&h8000*&hF00000 For i As Integer =0 To shcutnb-1 ''checking if shortcut If sccheck=shcut(i).sccur AndAlso shcut(i).scmenu=menuproc Then If GetMenuState(shcut(i).scmenu,shcut(i).scidnt,MF_BYCOMMAND)=0 Then ''active option ? SendMessage(windmain,WM_COMMAND,makelong(shcut(i).scidnt,BN_CLICKED),0):Return TRUE EndIf Exit For EndIf Next '' If pnotify2->wvkey=VK_SHIFT Then 'or shift key proc_loc EndIf End If ElseIf LoWord(wparam)=TVIEW3 Then Dim pnotify As NMHDR Ptr =Cast(NMHDR Ptr,lparam) Dim As TVHITTESTINFO ht If pnotify->code=CULng(NM_CLICK) Then 'remove culng when fix done in commctrl.bi Dim As Integer dwpos = GetMessagePos() ht.pt.x = LoWord(dwpos) ht.pt.y = HiWord(dwpos) MapWindowPoints(HWND_DESKTOP, pnotify->hwndFrom, @ht.pt, 1) sendmessage(tviewthd,TVM_HITTEST,0,Cast(LPARAM,@ht)) If(TVHT_ONITEMSTATEICON And ht.flags) Then PostMessage(hWnd, UM_CHECKSTATECHANGE, 3, Cast(LPARAM,ht.hItem))'3=tviewthd End If ElseIf pnotify->code=CULng(TVN_KEYDOWN) Then 'remove culng when fix done in commctrl.bi Dim pnotify2 As TV_KEYDOWN Ptr =Cast(TV_KEYDOWN Ptr,lparam) '' 2017/07/18 Dim As Integer sccheck=pnotify2->wvkey+(getkeystate(VK_CONTROL) And &h8000)/&h8000*&hF000+(getkeystate(VK_MENU) And &h8000)/&h8000*&hF0000+(getkeystate(VK_SHIFT) And &h8000)/&h8000*&hF00000 For i As Integer =0 To shcutnb-1 ''checking if shortcut If sccheck=shcut(i).sccur AndAlso shcut(i).scmenu=menuthread Then If GetMenuState(shcut(i).scmenu,shcut(i).scidnt,MF_BYCOMMAND)=0 Then ''active option ? SendMessage(windmain,WM_COMMAND,makelong(shcut(i).scidnt,BN_CLICKED),0):Return TRUE EndIf Exit For EndIf Next End If ElseIf LoWord(wparam)=IDRICHWIN Then Dim pmsgfilter As MSGFILTER Ptr =Cast(MSGFILTER Ptr,lparam) 'Dim idtempo As Integer If pmsgfilter->msg=WM_KEYDOWN Then 'SendMessage(windmain,WM_KEYDOWN,makelong(idtempo,pmsgfilter->wparam),null) SendMessage(windmain,WM_KEYDOWN,pmsgfilter->wparam,0) ElseIf getkeystate(VK_CONTROL) And &h8000 Then If pmsgfilter->msg=WM_LBUTTONUP Then 'display var in proc/var var_tip(PROCVAR) EndIf ElseIf getkeystate(VK_LMENU) And &h8000 Then If pmsgfilter->msg=WM_LBUTTONUP Then var_tip(WATCHED) 'select watched var EndIf End If End If Case UM_CHECKSTATECHANGE 'user message not MSWindows If wparam=2 Then SendMessage(tviewprc,TVM_SELECTITEM,TVGN_CARET,lparam) proc_activ(Cast(HTREEITEM,lparam)) 'handle tree item Else SendMessage(tviewthd,TVM_SELECTITEM,TVGN_CARET,lparam) thread_check(Cast(HTREEITEM,lparam)) 'thread tree item End If Case WM_SIZE Dim cx As Integer, cy As Integer cx = LoWord (lParam) cy = HiWord (lParam) dsp_size() dsp_sizecalc() 'Case WM_SETCURSOR 'Select Case wParam 'Case dbgrichedit 'fb_message("setcursor",str(wparam)) 'End Select Case WM_CLOSE Dim text As String Dim ztext As ZString *11 '20/05/2014 If prun Then text="CAUTION PROGRAM STILL RUNNING."+Chr(10)+Chr(10) If sendmessage(dbgedit1,WM_GETTEXT,10,Cast(LPARAM,@ztext))>4 Then text+="Don't forget to copy your notes."+Chr(10)+Chr(10) '20/05/2014 If fb_message("END OF FBDEBUGGER",text+Chr(10)+"Quit debugger ?",_ MB_YESNO Or MB_ICONWARNING ) = IDYES Then DestroyWindow (windmain) Exit Function Case WM_DESTROY 'If flaglog Then dbg_prt(" $$$$___CLOSE ALL___$$$$ ") 'test to avoid to suppress the watched If sourcenb<>-1 Then watch_sav:brk_sav 'case exiting without stopping debuggee before ini_write() ''''KillTimer (windmain,TimerID1) 'Clean Up Timers 'not used if 2 threads sendmessage(fb_hToolTip,WM_DESTROY,0,0) destroymenu(menuroot) destroymenu(menuvar) destroymenu(menuvar2) destroymenu(menuvar3) destroymenu(menuvar4) destroymenu(menuvar5) ''2016/06/15 destroymenu(menuedit) destroymenu(menuedit2) destroymenu(menutools) destroymenu(menuproc) destroymenu(menuthread) destroymenu(menuwatch) bx_closing 'to close all bx For x=0 To 23:DeleteObject(Cast(HGDIOBJ,bmb(x))):Next DeleteObject(Cast(HGDIOBJ,fonthdl)) DeleteObject(Cast(HGDIOBJ,fontbold)) DragAcceptFiles(hwnd, FALSE) help_manage(-1) 'to unload "hhctrl.ocx" PostQuitMessage 0 Exit Function Case Else WndProc = DefWindowProc( hWnd, message, wParam, lParam ) End Select End Function '======================= private sub menu_chg(hmenu As HMENU,mitem As Integer,text As String) Dim newitem As MENUITEMINFO With newitem .cbSize=SizeOf(newitem) .fMask=MIIM_STRING .fType=MFT_STRING .fState=0 .wID=0 .hSubMenu=0 .hbmpChecked=0 .hbmpUnchecked=0 .dwItemData=0 .dwTypeData=StrPtr(text) .cch=0 End With SetMenuItemInfo(hmenu,mitem,FALSE,@newitem) End Sub private function menu_gettxt(hmenu As HMENU,mitem As Integer) As String 'WARNING without the shortcut key text Dim As ZString*99 text=String(100,0) Dim newitem As MENUITEMINFO Dim As Integer p With newitem .cbSize=SizeOf(newitem) .fMask=MIIM_STRING .fType=MFT_STRING .fState=0 .wID=0 .hSubMenu=0 .hbmpChecked=0 .hbmpUnchecked=0 .dwItemData=0 .dwTypeData=@text .cch=99 End With getMenuItemInfo(hmenu,mitem,FALSE,@newitem) p=InStr(text,Chr(9)) If p Then text=Left(text,p-1) EndIf Return text End Function private sub drag_exe( hdrop As Handle) ' The following example uses the DragQueryPoint function to determine where to begin to write text. ' The first call to the DragQueryFile function determines the number of dropped files. ' The loop writes the name of each file, beginning at the point returned by DragQueryPoint. Dim As ZString *256 filename Dim As Integer filesnb = DragQueryFile(hdrop, &hFFFFFFFF,NULL, 0) 'nb files If filesnb>1 Then fb_message("Drag and drop error","Select only one file") Exit Sub EndIf DragQueryFile(hdrop, 0, filename, SizeOf(filename)) 'only one file index zero DragFinish(hdrop) If Lcase(Right(filename,4))<>".exe" And Lcase(Right(filename,4))<>".bas"Then '(BE)n fb_message("Drag and drop error","Select only a .exe or .bas file") Exit Sub EndIf treat_file(filename) End Sub '============================================== private sub exrichedit(ntab As Integer) ShowWindow(dbgrichedit,SW_HIDE) dbgrichedit=richedit(ntab) If dsptyp=0 Or dsptyp=1 Or dsptyp=3 Then ShowWindow(dbgrichedit,SW_SHOW) 'full view or source view SendMessage(htab1,TCM_SETCURSEL,ntab,0) 'item dbgsrc=source(ntab) menu_update(IDQCKEDT,"Quick edit "+dbgsrc) shwtab=ntab SetFocus(dbgrichedit) End Sub '======================================================================= 't 1=permanent breakpoint / 2=tempo breakpoint / 3=breakpoint with counter by changed in type 1 / 4=disable / 7=change value counter / 8 reset to initial value / 9=same line '======================================================================= Private sub brk_set(t As Integer) Dim l As Integer,i As Integer,range As charrange,b As Integer,ln As Integer range.cpmin=-1 :range.cpmax=0 sendmessage(dbgrichedit,EM_exsetsel,0,Cast(LPARAM,@range)) 'deselect l=sendmessage(dbgrichedit,EM_EXLINEFROMCHAR,0,-1) 'get line For i=1 To linenb If rline(i).nu=l+1 And proc(rline(i).pr).sr=shwtab Then Exit For 'check nline Next If i>linenb Then fb_message("Break point Not possible","Inaccessible line (not executable)") :Exit Sub For j As Integer =1 To procnb If rline(i).ad=proc(j).db Then fb_message("Break point Not possible","Inaccessible line (not executable)") :Exit Sub Next ln=i If t=9 Then 'run to cursor 'l N°line/by 0 If curlig=l+1 And shwtab=curtab Then If fb_message("Run to cursor","Same line, continue ?",MB_YESNO Or MB_ICONQUESTION)=IDNO Then Exit Sub End If brkol(0).ad=rline(ln).ad brkol(0).typ=2 'to clear when reached runtype=RTRUN but_enable() thread_rsm() Else For i=1 To brknb 'search if still put on this line If brkol(i).nline=l+1 And brkol(i).isrc=shwtab Then Exit For Next If i>brknb Then 'not put If brknb=BRKMAX Then fb_message("Max of brk reached ("+Str(BRKMAX)+")","Delete one and retry"):Exit Sub brknb+=1 brkol(brknb).nline=l+1 brkol(brknb).typ=t brkol(brknb).index=ln brkol(brknb).isrc=shwtab brkol(brknb).ad=rline(ln).ad brkol(brknb).cntrsav=0 brkol(brknb).counter=0 If t=3 Then 'change value counter inputval="0" inputtyp=7 'ulong fb_MDialog(@input_box,"Set value counter for a breakpoint",windmain,283,25,120,30) brkol(i).counter=ValUInt(inputval) brkol(i).cntrsav=brkol(i).counter brkol(brknb).typ=1 'forced permanent EndIf Else 'still put If t=7 Then 'change value counter inputval=Str(brkol(i).cntrsav) inputtyp=7 'ulong fb_MDialog(@input_box,"Change value counter, remaining= "+Str(brkol(i).counter)+" initial below",windmain,283,25,140,30) If inputval="" Then inputval=Str(brkol(i).cntrsav) 'cancel button selected so no value brkol(i).counter=ValUInt(inputval) brkol(i).cntrsav=brkol(i).counter ElseIf t=8 Then 'reset to initial value If brkol(i).cntrsav Then brkol(i).counter=brkol(i).cntrsav Else fb_message("Reset counter","No counter for this breakpoint") EndIf ElseIf t=4 Then 'toggle enabled/disabled 03/09/2015 If brkol(i).typ>2 Then brkol(i).typ-=2 Else brkol(i).typ+=2 EndIf ElseIf t=brkol(i).typ OrElse brkol(i).typ>2 Then 'cancel breakpoint brk_del(i) Exit Sub Else 'change type of breakpoint brkol(i).typ=t End If End If brk_color(i) If brknb=1 Then EnableMenuItem(menuedit,IDMNGBRK,MF_ENABLED) End If End Sub '============================================= private sub brk_del(n As Integer) 'delete one breakpoint brkol(n).typ=0 brk_color(n) brknb-=1 For i As Integer =n To brknb brkol(i)=brkol(i+1) Next If brknb=0 Then EnableMenuItem(menuedit,IDMNGBRK,MF_GRAYED) End Sub '================== Private function brk_test(ad As UInteger) As Byte 'check on breakpoint ? For i As Integer=0 To brknb If brkol(i).typ>2 Then Continue For 'disabled If ad=brkol(i).ad Then 'reached line = breakpoint If brkol(i).counter>0 Then brkol(i).counter-=1:Return FALSE 'decrement counter 02/09/2015 stopcode=CSBRK If i=0 Then brkol(0).ad=0 'delete continue to cursor stopcode=CSCURSOR Else If brkol(i).typ=2 Then brk_del(i):stopcode=CSBRKTEMPO 'tempo breakpoint End If Return TRUE End If Next Return FALSE End Function private sub brk_color(brk As Integer) Dim h As hwnd=richedit(brkol(brk).isrc),l As Integer=brkol(brk).nline-1,t As Integer=brkol(brk).typ Dim colr As Integer,range As charrange,b As Integer If t Then 'set If t=1 Then colr=clrperbrk'permanent breakpoint ElseIf t=2 Then colr=clrtmpbrk'tempo breakpoint Else colr=&hB0B0B0 'disabled EndIf If l+1=curlig And brkol(brk).isrc=curtab Then colr=colr Xor clrcurline sel_line(l,colr,2,h,FALSE) 'purple brk+current Else 'reset If l+1=curlig And brkol(brk).isrc=curtab Then sel_line(l,clrcurline,2,h,FALSE) 'blue Else b=rlineold:rlineold=brkol(brk).index 'hack to correctly color line sel_line(l,0,1,h,FALSE) 'grey rlineold=b End If End If b=sendmessage(h,EM_LINEINDEX,-1,0)'char index for line with caret range.cpmin=b :range.cpmax=b 'caret at begining of line sendmessage(h,EM_exsetsel,0,Cast(LPARAM,@range)) End Sub '================================ Private sub brk_apply() '03/09/2015 'brkexe = ,<#line>, Dim f As Integer =FALSE For i As Integer =1 To BRKMAX Dim As String brks,fn Dim As Integer p,p2,ln,ty Dim As UInteger cntr If brknb=BRKMAX Then Exit For 'no more breakpoint possible If brkexe(0,i)<>"" Then 'not empty brks=brkexe(0,i) p=InStr(brks,",")'parsing fn=Left(brks,p-1) 'file name p2=p+1 p=InStr(p2,brks,",") ln=ValInt(Mid(brks,p2,p-p2)) 'number line p2=p+1 p=InStr(p2,brks,",") cntr=ValUInt(Mid(brks,p2,p-p2)) 'counter ty=ValInt(Right(brks,1)) 'type For j As Integer =0 To sourcenb If name_extract(source(j))=fn Then 'name matching For k As Integer= 1 To linenb If rline(k).nu=ln AndAlso proc(rline(k).pr).sr=j Then 'searching index in rline brknb+=1 brkol(brknb).isrc =j brkol(brknb).nline=ln brkol(brknb).index=k brkol(brknb).ad =rline(k).ad brkol(brknb).typ =ty brkol(brknb).cntrsav=cntr brkol(brknb).counter=cntr brk_color(brknb) f=TRUE 'flag for managing breakpoint Exit For EndIf Next brkexe(0,i)="" 'used one time Exit For EndIf Next EndIf Next If f Then fb_MDialog(@brk_manage,"Restart debuggee, managing breakpoints",windmain,500,8,330,170) EnableMenuItem(menuedit,IDMNGBRK,MF_ENABLED) EndIf End Sub '=========================== Private sub brk_sav For i As Integer =1 To BRKMAX If i<=brknb Then brkexe(0,i)=name_extract(source(brkol(i).isrc))+","+Str(brkol(i).nline)+","+Str(brkol(i).cntrsav)+","+Str(brkol(i).typ) '03/09/2015 'Else ' brkexe(0,i)="" 'last ones empty EndIf Next End Sub '================================ private function brk_manage(ByVal hwnd As HWND,ByVal Msg As UInteger,ByVal wparam As Integer,ByVal lParam As Integer) As Integer Dim rc As RECT => (0, 0, 4, 8) Dim As Single scalex,scaley Dim lw As Integer Dim text As String *500 Static As HWND xbut(BRKMAX+1),xbut2(BRKMAX+1),label(BRKMAX+1) Select Case Msg Case WM_INITDIALOG ' to test 'SendMessage(hWnd, WM_SETICON, TRUE, _ 'Set Application Icon '(HICON)LoadImage(0,"i.ico",IMAGE_ICON,0,0,LR_LOADFROMFILE)) MapDialogRect (hwnd,@rc) ScaleX = rc.right/4 ScaleY = rc.bottom/8 For i As Byte =1 To brknb text=Chr(150)+Chr(0) sendmessage(richedit(brkol(i).isrc),EM_GETLINE,brkol(i).nline-1,Cast(LPARAM,StrPtr(text))) label(i)=fb_Label(" "+name_extract(source(brkol(i).isrc))+" ["+Str(brkol(i).nline)+"] cntr="+Str(brkol(i).counter)+" >> "+Left(Trim(text,Any Chr(9)+" "),50),hWnd,910+i,34*scalex, 3*scaley+i*20, 290*scalex, 9*scaley) xbut(i) =fb_button("X",hWnd,900+i, 4*scalex, 3*scaley+i*20, 10*scalex, 9*scaley) If brkol(i).typ>2 Then text="ENB" Else text="DSB" xbut2(i)=fb_button(text,hWnd,920+i,14*scalex, 3*scaley+i*20, 20*scalex, 9*scaley) Next fb_button("Close" ,hWnd,940, 10*scalex, 120*scaley, 40*scalex, 12*scaley) fb_button("Delete all" ,hWnd,941, 70*scalex, 120*scaley, 40*scalex, 12*scaley) fb_button("Disable all",hWnd,942,120*scalex, 120*scaley, 40*scalex, 12*scaley) fb_button("Enable all" ,hWnd,943,160*scalex, 120*scaley, 40*scalex, 12*scaley) Case WM_COMMAND lw=LoWord(wparam) Select Case lw Case Is <901 EndDialog(hWnd,0) Case Is <911 'delete one breakpoint lw=lw-900 brk_del(lw) showwindow(xbut(lw),SW_HIDE) showwindow(xbut2(lw),SW_HIDE) showwindow(label(lw),SW_HIDE) If brknb=0 Then EndDialog(hWnd,0) 'no more breakpoint so close the window EndIf Case Is <921 'selectline lw=lw-910 exrichedit(brkol(lw).isrc) sel_line(brkol(lw).nline-1) Case Is <931 'enable/disable lw=lw-920 If brkol(lw).typ>2 Then brkol(lw).typ-=2 setWindowText(xbut2(lw),@"DSB") Else brkol(lw).typ+=2 setWindowText(xbut2(lw),@"ENB") EndIf brk_color(lw) Case 940 'close EndDialog(hWnd,0) Case 941 '"Delete all" button For i As Byte=1 To brknb brk_del(i) Next EndDialog(hWnd,0) Case 942 'disable all For i As Byte =1 To brknb If brkol(i).typ<3 Then brkol(i).typ+=2 brk_color(i) setWindowText(xbut2(i),@"ENB") EndIf Next Case 943 'enable all For i As Byte =1 To brknb If brkol(i).typ>2 Then brkol(i).typ-=2 brk_color(i) setWindowText(xbut2(i),@"DSB") EndIf Next End Select Case WM_CLOSE EndDialog(hWnd,0) Return 0 'not really used End Select End Function private sub bmk_tgl() Dim l As Integer,s As ZString * 259,range As charrange,itempo As Integer,idx As Integer Clear s,0,101 l=sendmessage(dbgrichedit,EM_EXLINEFROMCHAR,0,-1)+1 'get line For i As Integer =1 To BMKMAX If bmk(i).ntab=shwtab AndAlso bmk(i).nline=l Then 'previously set, reset For j As Integer =0 To bmkcpt-1 'zero based If SendMessage(bmkh,CB_GETITEMDATA,j,0)=i Then 'is this index ? sendmessage(bmkh,CB_DELETESTRING,j,0) SendMessage(bmkh,CB_SETCURSEL,0,0) 'show first string Exit For EndIf Next bmkcpt-=1 bmk(i).ntab=-1 If bmkcpt=0 Then EnableMenuItem(menuedit,IDNXTBMK,MF_GRAYED) EnableMenuItem(menuedit,IDPRVBMK,MF_GRAYED) EndIf Exit Sub Else If bmk(i).ntab=-1 Then itempo=i 'free slot EndIf Next If itempo=0 Then fb_message("Set bookmark","No free slot, delete one existing") Exit Sub EndIf bmk(itempo).ntab=shwtab bmk(itempo).nline=l s=Chr(100) sendmessage(dbgrichedit,EM_getline,l-1,Cast(LPARAM,@s))'copy max 100 bytes s="BMK --> "+name_extract(source(shwtab))+"["+Str(l)+"] "+Trim(s) idx=SendMessage(bmkh,CB_ADDSTRING,0,Cast(LPARAM,@s)) 'add name/nline SendMessage(bmkh,CB_SETITEMDATA,idx,Cast(LPARAM,itempo)) 'store index inside combo data bmkcpt+=1 If bmkcpt=1 Then SendMessage(bmkh,CB_SETCURSEL,0,0) 'show first string EnableMenuItem(menuedit,IDNXTBMK,MF_ENABLED) EnableMenuItem(menuedit,IDPRVBMK,MF_ENABLED) EndIf End Sub '============================================ private sub bmk_goto(direct As Integer) Dim As Integer idx,nline,nltemp,b,l,f Dim range As charrange Dim As Integer bmkidx=sendmessage(dbgrichedit,EM_EXLINEFROMCHAR,0,-1)+1 'get line If direct Then nline=999999999 Else nline=0 End If For i As Integer = 1 To BMKMAX If bmk(i).ntab=shwtab Then 'same file nltemp=bmk(i).nline If direct Then If nltemp>bmkidx Then 'must go forward If nltempnline Then nline=nltemp EndIf EndIf EndIf EndIf Next If nline<>999999999 AndAlso nline<>0 Then sel_line(nline-1) Else If fb_message("Goto next/prev bookmark","End/beginning of file reached"+Chr(13)+"Do you want to move at beginning/end ?",MB_YESNO)=IDYES Then If direct Then SendMessage ( dbgrichedit , EM_LINESCROLL,-500,-99999999) 'beginning b=sendmessage(dbgrichedit,EM_LINEINDEX,0,0)'char index for line 0 Else 'number of lines zero based b=sendmessage(dbgrichedit,EM_GETLINECOUNT,0,0)-1 'next first visible line with filled window l=b-dspsize+1 'offset with current first visible line f=l-SendMessage (dbgrichedit,EM_GETFIRSTVISIBLELINE,0,0) 'scroll offset SendMessage ( dbgrichedit , EM_LINESCROLL,-500,f) 'number of lines b=sendmessage(dbgrichedit,EM_LINEINDEX,b,0) 'char index for last line EndIf range.cpmin=b :range.cpmax=b 'caret at beginning of line sendmessage(dbgrichedit,EM_exsetsel,0,Cast(LPARAM,@range)) setfocus(dbgrichedit) EndIf End If End Sub private sub notes_add() Dim text As String *1000,l As Integer,range As charrange l=sendmessage(dbgrichedit,EM_GETSELTEXT,0,Cast(LPARAM,StrPtr(text))) 'Returns the number of characters copied, not including the terminating null character If l=0 Then l=sendmessage(dbgrichedit,EM_EXLINEFROMCHAR,0,-1) 'get line text=Chr(1)+Chr(3) sendmessage(dbgrichedit,EM_getline,l,Cast(LPARAM,StrPtr(text))) End If text=Chr(13)+Chr(10)+"["+Date+" "+Time+"] "+text sendmessage(dbgedit1,EM_SETSEL,0,-1) 'no return value 'nstart=0 and nend=-1 --> all the text / nstart=-1 --> remove selection sendmessage(dbgedit1,EM_SETSEL,-1,0) sendmessage(dbgedit1,EM_REPLACESEL,TRUE,Cast(LPARAM,@text)) 'no return value 'flag : true-->can be undone / false -->can't be undone End Sub '======================================== private sub dsp_color 'change to the right color Dim As Integer colr sel_line(curlig-1,clrcurline,2,richedit(curtab),FALSE) 'current line in blue For i As Integer =1 To brknb If brkol(i).typ=1 Then colr=clrperbrk' red breakpoint ElseIf brkol(i).typ=2 Then colr=clrtmpbrk ' orange tempo breakpoint Else colr=&hB0B0B0 'disabled EndIf If brkol(i).nline=curlig And brkol(i).isrc=curtab Then If brkol(i).typ=1 Then colr=clrcurline Xor colr ' blue and red current and breakpoint ElseIf brkol(i).typ=2 Then colr=clrcurline Xor colr ' blue and orange current and tempo breakpoint Else colr=&hB0B0B0 'disabled EndIf EndIf sel_line(brkol(i).nline-1,colr,2,richedit(brkol(i).isrc),FALSE) Next End Sub '============================================= private sub dsp_change(index As Integer) Dim As Integer icurold,icurlig,curold,decal,clrold,clrcur Dim ntab As Integer=proc(rline(index).pr).sr ''unicode 10/05/2015 Dim As GETTEXTEX gtx Dim As WString *104 wstrg Clear *@wstrg,0,200+2 gtx.cb=200 gtx.flags=GT_SELECTION gtx.codepage=1200 gtx.lpDefaultChar=0 gtx.lpUsedDefChar=0 '' curold=curlig curlig=rline(index).nu icurold=FALSE :icurlig=FALSE For i As Integer =1 To brknb If brkol(i).nline=curold And brkol(i).isrc=shwtab Then icurold=TRUE If brkol(i).typ=1 Then clrold=clrperbrk ElseIf brkol(i).typ=2 Then clrold=clrtmpbrk Else clrold=&hB0B0B0 End If EndIf If brkol(i).nline=curlig And brkol(i).isrc=ntab Then icurlig=TRUE If brkol(i).typ=1 Then clrcur=clrperbrk Xor clrcurline ElseIf brkol(i).typ=2 Then clrcur=clrtmpbrk Xor clrcurline Else clrcur=&hB0B0B0 Xor clrcurline End If EndIf Next If icurold Then sel_line(curold-1,clrold,2,richedit(curtab),FALSE) 'restore breakpoint red Else sel_line(curold-1,0,1,richedit(curtab),FALSE) 'default color End If If ntab<>shwtab Then exrichedit(ntab) curtab=shwtab If icurlig Then sel_line(curlig-1,clrcur,2) 'current line + brk purple Else sel_line(curlig-1,clrcurline,2) 'current line in blue End If '??? sendmessage(dbgrichedit ,WM_HSCROLL,SB_PAGELEFT,0) rlineold=index ''10/05/2015 'sendmessage(dbgrichedit,EM_GETSELTEXT,0,Cast(LPARAM,@l)) ''SetWindowTextW(hcurline,"Current line ["+Str(curlig)+"]:"+LTrim(l,Any " "+Chr(9))) '' '' use of gettextex to unicode SendMessage(dbgrichedit,EM_GETTEXTEX,Cast(WPARAM,@gtx),Cast(LPARAM,@wstrg)) SetWindowTextW(hcurline,WStr("Current line ["+Str(curlig)+"]:")+LTrim(wstrg,Any WStr(" "+Chr(9)))) '' If flagtrace And 2 Then dbg_prt(LTrim(wstrg,Any WStr(" "+Chr(9)))) If runtype=RTAUTO Then watch_array 'update adr watched dyn array watch_sh 'update watched but not all the variables 'If tviewcur = tviewthd Then thread_text 'update ElseIf runtype=RTSTEP Then var_sh() dump_sh() but_enable() If tviewcur = tviewprc Then proc_sh elseIf tviewcur = tviewthd Then '25/01/2015 thread_text EndIf If flagfollow=TRUE AndAlso focusbx<>0 Then sendmessage(focusbx,UM_FOCUSSRC,0,0) EndIf ''=== Update select index windows ================== 2016/02/09 For i As Long =0 To INDEXBOXMAX If hindexbx(i)<>0 Then If autoupd(i)=TRUE Then SendMessage(hindexbx(i),WM_COMMAND,333,0) ''simulate click on button update 2016/03/16 EndIf Next ''================================================== End If End Sub '================================================================ private sub show_context() 'show all the registers Dim vcontext As CONTEXT Dim As String strg(15) vcontext.contextflags=CONTEXT_CONTROL or CONTEXT_INTEGER '07/08/2015 64 bit rbp is gotten with CONTEXT_INTEGER , instead in x86 CONTEXT_CONTROL For i As Integer=0 To threadnb GetThreadContext(thread(i).hd,@vcontext) dbg_prt("") If thread(i).hd=threadcontext Then dbg_prt("Current Thread="+Str(thread(i).hd)+" / "+Hex(thread(i).hd)) Else dbg_prt("Other Thread="+Str(thread(i).hd)+" / "+Hex(thread(i).hd)) EndIf '25/08/2015 regs_data(thread(i).hd,strg()) #Ifdef __FB_64BIT__ For i As Long =0 To 15 #Else For i As Long =0 To 8 #EndIf dbg_prt(strg(i)) Next Next End Sub ' Added 24/08/2015 Sub regs_data(thd As handle,reg_values() As String) Dim vcontext As CONTEXT vcontext.contextflags=CONTEXT_CONTROL or CONTEXT_INTEGER GetThreadContext(thd,@vcontext) #Ifdef __FB_64BIT__ If UBound(reg_values)<15 Then Exit sub reg_values(0)="Rax="+fmt(Str(vcontext.rax),20)+"/ "+Hex(vcontext.rax) reg_values(1)="Rcx="+fmt(Str(vcontext.rcx),20)+"/ "+Hex(vcontext.rcx) reg_values(2)="Rdx="+fmt(Str(vcontext.rdx),20)+"/ "+Hex(vcontext.rdx) reg_values(3)="Rbx="+fmt(Str(vcontext.rbx),20)+"/ "+Hex(vcontext.rbx) reg_values(4)="Rsp="+fmt(Str(vcontext.rsp),20)+"/ "+Hex(vcontext.rsp) reg_values(5)="Rbp="+fmt(Str(vcontext.rbp),20)+"/ "+Hex(vcontext.rbp) reg_values(6)="Rsi="+fmt(Str(vcontext.rsi),20)+"/ "+Hex(vcontext.rsi) reg_values(7)="R8 ="+fmt(Str(vcontext.r8),20) +"/ "+Hex(vcontext.r8) reg_values(8)="R9 ="+fmt(Str(vcontext.r9),20) +"/ "+Hex(vcontext.r9) reg_values(9)="R10="+fmt(Str(vcontext.r10),20)+"/ "+Hex(vcontext.r10) reg_values(10)="R11="+fmt(Str(vcontext.r11),20)+"/ "+Hex(vcontext.r11) reg_values(11)="R12="+fmt(Str(vcontext.r12),20)+"/ "+Hex(vcontext.r12) reg_values(12)="R13="+fmt(Str(vcontext.r13),20)+"/ "+Hex(vcontext.r13) reg_values(13)="R14="+fmt(Str(vcontext.r14),20)+"/ "+Hex(vcontext.r14) reg_values(14)="R15="+fmt(Str(vcontext.r15),20)+"/ "+Hex(vcontext.r15) reg_values(15)="Rip="+fmt(Str(vcontext.rip),20)+"/ "+Hex(vcontext.rip) #Else If UBound(reg_values)<8 Then Exit sub reg_values(0)="Edi="+fmt(Str(vcontext.edi),11)+"/ "+Hex(vcontext.edi) reg_values(1)="Esi="+fmt(Str(vcontext.esi),11)+"/ "+Hex(vcontext.esi) reg_values(2)="Ebx="+fmt(Str(vcontext.ebx),11)+"/ "+Hex(vcontext.ebx) reg_values(3)="Edx="+fmt(Str(vcontext.edx),11)+"/ "+Hex(vcontext.edx) reg_values(4)="Ecx="+fmt(Str(vcontext.ecx),11)+"/ "+Hex(vcontext.ecx) reg_values(5)="Eax="+fmt(Str(vcontext.eax),11)+"/ "+Hex(vcontext.eax) reg_values(6)="Ebp="+fmt(Str(vcontext.ebp),11)+"/ "+Hex(vcontext.ebp) reg_values(7)="Eip="+fmt(Str(vcontext.eip),11)+"/ "+Hex(vcontext.eip) reg_values(8)="Esp="+fmt(Str(vcontext.esp),11)+"/ "+Hex(vcontext.esp) #EndIf End Sub '================================================================ private sub sel_line(l As Integer,c As Integer=0,s As Integer=0,h As HWND=dbgrichedit,dsp As Integer=TRUE) Dim d As Integer,f As Integer,range As charrange Dim As Integer fl,ofs,tl,nl=l+1 Static flag As Integer=0 If l=-1 Then Exit sub 'first line no need to execute as no oldline d=SendMessage ( h , EM_LINEINDEX,l, 0) f=SendMessage ( h , EM_LINEINDEX,l+1, 0) If f-d > dspwidth Then f=d+dspwidth 'select no more than the width range.cpmin=d :range.cpmax=f-1 SendMessage ( h , EM_exSETSEL,0,Cast(LPARAM,@range)) If dsp Then 'if the whole file is displayed no need to decal tl=sendmessage(h,EM_GETLINECOUNT,0,0) If tl>dspsize Then 'current first line, return zero based so +1 fl=SendMessage (h,EM_GETFIRSTVISIBLELINE,0,0)+1 'current line outside limits ? If nl=fl+dspsize-dspofs Then ofs=nl-dspofs-fl 'ofs too big so loss of visible lines, reduce it If fl+ofs>tl+1-dspsize Then ofs=tl+1-dspsize-fl 'apply offset SendMessage ( h , EM_LINESCROLL,0,ofs) End If EndIf setfocus(h) EndIf If s Then fb_setcolor(h,2,c,s) If s=1 AndAlso hgltflag=TRUE Then SendMessage(h,EM_HIDESELECTION,1,0) 'no move For i As Integer = 0 To rline(rlineold).hn-1 'number of keywords in the line d=SendMessage ( h , EM_LINEINDEX,l, 0) 'begin of line range.cpmin=d+hgltdata(rline(rlineold).hp+i).ps-1 range.cpmax=range.cpmin+hgltdata(rline(rlineold).hp+i).lg SendMessage ( h , EM_exSETSEL,0,Cast(LPARAM,@range)) fb_setcolor(h,2,clrkeyword,3) Next range.cpmin=-1:range.cpmax=0 sendmessage(dbgrichedit,EM_exsetsel,0,Cast(LPARAM,@range)) 'deselect SendMessage(h,EM_HIDESELECTION,0,0) EndIf End Sub '================= NEW VERSION ============= ' Dim As String keyw(1 To 27)={_ ' " abs access acos alias allocate append as asc asin asm atan2 atn assertwarn any abstract add alpha and andalso assert ",_ ' " base beep bin binary bload bsave byval byref boolean bit bitreset bitset byte ",_ ' " call callocate case cdecl chain chdir chr circle class clear close cls color com command common cast cbyte cdbl cint clng clngint const cptr cshort csign csng cubyte cuint culng culngint cunsg cushort"+_ ' " custom condbroadcast condcreate conddestroy condsignal condwait cons constructor continue cos csrlin curdir cvd cvi cvl cvlongint cvs cvshort ",_ ' " double defined delete data date dateadd datediff datepart dateserial datevalue day deallocate declare destructor dim dir do draw dylibfree dylibload dylibsymbol dynamic defbyte defdbl defint deflng deflongint defshort defsng defstr defubyte defuint defulongint defushort ",_ ' " eqv else elseif encoding end endif enum environ eof erase erfn erl ermn err error escape exec exepath exit exp explicit export extends extern ",_ ' " field fileattr filecopy filedatetime fileexists filelen fix flip for format frac fre freefile function false ",_ ' " get getjoystick getkey getmouse gosub goto ",_ ' " hex hour hibyte hiword ",_ ' " integer if iif imageconvertrow imagecreate imagedestroy imageinfo implements import inkey inp input instr instrrev int is isdate imp "_, ' "",_ ' " kill ",_ ' " long longint lpos lbound lcase left len lib line loc local locate lock lof log loop lpos lobyte loword lprint lpt lset ltrim let ",_ ' " mid minute mkd mkdir mki mkl mklongint mks mkshort month monthname multikey mutexcreate mutexdestroy mutexlock mutexunlock mod ",_ ' " naked name namespace next nogosub nokeyword now not ",_ ' " oct on open operator option out output overload offsetof once object or orelse ",_ ' " paint palette pascal pcopy peek pipe pmap point poke pos preserve preset print private property protected pset public put pos pointer procptr ptr ",_ ' "",_ ' " rem random randomize read reallocate redim reset restore resume return right rmdir rnd rset rtrim run rgb rgba ",_ ' " shl shr sadd shared short single static string strptr scope screen screencontrol screencopy screenevent screenglproc screeninfo screenlist screenlock screenptr screenres screenset screensync screenunlock scrn second seek select setdate setenviron setmouse settime sgn shell sin sizeof sleep space spc sqr stdcall step stick str strig sub swap system stop ",_ ' " tab tan then this threadcall threadcreate threadwait time timer timeserial timevalue to trim type typeof trans true ",_ ' " unsigned ushort ubyte uinteger ulong ulongInt ubound ucase union unlock until using ",_ ' " val valint vallng valuint valulng var view va_arg va_first va_next virtual varptr ",_ ' " wstring zstring wait wbin wchr weekday weekdayname wend whex while widthwbin wchr weekday weekdayname wend whex while width window windowtitle winput with woct write wspace wstr ",_ ' " xor ",_ ' " year ",_ ' " __date__ __fb_argc__ __fb_argv__ __fb_backend__ __fb_bigendian__ __fb_build_date__"+_ ' " __fb_cygwin__ __fb_darwin__ __fb_debug__ __fb_dos__ __fb_err__ __fb_fpmode__ __fb_fpu__"+_ ' " __fb_freebsd__ __fb_lang__ __fb_linux__ __fb_main__ __fb_min_version__ __fb_mt__ __fb_netbsd__"+_ ' " __fb_openbsd__ __fb_option_byval__ __fb_option_dynamic__ __fb_option_escape__"+_ ' " __fb_option_explicit__ __fb_option_gosub__ __fb_option_private__ __fb_out_dll__ __fb_out_exe__"+_ ' " __fb_out_lib__ __fb_out_obj__ __fb_pcos__ __fb_signature__ __fb_sse__ __fb_unix__ "+_ ' " __fb_vectorize__ __fb_ver_major__ __fb_ver_minor__ __fb_ver_patch__ __fb_version__ __fb_win32__"+_ ' " __fb_xbox__ __file__ __file_nq__ __function__ __function_nq__ __line__ __path__ __time__ ",_ ' " #define #else #elseif #endif #endmacro #error #if #ifdef #ifndef #inclib #include #libpath #line #macro #pragma #print #undef ",_ ' " $dynamic $include "_ '} '=========================================== private sub hglt_lines(vbeg As Integer,vend As Integer) Dim As Integer l,d,f,procbegin Dim As charrange range Dim As HWND h=dbgrichedit Dim As ZString * 10000 text Dim As String keyw=" abs access acos alias allocate append as asc asin asm atan2 atn base beep bin binary bload bsave"+_ " byval byref call callocate case cdecl chain chdir chr circle class clear close cls color com command common"+_ " condbroadcast condcreate conddestroy condsignal condwait cons constructor continue cos csrlin curdir cvd"+_ " cvi cvl cvlongint cvs cvshort data date dateadd datediff datepart dateserial datevalue day deallocate"+_ " declare destructor dim dir do draw dylibfree dylibload dylibsymbol dynamic else elseif encoding end endif"+_ " enum environ eof erase erfn erl ermn err error escape exec exepath exit exp explicit export extends"+_ " extern field fileattr filecopy filedatetime fileexists filelen fix flip for format frac fre freefile"+_ " function get getjoystick getkey getmouse gosub goto hex hour if iif imageconvertrow imagecreate $dynamic"+_ " imagedestroy imageinfo implements import inkey inp input va_arg va_first va_next delete rem lpos pos"+_ " instr instrrev int is isdate kill lbound lcase left len lib line loc local locate lock lof log loop lpos"+_ " lprint lpt lset ltrim mid minute mkd mkdir mki mkl mklongint mks mkshort month monthname multikey"+_ " mutexcreate mutexdestroy mutexlock mutexunlock naked name namespace next nogosub nokeyword now oct"+_ " on open operator option out output overload paint palette pascal pcopy peek pipe pmap point poke pos"+_ " preserve preset print private property protected pset public put random randomize read reallocate redim"+_ " reset restore resume return right rmdir rnd rset rtrim run scope screen screencontrol screencopy"+_ " screenevent screenglproc screeninfo screenlist screenlock screenptr screenres screenset screensync"+_ " screenunlock scrn second seek select setdate setenviron setmouse settime sgn shell sin sizeof sleep"+_ " space spc sqr stdcall step stick str strig sub swap system tab tan then this threadcall threadcreate"+_ " threadwait time timer timeserial timevalue to trim type typeof ubound ucase union unlock until using"+_ " val valint vallng valuint valulng var view wait wbin wchr weekday weekdayname wend whex while width"+_ " window windowtitle winput with woct write wspace wstr year any byte cast cbyte cdbl cint clng clngint"+_ " const cptr cshort csign csng cubyte cuint culng culngint cunsg cushort defbyte defdbl defint deflng"+_ " deflongint defshort defsng defstr defubyte defuint defulongint defushort double integer long longint"+_ " object pointer procptr ptr sadd shared short single static string strptr ubyte uinteger ulong ulongInt"+_ " unsigned ushort varptr wstring zstring add alpha and andalso custom eqv imp let mod not or orelse shl"+_ " shr trans xor __date__ __fb_argc__ __fb_argv__ __fb_backend__ __fb_bigendian__ __fb_build_date__"+_ " __fb_cygwin__ __fb_darwin__ __fb_debug__ __fb_dos__ __fb_err__ __fb_fpmode__ __fb_fpu__"+_ " __fb_freebsd__ __fb_lang__ __fb_linux__ __fb_main__ __fb_min_version__ __fb_mt__ __fb_netbsd__"+_ " __fb_openbsd__ __fb_option_byval__ __fb_option_dynamic__ __fb_option_escape__"+_ " __fb_option_explicit__ __fb_option_gosub__ __fb_option_private__ __fb_out_dll__ __fb_out_exe__"+_ " __fb_out_lib__ __fb_out_obj__ __fb_pcos__ __fb_signature__ __fb_sse__ __fb_unix__ $include"+_ " __fb_vectorize__ __fb_ver_major__ __fb_ver_minor__ __fb_ver_patch__ __fb_version__ __fb_win32__"+_ " __fb_xbox__ __file__ __file_nq__ __function__ __function_nq__ __line__ __path__ __time__ assert"+_ " assertwarn bit bitreset bitset defined hibyte hiword lobyte loword offsetof once rgb rgba stop" _ " #define #else #elseif #endif #endmacro #error #if #ifdef #ifndef #inclib #include #libpath #line" _ " #macro #pragma #print #undef virtual abstract" Dim ln As String Dim As Integer i,p,b,lgt,cptk,flagquote,cptm,cptq Dim As String part Dim As tmodif modif(100) Dim As tmodif commt(100) Dim As tmodif quote(100) Static As Integer flagcomment For j As Integer=vbeg To vend h=richedit(j) SendMessage(h,EM_HIDESELECTION,1,0) 'no move For k As Integer =0 To sendmessage(h,EM_GETLINECOUNT,0,0)-1 procbegin=0 'get line text text=Chr(1)+Chr(3) sendmessage(h,EM_GETLINE,k,Cast(LPARAM,@text)) 'get line text 'analyze text ln=LCase(RTrim(text, Any Chr(13)+" "))+" " 'adding a space to simplify the algorithm i=-1:p=1:b=0:lgt=Len(ln)-1:cptk=0:flagquote=0:cptm=0:cptq=0 If flagcomment=1 Then cptm=1:commt(cptm).ps=1:commt(cptm).lg=0:i=-2 While i")) i+=1:b=ln[i]:p+=1 If i>=lgt Then Exit While,While Wend If flagquote=0 Then If b=Asc("/") AndAlso ln[i+1]=Asc("'") Then flagcomment=1:i+=1:b=ln[i]:p+=1:cptm+=1:commt(cptm).ps=i:commt(cptm).lg=1 EndIf While flagcomment i+=1:b=ln[i]:p+=1:commt(cptm).lg+=1 If ln[i]=Asc("'") AndAlso ln[i+1]=Asc("/") Then i+=2:b=ln[i]:p+=2:flagcomment=0:commt(cptm).lg+=2 If i>=lgt Then commt(cptm).lg=9999999:Exit While, While Wend End If If b=Asc("""") Then flagquote=1:cptq+=1:quote(cptq).ps=i:quote(cptq).lg=1 While flagquote i+=1:b=ln[i]:p+=1:quote(cptq).lg+=1 If ln[i]=Asc("""") Then If ln[i+1]<>Asc("""") Then flagquote=0:i+=1:p+=1:b=ln[i]:quote(cptq).lg+=1 Else i+=2:p+=2:b=ln[i]:quote(cptq).lg+=2 EndIf If i>=lgt Then quote(cptq).lg=9999999:Exit While, While Wend If b=Asc("'") Then cptm+=1:commt(cptm).ps=p:commt(cptm).lg=9999999:Exit While EndIf While b<>Asc("(") AndAlso b<>Asc(")") AndAlso b<>Asc("=") AndAlso b<>Asc(" ") AndAlso b<>9 AndAlso b<>Asc(":") AndAlso b<>Asc("""") AndAlso b<>Asc(",") AndAlso b<>Asc("[") AndAlso b<>Asc("]") AndAlso b<>Asc("<") AndAlso b<>Asc(">") i+=1:b=ln[i] Wend part=Mid(ln,p,i-p+1) If InStr(keyw," "+part+" ")<>0 Then cptk+=1:modif(cptk).ps=p:modif(cptk).lg=i-p+1 If (part="sub" OrElse part="function" OrElse part="operator" OrElse part="property" OrElse part="destructor" _ OrElse part="constructor" OrElse part="public" OrElse part="private") AndAlso cptk=1 Then procbegin=1 If part="rem" Then cptm+=1:commt(cptm).ps=p:commt(cptm).lg=9999999:Exit While End If p=i+2 Wend 'make changes For i As Integer = 1 To cptk d=SendMessage ( h , EM_LINEINDEX,k, 0) 'begin of line range.cpmin=d+modif(i).ps-1 :range.cpmax=range.cpmin+modif(i).lg SendMessage ( h , EM_exSETSEL,0,Cast(LPARAM,@range)) If i=1 AndAlso procbegin Then fb_setcolor(h,2,&h0000FF,3) 'sub and function in red Else fb_setcolor(h,2,clrkeyword,3) EndIf Next If cptk Then hglt_data(k+1 ,j, modif(),cptk) Next SendMessage(h,EM_HIDESELECTION,0,0) SendMessage(h,EM_SETSEL,-1,0)'to remove select hidecaret(h) Next End Sub private sub hglt_data(nline As Integer,src As Integer, datas() As tmodif, cptk As Integer) For i As Integer= 1 To linenb If rline(i).nu=nline AndAlso proc(rline(i).pr).sr=src Then rline(i).hn=cptk rline(i).hp=hgltpt+1 For j As Integer=1 To cptk hgltpt+=1 hgltdata(hgltpt)=datas(j) Next If hgltmax-500nline Then Exit Sub 'test because same nu line for begin of proc and real executable line End If Next 'if arrived here not an executable line so no need to keep data End Sub private sub hglt_all() Dim As hwnd h If hgltflag=TRUE Then hgltpt=0 hglt_lines(0,sourcenb) Else For i As Integer = 0 To sourcenb h=richedit(i) SendMessage(h,EM_HIDESELECTION,1,0) 'no move fb_setcolor(h,1,0,1)'all the text SendMessage(h,EM_HIDESELECTION,0,0) Next EndIf dsp_color End Sub '===================== break on var =============================================================== private function brkv_test() As Byte Dim recup(20) As Integer,ptrs As pointeurs,flag As Integer=0 Dim As Integer adr,temp2,temp3 Dim As String strg ptrs.pxxx=@recup(0) If brkv.arr Then 'watching dyn array element ? adr=vrr(brkv.ivr).ini ReadProcessMemory(dbghand,Cast(LPCVOID,adr),@adr,4,0) If adr<>brkv.arr Then brkv.adr+=brkv.arr-adr:brkv.arr=adr 'compute delta then add it if needed temp2=vrr(brkv.ivr).ini+2*SizeOf(Integer) 'adr global size 25/07/2015 64bit ReadProcessMemory(dbghand,Cast(LPCVOID,temp2),@temp3,SizeOf(Integer),0) If brkv.adr>adr+temp3 Then 'out of limit ? brkv_set(0) 'erase Return FALSE End If End If Select Case brkv.typ Case 2 'byte ReadProcessMemory(dbghand,Cast(LPCVOID,brkv.adr),@recup(0),1,0) If brkv.val.vbyte>*ptrs.pbyte Then If 42 And brkv.ttb Then flag=1 ElseIf brkv.val.vbyte<*ptrs.pbyte Then If 37 And brkv.ttb Then flag=1 ElseIf brkv.val.vbyte=*ptrs.pbyte Then If 19 And brkv.ttb Then flag=1 End If Case 3 'ubyte ReadProcessMemory(dbghand,Cast(LPCVOID,brkv.adr),@recup(0),1,0) If brkv.val.vubyte<*ptrs.pubyte Then If 42 And brkv.ttb Then flag=1 ElseIf brkv.val.vubyte>*ptrs.pubyte Then If 37 And brkv.ttb Then flag=1 ElseIf brkv.val.vubyte=*ptrs.pubyte Then If 19 And brkv.ttb Then flag=1 End If Case 5 'short ReadProcessMemory(dbghand,Cast(LPCVOID,brkv.adr),@recup(0),2,0) If brkv.val.vshort<*ptrs.pshort Then If 42 And brkv.ttb Then flag=1 ElseIf brkv.val.vshort>*ptrs.pshort Then If 37 And brkv.ttb Then flag=1 ElseIf brkv.val.vshort=*ptrs.pshort Then If 19 And brkv.ttb Then flag=1 End If Case 6 'ushort ReadProcessMemory(dbghand,Cast(LPCVOID,brkv.adr),@recup(0),2,0) If brkv.val.vushort<*ptrs.pushort Then If 42 And brkv.ttb Then flag=1 ElseIf brkv.val.vushort>*ptrs.pushort Then If 37 And brkv.ttb Then flag=1 ElseIf brkv.val.vushort=*ptrs.pushort Then If 19 And brkv.ttb Then flag=1 End If Case 1 'integer32/long ReadProcessMemory(dbghand,Cast(LPCVOID,brkv.adr),@recup(0),4,0) If brkv.val.vinteger<*ptrs.pinteger Then If 42 And brkv.ttb Then flag=1 ElseIf brkv.val.vinteger>*ptrs.pinteger Then If 37 And brkv.ttb Then flag=1 ElseIf brkv.val.vinteger=*ptrs.pinteger Then If 19 And brkv.ttb Then flag=1 End If Case 8 'uinteger32/ulong pointer ReadProcessMemory(dbghand,Cast(LPCVOID,brkv.adr),@recup(0),4,0) If brkv.val.vuinteger<*ptrs.puinteger Then If 42 And brkv.ttb Then flag=1 ElseIf brkv.val.vuinteger>*ptrs.puinteger Then If 37 And brkv.ttb Then flag=1 ElseIf brkv.val.vuinteger=*ptrs.puinteger Then If 19 And brkv.ttb Then flag=1 End If Case 4,13,14 If brkv.typ=13 Then ' normal string ReadProcessMemory(dbghand,Cast(LPCVOID,brkv.adr),@adr,SizeOf(Integer),0) 'address ptr 25/07/2015 64bit Else adr=brkv.adr End If Clear recup(0),0,26 'max 25 char ReadProcessMemory(dbghand,Cast(LPCVOID,adr),@recup(0),25,0) 'value strg=*ptrs.pzstring If brkv.ttb=32 Then If brkv.vst<>strg Then flag=1 Else If brkv.vst=strg Then flag=1 EndIf End Select If flag Then If brkv.ivr=0 Then stopcode=CSBRKM Else stopcode=CSBRKV brkv_set(0) Return TRUE End If Return FALSE End Function '=============================================================================== private function Tree_AddItem(hParent As HTREEITEM,Text As String,hInsAfter As HTREEITEM,hTV As HWND) As HTREEITEM Dim hItem As HTREEITEM Dim tvIns As TVINSERTSTRUCT Dim tvI As TV_ITEM tvI.mask = TVIF_TEXT Or TVIF_IMAGE Or TVIF_SELECTEDIMAGE Or TVIF_PARAM tvI.pszText = StrPtr(Text) tvI.cchTextMax = Len(Text) tvIns.item = tvI tvIns.hinsertAfter = hInsAfter tvIns.hParent = hParent 'Pour hinsertafter soit hitem soit : 'TVI_FIRST Inserts the item at the beginning of the list. 'TVI_LAST Inserts the item at the end of the list. 'TVI_SORT Inserts the item into the list in alphabetical order. hItem = Cast(HTREEITEM,SendMessage(hTV,TVM_INSERTITEM,0,Cast(LPARAM,@tvIns))) ' SendMessage(htv,TVM_SORTCHILDREN ,0,byval hparent) 'Activate to sort elements SendMessage(htv,TVM_EXPAND,TVE_COLLAPSE,Cast(LPARAM,hparent)) ' SendMessage(htv,TVM_EXPAND,TVE_EXPAND,hparent) Return hItem End Function '========================================== private function Tree_upditem(hitem As HTREEITEM,text As String,hTV As HWND) As Integer ' UPDATE TEXT ITEM Dim tvI As TVITEM tvI.mask = TVIF_TEXT tvI.pszText = StrPtr(Text) tvI.cchTextMax = Len(Text) tvi.hitem=hitem Tree_upditem=SendMessage(htv,TVM_SETITEM,0,Cast(LPARAM,@tvI)) 'Returns true if successful or false otherwise End Function '================================================ private sub menu_option(menu As HMENU,idnt As Integer,txt As String,value As Integer=0) Dim As String stempo=txt Static As Long flag '04/12/2014 If value Then stempo+=shcut_txt(value,1) AppendMenu(menu, MF_STRING, idnt,StrPtr(stempo)) shcut(shcutnb).sccur=value shcut(shcutnb).scmenu=menu shcut(shcutnb).scidnt=idnt If shcutnb>=SHCUTMAX AndAlso flag=0 Then flag=1 fb_message("Shortcut loading","Too much menu options"+Chr(13)+"Upper limit reached, change SHCUTMAX value"):Exit Sub '04/12/2014 EndIf shcutnb+=1 End Sub private sub menu_set menuRoot = CreateMenu() menuedit = CreatepopupMenu() menuedit2 = CreatepopupMenu() menu_option(menuedit,IDCONTHR, "Run to Cursor",VK_C) 'AppendMenu(menuedit, MFT_BITMAP,IDCONTHR, LoadImage(fb_hinstance,"buttons\step_over.bmp",IMAGE_BITMAP,19,17,LR_LOADFROMFILE)) 'AppendMenu(menuedit, MFT_BITMAP,IDCONTHR, Loadbitmap(fb_hinstance,Cast(LPSTR,MAKEINTRESOURCE(1001)))) menu_option(menuedit,IDBUTSTEP, "Next step",VK_S) menu_option(menuedit,IDBUTSTEPP, "Step over procs",VK_O) menu_option(menuedit,IDBUTSTEPM, "Step out current proc",VK_E) menu_option(menuedit,IDBUTSTEPT, "Step top called proc",VK_T) menu_option(menuedit,IDBUTSTEPB, "Step bottom current proc",VK_B) menu_option(menuedit,IDBUTRUN, "Run",VK_R) menu_option(menuedit,IDFASTRUN, "Fast Run",VK_F) menu_option(menuedit,IDBUTSTOP, "Halt running debuggee",VK_H) menu_option(menuedit,IDBUTKILL, "Kill debuggee",VK_K) menu_option(menuedit,IDBUTAUTO, "Step auto",VK_A) menu_option(menuedit,IDTHRDAUT, "Step auto multi threads",VK_D) menu_option(menuedit,IDEXEMOD, "Modify execution",VK_M) AppendMenu(menuedit, MF_SEPARATOR, 0, "") menu_option(menuedit,IDSETBRK, "Set/Clear Breakpoint",VK_F3) menu_option(menuedit,IDSETBRKC, "Set/clear Breakpoint with counter",VCTRL+VK_F3) '03/09/2015 menu_option(menuedit,IDRSTBRKC, "ReSet initial value counter of a Breakpoint") '03/09/2015 menu_option(menuedit,IDCHGBRKC, "Change value counter of a Breakpoint") '03/09/2015 menu_option(menuedit,IDSETBRT, "Set/Clear tempo Breakpoint",VSHIFT+VK_F3) menu_option(menuedit,IDBRKENB, "Enable/disable Breakpoint") menu_option(menuedit,IDMNGBRK, "Manage Breakpoints") AppendMenu(menuedit, MF_SEPARATOR, 0, "") AppendMenu(menuedit,MF_STRING,IDSHWVAR, "Show var"+Chr(9)+"Ctrl+Left click") AppendMenu(menuedit,MF_STRING,IDSETWVAR, "Set watched var"+Chr(9)+"Alt+Left click") AppendMenu(menuedit, MF_SEPARATOR, 0, "") menu_option(menuedit,IDFNDTXT, "Find text",VCTRL+VK_F) menu_option(menuedit,IDTGLBMK, "Toggle bookmark",VCTRL+VK_F2) menu_option(menuedit,IDNXTBMK, "Next bookmark",VK_F2) menu_option(menuedit,IDPRVBMK, "Previous bookmark",VSHIFT+VK_F2) menu_option(menuedit,IDGOTO, "Goto Line") AppendMenu(menuedit, MF_STRING Or MF_POPUP, Cast(Integer,menuedit2),"ASM data") menu_option(menuedit2,IDLINEADR, "Line Address") menu_option(menuedit2,IDLINEASM, "Asm code of line") menu_option(menuedit2,IDPROCASM, "Asm code of proc (from line)") menu_option(menuedit2,IDREGS, "Show registers for current thread)") menu_option(menuedit,IDACCLINE, "Mark no executable lines") menu_option(menuedit,IDFCSSRC, "Focus lines",VK_L) AppendMenu(menuedit, MF_SEPARATOR, 0, "") menu_option(menuedit,IDADDNOT, "Add Notes") menuvar = CreatepopupMenu() menuvar2 = CreatepopupMenu() menuvar3 = CreatepopupMenu()'28/11/2014 menuvar4 = CreatepopupMenu() menuvar5 = CreatepopupMenu()''2016/06/15 AppendMenu(menuvar, MF_STRING Or MF_POPUP, Cast(Integer,menuvar2),"Set watched") menu_option(menuvar2,IDSETWTCH,"Set watched") menu_option(menuvar2,IDSETWTTR,"Set watched+trace") menu_option(menuvar,IDVARBRK, "Break on var value") AppendMenu(menuvar, MF_SEPARATOR, 0, "") menu_option(menuvar,IDSELIDX, "Select index") AppendMenu(menuvar, MF_STRING Or MF_POPUP, Cast(Integer,menuvar5),"Array tracking") ''2016/06/15 menu_option(menuvar5,IDTRCKARR, "Assign vars to an array") menu_option(menuvar5,IDTRCKIDX0, "Set Variable for index 1") menu_option(menuvar5,IDTRCKIDX1, "Set Variable for index 2") menu_option(menuvar5,IDTRCKIDX2, "Set Variable for index 3") menu_option(menuvar5,IDTRCKIDX3, "Set Variable for index 4") menu_option(menuvar5,IDTRCKIDX4, "Set Variable for index 5") menu_option(menuvar5,IDTRCKRST, "Reset all choices") menu_option(menuvar,IDVARDMP, "Variable Dump") menu_option(menuvar,IDPTDUMP, "Pointed data Dump") menu_option(menuvar,IDVAREDT, "Edit var value") menu_option(menuvar,IDSHWEXP, "Show/expand variable") menu_option(menuvar,IDSHSTRG, "Show z/w/string") menu_option(menuvar,IDSHCHAR, "Show char at position") '03/11/2014 menu_option(menuvar,IDCHGZSTR,"Change (u)byte<>zstring type") AppendMenu(menuvar, MF_SEPARATOR, 0, "") menu_option(menuvar,IDLOCPRC, "Locate proc (source)") menu_option(menuvar,IDCALLINE,"Locate calling line") menu_option(menuvar,IDPBCKTRK,"Proc call Backtracking") menu_option(menuvar,IDPCHNING,"Proc call Chaining") menu_option(menuvar,IDASMPRC, "Asm code of proc") menu_option(menuvar,IDFNDVAR, "Find any text") '05/09/2015 menu_option(menuvar,IDVCLPSE, "Collapse proc/var") menu_option(menuvar,IDVEXPND, "Expand proc/var") AppendMenu(menuvar, MF_STRING Or MF_POPUP, Cast(Integer,menuvar3),"List to log") '28/11/2014 menu_option(menuvar3,IDLSTVARA, "List all proc/var") menu_option(menuvar3,IDLSTVARS, "List selected proc/var") AppendMenu(menuvar, MF_STRING Or MF_POPUP, Cast(Integer,menuvar4),"Copy to clipboard") menu_option(menuvar4,IDCLBVARA, "Copy all proc/var") menu_option(menuvar4,IDCLBVARS, "Copy selected proc/var") menuwatch = CreatepopupMenu() menu_option(menuwatch,IDWCHVAR, "Show in var window") menu_option(menuwatch,IDWCHEDT, "Edit value") menu_option(menuwatch,IDWCHDMP, "Memory Dump") menu_option(menuwatch,IDWCHSHW, "Show/expand variable") menu_option(menuwatch,IDWCHSTG, "Show z/w/string") AppendMenu(menuwatch, MF_SEPARATOR, 0, "") menu_option(menuwatch,IDWCHTTGL,"Toggle Tracing") menu_option(menuwatch,IDWCHTTGA,"Cancel all Tracing") AppendMenu(menuwatch, MF_SEPARATOR, 0, "") menu_option(menuwatch,IDSTWTCH1,"Switch watch 1") menu_option(menuwatch,IDSTWTCH2,"Switch watch 2") menu_option(menuwatch,IDSTWTCH3,"Switch watch 3") menu_option(menuwatch,IDSTWTCH4,"Switch watch 4") AppendMenu(menuwatch, MF_SEPARATOR, 0, "") menu_option(menuwatch,IDWCHDEL,"Delete") menu_option(menuwatch,IDWCHDALL,"Delete all") menuproc = CreatePopupMenu() menu_option(menuproc,IDLOCPRC, "Locate proc (source)") menu_option(menuproc,IDASMPRC, "Asm code of proc") menu_option(menuproc,IDSORTPRC,"Toggle sort by module or by proc") AppendMenu(menuproc, MF_SEPARATOR, 0, "") menu_option(menuproc,IDRSTPRC, "All procs followed") menu_option(menuproc,IDSETPRC, "No proc followed") menuthread = CreatepopupMenu() menu_option(menuthread,IDTHRDCHG, "Select next thread to be executed") menu_option(menuthread,IDEXCLINE, "Show next executed line (source)") menu_option(menuthread,IDCREATHR, "Show line creating thread (source)") menu_option(menuthread,IDLOCPRC, "Show first proc of thread (source)") menu_option(menuthread,IDSHWPROC, "Show proc (proc/var)") menu_option(menuthread,IDSHPRSRC, "Show proc (source)") menu_option(menuthread,IDTBCKTRK, "Proc call Backtracking") menu_option(menuthread,IDTCHNING, "Proc call Chaining") menu_option(menuthread,IDPRCRADR, "Proc Addresses") menu_option(menuthread,IDTHRDKLL, "Kill thread") menu_option(menuthread,IDTHRDEXP, "Expand one thread") menu_option(menuthread,IDTHRDCOL, "Collapse all threads") menu_option(menuthread,IDTHRDLST, "List all threads") menutools = CreatepopupMenu() menu_option(menutools,IDCMDLPRM, "Settings") menu_option(menutools,IDABOUT, "About") menu_option(menutools,IDCMPINF, "Compile info") menu_option(menutools,IDDBGHELP, "Help",VK_F1) menu_option(menutools,IDTUTO, "Launch tutorial") AppendMenu(menutools, MF_SEPARATOR, 0, "") menu_option(menutools,IDFILEIDE, "Launch IDE",VK_F10)'"F10" menu_option(menutools,IDQCKEDT, "Quick edit",VK_F11)'"F11" menu_option(menutools,IDCMPNRUN, "Compile (-g) and debug",VK_F9)'"F9" menu_option(menutools,IDCLIPBRD, "Copy notes to clipboard") menu_option(menutools,IDSHWLOG, "Show log file") menu_option(menutools,IDHIDLOG, "Hide log file") menu_option(menutools,IDDELLOG, "Delete log file") menu_option(menutools,IDSHENUM, "List enum") AppendMenu(menutools, MF_SEPARATOR, 0, "") menu_option(menutools,IDINFOS, "Process list") menu_option(menutools,IDLSTDLL, "Dlls list") menu_option(menutools,IDLSTSHC, "Shortcut keys list") menu_option(menutools,IDWINMSG, "Translate Win Message") menu_option(menutools,IDSHWBDH, "Bin/Dec/Hex") menu_option(menutools,IDFRTIMER,"Show fast run timer") menu_option(menutools,IDJITDBG, "Set JIT Debugger") ' Attach menu items to main menu AppendMenu(menuRoot,MF_POPUP, Cast(UInteger,menuedit),"Not seen") ' InsertMenu(dbgmnuRoot, 0, MF_POPUP, menuvar,"") End Sub '============================================== private function WinMain ( ByVal hInstance As HINSTANCE, _ ByVal hPrevInstance As Integer, _ szCmdLine As String, _ ByVal iCmdShow As Integer ) As Integer Dim wMsg As MSG Dim wcls As WNDCLASS Dim hWnd As Unsigned Integer WinMain = 0 '' '' Setup window class '' fb_hinstance=hinstance With wcls .style = CS_HREDRAW Or CS_VREDRAW .lpfnWndProc = Cast(WndProc,@WndProc) .cbClsExtra = 0 .cbWndExtra = 0 .hInstance = hInstance .hIcon = LoadIcon( hInstance,MAKEINTRESOURCE(1))'LoadIcon( null, byval IDI_APPLICATION ) .hCursor = LoadCursor( NULL, ByVal IDC_ARROW ) .hbrBackground = GetStockObject( WHITE_BRUSH ) .lpszMenuName = NULL .lpszClassName = StrPtr( fb_szAppName ) End With '' '' Register the window class '' If ( RegisterClass( @wcls ) = FALSE ) Then MessageBox NULL, "Failed to register the window class", fb_szAppName, MB_ICONERROR Exit Function End If ' ----------------------------------------------- Dim iccex As INITCOMMONCONTROLSEX iccex.dwSize = Len(INITCOMMONCONTROLSEX) iccex.dwICC = _ ICC_LISTVIEW_CLASSES Or ICC_TREEVIEW_CLASSES Or ICC_BAR_CLASSES _ Or ICC_TAB_CLASSES Or ICC_UPDOWN_CLASS Or ICC_PROGRESS_CLASS _ Or ICC_USEREX_CLASSES Or ICC_DATE_CLASSES InitCommonControlsEx(@iccex) ' --------------- call FB_WIN() for initialisation ------------------ fb_win() 'create window, etc ' -------------------------------------------------------------------------------- '' Process windows messages While ( GetMessage( @wMsg, NULL, 0, 0 ) <> FALSE ) Dim hActiveWindow As HWND hActiveWindow = GetActiveWindow() If (IsWindow(hActiveWindow)=0) Or (IsDialogMessage(hActiveWindow,@wMsg)=0) Then TranslateMessage @wMsg DispatchMessage @wMsg End If Wend WinMain = wMsg.wParam End Function '======================================================= private sub dump_set(hWnd As HWND) Dim lvCol As LVCOLUMN,lvItem As LVITEM Dim i As Integer Dim As rect recbox Dim tmp As String,delta As Integer,lg As Integer For i=lvnbcol+1 To 0 Step -1 sendmessage(hwnd,LVM_DELETECOLUMN,i,0) Next Select Case lvtyp Case 2,3,16 'byte/ubyte/boolean dec/hex 20/08/2015 boolean lvnbcol=16 :lg=40 Case 5,6 'short/ushort lvnbcol=8 :lg=60 Case 1,8,7 'integer/uinteger lvnbcol=4 :lg=90 Case 9,10 'longinteger/ulonginteger lvnbcol=2 :lg=160 Case 11 'single lvnbcol=4 :lg=120 Case 12 'double lvnbcol=2 :lg=180 End Select lvCol.mask = LVCF_FMT Or LVCF_WIDTH Or LVCF_TEXT Or LVCF_SUBITEM lvCol.fmt = LVCFMT_LEFT lvcol.cx=0 lvItem.mask = LVIF_TEXT lvCol.pszText = StrPtr("ADDRESS") lvCol.iSubItem = 0 sendmessage(hwnd,LVM_INSERTCOLUMN,0,Cast(LPARAM,@lvCol)) 'LVSCW_AUTOSIZE_USEHEADER = -2 ou AUTOSIZE= -1) sendmessage(hwnd,LVM_SETCOLUMNWIDTH,0,100) delta=16/lvnbcol For i=1 To lvnbcol 'nb columns tmp="+"+Right("0"+Str(delta*(i-1)),2) lvCol.pszText = StrPtr(tmp) lvCol.iSubItem = i sendmessage(hwnd,LVM_INSERTCOLUMN,i,Cast(LPARAM,@lvCol)) sendmessage(hwnd,LVM_SETCOLUMNWIDTH,i,lg) Next tmp="ASCII" lvCol.pszText = StrPtr(tmp) lvCol.iSubItem = lvnbcol+1 '17 sendmessage(hwnd,LVM_INSERTCOLUMN,lvnbcol+1,Cast(LPARAM,@lvCol)) sendmessage(hwnd,LVM_SETCOLUMNWIDTH,lvnbcol+1,125) ''''to avoid display update every update 'SendMessage(hwnd, WM_SETREDRAW, FALSE, 0) ' sendmessage(hwnd,LVM_SETCOLUMNWIDTH,lvnbcol+1,LVSCW_AUTOSIZE)'_USEHEADER) '==================================================================== sendmessage(hwnd,LVM_SETTEXTCOLOR,0,RGB(128,0,0)) 'sendmessage(hwnd,LVM_SETTEXTBKCOLOR,0,RGB(0,128,0)) 'sendmessage(hwnd,LVM_SETBKCOLOR,0,RGB(0,0,128)) ' InvalidateRect(hWnd,0,1) 'recreate dump_box to take in account new parameters If hdumpbx Then GetWindowRect(hdumpbx,@recbox):destroywindow(hdumpbx) fb_Dialog(@dump_box,"Manage dump",windmain,283,250,120,150,WS_POPUP Or WS_SYSMENU Or ws_border Or WS_CAPTION) SetWindowPos(hdumpbx,NULL,recbox.left,recbox.top,0,0,SWP_NOACTIVATE Or SWP_NOZORDER Or SWP_NOSIZE Or SWP_SHOWWINDOW) End If End Sub '================================ private sub start_pgm(p As Any Ptr) Dim As Integer pclass,st Dim As String workdir,cmdl Dim sinfo As STARTUPINFO 'directory st=0 While InStr(st+1,exename,"\") st=InStr(st+1,exename,"\") Wend workdir=Left(exename,st) cmdl=""""+exename+""" "+cmdexe(0) #Ifdef fulldbg_prt dbg_prt (Date+" "+Time+"Start Debug with "+cmdl) #EndIf sinfo.cb = Len(sinfo) 'Set the flags sinfo.dwFlags = STARTF_USESHOWWINDOW 'Set the window's startup position sinfo.wShowWindow = SW_NORMAL 'Set the priority class pclass = NORMAL_PRIORITY_CLASS Or CREATE_NEW_CONSOLE Or DEBUG_PROCESS Or DEBUG_ONLY_THIS_PROCESS 'Start the program If CreateProcess(exename,StrPtr(cmdl),ByVal NULL,ByVal NULL, FALSE, pclass, _ NULL, WorkDir, @sinfo, @pinfo) Then 'Wait WaitForSingleObject pinfo.hProcess, 10 dbgprocId=pinfo.dwProcessId dbgthreadID=pinfo.dwThreadId dbghand=pinfo.hProcess dbghthread=pinfo.hThread #Ifdef fulldbg_prt dbg_prt ("Create process") dbg_prt ("pinfo.hThread "+Str(pinfo.hThread)) dbg_prt ("pinfo.dwThreadId "+Str(pinfo.dwThreadId)) dbg_prt ("hand "+Str(dbghand)+" Pid "+Str(dbgprocid)) #EndIf prun=TRUE runtype=RTSTEP wait_debug Else fb_message("PROBLEM","no debugged pgm -->"+exename+Chr(10)+"error :"+Str(GetLastError()),MB_ICONERROR Or MB_SYSTEMMODAL) End If End Sub '=========================== private sub frground() Dim Proc As Integer,Nous As Integer,timeout As Integer 'SPI_GETFOREGROUNDLOCKTIMEOUT = 0x2000 'SPI_SETFOREGROUNDLOCKTIMEOUT = 0x2001 ''''''' messagebeep(MB_ICONASTERISK) SetForegroundWindow(windmain) FlashWindow(windmain,TRUE) Return Proc=GetWindowThreadProcessId(GetForeGroundWindow,0) Nous=GetCurrentThreadID If Proc<>Nous Then ' fbdebugger not in foreground SystemParametersInfo(&h2000,0,@timeout,0) SystemParametersInfo(&h2001,0,0,SPIF_SENDWININICHANGE Or SPIF_UPDATEINIFILE) SetForegroundWindow(windmain) SystemParametersInfo(&h2001,0,Cast(PVOID,timeout),SPIF_SENDWININICHANGE Or SPIF_UPDATEINIFILE) Else 'already SetForegroundWindow(windmain) End If End Sub '================================================= private sub but_enable() Dim l As ZString *300 Select Case runtype Case RTSTEP 'wait EnableWindow(butstep,TRUE) EnableWindow(butstepp,TRUE) EnableWindow(butstept,TRUE) EnableWindow(butstepb,TRUE) EnableWindow(butstepm,TRUE) EnableWindow(butauto,TRUE) EnableWindow(butrun,TRUE) EnableWindow(butfastrun,TRUE) EnableWindow(butstop,TRUE) EnableWindow(butcont,TRUE) EnableWindow(butfree,TRUE) EnableWindow(butkill,TRUE) EnableWindow(butexemod,TRUE) EnableWindow(butmini,TRUE) l="Waiting "+stoplibel(stopcode) SendMessage(dbgstatus,SB_SETTEXT,0,Cast(LPARAM,@l)) l="Thread "+Str(thread(threadcur).id) SendMessage(dbgstatus,SB_SETTEXT,1,Cast(LPARAM,@l)) l=name_extract(source(proc(procsv).sr)) SendMessage(dbgstatus,SB_SETTEXT,2,Cast(LPARAM,@l)) SendMessage(dbgstatus,SB_SETTEXT,3,Cast(LPARAM,StrPtr(proc(procsv).nm))) l=Left(Str(fasttimer),10) '08/04/2014 SendMessage(dbgstatus,SB_SETTEXT,4,Cast(LPARAM,@l)) frground() Case RTRUN,RTFREE,RTFRUN 'step over / out / free / run / fast run EnableWindow(butstep,FALSE) EnableWindow(butstepp,FALSE) EnableWindow(butstept,FALSE) EnableWindow(butstepb,FALSE) EnableWindow(butstepm,FALSE) EnableWindow(butauto,FALSE) EnableWindow(butrun,FALSE) EnableWindow(butfastrun,FALSE) EnableWindow(butcont,FALSE) EnableWindow(butfree,FALSE) 'EnableWindow(butkill,FALSE) '03/09/2015 to let the possibility to kill the debuggee when running EnableWindow(butexemod,FALSE) Select Case runtype Case RTRUN SendMessage(dbgstatus,SB_SETTEXT,0,Cast(LPARAM,@"Running")) Case RTFRUN SendMessage(dbgstatus,SB_SETTEXT,0,Cast(LPARAM,@"FAST Running")) Case Else SendMessage(dbgstatus,SB_SETTEXT,0,Cast(LPARAM,@"Released")) End Select Case RTAUTO 'auto EnableWindow(butstep,FALSE) EnableWindow(butstepp,FALSE) EnableWindow(butstept,FALSE) EnableWindow(butstepb,FALSE) EnableWindow(butstepm,FALSE) EnableWindow(butauto,FALSE) EnableWindow(butrun,FALSE) EnableWindow(butfastrun,FALSE) EnableWindow(butcont,FALSE) EnableWindow(butfree,FALSE) EnableWindow(butkill,FALSE) EnableWindow(butexemod,FALSE) SendMessage(dbgstatus,SB_SETTEXT,0,Cast(LPARAM,@"Auto")) Case Else 'prun=false --> terminated or no pgm EnableWindow(butstep,FALSE) EnableWindow(butstepp,FALSE) EnableWindow(butstept,FALSE) EnableWindow(butstepb,FALSE) EnableWindow(butstepm,FALSE) EnableWindow(butauto,FALSE) EnableWindow(butrun,FALSE) EnableWindow(butfastrun,FALSE) EnableWindow(butstop,FALSE) EnableWindow(butcont,FALSE) EnableWindow(butfree,FALSE) EnableWindow(butkill,FALSE) EnableWindow(butexemod,FALSE) If runtype=RTEND Then SendMessage(dbgstatus,SB_SETTEXT,0,Cast(LPARAM,@"Terminated")) enablewindow(butmini,FALSE) End Select End Sub '================================================= private sub menu_enable() 'MF_DISABLED MF_ENABLED MF_GRAYED Dim flag As Integer If prun Then flag=MF_ENABLED Else flag=MF_GRAYED EnableMenuItem(menuedit,IDSETBRK, flag) EnableMenuItem(menuedit,IDSETBRT, flag) EnableMenuItem(menuedit,IDSETBRKC, flag)'03/09/2015 EnableMenuItem(menuedit,IDRSTBRKC, flag)'03/09/2015 EnableMenuItem(menuedit,IDCHGBRKC, flag)'03/09/2015 EnableMenuItem(menuedit,IDBRKENB, flag) EnableMenuItem(menuedit,IDCONTHR, flag) EnableMenuItem(menuedit,IDBUTSTEP, flag) EnableMenuItem(menuedit,IDBUTSTEPP,flag) EnableMenuItem(menuedit,IDBUTSTEPM,flag) EnableMenuItem(menuedit,IDBUTSTEPB,flag) EnableMenuItem(menuedit,IDBUTSTEPT,flag) EnableMenuItem(menuedit,IDBUTRUN, flag) EnableMenuItem(menuedit,IDEXEMOD, flag) EnableMenuItem(menuedit,IDFASTRUN, flag) EnableMenuItem(menuedit,IDBUTKILL, flag) EnableMenuItem(menuedit,IDBUTSTOP, flag) EnableMenuItem(menuedit,IDBUTAUTO, flag) EnableMenuItem(menuedit,IDTHRDAUT, flag) EnableMenuItem(menuedit,IDSHWVAR, flag) EnableMenuItem(menuedit,IDSETWVAR, flag) EnableMenuItem(menuedit,IDLINEADR, flag) EnableMenuItem(menuedit,IDLINEASM, flag) EnableMenuItem(menuedit,IDPROCASM, flag) EnableMenuItem(menuedit,IDREGS, flag) EnableMenuItem(menuedit,27, flag Or MF_BYPOSITION) 'disable or enable asm data EnableMenuItem(menutools,IDLSTDLL, flag) EnableMenuItem(menuvar,0, flag Or MF_BYPOSITION) 'disable or enable set watched EnableMenuItem(menuvar,IDSELIDX, flag) EnableMenuItem(menuvar,4, flag Or MF_BYPOSITION) 'disable or enable array tracking ''2016/06/15 EnableMenuItem(menuvar,IDVARDMP, flag) EnableMenuItem(menuvar,IDVAREDT, flag) EnableMenuItem(menuvar,IDSHWEXP, flag) EnableMenuItem(menuvar,IDVARBRK, flag) EnableMenuItem(menuvar,IDSHSTRG, flag) EnableMenuItem(menuvar,IDSHCHAR, flag) '03/11/2014 EnableMenuItem(menuvar,IDCHGZSTR, flag) EnableMenuItem(menuvar,IDLSTVARA, flag) EnableMenuItem(menuvar,IDLSTVARS, flag) EnableMenuItem(menuvar,IDCLBVARA, flag) '28/11/2014 EnableMenuItem(menuvar,IDCLBVARS, flag) EnableMenuItem(menuvar,IDPTDUMP , flag) EnableMenuItem(menuvar,IDFNDVAR , flag) '05/09/2015 EnableMenuItem(menuthread,IDTHRDCHG,flag) EnableMenuItem(menuthread,IDTHRDKLL,flag) EnableMenuItem(menuthread,IDEXCLINE,flag) EnableMenuItem(menuthread,IDCREATHR,flag) EnableMenuItem(menuthread,IDTHRDEXP,flag) EnableMenuItem(menuthread,IDTHRDCOL,flag) EnableMenuItem(menuthread,IDLOCPRC, flag) EnableMenuItem(menuthread,IDSHWPROC,flag) EnableMenuItem(menuthread,IDTBCKTRK,flag) EnableMenuItem(menuthread,IDTCHNING,flag) EnableMenuItem(menuthread,IDSHPRSRC,flag) EnableMenuItem(menuthread,IDPRCRADR,flag) EnableMenuItem(menuthread,IDTHRDLST,flag) If wtchcpt AndAlso prun Then flag=MF_ENABLED Else flag=MF_GRAYED EnableMenuItem(menuwatch,IDSTWTCH1,flag) EnableMenuItem(menuwatch,IDSTWTCH2,flag) EnableMenuItem(menuwatch,IDSTWTCH3,flag) EnableMenuItem(menuwatch,IDSTWTCH4,flag) EnableMenuItem(menuwatch,IDWCHVAR,flag) EnableMenuItem(menuwatch,IDWCHDMP,flag) EnableMenuItem(menuwatch,IDWCHSHW,flag) EnableMenuItem(menuwatch,IDWCHSTG,flag) EnableMenuItem(menuwatch,IDWCHDEL,flag) EnableMenuItem(menuwatch,IDWCHDALL,flag) EnableMenuItem(menuwatch,IDWCHEDT,flag) EnableMenuItem(menuwatch,IDWCHTTGL,flag) EnableMenuItem(menuwatch,IDWCHTTGA,flag) If procnb Then flag=MF_ENABLED EnableMenuItem(menuproc,IDRSTPRC,flag) EnableMenuItem(menuproc,IDASMPRC,flag) EnableMenuItem(menuproc,IDSETPRC,flag) EnableMenuItem(menuproc,IDLOCPRC,flag) EnableMenuItem(menuproc,IDSORTPRC,flag) EnableMenuItem(menuvar,IDPBCKTRK,flag) EnableMenuItem(menuvar,IDPCHNING,flag) EnableMenuItem(menuvar,IDLOCPRC,flag) EnableMenuItem(menuvar,IDCALLINE,flag) EnableMenuItem(menuvar,IDVCLPSE,flag) EnableMenuItem(menuvar,IDVEXPND,flag) EnableMenuItem(menuvar,IDASMPRC,flag) If brknb Then EnableMenuItem(menuedit,IDMNGBRK,MF_ENABLED) Else EnableMenuItem(menuedit,IDMNGBRK,MF_GRAYED) EndIf End Sub '================================================= private sub dsp_hide(t As Integer) If dsptyp=0 Then 'enlarge or notes dsptyp=t ShowWindow(butenlrsrc,SW_HIDE) ShowWindow(butenlrvar,SW_HIDE) ShowWindow(butenlrmem,SW_HIDE) If t<>3 Then 'notes ShowWindow(htab1,SW_HIDE) ShowWindow(htab2,SW_HIDE) ShowWindow(dbgrichedit,SW_HIDE) ShowWindow(tviewcur,SW_HIDE) End If ShowWindow(bmkh,SW_HIDE) ShowWindow(listview1,SW_HIDE) ShowWindow(brkvhnd,SW_HIDE) For i As Integer =0 To WTCHMAIN:ShowWindow(wtch(i).hnd,SW_HIDE):Next dsp_size() Select Case t Case 1 'source ShowWindow(dbgrichedit,SW_SHOW) ShowWindow(htab1,SW_SHOW) ShowWindow(butenlrsrc,SW_SHOW) Case 2 'var ShowWindow(htab2,SW_SHOW) ShowWindow(tviewcur,SW_SHOW) ShowWindow(butenlrvar,SW_SHOW) Case 3 'notes ShowWindow(dbgedit1,SW_SHOW) setfocus(dbgedit1) Case 4 'dump ShowWindow(listview1,SW_SHOW) ShowWindow(butenlrmem,SW_SHOW) End Select Else 'normal display dsptyp=0 dsp_size() Select Case t Case 1 'src Case 2'var Case 3 'notes ShowWindow(dbgEdit1,SW_HIDE) Case 4 'dump End Select ShowWindow(butenlrsrc,SW_SHOW) ShowWindow(butenlrvar,SW_SHOW) ShowWindow(butenlrmem,SW_SHOW) ShowWindow(htab1,SW_SHOW) ShowWindow(htab2,SW_SHOW) ShowWindow(dbgrichedit,SW_SHOW) setfocus(dbgrichedit) ShowWindow(tviewcur,SW_SHOW) ShowWindow(listview1,SW_SHOW) ShowWindow(bmkh,SW_SHOW) ShowWindow(brkvhnd,SW_SHOW) For i As Integer =0 To WTCHMAIN:ShowWindow(wtch(i).hnd,SW_SHOW):Next EndIf End Sub '========================================================== private sub proc_expcol(v As Integer) For j As Integer =0 To procrnb SendMessage(tviewvar,TVM_EXPAND,v,Cast(LPARAM,procr(j).tv)) Next End Sub '========================================================== private function var_parent(child As HTREEITEM) As Integer 'find var master parent Dim As HTREEITEM temp,temp2,hitemp temp=child Do hitemp=temp2 temp2=temp temp=Cast(HTREEITEM,SendMessage(tviewvar,TVM_GETNEXTITEM,TVGN_PARENT,Cast(LPARAM,temp))) Loop While temp For i As Integer =1 To vrrnb If vrr(i).tv=hitemp Then Return i Next End Function '========================================================== private function var_find() As Integer 'return NULL if error Dim hitem As Integer 'get current hitem in tree hitem=sendmessage(tviewvar,TVM_GETNEXTITEM,TVGN_CARET,0)'NULL) For i As Integer = 1 To vrrnb 'search index variable If vrr(i).tv=hitem Then If vrr(i).ad=0 Then fb_message("Variable selection error","Dynamic array not yet sized !!"):Return 0 If vrr(i).vr<0 Then Return -i Else Return i EndIf End If Next fb_message("Variable selection error"," Select only a variable") Return 0 End Function private sub var_fill(i As Integer) If vrr(i).vr<0 Then varfind.ty=cudt(-vrr(i).vr).Typ varfind.pt=cudt(-vrr(i).vr).pt varfind.nm=cudt(-vrr(i).vr).nm varfind.pr=vrr(var_parent(vrr(i).tv)).vr'index of the vrb Else varfind.ty=vrb(vrr(i).vr).Typ varfind.pt=vrb(vrr(i).vr).pt varfind.nm=vrb(vrr(i).vr).nm varfind.pr=vrr(i).vr 'no parent so himself, index of the vrb End If varfind.ad=vrr(i).ad varfind.iv=i varfind.tv=tviewvar 'handle treeview varfind.tl=vrr(i).tv 'handle line End Sub private function var_find2(tv As HWND) As Integer 'return -1 if error Dim hitem As HTREEITEM,idx As Integer If tv=tviewvar Then 'get current hitem in tree hitem=Cast(HTREEITEM,sendmessage(tviewvar,TVM_GETNEXTITEM,TVGN_CARET,0)) For i As Integer = 1 To vrrnb 'search index variable If vrr(i).tv=hitem Then If vrr(i).ad=0 Then fb_message("Variable selection error","Dynamic array not yet sized !!"):Return -1 var_fill(i) Return i End If Next fb_message("Variable selection error2"," Select only a variable") Return -1 ElseIf tv=tviewwch Then idx=watch_find() If wtch(idx).psk=-3 OrElse wtch(idx).psk=-4 Then Return -1 'case non-existent local If wtch(idx).adr=0 Then Return -1 'dyn array varfind.nm=Left(wtch(idx).lbl,Len(wtch(idx).lbl)-1) varfind.ty=wtch(idx).typ varfind.pt=wtch(idx).pnt varfind.ad=wtch(idx).adr varfind.tv=tviewwch 'handle treeview varfind.tl=wtch(idx).tvl 'handle line varfind.iv=wtch(idx).ivr Else'shw/expand tree For idx =1 To SHWEXPMAX If shwexp(idx).tv=tv Then Exit For 'found index matching tview Next 'get current hitem in tree hitem=Cast(HTREEITEM,sendmessage(tv,TVM_GETNEXTITEM,TVGN_CARET,0)) For i As Integer = 1 To shwexp(idx).nb 'search index variable If vrp(idx,i).tl=hitem Then varfind.nm=vrp(idx,i).nm If varfind.nm="" Then varfind.nm="" varfind.ty=vrp(idx,i).Ty varfind.pt=vrp(idx,i).pt varfind.ad=vrp(idx,i).ad varfind.tv=tv 'handle treeview varfind.tl=hitem 'handle line varfind.iv=-1 Return i End If Next End If End Function '========================================== private sub watch_set() If wtchcpt>WTCHMAX Then ' free slot not found ' change focus ShowWindow(tviewcur,SW_HIDE) tviewcur=tviewwch ShowWindow(tviewcur,SW_SHOW) SetFocus(tviewcur) SendMessage(htab2,TCM_SETCURSEL,3,0) fb_message("Add watched variable","No free slot, delete one") Exit Sub EndIf 'Already set ? For i As Integer =0 To WTCHMAX If wtch(i).psk<>-1 AndAlso wtch(i).adr=varfind.ad AndAlso wtch(i).typ=varfind.ty AndAlso _ wtch(i).pnt=varfind.pt Then'found 'If fb_message("Set watched variable/memory","Already existing"+Chr(13)+"Continue ?", _ 'MB_YESNO or MB_ICONQUESTION or MB_DEFBUTTON1) = IDNO Then exit sub wtchidx=i'for delete fb_MDialog(@watch_box,"Adding watched : "+Left(wtch(i).lbl,Len(wtch(i).lbl)-1)+" already existing",windmain,50,25,180,90) Exit Sub EndIf Next watch_add(0)'first create no additional type End Sub private sub watch_add(f As Integer,r As Integer =-1) 'if r<>-1 session watched, return index Dim As Integer t Dim As String temps,temps2 Dim tvi As TVITEM,text As ZString *100 If r=-1 Then 'Find first free slot For i As Integer =0 To WTCHMAX If wtch(i).psk=-1 Then t=i:Exit For 'found Next wtchcpt+=1 If wtchcpt=1 Then menu_enable 'enable the context menu for the watched window Else t=r End If wtch(t).typ=varfind.ty wtch(t).pnt=varfind.pt wtch(t).adr=varfind.ad wtch(t).arr=0 wtch(t).tad=f If varfind.iv=-1 Then 'memory from dump_box or shw/expand wtch(t).lbl=varfind.nm wtch(t).psk=-2 wtch(t).ivr=0 Else 'variable wtch(t).ivr=varfind.iv ' if dyn array store real adr If Cast(Integer,vrb(varfind.pr).arr)=-1 Then ReadProcessMemory(dbghand,Cast(LPCVOID,vrr(varfind.iv).ini),@wtch(t).arr,4,0) End If If varfind.iv=procr(j).vr And varfind.iv0 Then c+=1 wtch(t).vnm(c)=vrb(vrr(iparent).vr).nm wtch(t).vty(c)=udt(vrb(vrr(iparent).vr).typ).nm If vrb(vrr(iparent).vr).arr Then wtch(t).var=1 Else wtch(t).var=0 Exit Do Else c+=1 wtch(t).vnm(c)=cudt(Abs(vrr(iparent).vr)).nm wtch(t).vty(c)=udt(cudt(Abs(vrr(iparent).vr)).typ).nm If cudt(Abs(vrr(iparent).vr)).arr Then wtch(t).var=1:Exit Do Else wtch(t).var=0 End If temp=Cast(HTREEITEM,SendMessage(tviewvar,TVM_GETNEXTITEM,TVGN_PARENT,Cast(LPARAM,vrr(iparent).tv))) For i As Integer =1 To vrrnb If vrr(i).tv=temp Then iparent=i Next Loop While 1 wtch(t).vnb=c EndIf If r=-1 Then wtch(t).tvl=Tree_AddItem(NULL,"To fill", 0, tviewwch) 'create an empty line in treeview watch_sh(t) wtchnew=t End Sub private sub watch_sh(aff As Integer) 'default all watched Dim As Integer vbeg,vend Dim As String libel,value If aff=WTCHALL Then vbeg=0:vend=WTCHMAX Else vbeg=aff:vend=aff For i As Integer= vbeg To vend If wtch(i).psk<>-1 Then libel=wtch(i).lbl If wtch(i).psk=-3 Then value=libel libel+=udt(wtch(i).typ).nm If wtch(i).idx Then libel+=">=LOCAL NON-EXISTENT" Else libel+=">=Dll not loaded" EndIf ElseIf wtch(i).psk=-4 Then value=libel Else value=var_sh2(wtch(i).typ,wtch(i).adr,wtch(i).pnt) libel+=value '2 spaces for trace T End If 'trace If Len(wtch(i).old)<>0 Then If wtch(i).old<>value Then dbg_prt("Trace :"+libel):wtch(i).old=value Mid(libel,1, 1) = "T" End If 'additionnal data If wtch(i).tad Then libel+=" "+var_add(Mid(value,InStr(value,"=")+1),wtch(i).typ,wtch(i).tad)'additionnal info 'main display If i<=WTCHMAIN Then setWindowText(wtch(i).hnd,libel) 'watched tab Tree_upditem(wtch(i).tvl,libel,tviewwch) End If Next End Sub private sub watch_trace(t As Integer=WTCHALL) If t=WTCHALL Then 'reset all For i As Integer =0 To WTCHMAX If wtch(i).old<>"" Then wtch(i).old="" watch_sh(i) EndIf Next Else If wtch(t).old<>"" Then 'reset one wtch(t).old="" Else 'set tracing If wtch(t).typ>15 AndAlso wtch(t).pnt=0 Then fb_message("Tracing Watched var/mem","Only with pointer or standard type") Exit Sub Else If flaglog=0 Then If fb_message("Tracing var/mem","No log output defined"+Chr(13)+"Open settings ?",MB_YESNO)=IDYES Then sendmessage(windmain,WM_COMMAND,IDCMDLPRM,0) EndIf If flaglog=0 Then fb_message("Tracing var/mem","No log output defined"+Chr(13)+"So doing nothing") Exit Sub EndIf EndIf If wtch(t).psk=-2 Then wtch(t).old=var_sh2(wtch(t).typ,wtch(t).adr,wtch(t).pnt) ElseIf wtch(t).psk=-3 Or wtch(t).psk=-4 Then wtch(t).old=wtch(t).lbl Else wtch(t).old=var_sh2(wtch(t).typ,wtch(t).adr,wtch(t).pnt) EndIf EndIf EndIf watch_sh(t) EndIf End Sub private sub watch_del(i As Integer=WTCHALL) Dim As Integer bg,ed If i=WTCHALL Then bg=0:ed=WTCHMAX Else bg=i:ed=i EndIf For j As Integer=bg To ed If wtch(j).psk=-1 Then Continue For wtch(j).psk=-1 wtch(j).old="" wtch(j).tad=0 wtchcpt-=1 If wtchcpt=0 Then menu_enable If j<=WTCHMAIN Then setWindowText(wtch(j).hnd,"Watch "+Str(j+1)) SendMessage(tviewwch,TVM_DELETEITEM,0,Cast(LPARAM,wtch(j).tvl)) Next End Sub private sub watch_sel(i As Integer) 'i index If wtch(i).psk=-1 OrElse wtch(i).psk=-3 OrElse wtch(i).psk=-4 Then Exit Sub If wtch(i).ivr=0 Then 'watch memory dumpadr=wtch(i).adr lvtyp=wtch(i).typ dump_set(listview1) dump_sh If hdumpbx=0 Then fb_Dialog(@dump_box,"Manage dump",windmain,283,25,120,150) End If Else If vrr(wtch(i).ivr).ad=wtch(i).adr Then ShowWindow(tviewcur,SW_HIDE) tviewcur=tviewvar ShowWindow(tviewcur,SW_SHOW) SendMessage(htab2,TCM_SETCURSEL,0,0) SendMessage(tviewvar,TVM_SELECTITEM,TVGN_CARET,Cast(LPARAM,vrr(wtch(i).ivr).tv)) SetFocus(tviewcur) Else fb_message("Select watched variable","Not possible : changed index (different address)") End If End If End Sub private function watch_find() As Integer Dim hitem As Integer 'get current hitem in tree hitem=sendmessage(tviewwch,TVM_GETNEXTITEM,TVGN_CARET,0) For k As Integer =0 To WTCHMAX If wtch(k).tvl=hitem Then Return k 'found Next End Function private sub watch_exch(i As Integer) Dim j As Integer 'get current hitem in tree j=watch_find() If i=j Then Exit Sub 'same nothing to do Swap wtch(i),wtch(j) Swap wtch(i).hnd,wtch(j).hnd 'handle for main display DO NOT BE CHANGED If wtch(j).psk=-1 Then 'destination (watch in main is empty) watch_sh(i) If j<=WTCHMAIN Then setWindowText(wtch(j).hnd,"Watch "+Str(j+1)) Else watch_sh(i):watch_sh(j) EndIf End Sub '========================================== private sub watch_check(wname()As String) Dim As Integer dlt,bg,ed,pidx,vidx,tidx,index,p,q,vnb,varb,ispnt,tad Dim As String pname,vname,vtype While wname(index)<>"" pidx=-1:vidx=-1:p=0:vnb=1 p=InStr(wname(index),"/") pname=Mid(wname(index),1,P-1) If InStr(pname,".dll") Then 'shared in dll pidx=0 Else 'check proc existing ? For i As Integer=1 To procnb If proc(i).nm=pname Then pidx=i:Exit For Next EndIf 'var name : vname,vtype/ and so on then pointer number q=p+1 p=InStr(q,wname(index),",") vname=Mid(wname(index),q,p-q) q=p+1 p=InStr(q,wname(index),"/") vtype=Mid(wname(index),q,p-q) If pidx=-1 Then fb_message("Watched variables","Proc <"+pname+"> for <"+vname+"> removed, canceled",MB_SYSTEMMODAL) index+=1 Continue While 'proc has been removed EndIf 'check var existing ? bg=proc(pidx).vr:ed=proc(pidx+1).vr-1 If pname="main" Then For i As Integer = 1 To vrbgbl If vrb(i).nm=vname AndAlso udt(vrb(i).typ).nm=vtype AndAlso vrb(i).arr=0 Then vidx=i tidx=vrb(i).typ ispnt=vrb(i).pt Exit For End If Next Else If pidx=0 Then 'DLL [WTC]=dll.dll/B,Integer/0/0 For i As Integer= 1 To TYPESTD '20/08/2015 If udt(i).nm=vtype Then tidx=i:Exit For Next wtch(index).typ=tidx wtch(index).psk=-4 wtch(index).vnb=1 'only basic type or pointer wtch(index).idx=pidx wtch(index).pnt=ValInt(Right(wname(index),1)) wtch(index).tad=0 'unknown address wtch(index).vnm(vnb)=vname wtch(index).var=0 'not an array wtch(index).vty(vnb)=vtype wtch(index).tvl=Tree_AddItem(NULL,"", 0, tviewwch) wtch(index).lbl=pname+"/"+vname+" <"+String(wtch(index).pnt,"*")+" "+udt(tidx).nm+">=Dll not loaded" wtchcpt+=1 index+=1 Continue While EndIf EndIf If vidx=-1 Then 'local For i As Integer = bg To ed If vrb(i).nm=vname AndAlso udt(vrb(i).typ).nm=vtype AndAlso vrb(i).arr=0 Then vidx=i tidx=vrb(i).typ ispnt=vrb(i).pt Exit For End If Next EndIf If vidx=-1 Then 'var has been removed fb_message("Applying watched variables","<"+vname+"> removed, canceled",MB_SYSTEMMODAL) index+=1 Continue While End If 'store value for var_search wtch(index).vnm(vnb)=vname wtch(index).var=0 wtch(index).vty(vnb)=vtype varb=vidx 'check component q=p+1 p=InStr(q,wname(index),",") While p vidx=-1 vname=Mid(wname(index),q,p-q) q=p+1 p=InStr(q,wname(index),"/") vtype=Mid(wname(index),q,p-q) For i As Integer =udt(tidx).lb To udt(tidx).ub With cudt(i) If .nm=vname AndAlso udt(.typ).nm=vtype AndAlso .arr=0 Then vidx=i:tidx=.typ ispnt=cudt(i).pt Exit For End If End With Next If vidx=-1 Then 'udt has been removed fb_message("Applying watched variables","udt <"+vname+"> removed, canceled") index+=1 Continue While,While End If vnb+=1 wtch(index).vnm(vnb)=vname wtch(index).vty(vnb)=vtype If tidx<=TYPESTD Then Exit While '20/08/215 q=p+1 p=InStr(q,wname(index),",") Wend tad=ValInt(Mid(wname(index),q,1)) 'tad q+=2 If ispnt<>ValInt(Mid(wname(index),q,1)) Then 'pnt 'pointer doesn't match fb_message("Applying watched variables",Left(wname(index),Len(wname(index))-2)+" not a pointer or pointer, canceled") index+=1 Continue While EndIf wtch(index).tvl=Tree_AddItem(NULL,"", 0, tviewwch) wtch(index).lbl=proc(pidx).nm+"/"+vname+" <"+String(ispnt,"*")+" "+udt(tidx).nm+">=LOCAL NON-EXISTENT" wtch(index).typ=tidx wtch(index).psk=-4 wtch(index).vnb=vnb wtch(index).idx=pidx wtch(index).pnt=ispnt wtch(index).tad=tad wtchcpt+=1 index+=1 Wend If wtchcpt Then menu_enable End Sub private sub watch_sav()'save watched 'example main/TUTU,TTEST/B,TTITI/C,Integer/pnt '= PROC main,tutu type ttest,B type ttiti, C type integer, nb pointer Dim As Integer begb,Endb,stepb Dim As String text For i As Integer =0 To WTCHMAX If wtch(i).psk=-1 OrElse wtch(i).psk=-2 OrElse wtch(i).Var<>0 Then 'not used or memory not saved or array text="" Else 'dll, more than one level and not a basic type on not a pointer ? If wtch(i).idx=0 AndAlso wtch(i).vnb>1 AndAlso wtch(i).typ>TYPESTD AndAlso wtch(i).pnt=0 Then '20/08/2015 text="" Else If wtch(i).idx=0 Then 'shared in dll text=Left( wtch(i).lbl , InStr( wtch(i).lbl ,"/") ) 'dll name 'watched used or saved previously but not used this time (psk= -3 or 4) Else text=proc(wtch(i).idx).nm+"/" 'proc name End If 'if -4 order of storage is different than -3 so inverse stepping If wtch(i).psk=-4 Then begb=1:Endb=wtch(i).vnb:Stepb=1 Else begb=wtch(i).vnb:Endb=1:Stepb=-1 For j As Integer =begb To Endb Step Stepb '10 levels max text+=wtch(i).vnm(j)+","+wtch(i).vty(j)+"/" 'name type Next text+=Str(wtch(i).tad)+"/"+Str(wtch(i).pnt) EndIf EndIf If text="/0/0" Then text="" wtchexe(0,i)=text Next End Sub private sub watch_addtr wtchnew=-1 If var_find2(tviewvar)<>-1 Then watch_set() If wtchnew<>-1 Then watch_trace(wtchnew) EndIf End Sub private sub brkv_set(a As Integer) 'breakon variable Dim As Integer t,p Dim Title As String, j As UInteger,ztxt As ZString*301,tvi As TVITEM If a=0 Then 'cancel break brkv.adr=0 setWindowText(brkvhnd,"Break on var") menu_chg(menuvar,idvarbrk,"Break on var") Exit Sub ElseIf a=1 Then 'new If var_find2(tviewvar)=-1 Then Exit Sub 'search index variable under cursor 'search master variable t=varfind.Ty p=varfind.pt If p Then t=8 If t>8 AndAlso p=0 AndAlso t<>4 AndAlso t<>13 AndAlso t<>14 Then fb_message("Break on var selection error","Only [unsigned] Byte, Short, integer or z/f/string") Exit Sub End If brkv2.typ=t 'change in brkv_box if pointed value brkv2.adr=varfind.ad 'idem brkv2.vst="" 'idem brkv2.tst=1 'type of test brkv2.ivr=varfind.iv ' if dyn array store real adr If Cast(Integer,vrb(varfind.pr).arr)=-1 Then ReadProcessMemory(dbghand,Cast(LPCVOID,vrr(varfind.iv).ini),@brkv2.arr,4,0) Else brkv2.arr=0 End If If vrb(varfind.pr).mem=3 Then brkv2.psk=-2 'static Else For j As UInteger = 1 To procrnb 'find proc to delete watching If varfind.iv>=procr(j).vr And varfind.iv (0, 0, 4, 8) Dim As single scalex ,scaley Dim As String txt Dim As WString * 300 wtxt static As HWND hedit,updown static As Long pschar,strglg,x1,x2 '24/04/2015 Dim ztxt As ZString*10 Dim As Byte buffer(RECUPMAX-1) 'get x chars Dim As UInteger adr Select Case Msg Case WM_INITDIALOG 'All of your controls are created here in the same MapDialogRect (hwnd,@rc) ScaleX = rc.right/4 ScaleY = rc.bottom/8 fb_ModStyle(hwnd,0,WS_EX_NOPARENTNOTIFY,1) 'search the lenght of the string Select Case varfind.ty Case 13 'String ReadProcessMemory(dbghand,Cast(LPCVOID,varfind.ad+SizeOf(Integer)),@strglg,SizeOf(Integer),0) 'directly lenght of string 25/07/2015 64bit Clear buffer(0),0,AFFMAX2+2 'clear buffer ReadProcessMemory(dbghand,Cast(LPCVOID,varfind.ad),@adr,4,0)'address of string ReadProcessMemory(dbghand,Cast(LPCVOID,adr),@buffer(0),AFFMAX2+1,0) 'value max AFFAMX2+1 chars or less txt=*Cast(ZString Ptr,@buffer(0)) Case 4,14 'ZString (4) fstring (14) adr=varfind.ad strglg=0 While 1 'filling buffer ReadProcessMemory(dbghand,Cast(LPCVOID,adr),@buffer(0),RECUPMAX,0) 'searching zero For i As Long =0 To RECUPMAX-1 If buffer(i)=0 Then strglg+=i:Exit While Next strglg+=RECUPMAX adr+=RECUPMAX Wend Clear buffer(0),0,AFFMAX2+2 'clear buffer ReadProcessMemory(dbghand,Cast(LPCVOID,varfind.ad),@buffer(0),AFFMAX2+1,0) 'value max AFFAMX2+1 chars or less txt=*Cast(ZString Ptr,@buffer(0)) Case 6 'wString (6 same ushort, 2 bytes by char) adr=varfind.ad strglg=0 While 1 'filling buffer ReadProcessMemory(dbghand,Cast(LPCVOID,adr),@buffer(0),RECUPMAX,0) 'searching zero For i As Long =0 To RECUPMAX-1 Step 2 'FOR LINUX set 4 instead 2 If buffer(i)=0 Then strglg+=i/2:Exit While Next strglg+=RECUPMAX/2 adr+=RECUPMAX Wend Clear buffer(0),0,(AFFMAX2+2)*2 'clear buffer ReadProcessMemory(dbghand,Cast(LPCVOID,varfind.ad),@buffer(0),(AFFMAX2+1)*2,0) 'value max AFFAMX2+1 chars or less wtxt=*Cast(WString Ptr,@buffer(0)) Case Else fb_message("Showing char at position x","Error on string type="+Str(varfind.ty)) End Select x1=1 If strglg>",hWnd,1004,60*scalex, 34*scaley, 36*scalex, 12*scaley) Case WM_COMMAND Select Case LoWord(wparam) Case 1000,1001,1002,1003,1004 'buttons Select Case LoWord(wparam) Case 1000 'apply 'get info GetWindowText(Cast(hwnd,SendMessage(updown,UDM_GETBUDDY,0,0)),ztxt,9) pschar=ValInt(ztxt) Case 1001 'first pschar=1 Case 1002 'last pschar=strglg Case 1003 '<< pschar-=AFFMAX Case 1004 '>> pschar+=AFFMAX End Select If pschar>strglg Then 'number too high pschar=strglg ElseIf pschar<1 Then 'number too low pschar=1 End If If strglg>AFFMAX2 Then ' 2 x AFFMAX chars If pschar-AFFMAX<1 Then x1=1 Else x1=pschar-AFFMAX x2=x1+AFFMAX2 If x2>strglg Then x2=strglg:x1=x2-AFFMAX2 EndIf SendMessage(updown,UDM_SETRANGE32,x1,x2) SendMessage(updown,UDM_SETPOS32,0,pschar) 'retrieve part of string Select Case varfind.ty Case 13 'String Clear buffer(0),0,AFFMAX2+2 'clear buffer ReadProcessMemory(dbghand,Cast(LPCVOID,varfind.ad),@adr,4,0)'address of string adr+=x1-1 ReadProcessMemory(dbghand,Cast(LPCVOID,adr),@buffer(0),AFFMAX2+1,0) 'value max AFFAMX2+1 chars or less txt=*Cast(ZString Ptr,@buffer(0)) SetWindowText(hedit,txt) Case 4,14 'ZString (4) fstring (14) adr=varfind.ad+x1-1 Clear buffer(0),0,AFFMAX2+2 'clear buffer ReadProcessMemory(dbghand,Cast(LPCVOID,adr),@buffer(0),AFFMAX2+1,0) 'value max AFFAMX2+1 chars or less txt=*Cast(ZString Ptr,@buffer(0)) SetWindowText(hedit,txt) Case 6 'wstring adr=varfind.ad+(x1-1)*2 Clear buffer(0),0,(AFFMAX2+2)*2 'clear buffer ReadProcessMemory(dbghand,Cast(LPCVOID,adr),@buffer(0),(AFFMAX2+1)*2,0) 'value max AFFAMX2+1 chars or less wtxt=*Cast(WString Ptr,@buffer(0)) SetWindowTextw(hedit,wtxt) Case Else fb_message("Showing char at position x","Error on string type") End Select sendmessage(hedit,EM_SETSEL,pschar-x1,pschar-x1+1) 'zero based setfocus(hedit) End Select Case WM_VSCROLL,WM_HSCROLL pschar=SendMessage(updown,UDM_GETPOS32,0,0) sendmessage(hedit,EM_SETSEL,pschar-x1,pschar-x1+1) 'zero based setfocus(hedit) Case WM_CLOSE enddialog(hwnd,0) Return 0 End Select End Function private sub char_sh(tv As HWND) '03/11/2014 If var_find2(tv)=-1 Then Exit Sub 'search index variable under cursor If varfind.ty<>4 And varfind.ty<>13 And varfind.ty<>14 And varfind.ty <>6 Then 'Or ty<>15 fb_message("Show string error","Select only a (zw)string variable") Exit Sub End If fb_MDialog(@char_box,"Show character at position n for : "+varfind.nm,windmain,283,25,325,60) End Sub private sub string_sh(tv As HWND) If var_find2(tv)=-1 Then Exit Sub 'search index variable under cursor If varfind.ty<>4 And varfind.ty<>13 And varfind.ty<>14 And varfind.ty <>6 Then 'or ty<>15 fb_message("Show string error","Select only a string variable") Exit Sub End If stringadr=varfind.ad If varfind.pt Then ReadProcessMemory(dbghand,Cast(LPCVOID,stringadr),@stringadr,SizeOf(Integer),0) 'string ptr 27/07/2015 64bit If varfind.pt=2 Then ReadProcessMemory(dbghand,Cast(LPCVOID,stringadr),@stringadr,SizeOf(Integer),0) 'if two levels EndIf If varfind.ty <>6 Then If varfind.ty=13 Then 'string ReadProcessMemory(dbghand,Cast(LPCVOID,stringadr),@stringadr,SizeOf(Integer),0)'string address End If If helpbx=0 Then helptyp=4:fb_Dialog(@help_box,"String : "+varfind.nm+" (To change value use dump)" ,windmain,2,2,400,260) Else If helpbx=0 Then helptyp=5:fb_Dialog(@help_box,"WString (ushort) : "+varfind.nm+" (To change value use dump)" ,windmain,2,2,400,250) EndIf End Sub '========================================== private sub zstringbyte_exchange() 'exchange type between zstring and array of ubyte Dim As Integer i,typ i=var_find() 'search index variable under cursor If i=0 Then Exit Sub If i>0 Then 'var typ=vrb(vrr(i).vr).typ If typ=3 And vrb(vrr(i).vr).arr=0 Then typ=9 'not an array of ubytes --> error Else typ=cudt(Abs(vrr(Abs(i)).vr)).typ If typ=3 And cudt(Abs(vrr(Abs(i)).vr)).arr=0 Then typ=9 'not an array of ubytes --> error End If If typ<>3 And typ<>4 Then '(byte / zstring fb_message("Change ubyte <> zstring error","Select only a ubyte array or zstring variable") Exit Sub End If If Typ=3 Then Typ=4 Else Typ=3 If i>0 Then vrb(vrr(i).vr).typ=typ Else cudt(Abs(vrr(Abs(i)).vr)).typ=typ EndIf var_sh() 'display update End Sub '========================================== private sub var_dump(tv As HWND,ptd As Long =0) 'dump variable '28/11/2014 If var_find2(tv)=-1 Then Exit Sub 'search index variable under cursor dumpadr=varfind.ad If ptd Then 'dumpin pointed data If varfind.pt=0 Then fb_message("Dumping pointed data","The selected variable is not a pointer"):Exit Sub ReadProcessMemory(dbghand,Cast(LPCVOID,dumpadr),@dumpadr,4,0) EndIf If udt(varfind.ty).en Then lvtyp=1 'if enum then as integer Else lvtyp=varfind.ty End If If varfind.pt Then lvtyp=8 Else Select Case lvtyp Case 13 'string lvtyp=2 'default for string ReadProcessMemory(dbghand,Cast(LPCVOID,dumpadr),@dumpadr,4,0)'string address Case 4,14 'f or zstring lvtyp=2 Case Is>TYPESTD '20/08/2015 lvtyp=8 'default for pudt and any End Select End If dump_set(listview1) dump_sh() End Sub '====================================== private sub dump_sh() '24/11/2014 Dim i As Integer,j As Integer,tmp As String,lvi As LVITEM Dim buf(16) As UByte,r As Integer,ad As UInteger Dim ascii As String Dim ptrs As pointeurs Dim As Long errorformat 'delete all items sendmessage(listview1,LVM_DELETEALLITEMS,0,0) ad=dumpadr For j=1 To dumplig 'put address lvI.mask = LVIF_TEXT lvi.iitem = j-1 'index line lvi.isubitem = 0 'index column tmp=Str(ad) lvi.pszText = StrPtr(tmp) sendmessage(listview1,LVM_INSERTITEM,0,Cast(LPARAM,@lvi)) 'handle,adr start read,adr put read,nb to read,nb read ReadProcessMemory(dbghand,Cast(LPCVOID,ad),@buf(0),16,@r) ad+=r ptrs.pxxx=@buf(0) For i=1 To lvnbcol lvi.isubitem = i Select Case lvtyp+dumpdec Case 2,16,66 'byte/dec/sng - boolean hex or dec 20/08/2015 boolean tmp=Str(*ptrs.pbyte) lvi.pszText = StrPtr(tmp) ptrs.pbyte+=1 Case 3 'byte/dec/usng tmp=Str(*ptrs.pubyte) lvi.pszText = StrPtr(tmp) ptrs.pubyte+=1 Case 5 'short/dec/sng tmp=Str(*ptrs.pshort) lvi.pszText = StrPtr(tmp) ptrs.pshort+=1 Case 6 'short/dec/usng tmp=Str(*ptrs.pushort) lvi.pszText = StrPtr(tmp) ptrs.pushort+=1 Case 1 'integer/dec/sng tmp=Str(*ptrs.pinteger) lvi.pszText = StrPtr(tmp) ptrs.pinteger+=1 Case 7,8 'integer/dec/usng tmp=Str(*ptrs.puinteger) lvi.pszText = StrPtr(tmp) ptrs.puinteger+=1 Case 9 'longinteger/dec/sng tmp=Str(*ptrs.plinteger) lvi.pszText = StrPtr(tmp) ptrs.plinteger+=1 Case 10 'longinteger/dec/usng tmp=Str(*ptrs.pulinteger) lvi.pszText = StrPtr(tmp) ptrs.pulinteger+=1 Case 11 'single tmp=Str(*ptrs.psingle) lvi.pszText = StrPtr(tmp) ptrs.psingle+=1 Case 12 'double tmp=Str(*ptrs.pdouble) lvi.pszText = StrPtr(tmp) ptrs.pdouble+=1 Case 52,53 'byte/hex tmp=Right("0"+Hex(*ptrs.pbyte),2) lvi.pszText = StrPtr(tmp) ptrs.pbyte+=1 Case 55,56 'short/hex tmp=Right("000"+Hex(*ptrs.pshort),4) lvi.pszText = StrPtr(tmp) ptrs.pshort+=1 Case 51,58 'integer/hex tmp=Right("0000000"+Hex(*ptrs.pinteger),8) lvi.pszText = StrPtr(tmp) ptrs.pinteger+=1 Case 59,60 'longinteger/hex tmp=Right("000000000000000"+Hex(*ptrs.plinteger),16) lvi.pszText = StrPtr(tmp) ptrs.pulinteger+=1 Case Else lvi.pszText = StrPtr("Error") errorformat=1:Exit for End Select sendmessage(listview1,LVM_SETITEMTEXT,j-1,Cast(LPARAM,@lvi)) 'sendmessage(listview1,LVM_SETCOLUMNWIDTH,lvnbcol,LVSCW_AUTOSIZE) Next ascii="" For i=1 To 16 If buf(i-1)>31 Then ascii+=Chr(buf(i-1)) Else ascii+="." End If Next lvi.isubitem = lvnbcol+1 lvi.pszText = StrPtr(ascii) sendmessage(listview1,LVM_SETITEMTEXT,j-1,Cast(LPARAM,@lvi)) Next If errorformat Then fb_message("Error format","Impossible to display single or double in hex"+Chr(13)+"Retry with another format") '24/11/2014 End Sub private sub dump_copy Dim lvi As LVITEM,tmp As ZString *25 Dim As hwnd hedit=fb_edit("",windmain,1234,0,0,0,0,0,ES_MULTILINE Or ES_WANTRETURN) Dim As String text,textln Dim As Long sz lvI.mask = LVIF_TEXT lvi.pszText = @tmp lvi.cchtextmax=24 Select Case lvnbcol Case 16 sz=4 Case 8 sz=6 Case 4 sz=11 Case 2 sz=23 End Select If copycol<>-99 Then 'for one cell lvi.iitem = copybeg lvi.isubitem = copycol SendMessage(listview1,LVM_GETITEM,0,Cast(LPARAM,@lvi)) text=Str(dumpadr+copybeg*16+(copycol-1)*16/lvnbcol)+" = "+tmp Else For i As Long = copybeg To copyend lvi.iitem = i lvi.isubitem = 0 SendMessage(listview1,LVM_GETITEM,0,Cast(LPARAM,@lvi)) textln+=Space(15-Len(tmp))+tmp+" = " For j As Long = 1 To lvnbcol lvi.isubitem =j SendMessage(listview1,LVM_GETITEM,0,Cast(LPARAM,@lvi)) textln+=Space(sz-Len(tmp))+tmp Next lvi.isubitem =lvnbcol+1 SendMessage(listview1,LVM_GETITEM,0,Cast(LPARAM,@lvi)) text+=textln+" "+tmp+Chr(13)+Chr(10) 'skip next line textln="" Next EndIf SetWindowText(hedit,text) SendMessage(hedit,EM_SETSEL,0,-1) SendMessage(hedit,WM_COPY,0,0) 'copy text in the clipboard DestroyWindow (hedit) End Sub private sub dump_sel(lvp As NMITEMACTIVATE Ptr)'23/11/2014 If hdumpbx=0 Then fb_Dialog(@dump_box,"Manage dump",windmain,283,25,120,150) End If If lvp->iitem=-1 Then copybeg=0 copyend=dumplig-1 SendMessage(hdumpbx, WM_SETTEXT, 201, 0) SendMessage(hdumpbx, WM_SETTEXT, 202, 0) ElseIf lvp->isubitem=0 OrElse lvp->isubitem=lvnbcol+1 Then 'addresse or ascii zone If copybeg=-99 Then copybeg=lvp->iitem copyend=copybeg SendMessage(hdumpbx, WM_SETTEXT, 201, 0) Else copyend=lvp->iitem If copyendiitem copyend=copybeg copycol=lvp->isubitem SendMessage(hdumpbx, WM_SETTEXT, 201, 0) SendMessage(hdumpbx, WM_SETTEXT, 202, 0) EndIf End Sub private sub dump_spe(lvp As NMITEMACTIVATE Ptr)'27/11/2014 If lvp->isubitem>lvnbcol+1 orelse lvp->isubitem=0 Then fb_message("Special address","Not possible on this column, only cell data"):Exit Sub varfind.ad=dumpadr+lvp->iitem*16+(lvp->isubitem-1)*16/lvnbcol varfind.nm="memory "+Str(varfind.ad) If hdumpbx=0 Then fb_Dialog(@dump_box,"Manage dump",windmain,283,25,130,150)'open dialog box sendmessage(hdumpbx,WM_COMMAND,891,0)'activate command in dump_box End Sub '==================================== private sub dump_update(lvp As NMITEMACTIVATE Ptr)'NMLISTVIEW 20/11/2014 Dim lvi As LVITEM,tmp As ZString *25,lvu As valeurs lvI.mask = LVIF_TEXT lvi.iitem = lvp->iitem'0 'first line lvi.isubitem = lvp->isubitem 'index column lvi.pszText = @tmp lvi.cchtextmax=24 SendMessage(listview1,LVM_GETITEM,0,Cast(LPARAM,@lvi)) 'retrieve text lvi.mask = LVIS_SELECTED lvi.state = 0 SendMessage(listview1,LVM_SETITEMSTATE,lvp->iitem,Cast(LPARAM,@lvi))'deselection '-1 all lvi.mask = LVIS_DROPHILITED Or LVIS_FOCUSED lvi.state = 0 SendMessage(listview1,LVM_SETITEMSTATE,lvp->iitem,Cast(LPARAM,@lvi))'deselection '-1 all If lvp->uKeyFlags=1 Then dump_spe(lvp):Exit Sub If lvp->uKeyFlags=4 OrElse (lvp->uKeyFlags<>2 AndAlso lvp->isubitem=0) Then dump_sel(lvp):Exit Sub 'handle copy to clipboard (first column or shift) If lvp->isubitem>=lvnbcol+1 Then fb_message("Change value error","Not possible with this column"):Exit Sub If lvp->uKeyFlags=2 Then 'changing adr dump by the value in the selected case (click + ctrl) If lvp->isubitem<>0 AndAlso lvtyp<>1 andalso lvtyp<>7 andalso lvtyp<>8 Then fb_message("Changing address for memory dump","Only possible with integer and uinteger"):Exit Sub dumpadr=ValUInt(tmp) dump_sh() Exit Sub EndIf If lvp->isubitem<1 Then fb_message("Change value error","Not possible with this column"):Exit Sub 'editing value inputval=tmp inputtyp=lvtyp 'fb_MDialog(@input_box,"Change value ["+tmp+"]",windmain,283,25,150,30) fb_MDialog(@input_box,"Changing value in memory : Adr="+Str(dumpadr+(lvp->iitem)*16+(lvp->isubitem-1)*16\lvnbcol)+" (Line="+Str(lvp->iitem+1)+" / Column="+Str(lvp->isubitem)+")",windmain,283,25,200,30) If inputval<>"" Then 'fb_message("Change value in memory dump","Adr="+Str(dumpadr+(lvp->iitem)*16+(lvp->isubitem-1)*16\lvnbcol)+Chr(13)+"Line="+Str(lvp->iitem+1)+" / Column="+Str(lvp->isubitem)+Chr(13)+"New value = "+inputval) Select Case lvtyp Case 2 lvu.vbyte=ValInt(inputval) Case 3 lvu.vubyte=ValUInt(inputval) Case 5 lvu.vshort=ValInt(inputval) Case 6 lvu.vushort=ValUInt(inputval) Case 1 lvu.vinteger=ValInt(inputval) Case 7 #Ifdef __FB_64BIT__ lvu.vlinteger=ValULng(inputval) #Else lvu.vuinteger=ValUInt(inputval) #EndIf Case 8 lvu.vuinteger=ValUInt(inputval) Case 9 lvu.vlinteger=ValLng(inputval) Case 10 lvu.vulinteger=ValULng(inputval) Case 11 lvu.vsingle=Val(inputval) Case 12 lvu.vdouble=Val(inputval) Case 16 '20/08/2015 boolean lvu.vubyte=ValInt(inputval) If lvu.vubyte>1 Then 'boolean value 0 or 1 fb_message("Changing boolean value","Authorized value only 0 or -1") Exit Sub EndIf End Select writeprocessmemory(dbghand,Cast(LPVOID,dumpadr+(lvp->iitem)*16+(lvp->isubitem-1)*16\lvnbcol),@lvu,16\lvnbcol,0) var_sh() dump_sh() End If End Sub '==================================== private function settings_box(ByVal hWnd As HWND,ByVal Msg As UInteger,ByVal wparam As Integer,ByVal lParam As Integer) As Integer Dim txt As String *300 Dim rc As RECT => (0, 0, 4, 8) Dim As Single scalex,scaley Dim As Integer flaglogold,clrnew,tempo Static As HWND hedit1,hedit2,hedit3,hedit4,hedit5,hcomb01,rich,hsbox,hcbox,habox Static As HWND checkbox1,checkbox2,checkbox3,radio(7),hfont8,hfont10,hfont12,checkttp,fontbut,hlkbut Static As Integer shcutindex,shcutkey Dim As MSGFILTER Ptr pmsgfilter Select Case Msg Case WM_INITDIALOG 'All controls are created here MapDialogRect (hwnd,@rc) ScaleX = rc.right/4 ScaleY = rc.bottom/8 fb_message("Values for converting map/pixel","baseunits="+hex(GetDialogBaseUnits)+Chr(13)+"right="+Str(rc.right)+" "+"bottom="+Str(rc.bottom)+Chr(13)+"scale x y ="+Str(scalex)+" "+Str(scaley)) fb_ModStyle(hwnd,0,WS_EX_NOPARENTNOTIFY,1) fb_Group("Customize shortcuts : select a combination, use ""A"" button to check and apply, ""Del"" key To delete",hwnd,2003,6*scalex,2*scaley,252*scalex,20*scaley) hsbox=fb_Checkbox("Shift",hwnd,2004,140*scalex,9*scaley,20*scalex,10*scaley) hcbox=fb_Checkbox("Ctrl",hwnd,2005,165*scalex,9*scaley,20*scalex,10*scaley) habox=fb_Checkbox("Alt",hwnd,2006,190*scalex,9*scaley,18*scalex,10*scaley) hcomb01=fb_combobox (hWnd,2007,8*scalex,9*scaley,130*scalex,200*scaley) rich=fb_RichEdit("",hWnd,2008,218*scalex,9*scaley,28*scalex,10*scaley) SendMessage(rich,EM_SETEVENTMASK,0,ENM_KEYEVENTS Or ENM_MOUSEEVENTS) fb_button("A",hWnd,2009,248*scalex, 9*scaley, 8*scalex, 10*scaley) shcutkey=shcut(shcutindex).sccur And &hFFF shcut_display(shcutindex,hcbox,habox,hsbox,rich) For i As Integer =0 To shcutnb-1 txt=menu_gettxt(shcut(i).scmenu,shcut(i).scidnt) sendmessage(hcomb01,CB_ADDSTRING,0,Cast(LPARAM,StrPtr(txt))) Next sendmessage(hcomb01,CB_SETCURSEL,shcutindex,0) fb_Group("Cmdline, parameters for compiling (-g added by default) and for the debuggee when debugging",hwnd,2002,6*scalex,69*scaley,252*scalex,45*scaley) fb_Label("CMPL",hwnd,100,13*scalex,81*scaley,18*scalex,9*scaley,SS_LEFT) ''fb_htooltip=0 'fb_CreateTooltips(fb_Label("CMPL",hwnd,100,13*scalex,81*scaley,18*scalex,9*scaley,SS_LEFT), "Compilation", "Test",0) hEdit1 = fb_edit ("",hWnd,101,34*scalex,81*scaley,201*scalex,9*scaley) fb_ModStyle(hedit1,0,WS_EX_NOPARENTNOTIFY,1) fb_ModStyle(hedit1,0,WS_VSCROLL,0) setwindowtext(hedit1,cmdlfbc) fb_Label("DBG",hwnd,100,13*scalex,93*scaley,18*scalex,9*scaley,SS_LEFT) hEdit2 = fb_edit ("",hWnd,102,34*scalex,93*scaley,201*scalex,9*scaley) fb_ModStyle(hedit2,0,WS_EX_NOPARENTNOTIFY,1) fb_ModStyle(hedit2,0,WS_VSCROLL,0) setwindowtext(hedit2,cmdexe(0)) fb_Group("Files location, disc:\path\name[.exe]",hwnd,2001,6*scalex,23*scaley,252*scalex,42*scaley) fb_Label("FBC",hwnd,150,13*scalex,33*scaley,18*scalex,9*scaley,SS_LEFT) hEdit3 = fb_edit ("",hWnd,151,33*scalex,33*scaley,201*scalex,9*scaley) fb_button("...",hWnd,152,240*scalex, 33*scaley, 12*scalex, 9*scaley) fb_ModStyle(hedit3,0,WS_EX_NOPARENTNOTIFY,1) fb_ModStyle(hedit3,0,WS_VSCROLL,0) setwindowtext(hedit3,fbcexe) fb_Label("IDE",hwnd,155,13*scalex,45*scaley,18*scalex,9*scaley,SS_LEFT) hEdit4 = fb_edit ("",hWnd,156,33*scalex,45*scaley,201*scalex,9*scaley) fb_button("...",hWnd,157,240*scalex, 45*scaley, 12*scalex, 9*scaley) fb_ModStyle(hedit4,0,WS_EX_NOPARENTNOTIFY,1) fb_ModStyle(hedit4,0,WS_VSCROLL,0) setwindowtext(hedit4,ideexe) Dim As HWND loggroup=fb_Group("Advanced log (FBDebugger path\dbg_log_file.txt)",hwnd,200,6*scalex,123*scaley,226*scalex,36*scaley) radio(1)=fb_radio("Screen",loggroup,201,10*scalex,8*scaley,35*scalex,15*scaley) radio(2)=fb_radio("File ",loggroup,202,50*scalex,8*scaley,35*scalex,15*scaley) radio(3)=fb_radio("Screen/file",loggroup,203,85*scalex,8*scaley,35*scalex,15*scaley) radio(0)=fb_radio("None",loggroup,204,130*scalex,8*scaley,35*scalex,15*scaley) sendmessage(radio(flaglog),BM_SETCHECK,BST_CHECKED ,0) checkbox1=fb_Checkbox("Trace proc On",hwnd,210,175*scalex,130*scaley,55*scalex,15*scaley) If flagtrace Then SendMessage(checkbox1,BM_SETCHECK,BST_CHECKED ,0) checkbox3=fb_Checkbox("Trace line On",hwnd,211,175*scalex,142*scaley,55*scalex,15*scaley) If flagtrace And 2 Then SendMessage(checkbox3,BM_SETCHECK,BST_CHECKED ,0) fb_Label("10000> Delay auto (ms) >50",hwnd,170,6*scalex,162*scaley,75*scalex,9*scaley,SS_LEFT) hEdit5 = fb_edit ("200",hWnd,171,83*scalex,162*scaley,25*scalex,9*scaley) fb_ModStyle(hedit5,0,WS_VSCROLL Or ES_NUMBER,0) setwindowtext(hedit5,Str(autostep)) checkbox2=fb_Checkbox("Verbose mode On (proc/var)",hwnd,220,130*scalex,162*scaley,85*scalex,9*scaley) If flagverbose=TRUE Then sendmessage(checkbox2,BM_SETCHECK,BST_CHECKED ,0) 'Dim As HWND fontgroup=fb_Group("Font size",hwnd,230,240*scalex,123*scaley,75*scalex,20*scaley) 'hfont8=fb_radio("8 ",fontgroup,231,3*scalex,6*scaley,23*scalex,12*scaley) 'hfont10=fb_radio("10",fontgroup,232,26*scalex,6*scaley,23*scalex,12*scaley) 'hfont12=fb_radio("12",fontgroup,233,49*scalex,6*scaley,23*scalex,12*scaley) 'If fontsize=KSIZE8 Then ' sendmessage(hfont8,BM_SETCHECK,BST_CHECKED ,0) 'ElseIf fontsize=KSIZE10 Then ' sendmessage(hfont10,BM_SETCHECK,BST_CHECKED ,0) 'Else ' sendmessage(hfont12,BM_SETCHECK,BST_CHECKED ,0) 'EndIf fontbut=fb_button("Change font"+Chr(13)+fontname+"/"+Str(fontsize),hWnd,234,240*scalex, 126*scaley, 60*scalex, 20*scaley) checkttp=fb_Checkbox("Activated tooltips",hwnd,240,240*scalex,148*scaley,55*scalex,15*scaley) If flagtooltip=TRUE Then sendmessage(checkttp,BM_SETCHECK,BST_CHECKED ,0) Dim As HWND dspgroup=fb_Group("Position current source line,x lines from top and x lines before bottom",hwnd,250,6*scalex,175*scaley,170*scalex,20*scaley) radio(4)=fb_radio("3 lines ", dspgroup,251, 10*scalex,7*scaley,35*scalex,10*scaley) radio(5)=fb_radio("5 lines", dspgroup,252, 50*scalex,7*scaley,39*scalex,10*scaley) 'trick value of dspofs = 2 or 4, /2 +3 --> 4 or 5 !!! sendmessage(radio(dspofs/2+3),BM_SETCHECK,BST_CHECKED ,0) fb_button("Ok",hWnd,103,240*scalex, 171*scaley, 35*scalex, 15*scaley) fb_button("Cancel",hWnd, 104, 283*scalex, 171*scaley, 35*scalex, 15*scaley) ' 100 / 83 / 66 / 49 / 32 fb_button("Color Bkgrd",hWnd, 105, 283*scalex, 32*scaley, 35*scalex, 15*scaley) If hgltflag=TRUE Then txt="No HL keywords" Else txt="HL keywords" hlkbut=fb_button(txt,hWnd, 106, 283*scalex, 100*scaley, 35*scalex, 15*scaley) fb_button("Color keywords",hWnd, 107, 283*scalex, 83*scaley, 35*scalex, 15*scaley) fb_button("Color current line",hWnd, 108, 283*scalex, 49*scaley, 35*scalex, 15*scaley) fb_button("Color tmp breakpoint",hWnd, 109, 263*scalex, 66*scaley, 35*scalex, 15*scaley) fb_button("Color per breakpoint",hWnd, 110, 300*scalex, 66*scaley, 35*scalex, 15*scaley) Case WM_COMMAND Select Case LoWord(wparam) Case 152 'select new location for FBC txt=fb_GetFileName("Select Exe file","FBC *.exe|fbc.exe||",0,0,0,"") If txt<>"" Then setwindowtext(hedit3,txt) Case 157 'select new location for IDE txt=fb_GetFileName("Select IDE file","*.exe|*.exe||",0,0,0,"") If txt<>"" Then setwindowtext(hedit4,txt) Case 210 If SendMessage(Checkbox1, BM_GETCHECK,0,0)=BST_UNCHECKED Then SendMessage(Checkbox3, BM_SETCHECK,BST_UNCHECKED,0) EndIf Case 211 If SendMessage(Checkbox3, BM_GETCHECK,0,0)=BST_CHECKED Then SendMessage(Checkbox1, BM_SETCHECK,BST_CHECKED,0) EndIf Case 103 'Ok GetWindowText(hEdit1,txt,299) cmdlfbc=txt getwindowtext(hEdit2,txt,299) cmdexe(0)=txt GetWindowText(hEdit3,txt,299) fbcexe=txt GetWindowText(hEdit4,txt,299) ideexe=txt If SendMessage(Checkbox1, BM_GETCHECK,0,0)=BST_CHECKED Then flagtrace=1 If SendMessage(Checkbox3, BM_GETCHECK,0,0)=BST_CHECKED Then flagtrace+=2 Else flagtrace=0 EndIf If SendMessage(Checkbox2, BM_GETCHECK,0,0)=BST_CHECKED Then flagverbose=TRUE Else flagverbose=FALSE If SendMessage(Checkttp, BM_GETCHECK,0,0)=BST_CHECKED Then flagtooltip=TRUE Else flagtooltip=FALSE sendmessage (fb_hToolTip,TTM_ACTIVATE, Cast(WPARAM,flagtooltip),0) If prun Then proc_update():var_sh:proc_sh:thread_text flaglogold=flaglog For i As Integer =0 To 3 If SendMessage(radio(i), BM_GETCHECK,0,0)=BST_CHECKED Then flaglog=i:Exit For Next If flaglogold And flaglog<>flaglogold Then dbg_prt(" $$$$___CLOSE ALL___$$$$ ") 'close if needed GetWindowText(hEdit5,txt,299) 'value for auto autostep=ValInt(txt) If autostep<50 Then autostep=50 If autostep>10000 Then autostep=10000 'If SendMessage(hfont8, BM_GETCHECK,0,0)=BST_CHECKED Then ' font_change(,KSIZE8) 'ElseIf SendMessage(hfont10, BM_GETCHECK,0,0)=BST_CHECKED Then ' font_change(,KSIZE10) 'Else ' font_change(,KSIZE12) 'EndIf 'change of dspofs ? For i As Integer =1 To 2 If SendMessage(radio(i+3), BM_GETCHECK,0,0)=BST_CHECKED Then dspofs=i*2:Exit For Next enddialog(hwnd,0) Case 104 'Cancel enddialog(hwnd,0) Case 105 clrnew=color_change(clrrichedit) If clrnew<>clrrichedit Then clrrichedit=clrnew For i As Integer=0 To MAXSRC sendmessage(richedit(i),EM_SETBKGNDCOLOR,0,clrrichedit) Next EndIf Case 106 If hgltflag=TRUE Then hgltflag=FALSE txt="HL keywords" Else hgltflag=TRUE txt="No HL keywords" EndIf setwindowtext(hlkbut,txt) hglt_all Case 107 clrnew=color_change(clrkeyword) If clrnew<>clrkeyword Then clrkeyword=clrnew:hglt_all Case 108 clrnew=color_change(clrcurline) If clrnew<>clrcurline Then clrcurline=clrnew:dsp_color Case 109 clrnew=color_change(clrtmpbrk) If clrnew<>clrtmpbrk Then clrtmpbrk=clrnew:dsp_color Case 110 clrnew=color_change(clrperbrk) If clrnew<>clrperbrk Then clrperbrk=clrnew:dsp_color Case 234 If fb_FontDlg(hwnd) Then txt="Change font"+Chr(13)+fontname+"/"+Str(fontsize) setwindowtext(fontbut,txt) font_change(fontname,fontsize) EndIf Case 2009 'check if new shortcut is valid tempo=shcutkey If SendMessage(hsbox, BM_GETCHECK,0,0)=BST_CHECKED Then tempo+=VSHIFT If SendMessage(habox, BM_GETCHECK,0,0)=BST_CHECKED Then tempo+=VALT If SendMessage(hcbox, BM_GETCHECK,0,0)=BST_CHECKED Then tempo+=VCTRL If shcut_check(shcutindex,tempo) Then shcut_display(shcutindex,hcbox,habox,hsbox,rich) 'restore Else shcut(shcutindex).sccur=tempo menu_update(shcutindex) EndIf End Select If lparam=hcomb01 Then 'combobox If HiWord(wparam)=CBN_SELCHANGE Then 'change selected shortcut shcutindex=sendmessage(hcomb01,CB_GETCURSEL,0,0) 'get new index shcutkey=shcut(shcutindex).sccur And &hFFF shcut_display(shcutindex,hcbox,habox,hsbox,rich) EndIf EndIf Case wm_notify pmsgfilter=Cast(MSGFILTER Ptr,lparam) If pmsgfilter->msg=WM_KEYDOWN And pmsgfilter->nmhdr.idfrom=2008 Then If pmsgfilter->wparam=VK_DELETE Then shcut(shcutindex).sccur=0 shcutkey=0 shcut_display(shcutindex,hcbox,habox,hsbox,rich) menu_update(shcutindex) Else txt=shcut_txt(pmsgfilter->wparam,0) If txt<>"Error" Then shcutkey=pmsgfilter->wparam EndIf sendmessage(rich,WM_SETTEXT,0,Cast(LPARAM,StrPtr(txt))) EndIf EndIf Case WM_CLOSE enddialog(hwnd,0) Return 0 'not really used End Select End Function private sub font_change(fname As String="",fsize As Integer=0) If fname="" Then fname=fontname Else fontname=fname EndIf If fsize=0 Then fsize=fontsize Else fontsize=fsize EndIf 'If fontsize=fsize AndAlso fontname=fname Then Exit Sub DeleteObject(Cast(HGDIOBJ,fonthdl)) fonthdl=fb_Set_Font(fontname,fontsize) fontbold=fb_Set_Font(fontname,fontsize,FW_SEMIBOLD) SendMessage(tviewvar,WM_SETFONT,Cast(WPARAM,fonthdl),0) SendMessage(tviewprc,WM_SETFONT,Cast(WPARAM,fonthdl),0) SendMessage(tviewthd,WM_SETFONT,Cast(WPARAM,fonthdl),0) SendMessage(tviewwch,WM_SETFONT,Cast(WPARAM,fonthdl),0) For i As Integer=0 To MAXSRC SendMessage(richedit(i),WM_SETFONT,Cast(WPARAM,fontbold),0) Next If focusbx Then destroywindow(focusbx) If hgltflag=TRUE Then hglt_all dsp_sizecalc End Sub private function shcut_check(idx As Integer,value As Integer) As Integer If value=0 Then Return 0 'no need to test For i As Integer=0 To shcutnb-1 If shcut(i).sccur<>value OrElse idx=i Then Continue For fb_message("Defining New Shortcut","Combination not possible, already used by : "+menu_gettxt(shcut(i).scmenu,shcut(i).scidnt) ) Return 1 'already used Next Return 0 'possible End Function private function shcut_txt(value As Integer, full As Integer) As String Dim As Integer vkey=value And &hFFF Dim As String stempo If value=0 Then Return "" If full Then If full=1 Then stempo=Chr(9) If (value And VSHIFT) Then stempo+="Shift+" EndIf If (value And VALT) Then stempo+="Alt+" EndIf If (value And VCTRL) Then stempo+="Ctrl+" EndIf EndIf If vkey>Asc("0") AndAlso vkey=112 AndAlso vkey<=123 Then If vkey<121 Then Return stempo+"F"+Chr(vkey-&h3F) 'F12 to F9 Return stempo+"F1"+Chr(vkey-&h49)'F10 to F12 EndIf If vkey=VK_RETURN Then Return stempo+"Enter" 'return key ' add other values if needed Return "Error" End Function private sub shcut_display(idx As Integer,hcbox As hwnd,habox As hwnd,hsbox As hwnd,rich As hwnd) Dim As Integer value=shcut(idx).sccur Dim As String stempo=shcut_txt(value,0) If (value And VSHIFT) Then SendMessage(hsbox, BM_SETCHECK,BST_CHECKED,0) Else SendMessage(hsbox, BM_SETCHECK,BST_UNCHECKED,0) EndIf If (value And VALT) Then SendMessage(habox, BM_SETCHECK,BST_CHECKED,0) Else SendMessage(habox, BM_SETCHECK,BST_UNCHECKED,0) EndIf If (value And VCTRL) Then SendMessage(hcbox, BM_SETCHECK,BST_CHECKED,0) Else SendMessage(hcbox, BM_SETCHECK,BST_UNCHECKED,0) EndIf sendmessage(rich,WM_SETTEXT,0,Cast(LPARAM,StrPtr(stempo))) End Sub private sub shcut_ini(Strg As String) Static As Integer llimit 'as data are in order no need to begin each time the loop at zero Dim As Integer p=InStr(Strg,","),ident,value ident=ValInt(Left(Strg,p-1)):value=ValInt(Mid(Strg,p+1)) For i As Integer =llimit To shcutnb-1 If shcut(i).scidnt=ident Then shcut(i).sccur=value:menu_update(i) llimit=i+1:Exit Sub EndIf Next End Sub private sub menu_update(idx As Integer,s As String="") Dim As String stempo Dim As Integer itempo If s<>"" Then 'if string is given idx=ident so at first find the index in shcut For i As Integer=0 To shcutnb-1 If idx=shcut(i).scidnt Then itempo=i EndIf Next stempo=s Else itempo=idx stempo=menu_gettxt(shcut(idx).scmenu,shcut(idx).scidnt) EndIf stempo+=shcut_txt(shcut(itempo).sccur,1)'1=full text menu_chg(shcut(itempo).scmenu,shcut(itempo).scidnt,stempo) End Sub private sub bx_closing If hfindbx Then SendMessage(hfindbx,WM_CLOSE,0,0) If hdumpbx Then SendMessage(hdumpbx,WM_CLOSE,0,0) If savebx Then SendMessage(savebx,WM_CLOSE,0,0) If helpbx Then SendMessage(helpbx,WM_CLOSE,0,0) For i As Long =0 To INDEXBOXMAX ''2016/02/07 If hindexbx(i) Then SendMessage(hindexbx(i),WM_CLOSE,0,0) Next If focusbx Then SendMessage(focusbx,WM_CLOSE,0,0) If tutobx Then SendMessage(tutobx,WM_CLOSE,0,0) bcktrk_close 'same for bcktrkbx shwexp_del() 'destroy all shwexp boxes End Sub private function input_box(ByVal hWnd As HWND,ByVal Msg As UInteger,ByVal wparam As Integer,ByVal lParam As Integer) As Integer Dim rc As RECT => (0, 0, 4, 8) Dim As single scalex,scaley Dim vflag As Integer,vald As Double Static hedit1 As HWND Select Case Msg Case WM_INITDIALOG 'All of your controls are created here in the same MapDialogRect (hwnd,@rc) ScaleX = rc.right/4 ScaleY = rc.bottom/8 fb_ModStyle(hwnd,0,WS_EX_NOPARENTNOTIFY,1) ' fb_label(inputtxt,hwnd,100,2*scalex,2*scaley,150*scalex,10*scaley,SS_LEFT) hEdit1 = fb_edit("",hWnd,101,8*scalex,2*scaley,80*scalex,10*scaley) fb_ModStyle(hedit1,0,WS_EX_NOPARENTNOTIFY,1) fb_ModStyle(hedit1,,ES_MULTILINE,0) fb_ModStyle(hedit1,,WS_VSCROLL,0) fb_ModStyle(hedit1,,ES_WANTRETURN,0) setwindowtext(hedit1,inputval) setfocus(hedit1) sendmessage(hedit1,EM_SETSEL,0,-1) fb_button("Ok",hWnd,103,8*scalex, 13*scaley, 36*scalex, 10*scaley) fb_button("Cancel",hWnd, 104, 50*scalex, 13*scaley, 36*scalex, 10*scaley) setfocus(hedit1) Case WM_COMMAND Select Case LoWord(wparam) Case 103 'Ok getwindowtext(hedit1,inputval,25) vflag=1 vald=Val(inputval) Select Case inputtyp Case 2 If vald<-128 Or vald>127 Then setwindowtext(hwnd,"min -128,max 127"):vflag=0 Case 3 If vald<0 Or vald>255 Then setwindowtext(hwnd,"min 0,max 255"):vflag=0 Case 5 If vald<-32768 Or vald>32767 Then setwindowtext(hwnd,"min -32768,max 32767"):vflag=0 Case 6 If vald<0 Or vald>65535 Then setwindowtext(hwnd,"min 0,max 65535"):vflag=0 Case 1 If vald<-2147483648 Or vald>2147483648 Then setwindowtext(hwnd,"min -2147483648,max +2147483647"):vflag=0 Case 7,8 If vald<0 Or vald>4294967395 Then setwindowtext(hwnd,"min 0,max 4294967395"):vflag=0 End Select If vflag Then enddialog(hwnd,0) Case 104 'Cancel inputval="" enddialog(hwnd,0) End Select Case WM_CLOSE If vflag=0 Then inputval="" enddialog(hwnd,0) Return 0 Case WM_DESTROY End Select End Function '==================================== private function save_box(ByVal hWnd As HWND,ByVal Msg As UInteger,ByVal wparam As Integer,ByVal lParam As Integer) As Integer Dim rc As RECT => (0, 0, 4, 8) Dim As Single scalex,scaley Dim l As Integer,f As Integer,buf(MAXSRCSIZE) As Byte Select Case Msg Case WM_INITDIALOG 'All of your controls are created here in the same MapDialogRect (hwnd,@rc) ScaleX = rc.right/4 ScaleY = rc.bottom/8 fb_ModStyle(hwnd,0,WS_EX_NOPARENTNOTIFY,1) fb_Label("Select option after editing done (no backup)",hwnd,100,2*scalex,2*scaley,110*scalex,10*scaley,SS_LEFT) fb_button("Save",hWnd,103,2*scalex, 13*scaley, 36*scalex, 10*scaley) 'option only with 1 source code If sourcenb=0 Then fb_button("Save, Compile and Run",hWnd,104,40*scalex, 13*scaley, 72*scalex, 10*scaley) fb_button("Reload",hWnd, 105, 112*scalex, 13*scaley, 36*scalex, 10*scaley) fb_button("Quit",hWnd, 106, 112*scalex, 2*scaley, 36*scalex, 10*scaley) savebx=hwnd Case WM_COMMAND Select Case LoWord(wparam) Case 103 'Ok save richedit save_source destroywindow(hwnd) Case 104 save_source treat_file(dbgsrc) destroywindow(hwnd) Case 105 'reloading If FileExists(dbgsrc)=0 Then fb_message("Source "+dbgsrc,"not found, can not reload",MB_ICONERROR) Else Clear(buf(0),0,MAXSRCSIZE) f = FreeFile Open dbgsrc For Binary As #f l=Lof(f) If l>MAXSRCSIZE Then fb_message(dbgsrc,"Source too large ("+Str(l)+">"+Str(MAXSRCSIZE)+") not loaded",MB_ICONERROR) destroywindow(hwnd) Else Get #f,,buf() 'get source End If Close #f SendMessage(dbgrichedit,EM_EXLIMITTEXT,0,l+10000) 'put file size setWindowText(dbgrichedit,@buf(0)) End If destroywindow(hwnd) Case 106 'Cancel destroywindow(hwnd) End Select Case WM_CLOSE destroywindow(hwnd) Case WM_DESTROY sendmessage(dbgrichedit,EM_SETREADONLY,TRUE,0) dsp_hide(1) savebx=0 Return 0 End Select End Function '==================================== Private sub procvar_find(stext As String) 'find variable or field in proc/vat treeview Dim tvi As TVITEM,text As ZString *100 Dim As Integer hitem,temp 'get current hitem in tree hitem=sendmessage(tviewvar,TVM_GETNEXTITEM,TVGN_CARET,0) tvI.mask=TVIF_TEXT While hitem<>0 temp=SendMessage(tviewvar,TVM_GETNEXTITEM,TVGN_CHILD,hitem) 'searching child While temp=0 temp=SendMessage(tviewvar,TVM_GETNEXTITEM,TVGN_NEXT,hitem) If temp Then hitem=temp:Exit While 'sibble founded hitem=SendMessage(tviewvar,TVM_GETNEXTITEM,TVGN_PARENT,hitem) 'parent ? If hitem=0 Then hitem=sendmessage(tviewvar,TVM_GETNEXTITEM,TVGN_ROOT,0) 'no parent go to top and finish SendMessage(tviewvar,TVM_SELECTITEM,TVGN_CARET,Cast(LPARAM,hitem)) SetFocus(tviewvar) Exit sub EndIf Wend hitem=temp 'to display the founded (need to expand ???) tvI.hitem = Cast(HTREEITEM,hitem) tvI.pszText = @(text) tvI.cchTextMax = 99 sendmessage(tviewvar,TVM_GETITEM,0,Cast(LPARAM,@tvi)) If InStr(text,stext) Then SendMessage(tviewvar,TVM_SELECTITEM,TVGN_CARET,Cast(LPARAM,hitem)) SetFocus(tviewvar) Exit while EndIf Wend End Sub '==================================== Private function procvar_box(ByVal hWnd As HWND,ByVal Msg As UInteger,ByVal wparam As Integer,ByVal lParam As Integer) As Integer Dim Txt As String *300 Dim rc As RECT => (0, 0, 4, 8) Dim As single scalex,scaley Static As HWND hedit1,hbutton1 Select Case Msg Case WM_INITDIALOG 'All of your controls are created here in the same hfindbx=hwnd MapDialogRect (hwnd,@rc) ScaleX = rc.right/4 ScaleY = rc.bottom/8 fb_ModStyle(hwnd,0,WS_EX_NOPARENTNOTIFY,1) hEdit1 = fb_edit ("",hWnd,101,2*scalex,2*scaley,95*scalex,10*scaley) fb_ModStyle(hedit1,0,WS_EX_NOPARENTNOTIFY,1) fb_ModStyle(hedit1,0,WS_VSCROLL,0) setfocus(hedit1) hButton1 = fb_button("Find",hWnd,IDFNDTXUP,2*scalex, 14*scaley, 18*scalex, 10*scaley) fb_ModStyle(hbutton1,0,WS_EX_NOPARENTNOTIFY,1) Case WM_COMMAND if LoWord(wparam)=IDFNDTXUP Then 'clicked on the button GetWindowText(hEdit1,txt,299) procvar_find(txt) 'SendMessage(windmain,WM_COMMAND,makelong(IDFNDTXUP,BN_CLICKED),Cast(LPARAM,hbutton1)) EndIf Case WM_CLOSE hfindbx=0 destroywindow(hwnd) setfocus(dbgrichedit) Return 0 'not really used End Select End Function private function find_box(ByVal hWnd As HWND,ByVal Msg As UInteger,ByVal wparam As Integer,ByVal lParam As Integer) As Integer Dim Txt As String *300 Dim rc As RECT => (0, 0, 4, 8) Dim As Single scalex,scaley Static As HWND hedit1,checkcase,hbutton1 Select Case Msg Case WM_INITDIALOG 'All of your controls are created here in the same ' à tester 'SendMessage(hWnd, WM_SETICON, TRUE, _ 'Set Application Icon '(HICON)LoadImage(0,"i.ico",IMAGE_ICON,0,0,LR_LOADFROMFILE)) hfindbx=hwnd MapDialogRect (hwnd,@rc) ScaleX = rc.right/4 ScaleY = rc.bottom/8 fb_ModStyle(hwnd,0,WS_EX_NOPARENTNOTIFY,1) hEdit1 = fb_edit ("",hWnd,101,2*scalex,2*scaley,95*scalex,10*scaley) fb_ModStyle(hedit1,0,WS_EX_NOPARENTNOTIFY,1) fb_ModStyle(hedit1,0,WS_VSCROLL,0) setwindowtext(hedit1,stext) setfocus(hedit1) SendMessage(hedit1,EM_SETSEL,0,-1) hButton1 = fb_button("Up",hWnd,IDFNDTXUP,2*scalex, 14*scaley, 18*scalex, 10*scaley) fb_ModStyle(hbutton1,0,WS_EX_NOPARENTNOTIFY,1) fb_button("Dw",hWnd, IDFNDTXDW, 20*scalex, 14*scaley, 18*scalex, 10*scaley) checkcase=fb_Checkbox("Case",hwnd,IDFNDTXCS,42*scalex, 14*scaley, 25*scalex, 10*scaley) Case WM_COMMAND Select Case LoWord(wparam) Case IDFNDTXUP 'clicked the up button getwindowtext(hEdit1,txt,299) sfind=txt sendmessage(windmain,WM_COMMAND,makelong(IDFNDTXUP,BN_CLICKED),Cast(LPARAM,hbutton1)) Case IDFNDTXDW 'clicked dw button getwindowtext(hEdit1,txt,299) sfind=txt sendmessage(windmain,WM_COMMAND,makelong(IDFNDTXDW,BN_CLICKED),Cast(LPARAM,hbutton1)) Case IDFNDTXCS 'clicked case If SendMessage(Checkcase, BM_GETCHECK,0,0)=BST_CHECKED Then chkcase=4 'FR_MATCHCASE Else chkcase=0 End If End Select Case WM_CLOSE hfindbx=0 destroywindow(hwnd) setfocus(dbgrichedit) Return 0 'not really used End Select End Function '================================== private function wtext() As String '-->return automatic searched text Dim text As ZString *200,range As charrange Dim As Integer n,p,c,i,j,l l=sendmessage(dbgrichedit,EM_GETSELTEXT,0,Cast(LPARAM,@text)) 'selected text 'Returns the number of characters copied, not including the terminating null character If l=0 Then n=SendMessage(dbgrichedit,EM_LINEINDEX,-1,0) 'nb char until current line sendmessage(dbgrichedit,EM_EXGETSEL,0, Cast(LPARAM,@range)) 'get pos cursor p=range.cpmin l=sendmessage(dbgrichedit,EM_EXLINEFROMCHAR,0,-1) 'get line number text=Chr(150)+Chr(0) sendmessage(dbgrichedit,EM_GETLINE,l,Cast(LPARAM,@text)) 'get line text If Right(text,1)=Chr(13) Then text=Left(text,Len(text)-1) 'suppress chr$(13) at the end p=p-n+1 'real pos of cursor in line one based For i=p-1 To 1 Step-1 c=Asc(text,i) If c>=Asc("0") AndAlso c<=Asc("9") Then Continue For If c>=Asc("A") AndAlso c<=Asc("Z") Then Continue For If c>=Asc("a") AndAlso c<=Asc("z") Then Continue For If c>=Asc(".") Then Continue For If c>=Asc("_") Then Continue For i+=1:Exit For Next If i=0 Then i+=1 For j=p To Len(text) c=Asc(text,j) If c>=Asc("0") AndAlso c<=Asc("9") Then Continue For If c>=Asc("A") AndAlso c<=Asc("Z") Then Continue For If c>=Asc("a") AndAlso c<=Asc("z") Then Continue For If c=Asc(".") Then Continue For If c=Asc("_") Then Continue For j-=1 :Exit For Next If i>j Then text="" Else text=Mid(text,i,j-i+1) End If End If Return text End Function '==================================== private function brkv_box(ByVal hWnd As HWND,ByVal Msg As UInteger,ByVal wparam As Integer,ByVal lParam As Integer) As Integer Static Txt As ZString *300 Dim rc As RECT => (0, 0, 4, 8) Dim As Single scalex,scaley Static As HWND hedit1,hcombo1,hbutdel,hbutapl Static vflag As Integer,vald As Double Select Case Msg Case WM_INITDIALOG MapDialogRect (hwnd,@rc) ScaleX = rc.right/4 ScaleY = rc.bottom/8 fb_ModStyle(hwnd,0,WS_EX_NOPARENTNOTIFY,1) fb_Label (brkv2.txt,hWnd,101,2*scalex,2*scaley,250*scalex,10*scaley) If brkv2.vst="" Then brkv2.vst=Mid(brkv2.txt,InStr(brkv2.txt,"=")+1,25) End If hEdit1=fb_edit (brkv2.vst,hWnd,101,275*scalex,2*scaley,70*scalex,10*scaley) fb_ModStyle(hedit1,0,WS_EX_NOPARENTNOTIFY,1) fb_ModStyle(hedit1,,WS_VSCROLL,0) SetFocus(hedit1) SendMessage(hedit1,EM_SETSEL,0,-1) hcombo1 = fb_combobox (hWnd,101,255*scalex,2*scaley,20*scalex,40*scaley) SendMessage(hcombo1,CB_ADDSTRING,0,Cast(LPARAM,@"<>")) SendMessage(hcombo1,CB_ADDSTRING,0,Cast(LPARAM,@"=")) If brkv2.typ<>4 AndAlso brkv2.typ<>13 AndAlso brkv2.typ<>14 Then SendMessage(hcombo1,CB_ADDSTRING,0,Cast(LPARAM,@">")) SendMessage(hcombo1,CB_ADDSTRING,0,Cast(LPARAM,@"<")) SendMessage(hcombo1,CB_ADDSTRING,0,Cast(LPARAM,@">=")) SendMessage(hcombo1,CB_ADDSTRING,0,Cast(LPARAM,@"<=")) End If SendMessage(hcombo1,CB_SETCURSEL,brkv2.tst-1,0) hButapl = fb_button("Apply",hWnd,1,170*scalex, 28*scaley, 36*scalex, 10*scaley) fb_ModStyle(hbutapl,0,WS_EX_NOPARENTNOTIFY,1) hButdel=fb_button("Delete",hWnd,2, 210*scalex, 28*scaley, 36*scalex, 10*scaley) fb_ModStyle(hbutdel,0,WS_EX_NOPARENTNOTIFY,1) txt=brkv2.vst vflag=1 Case WM_COMMAND Select Case lparam Case hButapl 'clicked apply If HiWord(wparam)=BN_CLICKED Then If vflag=1 Then brkv2.tst=sendmessage(hcombo1,CB_GETCURSEL,0,0)+1 brkv2.ttb=32 Shr (brkv2.tst-1) Select Case brkv2.tst Case 1 brkv2.txt+=" becomes <> " Case 2 brkv2.txt+=" becomes = " Case 3 brkv2.txt+=" becomes > " Case 4 brkv2.txt+=" becomes < " Case 5 brkv2.txt+=" becomes >= " Case 6 brkv2.txt+=" becomes <= " End Select Select Case brkv2.typ Case 2 brkv2.val.vbyte=ValInt(txt) brkv2.vst=Str(brkv2.val.vbyte) Case 3 brkv2.val.vubyte=ValUInt(txt) brkv2.vst=Str(brkv2.val.vubyte) Case 5 brkv2.val.vshort=ValInt(txt) brkv2.vst=Str(brkv2.val.vshort) Case 6 brkv2.val.vushort=ValUInt(txt) brkv.vst=Str(brkv2.val.vushort) Case 1 brkv2.val.vinteger=ValInt(txt) brkv2.vst=Str(brkv2.val.vinteger) Case 7,8 brkv2.val.vuinteger=ValUInt(txt) brkv2.vst=Str(brkv2.val.vuinteger) Case Else brkv2.vst=Left(txt,26)'str(brkv.val.vuinteger) End Select brkv=brkv2 SetWindowText(brkvhnd,brkv.txt+brkv.vst) 'update display menu_chg(menuvar,idvarbrk,brkv.txt+brkv.vst) enddialog(hwnd,0) End If End If Case hButdel 'clicked delete If HiWord(wparam)=BN_CLICKED Then brkv_set(0) 'delete current break on var enddialog(hwnd,0) End If 'case hcombo1 'combobox ' if hiword(wparam)=CBN_SELCHANGE then 'change kind of test 'end if Case hedit1 'change address If HiWord(wparam)=EN_CHANGE Then sendmessage(hedit1,WM_GETTEXT,26,Cast(LPARAM,@txt)) vflag=1 vald=Val(txt) Select Case brkv2.typ Case 2 If vald<-128 Or vald>127 Then setwindowtext(hwnd,"min -128,max 127"):vflag=0 Case 3 If vald<0 Or vald>255 Then setwindowtext(hwnd,"min 0,max 255"):vflag=0 Case 5 If vald<-32768 Or vald>32767 Then setwindowtext(hwnd,"min -32768,max 32767"):vflag=0 Case 6 If vald<0 Or vald>65535 Then setwindowtext(hwnd,"min 0,max 65535"):vflag=0 Case 1 If vald<-2147483648 Or vald>2147483648 Then setwindowtext(hwnd,"min -2147483648,max +2147483647"):vflag=0 Case 7,8 If vald<0 Or vald>4294967395 Then setwindowtext(hwnd,"min 0,max 4294967395"):vflag=0 End Select End If End Select Case WM_CLOSE enddialog(hwnd,0) Return 0 End Select End Function '==================================== private function kill_process(text As String) As Integer Dim As Long retcode,lasterr If fb_message("Kill current running Program ?",text+Chr(10)+Chr(10) _ +"USE CARREFULLY SYSTEM CAN BECOME UNSTABLE, LOSS OF DATA, MEMORY LEAK"+Chr(10)+ _ "Try to close your program first",MB_ICONWARNING Or MB_YESNO Or MB_APPLMODAL) = IDYES Then flagkill=TRUE retcode=terminateprocess(dbghand,999) lasterr=GetLastError #Ifdef fulldbg_prt dbg_prt ("return code terminate process ="+Str(retcode)+" lasterror="+Str(lasterr)) #EndIf thread_rsm() While prun:Sleep 500:Wend Return TRUE Else Return FALSE EndIf End Function private function attach_box(ByVal hWnd As HWND,ByVal Msg As UInteger,ByVal wparam As Integer,ByVal lParam As Integer) As Integer Dim rc As RECT => (0, 0, 4, 8),ad As UInteger Dim As Single scalex,scaley Static As HWND hlistbox Dim prcinfo As PROCESSENTRY32,snap As HANDLE,text As String Dim stext As String *200,nitem As Integer Select Case Msg Case WM_INITDIALOG MapDialogRect (hwnd,@rc) ScaleX = rc.right/4 ScaleY = rc.bottom/8 fb_ModStyle(hwnd,0,WS_EX_NOPARENTNOTIFY,1) hlistbox=fb_listbox(hWnd,101,0*scalex,0*scaley,100*scalex,130*scaley) SendMessage(hlistbox,WM_SETFONT,Cast(WPARAM,GetStockObject(ANSI_FIXED_FONT)),0) snap=CreateToolhelp32Snapshot (TH32CS_SNAPPROCESS, 0)'Take snapshot of running processes If snap <> INVALID_HANDLE_VALUE Then prcinfo.dwSize=SizeOf(PROCESSENTRY32) If Process32First (snap,@prcinfo) Then Do text=fmt(prcinfo.szExeFile,20)+fmt(Str(prcinfo.th32ProcessID),5) If SendMessage(hlistbox, LB_SETITEMDATA,SendMessage(hlistbox, LB_ADDSTRING, 0,Cast(LPARAM,StrPtr(text))),prcinfo.th32ProcessID)=LB_ERR Then fb_message("Error insertion data ","") Loop While Process32Next (snap,@prcinfo) Else fb_message("Process list error","Failed to create process list!") enddialog(hwnd,0) End If CloseHandle (snap) Else fb_message("Process list error","INVALID_HANDLE_VALUE") EndDialog(hwnd,0) End If Case WM_COMMAND If lparam=hlistbox Then If (HiWord(wParam))=LBN_DBLCLK Then nitem=SendMessage(hlistbox, LB_GETCURSEL, 0, 0) SendMessage(hlistbox, LB_GETTEXT,nitem,Cast(LPARAM,@stext)) If fb_message("Attach to this process ?",stext,MB_YESNO) = IDYES Then dbgprocid=SendMessage(hlistbox, LB_GETITEMDATA,nitem,0) ThreadCreate(@dbg_attach) enddialog(hwnd,0) End If End If End If Case WM_CLOSE enddialog(hwnd,0) Return 0 'Not really used End Select End Function private function watch_box(ByVal hWnd As HWND,ByVal Msg As UInteger,ByVal wparam As Integer,ByVal lParam As Integer) As Integer Dim rc As RECT => (0, 0, 4, 8),ad As UInteger Static As Single scalex,scaley Static As HWND hbutton1,hbutton2,hbutton3 Static As HWND butrad(5) Select Case Msg Case WM_INITDIALOG 'All of your controls are created here in the same hwtchbx=hwnd MapDialogRect (hwnd,@rc) ScaleX = rc.right/4 ScaleY = rc.bottom/8 fb_ModStyle(hwnd,0,WS_EX_NOPARENTNOTIFY,1) fb_Label("Current type : "+udt(varfind.ty).nm+", Select type of additional info",hwnd,,_ 2*scalex, 4*scaley, 150*scalex, 10*scaley) butrad(1)=fb_radio("Hex FA0B", hwnd,1,2*scalex, 14*scaley, 60*scalex, 10*scaley) butrad(2)=fb_radio("Binary 11010", hwnd,2,2*scalex, 24*scaley, 60*scalex, 10*scaley) butrad(3)=fb_radio("Ascii ARXp", hwnd,3,2*scalex, 34*scaley, 60*scalex, 10*scaley) butrad(4)=fb_radio("Byte 23,78", hwnd,4,2*scalex, 44*scaley, 60*scalex, 10*scaley) butrad(5)=fb_radio("Word 2345,6789",hwnd,5,2*scalex, 54*scaley, 60*scalex, 10*scaley) butrad(0)=fb_radio("None", hwnd,0,2*scalex, 64*scaley, 60*scalex, 10*scaley) sendmessage(butrad(0),BM_SETCHECK,BST_CHECKED ,0) hButton1 = fb_button("Remove",hWnd,,2*scalex, 78*scaley, 30*scalex, 10*scaley) fb_ModStyle(hbutton1,0,WS_EX_NOPARENTNOTIFY,1) hButton2 = fb_button("Add",hWnd,,34*scalex, 78*scaley, 30*scalex, 10*scaley) fb_ModStyle(hbutton3,0,WS_EX_NOPARENTNOTIFY,1) hButton3=fb_button("Cancel",hWnd,, 66*scalex, 78*scaley, 30*scalex, 10*scaley) fb_ModStyle(hbutton3,0,WS_EX_NOPARENTNOTIFY,1) Case WM_COMMAND Select Case lparam Case hButton1,hButton2,hButton3 If HiWord(wparam)=BN_CLICKED Then Select Case lparam Case hButton1 'remove watch_del(wtchidx) sendmessage(hwnd,WM_CLOSE,0,0) Case hButton2 'add If sendmessage(butrad(0),BM_GETCHECK,0,0)=BST_UNCHECKED Then For i As Integer =1 To 5 If sendmessage(butrad(i),BM_GETCHECK,0,0)=BST_CHECKED Then watch_add(i) Exit For EndIf Next Else fb_message("Add watched var","operation aborted, No additionnal type") End If sendmessage(hwnd,WM_CLOSE,0,0) Case hButton3 'cancel, abort sendmessage(hwnd,WM_CLOSE,0,0) End Select End If End Select Case WM_CLOSE hwtchbx=0 enddialog(hwnd,0) Return 0 'not really used End Select End Function private function dump_box(ByVal hWnd As HWND,ByVal Msg As UInteger,ByVal wparam As Integer,ByVal lParam As Integer) As Integer Dim Txt As ZString *300,combotyp As Integer, tmp As Integer Dim rc As RECT => (0, 0, 4, 8),ad As UInteger Static As Single scalex,scaley Static As HWND hbutton1,hbutton2,hbutton3,hbutton4 Static As HWND hedit1,hcombo1,butrad1,butrad2,butwtch,butbrk,butmem,hadrbeg,hadrend,hcopy,hreset Dim As UInteger adrtemp Static As HWND ptgroup,nopt,ptr1,ptr2,cellapply,hcombo2,hadrspe '25/11/2014 Select Case Msg Case WM_INITDIALOG 'All of your controls are created here in the same hdumpbx=hwnd MapDialogRect (hwnd,@rc) ScaleX = rc.right/4 ScaleY = rc.bottom/8 fb_ModStyle(hwnd,0,WS_EX_NOPARENTNOTIFY,1) hEdit1 = fb_edit ("",hWnd,101,2*scalex,2*scaley,60*scalex,10*scaley) fb_ModStyle(hedit1,0,WS_EX_NOPARENTNOTIFY,1) fb_ModStyle(hedit1,ES_NUMBER,WS_VSCROLL,0) txt=Str(dumpadr) setfocus(hedit1) sendmessage(hedit1,WM_SETTEXT,0,Cast(LPARAM,@txt)) sendmessage(hedit1,EM_SETSEL,0,-1) 'fb_Label (" Copy to clipboard",hWnd,200,2*scalex,64*scaley,90*scalex,10*scaley) ptgroup=fb_Group(" Copy to clipboard",hwnd,200,2*scalex,64*scaley,117*scalex,40*scaley) If copybeg=-99 Then adrtemp=0 Else adrtemp=dumpadr+copybeg*16 If copycol<>-99 Then copybeg+=(copycol-1)*16/lvnbcol EndIf hadrbeg = fb_Label (Str(adrtemp),hWnd,201,2*scalex,75*scaley,60*scalex,10*scaley) If copyend=-99 Then adrtemp=0 Else adrtemp=dumpadr+copyend*16 If copycol<>-99 Then adrtemp+=(copycol-1)*16/lvnbcol Else adrtemp+=15 EndIf EndIf hadrend = fb_Label (Str(adrtemp),hWnd,202,2*scalex,88*scaley,60*scalex,10*scaley) fb_ModStyle(hadrbeg,0,WS_EX_NOPARENTNOTIFY,1) fb_ModStyle(hadrbeg,ES_NUMBER,WS_VSCROLL,0) fb_ModStyle(hadrend,0,WS_EX_NOPARENTNOTIFY,1) fb_ModStyle(hadrend,ES_NUMBER,WS_VSCROLL,0) hreset=fb_button("Reset",hWnd,205,65*scalex,75*scaley,35*scalex,10*scaley) hcopy=fb_button("Copy to CB",hWnd,206,65*scalex,88*scaley,35*scalex,10*scaley) hcombo1 = fb_combobox (hWnd,101,65*scalex,2*scaley,30*scalex,80*scaley) txt="Integer":sendmessage(hcombo1,CB_ADDSTRING,0,Cast(LPARAM,@txt)) txt="Byte":sendmessage(hcombo1,CB_ADDSTRING,0,Cast(LPARAM,@txt)) txt="uByte":sendmessage(hcombo1,CB_ADDSTRING,0,Cast(LPARAM,@txt)) txt="Short":sendmessage(hcombo1,CB_ADDSTRING,0,Cast(LPARAM,@txt)) txt="uShort":sendmessage(hcombo1,CB_ADDSTRING,0,Cast(LPARAM,@txt)) txt="uInteger":sendmessage(hcombo1,CB_ADDSTRING,0,Cast(LPARAM,@txt)) txt="Longint":sendmessage(hcombo1,CB_ADDSTRING,0,Cast(LPARAM,@txt)) txt="uLongint":sendmessage(hcombo1,CB_ADDSTRING,0,Cast(LPARAM,@txt)) txt="Single":sendmessage(hcombo1,CB_ADDSTRING,0,Cast(LPARAM,@txt)) txt="Double":sendmessage(hcombo1,CB_ADDSTRING,0,Cast(LPARAM,@txt)) Select Case lvtyp Case Is>7 combotyp=lvtyp-2 Case Is>3 combotyp=lvtyp-1 Case Else combotyp=lvtyp End Select sendmessage(hcombo1,CB_SETCURSEL,combotyp-1,0) butrad1=fb_radio("Dec",hwnd,,2*scalex, 14*scaley, 20*scalex, 10*scaley) butrad2=fb_radio("Hex",hwnd,,24*scalex, 14*scaley, 20*scalex, 10*scaley) If dumpdec=0 Then sendmessage(butrad1,BM_SETCHECK,BST_CHECKED ,0) Else sendmessage(butrad2,BM_SETCHECK,BST_CHECKED ,0) EndIf hButton1 = fb_button("-",hWnd,1,2*scalex, 28*scaley, 18*scalex, 10*scaley) fb_ModStyle(hbutton1,0,WS_EX_NOPARENTNOTIFY,1) hButton2=fb_button("+",hWnd,2, 20*scalex, 28*scaley, 18*scalex, 10*scaley) fb_ModStyle(hbutton1,0,WS_EX_NOPARENTNOTIFY,1) hButton3 = fb_button("--",hWnd,3,38*scalex, 28*scaley, 18*scalex, 10*scaley) fb_ModStyle(hbutton3,0,WS_EX_NOPARENTNOTIFY,1) hButton4=fb_button("++",hWnd,4, 56*scalex, 28*scaley, 18*scalex, 10*scaley) fb_ModStyle(hbutton4,0,WS_EX_NOPARENTNOTIFY,1) butwtch=fb_button("Add watched",hWnd,991, 2*scalex, 40*scaley, 52*scalex, 10*scaley) butbrk=fb_button("--> Break on mem",hWnd,995,2*scalex,52*scaley,52*scalex,10*scaley) butmem=fb_button("M",hWnd,996,100*scalex,2*scaley,18*scalex,15*scaley) fb_CreateTooltips(butmem, "Enlarge/reduce dump memory", "",0) fb_ModStyle(butmem,BS_BITMAP) SendMessage(butmem, BM_SETIMAGE, IMAGE_BITMAP, Cast(LPARAM,bmb(20))) ptgroup=fb_Group("Use cell value as pointer or udt beginning",hwnd,200,2*scalex,105*scaley,117*scalex,45*scaley) nopt=fb_radio("No Ptr",ptgroup,201,5*scalex,28*scaley,25*scalex,15*scaley) ptr1=fb_radio("x1",ptgroup,202,40*scalex,28*scaley,20*scalex,15*scaley) ptr2=fb_radio("x2",ptgroup,203,65*scalex,28*scaley,20*scalex,15*scaley) sendmessage(nopt,BM_SETCHECK,BST_CHECKED ,0) cellapply=fb_button("Apply",hWnd,1,93*scalex, 113*scaley, 22*scalex, 10*scaley) hcombo2=fb_combobox (hWnd,101,5*scalex,125*scaley,110*scalex,100*scaley) hadrspe=fb_Label ("",hWnd,200,5*scalex,113*scaley,70*scalex,10*scaley) For i As Long = 1 To udtmax '25/11/2014 If udt(i).nm<>"" Then SendMessage(hcombo2,CB_ADDSTRING,0,Cast(LPARAM,StrPtr(udt(i).nm))) Next SendMessage(hcombo2,CB_SETCURSEL,0,0) Case WM_COMMAND Select Case lparam Case hButton1,hButton2,hButton3,hButton4 'clicked the - button If HiWord(wparam)=BN_CLICKED Then Select Case lparam Case hButton1 If dumplig=1 Then ad=dumpadr-16/lvnbcol Else ad=dumpadr-16 End If Case hButton2 'clicked + button If dumplig=1 Then ad=dumpadr+16/lvnbcol Else ad=dumpadr+16 End If Case hButton3 'clicked the -- button ad=dumpadr-16*dumplig Case hButton4 'clicked ++ button ad=dumpadr+16*dumplig End Select If readProcessMemory(dbghand,Cast(LPCVOID,ad),@txt,1,0)=0 Then sendmessage(hdumpbx,WM_SETTEXT,0,Cast(LPARAM,@"Invalid Memory Address")) Else sendmessage(hdumpbx,WM_SETTEXT,0,Cast(LPARAM,@"Manage Dump")) dumpadr=ad txt=Str(dumpadr):sendmessage(hedit1,WM_SETTEXT,0,Cast(LPARAM,@txt)) dump_sh() End If End If 'case IDFNDTXCS 'clicked case 'if SendMessage(Checkcase, BM_GETCHECK,0,0)=BST_CHECKED then ' chkcase=4 'FR_MATCHCASE ' else ' chkcase=0 'end if Case hcombo1 'combobox If HiWord(wparam)=CBN_SELCHANGE Then 'change kind of unit combotyp=sendmessage(hcombo1,CB_GETCURSEL,0,0)+1 Select Case combotyp Case Is>5 lvtyp=combotyp+2 Case Is>3 lvtyp=combotyp+1 Case Else lvtyp=combotyp End Select dump_set(listview1) dump_sh() End If Case hedit1 'change address If HiWord(wparam)=EN_CHANGE Then sendmessage(hedit1,WM_GETTEXT,10,Cast(LPARAM,@txt)) ad=Val(txt) If readProcessMemory(dbghand,Cast(LPCVOID,ad),@txt,1,0)=0 Then sendmessage(hdumpbx,WM_SETTEXT,0,Cast(LPARAM,@"Invalid Memory Address")) Else sendmessage(hdumpbx,WM_SETTEXT,0,Cast(LPARAM,@"Manage Dump")) dumpadr=ad dump_sh() End If End If Case butrad1,butrad2 'DEC/HEX If HiWord(wparam)=BN_CLICKED Then If sendmessage(butrad1,BM_GETCHECK,0,0)=BST_CHECKED Then dumpdec=0 Else dumpdec=50 End If dump_sh() End If Case butwtch If HiWord(wparam)=BN_CLICKED Then varfind.ty=lvtyp varfind.ad=dumpadr varfind.nm="Memory ["+Str(dumpadr)+"]<" varfind.pt=0 varfind.iv=-1 watch_set() End If Case butbrk If HiWord(wparam)=BN_CLICKED Then brkv2.typ=lvtyp 'change in brkv_box if pointed value brkv2.adr=dumpadr 'idem brkv2.vst="" 'idem brkv2.tst=1 'type of test brkv2.ivr=0 'not var brkv2.arr=0 brkv2.psk=-2 'permanent brkv2.txt="Stop if MEMORY ["+Str(dumpadr)+"]<"+var_sh2(brkv2.typ,brkv2.adr) fb_MDialog(@brkv_box,"Test for break on value",windmain,283,25,350,50) hdumpbx=0 destroywindow(hwnd) End If Case butmem dsp_hide(4) Case hcopy If HiWord(wparam)=BN_CLICKED Then dump_copy() EndIf Case cellapply 'applying special adr If sendmessage(nopt,BM_GETCHECK,0,0)=BST_CHECKED Then varfind.pt=0 ElseIf sendmessage(ptr1,BM_GETCHECK,0,0)=BST_CHECKED Then varfind.pt=1 'to be added pointer value instead pointer ? same below 2 twice Else varfind.pt=2 EndIf varfind.ty=sendmessage(hcombo2,CB_GETCURSEL,0,0)+1 For i As Integer =1 To udtmax 'need to find the real index as some udt().nm are empty If udt(i).nm<>"" Then tmp+=1:If tmp=varfind.ty Then varfind.ty=i:Exit For EndIf Next shwexp_new(0) End Select If LoWord(wparam)=891 Then 'coming from dump_spe dumpadr=varfind.ad dump_sh SetWindowText(hadrspe,Str(dumpadr)) ElseIf LoWord(wparam)=205 Then 'reset If HiWord(wparam)=BN_CLICKED Then copybeg=-99:copyend=-99:copycol=-99 SetWindowText(hadrbeg,"0") SetWindowText(hadrend,"0") EndIf EndIf Case WM_SETTEXT Select Case wparam Case 201 adrtemp=dumpadr+copybeg*16 If copycol<>-99 Then adrtemp+=(copycol-1)*16/lvnbcol SetWindowText(hadrbeg,Str(adrtemp)) Case 202 adrtemp=dumpadr+copyend*16 If copycol<>-99 Then adrtemp+=(copycol-1)*16/lvnbcol Else adrtemp+=15 EndIf SetWindowText(hadrend,Str(adrtemp)) End Select Case WM_CLOSE hdumpbx=0 destroywindow(hwnd) Return 0 'not really used End Select End Function private function bcktrk2_box(byval hWnd As HWND,byval Msg AS UINTeger,byval wparam as integer,byval lParam AS integer) as Integer dim rc as RECT => (0, 0, 4, 8) Dim As Single scalex,scaley Dim lvp as NMLISTVIEW Ptr Dim lvCol AS LVCOLUMN,lvI AS LVITEM,il as integer, txt as string,ztxt As ZString *300 Dim As Integer tempo Static as HWND listview Static As Integer procrsav(PROCRMAX),thid,lastitem,selitem SELECT CASE Msg Case WM_INITDIALOG 'All of your controls are created here in the same MapDialogRect (hwnd,@rc) ScaleX = rc.right/4 ScaleY = rc.bottom/8 bcktrkbx=hwnd listview=fb_listview(hwnd,77,3,4,10,10) 'CLICK ON THE TOP OF TH LEFT COLUMN TO CHANGE THE ORDER lvCol.mask = LVCF_FMT OR LVCF_WIDTH OR LVCF_TEXT OR LVCF_SUBITEM lvCol.fmt = LVCFMT_LEFT lvcol.cx=0 lvI.mask = LVIF_TEXT thid=procr(bcktrkpr).thid txt ="Calling line [ThID="+ Str(thid)+"]" lvCol.pszText = strptr(txt) lvCol.iSubItem = 0 sendmessage(listview,LVM_INSERTCOLUMN,0,Cast(LPARAM,@lvCol)) 'LVSCW_AUTOSIZE_USEHEADER = -2 ou AUTOSIZE= -1) sendmessage(listview,LVM_SETCOLUMNWIDTH,0,350) lvCol.pszText = strptr("L.No.") lvCol.iSubItem = 1 sendmessage(listview,LVM_INSERTCOLUMN,1,Cast(LPARAM,@lvCol)) sendmessage(listview,LVM_SETCOLUMNWIDTH,1,50) lvCol.pszText = strptr("In proc name") lvCol.iSubItem = 2 sendmessage(listview,LVM_INSERTCOLUMN,2,Cast(LPARAM,@lvCol)) sendmessage(listview,LVM_SETCOLUMNWIDTH,2,250) lvCol.pszText = strptr("File name") lvCol.iSubItem = 3 sendmessage(listview,LVM_INSERTCOLUMN,3,Cast(LPARAM,@lvCol)) sendmessage(listview,LVM_SETCOLUMNWIDTH,3,150) ''''to avoid display update every update 'SendMessage(listview, WM_SETREDRAW, FALSE, 0) ' sendmessage(listview,LVM_SETCOLUMNWIDTH,lvnbcol+1,LVSCW_AUTOSIZE)'_USEHEADER) sendmessage(listview,LVM_SETTEXTCOLOR,0,RGB(128,0,0)) for i as integer = 1 to procrnb If procr(i).thid=thid Then tempo=i procrsav(il)=i 'to make easier the location If i=bcktrkpr Then selitem=il lvi.iitem = il 'index line lvi.isubitem = 0 'lvi.pszText = @"No calling line" SendMessage(listview,LVM_INSERTITEM,0,Cast(LPARAM,@lvi)) If il<>0 Then exrichedit(proc(tempo).sr) 'previous proc source sel_line(rline(procr(i).cl).nu-1)'calling line SendMessage(dbgrichedit,EM_GETSELTEXT,0,Cast(LPARAM,@ztxt)) txt=LTrim(ztxt) lvi.pszText = strptr(txt) lvi.iitem = il-1'index line lvi.isubitem = 0 'index column SendMessage(listview,LVM_SETITEMTEXT,il-1,Cast(LPARAM,@lvi)) txt=Right("_____"+Str(rline(procr(i).cl).nu),5) lvi.pszText = strptr(txt) lvi.isubitem = 1 'index column SendMessage(listview,LVM_SETITEMTEXT,il-1,Cast(LPARAM,@lvi)) EndIf lvi.iitem = il 'index line lvi.isubitem = 2 txt=proc(procr(i).idx).nm lvi.pszText = strptr(txt) SendMessage(listview,LVM_SETITEMTEXT,il,Cast(LPARAM,@lvi)) 'sendmessage(listview,LVM_SETCOLUMNWIDTH,lvnbcol,LVSCW_AUTOSIZE) To be tested lvi.isubitem = 3 txt=name_extract(source(proc(procr(i).idx).sr)) lvi.pszText = strptr(txt) sendmessage(listview,LVM_SETITEMTEXT,il,Cast(LPARAM,@lvi)) il+=1 End if Next 'last item managed differently lastitem=il-1 thread_execline(1,thid) 'restore the display of next executed line SendMessage(dbgrichedit,EM_GETSELTEXT,0,Cast(LPARAM,@ztxt)) txt=" "+LTrim(ztxt) lvi.pszText = strptr(txt) lvi.iitem = lastitem'index line lvi.isubitem = 0 'index column SendMessage(listview,LVM_SETITEMTEXT,lastitem,Cast(LPARAM,@lvi)) 'highlight selected proc lvi.iitem = selitem lvI.mask = LVIF_STATE lvI.statemask = LVIS_SELECTED lvI.state = LVIS_SELECTED SendMessage(listview,LVM_SETITEMSTATE,selitem,Cast(LPARAM,@lvi)) 'sizing the windows, not usefull a too big window If lastitem<11 Then MoveWindow(hwnd,300,500,800,20+(lastitem+1)*15+38,FALSE) MoveWindow(listview,3,4,800,22+(lastitem+1)*15,FALSE) Else MoveWindow(hwnd,300,500,800,20+10*15+3,FALSE) MoveWindow(listview,3,4,800,22+10*15+19,FALSE) EndIf case WM_NOTIFY lvp=Cast(NMLISTVIEW Ptr,lparam) If lvp->hdr.hwndFrom=listview Then If lvp->hdr.code =CULng(NM_CLICK) Then 'remove culng when fix done in commctrl.bi ShowWindow(tviewcur,SW_HIDE) tviewcur=tviewvar ShowWindow(tviewcur,SW_SHOW) SendMessage(htab2,TCM_SETCURSEL,0,0) proc_expcol(TVE_COLLAPSE) If lvp->iitem=-1 OrElse lvp->iitem=lastitem Then 'click somewhere else or last item thread_execline(1,thid) 'show next executed line of thread tempo=procrsav(lastitem)'to avoid case lvp->iitem=-1 Else tempo=procr(procrsav(lvp->iitem+1)).cl exrichedit(proc(procr(procrsav(lvp->iitem)).idx).sr ) sel_line(rline(tempo).nu-1)'Select Line tempo=procrsav(lvp->iitem) EndIf SendMessage(tviewvar,TVM_SELECTITEM,TVGN_CARET,Cast(LPARAM,procr(tempo).tv)) SendMessage(tviewvar,TVM_EXPAND,TVE_EXPAND,Cast(LPARAM,procr(tempo).tv)) SetFocus(tviewcur) elseIf lvp->hdr.code =LVN_COLUMNCLICK Then 'change order most outer <> less outer fb_message("Proc call chaining","Inverse order, not implemented") EndIf EndIf Case WM_CLOSE bcktrkbx=0 destroywindow(hwnd) Return 0 End Select end Function private function bcktrk1_box(ByVal hWnd As HWND,ByVal Msg As UInteger,ByVal wparam As Integer,ByVal lParam As Integer) As Integer Dim rc As RECT => (0, 0, 4, 8) Dim As Single scalex,scaley Static As HWND lblcur,lblprev,lblnext,butprev,butnext,butcur Static As tbcktrk btprc Select Case Msg Case WM_INITDIALOG 'All of your controls are created here in the same MapDialogRect (hwnd,@rc) ScaleX = rc.right/4 ScaleY = rc.bottom/8 '''''''''''''''''''fb_modstyle(hwnd,0,WS_EX_NOPARENTNOTIFY,1) butprev=fb_button("Prev" ,hwnd,110 ,2*scalex,2*scaley,30*scalex,10*scaley,SS_LEFT) butcur=fb_button("Current",hwnd,111 ,2*scalex,14*scaley,30*scalex,10*scaley,SS_LEFT) butnext=fb_button("next" ,hwnd,112 ,2*scalex,26*scaley,30*scalex,10*scaley,SS_LEFT) lblprev=fb_Label("" ,hwnd,100 ,35*scalex,2*scaley,150*scalex,10*scaley,SS_LEFT) lblcur=fb_Label("" ,hwnd,101 ,35*scalex,14*scaley,150*scalex,10*scaley,SS_LEFT) lblnext=fb_Label("" ,hwnd,102 ,35*scalex,26*scaley,150*scalex,10*scaley,SS_LEFT) bcktrk_proc(bcktrkpr,btprc,3,lblcur,lblprev,lblnext,butprev,butnext)'both directions If btprc.bcw=0 AndAlso btprc.frw=0 Then fb_message("Backtracing","Neither calling and nor called procs, command canceled") postmessage(hwnd,WM_CLOSE,0,0) EndIf bcktrkbx=hwnd Case WM_COMMAND Select Case LoWord(wparam) Case 110 'previous proc mother btprc.frw=bcktrkpr bcktrkpr=btprc.bcw bcktrk_proc(bcktrkpr,btprc,1,lblcur,lblprev,lblnext,butprev,butnext) Case 111 bcktrk_proc(bcktrkpr,btprc,3,lblcur,lblprev,lblnext,butprev,butnext) Case 112 'next proc daughter btprc.bcw=bcktrkpr bcktrkpr=btprc.frw bcktrk_proc(bcktrkpr,btprc,2,lblcur,lblprev,lblnext,butprev,butnext) End Select Case WM_CLOSE bcktrkbx=0 destroywindow(hwnd) Return 0 End Select End Function 'Changes the value of btprc next/prev proc typ=1 prev/=2 next/3 both and does all the displays private sub bcktrk_proc(prr As Integer,ByRef bcktrk As tbcktrk,typ As Integer,lblcur As HWND,lblprev As HWND,lblnext As HWND,butprev As HWND,butnext As HWND) Dim As Integer idx,thid=procr(prr).thid,linenu,src Dim txt As String If (typ And 1) Then 'prev bcktrk.bcw=0 For idx =prr-1 To 1 Step -1 If procr(idx).thid=thid Then bcktrk.bcw=idx:Exit For EndIf Next EndIf If (typ And 2) Then 'next bcktrk.frw=0 For idx =prr+1 To procrnb If procr(idx).thid=thid Then bcktrk.frw=idx:Exit For EndIf Next EndIf If bcktrk.bcw Then 'show prev EnableWindow(butprev,TRUE) txt=proc(procr(bcktrk.bcw).idx).nm+" ["+name_extract(source(proc(procr(bcktrk.bcw).idx).sr))+"]" src=proc(rline(procr(prr).cl).pr).sr linenu=rline(procr(prr).cl).nu Else EnableWindow(butprev,FALSE) txt="No parent proc" src=proc(procr(prr).idx).sr linenu=proc(procr(prr).idx).nu EndIf setwindowtext(lblprev,StrPtr(txt)) If bcktrk.frw Then 'show next EnableWindow(butnext,TRUE) txt=proc(procr(bcktrk.frw).idx).nm+" ["+name_extract(source(proc(procr(bcktrk.frw).idx).sr))+"]" Else EnableWindow(butnext,FALSE) txt="No child proc" EndIf setwindowtext(lblnext,StrPtr(txt)) txt=proc(procr(bcktrkpr).idx).nm+" ["+name_extract(source(proc(procr(bcktrkpr).idx).sr))+"]" setwindowtext(lblcur,StrPtr(txt)) exrichedit(src) 'display source sel_line(linenu-1)'Select Line End Sub private sub bcktrk_close If bcktrkbx Then SendMessage(bcktrkbx,WM_CLOSE,0,0) End Sub private sub bcktrk_launch(pr As Integer,typ As Integer)''typ=1 -->simple backtracking / typ=2 -->full backtracking or chaining If bcktrkbx<>0 Then Exit Sub bcktrkpr=pr If typ=1 Then fb_Dialog(@bcktrk1_box,"Proc Backtracking",windmain,300,100,190,40) Else fb_Dialog(@bcktrk2_box,"Proc call chaining",windmain,300,500,300,900) EndIf End Sub private sub fill_focus(l As Integer,hedit1 As HWND,hsrc As HWND) Dim f As Integer,d As Integer,c As Integer Dim src As String *1000 setWindowText(hedit1,"") d=l-3:If d<0 Then d=0 f=l+10:c=sendmessage(hsrc,EM_GETLINECOUNT,0,0)-1:If f>c Then f=c For i As Integer =d To f src=Chr(1)+Chr(3) sendmessage(hsrc,EM_getline,i,Cast(LPARAM,StrPtr(src))) 'get text src+=Chr(13)+Chr(10) If i=l Then src="----------------------------------------"+Chr(13)+Chr(10)+src+"----------------------------------------"+Chr(13)+Chr(10) sendmessage(hedit1,EM_SETSEL,0,-1) sendmessage(hedit1,EM_SETSEL,-1,0) sendmessage(hedit1,EM_REPLACESEL,FALSE,Cast(LPARAM,@src)) Next setfocus(dbgrichedit) End Sub private function dll_name(FileHandle As HANDLE,t As Integer =1 )As String ' t=1 --> full name, t=2 --> short name Dim As ZString*251 fileName Dim As ZString*512 zstr,dn,tzstr=" :" Dim As HANDLE hfileMap Dim As Long fileSizeHi,fileSizeLo,p Dim As Any Ptr pmem Dim As String tstring fileSizeLo = GetFileSize(FileHandle, @fileSizeHi) If fileSizeLo = 0 And fileSizeHi=0 Then Return "Empty file." ' cannot map an 0 byte file hfileMap = CreateFileMapping(FileHandle,0,PAGE_READONLY, 0, 1, NULL) If hfileMap Then pMem = MapViewOfFile(hfileMap,FILE_MAP_READ, 0, 0, 1) If pMem Then GetMappedFileName(GetCurrentProcess(),pMem, @fileName, 250) UnmapViewOfFile(pMem) CloseHandle(hfileMap) If Len(fileName) > 0 Then getlogicaldrivestrings(511,zstr)'get all the device letters c:\ d:\ etc separate by null While zstr[p] tzstr[0]=zstr[p]'replace space by letter querydosdevice(tzstr,dn,511)'get corresponding device name If InStr(fileName,dn) Then tstring=fileName str_replace(tstring,dn,tzstr) If t=1 Then Return tstring 'full name Else Return name_extract(tstring)'extract only name without path EndIf EndIf p+=4'next letter skip ":\" Wend Else Return "Empty filename." EndIf EndIf End If Return "Empty filemap handle." End Function private function focus_box(ByVal hWnd As HWND,ByVal Msg As UInteger,ByVal wparam As Integer,ByVal lParam As Integer) As Integer Dim rc As RECT => (0, 0, 4, 8) Dim As Single scalex,scaley Dim As Integer Style = WS_CHILD Or WS_VISIBLE Or ES_WANTRETURN Or WS_VSCROLL Or ES_MULTILINE Or ES_AUTOVSCROLL Static As HWND hedit1,hbut1,hsrc Static As Integer linenum,nblines Select Case Msg Case WM_INITDIALOG focusbx=hwnd MapDialogRect (hwnd,@rc) ScaleX = rc.right/4 ScaleY = rc.bottom/8 hbut1=fb_button("Exec following",hWnd,992, 10*scalex, 250*scaley, 50*scalex, 10*scaley) fb_button("UP",hWnd,993, 60*scalex, 250*scaley, 50*scalex, 10*scaley) fb_button("DOWN",hWnd,994, 100*scalex, 250*scaley, 50*scalex, 10*scaley) fb_ModStyle(hwnd,0,WS_EX_NOPARENTNOTIFY,1) hEdit1=fb_edit ("",hWnd,101,0*scalex,0*scaley,400*scalex,250*scaley,style) SendMessage (hedit1,WM_SETFONT,Cast(WPARAM,fonthdl),0) hsrc=dbgrichedit linenum=sendmessage(hsrc,EM_EXLINEFROMCHAR,0,-1) 'get line number nblines=sendmessage(hsrc,EM_GETLINECOUNT,0,0)-1 flagfollow=FALSE SendMessage(hedit1,EM_SETREADONLY,TRUE,0) fill_focus(linenum,hedit1,hsrc) Return TRUE Case WM_COMMAND Select Case As Const LoWord(wparam) Case 992 If flagfollow=TRUE Then flagfollow=FALSE setWindowText(hbut1,"Exec following") Else flagfollow=TRUE setWindowText(hbut1,"No Exec following") hsrc=richedit(curtab) linenum=sendmessage(hsrc,EM_EXLINEFROMCHAR,0,-1) 'get line number nblines=sendmessage(hsrc,EM_GETLINECOUNT,0,0)-1 fill_focus(linenum,hedit1,hsrc) EndIf Case 993 If linenum>0 Then linenum-=1:fill_focus(linenum,hedit1,hsrc) Case 994 If linenum (0, 0, 4, 8) Dim f As Integer,inc As Integer=32000,wstrg As WString *32001,bufw As UShort Dim As String text Dim As Integer Style = WS_CHILD Or WS_VISIBLE Or ES_WANTRETURN Or WS_VSCROLL Or ES_MULTILINE Or ES_AUTOVSCROLL Dim As String rgvalues(15) '24/08/2015 Static As Byte wrapflag,buf(32004) Static As HWND hedit1 ,hbut Static As Single scalex,scaley Select Case Msg Case WM_INITDIALOG helpbx=hwnd MapDialogRect (hwnd,@rc) ScaleX = rc.right/4 ScaleY = rc.bottom/8 fb_ModStyle(hwnd,0,WS_EX_NOPARENTNOTIFY,1) If helptyp<>5 AndAlso helptyp<>6 Then hEdit1=fb_edit ("",hWnd,101,0*scalex,0*scaley,400*scalex,250*scaley) SendMessage(hedit1,WM_SETFONT,Cast(WPARAM,GetStockObject(ANSI_FIXED_FONT)),0) EndIf If helptyp=1 Then 'threads list For i As Integer =0 To threadnb Dim As Integer thid,p thid=thread(i).id 'text+="ThreadID="+Str(thid)+"/"+hex(thid)+" / Handle="+Str(thread(i).hd)+"/"+hex(thread(i).hd)+" : " text+="ID="+fmt2(Str(thid),4)+"/"+fmt2(Hex(thid),4)+" HD="+fmt2(Str(thread(i).hd),4)+"/"+fmt2(Hex(thread(i).hd),3)+" : " If thread(i).sv<>-1 Then 'thread debugged p=proc_find(thid,KLAST) text+=proc(procr(p).idx).nm If threadhs=thread(i).hd Then text+="(next execution)" Else text+="(not debugged, hidden)" End If text+=Chr(13)+Chr(10) Next SetWindowText(hedit1,StrPtr(text)) ElseIf helptyp=2 Then 'process list Dim prcinfo As PROCESSENTRY32,snap As HANDLE snap=CreateToolhelp32Snapshot (TH32CS_SNAPPROCESS, 0)'Take snapshot of running processes If snap <> INVALID_HANDLE_VALUE Then prcinfo.dwSize=SizeOf(PROCESSENTRY32) text="file Process name ID Nthread parent id"+Chr(13)+Chr(10) If Process32First (snap,@prcinfo) Then Do text+=fmt(prcinfo.szExeFile,20)+fmt(Str(prcinfo.th32ProcessID),5)+fmt(Str(prcinfo.cntThreads),3)+fmt(Str(prcinfo.th32ParentProcessID),5)+Chr(13)+Chr(10) Loop While Process32Next (snap,@prcinfo) Else fb_message("Process list error","Failed to create process list!") End If CloseHandle (snap) End If SetWindowText(hedit1,StrPtr(text)) ElseIf helptyp=3 Then f = FreeFile Open ExePath+"\fbdebug_compil.log" For Binary As #f Get #f,,buf() 'get compilation log Close #f setWindowText(hedit1,@buf(0)) ElseIf helptyp=4 Then 'string zstring inc=32000 f=stringadr While inc<>0 If ReadProcessMemory(dbghand,Cast(LPCVOID,f+inc),@buf(0),4,0) Then f+=inc Exit While Else inc\=2 End If Wend ReadProcessMemory(dbghand,Cast(LPCVOID,stringadr),@buf(0),f-stringadr,0) buf(f-stringadr+1)=0 'end of string if length >32000 setWindowText(hedit1,@buf(0)) hbut=fb_button("Wrapping",hWnd,991, 10*scalex, 250*scaley, 40*scalex, 10*scaley) ElseIf helptyp=5 Then 'wstring hEdit1 = fb_editw (WStr(""),hWnd,101,0*scalex,0*scaley,400*scalex,250*scaley) inc=0:wstrg="" ReadProcessMemory(dbghand,Cast(LPCVOID,stringadr),@bufw,2,0) While bufw wstrg[inc]=bufw inc+=1 If inc=32000 Then Exit While 'limit if wstring >32000 ReadProcessMemory(dbghand,Cast(LPCVOID,stringadr+inc*2),@bufw,2,0) Wend WStrg[inc]=0 'end of wstring SendMessage (hedit1,WM_SETFONT,Cast(WPARAM,fonthdl),0) setwindowtextw(hedit1,wstrg) ElseIf helptyp=6 Then 'enums list enum_show(hwnd) ElseIf helptyp=7 Then 'dlls list For i As Integer=1 To dllnb text+=dlldata(i).fnm If dlldata(i).hdl=0 Then text+=" Currently not used" text+=Chr(13)+Chr(10) Next SetWindowText(hedit1,StrPtr(text)) ElseIf helptyp=8 Then 'shortcut keys list For i As Integer =0 To shcutnb-1 If shcut(i).sccur Then text+=fmt(shcut_txt(shcut(i).sccur,2),18)+menu_gettxt(shcut(i).scmenu,shcut(i).scidnt) text+=Chr(13)+Chr(10) EndIf Next SetWindowText(hedit1,StrPtr(text)) ElseIf helptyp=9 Then 'display asm code line If dissassemble(hedit1,KLINE) Then SendMessage( hwnd,WM_CLOSE,0,0) ElseIf helptyp=10 Then 'display asm code proc from line in source If dissassemble(hedit1,KSPROC) Then SendMessage( hwnd,WM_CLOSE,0,0) ElseIf helptyp=11 Then 'display asm code proc from proc/var tab or proc tab dissassemble(hedit1,KPROC) ElseIf helptyp=12 Then 'show registers '24/08/2015 regs_data(threadcontext,rgvalues())'prepare the lines text="Registers of current thread "+Hex(thread(threadcur).id)+" "+ver3264+Chr(13)+Chr(10)+Chr(13)+Chr(10) #Ifdef __FB_64BIT__ For i As Long = 0 To 15 #Else For i As Long = 0 To 8 #EndIf text+=rgvalues(i)+Chr(13)+Chr(10) Next SetWindowText(hedit1,StrPtr(text)) EndIf fb_ModStyle(hedit1,0,WS_EX_NOPARENTNOTIFY,1) fb_ModStyle(hedit1,WS_VSCROLL Or WS_HSCROLL,0) SendMessage(hedit1,EM_SETREADONLY,TRUE,0) ' just for test 'CAUTION it's displayed behind the edit area so change the y coordinate 'Static MyhBmp as HBITMAP ' MyhBmp = fb_LOADBMP("toolbar2.bmp") ' Case WM_PAINT ' ' static ps AS PAINTSTRUCT ' static hdc AS long ' static hdcMem AS long ' hdc = BeginPaint (hWnd, @ps) ' hdcMem = CreateCompatibleDC (hdc) ''----------------------------------- ' SelectObject (hdcMem, MyhBmp) ' ' ' ''''''StretchBlt (hdc,1,1,L,H,hdcMem,0,0,L0,H0,SRCCOPY) ' bitblt(hdc,100,100,396,16,hdcMem,0,0,SRCCOPY) ''----------------------------------- ' DeleteDC (hdcMem) ' EndPaint (hWnd,@ps) ' 'end of test Case WM_COMMAND If LoWord(wparam)=991 Then destroywindow (hedit1) If wrapflag Then hEdit1=fb_edit ("",hWnd,101,0*scalex,0*scaley,400*scalex,250*scaley) wrapflag=0 setWindowText(hbut,"Wrapping") Else hEdit1=fb_edit ("",hWnd,101,0*scalex,0*scaley,400*scalex,250*scaley,style) wrapflag=1 setWindowText(hbut,"No Wrapping") EndIf SendMessage(hedit1,EM_SETREADONLY,TRUE,0) fb_ModStyle(hedit1,0,WS_EX_NOPARENTNOTIFY,1) fb_ModStyle(hedit1,WS_VSCROLL Or WS_HSCROLL,0) setWindowText(hedit1,@buf(0)) EndIf Return TRUE Case WM_CLOSE helpbx=0 destroywindow(hwnd) Return TRUE End Select End Function private function tuto_box(ByVal hWnd As HWND,ByVal Msg As UInteger,ByVal wparam As Integer,ByVal lParam As Integer) As Integer Dim rc As RECT => (0, 0, 4, 8) Dim As Single scalex,scaley Dim bg As Integer,ZStr As ZString Ptr Static hedit1 As HWND,cpt As Integer,buf(100000) As Byte,f As Integer,l As Integer Select Case Msg Case WM_INITDIALOG 'All of your controls are created here in the same tutobx=hwnd MapDialogRect (hwnd,@rc) ScaleX = rc.right/4 ScaleY = rc.bottom/8 fb_ModStyle(hwnd,0,WS_EX_NOPARENTNOTIFY,1) ' fb_label(inputtxt,hwnd,100,2*scalex,2*scaley,150*scalex,10*scaley,SS_LEFT) hEdit1 = fb_edit ("",hWnd,101,8*scalex,1*scaley,300*scalex,50*scaley) fb_ModStyle(hedit1,0,WS_EX_NOPARENTNOTIFY,1) setwindowtext(hedit1,"Begin tutorial, click on button NEXT for next step"+Chr(13)+Chr(10)+"Click on button HELP for help on some part of screen") SendMessage(hedit1,EM_SETREADONLY,TRUE,0) fb_button("Next",hWnd,103,8*scalex, 51*scaley, 36*scalex, 10*scaley) fb_button("Help",hWnd,104,78*scalex, 51*scaley, 36*scalex, 10*scaley) cpt=1 'first instruction flagtuto=1 If Dir(ExePath+"\tutorial.txt")="" Then fb_message("Launching tutorial","""File "+ExePath+"\tutorial.txt"" not found"+Chr(13)+Chr(10)+" can't continue tutorial.") sendmessage(hwnd,WM_close,0,0) Return 0 EndIf Clear(buf(0),0,100000) f = FreeFile Open ExePath+"\tutorial.txt" For Binary As #f l=Lof(f) If l>100000 Then fb_message("Launching tutorial","""File "+ExePath+"\tutorial.txt"" too large ("+Str(l)+">"+Str(100000)+") not loaded"+Chr(13)+Chr(10)+"Can't continue tutorial.") Close #f sendmessage(hwnd,WM_close,0,0) Return 0 Else Get #f,,buf() 'get source End If Close #f f=0 If Dir(ExePath+"\tutorial.exe")="" Then 'tutorial.exe fb_message("Launching tutorial","""File "+ExePath+"\tutorial.exe"" not found."+Chr(13)+Chr(10)+" can't continue tutorial.") sendmessage(hwnd,WM_close,0,0) Return 0 EndIf Case WM_COMMAND Select Case LoWord(wparam) Case 103 'next bg=f 'get text While f (0, 0, 4, 8) Dim As Single scalex,scaley dim as integer p2,typtemp Static As HWND hedit1,hedit2,hbutdel,hbutapl,hbutdmp Static adr As UInteger,vflag As Integer Dim edt As valeurs,tvi As TVITEM,aptr As UInteger,vald As Double Select Case Msg Case WM_INITDIALOG If (varfind.ty=4 Or varfind.ty=13 Or varfind.ty=14 Or varfind.ty=15) And varfind.pt=0 Then fb_message("Edit variable error","Select only a numeric variable"+Chr(13)+"For string use change with dump") var_dump(varfind.tv) enddialog(hwnd,0):Exit Function End If If varfind.ty>TYPESTD And varfind.pt=0 And udt(varfind.ty).en=0 Then '20/08/2015 fb_message("Edit variable error","Select only a numeric variable") enddialog(hwnd,0):Exit Function End If MapDialogRect (hwnd,@rc) ScaleX = rc.right/4 ScaleY = rc.bottom/8 fb_ModStyle(hwnd,0,WS_EX_NOPARENTNOTIFY,1) tvI.mask = TVIF_TEXT tvI.pszText = @(txt) tvI.hitem = varfind.tl tvI.cchTextMax = 300 SendMessage(varfind.tv,TVM_GETITEM,0,Cast(LPARAM,@tvi)) fb_Label (txt,hWnd,101,2*scalex,2*scaley,250*scalex,10*scaley) txt=Mid(txt,InStr(txt,"=")+1,25) If varfind.ty=16 Then 'boolean txt=IIf(txt="False","0","1") EndIf hEdit1=fb_edit (Str(Val(txt)),hWnd,101,275*scalex,2*scaley,70*scalex,10*scaley) fb_ModStyle(hedit1,0,WS_EX_NOPARENTNOTIFY,1) fb_ModStyle(hedit1,,WS_VSCROLL,0) SetFocus(hedit1) SendMessage(hedit1,EM_SETSEL,0,-1) If varfind.pt Then 'pointer If varfind.pt>220 Then p2=varfind.pt-220 ElseIf varfind.pt>200 Then p2=varfind.pt-200 Else p2=varfind.pt End If aptr=varfind.ad For j As Integer = 1 To p2 'only the last pointer is displayed ReadProcessMemory(dbghand,Cast(LPCVOID,aptr),@aptr,SizeOf(Integer),0) '27/06/2015 64bit fb_Label (Str(aptr),hWnd,101,2*scalex,20*scaley,50*scalex,10*scaley) Next adr=aptr If adr Then 'if null address don't do anything If varfind.pt>200 Then fb_Label (proc_name(adr),hWnd,101,65*scalex,20*scaley,150*scalex,10*scaley) 'proc name Else txt=var_sh2(varfind.ty,adr) txt=Mid(txt,InStr(txt,"=")+1,90) If varfind.ty=16 Then 'boolean txt=iif(txt="False","0","1") EndIf fb_Label (txt,hWnd,101,65*scalex,20*scaley,150*scalex,10*scaley) 'pointed value End If If (varfind.ty<>4 And varfind.ty<>13 And varfind.ty<>14 And varfind.ty<>15 And varfind.pt<200) Or udt(varfind.ty).en Then hEdit2=fb_edit (Str(Val(txt)),hWnd,101,275*scalex,20*scaley,70*scalex,10*scaley) fb_ModStyle(hedit2,,WS_VSCROLL,0) End If hButdmp=fb_button("Ptr dump",hWnd,3, 130*scalex, 32*scaley, 36*scalex, 10*scaley) fb_ModStyle(hbutdel,0,WS_EX_NOPARENTNOTIFY,1) Else fb_Label ("Null address, Nothing to display",hWnd,101,65*scalex,20*scaley,150*scalex,10*scaley) End If End If hButapl = fb_button("Apply",hWnd,1,170*scalex, 32*scaley, 36*scalex, 10*scaley) fb_ModStyle(hbutapl,0,WS_EX_NOPARENTNOTIFY,1) hButdel=fb_button("Cancel",hWnd,2, 210*scalex, 32*scaley, 36*scalex, 10*scaley) fb_ModStyle(hbutdel,0,WS_EX_NOPARENTNOTIFY,1) vflag=0 If udt(varfind.ty).en Then varfind.ty=7 'enum treated as integer, here just for control Case WM_COMMAND Select Case lparam Case hButapl 'clicked apply If HiWord(wparam)=BN_CLICKED Then If vflag Then If vflag=1 Then If varfind.pt Then varfind.ty=8 Else varfind.ad=adr EndIf Select Case varfind.ty Case 2,16 '20/082015 boolean edt.vbyte=ValInt(txt) :p2=1 Case 3 edt.vubyte=ValUInt(txt) :p2=1 Case 5 edt.vshort=ValInt(txt) :p2=2 Case 6 edt.vushort=ValUInt(txt) :p2=2 Case 1 edt.vinteger=ValInt(txt) :p2=4 Case 7 '27/07/2015 64bit #Ifdef __FB_64BIT__ edt.vulinteger=ValULng(txt) :p2=8 #Else edt.vuinteger=ValUInt(txt) :p2=4 #EndIf Case 8 edt.vuinteger=ValUInt(txt) :p2=4 Case 9 edt.vlinteger=ValLng(txt) :p2=8 Case 10 edt.vulinteger=ValULng(txt) :p2=8 Case 11 edt.vsingle=Val(txt) :p2=4 Case 12 edt.vdouble=Val(txt) :p2=8 Case Else '27/07/2015 64bit #Ifdef __FB_64BIT__ edt.vulinteger=ValULng(txt) :p2=8 #Else edt.vuinteger=ValUInt(txt) :p2=4 #EndIf End Select writeprocessmemory(dbghand,Cast(LPVOID,varfind.ad),@edt,p2,0) var_sh() dump_sh() enddialog(hwnd,0) End If End If Case hButdel 'clicked delete If HiWord(wparam)=BN_CLICKED Then enddialog(hwnd,0) End If Case hedit1,hedit2 ' If HiWord(wparam)=EN_CHANGE Then If lparam=hedit1 Then vflag=1 sendmessage(hedit1,WM_GETTEXT,25,Cast(LPARAM,@txt)) Else vflag=2 sendmessage(hedit2,WM_GETTEXT,25,Cast(LPARAM,@txt)) End If vald=Val(txt) If varfind.pt Then typtemp=7 Else typtemp=varfind.ty EndIf Select Case As Const typtemp Case 2 If vald<-128 Or vald>127 Then setwindowtext(hwnd,"min -128,max 127"):vflag=0 Case 3 If vald<0 Or vald>255 Then setwindowtext(hwnd,"min 0,max 255"):vflag=0 Case 5 If vald<-32768 Or vald>32767 Then setwindowtext(hwnd,"min -32768,max 32767"):vflag=0 Case 6 If vald<0 Or vald>65535 Then setwindowtext(hwnd,"min 0,max 65535"):vflag=0 Case 1 If vald<-2147483648 Or vald>2147483648 Then setwindowtext(hwnd,"min -2147483648,max +2147483647"):vflag=0 Case 7 #Ifdef __FB_64BIT__ '27/07/2015 If Vald<0 Or vald>18446744073709551615 Then setwindowtext(hwnd,"min 0,max 18446744073709551615"):vflag=0 #Else If vald<0 Or vald>4294967395 Then setwindowtext(hwnd,"min 0,max 4294967395"):vflag=0 #EndIf Case 8 If vald<0 Or vald>4294967395 Then setwindowtext(hwnd,"min 0,max 4294967395"):vflag=0 Case 9 If Vald<-9223372036854775808 Or vald>9223372036854775807 Then setwindowtext(hwnd,"min -9223372036854775808,max 9223372036854775807"):vflag=0 Case 10 If Vald<0 Or vald>18446744073709551615 Then setwindowtext(hwnd,"min 0,max 18446744073709551615"):vflag=0 Case 16 If vald>1 or vald<-1 Then SetWindowText(hwnd,"Authorized value only 0 or 1"):vflag=0 End Select End If Case hbutdmp lvtyp=varfind.ty:dumpadr=adr Select Case lvtyp Case 13 'string lvtyp=2 'default for string ReadProcessMemory(dbghand,Cast(LPCVOID,dumpadr),@dumpadr,SizeOf(Integer),0)'string address 27/07/2015 Case 4,14 'f or zstring lvtyp=2 Case Is>TYPESTD '20/08/2015 replaced 15 by TYPESTD lvtyp=8 'default for pudt and any End Select dump_set(listview1) dump_sh() enddialog(hwnd,0) End Select Case WM_CLOSE enddialog(hwnd,0) Return 0 'not really used End Select End Function '====================================================================== private sub load_sources(n As Integer) Dim l As Integer,f As Integer,buf(MAXSRCSIZE) As UByte Dim As String gen(2)={" (AS)"," (CS)"," (CD)"} If flagrestart=-1 Then For i As Integer=n To sourcenb ' main index =0 If FileExists(source(i))=0 Then fb_message("Loading Source error","File : "+source(i)+" not found",MB_ICONERROR Or MB_SYSTEMMODAL):Continue For Clear(buf(0),0,MAXSRCSIZE) f = FreeFile Open source(i) For Binary As #f l=Lof(f) If l>MAXSRCSIZE Then fb_message("Loading Source error","File : "+source(i)+" too large ("+Str(l)+">"+Str(MAXSRCSIZE)+") not loaded",MB_ICONERROR) Else Get #f,,buf() 'get source End If Close #f ''01/12/2014 SendMessage(richedit(i),EM_EXLIMITTEXT,0,l+10000) 'put file size 'If buf(0)=&hEF AndAlso buf(1)=&hBB AndAlso buf(2)=&hBF Then 'UTF8 ' 'fb_message("","UTF8 "+hex(buf(0))+" "+hex(buf(1))+" "+hex(buf(2))) ' srcunicode(i)=1 ' 'setWindowTextW(richedit(i),CPtr(UShort ptr,@buf(3))) 'ElseIf (buf(0)=&hFE AndAlso buf(1)=&hFF) OrElse (buf(0)=&hFF AndAlso buf(1)=&hFE) Then 'UTF16 FE or ' srcunicode(i)=1 ' 'setWindowTextW(richedit(i),CPtr(UShort ptr,@buf(2))) 'ElseIf (buf(0)=&h00 AndAlso buf(1)=&h00 andalso buf(2)=&hFE AndAlso buf(3)=&hFF) _ 'OrElse (buf(0)=&hFF AndAlso buf(1)=&hFE AndAlso buf(2)=&h00 AndAlso buf(3)=&h00) Then 'UTF32 ' srcunicode(i)=1 ' 'setWindowTextW(richedit(i),CPtr(UShort ptr,@buf(4))) 'Else 'ascii ' srcunicode(i)=0 ' 'setWindowText(richedit(i),@buf(0)) 'EndIf setWindowText(richedit(i),@buf(0)) tab_add(i,htab1,LCase(name_extract(source(i)))+gen(srccomp(i))) If FileDateTime (source(i))>exedate Then fb_message("Loading source file","WARNING Date of "+source(i)+Chr(10)+Chr(13)+" is > date of exe "+exename,MB_ICONWARNING Or MB_SYSTEMMODAL) EndIf Next EnableMenuItem(menutools,IDHIDLOG,MF_GRAYED) 'log file tab canceled so option menu grayed If hgltflag Then hglt_lines(n,sourcenb) Else 'restart with same exe, only the main files are not loaded, dll sources are removed For i As Integer=sourcenb+1 To flagrestart setWindowText(richedit(i),""):ShowWindow(richedit(i),SW_HIDE)'hide all the exceding windows (>sourcenb) sendmessage(htab1,TCM_DELETEITEM ,i,0) 'delete tabs Next flagrestart=-1 EndIf If n Then Exit Sub 'no need to execute next lines 'curtab=dbgmain NOTA 'dbg_prt2("DBGMAIN="+Str(dbgmain)+" "+source(dbgmain)) exrichedit(0) menu_update(IDCMPNRUN,"Compile and run "+dbgsrc) For j As Integer =0 To procnb 'As .nu not consistent for main Dim As UInteger temp=proc(j).db If proc(j).nm="main" Then For i As Integer =1 To linenb If rline(i).ad>temp Then 'found first line of main proc(j).nu=rline(i).nu:rlineold=i Exit For,For EndIf Next End If Next End Sub private function check_source(sourcenm As String) As Integer ' check if source yet stored For i As Integer=0 To sourcenb If source(i)=sourcenm Then Return i 'found Next Return -1 'not found End Function private sub save_source() Dim f As Integer,buf As ZString *200000,a As Integer,bufp As ZString Ptr getWindowText(dbgrichedit,@buf,199999) For a=0 To 199999 If buf[a]=0 Then Exit For Next Kill dbgsrc f = FreeFile bufp=@buf Open dbgsrc For Binary Access write As #f Put #f,,bufp[0],a-1 'write source Close #f End Sub '=============================================================== private sub log_show() Dim f As Integer,buffer As Byte Ptr, l As Integer,flaguse As Integer If (flaglog And 2) Then 'close if needed flaglog And=1 dbg_prt(" $$$$___CLOSE ALL___$$$$ ") flaguse=1 EndIf If Dir(ExePath+"\dbg_log_file.txt")="" Then fb_message("Display dbg_log_file.txt","File doesn't exist") Exit Sub EndIf f = FreeFile Open ExePath+"\dbg_log_file.txt" For Binary As #f l=Lof(f)+1 buffer = Allocate(l) If buffer=0 Then Close #f fb_message("Display dbg_log_file.txt","Unable to allocate memory") Exit Sub EndIf Get #f,,*buffer,l-1 'get file Close #f *(buffer+l-1)=0 'null-terminated string SendMessage(richedit(sourcenb+1),EM_EXLIMITTEXT,0,l) SetWindowText(richedit(sourcenb+1),buffer) DeAllocate(buffer) source(sourcenb+1)="Log file" EnableMenuItem(menutools,IDHIDLOG,MF_ENABLED) 'enable option menu l=SendMessage(htab1,TCM_GETITEMCOUNT,0,0) If l>sourcenb+1 Then SendMessage(htab1,TCM_DELETEITEM,l-1,0)'To avoid adding of another empty tab named also log file tab_add(sourcenb+1,htab1,LCase(name_extract(source(sourcenb+1)))) exrichedit(sourcenb+1) If flaguse Then flaglog Or=2 End Sub private sub log_hide() Dim As Integer l=SendMessage(htab1,TCM_GETITEMCOUNT,0,0) 'If l>sourcenb+1 Then 'log file currently displayed SendMessage(htab1,TCM_DELETEITEM,l-1,0) 'remove tab If sourcenb=-1 Then 'only log file showWindow(richedit(sourcenb+1),SW_HIDE) 'to hide Else exrichedit(sourcenb) 'to show first file EndIf EnableMenuItem(menutools,IDHIDLOG,MF_GRAYED) 'End If End Sub private function prep_debug(fname As String) As String Dim As Integer pst Dim As String exenm 'start compilation If fbcexe<>"" Then ''start compile, log in fbcompil.log pst=InStr(fname,"."):If pst=0 Then pst=999 exenm=Left(fname,pst)+"exe" If Dir(exenm)<>"" Then Kill exenm Shell(""""""+fbcexe+""""+" -v -w 1 -g "+cmdlfbc+" """+fname+""""+" >"""+ExePath+"\fbdebug_compil.log""") If Dir(exenm)="" Then If helpbx Then destroywindow(helpbx) helptyp=3 fb_Dialog(@help_box,"Exe not created : Compilation log",windmain,2,2,400,250) Return "" Else 'fb_message("Compilation ok","start debugging...") Return exenm End If Else fb_message("Compilation error","[FBC]= not in fbdebugger.ini") Return "" End If End Function '====================================================================== private sub ini_read() Dim filein As Integer,lineread As String, c As Integer=-1,w As Integer,b As Integer Dim As Long lft,top,rgt,bot,p,q If Dir(ExePath+"\fbdebugger.ini")="" Then 'fb_message("Init Error","fbdebugger.ini doesn't exist"+chr(10)+"compilation impossible") Exit Sub End If Filein = FreeFile Open ExePath+"\"+"fbdebugger.ini" For Input As #Filein Do While Not Eof(Filein) Line Input #filein,lineread If Left(lineread,6)="[FBC]=" Then lineread=RTrim(Mid(lineread,7)) If InStr(LCase(lineread),"fbc.exe")=0 Then lineread+=".exe" If Dir(lineread)="" Then fb_message("Specified compiler:", lineread + chr(10) + "Not found !") ' (BE) Else fbcexe=lineread End If elseIf Left(lineread,6)="[FCD]=" Then cmdlfbc=RTrim(Mid(lineread,7)) ElseIf Left(lineread,6)="[IDE]=" Then lineread=RTrim(Mid(lineread,7)) If InStr(LCase(lineread),".exe")=0 Then lineread+=".exe" If Dir(lineread)="" Then fb_message("Specified IDE/Editor:", lineread + chr(10) + "Not found !") '(BE) Else ideexe=lineread menu_update(IDFILEIDE,"Launch "+ideexe) End If ElseIf Left(lineread,6)="[EXE]=" Then lineread=RTrim(Mid(lineread,7)) If Dir(lineread)<>"" And InStr(LCase(lineread),".exe") Then c+=1 savexe(c)=lineread:cmdexe(c)="" w=-1:b=0 EndIf ElseIf Left(lineread,6)="[CMD]=" Then cmdexe(c)=RTrim(Mid(lineread,7)) ElseIf Left(lineread,6)="[WTC]=" Then w+=1 wtchexe(c,w)=RTrim(Mid(lineread,7)) ElseIf Left(lineread,6)="[BRK]=" Then b+=1 brkexe(c,b)=RTrim(Mid(lineread,7)) ElseIf Left(lineread,6)="[TTP]=" Then If RTrim(Mid(lineread,7,999))="TRUE" Then flagtooltip=TRUE Else flagtooltip=FALSE EndIf 'activate or inactive the tooltips sendmessage (fb_hToolTip,TTM_ACTIVATE, Cast(WPARAM,flagtooltip),0) ElseIf Left(lineread,6)="[FTN]=" Then font_change(RTrim(Mid(lineread,7))) ElseIf Left(lineread,6)="[FTS]=" Then font_change(,ValInt(RTrim(Mid(lineread,7)))) ElseIf Left(lineread,6)="[DPO]=" Then dspofs=ValInt(RTrim(Mid(lineread,7))) ElseIf Left(lineread,6)="[JIT]=" Then jitprev=RTrim(Mid(lineread,7)) ElseIf Left(lineread,6)="[HLK]=" Then If RTrim(Mid(lineread,7))="TRUE" Then hgltflag=TRUE Else hgltflag=FALSE EndIf ElseIf Left(lineread,6)="[CRE]=" Then 'color richedit clrrichedit=ValInt(RTrim(Mid(lineread,7))) For i As Integer=0 To MAXSRC sendmessage(richedit(i),EM_SETBKGNDCOLOR,0,clrrichedit) Next ElseIf Left(lineread,6)="[CRK]=" Then 'color highlighted keywords clrkeyword=ValInt(RTrim(Mid(lineread,7))) ElseIf Left(lineread,6)="[CCL]=" Then 'color current line clrcurline=ValInt(RTrim(Mid(lineread,7))) ElseIf Left(lineread,6)="[CTB]=" Then 'color tempo breakpoint clrtmpbrk=ValInt(RTrim(Mid(lineread,7))) ElseIf Left(lineread,6)="[CPB]=" Then 'color perm breakpoint clrperbrk=ValInt(RTrim(Mid(lineread,7))) ElseIf Left(lineread,6)="[LOG]=" Then 'type of log flaglog=ValInt(RTrim(Mid(lineread,7))) ElseIf Left(lineread,6)="[FLT]=" Then 'flagtrace 07/04/2014 flagtrace=ValInt(RTrim(Mid(lineread,7))) ElseIf Left(lineread,6)="[PST]=" Then 'type of proc sort procsort=ValInt(RTrim(Mid(lineread,7))) ElseIf Left(lineread,6)="[SCK]=" Then 'shcut keys shcut_ini(RTrim(Mid(lineread,7))) ElseIf Left(lineread,6)="[WND]=" Then 'restore position/size of main window '15/09/2015 lineread=RTrim(Mid(lineread,7)) p=1:q=InStr(lineread,",") lft=ValInt(Mid(lineread,p,q-p)) p=q+1:q=InStr(p,lineread,",") top=ValInt(Mid(lineread,p,q-p)) p=q+1:q=InStr(p,lineread,",") rgt=ValInt(Mid(lineread,p,q-p)) p=q+1 bot=ValInt(Mid(lineread,p)) '' and modify values to avoid issue with display if erroneus values (negative) If lft(GetSystemMetrics(SM_XVIRTUALSCREEN)+GetSystemMetrics(SM_CXVIRTUALSCREEN)) Then lft=GetSystemMetrics(SM_XVIRTUALSCREEN) If (rgt-lft)<700 Then rgt=700+lft If top(GetSystemMetrics(SM_YVIRTUALSCREEN)+GetSystemMetrics(SM_CYVIRTUALSCREEN)) Then top=GetSystemMetrics(SM_yVIRTUALSCREEN) If (bot-lft)<500 Then bot=500+top SetWindowPos(windmain,HWND_NOTOPMOST,lft,top,rgt-lft,bot-top,SWP_NOACTIVATE Or SWP_FRAMECHANGED) dsptyp=0 dsp_size SetWindowPos(windmain,HWND_NOTOPMOST,lft,top,rgt-lft,bot-top,SWP_NOACTIVATE Or SWP_FRAMECHANGED) End If Loop Close #Filein exename=savexe(0) fb_UpdateTooltip(fb_hToolTip,butrrune,"Restart "+exename,"",0) 'crc_init() 'for checksum End Sub '======== init ========================================= private sub re_ini() prun=FALSE runtype=RTOFF brkv.adr=0 'no break on var brknb=0 'no break on line brkol(0).ad=0 'no break on cursor setwindowtext(hcurline,"") setwindowtext(brkvhnd,"Break on var") setwindowtext(windmain,"DEBUG "+ver3264) SendMessage(listview1,LVM_DELETEALLITEMS,0,0) 'dump SendMessage(tviewvar,TVM_DELETEITEM,0,Cast(LPARAM,TVI_ROOT)) 'procs/vars SendMessage(tviewprc,TVM_DELETEITEM,0,Cast(LPARAM,TVI_ROOT)) 'procs SendMessage(tviewthd,TVM_DELETEITEM,0,Cast(LPARAM,TVI_ROOT)) 'threads ShowWindow(tviewcur,SW_HIDE):tviewcur=tviewvar:ShowWindow(tviewcur,SW_SHOW) SendMessage(htab2,TCM_SETCURSEL,0,0) If dsptyp Then dsp_hide(dsptyp) dsp_sizecalc threadnb=-1 If flagrestart=-1 Then 'add test for restart without loading again all the files setwindowtext(dbgrichedit,"Your source") sendmessage(htab1,TCM_DELETEALLITEMS ,0,0) 'zone tab For i As Integer=0 To MAXSRC:setWindowText(richedit(i),""):ShowWindow(richedit(i),SW_HIDE):Next Else sel_line(curlig-1,0,1,richedit(curtab),FALSE) 'default color EndIf curlig=0 sourcenb=-1:dllnb=0 vrrnb=0:procnb=0:procrnb=0:linenb=0:cudtnb=0:arrnb=0:procr(1).vr=1:procin=0:procfn=0:procbot=0:proctop=FALSE proc(1).vr=VGBLMAX+1 'for the first stored proc excldnb=0 dumpadr=0:copybeg=-99:copyend=-99:copycol=-99 '23/11/2014 'flaglog=0:dbg_prt(" $$$$___CLOSE ALL___$$$$ "):flagtrace=0 flagmain=TRUE:flagattach=FALSE:flagkill=FALSE udtcpt=0:udtmax=0 For i As Integer = 0 To 4 :SendMessage(dbgstatus,SB_SETTEXT,i,Cast(LPARAM,@"")) : Next '08/04/2014 3-->4 vrbgbl=0:vrbloc=VGBLMAX:vrbgblprev=0 udtbeg=TYPESTD+1:cudtbeg=1:locbeg=VGBLMAX+1:vrbbeg=1:prcbeg=1 'dwarf 20/08/2015 boolean bx_closing array_tracking_remove 'reset bookmarks sendmessage(bmkh,CB_RESETCONTENT,0,0) bmkcpt=0:For i As Integer =1 To BMKMAX:bmk(i).ntab=-1:Next EnableMenuItem(menuedit,IDNXTBMK,MF_GRAYED) EnableMenuItem(menuedit,IDPRVBMK,MF_GRAYED) EnableMenuItem(menutools,IDHIDLOG,MF_GRAYED) compinfo="" 'information about compilation threadprv=0 threadsel=0 hgltmax=20000 'for highlighting keywords hgltpt=0 ReDim hgltdata(hgltmax) As tmodif ReDim Trans(70000) Trans(1)="1" Trans(2)="2" Trans(3)="1" Trans(4)="8" Trans(5)="8" Trans(6)="9" Trans(7)="10" Trans(8)="5" Trans(9)="6" Trans(10)="2" Trans(11)="3" Trans(12)="11" Trans(13)="12" Trans(18)="7" Trans(19)="2" Trans(20)="3" Trans(21)="5" Trans(22)="6" Trans(23)="1" Trans(24)="8" Trans(25)="9" Trans(26)="10" For i As Long =TYPESTD+1 To TYPEMAX 'reinit index to avoid message udt nok when executing an other debuggee, only gcc 16/08/2015 20/08/2015 boolean udt(i).typ=0 Next End Sub '================================================================ private sub treat_file(f As String) Dim As String ffinal,cmdline=cmdexe(0) Dim As Integer p If prun AndAlso kill_process("Trying to launch but debuggee still running")=FALSE Then Exit Sub End If re_ini() 'init all If f="£$_NO$FILE_$£" Then 'call by button files ffinal=fb_GetFileName("Select Exe file","pgm *.exe or .bas|*.exe;*.bas||",0,0,0,"") ElseIf f="" Then 'Fbdebugger launched by shell eventually with parameters p=InStr(Command,".exe") If p Then 'fbdebugger .exe param 1 param2 ffinal=Left(Command,p+3) If InStr(ffinal,":")=0 Then ffinal=ExePath+"\"+ffinal '31/07/2015 case short name of exe, without disk/folder name cmdline=Trim(Mid(Command,p+4)) Else p=InStr(Command,".bas") If p Then 'fbdebugger .bas compilparam ffinal=Left(Command,p+3) cmdlfbc=Trim(Mid(Command,p+4)) Else p=InStr(Command,"-p") If p<>0 And InStr(Command,"-e")<>0 And InStr(Command,"-g")<>0 Then 'started by dbgprocid=ValInt(Mid(Command,P+3)) p=InStr(p+3,Command,"-e") p=ValInt(Mid(Command,P+3)) hattach=Cast(HANDLE,p) ThreadCreate(@dbg_attach) Exit Sub EndIf EndIf EndIf Else ffinal=f End If ffinal=Trim(ffinal) #Ifdef fulldbg_prt dbg_prt (ffinal) #EndIf If ffinal="" Or Dir(ffinal)="" Then fb_message("File error","No file or "+ffinal+" doesn't exist") Exit Sub ElseIf Right(ffinal,4)<>".exe" Then ffinal=prep_debug(ffinal)'exe name If ffinal="" Then Exit Sub 'unsuccesfull compilation If fb_message("Ready to debug","Launch file --> "+ffinal,MB_YESNO Or MB_ICONQUESTION)<>IDYES Then Exit Sub EndIf End If exename=ffinal exe_sav(exename,cmdline) If ThreadCreate(@start_pgm)=0 Then fb_message("ERROR unable to start the thread managing the debuggee","Debuggee not running",MB_SYSTEMMODAL Or MB_ICONSTOP ) EndIf End Sub private sub exe_sav(exename As String,cmdline As String) Dim As Integer c Dim As Double tempdate=FileDateTime(exename) If flagwtch=0 OrElse exedate<>tempdate Then watch_del() EndIf exedate=tempdate For i As Integer =0 To 8 If savexe(0)<>exename Then Swap savexe(0),savexe(c) Swap cmdexe(0),cmdexe(c) For j As Integer=0 To WTCHMAX Swap wtchexe(0,j),wtchexe(c,j) Next For j As Integer=0 To BRKMAX Swap brkexe(0,j),brkexe(c,j) Next c+=1 Else Exit For End If Next savexe(0)=exename If cmdline<>"" Then cmdexe(0)=cmdline fb_UpdateTooltip(fb_hToolTip,butrrune,"Restart "+exename,"",0) setwindowtext(windmain,"Debugging "+ver3264+exename) End Sub '============== private sub ide_launch() Dim pclass As Integer,st As Integer Dim As String workdir,cmdl Dim sinfo As STARTUPINFO If ideexe="" Then fb_message("Launch Ide error","[IDE]= not defined") Exit Sub End If If dbgsrc="" Or Dir(dbgsrc)="" Then fb_message("Launch Ide error","No source") Exit Sub End If fb_message("Ready to edit","file : "+dbgsrc) st=0 While InStr(st+1,ideexe,"\") st=InStr(st+1,ideexe,"\") Wend workdir=Left(ideexe,st) cmdl=""""+ideexe For i As Byte =0 To sourcenb cmdl+=""" """+source(i) Next cmdl+="""" sinfo.cb = Len(sinfo) 'Set the flags sinfo.dwFlags = STARTF_USESHOWWINDOW 'Set the window's startup position sinfo.wShowWindow = SW_SHOWDEFAULT 'Set the priority class pclass = NORMAL_PRIORITY_CLASS Or CREATE_NEW_CONSOLE 'Start the program CreateProcess(ideexe,StrPtr(cmdl),ByVal NULL,ByVal NULL, FALSE, pclass, _ NULL, WorkDir, @sinfo, @pinfo) End Sub '=============================================== private sub crc_init() 'initialisation for checksum Dim i As Integer,j As Integer,value As Integer For i=0 To 255 value=i For j=0 To 7 If (value And 1) Then value=(value Shr 1) Xor &hEDB88320 Else value=(value Shr 1) EndIf Next crc_table(i)=value Next End Sub '-------------------------- private function crc_string(txt As String) As Integer Dim vbyte As Byte,crc As Integer,i As Integer,size As Integer crc=&hFFFFFFFF size=Len(txt) For i=1 To size vbyte=Asc(Mid(txt,i,1)) crc=(crc Shr 8) Xor crc_table(vbyte Xor (crc And &hFF)) Next Return crc End Function '--------------------------- private function crc_bank(bank As Integer,size As Integer) As Integer Dim vbyte As Byte,crc As Integer,i As Integer crc=&hFFFFFFFF For i=0 To size-1 vbyte=Peek (Byte,bank+i) crc=(crc Shr 8) Xor crc_table(vbyte Xor (crc And &hFF)) Next Return crc End Function '--------------------------------- private function crc_file(fname As String) As String Dim vbyte As Byte ,crc As Integer,filein As Integer crc=&hFFFFFFFF filein=FreeFile If Dir(fname)="" Then Print "No file ";fname:Exit Function Open fname For Binary Access Read As filein Do While Not Eof(filein) Get #filein,,vbyte crc=(crc Shr 8) Xor crc_table(vbyte Xor (crc And &hFF)) Loop Close filein Return Right("00000000"+Hex(crc),8) End Function '============================== private sub winmsg()' winmessage Dim Buffer As String*210 inputval="" inputtyp=5 fb_MDialog(@input_box,"Window message number",windmain,283,25,90,30) If inputval<>"" Then 'Format the message string FormatMessage FORMAT_MESSAGE_FROM_SYSTEM, ByVal 0,ValInt(inputval) , LANG_NEUTRAL, Buffer, 200, ByVal 0 fb_message("Windows message","Code : "+inputval+Chr(10)+"Message : "+buffer) End If End Sub '=============================== private sub dechexbin() 'dec/hex/bin inputval="" inputtyp=99 fb_MDialog(@input_box,"Input value HEX(&h) or DEC",windmain,283,25,90,30) If inputval<>"" Then fb_message("Value in dec, hex and bin","Dec= "+Str(Val(inputval))+Chr(10)+"Hex="+Hex(Val(inputval))+Chr(10)+"Bin="+Bin(Val(inputval))) End If End Sub private sub compinfo_sh Dim cdata(3) As String Dim As UInteger p,q If compinfo="" Then fb_message("No information about compilation or no progam loaded","Just add this line anywhere"+Chr(13)+"const FDBG_COMPIL_INFO As String=""$$__COMPILINFO__$$""+__FB_VERSION__+""/""+__FB_BUILD_DATE__+""/""+__FB_BACKEND__+""/""+__DATE__+"" ""+__TIME__)") Exit Sub EndIf p=InStr(compinfo,"/") cdata(0)="version number of the compiler : "+Mid(compinfo,19,p-19) q=InStr(p+1,compinfo,"/") cdata(1)="build date : "+Mid(compinfo,p+1,q-p-1) p=q q=InStr(p+1,compinfo,"/") cdata(2)="backend : "+Mid(compinfo,p+1,q-p-1) cdata(3)="debuggee compilation date : "+Mid(compinfo,q+1,19) fb_message("Compilation Information",cdata(0)+Chr(13)+cdata(1)+Chr(13)+cdata(2)+Chr(13)+cdata(3)) End Sub private sub line_goto() 'Goto line Dim Linenb As Integer inputval="" inputtyp=99 linenb=SendMessage(dbgrichedit,EM_EXLINEFROMCHAR,0,-1)+1 'get line zero based fb_MDialog(@input_box,"Current line "+Str(linenb)+", Goto line ?",windmain,283,25,90,30) Linenb=ValInt(inputval)-1 If linenb>=0 Then sel_line(linenb) End If End Sub private sub line_adr() 'address of cursor on line in memory Dim l As Integer,i As Integer,range As charrange,b As Integer range.cpmin=-1 :range.cpmax=0 sendmessage(dbgrichedit,EM_exsetsel,0,Cast(LPARAM,@range)) 'deselect l=sendmessage(dbgrichedit,EM_EXLINEFROMCHAR,0,-1) 'get line For i=1 To linenb If rline(i).nu=l+1 AndAlso proc(rline(i).pr).sr=shwtab Then Exit For 'check nline Next If i>linenb Then fb_message("Line memory address","Not executable so no address") :Exit Sub For j As Integer =0 To procnb If rline(i).ad=proc(j).db Then fb_message("Line memory address","Not executable so no address") :Exit Sub Next sel_line(l) fb_message("Line memory address","Adr = "+Str(rline(i).ad)+" / &h "+Hex(rline(i).ad)) End Sub Private sub compinfo_load(basedata As UInteger,sizedata As UInteger) ReDim As Byte buffer(sizedata) Dim As UInteger idx=0,find,limit Dim As String strg="$$__COMPILINFO__$$" Dim As String wstrg="$$__COMPILINFO__$$" Dim As WString Ptr wsptr Dim As ZString Ptr pzstrg ReadProcessMemory(dbghand,Cast(LPCVOID,basedata),@buffer(0),sizedata,0) While idxstrg[i] Then find=FALSE:Exit For Next If find Then pzstrg=@buffer(idx) compinfo=*pzstrg Exit While End If idx+=1 Wend idx=Cast(uinteger,@buffer(0)) 'unicode search limit=Cast(UInteger,idx)+sizedata-32 While idxlinenb Then fb_message("Dissassembly","Not executable so no address") :Return -1 If scop=KLINE Then 'line inside source tab For j As Integer =0 To procnb If rline(i).ad=proc(j).db Then fb_message("Dissassembly","Not executable so no address") :Return -1 Next sel_line(l) paramstart=" --start-address="+Str(rline(i).ad) If rline(i+1).ad>proc(rline(i).pr).fn Then paramstop=" --stop-address="+Str(proc(rline(i).pr).ed) 'upper limit = the end of the proc....18/08/2015 Else paramstop=" --stop-address="+Str(rline(i+1).ad) EndIf lindex=l SendMessage(dbgrichedit,EM_GETSELTEXT,0,Cast(LPARAM,@lbas)) txt=LTrim(lbas)+Chr(13)+Chr(10)+Chr(13)+Chr(10) Else 'proc inside source tabs temp=rline(i).pr End If Case KPROC'proc inside proc/var treeview or inside proc treview temp=sendmessage(tviewcur,TVM_GETNEXTITEM,TVGN_CARET,0) If tviewcur=tviewvar Then 'proc/var treeview Do 'search index proc hitem=temp temp=SendMessage(tviewcur,TVM_GETNEXTITEM,TVGN_PARENT,hitem) Loop While temp temp=0 For i As Integer =1 To procrnb If procr(i).tv=hitem Then temp=procr(i).idx Exit For EndIf Next If temp=0 Then temp=1 'main also for globals Else 'proc treview hitem=temp For i As Integer =1 To procnb If proc(i).tv=hitem Then temp=i Exit For EndIf Next EndIf exrichedit(proc(temp).sr) Case KPROG 'for now not used paramstart="":paramstop="" End Select If scop=KPROC OrElse scop=KSPROC Then prad=proc(temp).db For i As Integer=1 To linenb 'searching the second executable line of proc If rline(i).ad=prad Then lindex=i If srccomp(proc(temp).sr) Then lindex+=1 EndIf Next txt="PROC : "+proc(temp).nm+Chr(13)+Chr(10) paramstart=" --start-address="+Str(proc(temp).db):paramstop=" --stop-address="+Str(proc(temp).ed)'18/08/2015 EndIf 'open pipe dissas_command=""""""+ExePath+"\objdump.exe"" -d"+paramstart+paramstop+paramsup+" """+exename+"""""" Open Pipe dissas_command For Input As #ff Dim As Integer linenu Do Until Eof(ff) Line Input #ff, ln counter+=1 If counter>6 AndAlso Len(ln)>0 Then iadr=ValInt("&h"+LTrim(Left(ln,InStr(ln,":")-1))) If iadr=rline(lindex).ad Then linenu=rline(lindex).nu sel_line(linenu-1) ''SendMessage ( dbgrichedit , EM_exSETSEL,0,Cast(LPARAM,@range)) sendmessage(dbgrichedit,EM_GETSELTEXT,0,Cast(LPARAM,@lbas)) txt+=Chr(13)+Chr(10)+LTrim(lbas)+Chr(13)+Chr(10) lindex+=1 'while nu+1<>rline(lindex).nu ' not executable ' display ' nu+=1 'Wend EndIf txt+=ln+Chr(13)+Chr(10) EndIf Loop Close #ff SendMessage(dbgrichedit,EM_exsetsel,0,Cast(LPARAM,@range)) 'deselect SetWindowText(hedit,StrPtr(txt)) Keybd_event VK_CONTROL, 0, 0, 0 '19/04/2015 for unselect the text (by marpon) Keybd_event VK_HOME, 0, 0, 0 Keybd_event VK_HOME, 0, KEYEVENTF_KEYUP, 0 Keybd_event VK_CONTROL, 0, KEYEVENTF_KEYUP, 0 Return 0 End Function private sub debug_extract(exebase As UInteger,nfile As String,dllflag As Long=NODLL) '19/09/2014 Dim recup As ZString *MAX_STAB_SZ '20/07/2014 Dim recupstab As udtstab,secnb As UShort,secnm As String *8,lastline As UShort=0,firstline As Integer=0 Dim As UInteger basestab=0,basestabs=0,pe,baseimg,sizemax,sizestabs,proc1,proc2 Dim sourceix As Integer,sourceixs As Integer Dim As Byte procfg,flag=0,procnodll=TRUE,flagstabd=TRUE 'flags (flagstabd to skip stabd 68,0,1) Dim As Integer n=sourcenb+1,temp Dim procnmt As String Dim As Long flagdll,flagdwarf=-1 flagdll=dllflag '19/09/2014 'If Right(nfile,4)=".dll" Then lines could be removed 19/09/2014 ' flagdll=DLL 'Else ' flagdll=NODLL 'EndIf vrbgblprev=vrbgbl linenbprev=linenb SendMessage(dbgstatus,SB_SETTEXT,0,Cast(LPARAM,@"Loading debug data")) ReadProcessMemory(dbghand,Cast(LPCVOID,exebase+&h3C),@pe,4,0) pe+=exebase+6 'adr nb section ReadProcessMemory(dbghand,Cast(LPCVOID,pe),@secnb,2,0) #Ifdef __FB_64BIT__ '22/07/2015 pe+=42 #else pe+=46 'adr compiled baseimage #endif ReadProcessMemory(dbghand,Cast(LPCVOID,pe),@baseimg,sizeof(integer),0) '22/07/2015 #Ifdef __FB_64BIT__ '22/07/2015 pe+=&hD8 #else pe+=&hC4 'adr sections #EndIf For i As UShort =1 To secnb Dim As UInteger basedata,sizedata secnm=String(8,0) 'Init var ReadProcessMemory(dbghand,Cast(LPCVOID,pe),@secnm,8,0) 'read 8 bytes max name size If secnm=".stab" Then ReadProcessMemory(dbghand,Cast(LPCVOID,pe+12),@basestab,4,0) ElseIf secnm=".stabstr" Then ReadProcessMemory(dbghand,Cast(LPCVOID,pe+12),@basestabs,4,0) ReadProcessMemory(dbghand,Cast(LPCVOID,pe+8),@sizestabs,4,0) ElseIf secnm=".data" AndAlso flagdll=NODLL Then 'compinfo ReadProcessMemory(dbghand,Cast(LPCVOID,pe+12),@basedata,4,0) ReadProcessMemory(dbghand,Cast(LPCVOID,pe+8),@sizedata,4,0) compinfo_load(basedata+exebase,sizedata) ElseIf secnm[0]=Asc("/") Then If flagdwarf=-1 Then 'to done only one time If udtmaxMAX_STAB_SZ Then '20/07/2014 'fb_message("Loading stabs","ERROR not enough space to load stabs string (" + Str(MAX_STAB_SZ) + "), change MAX_STAB_SZ"):Exit Sub 11/01/2015 sizemax=MAX_STAB_SZ Else sizemax=sizestabs-recupstab.stabs EndIf If ReadProcessMemory(dbghand,Cast(LPCVOID,recupstab.stabs+basestabs),@recup,sizemax,0)=0 Then fb_message("Loading stabs","ERROR When reading memory : "+Str(GetLastError)+Chr(10)+"Exit loading"):Exit Sub End If #Ifdef fulldbg_prt dbg_prt (recup) #EndIf Select Case recupstab.code Case 36 'proc procnodll=FALSE ' procnmt=cutup_proc(Left(recup,InStr(recup,":")-1)) procnmt=cutup_proc(recup) '02/11/2014 If procnmt="main" Then flagstabd=TRUE ' + A FAIRE supp l'équivalent cidessous 'If procnmt<>"" And procnmt<>"{MODLEVEL}" And(flagmain=TRUE Or procnmt<>"main") Then '' mike's bug 02/12/2015 If procnmt<>"" And(flagmain=TRUE Or procnmt<>"main") Then '' mike's bug 02/12/2015 'If InStr(procnmt,"structor : IRHLCCTX")=0 And InStr(procnmt,".LT")=0 Then If InStr(procnmt,".LT")=0 Then #Ifdef fulldbg_prt dbg_prt ("Proc : "+procnmt) #EndIf If flagmain=TRUE And procnmt="main" Then flagmain=FALSE:flagstabd=TRUE'first main ok but not the others #Ifdef fulldbg_prt dbg_prt("MAIN main "+source(sourceix)) #EndIf EndIf procnodll=TRUE:proc2=recupstab.ad+exebase-baseimg 'only when <> exebase and baseimg (DLL) procfg=1:procnb+=1:proc(procnb).sr=sourceix proc(procnb).nm=procnmt 'proc(procnb).ad=proc2 keep it if needed 'GCC to remove @ in proc name ex test@0: --> test: If InStr(procnmt,"@") Then procnmt=Left(procnmt,InStr(procnmt,"@")-1) End If proc(procnb).nm=procnmt ' :F --> public / :f --> private then return value Dim As String recupbis If gengcc=1 then recupbis=recup:translate_gcc(recupbis):recup=recupbis cutup_retval(procnb,Mid(recup,InStr(recup,":")+2,99))'return value .rv + pointer .pt proc(procnb).st=1 'state no checked proc(procnb).nu=recupstab.nline:lastline=0 proc(procnb+1).vr=proc(procnb).vr 'in case there is not param nor local var proc(procnb).rvadr=0 'for now only used in gcc case 19/08/2015 EndIf End If Case 32,38,40,128,160 'init common/ var / uninit var / local / parameter cutup_1(recup,recupstab.ad,exebase-baseimg) 'GCC Case 60 If recup="gcc2_compiled." Then 'fb_message("Compiled with option -gen gcc"," Expect few strange behaviours ") gengcc=1 srccomp(sourcenb)=gengcc 'stabs 60 arrives just after stabs 100 .... EndIf 'END GCC Case 100 If flag=0 Then If InStr(recup,":")=0 Then Exit Select ' case just name in excess then new path flag=1 If InStr(recup,".") Then 'full name so can check temp=check_source(recup) Else temp=-1 EndIf If temp=-1 Then sourcenb+=1:source(sourcenb)=recup:sourceix=sourcenb:sourceixs=sourceix Else sourceix=temp:sourceixs=sourceix End If dbgmaster=sourcenb 'master bas not the include files 'reinit when new module (main, lib or dll) gengcc=0:procnodll=TRUE srccomp(sourcenb)=gengcc 'could be changed after by case60 10/01/2014 Else flag=0 'case path then full name or path then name 'GCC If Right(recup,2)=".c" Then recup=Left(recup,Len(recup)-2)+".bas" dbgmain=sourcenb 'considering that entry point is inside this source EndIf 'END GCC If InStr(recup,":")=0 Then recup=source(sourcenb)+recup 'path + name temp=check_source(recup) If temp<>-1 Then sourceix=temp:sourceixs=sourceix:sourcenb-=1 Else source(sourcenb)=recup End If End If Case 130 'include RAS Case 132 'include #Ifdef fulldbg_prt dbg_prt ("Include : "+recup) #EndIf 'GCC If InStr(recup,":") Then 'new include file path name with file name temp=check_source(recup) If temp=-1 Then sourcenb+=1:source(sourcenb)=recup:sourceix=sourcenb srccomp(sourcenb)=gengcc Else sourceix=temp End If Else sourceix=0 EndIf ' == 'If InStr(recup,":") Then 'new include file path name with file name ' sourcenb+=1:source(sourcenb)=recup:sourceix=sourcenb' ????? Utilité :sourcead(sourcenb)=recupstab.ad 'Else 'return in main source because no path name ' sourceix=0 'EndIf 'just usefull if GCC because the information for include is arriving after the proc !!! If gengcc Then proc(procnb).sr=sourceix':dbg_prt("include ahah "+source(sourceix)+" "+proc(procnb).nm) 'END GCC Case 42 'main proc = entry point flagstabd=FALSE ' order : code 42 / stabd / code 36 main dbgmain=dbgmaster Case Else #Ifdef fulldbg_prt dbg_prt ("UNKNOWN stabs "+Str(recupstab.code)+" "+Str(recupstab.stabs)+" "+Str(recupstab.nline)+" "+Str(recupstab.ad)+" "+recup) #EndIf End Select Else Select Case recupstab.code Case 68 'dbg_prt2("code 68 "+Str(procnodll)+" "+Str(flagstabd)+" "+Str(recupstab.nline)+" "+Str(lastline)) 'And recupstab.nline>lastline : To avoid very last line see next comment about lastline 'recupstab.nline<>65535 And If procnodll And flagstabd Then 'And recupstab.nline>lastline Then ''''''''''''''''== '12/01/2014''''''''''''If recupstab.nline<>firstline Then If recupstab.nline Then If recupstab.nline>lastline Then 'asm with just comment If recupstab.ad+proc2<>rline(linenb).ad Then linenb+=1 Else WriteProcessMemory(dbghand,Cast(LPVOID,rline(linenb).ad),@rLine(linenb).sv,1,0) EndIf rline(linenb).ad=recupstab.ad+proc2 ReadProcessMemory(dbghand,Cast(LPCVOID,rline(linenb).ad),@rLine(linenb).sv,1,0) 'sav 1 byte before writing &CC If rLine(linenb).sv=-112 Then 'nop, address of looping (eg in a for/next loop correponding to the command next) linenb-=1 ''' dbg_prt2("NUM LINE = NOP "+Str(recupstab.nline))'gcc only Else rLine(linenb).nu=recupstab.nline:rLine(linenb).pr=procnb WriteProcessMemory(dbghand,Cast(LPVOID,rline(linenb).ad),@breakcpu,1,0) #Ifdef fulldbg_prt dbg_prt("Line / adr : "+Str(recupstab.nline)+" "+Hex(rline(linenb).ad)) dbg_prt("") #EndIf If recupstab.ad<>0 Then lastline=recupstab.nline 'first proc line always coded 1 but ad=0 '12/01/2014'''''''''''''If recupstab.ad=0 AndAlso gengcc=1 Then '''''''''''''' firstline=recupstab.nline 'in case of gcc the line could be anything '''''''''''''' rLine(linenb).nu=-1 ''''''''''''''Else '''''''''''''' firstline=-1 ''''''''''''''EndIf EndIf Else 'dbg_prt2("NUM LINE NOT > LAST LINE") End If Else 'dbg_prt2("NUM LINE = 0") EndIf '12/01/2014''''''''''''''''Else ''''''''''''''''dbg_prt2("STILL VERY FIRST LINE = "+Str(firstline)) '12/01/2014'''''''''''EndIf End If Case 192 '' if procfg And procnodll then ''Begin.block proc, real first program ligne for every proc not use now ''procfg=0:proc(procnb).db=recupstab.ad+proc2 ''else ''Begin. of block ''end if Case 224 ''End of block If procnodll Then proc1=recupstab.ad+proc2 Case 36 ''End of proc If procnodll Then If gengcc=1 Then proc1=recupstab.ad+proc2 'under gcc 36=224 or 224 not use 10/01/2014 proc(procnb).ed=recupstab.ad+proc2 Else proc(procnb).ed=recupstab.ad+proc2 '18/08/2015 for gcc it's done below EndIf proc(procnb).fn=proc1:proc(procnb).db=proc2 If proc1>procfn Then procfn=proc1+1 ' just to be sure to be above see gest_brk 'dbg_prt2("Procfn stab="+Hex(procfn)) EndIf If proc(procnb).nu=rline(linenb).nu AndAlso linenb>2 Then 'for proc added by fbc (constructor, operator, ...) '11/05/2014 adding >2 to avoid case only one line ... proc(procnb).nu=-1 For i As Integer =1 To linenb 'dbg_prt2("Proc db/fn inside for stab="+Hex(proc(procnb).db)+" "+Hex(proc(procnb).fn)) 'dbg_prt2("Line Adr="+Hex(rline(i).ad)+" "+Str(rline(i).ad)) If rline(i).ad>=proc(procnb).db AndAlso rline(i).ad<=proc(procnb).fn Then 'dbg_prt2("Cancel breakpoint adr="+Hex(rline(i).ad)+" "+Str(rline(i).ad)) WriteProcessMemory(dbghand,Cast(LPVOID,rline(i).ad),@rLine(i).sv,1,0) 'nota rline(linenb).nu=-1 EndIf Next Else 'for GCC '''''''''' If gengcc Then If proc(procnb).rv=7 Then 'sub return void rline(linenb).nu-=1 'decrement the number of the last line of the proc proc(procnb).fn=rline(linenb).ad 'replace address because = next proc address ''' dbg_prt2("SPECIAL GCC1 "+proc(procnb).nm+" "+Str(rline(linenb).nu)+" "+Str(rline(linenb).ad)) Else 'function linenb-=1 'remove the last line (added by gcc but unexist) If proc(procnb).nm<>"main" Then 'main = NO CHANGE writeProcessMemory(dbghand,Cast(LPVOID,rline(linenb).ad),@rLine(linenb).sv,1,0) 'restore to avoid stop rline(linenb).ad=rline(linenb+1).ad 'replace the address by these of the next one rline(linenb).sv=rline(linenb+1).sv proc(procnb).fn=rline(linenb).ad 'replace address because = next proc address ''' dbg_prt2("SPECIAL GCC2 "+proc(procnb).nm+" "+Str(rline(linenb).ad)) Else ''' dbg_prt2("SPECIAL GCC3") EndIf EndIf EndIf EndIf ''''''''''''''''''''''''''''' Case 162 ''End include sourceix=sourceixs Case 100 flag=0 'as the definitions for integer, ushort etc are repeated keep only the 15 first ones udtcpt=udtmax-TYPESTD '20/08/2015 Case 46,78 'beginning/end of a relocatable function block, not used Case Else ''should not happen but in this case (reported by luis) terminating the loading.... 2016/08/14 #Ifdef fulldbg_prt dbg_prt ("UNKNOWN "+Str(recupstab.code)+" "+Str(recupstab.stabs)+" "+Str(recupstab.nline)+" "+Str(recupstab.ad)) #EndIf Exit while End Select End If basestab+=12 Wend EndIf udtbeg=udtmax+1 'to avoid replacing data already treated cudtbeg=cudtnb+1 locbeg=vrbloc+1 vrbbeg=vrbgbl+1 prcbeg=procnb+1 globals_load() If procrnb=0 Then '05/02/2014 If flagwtch=0 AndAlso wtchexe(0,0)<>"" Then watch_check(wtchexe())'19/04/2014 flagwtch=0 EndIf SendMessage(dbgstatus,SB_SETTEXT,0,Cast(LPARAM,@"Loading sources")) load_sources(n) 'activate buttons/menu after real start but_enable() menu_enable() brk_apply 'apply previous breakpoints End Sub 'GCC 'udt(0).nm="Unknown" 'udt(1).nm="Integer":udt(1).lg=Len(Integer) integer:t(0,1) / int:t(0,1)=r(0,1);-2147483648;2147483647; 'udt(2).nm="Byte":udt(2).lg=Len(Byte) byte:t(0,2) / char:t(0,2)=r(0,2);0;127; ' plutôt signed char ?? signed char:t(0,10)=@s8;r(0,10);-128;127; 'udt(3).nm="Ubyte":udt(3).lg=Len(UByte) ubyte:t(0,11) / unsigned char:t(0,11)=@s8;r(0,11);0;255; 'udt(4).nm="Zstring":udt(4).lg=4 byte 'udt(5).nm="Short":udt(5).lg=Len(Short) short int:t(0,8)=@s16;r(0,8);-32768;32767; 'udt(6).nm="Ushort":udt(6).lg=Len(UShort) ushort:t(0,9) / short unsigned int:t(0,9)=@s16;r(0,9);0;65535; 'udt(7).nm="Void":udt(7).lg=4 void:t(0,19)=(0,19) 'udt(8).nm="Uinteger":udt(8).lg=Len(UInteger) uinteger:t(0,4) unsigned int:t(0,4)=r(0,4);0000000000000;0037777777777; 'udt(9).nm="Longint":udt(9).lg=Len(LongInt) longint:t(0,6) long long int:t(0,6)=@s64;r(0,6);01000000000000000000000;0777777777777777777777; 'udt(10).nm="Ulongint":udt(10).lg=Len(ULongInt) ulongint:t(0,7) long long unsigned int:t(0,7)=@s64;r(0,7);0000000000000;01777777777777777777777; 'udt(11).nm="Single":udt(11).lg=Len(Single) single:t(0,12) / float:t(0,12)=r(0,1);4;0; 'udt(12).nm="Double":udt(12).lg=Len(Double) double:t(0,13)=r(0,1);8;0; 'udt(13).nm="String":udt(13).lg=Len(String) _string:T(0,22)=s12data:(0,23)=*(0,2),0,32;len:(0,1),32,32;size:(0,1),64,32;; 'udt(14).nm="Fstring":udt(14).lg=4 fixstr:t(0,2) 'udt(15).nm="Pchar":udt(15).lg=4 'in string STRG all the occurences of SRCH are replaced by REPL private sub str_replace(strg As String,srch As String, repl As String) Dim As Integer p,lgr=Len(repl),lgs=Len(srch) p=InStr(strg,srch) While p strg=Left(strg,p-1)+repl+Mid(strg,p+lgs) p=InStr(p+lgr,strg,srch) Wend End Sub private function translate_type(strg As String,p As Integer) As Integer Dim As Integer index Static As Integer flagstring,flagvoid If flagstring=0 AndAlso Left(strg,9)="_string:T" Then index=Val(Mid(strg,13,9)) Trans(index)="13" '_string:T(0,xx) flagstring=1 Return index EndIf If flagvoid=0 AndAlso Left(strg,6)="void:t" Then 'void:t(0,xx) index=Val(Mid(strg,10,9)) Trans(index)="7" flagvoid=1 Return index EndIf index=Val(Mid(strg,InStr(p,strg,",")+1,9)) Return index End Function private sub translate_part(strg As String,masterindex As Integer) Dim As String sav,modif Dim As Integer p,q,index,indexbis,limit sav=strg While InStr(sav,")=") q=1 p=InStr(q,sav,"(") q=InStr(p+1,sav,")") indexbis=Val(Mid(sav,InStr(p,sav,",")+1,9)) modif=Mid(sav,q+2) sav=Mid(sav,InStr(q+2,sav,"(")) p=InStr(modif,"(") While p q=InStr(p+1,modif,")") index=Val(Mid(modif,InStr(p,modif,",")+1,9)) If Trans(index)<>"" Then str_replace(modif,Mid(modif,p,q-p+1),Trans(index)) Else str_replace(modif,Mid(modif,p,q-p+1),Str(index)) EndIf p=InStr(p+1,modif,"(") Wend Trans(indexbis)=Str(indexbis)+"="+modif Wend strg=Trans(masterindex) End Sub private sub translate_gcc(strg As String) Dim As Integer p,q,index Dim As String part Static As Integer flagarray,flagstring,flagvoid If flagarray=0 Then p=InStr(strg,"00;003777") 'searching for the string used for array. Depending on the version of gcc If p Then p-=31 Else p=InStr(strg,";0;03777") If p Then p-=20 EndIf If p Then 'TCD:T(0,34)=s32VALUE:(0,35)=ar(0,36)=r(0,36);0000000000000;0037777777777;;0;31;(0,23),0,256;; 'TCD:T(0,31)=s32VALUE:(0,32)=ar(0,33)=r(0,33);0;037777777777;;0;31;(0,20),0,256;; q=InStr(p,strg,"=ar(") stringarray=Mid(strg,q,InStr(q+4,strg,")")-q+1) 'ar(0,xx) equivalent ar1 str_replace(strg,Mid(strg,q,InStr(strg,"777;;")+5-q),"=ar1;") 'replace flagarray=1 EndIf Else If InStr(strg,stringarray) Then str_replace(strg,stringarray,"=ar1") EndIf p=InStr(strg,"(") q=InStr(p+1,strg,")") 'index=val(mid(strg,instr(p,strg,",")+1,9)) index=Val(Mid(strg,InStr(p,strg,",")+1,9)) If flagvoid=0 AndAlso Left(strg,6)="void:t" Then Trans(index)="7" 'void:t(0,xx) str_replace(strg,Mid(strg,p,q-p+1),Str(index)) flagvoid=1 Return EndIf If flagstring=0 AndAlso ( Left(strg,10)="FBSTRING:t" OrElse Left(strg,9)="_string:T" ) Then '_string:T(0,xx) or FBSTRING:t(0,xx) Trans(index)="13" flagstring=1 Return EndIf '"_TMP$3:T(0,25)=s44DATA:(0,26)=*(0,27)=*(0,1),0,32;PTR:(0,26),32,32;SIZE:(0,1),64, '_TUDT:T(0,38)=s8VINT:(0,1),0,32;VBYTE:(0,2),32,8;; If Strg[p-2]=Asc("T") Then 'Trans(masterindex)="" str_replace(strg,Mid(strg,p,q-p+1),Str(index)) 'replace master index p=InStr(strg,"(")'find begin and end of type (with array if needed) of component While p q=InStr(p+1,strg,"),") part=Mid(strg,p,q-p+1) translate_part(part,Val(Mid(strg,InStr(p,strg,",")+1,9))) str_replace(strg,Mid(strg,p,q-p+1),part) p=InStr(p,strg,"(") Wend 'remove $N or $NN at beginning $Nudt If strg[0]=Asc("$") AndAlso Left(strg,10)<>"$fb_Object" Then '$4UDT1:T(0,58)=s128A:(0,23),0,32;B:(0,54),64,896;C:(0,22),960,16;; If strg[2]>Asc("9") OrElse strg[2]=Asc("$") Then strg=Mid(strg,3) Else strg=Mid(strg,4) EndIf If Left(strg,4)="TMP$" Then 'description for dynamic array p=InStr(strg,"DATA:") p=InStr(p,strg,"*") 'skip first * p=InStr(p,strg,"=")+1 'extract data q=InStr(p,strg,",") Trans(index)="=;;"+Mid(strg,p,q-p) 'extract some data to trans()="=s44;;" Exit Sub EndIf Trans(index)=Str(index) Else If Trans(index)<>"" Then str_replace(strg,Mid(strg,p,q-p+1),Trans(index)) 'replace by the corresponding string Else 'replace master index part=Mid(strg,p) translate_part(part,index) str_replace(strg,Mid(strg,p),part) End If End If End Sub private function cutup_names(strg As String) As String '"__ZN9TESTNAMES2XXE:S1 Dim As Integer p,d Dim As String nm,strg2,nm2 p=InStr(strg,"_ZN") strg2=Mid(strg,p+3,999) p=Val(strg2) If p>9 Then d=3 Else d=2 nm=Mid(strg2,d,p) strg2=Mid(strg2,d+p) p=Val(strg2) If p>9 Then d=3 Else d=2 nm2=Mid(strg2,d,p) 'Return "NS : "+nm+"."+nm2 Return nm+"."+nm2 '17/01/2015 End Function private function cutup_proc(fullname As String) As String '02/11/2014 Dim As Long p=3,lg,namecpt,ps Dim As String strg,strg2,names(10),mainname,strg3 lg=InStr(fullname,"@") If lg=0 Then lg=InStr(fullname,":") strg=Left(fullname,lg-1) If InStr(strg,"_Z")=0 Then Return strg If strg[2]=Asc("Z") Then p+=1 'add 1 case _ _ Z If strg[p-1]=Asc("N") Then 'nested waiting "E" mainname="" p+=1 While Strg[p-1]<>Asc("E") lg=ValInt(Mid(strg,p,2)) 'evaluate possible lenght of name eg 7NAMESPC If lg Then 'name of namespace or udt If lg>9 Then p+=1 '>9 --> 2 characters strg3=Mid(strg,p+1,lg) 'extract name and keep it for later ps=InStr(strg3,"__get__") If ps Then strg3=Left(strg3,ps-1)+" (Get property)" Else ps=InStr(strg3,"__set__") If ps Then strg3=Left(strg3,ps-1)+" (Set property)" EndIf EndIf If mainname="" Then mainname=strg3 strg2+=strg3 Else mainname+="."+strg3 strg2+="."+strg3 EndIf namecpt+=1 names(namecpt)=mainname p+=1+lg'next name Else 'operator strg2+=" "+cutup_op(Mid(strg,p,2))+" " 'extract name of operator p+=2 mainname="" While Strg[p-1]<>Asc("E") 'more data eg FBSTRING, lg=ValInt(Mid(strg,p,2)) If lg Then If lg>9 Then p+=1 strg3=Mid(strg,p+1,lg) 'extract name and keep it for later If strg3="FBSTRING" Then strg3="string" If mainname="" Then mainname=strg3 strg2+=strg3 Else mainname+="."+strg3 strg2+="."+strg3 endif namecpt+=1 names(namecpt)=mainname p+=1+lg Else strg2+=parse_typeope(Asc(Mid(strg,p,1)))'mymodif p+=1 EndIf Wend EndIf Wend Else lg=ValInt(Mid(strg,p,2)) 'overloaded proc eg. for sub testme overload (as string) --> __ZN6TESTMER8FBSTRING@4 07/11/2015 If lg Then If lg>9 Then p+=1 strg2=Mid(strg,p+1,lg) 'extract name p+=1+lg'next Else strg2=cutup_op(Mid(strg,p,2))+" " p+=2 End If EndIf If strg[p-1]=Asc("E") Then p+=1 'skip "E" 'parameters mainname="" strg2+="(" While p<=Len(strg) lg=ValInt(Mid(strg,p,2)) If lg Then If lg>9 Then p+=1 strg3=Mid(strg,p+1,lg) 'extract name and keep it for later If strg3="FBSTRING" Then strg3="String" If mainname="" Then mainname=strg3 strg2+=strg3 Else mainname+="."+strg3 strg2+="."+strg3 EndIf namecpt+=1 names(namecpt)=mainname p+=1+lg elseIf strg[p-1]=Asc("R") Then If Right(strg2,1)<>"(" AndAlso Right(strg2,1)<>"," Then strg2+="," p+=1 elseIf strg[p-1]=Asc("N") Then If Right(strg2,1)<>"(" AndAlso Right(strg2,1)<>"," Then strg2+="," mainname="" p+=1 elseIf strg[p-1]=Asc("K") Then If Right(strg2,1)<>"(" AndAlso Right(strg2,1)<>"," Then strg2+=",const." Else strg2+="const." EndIf p+=1 elseIf strg[p-1]=Asc("E") Then 'If Right(strg2,1)<>"," Then strg2+="," p+=1 ElseIf strg[p-1]=Asc("S") Then 'S0_ --> 'repeating the previous type If Right(strg2,1)<>"(" AndAlso Right(strg2,1)<>"," Then strg2+=",":mainname="" p+=1 If strg[p-1]=asc("_") Then strg3=names(1) p+=1 Else strg3=names(strg[p-1]-46) p+=2 EndIf If mainname="" Then mainname=strg3 strg2+=strg3 Else mainname+="."+strg3 strg2+="."+strg3 EndIf namecpt+=1 names(namecpt)=mainname Else If Right(strg2,1)="(" Then strg2+=parse_typeope(Asc(Mid(strg,p,1))) Else strg2+=","+parse_typeope(Asc(Mid(strg,p,1))) EndIf p+=1 EndIf Wend strg2+=")" If Right(strg2,6)="(Void)" Then strg2=Left(strg2,Len(strg2)-6) EndIf Return strg2 End Function private function cutup_op (op As String) As String Select Case op Case "aS" Function = "Let" Case "pl" Function = "+" Case "pL" Function = "+=" Case "mi" Function = "-" Case "mI" Function = "-=" Case "ml" Function = "*" Case "mL" Function = "*=" Case "dv" Function = "/" Case "dV" Function = "/=" Case "Dv" Function = "\" Case "DV" Function = "\=" Case "rm" Function = "mod" Case "rM" Function = "mod=" Case "an" Function = "and" Case "aN" Function = "and=" Case "or" Function = "or" Case "oR" Function = "or=" Case "aa" Function = "andalso" Case "aA" Function = "andalso=" Case "oe" Function = "orelse" Case "oE" Function = "orelse=" Case "eo" Function = "xor" Case "eO" Function = "xor=" Case "ev" Function = "eqv" Case "eV" Function = "eqv=" Case "im" Function = "imp" Case "iM" Function = "imp=" Case "ls" Function = "shl" Case "lS" Function = "shl=" Case "rs" Function = "shr" Case "rS" Function = "shr=" Case "po" Function = "^" Case "pO" Function = "^=" Case "ct" Function = "&" Case "cT" Function = "&=" Case "eq" Function = "eq" Case "gt" Function = "gt" Case "lt" Function = "lt" Case "ne" Function = "ne" Case "ge" Function = "ge" Case "le" Function = "le" Case "nt" Function = "not" Case "ng" Function = "neg" Case"ps" Function = "ps" Case "ab" Function = "ab" Case "fx" Function = "fix" Case "fc" Function = "frac" Case "sg" Function = "sgn" Case "fl" Function = "floor" Case "nw" Function = "new" Case "na" Function = "new []?" Case "dl" Function = "del" Case "da" Function = "del[]?" Case "de" Function = "." Case "pt" Function = "->" Case "ad" Function = "@" Case "fR" Function = "for" Case "sT" Function = "step" Case "nX" Function = "next" Case "cv" Function = "Cast" Case "C1" Function = "(Constructor)" '02/11/2014 Case "D1" Function = "(Destructor)" Case Else Function = "Unknow" End Select End Function private function parse_typeope(vchar As long) As String 'RPiR8vector2D or R8vector2DS0_ or R8FBSTRINGR8VECTOR2D Dim As Long typ If vchar=Asc("P") Then Return "*" 'pointer Else 'l=long/m=unsigned long/n=__int128/o=unsigned __int128/e=long double, __float80 Select Case As Const vchar Case Asc("i") typ=1 Case Asc("a") typ=2 Case Asc("h") typ=3 'Case Asc("") 'Zstring ' typ=4 Case Asc("s") typ=5 Case Asc("t") typ=6 Case Asc("v") typ=7 Case Asc("j") typ=8 Case Asc("x") typ=9 Case Asc("y") typ=10 Case Asc("f") typ=11 Case Asc("d") typ=12 'Case Asc("")'String ' typ=13 'Case Asc("")'Fstring ' typ=14 Case Else typ=0 End Select Return udt(typ).nm EndIf End Function private sub cutup_1(gv As String,ad As UInteger, dlldelta As Integer=0) Dim p As Integer Static defaulttype As Integer Dim As String vname If gengcc Then If InStr(gv,"long double:t")<>0 OrElse InStr(gv,"FBSTRING:t")<>0 Then defaulttype=0 ElseIf Left(gv,5)="int:t" OrElse InStr(gv,"_Decimal32:t")<>0 Then defaulttype=1 EndIf Else If InStr(gv,"boolean:t") Orelse InStr(gv,"pchar:t") Then 'last default type 20/08/2015 defaulttype=0 ElseIf InStr(gv,"integer:t") Then defaulttype=1 EndIf EndIf If defaulttype Then Exit Sub If gengcc Then translate_gcc(gv) '===================================================== vname=Left(gv,InStr(gv,":")+1) p=InStr(vname,"$") If p=0 Then 'no $ in the string If InStr(vname,":t")<>0 Then If UCase(Left(vname,InStr(vname,":")))<>Left(vname,InStr(vname,":")) Then Exit Sub 'don't keep :t, keep :t => enum EndIf ElseIf InStr(vname,"_ZTSN")<>0 orelse InStr(vname,"_ZTVN")<>0 then Exit Sub 'don't keep _ZTSN or _ZTVN (extra data for class) or with double underscore __Z EndIf If Left(vname,2)="_{" Then Exit Sub '_{fbdata}_