Inside Kernel

September 18, 2008

announcing new kernel blog!

Filed under: Uncategorized — heejune @ 2:49 pm

Jeff started writing his new technical blog about Windows Kernel and OS Internals. Strongly recommend visit the new website!

http://blogs.msdn.com/coreinternals/ (english version)

http://blogs.msdn.com/kocoreinternals/ (korean version)

August 3, 2008

Disassemble ExAcquireResourceExclusiveLite

Filed under: Uncategorized — heejune @ 3:46 pm

This article describe how ExAcquireResourceExclusiveList works by diassembling.

 

view Disassemble ExAcquireResourceExclusiveLite

IDA tips

Filed under: Uncategorized — heejune @ 2:25 pm

IDA is a one of the greatest disassemble tool in the world. Unfortunately it’s not that easy to utilize, but if you once get used to a few shortcuts, then it will dramatically improve the skills of disassembling.

 

view IDA tips

July 26, 2008

[tip] HOWTO SVN server on Windows

Filed under: Uncategorized — heejune @ 1:17 pm
This is a brief tip for who want to install and use Subversion server on your local computers. This might be also just another version of thousands of SVN documents on the net, but I don’t use apache to run SVN so this going to be a little easier only if you don’t care security issues. That’s why I mentioned ‘brief’ at beginning.

First download SVN setup file and install it.

You can find out how to configure and run SVN as Windows service from included help file. Open command console with administrator privilege and type following command. But I recommend make batch file which can be used after.

Register the SVN as windows service.

‘net start svn’ command will start registered SVN service. Of course you should have admin privilege.

Next you need to edit svnserve.conf configuration file. Actualy the file is quiete stragitfoward to understand so all you need to do is un-comment the ‘password-db’ line to use ‘passwd’ as password authentification file. This will make you easily maintain your SVN just in case when you should install new OS or move your repository to other computer.

And make new account to ‘passwd’ file. For example I created new id ‘heejune’ and set password as well following it.

That’s all!  When you commit or update source file from your SVN repository on local computer, it will ask id and password. Then just type in what you created in ‘passwd’ file.

Okay you will see everything goes well like following capture.

Thanks.

May 3, 2008

newer version Windbg released (6.9.3.113)

Filed under: Windbg — heejune @ 3:01 pm

Last Tuesday (April 29), the Windbg has been updated to 6.9.3.113. Visit the official site.

February 13, 2008

x64 Structured Exception Handling

Filed under: x64 — heejune @ 2:22 pm

while moving x64 environment, Structured Exception Handling has been also changed a lot. This article explains about x64 Structured Exception Handling with disassembled x64 sample binary and the output of dump program which shows all tables and structured used by exception process.

download as PDF

x64 SEH

January 31, 2008

Linked List : 실제 커널 개발 환경에서 참고할 점

Filed under: Uncategorized — heejune @ 4:55 pm

외부 라이브러리 사용에 있어서 제약이 많은 커널 개발 환경에서는 처리할 데이터가 많지 않고, 단순한 형태의 iteration/search 기능이 필요할 때 대부분 linked list 자료구조를 선택하게 된다. Linked list의 구현이나 이용에는 큰 어려움이 따르지 않고 이미 드라이버 개발 환경에도 헤더 파일(winnt.h, wdm.h)을 통하여 관련 함수에 대한 코드를 제공하고 있다.

 

특히 linked list를 활용한 iteration의 예는 쉽게 찾아볼 수 있는데, 가장 자주 눈에 띄는 것으로는 EPROCESS, ETHREAD와 같은 커널 객체들을 스케쥴링 및 iteration 할 때이다.

 

Winnt.h 에는 single/double linked list를 위한 구조체가 정의되어 있다.

 

//
//  Doubly linked list structure.  Can be used as either a list head, or
//  as link words.
//
 

typedef struct _LIST_ENTRY {
   struct _LIST_ENTRY *Flink;
   struct _LIST_ENTRY *Blink;
} LIST_ENTRY, *PLIST_ENTRY, *RESTRICTED_POINTER PRLIST_ENTRY;
 

//
//  Singly linked list structure. Can be used as either a list head, or
//  as link words.
//
 

typedef struct _SINGLE_LIST_ENTRY {
    struct _SINGLE_LIST_ENTRY *Next;
} SINGLE_LIST_ENTRY, *PSINGLE_LIST_ENTRY;
 

 

linked list들을 다루는 함수들은 wdm.hinline으로 정의되어 있다.

 

FORCEINLINE
VOID
InitializeListHead(
    IN PLIST_ENTRY ListHead
    )
{
    ListHead->Flink = ListHead->Blink = ListHead;
}
 

FORCEINLINE
BOOLEAN
RemoveEntryList(
    IN PLIST_ENTRY Entry
    )
{
    PLIST_ENTRY Blink;
    PLIST_ENTRY Flink;
 

    Flink = Entry->Flink;
    Blink = Entry->Blink;
    Blink->Flink = Flink;
    Flink->Blink = Blink;
    return (BOOLEAN)(Flink == Blink);
}
 

위의 코드에서 볼 수 있듯 커널에서 제공하는 기본 함수 내부에는 동기화 코드가 있지 않으므로 만약 이 linked list 자료구조를 다룰 때 동기화 기능이 필요하다면 함수를 호출하기 전 외부에서 직접 동기화 처리를 해 주거나, SLIST_HEADER 구조체를 이용하여 동기화 기능이 추가된 single/double linked list 관련 함수들을 사용해야 한다.

 

