ReactOS  0.4.12-dev-43-g63b00d8
dbgchnl.c File Reference
#include "precomp.h"
#include <stdio.h>
Include dependency graph for dbgchnl.c:

Go to the source code of this file.

Classes

struct  cce_user
 
struct  dll_option_layout
 

Typedefs

typedef int(* EnumChannelCB) (HANDLE, void *, WCHAR *, void *)
 

Functions

BOOL DebugChannelsAreSupported (void)
 
static int list_channel_CB (HANDLE hProcess, void *addr, WCHAR *buffer, void *user)
 
static int change_channel_CB (HANDLE hProcess, void *addr, WCHAR *buffer, void *pmt)
 
voidget_symbol (HANDLE hProcess, const char *name, const char *lib)
 
static int enum_channel (HANDLE hProcess, EnumChannelCB ce, void *user, unsigned unique)
 
static void DebugChannels_FillList (HWND hChannelLV)
 
static void DebugChannels_OnCreate (HWND hwndDlg)
 
static void DebugChannels_OnNotify (HWND hDlg, LPARAM lParam)
 
static INT_PTR CALLBACK DebugChannelsDlgProc (HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
 
void ProcessPage_OnDebugChannels (void)
 

Typedef Documentation

◆ EnumChannelCB

typedef int(* EnumChannelCB) (HANDLE, void *, WCHAR *, void *)

Definition at line 200 of file dbgchnl.c.

Function Documentation

◆ change_channel_CB()

static int change_channel_CB ( HANDLE  hProcess,
void addr,
WCHAR buffer,
void pmt 
)
static

Definition at line 85 of file dbgchnl.c.

Referenced by DebugChannels_OnNotify().

86 {
87  struct cce_user* user = (struct cce_user*)pmt;
88 
89  if (!user->name || !wcscmp(buffer + 1, user->name))
90  {
91  buffer[0] = (buffer[0] & ~user->mask) | (user->value & user->mask);
92  if (WriteProcessMemory(hProcess, addr, buffer, 1, NULL))
93  user->done++;
94  else
95  user->notdone++;
96  }
97  return 1;
98 }
GLuint buffer
Definition: glext.h:5915
smooth NULL
Definition: ftsmooth.c:416
unsigned mask
Definition: dbgchnl.c:75
unsigned value
Definition: dbgchnl.c:75
unsigned done
Definition: dbgchnl.c:76
unsigned notdone
Definition: dbgchnl.c:77
_Check_return_ _CRTIMP int __cdecl wcscmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
LPCWSTR name
Definition: dbgchnl.c:74
void user(int argc, const char *argv[])
Definition: cmds.c:1350
BOOL NTAPI WriteProcessMemory(IN HANDLE hProcess, IN LPVOID lpBaseAddress, IN LPCVOID lpBuffer, IN SIZE_T nSize, OUT SIZE_T *lpNumberOfBytesWritten)
Definition: proc.c:2086

◆ DebugChannels_FillList()

static void DebugChannels_FillList ( HWND  hChannelLV)
static

Definition at line 262 of file dbgchnl.c.

Referenced by DebugChannels_OnCreate().

263 {
265 
266  (void)ListView_DeleteAllItems(hChannelLV);
267 
269  if (!hProcess) return; /* FIXME messagebox */
270  SendMessageW(hChannelLV, WM_SETREDRAW, FALSE, 0);
271  enum_channel(hProcess, list_channel_CB, (void*)hChannelLV, TRUE);
272  SendMessageW(hChannelLV, WM_SETREDRAW, TRUE, 0);
273  CloseHandle(hProcess);
274 }
#define TRUE
Definition: types.h:120
DWORD GetSelectedProcessId(void)
Definition: procpage.c:99
#define CloseHandle
Definition: compat.h:398
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:47
#define WM_SETREDRAW
Definition: winuser.h:1598
_In_ BOOL _In_ HANDLE hProcess
Definition: mapping.h:70
static int list_channel_CB(HANDLE hProcess, void *addr, WCHAR *buffer, void *user)
Definition: dbgchnl.c:47
HANDLE WINAPI OpenProcess(IN DWORD dwDesiredAccess, IN BOOL bInheritHandle, IN DWORD dwProcessId)
Definition: proc.c:1257
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
static int enum_channel(HANDLE hProcess, EnumChannelCB ce, void *user, unsigned unique)
Definition: dbgchnl.c:208
#define PROCESS_VM_READ
Definition: pstypes.h:153
#define PROCESS_VM_OPERATION
Definition: pstypes.h:152
#define ListView_DeleteAllItems(hwnd)
Definition: commctrl.h:2384

◆ DebugChannels_OnCreate()

static void DebugChannels_OnCreate ( HWND  hwndDlg)
static

Definition at line 276 of file dbgchnl.c.

Referenced by DebugChannelsDlgProc().

277 {
278  HWND hLV = GetDlgItem(hwndDlg, IDC_DEBUG_CHANNELS_LIST);
279  LVCOLUMN lvc;
280 
281  lvc.mask = LVCF_FMT | LVCF_TEXT | LVCF_WIDTH;
282  lvc.fmt = LVCFMT_LEFT;
283  lvc.pszText = L"Debug Channel";
284  lvc.cx = 100;
285  (void)ListView_InsertColumn(hLV, 0, &lvc);
286 
287  lvc.mask = LVCF_FMT | LVCF_TEXT | LVCF_WIDTH;
288  lvc.fmt = LVCFMT_CENTER;
289  lvc.pszText = L"Fixme";
290  lvc.cx = 55;
291  (void)ListView_InsertColumn(hLV, 1, &lvc);
292 
293  lvc.mask = LVCF_FMT | LVCF_TEXT | LVCF_WIDTH;
294  lvc.fmt = LVCFMT_CENTER;
295  lvc.pszText = L"Err";
296  lvc.cx = 55;
297  (void)ListView_InsertColumn(hLV, 2, &lvc);
298 
299  lvc.mask = LVCF_FMT | LVCF_TEXT | LVCF_WIDTH;
300  lvc.fmt = LVCFMT_CENTER;
301  lvc.pszText = L"Warn";
302  lvc.cx = 55;
303  (void)ListView_InsertColumn(hLV, 3, &lvc);
304 
305  lvc.mask = LVCF_FMT | LVCF_TEXT | LVCF_WIDTH;
306  lvc.fmt = LVCFMT_CENTER;
307  lvc.pszText = L"Trace";
308  lvc.cx = 55;
309  (void)ListView_InsertColumn(hLV, 4, &lvc);
310 
312 }
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:47
#define LVCF_WIDTH
Definition: commctrl.h:2557
#define LVCF_TEXT
Definition: commctrl.h:2558
#define LVCFMT_CENTER
Definition: commctrl.h:2570
#define LVCFMT_LEFT
Definition: commctrl.h:2568
#define LVCOLUMN
Definition: commctrl.h:2551
#define ListView_InsertColumn(hwnd, iCol, pcol)
Definition: commctrl.h:2606
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
#define IDC_DEBUG_CHANNELS_LIST
Definition: resource.h:29
static const WCHAR L[]
Definition: oid.c:1087
static void DebugChannels_FillList(HWND hChannelLV)
Definition: dbgchnl.c:262
#define LVCF_FMT
Definition: commctrl.h:2556

◆ DebugChannels_OnNotify()

static void DebugChannels_OnNotify ( HWND  hDlg,
LPARAM  lParam 
)
static

Definition at line 314 of file dbgchnl.c.

Referenced by DebugChannelsDlgProc().

315 {
316  NMHDR* nmh = (NMHDR*)lParam;
317 
318  switch (nmh->code)
319  {
320  case NM_CLICK:
321  if (nmh->idFrom == IDC_DEBUG_CHANNELS_LIST)
322  {
323  LVHITTESTINFO lhti;
324  HWND hChannelLV;
327 
329  if (!hProcess) return; /* FIXME message box */
330  lhti.pt = nmia->ptAction;
331  hChannelLV = GetDlgItem(hDlg, IDC_DEBUG_CHANNELS_LIST);
332  SendMessageW(hChannelLV, LVM_SUBITEMHITTEST, 0, (LPARAM)&lhti);
333  if (nmia->iSubItem >= 1 && nmia->iSubItem <= 4)
334  {
335  WCHAR val[2];
336  WCHAR name[32];
337  unsigned bitmask = 1 << (lhti.iSubItem - 1);
338  struct cce_user user;
339 
340  ListView_GetItemText(hChannelLV, lhti.iItem, 0, name, sizeof(name) / sizeof(name[0]));
341  ListView_GetItemText(hChannelLV, lhti.iItem, lhti.iSubItem, val, sizeof(val) / sizeof(val[0]));
342  user.name = name;
343  user.value = (val[0] == L'x') ? 0 : bitmask;
344  user.mask = bitmask;
345  user.done = user.notdone = 0;
347  if (user.done)
348  {
349  val[0] ^= (L'x' ^ L' ');
350  ListView_SetItemText(hChannelLV, lhti.iItem, lhti.iSubItem, val);
351  }
352  if (user.notdone)
353  printf("Some channel instance weren't correctly set\n");
354  }
355  CloseHandle(hProcess);
356  }
357  break;
358  }
359 }
DWORD GetSelectedProcessId(void)
Definition: procpage.c:99
#define CloseHandle
Definition: compat.h:398
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define ListView_GetItemText(hwndLV, i, iSubItem_, pszText_, cchTextMax_)
Definition: commctrl.h:2654
_In_ BOOL _In_ HANDLE hProcess
Definition: mapping.h:70
UINT code
Definition: winuser.h:3112
#define LVM_SUBITEMHITTEST
Definition: commctrl.h:2734
LONG_PTR LPARAM
Definition: windef.h:208
UINT_PTR idFrom
Definition: winuser.h:3111
GLuint GLfloat * val
Definition: glext.h:7180
#define ListView_SetItemText(hwndLV, i, iSubItem_, pszText_)
Definition: commctrl.h:2661
#define PROCESS_VM_WRITE
Definition: pstypes.h:154
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
#define IDC_DEBUG_CHANNELS_LIST
Definition: resource.h:29
static const WCHAR L[]
Definition: oid.c:1087
#define NM_CLICK
Definition: commctrl.h:130
HANDLE WINAPI OpenProcess(IN DWORD dwDesiredAccess, IN BOOL bInheritHandle, IN DWORD dwProcessId)
Definition: proc.c:1257
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
static int enum_channel(HANDLE hProcess, EnumChannelCB ce, void *user, unsigned unique)
Definition: dbgchnl.c:208
static int change_channel_CB(HANDLE hProcess, void *addr, WCHAR *buffer, void *pmt)
Definition: dbgchnl.c:85
#define PROCESS_VM_READ
Definition: pstypes.h:153
Definition: name.c:36
#define PROCESS_VM_OPERATION
Definition: pstypes.h:152
LPARAM lParam
Definition: combotst.c:139
void user(int argc, const char *argv[])
Definition: cmds.c:1350
#define printf
Definition: config.h:203
GLuint const GLchar * name
Definition: glext.h:6031

◆ DebugChannelsAreSupported()

BOOL DebugChannelsAreSupported ( void  )

Definition at line 39 of file dbgchnl.c.

Referenced by ProcessPageShowContextMenu().

40 {
41 #ifdef WINE
42  return TRUE;
43 #endif
44  return FALSE;
45 }
#define TRUE
Definition: types.h:120

◆ DebugChannelsDlgProc()

static INT_PTR CALLBACK DebugChannelsDlgProc ( HWND  hDlg,
UINT  message,
WPARAM  wParam,
LPARAM  lParam 
)
static

Definition at line 361 of file dbgchnl.c.

Referenced by ProcessPage_OnDebugChannels().

362 {
363  switch (message)
364  {
365  case WM_INITDIALOG:
367  return TRUE;
368  case WM_COMMAND:
369  if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL) {
370  EndDialog(hDlg, LOWORD(wParam));
371  return TRUE;
372  }
373  break;
374  case WM_NOTIFY:
376  break;
377  }
378  return FALSE;
379 }
Definition: tftpd.h:59
#define TRUE
Definition: types.h:120
#define IDOK
Definition: winuser.h:824
static void DebugChannels_OnNotify(HWND hDlg, LPARAM lParam)
Definition: dbgchnl.c:314
BOOL WINAPI EndDialog(_In_ HWND, _In_ INT_PTR)
WPARAM wParam
Definition: combotst.c:138
static void DebugChannels_OnCreate(HWND hwndDlg)
Definition: dbgchnl.c:276
#define WM_COMMAND
Definition: winuser.h:1716
#define IDCANCEL
Definition: winuser.h:825
#define WM_INITDIALOG
Definition: winuser.h:1715
LPARAM lParam
Definition: combotst.c:139
#define LOWORD(l)
Definition: pedump.c:82
#define WM_NOTIFY
Definition: richedit.h:61

