겸손한 개발을 위한 자양분

사용자 삽입 이미지
예외정보를 무작정... 확인하기 위하여,
Access Violation 을 일으키는 간단한 어플리케이션을 만들었습니다.

다음은 에러가 발생한 Process 의 정보입니다.

kd> !process 81d2b9e0 
PROCESS 81d2b9e0  SessionId: 0  Cid: 06d8    Peb: 7ffdf000  ParentCid: 05a4
    DirBase: 065402c0  ObjectTable: e1d46190  HandleCount:  43.
    Image: accessviolation.exe
    VadRoot 81d2d9a0 Vads 45 Clone 0 Private 91. Modified 9. Locked 0.
    DeviceMap e188e0b0
    Token                             e10927d0
    ElapsedTime                       00:00:21.625
    UserTime                          00:00:00.015
    KernelTime                        00:00:00.031
    QuotaPoolUsage[PagedPool]         33308
    QuotaPoolUsage[NonPagedPool]      1800
    Working Set Sizes (now,min,max)  (540, 50, 345) (2160KB, 200KB, 1380KB)
    PeakWorkingSetSize                540
    VirtualSize                       16 Mb
    PeakVirtualSize                   20 Mb
    PageFaultCount                    592
    MemoryPriority                    BACKGROUND
    BasePriority                      8
    CommitCharge                      111
        THREAD 81d34a48  Cid 06d8.06d4  Teb: 7ffde000 Win32Thread: e1092ac0 WAIT: (UserRequest) UserMode Non-Alertable
            82034198  SynchronizationEvent
            8207f768  ProcessObject
            81d34b38  NotificationTimer
        Not impersonating
        DeviceMap                 e188e0b0
        Owning Process            81d2b9e0       Image:         accessviolation.exe
        Attached Process          N/A            Image:         N/A
        Wait Start TickCount      9254           Ticks: 1 (0:00:00:00.015)
        Context Switch Count      104                 LargeStack
        UserTime                  00:00:00.000
        KernelTime                00:00:00.031
        Win32 Start Address accessviolation (0x004013e2)
        Start Address kernel32!BaseProcessStartThunk (0x7c810867)
        Stack Init b26f6000 Current b26f595c Base b26f6000 Limit b26f1000 Call 0
        Priority 9 BasePriority 8 PriorityDecrement 0 DecrementCount 16

MS Windows 는 예외나 인터럽트가 발생할 경우 Trap Frame을 생성하여 이를 관리합니다.
이 Trap Frame 은 KTHREAD 에서 확인할 수 있고, 해당 쓰레드의 Thread Context 정보를 확인할 수 있습니다.

kd> dt nt!_KTHREAD 81d34a48 
   +0x000 Header           : _DISPATCHER_HEADER

...

   +0x128 Preempted        : 0 ''
   +0x129 ProcessReadyQueue : 0 ''
   +0x12a KernelStackResident : 0x1 ''
   +0x12b NextProcessor    : 0 ''
   +0x12c CallbackStack    : (null)
   +0x130 Win32Thread      : 0xe1092ac0
   +0x134 TrapFrame        : 0xb26f5d64 _KTRAP_FRAME
   +0x138 ApcStatePointer  : [2] 0x81d34a7c _KAPC_STATE
   +0x140 PreviousMode     : 1 ''
   +0x141 EnableStackSwap  : 0x1 ''
   +0x142 LargeStack       : 0x1 ''
   +0x143 ResourceIndex    : 0 ''
   +0x144 KernelTime       : 2
   +0x148 UserTime         : 0
   +0x14c SavedApcState    : _KAPC_STATE
   +0x164 Alertable        : 0 ''
   +0x165 ApcStateIndex    : 0 ''
   +0x166 ApcQueueable     : 0x1 ''
   +0x167 AutoAlignment    : 0 ''
   +0x168 StackBase        : 0xb26f6000
   +0x16c SuspendApc       : _KAPC
   +0x19c SuspendSemaphore : _KSEMAPHORE
   +0x1b0 ThreadListEntry  : _LIST_ENTRY [ 0x81d2ba30 - 0x81d2ba30 ]
   +0x1b8 FreezeCount      : 0 ''
   +0x1b9 SuspendCount     : 0 ''
   +0x1ba IdealProcessor   : 0 ''
   +0x1bb DisableBoost     : 0 ''


