<div dir="ltr">Thanks Lex.</div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Oct 15, 2015 at 5:33 PM, Lex Trotman <span dir="ltr"><<a href="mailto:elextr@gmail.com" target="_blank">elextr@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On 16 October 2015 at 06:42, Pengfei Sun <<a href="mailto:shaotian330@gmail.com">shaotian330@gmail.com</a>> wrote:<br>
> Hi Lex,<br>
><br>
</span><span class="">> I checked again the gap buffer and heap memory dump. I made mistakes last<br>
> time. scintilla_send_message returned the virtual address which was the<br>
> address of text in the heap. However, I also found parts of text (each line)<br>
> which locate in different address in the heap. So I made the mistake.<br>
><br>
> I still have one question about memory allocation of geany. When you type<br>
> some text in the one window of geany, which function is responsible for<br>
> allocating the memory space in the heap? g_new, g_new0, g_malloc,<br>
> g_slice_alloc??  I remembered you mentioned that "The buffer itself is<br>
> allocated by Scintilla which means its allocated by C++ new". But I don't<br>
> find the exact location in the source code of geany.<br>
<br>
</span>Splitvector.h:94<br>
<div class="HOEnZb"><div class="h5"><br>
><br>
> Thank you very much!<br>
><br>
> Best Regards,<br>
> Pengfei<br>
><br>
> On Wed, Oct 14, 2015 at 5:13 AM, Lex Trotman <<a href="mailto:elextr@gmail.com">elextr@gmail.com</a>> wrote:<br>
>><br>
>> On 13 October 2015 at 04:43, Pengfei Sun <<a href="mailto:shaotian330@gmail.com">shaotian330@gmail.com</a>> wrote:<br>
>> > Hi Lex,<br>
>> ><br>
>> > Thanks for you hint about scintilla. Matthew also mentioned to use the<br>
>> > scintilla. I tried his patch, but there is still one problem about the<br>
>> > address of buffer. I don't know why the address of output is not<br>
>> > consistent<br>
>> > with address of buffer in the dumped heap memory?<br>
>><br>
>> The Scintilla buffer is a gap buffer, its contents are moved depending<br>
>> on user actions, and depending on what else Geany is doing it can copy<br>
>> all or parts of the buffer to C memory.  So your string can appear in<br>
>> lots of places in memory, C heap, C++ heap (which may or may not be<br>
>> the same as the C heap) not just in the buffer.<br>
>><br>
>> Cheers<br>
>> Lex<br>
>><br>
>> ><br>
>> > Best Regards,<br>
>> > Pengfei<br>
>> ><br>
>> > On Fri, Oct 9, 2015 at 7:12 PM, Lex Trotman <<a href="mailto:elextr@gmail.com">elextr@gmail.com</a>> wrote:<br>
>> >><br>
>> >> On 10 October 2015 at 08:42, Pengfei Sun <<a href="mailto:shaotian330@gmail.com">shaotian330@gmail.com</a>> wrote:<br>
>> >> > Hi Lex,<br>
>> >> ><br>
>> >> > Thanks for your suggestions.<br>
>> >> ><br>
>> >> > I work on memory forensics. My part of project is to locate memory of<br>
>> >> > the<br>
>> >> > sensitive data. For example, when I use the geany open one sensitive<br>
>> >> > file,<br>
>> >> > and the content will be in the memory (heap). I hope I can locate all<br>
>> >> > memory<br>
>> >> > related this sensitive file. And later I can do some analysis or<br>
>> >> > protection.<br>
>> >> ><br>
>> >><br>
>> >> The buffer itself is allocated by Scintilla which means its allocated<br>
>> >> by C++ new.<br>
>> >><br>
>> >> > Now, I override malloc and can log all malloc functions to get return<br>
>> >> > address and size (I think g_malloc is a wrapper of malloc). But I<br>
>> >> > still<br>
>> >> > cannot building the mapping between the special file and related heap<br>
>> >> > memory. I know each open or created file have different ID<br>
>> >> > (GeanyDocument->id). However, I still cannot figure out how to trace<br>
>> >> > the<br>
>> >> > related memory of different ID. Assume I have open three files, so<br>
>> >> > there<br>
>> >> > are<br>
>> >> > three windows and three different GeanyDocument->id. I write or<br>
>> >> > change<br>
>> >> > some<br>
>> >> > things among these three windows. Meanwhile, I log all<br>
>> >> > malloc/realloc/calloc<br>
>> >> > functions. I try to figure out which malloc belong to window 1, which<br>
>> >> > belong<br>
>> >> > to window2 or window 3?  Do you have any further suggestions for my<br>
>> >> > case?<br>
>> >> ><br>
>> >><br>
>> >> Use only one window :)<br>
>> >><br>
>> >> > Thank you very much.<br>
>> >> ><br>
>> >> > Best Regards,<br>
>> >> > Pengfei<br>
>> >> ><br>
>> >> > On Fri, Oct 9, 2015 at 5:45 PM, Lex Trotman <<a href="mailto:elextr@gmail.com">elextr@gmail.com</a>> wrote:<br>
>> >> >><br>
>> >> >> On 10 October 2015 at 05:05, Pengfei Sun <<a href="mailto:shaotian330@gmail.com">shaotian330@gmail.com</a>><br>
>> >> >> wrote:<br>
>> >> >> > Dear All,<br>
>> >> >> ><br>
>> >> >> > I am always using geany, but now this is the first time I prepare<br>
>> >> >> > to<br>
>> >> >> > look at<br>
>> >> >> > geany source code. I have one question about memory allocation.<br>
>> >> >> > When<br>
>> >> >> > we<br>
>> >> >> > open<br>
>> >> >> > one new file, there will be one new window in geany. How could I<br>
>> >> >> > track<br>
>> >> >> > all<br>
>> >> >> > memory allocation(g_malloc) related with this window? Or would it<br>
>> >> >> > be<br>
>> >> >> > possible to track all related functions with this window?<br>
>> >> >><br>
>> >> >> The only way to track all allocations is to track Glib/GTK<br>
>> >> >> operations<br>
>> >> >> (some of these functions use Gslice, which does its own allocations<br>
>> >> >> from large blocks and may not show on malloc, or will show<br>
>> >> >> allocating<br>
>> >> >> the large block not all of which is for the one window).<br>
>> >> >><br>
>> >> >> Also track g_malloc that Geany uses, though you can force that to<br>
>> >> >> always malloc I think.<br>
>> >> >><br>
>> >> >> Also track malloc in case some libraries use it.<br>
>> >> >><br>
>> >> >> And to track C++ new as used by the editing component (which again<br>
>> >> >> need not use malloc).<br>
>> >> >><br>
>> >> >> One question is why do you want to do this,what are you trying to<br>
>> >> >> achieve? There might be a better way.<br>
>> >> >><br>
>> >> >> Geany is mostly event driven (though a few things are timer driven)<br>
>> >> >> so<br>
>> >> >> if you only perform actions on one window most code run will relate<br>
>> >> >> to<br>
>> >> >> that window.<br>
>> >> >><br>
>> >> >> Cheers<br>
>> >> >> Lex<br>
>> >> >><br>
>> >> >> ><br>
>> >> >> > Thank you very much!<br>
>> >> >> ><br>
>> >> >> > Best Regards,<br>
>> >> >> > Pengfei<br>
>> >> >> ><br>
>> >> >> ><br>
>> >> >> > _______________________________________________<br>
>> >> >> > Devel mailing list<br>
>> >> >> > <a href="mailto:Devel@lists.geany.org">Devel@lists.geany.org</a><br>
>> >> >> > <a href="https://lists.geany.org/cgi-bin/mailman/listinfo/devel" rel="noreferrer" target="_blank">https://lists.geany.org/cgi-bin/mailman/listinfo/devel</a><br>
>> >> >> ><br>
>> >> >> _______________________________________________<br>
>> >> >> Devel mailing list<br>
>> >> >> <a href="mailto:Devel@lists.geany.org">Devel@lists.geany.org</a><br>
>> >> >> <a href="https://lists.geany.org/cgi-bin/mailman/listinfo/devel" rel="noreferrer" target="_blank">https://lists.geany.org/cgi-bin/mailman/listinfo/devel</a><br>
>> >> ><br>
>> >> ><br>
>> >> ><br>
>> >> > _______________________________________________<br>
>> >> > Devel mailing list<br>
>> >> > <a href="mailto:Devel@lists.geany.org">Devel@lists.geany.org</a><br>
>> >> > <a href="https://lists.geany.org/cgi-bin/mailman/listinfo/devel" rel="noreferrer" target="_blank">https://lists.geany.org/cgi-bin/mailman/listinfo/devel</a><br>
>> >> ><br>
>> >> _______________________________________________<br>
>> >> Devel mailing list<br>
>> >> <a href="mailto:Devel@lists.geany.org">Devel@lists.geany.org</a><br>
>> >> <a href="https://lists.geany.org/cgi-bin/mailman/listinfo/devel" rel="noreferrer" target="_blank">https://lists.geany.org/cgi-bin/mailman/listinfo/devel</a><br>
>> ><br>
>> ><br>
>> ><br>
>> > _______________________________________________<br>
>> > Devel mailing list<br>
>> > <a href="mailto:Devel@lists.geany.org">Devel@lists.geany.org</a><br>
>> > <a href="https://lists.geany.org/cgi-bin/mailman/listinfo/devel" rel="noreferrer" target="_blank">https://lists.geany.org/cgi-bin/mailman/listinfo/devel</a><br>
>> ><br>
>> _______________________________________________<br>
>> Devel mailing list<br>
>> <a href="mailto:Devel@lists.geany.org">Devel@lists.geany.org</a><br>
>> <a href="https://lists.geany.org/cgi-bin/mailman/listinfo/devel" rel="noreferrer" target="_blank">https://lists.geany.org/cgi-bin/mailman/listinfo/devel</a><br>
><br>
><br>
><br>
> _______________________________________________<br>
> Devel mailing list<br>
> <a href="mailto:Devel@lists.geany.org">Devel@lists.geany.org</a><br>
> <a href="https://lists.geany.org/cgi-bin/mailman/listinfo/devel" rel="noreferrer" target="_blank">https://lists.geany.org/cgi-bin/mailman/listinfo/devel</a><br>
><br>
_______________________________________________<br>
Devel mailing list<br>
<a href="mailto:Devel@lists.geany.org">Devel@lists.geany.org</a><br>
<a href="https://lists.geany.org/cgi-bin/mailman/listinfo/devel" rel="noreferrer" target="_blank">https://lists.geany.org/cgi-bin/mailman/listinfo/devel</a><br>
</div></div></blockquote></div><br></div>