◆ enum_channel()

static int enum_channel ( HANDLE  hProcess,
EnumChannelCB  ce,
void user,
unsigned  unique 
)
static

Definition at line 208 of file dbgchnl.c.

Referenced by DebugChannels_FillList(), and DebugChannels_OnNotify().

209 {
210  struct dll_option_layout dol;
211  int ret = 1;
212  void* buf_addr;
213  WCHAR buffer[32];
214  void* addr;
215  WCHAR** cache = NULL;
216  unsigned i, j, num_cache, used_cache;
217 
218  addr = get_symbol(hProcess, "first_dll", "libwine.so");
219  if (!addr) return -1;
220  if (unique)
221  cache = HeapAlloc(GetProcessHeap(), 0, (num_cache = 32) * sizeof(WCHAR*));
222  else
223  num_cache = 0;
224  used_cache = 0;
225 
226  for (;
227  ret && addr && ReadProcessMemory(hProcess, addr, &dol, sizeof(dol), NULL);
228  addr = dol.next)
229  {
230  for (i = 0; i < dol.nb_channels; i++)
231  {
232  if (ReadProcessMemory(hProcess, (void*)(dol.channels + i), &buf_addr, sizeof(buf_addr), NULL) &&
233  ReadProcessMemory(hProcess, buf_addr, buffer, sizeof(buffer), NULL))
234  {
235  if (unique)
236  {
237  /* since some channels are defined in multiple compilation units,
238  * they will appear several times...
239  * so cache the channel's names we already reported and don't report
240  * them again
241  */
242  for (j = 0; j < used_cache; j++)
243  if (!wcscmp(cache[j], buffer + 1)) break;
244  if (j != used_cache) continue;
245  if (used_cache == num_cache)
246  cache = HeapReAlloc(GetProcessHeap(), 0, cache, (num_cache *= 2) * sizeof(WCHAR*));
247  cache[used_cache++] = wcscpy(HeapAlloc(GetProcessHeap(), 0, (wcslen(buffer + 1) + 1) * sizeof(WCHAR)),
248  buffer + 1);
249  }
250  ret = ce(hProcess, buf_addr, buffer, user);
251  }
252  }
253  }
254  if (unique)
255  {
256  for (j = 0; j < used_cache; j++) HeapFree(GetProcessHeap(), 0, (WCHAR*)cache[j]);
257  HeapFree(GetProcessHeap(), 0, cache);
258  }
259  return 0;
260 }
Definition: cache.c:46
GLenum GLclampf GLint GLenum GLuint GLenum GLenum GLsizei GLenum const GLvoid GLfloat GLfloat GLfloat GLfloat GLclampd GLint GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean GLboolean GLboolean GLboolean GLint GLenum GLsizei const GLvoid GLenum GLint GLenum GLint GLint GLsizei GLint GLenum GLint GLint GLint GLint GLsizei GLenum GLsizei const GLuint GLboolean GLenum GLenum GLint GLsizei GLenum GLsizei GLenum const GLvoid GLboolean const GLboolean GLenum const GLdouble const GLfloat const GLdouble const GLfloat GLenum GLint GLint GLint GLint GLint GLint j
Definition: glfuncs.h:98
__wchar_t WCHAR
Definition: xmlstorage.h:180
GLuint buffer
Definition: glext.h:5915
#define ReadProcessMemory(a, b, c, d, e)
Definition: compat.h:415
GLenum GLclampf GLint i
Definition: glfuncs.h:14
void * get_symbol(HANDLE hProcess, const char *name, const char *lib)
Definition: dbgchnl.c:185
smooth NULL
Definition: ftsmooth.c:416
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
int ret
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
GLenum const GLvoid * addr
Definition: glext.h:9621
_Check_return_ _CRTIMP int __cdecl wcscmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
#define HeapReAlloc
Definition: compat.h:393
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define HeapFree(x, y, z)
Definition: compat.h:394