kd> dt nt!_KTRAP_FRAME 0xb26f5d64
   +0x000 DbgEbp           : 0x12dbb0
   +0x004 DbgEip           : 0x7c90eb94
   +0x008 DbgArgMark       : 0xbadb0d00
   +0x00c DbgArgPointer    : 0x12db1c
   +0x010 TempSegCs        : 0
   +0x014 TempEsp          : 0
   +0x018 Dr0              : 0
   +0x01c Dr1              : 0
   +0x020 Dr2              : 0
   +0x024 Dr3              : 0
   +0x028 Dr6              : 0
   +0x02c Dr7              : 0
   +0x030 SegGs            : 0
   +0x034 SegEs            : 0x23
   +0x038 SegDs            : 0x23
   +0x03c Edx              : 0x7c90eb94
   +0x040 Ecx              : 0x1000
   +0x044 Eax              : 0x8e0000
   +0x048 PreviousPreviousMode : 1
   +0x04c ExceptionList    : 0xffffffff _EXCEPTION_REGISTRATION_RECORD
   +0x050 SegFs            : 0x3b
   +0x054 Edi              : 0x7ffdf000
   +0x058 Esi              : 0
   +0x05c Ebx              : 0x12db3c
   +0x060 Ebp              : 0x12dbb0
   +0x064 ErrCode          : 0
   +0x068 Eip              : 0x7c90eb94
   +0x06c SegCs            : 0x1b
   +0x070 EFlags           : 0x246
   +0x074 HardwareEsp      : 0x12db14
   +0x078 HardwareSegSs    : 0x23
   +0x07c V86Es            : 0
   +0x080 V86Ds            : 0
   +0x084 V86Fs            : 0
   +0x088 V86Gs            : 0


예외(에러)가 발생한 경우, 프로세스는 예외 핸들러를 호출하게 되고,
예외 핸들러가 등록되지 않은 경우 시스템의 기본 예외 핸들러를 호출합니다.
그리고, 예외 핸들러가 호출 될때에는 _EXCEPTION_RECORD 구조체를 넘겨주게 됩니다.

따라서, 예외가 발생한 쓰레드의 Call Stack 을 이용하여, _EXCEPTION_RECORD 를 확인할 수 있습니다.

위의 _KTHREAD 구조체에서, 현재 Stack 의 Base Pointer 는 0x12dbb0 입니다.

kd> dds 0x12dbb0
0012dbb0  0012dbcc ; 이전의 스택프레임
0012dbb4  7c809c86 kernel32!WaitForMultipleObjects+0x18 ; 복귀주소
0012dbb8  00000002
0012dbbc  0012dce0
0012dbc0  00000000

Stack Frame 의 구조에 따라, 복귀 주소가 0x0012dbcc 이므로,
호출 관계를 따라갈 수 있습니다.

kd> dds 0012dbcc 
0012dbcc  0012e560
0012dbd0  6945763c faultrep!StartDWException+0x5df
0012dbd4  00000002
0012dbd8  0012dce0
0012dbdc  00000000

kd> dds 0012e560
0012e560  0012f5d4
0012e564  694582b1 faultrep!ReportFault+0x533
0012e568  0012f884
0012e56c  ffffffff
0012e570  00198310


호출 관계를 따라가면서, 함수의 호출 위치를 확인합니다.
아래는 faultrep!ReportFault+0x533 의 복귀주소를 갖고 호출된 함수의 호출부입니다. 