실제 상용 코드를 개발할 때에는 거의 대부분 list에 대한 동기화가 필요하다. 일반적으로 event, mutex, IRQL 레벨에 따라 spinlock을 사용해야 한다. 커널에서 제공하는 동기화 포함 list 조작 함수인 ExInterlocked 함수들(-ExInterlockedPushEntrySList)은 어떠한 IRQL에서도 동작할 수 있다.

 

LIST_ENTRY 필드를 추가하여 각자 고유한 구조체를 정의하였을 경우 구조체의 시작 포인터 주소를 얻어야 하는 경우가 빈번하게 발생하는데 그럴 때를 위하여 CONTAINING_RECORD라는 매크로가 이미 정의되어 있다.
 

//
// Calculate the address of the base of the structure given its type, and an
// address of a field within the structure.
//
#define CONTAINING_RECORD(address, type, field) ((type *)( \
                                                  (PCHAR)(address) - \
                                                  (ULONG_PTR)(&((type *)0)->field)))
 

 

특히 LIST_ENTRY를 이용하여 개발했을 경우에는 WinDBG를 통해 list 코드의 디버깅을 할 때 DL 이라는 커맨드를 활용하면 쉽게 그 리스트의 내용을 덤프할 수도 있다.

(참고: http://blogs.msdn.com/doronh/archive/2006/08/09/693765.aspx)

 

 

linked list는 그 구조와 구현이 단순하여 만약 list를 활용하는 코드와 관련한 에러가 발생하면 비교적 쉽게 대처가 가능하다. 우선 포인터가 올바른지 확인하고 WinDBG를 통해 list prev, next 필드가 올바른 메모리 위치나 list를 가르치고 있는지 확인하는 것이 가장 중요하다. 또한 IRQLDISPATCH_LEVEL 이상이라면 list가 할당된 메모리가 non-paged pool인지도 반드시 확인하자. 동기화 코드에서 문제가 발생한다면 좀 해결하기에 난감하겠지만, 이때에도 IRQL과 데드락을 의심해보고, 또는 원시적인 방법이지만 디버그 메시지를 통해 문제의 원인을 해결하도록 한다.

 

윈도우 커널에서 제공하는 보다 자세한 linked list 구현 내용은 아래 osr 링크를 참고하도록 하자.

Kernel-Mode Basics: Windows Linked Lists

November 13, 2007

Crash Dump Analysis Patterns Translation

Filed under: Dump analysis — heejune @ 12:58 pm

저는 지금 지난 07년 4월부터 www.dumpanalysis.org의 Crash Dump Analysis Pattern들을 번역해오고 있습니다. 주로 www.driveronline.org의 SystemTeam 게시판에 글을 올리고 있으며, 이곳 insidekernel.net의 follow-up이 늦은 편입니다. 글들이 산발적으로 흩어져 있고, 무엇보다 그림 포함 여부에 따라 텍스트나 pdf 파일로 번역되는 등 혼란이 있어서 이번 posting을 통해서 지금까지, 그리고 앞으로 번역될 패턴 번역글들을 모두 링크, 정리할 것입니다.

I’ve translated Crash Dump Analysis Patterns from www.dumpanalysis.org since 2007 April. I usually post translated article to SystemTeam bulletin board at www.driveronline.org first, so sometimes uploding here, www.insidekernel.net, used to be late. Translated articles are scattered here and there, and there were also some confusing choosing final format to plain text or pdf due to contain image file. So I decide to organize every article I’ve done and will do to this posting.

dumpanalysis.org의 패턴 리스트

translated list

  • Multiple Exceptions
  • Dynamic Memory Corruption
  • False Positive Dump
  • Lateral Damage
  • Optimized Code
  • Invalid Pointer
  • Inconsistent Dump
  • Hidden Exception
  • Deadlock (critical sections)
  • Deadlock (executive resources)
  • Deadlock (mixed objects)
  • Changed Environment
  • Incorrect Stack Trace
  • OMAP Code Optimization
  • No Component Symbols
  • Insufficient Memory (committed memory)
  • Insufficient Memory (handle leak)
  • Insufficient Memory (kernel pool)
  •  

    September 18, 2007

    DriverOnine Crash Analysis Service

    Filed under: Dump analysis — heejune @ 8:48 am

    DCA(DriverOnline Crash Analysis) 서비스를 통해 덤프를 분석하고 그 과정을 글로써 공개하는 첫번째 글입니다. 이와 관련된 모든 것은 www.driveronline.org 사이트의 DCA 게시판을 통해서 이루어집니다.

    해당 게시판이 아직 파일업로드 기능이 활성화되지 않아서, 우선 이곳을 통해 업로드하고 링크합니다.

    dca_1

    June 29, 2007

    Crash Dump Analysis Pattern (Part 6)

    Filed under: Dump analysis — heejune @ 12:00 am

    Crash Dump Analysis Pattern, 여섯번째 이야기 번역입니다.

    잘못된 포인터에 대해서 설명합니다. 원문 주소는 아래와 같습니다.

    http://www.dumpanalysis.org/blog/index.php/2006/12/18/crash-dump-analysis-patterns-part-6/

    crashdumpanalysispart6.pdf

    Next Page »

    Powered by WordPress