1 / 50

Ch 13. Windows 관리 기구

Ch 13. Windows 관리 기구. Contents. WMI WMI Architecture 전통적인 방법의 Driver Event Logging Summary. 1. WMI. WMI. Windows Management Instrumentation WDM 이 제공 Management Data 수집 , 저장 , 보고 하는 표준화된 기능 Driver 의 Client 가 Device 의 설정을 변경 가능 CIM (Common Information Model)

gale
Download Presentation

Ch 13. Windows 관리 기구

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Ch 13. Windows 관리 기구

  2. Contents • WMI • WMI Architecture • 전통적인 방법의 Driver Event Logging • Summary Ch 13. Windows 관리 기구

  3. 1. WMI

  4. WMI • Windows Management Instrumentation • WDM이 제공 • Management Data 수집, 저장, 보고 하는 표준화된 기능 • Driver의 Client가 Device의 설정을 변경 가능 • CIM (Common Information Model) • System이 제공하는 Data를 Client가 Property, Method , Event 등으로 쉽게 사용하게 하는 Model • MOF 라는 새로운 언어는 정의 • RPC나 COM과 비슷 • WMI는 CIM을 기반으로 하고 있음 Ch 13. Windows 관리 기구

  5. 2. WMI Architecture

  6. WMI Architecture(1) • 5 Layer of WMI Architecture • WMI Data Source (Ex. Device Driver) • Data Provider • WMI Data 중앙 저장소 • CIMOM 기반의 CIM Data 저장소를 구현 • WMI Provider (Ex. WDM WMI Provider) • Data Source와 Data 저장소를 연결 • WMI Data Comsumer (Ex. Client) • Protocol (Ex. COM) • Data 저장소를 Client에게 제공 Ch 13. Windows 관리 기구

  7. WMI Architecture(2) • WMI Provider의 두가지 구성요소 • Win32 DLL • User Mode Client 간의 연결을 제공 • Kernel Mode Service • Driver의 Code에 응답하거나 호출 Ch 13. Windows 관리 기구

  8. WMI Architecture(3) Event 통지 관리된 Application Application & Platform 관리 Query Request Active Directory CIM Object Manager (CIMOM) CIM-compliant store WMI Provider for WDM 다른 주소 Query Request Event 통지 User Mode Kernel Mode WDM / WMI WMILIB WDM / WMI 호환 Driver Ch 13. Windows 관리 기구

  9. WMI를 지원하는 WDM Driver 작성 • WMI Data를 제공하기 위해서 Driver에서 수행할 과정 • MOF 명세를 제공 • Driver에 의해 제공되고 생성될 Data, Method, Event • DDK에서 제공하는 mofcomp.exe로 MOF Source를 complie • Platform 독립적인 Binary File 생성 (.BMF) • Driver의 Resource Section 내에 Compile한 MOF Data를 포함 • IRP_MJ_SYSTEM_CONTROL dispatch Routine 작성 • Driver는 이 IRP를 받으면 WMI Request에 대한 세부사항을 IRP Minor Field에 기술함 Ch 13. Windows 관리 기구

  10. WMI를 지원하는 WDM Driver 작성 • IoWmiRegistationControl 함수를 사용해 WMI Data의 Provider로 등록 • IRP_MJ_SYSTEM_Control IRP의 Minor SubCode로 IRP_MN_REGINFO를 처리하는 Code 작성 • WMIREGISTER 실행 Code를 처리하기 위해 MOF 기술자 내에 Data와 Event Block을 정의한 정보를 제공 • WMILIB.h 안에 선언된 Helper Function을 호출 • WMIUPDATE 실행 Code를 처리 Ch 13. Windows 관리 기구

  11. MOF의 문법 • RPC Interface 정의의 표준구조를 따름 [ATTRIBUTES and QUALIFIERS] ENTITY TYPE and NAME { [DATA ITEM QUALIFIERS] DATA TYPE and NAME; … }; • 구조체는 구조체내에 중첩정의 될수 있음 • ENTITY Type은 일반적인 Keyword가 될수 있음 • Class, string, boolean • MOF은 class name을 기술하는 것으로 시작 • WMI namespace중 유일해야함 • Class는 상속 가능 Ch 13. Windows 관리 기구

  12. WMI MOF 정의중 Class 권한 지정자 Ch 13. Windows 관리 기구

  13. WMI MOF 정의중 Data Item 권한 지정자 Ch 13. Windows 관리 기구

  14. WMI MOF 정의중 Data Type Ch 13. Windows 관리 기구

  15. Example Code(1) • InstanceName 과 Active 두개의 Item은 필수 • WMI에 의해 관리, Driver 자체에서 관리하는 Data는 아니라고 고려함 [WMI, guid("12345678-1234-5678-9ABC-123456789ABC"), Dynamic, Provider("WMIProv"), WmiExpense(1), Locale("MS\\0x409"), Description("Example class")] classw2kDriverBook_Missile { // 필수 아이템 정의 - 드라이버에서 사용되지 않는다. [key , read] stringInstanceName; [read] booleanActive; Ch 13. Windows 관리 기구

  16. Example Code(2) // 속성 [read , WmiDataId(1), WmiScale(0), Description("Total Missile Launches")] uint32 TotalLaunches; //siloStatus 배열 내의 저장소 개수 [read , WmiDataId(2)] uint32 SiloCount; // SiloStatus 배열 [read , WmiDataId(3), WmiSizeIs("SiloCount")] uint8 SiloStatus[]; }; Ch 13. Windows 관리 기구

  17. MOF Source Compile • system32 Folder내에 mofcomp.EXE Utility를 이용 • WDM 개발환경에서는 두개의 compile Switch가 필요 • -B:filename.bmf • 해당 Filename으로 compile 된 binary 파일 작성 • -WMI filename2.MOF • filename2.MOF 를 WMI와 호환되도록 compile • EX) mofcomp –B:Example.bmf –WMI Example.MOF • Ex) MofResource MOFDATA Example.bmf • Driver에 Resource file(.RC)를 Project에 포함 • Driver가 System Memory에 Load될시, Resource section이 RAM에 자리잡고 Driver에서 접근 가능하게 됨 Ch 13. Windows 관리 기구

  18. WMI IRP Request 처리 • Driver 자신이 WMI의 일원이라는 것을 I/O Manager에게 등록 • IoWMIRegistrationControl Function 이용 • AddDecive Routine 중 WMIREG_ACTION_REGISTER인자를 통해 WMI에 등록함 • RemoveDevice Routine 중 WMIREG_ACTION_DEREGISTER action 인자를 주어 등록 해제해야함 • WMI 에 등록되면 Driver는 IRP_MJ_SYSTEM_CONTROL IRP에 대한 dispatch Routine 이 구현되어 있어야 함 Ch 13. Windows 관리 기구

  19. Class & Instance • class는 단지 선언일뿐 어떠한 공간도 예약하지 않음 • DpWmiQueryReginfo Function을 통해 Instance로 생성 • 대부분 한 class에는 하나의 Instance가 적당 • 구지 여러 Instance를 사용해야하면 Instance Index가 필요 Ch 13. Windows 관리 기구

  20. WMILIB • WMI IRP Request처리는 대부분 Kernel Mode의 DLL, WMILIB에서 함 • 핵심 Routine  WmiSystemControl • WMILIB_CONTEXT Structure를 입력으로 받음 • WMILIB_CONTEXT • control들을 수행하는 Function Pointer들의 List • 만약 지원하지 않는 Function 이 있다면 반드시 NULL로 Setting • WmiCompleteRequest Function • WMILIB_CONTEXT의 각 Function들의 완료 함수 • DpWmiQueryReginfo 제외 Ch 13. Windows 관리 기구

  21. WmiSystemControl Ch 13. Windows 관리 기구

  22. WMILIB_CONTEXT Structure Ch 13. Windows 관리 기구

  23. WmiCompleteRequest(1) • WMILIB_CONTEXT 내에 ENTRY로 지정된 각 dispatch Function들의 완료 Routine • DpWmiQueryReginfo 제외 • class의 Instance를 등록하는 Function임 Ch 13. Windows 관리 기구

  24. WmiCompleteRequest(2) Ch 13. Windows 관리 기구

  25. DpWmiQueryReginfo • 목적 • 하나 또는 그 이상의 Data Class의 Instance를 등록함 • 호출시기 및 호출자 • IRP의 Minor SubCode  IRP_MN_REGINFO • Action Code가 WMIREGISTER or WMIUPDATE일때 • Action Code란 WMI Structure 내에 있는 변수중 하나 • WMI에 의해 호출 Ch 13. Windows 관리 기구

  26. DpWmiQueryDataBlock • 목적 • Request된 Instance Data를 Return 하는 것 • 호출시기 및 호출자 • IRP의 Minor SubCode  IRP_MN_QUERY_DATA_BLOCK or IRP_MN_QUERY_ALL_DATA • WMILIB에 의해 호출 Ch 13. Windows 관리 기구

  27. DpWmiSetDataBlock • 목적 • 특정 Instance Data를 수정 하는 것 • 호출시기 및 호출자 • IRP의 Minor SubCode  IRP_MN_CHANGE_SINGLE_INSTANCE • WMILIB에 의해 호출 • 오직 한 Instance만이 한시점에 변경가능 • 다중 Instance일때에는 InstanceIndex값을 0으로 남겨둠 Ch 13. Windows 관리 기구

  28. DpWmiSetDataItem • 목적 • Instance Data 내의 특정 Item Data를 수정 하는 것 • 호출시기 및 호출자 • IRP의 Minor SubCode  IRP_MN_CHANGE_SINGLE_ITEM • WMILIB에 의해 호출 Ch 13. Windows 관리 기구

  29. DpWmiExecuteMethod • 목적 • 특정 Method의 실행을 dispatch 하는것 • 호출시기 및 호출자 • IRP의 Minor SubCode  IRP_MN_EXECUTE_METHOD • WMILIB에 의해 호출 • WMI Client로 부터 Driver Code의 직접호출의 Interface로 이용 Ch 13. Windows 관리 기구

  30. DpWmiFunctionControl • 목적 • Data 수집을 시작, 중지하거나 Event생성을 시작, 중지하는 것 • 등록시에 WMIREG_FLAG_EXPENSIVE로 설정된 중요한 DATA) • 호출시기 및 호출자 • IRP의 Minor SubCode  IRP_MN_ENABLE_COLLECTION,  IRP_MN_DISABLE_COLLECTION,  IRP_MN_ENABLE_EVENTS,  IRP_MN_DISABLE_EVENTS • WMILIB에 의해 호출 Ch 13. Windows 관리 기구

  31. WMI Summary • Driver는 반드시 WMI를 지원하게 할 필요는 없음 • 하지만, 결국 WMI를 추가하는 모습이 될것임 • WMI를 지원하지 않아도 전통적인 방법이 있음 • System Event Logging Method (Message 통지) • Registry or Custom IOCTL (Data 수집) Ch 13. Windows 관리 기구

  32. 3. 전통적인 방법의 Driver Event Logging

  33. Event Logging • 개발 과정하에서 제품을 사용할때 Software의 동작을 Monitering 할수 있도록 도와주는 역할 • 사용 목적 • SubSystem에 Event 정보를 저장하기위한 통합 Framework구축 • System Administrator에게 쉽고 일관적으로 Event Message를 보여주기 위함 • Viewer Utility에서 Event Message를 각 언어로 제공 Ch 13. Windows 관리 기구

  34. Event Logging Architecture ⑤ Display되는 실제 Message Text를 가짐 Message File Event Viewer Driver ① I/O Manager 에게 Nonpaged Memory 요청 ⑤ Log File로 부터 Binary Packet을 읽음 ③ I/O Manager는 Packet을 Logging Thread로 전송 Error Log Packet Event Log File Message Code Message Code ② Driver는 Packet을 Event 설명 정보로 채움 ④ Logging Thread는 정기적으로 Event Log File에 Packet을 기록 Logging Thread Ch 13. Windows 관리 기구

  35. Message로 작업하기(1) • Driver는 Event Log Entry 내에 실제 Message Text를 가지지 않음 • Disk의 어딘가의 정보를 Code Number를 통해 소유 • Code Number (32 bits) 31 ~ 30 29 28 ~ 16 15 ~ 0 Error Code Facility Customer Severity • Severity • Success(0) , Warning(2) , Error(3) , Information(1) Status • Facility • 발생 지점 • Error Code Ch 13. Windows 관리 기구

  36. Message로 작업하기(2) • Message Text를 IOLOGMSG.dll 에서 공유 • Driver는 Customer Message Text를 제공가능 • Code Number에서 customer Bit 이용 • 절차 • Message Code와 연관된 Message 정의 File에 특정 Text 문자열을 작성 • 이 File을 Message Compiler로 Compile • 생성한 Message Resource를 Driver와 결합 • Message Compiler 사용 • Driver를 Event Logging System 구성요소로 등록후 확인 Ch 13. Windows 관리 기구

  37. Message Definition File 작성 • Message Definition File • Driver의 모든 Message를 기술한 File • Header Section • 실제 Message Definition내에 사용될수 있는 값들을 위한 이름정의 • Message Section • Message의 실제 Text를 포함 • Message Text는 마지막 Keyword 다음에 시작 • Message Text는 몇 개의 Line으로 구성 가능 • 끝은 한 개의 마침표(.)로 인식 • Message Text는 특수 기호를 사용 • ‘\b’ , ‘\t’ , ‘\r\n’ Ch 13. Windows 관리 기구

  38. Header Section Keyword Ch 13. Windows 관리 기구

  39. Message Section Keyword Ch 13. Windows 관리 기구

  40. Example Header Section MessageIdTypedef = NTSTATUS SeverityNames = ( Success = 0x0:STATUS_SEVERITY_SUCCESS Informational = 0x1:STATUS_SEVERITY_INFORMATIONAL Warning = 0x2:STATUS_SEVERITY_WARNING Error = 0x3:STATUS_SEVERITY_ERROR ) FacilityNames = ( System = 0x0 RpcRuntime = 0x2:FACILITY_RPC_RUNTIME RpcStubs = 0x3:FACILITY_RPC_STUBS Io = 0x4:FACILITY_IO_ERROR_CODE MyDriver = 0x7:FACILITY_MY_ERROR_CODE ) Ch 13. Windows 관리 기구

  41. Example Message Section MessageId=0x0001 Facility=MyDriver Severity=Informational SymbolicName=MSG_LOGGING_ENABLED Language=English Event logging enabled for MyDriver. . MessageId=+1 Facility=MyDriver Severity=Informational SymbolicName=MSG_DRIVER_STARTING Language=English MyDriver has successfully initialized. . Ch 13. Windows 관리 기구

  42. Message Definition File Compiling(1) Ch 13. Windows 관리 기구

  43. Message Definition File Compiling(2) • Compile 후 생성되는 Files • filename.RC • Message Definition File 내에서 사용된 모든 언어를 인식하는 Resource Control Script임 • filename.H • MC 입력 File안의 모든 Message Code Number를 위한 #define 구문을 포함하는 File • MSGnnnnn.BIN • 한가지 언어의 Message를 위한 모든 Text를 담고 있음 • Message Definition File 내에 각 언어별로 개별적인 File을 생성 • MC Utility로 Compile한 출력 File은 Driver 실행 File 자체에 포함됨 Ch 13. Windows 관리 기구

  44. Driver를 Event Source로 등록 • Driver를 Event Source로 등록하기 위해선 다음경로변경 • HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\EventLog\System • Driver의 실행File이름을 REG_MULTY_SZ type Source값에 추가 (.SYS확장자 제외) • Driver로 같은 이름의 Key Value 추가 • 새로운 Key Value로 REG_EXPAND_SZ type의 EventMessageFile Value 생성 • Message File 전체 경로의 이름을 ‘;’로 구분해서 반드시 포함 • 동일한 Key Value로 REG_DWORD type의 TypesSupported Value 생성 • 0x7 Value는 All Message type이 생성을 의미 Ch 13. Windows 관리 기구

  45. Error Log Packet 할당(1) • Event를 처리하지 못하는 경우를 대비해 반드시 준비 • 3개의 Section으로 구성 • Standard Header • Driver에서 정의된 ULONGs 배열 (DumpData) • 하나 또는 그 이상의 NULL종료 Unicode 삽입 문자열 • Error Log Packet을 할당하기 전에 Packet의 크기를 결정 • ERROR_LOG_MAXIMUM_SIZE를 넘으면 안됨 • IoAllocateErrorLogEntry Function을 사용 Ch 13. Windows 관리 기구

  46. Error Log Packet 할당(2) IO_ERROR_LOG_PACKET IO_ERROR_LOG_PACKET ErrorCode DumpDataSize NumberOfStrings StringOffset StringOffset … DumpData[] … “Second Unicode insertion string \0” “Second Unicode insertion string \0” Error Log Packet의 LayOut Ch 13. Windows 관리 기구

  47. Logging Error(1) • Packet이 할당되면 각 Field를 채움 • Packet을 System Logging Thread로 전송 • IoWriteErrorLogEntry Function 사용 • 위 Func 호출후엔 더 이상 Packet은 Driver의 소유가 아님 • Driver가 Packet을 건드리면 안됨 • Packet의 할당은 DISPATCH_LEVEL IRQL에서 사용 • IO_ERROR_LOG_PACKET structure를 사용 Ch 13. Windows 관리 기구

  48. Logging Error(2) Ch 13. Windows 관리 기구

  49. 4. Summary

  50. Summary • WMI 와 Event Logging을 Driver와 통합시키는 것은 매우 지루한 일임 • 하지만, 제품Driver에 System Reporting Mechanism은 필수로 제공되어야 함 • Event를 통해 Error를 추적하는 기능은 문제점을 찾아내는데 필수적인 기능임 Ch 13. Windows 관리 기구

More Related