6945828d 7405            je      faultrep!ReportFault+0x516 (69458294)
6945828f b8a4184569      mov     eax,offset faultrep!`string'+0x3c8 (694518a4)
69458294 8985fcefffff    mov     dword ptr [ebp-1004h],eax
6945829a 6aff            push    0FFFFFFFFh
6945829c 50              push    eax
6945829d ffb520f0ffff    push    dword ptr [ebp-0FE0h]
694582a3 ff750c          push    dword ptr [ebp+0Ch]
694582a6 ffb510f0ffff    push    dword ptr [ebp-0FF0h]

694582ac e8acedffff      call    faultrep!StartDWException (6945705d)
694582b1 eb3e            jmp     faultrep!ReportFault+0x573 (694582f1)
694582b3 399d24f0ffff    cmp     dword ptr [ebp-0FDCh],ebx
694582b9 741f            je      faultrep!ReportFault+0x55c (694582da)

StartDWException 함수는 DrWatson 의 예외처리 프로세스를 시작하는 함수로 추측되며,
다섯개의 인자를 받고 있습니다.

DrWatson 에서 해당 프로세스의 에러 정보를 처리하므로,
저 다섯가지의 인자에서 _EXCEPTION_RECORD 를 확인할 수 있다는 것을 유추할 수 있습니다.
해당 인자들의 위치를, 호출 스택의 구조에 따라 확인하면 다음과 같습니다.

kd> dds 0012e560
0012e560  0012f5d4
0012e564  694582b1 faultrep!ReportFault+0x533
0012e568  0012f884 ; 첫번째 인자
0012e56c  ffffffff ; 두번째 인자
0012e570  00198310 ; 세번째 인자
0012e574  0012f2ac ; 네번째 인자
0012e578  ffffffff ; 다섯번째 인자

0012e57c  00000000

첫번째 인자를 확인하면 다음과 같습니다.
kd> dd 0012f884
0012f884  0012f978 0012f994 0012f8b0 7c9037bf

해당 인자가 스택을 가리키고 있으므로, 포인터로 볼 수 있습니다.
따라서, 다시 내용을 확인하면,

kd> dd 0012f978
0012f978  c0000005 00000000 00000000 00401de4
0012f988  00000002 00000001 00401000 0001003f

kd> dt nt!_EXCEPTION_RECORD 0012f978
   +0x000 ExceptionCode    : c0000005 ; Access Violation
   +0x004 ExceptionFlags   : 0
   +0x008 ExceptionRecord  : (null)
   +0x00c ExceptionAddress : 0x00401de4
   +0x010 NumberParameters : 2
   +0x014 ExceptionInformation : [15] 1

위와 같이 _EXCEPTION_RECORD 인 것을 확인할 수 있고,
예외가 발생한 주소와, 예외 코드를 알 수 있습니다.

일주일 전 즈음,
서점에서 보물과도 같은 책을 찾았습니다.

공문선씨의 '히든 커뮤니케이션'이라는 책인데,
정말, 물건입니다.

오늘 아침 출근길에 읽은 내용중
가슴에 와 닿는 부분을 새겨놓습니다.


 충고를 좋아하는 사람은 아무도 없다. 하다못해 어린 아이들조차 충고를 싫어한다.
 사람들이 충고를 싫어하는 이유는 듣기 싫은 말을 회피하는 '지각의 방어 현상' 때문이다. 자신의 믿음과 상반되는 말에 대해 자신을 보호하고, 자신의 생각이 틀렸음을 인정하지 않으려는 심리가 작용하는 것이다.
 그렇다면 상대가 당신의 충고에 귀 기울이고 기분 좋게 인정하게 하려면 어떻게 해야 할까?

 충고를 할 때는 마치 의사처럼 상대의 상태와 상황을 정확히 알고 해결에 필요한 알맞은 말을 해줘야 효과적이다.
 의사들은 병원을 찾은 환자에게 왜 병에 걸렸냐고 혼내기보다 치료법에 집중한다. 하지만 직장상사들 중에는 부하직원들에게 충고할 때 잘잘못의 원인만을 따지면서 무조건 앞으로 그렇게 하지 말라고 다그치는 사람들이 많은데, 충고는 비판이나 비난이 아니다. 충고하는 사람이 잘못된 점이나 고쳐야 할 점만 지적하면 듣는 사람은 '나도 안다고! 이제 그만하라고! 그래서 어쩌라고?' 하는 부정적인 생각에 가득 차게 된다.
 따라서, 무턱대고 상대의 잘못을 비난하지 말고 문제점에 대한 원인을 제시하고 대안이나 해결책을 같이 찾으려는 노력을 기울여야 한다.

Site settings could not be loaded

We were unable to locate the API to request site settings. Please see below for debugging information.

HTTP Response Status Code: 0

Trying API autodiscovery:

The API is currently located at http://localhost:8081/deki.
Trying http://192.168.10.102:10080/@api/deki ... failed (HTTP Status: 503)


Deki 를 사용하다가 위와 같은 에러가 발생하면, Deki Host 가 정상 작동하지 않는 경우입니다.

이 때는,
%dekiwiki%\config\ 폴더에 있는
mindtouch.host.bat 파일을 실행하여, Deki Host 를 실행하여야 하는데,
콘솔에서 동작하는 프로그램이기 때문에, 컴퓨터를 재부팅하고 로그인하기 전에는 동작하지 않습니다.


아파치 서버처럼 서비스로 등록하는 방법은 다음과 같습니다.

1. 여기를 클릭하여 파일을 다운받은 후 임의의 디렉토리에 압축을 풀어줍니다

2. cmd.exe 창을 띄워 압축을 푼 디렉토리에서 다음과 같이 실행합니다.

instsrv dekihost %절대경로%\srvany.exe

예 ) c:\reskit>instsrv dekihost c:\reskit\srvany.exe


3. Regedit.exe 를 실행하여 HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\dekihost 으로 이동합니다.

4. dekihost 에 Parameters라는 키를 만들고 다음과 같은 문자열 키를 생성합니다.

AppDirectory      // dekiwiki\bin 패스 설정
Application        // dekiwiki\bin 폴더의 mindtouch.host.exe 를 설정
AppParameters  // mindtoych.host.bat 파일을 메모장으로 열어 실행 아규먼트 값을 설정


예 )

사용자 삽입 이미지


5. services.msc 를 실행하여 dekihost 서비스를 시작시킵니다

사용자 삽입 이미지

끝.


원문 : http://wiki.developer.mindtouch.com/MindTouch_Deki/Installation_and_Upgrade/1.8_Hayes_Official_Install_and_Upgrade_Guide/Windows/Dekihost_Windows_Service

http://msdn.microsoft.com/en-us/library/bb773173(VS.85).aspx

Windows Controls

A control is a child window that an application uses in conjunction with another window to enable user interaction. Controls are most often used within dialog boxes, but they can also be used in other windows. Controls within dialog boxes provide the user with a way to type text, choose options, and initiate actions. Controls in other windows provide a variety of services, such as letting the user choose commands, view status, and view and edit text.

The common controls overview documentation describes the common controls delivered in Microsoft Windows and the programming elements used to create and manipulate them.

The following table lists the Windows controls.

Control

Description

Animation

A window that displays an Audio-Video Interleaved (AVI) clip.

Button

Notifies the parent window when the user selects the control.

Combo Box

A combination of a list box and an edit control, enabling the user to select or add items.

ComboBoxEx

An extension of the combo box control that provides native support for item images.

Date and Time Picker

A simple and intuitive interface through which to exchange date and time information with a user.

Drag List Box

A type of list box that enables the user to drag items from one position to another.

Edit

A window within the user can view and edit text.

Flat Scroll Bar

A scroll bar with a more customizable appearance than standard scroll bars.

Header

A window that is usually positioned above columns of text or numbers. It contains a title for each column, and it can be divided into parts.

Hot Key

A window that enables the user to enter a combination of keystrokes to be used as a hot key.

Image Lists

A collection of images of the same size, each of which can be referred to by its index.

IP Address

A window in which the user can enter an Internet Protocol (IP) address in an easily understood format.

List Box

A simple list from which the user can select one or more items.

List-View

A list box that provides several ways to arrange and display the items.

Month Calendar

A calendar that enables the user to select a date or dates.

Pager

A set of arrow buttons that enable the contents of a control window to be scrolled.

Progress Bar

An animated control that indicates the progress of a lengthy operation.

Property Sheet

A dialog box that enables the user to view and edit the properties of an item. Pages may be viewed as tabs, or in succession as a wizard.

ReBar

A container for child windows. An application assigns child windows, which are often other controls, to a rebar control band.

Rich Edit

A window in which the user can view and edit text with character and paragraph formatting. It can also contain embedded COM objects.

Scroll Bar

A control that enables the user to choose the direction and distance to scroll information in a related window.

Static

Non-interactive text, including labels for other controls.

Status Bar

A horizontal window at the bottom of a parent window in which an application can display various kinds of status information.

SysLink

A hypertext link.

Tab

A selectable page, analogous to a divider in a notebook. By using a tab control, an application can define multiple pages for the same area of a window or dialog box.

Task Dialog

A more powerful alternative to simple message boxes, incorporating elements such as custom buttons, radio buttons, hyperlinks, and progress bars.

Toolbar

A window that contains one or more buttons and possibly other controls.

ToolTip

A message that appears automatically when the mouse pointer hovers over a tool.

Trackbar

A slider with optional tick marks, used to set a value within a range.

Tree-View

A hierarchical list of items, such as the headings in a document or the files and directories on a disk.

Up-Down

A pair of arrow buttons that the user can click to increment or decrement a value, such as a scroll position or a number displayed in a companion control.