<div dir="ltr"><div>Hi</div><div>I hope this is more readable and easier to review.</div><div><br></div><div>/*==========================CODE====================================*/</div><div>diff --git a/programs/taskmgr/endproc.c b/programs/taskmgr/endproc.c</div><div>index 89c2d7b..b1a9242 100644</div><div>--- a/programs/taskmgr/endproc.c</div><div>+++ b/programs/taskmgr/endproc.c</div><div>@@ -31,18 +31,26 @@</div><div> #include "wine/unicode.h"</div><div> #include "taskmgr.h"</div><div> #include "perfdata.h"</div><div>+#include "tlhelp32.h" </div><div>+</div><div> </div><div> static WCHAR wszWarnMsg[511];</div><div> static WCHAR wszWarnTitle[255];</div><div> static WCHAR wszUnable2Terminate[255];</div><div> </div><div>+typedef struct process_list {</div><div>+    DWORD        *pid;       /*dynamic array to store the process IDs*/</div><div>+    SIZE_T      count;      /*index to maintain the last entry of the array;*/</div><div>+    SIZE_T      size;       /*the current size of the pid array*/</div><div>+} process_list;</div><div>+</div><div> static void load_message_strings(void)</div><div> {</div><div>     LoadStringW(hInst, IDS_TERMINATE_MESSAGE, wszWarnMsg, sizeof(wszWarnMsg)/sizeof(WCHAR));</div><div>     LoadStringW(hInst, IDS_TERMINATE_UNABLE2TERMINATE, wszUnable2Terminate, sizeof(wszUnable2Terminate)/sizeof(WCHAR));</div><div>     LoadStringW(hInst, IDS_WARNING_TITLE, wszWarnTitle, sizeof(wszWarnTitle)/sizeof(WCHAR));</div><div> }</div><div>-</div><div>+                                                                                                                                                                                            </div><div> void ProcessPage_OnEndProcess(void)</div><div> {</div><div>     LVITEMW          lvitem;</div><div>@@ -93,6 +101,57 @@ void ProcessPage_OnEndProcess(void)</div><div>     CloseHandle(hProcess);</div><div> }</div><div> </div><div>+</div><div>+static void init_process_list(process_list *list) {</div><div>+    list->size = 4;            /*initialise size with 4. Will increase if necessary.*/</div><div>+    list->pid = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, list->size * sizeof(*(list->pid)));</div><div>+    list->count = 0;</div><div>+}</div><div>+</div><div>+static void increase_list_size(process_list *list) {</div><div>+    list->size *= 2;</div><div>+    list->pid = HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, list->pid, list->size * sizeof(*(list->pid)));</div><div>+}</div><div>+</div><div>+static void process_list_append(process_list *list, DWORD id) {</div><div>+    if(list->count == list->size)</div><div>+        increase_list_size(list);</div><div>+    list->pid[list->count] = id;</div><div>+    list->count += 1;</div><div>+}</div><div>+</div><div>+static void free_process_list(process_list *list) {</div><div>+    HeapFree(GetProcessHeap(), 0, list->pid);</div><div>+}</div><div>+</div><div>+</div><div>+static void enum_process_children(HANDLE snapshot, process_list *list, DWORD pid) {</div><div>+    PROCESSENTRY32 entry;</div><div>+</div><div>+    SIZE_T start, end, i;</div><div>+</div><div>+    start = list->count;</div><div>+</div><div>+    entry.dwSize = sizeof(entry); </div><div>+</div><div>+    if(!Process32First(snapshot, &entry))</div><div>+        return;</div><div>+</div><div>+    do </div><div>+    {   </div><div>+        if(entry.th32ParentProcessID == pid)</div><div>+            process_list_append(list, entry.th32ProcessID);</div><div>+    } while (Process32Next(snapshot, &entry));</div><div>+</div><div>+    end = list->count;</div><div>+</div><div>+    for(i = start; i < end; ++i)</div><div>+    {</div><div>+        enum_process_children(snapshot, list, list->pid[i]);</div><div>+    }</div><div>+}</div><div>+</div><div>+</div><div> void ProcessPage_OnEndProcessTree(void)</div><div> {</div><div>     LVITEMW          lvitem;</div><div>@@ -100,6 +159,9 @@ void ProcessPage_OnEndProcessTree(void)</div><div>     DWORD            dwProcessId;</div><div>     HANDLE           hProcess;</div><div>     WCHAR            wstrErrorText[256];</div><div>+    process_list     list;</div><div>+    SIZE_T           i;</div><div>+    HANDLE           snapshot;</div><div> </div><div>     load_message_strings();</div><div> </div><div>@@ -125,20 +187,40 @@ void ProcessPage_OnEndProcessTree(void)</div><div>     if (MessageBoxW(hMainWnd, wszWarnMsg, wszWarnTitle, MB_YESNO|MB_ICONWARNING) != IDYES)</div><div>         return;</div><div> </div><div>-    hProcess = OpenProcess(PROCESS_TERMINATE, FALSE, dwProcessId);</div><div> </div><div>-    if (!hProcess)</div><div>-    {</div><div>-        GetLastErrorText(wstrErrorText, sizeof(wstrErrorText)/sizeof(WCHAR));</div><div>-        MessageBoxW(hMainWnd, wstrErrorText,wszUnable2Terminate, MB_OK|MB_ICONSTOP);</div><div>+    init_process_list(&list);</div><div>+</div><div>+    if(list.pid == NULL)</div><div>         return;</div><div>-    }</div><div> </div><div>-    if (!TerminateProcess(hProcess, 0))</div><div>-    {</div><div>-        GetLastErrorText(wstrErrorText, sizeof(wstrErrorText)/sizeof(WCHAR));</div><div>-        MessageBoxW(hMainWnd, wstrErrorText,wszUnable2Terminate, MB_OK|MB_ICONSTOP);</div><div>+    process_list_append(&list, dwProcessId);</div><div>+</div><div>+    snapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);//TH32SNAPPROCESS</div><div>+</div><div>+    if(!snapshot)</div><div>+        return;</div><div>+</div><div>+    enum_process_children(snapshot, &list, dwProcessId);</div><div>+    </div><div>+    CloseHandle(snapshot);</div><div>+</div><div>+    for(i = 0; i < list.count; ++i) {</div><div>+        hProcess = OpenProcess(PROCESS_TERMINATE, FALSE, list.pid[i]);        </div><div>+</div><div>+        if (!hProcess)</div><div>+        {</div><div>+            GetLastErrorText(wstrErrorText, sizeof(wstrErrorText)/sizeof(WCHAR));</div><div>+            MessageBoxW(hMainWnd, wstrErrorText,wszUnable2Terminate, MB_OK|MB_ICONSTOP);</div><div>+            break;</div><div>+        }</div><div>+</div><div>+        if (!TerminateProcess(hProcess, 0))</div><div>+        {</div><div>+            GetLastErrorText(wstrErrorText, sizeof(wstrErrorText)/sizeof(WCHAR));</div><div>+            MessageBoxW(hMainWnd, wstrErrorText,wszUnable2Terminate, MB_OK|MB_ICONSTOP);</div><div>+        }</div><div>+        CloseHandle(hProcess);</div><div>     }</div><div> </div><div>-    CloseHandle(hProcess);</div><div>-}</div><div>+    free_process_list(&list);</div><div>+}</div><div>\ No newline at end of file</div><div><br></div></div><div class="gmail_extra"><br clear="all"><div><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr" style="font-size:12.8px"><font color="#444444" face="trebuchet ms, sans-serif">Regards</font></div><div dir="ltr" style="font-size:12.8px"><font color="#444444" face="trebuchet ms, sans-serif">--<br></font><div><div><font color="#444444" face="trebuchet ms, sans-serif"><b>Akarsha Sehwag</b></font></div><div><font color="#444444" size="2" face="trebuchet ms, sans-serif">2015010</font></div><font face="trebuchet ms, sans-serif"><span style="color:rgb(68,68,68);font-size:small">Rang Coordinator</span><br style="color:rgb(68,68,68);font-size:small"></font><div><font color="#444444" size="2" face="trebuchet ms, sans-serif">Adventure Club Coordinator</font></div><div><font color="#444444" size="2" face="trebuchet ms, sans-serif">Sports Council | Ink member </font></div><div><font color="#444444" size="2" face="trebuchet ms, sans-serif">CSE Undergrad,  IIIT Delhi</font></div></div></div></div><div dir="ltr"><font color="#444444" face="tahoma, sans-serif"><img src="https://docs.google.com/uc?export=download&id=0BwybN3USu5FMWTNYWEt1U2V4ZmM&revid=0BwybN3USu5FMbjgxcmRTNVVSbUhhY05xWnpybW9DbWcxZUZvPQ" width="200" height="34"><br></font></div><div dir="ltr"><br></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div>
<br><div class="gmail_quote">On Thu, Apr 20, 2017 at 9:19 PM, Aaryaman Vasishta <span dir="ltr"><<a href="mailto:jem456.vasishta@gmail.com" target="_blank">jem456.vasishta@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Forgot to CC wine-devel..<div class="gmail_extra"><br><div class="gmail_quote">On Fri, Apr 21, 2017 at 12:47 AM, Aaryaman Vasishta <span dir="ltr"><<a href="mailto:jem456.vasishta@gmail.com" target="_blank">jem456.vasishta@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi,<br><div class="gmail_extra"><br><div class="gmail_quote"><span>On Thu, Apr 20, 2017 at 6:51 AM, Akarsha Sehwag <span dir="ltr"><<a href="mailto:akarsha15010@iiitd.ac.in" target="_blank">akarsha15010@iiitd.ac.in</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Hi<br>Could someone take out a little time to review the code once?<br>Bug I intend to solve: <a href="https://bugs.winehq.org/show_bug.cgi?id=39640" target="_blank">https://bugs.winehq.org/show_b<wbr>ug.cgi?id=39640</a><br><br><div>I am new to wine. So, I would appreciate suggestions regarding my coding style if that's not-so-perfect according to wine standards. Or any other problems with the code I have written. I apologize for submitting an untested code earlier. I hope now it works fine.<br></div></div></blockquote></span><div>No worries! your efforts in contributing is always appreciated :)</div><div><br></div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>/*----------------------------<wbr>---------------CODE-----------<wbr>------------------------------<wbr>---------*/<br></div></div></blockquote><div>Try using diffs/patches instead of manually copying them in this format. Diffs are easier to apply and test with using git. That's how Stefan was able to detect compilation errors in the patches you sent over on wine-patches. I suggest sending another email with the changes in a diif format if possible.</div><span><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div><b>//DOUBT: </b>Would sizeof(list->pid) be better or sizeof(int)? <br>//Since in the former case,<font face="arial, helvetica, sans-serif"> <span style="color:rgb(0,0,0);font-size:13px;white-space:pre-wrap">since list->pid is actually a pointer to DWORD, so //sizeof(list->pid) would return 8 bytes and not 4 bytes.</span></font></div><div><br></div><div>}<br></div></div></blockquote></span><div>Probably sizeof(DWORD) would be fine as well. In general, try following what the surrounding, previously committed code is doing.</div><div>FWIW, pointers don't necessarily have to be 8 bytes in size. The size of a pointer depends on whether your application is compiled as 32 or 64 bit. It's possible to e.g. compile a program as 32 bit on a 64 bit machine.</div><div>For wine in 64 bit: <a href="https://wiki.winehq.org/FAQ#Is_there_a_64_bit_Wine.3F" target="_blank">https://wiki.winehq.org/F<wbr>AQ#Is_there_a_64_bit_Wine.3F</a></div><div><br></div><div>Cheers,</div><div>Aaryaman</div></div></div></div>
</blockquote></div><br></div></div>
</blockquote></div><br></div>