◆ get_symbol()

void* get_symbol ( HANDLE  hProcess,
const char name,
const char lib 
)

Definition at line 185 of file dbgchnl.c.

Referenced by change_channel_CB(), and enum_channel().

186 {
187  printf("get_symbol: not implemented on this platform\n");
188  return NULL;
189 }
smooth NULL
Definition: ftsmooth.c:416
#define printf
Definition: config.h:203

◆ list_channel_CB()

static int list_channel_CB ( HANDLE  hProcess,
void addr,
WCHAR buffer,
void user 
)
static

Definition at line 47 of file dbgchnl.c.

Referenced by DebugChannels_FillList().

48 {
49  int j;
50  WCHAR val[2];
51  LVITEM lvi;
52  int index;
53  HWND hChannelLV = (HWND)user;
54 
55  memset(&lvi, 0, sizeof(lvi));
56 
57  lvi.mask = LVIF_TEXT;
58  lvi.pszText = buffer + 1;
59 
60  index = ListView_InsertItem(hChannelLV, &lvi);
61  if (index == -1) return 0;
62 
63  val[1] = L'\0';
64  for (j = 0; j < 4; j++)
65  {
66  val[0] = (buffer[0] & (1 << j)) ? L'x' : L' ';
67  ListView_SetItemText(hChannelLV, index, j + 1, val);
68  }
69  return 1;
70 }
GLenum GLclampf GLint GLenum GLuint GLenum GLenum GLsizei GLenum const GLvoid GLfloat GLfloat GLfloat GLfloat GLclampd GLint GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean GLboolean GLboolean GLboolean GLint GLenum GLsizei const GLvoid GLenum GLint GLenum GLint GLint GLsizei GLint GLenum GLint GLint GLint GLint GLsizei GLenum GLsizei const GLuint GLboolean GLenum GLenum GLint GLsizei GLenum GLsizei GLenum const GLvoid GLboolean const GLboolean GLenum const GLdouble const GLfloat const GLdouble const GLfloat GLenum GLint GLint GLint GLint GLint GLint j
Definition: glfuncs.h:98
__wchar_t WCHAR
Definition: xmlstorage.h:180
HANDLE HWND
Definition: compat.h:13
GLuint buffer
Definition: glext.h:5915
#define ListView_InsertItem(hwnd, pitem)
Definition: commctrl.h:2378
#define LVIF_TEXT
Definition: commctrl.h:2279
GLuint GLfloat * val
Definition: glext.h:7180
#define ListView_SetItemText(hwndLV, i, iSubItem_, pszText_)
Definition: commctrl.h:2661
#define index(s, c)
Definition: various.h:29
static const WCHAR L[]
Definition: oid.c:1087
#define LVITEM
Definition: commctrl.h:2345
#define memset(x, y, z)
Definition: compat.h:39

◆ ProcessPage_OnDebugChannels()

void ProcessPage_OnDebugChannels ( void  )

Definition at line 381 of file dbgchnl.c.

Referenced by TaskManagerWndProc().

382 {
384 }
#define IDD_DEBUG_CHANNELS_DIALOG
Definition: resource.h:28
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
#define DialogBoxW(i, t, p, f)
Definition: winuser.h:4268
static INT_PTR CALLBACK DebugChannelsDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
Definition: dbgchnl.c:361
HWND hMainWnd
Definition: magnifier.c:33
HINSTANCE hInst
Definition: dxdiag.c:13