2010년 9월 29일 수요일

WinDbg 사용 핸들릭 잡기

[사용예]
notepad.exe 가 핸들릭을 발생시키는 우리의 프로세스라고 가정합니다.

notepad.exe 를 실행하고 WinDbg 의 Attach Process 로 attach 합니다.
이 상태에서 !htrace 를 사용하면 다음과 같이 오류 메시지가 발생합니다.

0:001> !htrace
Handle tracing is not enabled for this process. Use "!htrace -enable" to enable it.

하지만 친절하게도 사용할 수 있는 방법을 가르쳐 주네요.
Application Verifier 없이도 -enable 옵션을 사용하면 동작합니다.

0:001> !htrace -enable
Handle tracing enabled.
Handle tracing information snapshot successfully taken.

이 때부터 사용하는 핸들은 내용 추적이 가능합니다.
g 로 진행시키고 notepad 에 몇자 적어놓고 나서 Break 를 잡습니다.

이제 !htrace 명령어를 수행하면 그동안 Open/Close 된 핸들의 정보가 나옵니다.
가장 유용한 정보는 Open/Close 가 수행된 콜스택을 보여준다는 부분입니다.
어떤 API 에 의해 Open 된 것인지 보이기 때문에 핸들의 타입을 정확히 알 수 있고
콜스택이 보이기 때문에 어떤 목적으로 어떤 행위를 하고 있었다는 것이 확인됩니다.

0:001> !htrace

주의할 점은 같은 핸들에 대해서 Open 되고 Close 된 것이 모두 나오기 때문에
차근차근 확인해 보셔야 합니다.

이 정보만 가지고도 많은 도움이 되지만 핸들이 닫히지 않고 계속 남아 있는 릭
상황을 확인할 때는 -diff 옵션을 사용하면 더 좋습니다.

-diff 옵션을 사용하면 -enable 을 실행할 때 snapshot 잡힌 정보와 -diff 할 때의
정보를 비교하여 닫히지 않고 열려있는 핸들만 보여줍니다. 핸들릭을 잡는 상황이면
이렇게 보여지는 핸들중에서 문제의 핸들을 찾는 것이 훨씬 쉬울 것입니다.

0:001> !htrace -diff

출처 : GreeMate의 끄적끄적 :: [WinDbg 사용] 핸들릭 잡기

http://www.driveronline.org/bbs/view.asp?tb=tipbbs&GotoPage=1&s_bulu=title&s_key=windbg&no=92

2010년 9월 27일 월요일

asterisk 를 사용하려고 할때

asterisk 검색할때

“\* “이문자를 쓰면됨.

$rc_file = get-Content -path D:\log2.txt
$rc_length = $rc_file.Length 
for ($i =0 ; $i -lt $rc_length; $i++)
{
    if ($rc_file[$i] -match "\*\*") {$message+= $rc_file[$i] +"`n"}
} 
set-Content -path D:\SRC\BuildTools\Rlog.txt $message


Hey, Scripting Guy! How Can I Use Windows PowerShell to Replace Characters in a Text File? - Hey, Scripting Guy! Blog - Site Home - TechNet Blogs

2010년 9월 20일 월요일

Windbg 설치 및 연습

1.환경변수에 아래 경로 추가.

C:\Program Files\Debugging Tools for Windows (x86)

2. Windbg 실행

3. OS 심볼 경로 설정

^S 또는 file Symbols Path 에 경로를 삽입.

OS SRV*d:\osSymbols*http:/msdl.microsoft.com/download/symbols
App  

4. File>Open Executable 를 클릭해서 디버깅할 파일 선택(Sample : Myapp.exe)

Windbg 설치위치가 있는 곳.

Windbg 설치위치가 있는 곳.

은수네집! :: 네이버 블로그

2010년 9월 15일 수요일

Programming world :: Windbg 를 이용한 디버깅 방법

Programming world :: Windbg 를 이용한 디버깅 방법

WinDbg 사용법 기초

WinDbg 사용법 기초가 있는 곳.

WinDbg

Windbg 의 기초적인 사용법이 있는 곳

Windbg 의 기초적인 사용법이 있는 곳.

deguls의 궁금하니? :: [펌] Windbg 를 이용한 디버깅 방법

TaeHoon Cuya :: 네이버 블로그

TaeHoon Cuya :: 네이버 블로그

김태환 팬클럽 : Windbg 를 이용한 디버깅 방법

김태환 팬클럽 : Windbg 를 이용한 디버깅 방법

J.K's Life And Story :: [펌] WinDbg 사용법2

J.K's Life And Story :: [펌] WinDbg 사용법2

WinDBG 디버깅 하는 방법 | 마을 :: 컨텐츠 상세보기

WinDBG 디버깅 하는 방법 마을 :: 컨텐츠 상세보기

Study Log of phiDel :: WinDBG와 VirtualBox를 사용한 원격 디버깅 설정

Study Log of phiDel :: WinDBG와 VirtualBox를 사용한 원격 디버깅 설정

김태환 팬클럽 : Tool/Windbg

김태환 팬클럽 : Tool/Windbg

10 WinDbg 간단 사용법 - kkamagui의 프로그래밍 작업실

들어가기 전에...


•이 글은 kkamagui에 의해 작성된 글입니다.

•마음껏 인용하시거나 사용하셔도 됩니다. 단 출처(http://kkamagui.tistory.com, http://kkamagui.springnote.com)는 밝혀 주십시오.

•기타 사항은 kkakkunghehe at daum.net 이나 http://kkamagui.tistory.com으로 보내주시면 반영하겠습니다.





웹 심볼(Web Symbol) 얻기

SRV*D:\Symbol\WebSymbol*http://msdl.microsoft.com/download/symbols 를 Symbol Path에 넣으면 웹 심볼을 사용할 수 있다.







로드된 모듈 리스트 보기

lm 명령을 이용하면 된다.



•lm k : Kernel Mode 모듈 표시

•lm u : User Mode 모듈 표시

•lm m : 패턴을 검사하여 해당하는 것만 보여줌





lkd> lm

start end module name

00c80000 00c90000 NateOnHook40u (export symbols) C:\Program Files\NATEON\BIN\NateOnHook40u.dll

00cb0000 00cb9000 MgHookDll C (export symbols) C:\Program Files\LG Software\On Screen Display\MgHookDll.dll

01000000 0106a000 windbg (pdb symbols) D:\Symbol\WebSymbol\windbg.pdb\D6EF677AA54441279479F0307F05A8941\windbg.pdb

016a0000 01784000 ext (export symbols) C:\Program Files\Debugging Tools for Windows\winext\ext.dll

01790000 017c1000 kext (pdb symbols) D:\Symbol\WebSymbol\kext.pdb\6B643FC4E9F94FF4ABA4CEF1FD6F89D61\kext.pdb







모듈의 심볼(Symbol) 검사

x 모듈!패턴 을 입력하면 된다.



lkd> x nt!Ke*

804f8c02 nt!KeQuerySystemTime =

804f8c9e nt!KeEnableInterrupts =

80500e38 nt!KeSwitchKernelStack =

804fad32 nt!KeReadStateProcess =

804f9188 nt!KeReleaseInterruptSpinLock =







데이터 타입(Date Type) 표시

dt 데이터 타입 을 입력하면 된다.



lkd> dt _EPROCESS

+0x000 Pcb : _KPROCESS

+0x06c ProcessLock : _EX_PUSH_LOCK

+0x070 CreateTime : _LARGE_INTEGER

+0x078 ExitTime : _LARGE_INTEGER

+0x080 RundownProtect : _EX_RUNDOWN_REF

+0x084 UniqueProcessId : Ptr32 Void

+0x088 ActiveProcessLinks : _LIST_ENTRY

+0x090 QuotaUsage : [3] Uint4B

+0x09c QuotaPeak : [3] Uint4B

+0x0a8 CommitCharge : Uint4B











메모리 덤프(Memory Dump)

d* 명령들을 이용하면 된다.



•db : Byte 형식 + Ascii 로 표시

•dd : 데이터를 4Byte 형식으로 표시





lkd> db 8053db18

8053db18 8b ff 55 8b ec 8b 45 08-8b 4d 0c 8b 55 14 89 48 ..U...E..M..U..H

8053db28 0c 8b 4d 10 89 48 10 03-ca 89 48 14 8b 4d 18 83 ..M..H....H..M..

8053db38 c1 fe 89 48 18 8b 4d 1c-89 48 20 66 8b 4d 20 66 ...H..M..H f.M f











디스어셈블리(Disassembly)

u 주소 를 이용하면 된다. 특정 함수를 디스어셈블리 하고 싶으면 uf 주소 를 하면 된다.



•u 주소 : 주소에서 일부분만 디스어셈블리

•u 주소1 주소2 : 주소1에서 주소 2까지 디스어셈블리





lkd> u 8053db18 or uf nt!NtOpenProcess

nt!KeInitializeProfile:

8053db18 8bff mov edi,edi

8053db1a 55 push ebp

8053db1b 8bec mov ebp,esp

8053db1d 8b4508 mov eax,[ebp+0x8]

8053db20 8b4d0c mov ecx,[ebp+0xc]







메모리 영역 속성 보기(VA Dump)

!vadump 명령을 사용하면 된다. 만약 특정 메모리의 속성을 보고 싶다면 !vprot 주소 명령을 사용하면 된다.



0:000> !vadump

BaseAddress: 00000000

RegionSize: 00010000

State: 00010000 MEM_FREE

Protect: 00000001 PAGE_NOACCESS



BaseAddress: 00010000

RegionSize: 00001000

State: 00001000 MEM_COMMIT

Protect: 00000004 PAGE_READWRITE

Type: 00020000 MEM_PRIVATE







0:000> !vprot 30c191c

BaseAddress: 030c1000

AllocationBase: 030c0000

AllocationProtect: 00000080 PAGE_EXECUTE_WRITECOPY

RegionSize: 00011000

State: 00001000 MEM_COMMIT

Protect: 00000010 PAGE_EXECUTE

Type: 01000000 MEM_IMAGE







프로세스 관련

모든 프로세스를 보기위해서는 !process 0 0 를 입력하면 된다. 디버거를 특정 프로세스에 붙이고 싶으면 .process /i [pid] 를 입력하면 된다.







lkd> !process 0 0

**** NT ACTIVE PROCESS DUMP ****

PROCESS 8a3a3490 SessionId: none Cid: 0004 Peb: 00000000 ParentCid: 0000

DirBase: 00780000 ObjectTable: e1001c70 HandleCount: 521.

Image: System



PROCESS 8a184158 SessionId: none Cid: 03f0 Peb: 7ffdd000 ParentCid: 0004

DirBase: 17a40020 ObjectTable: e163dd70 HandleCount: 20.

Image: smss.exe



PROCESS 89df4da0 SessionId: 0 Cid: 0440 Peb: 7ffd5000 ParentCid: 03f0

DirBase: 17a40040 ObjectTable: e1c6cb18 HandleCount: 626.

Image: csrss.exe

안철수연구소 ASEC 대응팀 블로그 :: WinDBG를 이용한 VMware 커널 디버깅!

안철수연구소 ASEC 대응팀 블로그 :: WinDBG를 이용한 VMware 커널 디버깅!

웹 심볼 설정및 원격 디버깅 설정.

웹 심볼 설정
File -> Symbol File Path
SRV*C:WINDOWSSymbolsWeb*http://msdl.microsoft.com/download/symbols
원격 컴퓨터 디버깅 설정
Debuggee 설정
C:Boot.ini 파일 편집
[operation systems]
-- skip -- /debugport=com1 /baudrate = 115200
두 옵션을 추가해 준다.
Debuggee 를 부팅하고, WinDbg->File->Kernel Debug (^K) 를 선택
115200, com1 을 입력하면 된다. (물론 웹심볼도 설정하고...)

Ctrl + break 또는 툴버튼(손바닥)을 클릭하면 Debuggee 의 제어권을 가져온다.

window 쪼물딱 거리기 : WinDbg 사용하기

WinDBG 디버깅 분석 처리 예 (Programming / devicedriver) - cpueblo.com

WinDBG 디버깅 분석 처리 예 (Programming / devicedriver) - cpueblo.com

시간값 알아오기

:: Windows PowerShell 1편

Get-Date

2010년 9월 13일 월요일

KLDPWiki: Subversion-HOWTO

KLDPWiki: Subversion-HOWTO

파워 쉘 로 자동화하기 (Windows Automation Snapin for Powershell)

WASP(Windows Automation Snapin for Powershell) http://wasp.codeplex.com/

윈도우를 선택, 활성화, 창 크기 변경, 창 닫기, Keyboard,Mouse Action 등을 할 수 있는 PowerShell 자동화 Snapin

Autohot Key 와 비슷한 기능들을 이용 가능할 것 같다.

사용 가능한 명령어들은 아래와 같다.

•Select-Window - pick windows by process name or window caption (with wildcard support)

•Select-ChildWindow - pick all owned windows of another window (eg: dialogs, tool windows)

•Select-Control - pick controls (children) of a specific window, by class and/or name and/or index (with wildcard support) -- NOTE: the "Window" can be specified as "-Window 0" to get all parentless windows, which includes windows, dialogs, tooltips, etc... With -Window 0 this returns a true superset of the Select-Window output.

•Send-Click - send mouse clicks (any button, with any modifier keys) •Send-Keys - Windows.Forms.SendKeys lets you send keys ... try this: Select-Window notepad | Send-Keys "%(ea)Testing{Enter}{F5}" (and for extra fun, try it with multiple notepad windows open).

•Set-WindowActive - yeah, just activates the window

•Set-WindowPosition - set any one of (or all of) top, left, width, height on a window ... or maximize/minimize/restore

•Get-WindowPosition - get the position (kind-of redundant, actually, since the Window object has it's position as a property)

•Remove-Window - closes the specified window

WASP 1.3 RC 버전이 이글을 쓸때의 신버전이고(20100913) http://wasp.codeplex.com/releases/view/22118

설치는 압축을 해제하면 .아래 3개의 파일이 실행된다.

Install.ps1
UnInstall.ps1
WASP.dll

PowerShell 을 실행 후  Install.ps1 을 실행하면  2.0이 설치되어있다고 PSSnapin을 이용해 Import-Module 을 하거나 -Force를 이용해서 하라고 한다.

PS C:\WASP> .\Install.ps1
You're running PowerShell 2.0, so you don't need to Install this as a PSSnapin, you can use Import-Module (or Add-Module
in CTP2) to load it.  If you still want to install it as a PSSnapin, re-run this script with -Force

-Force 명령을 실행하면 아래와 같이 설치가 진행 된다.

PS C:\WASP> .\Install.ps1 -force
You're running PowerShell 2.0, so you don't need to Install this as a PSSnapin, you can use Import-Module (or Add-Module
in CTP2) to load it.  If you still want to install it as a PSSnapin, re-run this script with -Force
Microsoft (R) .NET Framework Installation utility Version 2.0.50727.4927
Copyright (c) Microsoft Corporation. All rights reserved.

트랜잭트 설치를 실행하고 있습니다.

설치의 Install 단계를 시작하고 있습니다.
C:\Users\kwang\Desktop\WASP\WASP\WASP.dll 어셈블리의 진행 상황을 보려면 로그 파일 내용을 검토하십시오.
파일은 C:\Users\kwang\Desktop\WASP\WASP\WASP.InstallLog 위치에 있습니다.
어셈블리 'C:\Users\kwang\Desktop\WASP\WASP\WASP.dll'을(를) 설치하고 있습니다.
영향을 받는 매개 변수:
   assemblypath = C:\Users\kwang\Desktop\WASP\WASP\WASP.dll
   logfile = C:\Users\kwang\Desktop\WASP\WASP\WASP.InstallLog
   logtoconsole =

Install 단계는 완료되었으며 Commit 단계를 시작하고 있습니다.
C:\Users\kwang\Desktop\WASP\WASP\WASP.dll 어셈블리의 진행 상황을 보려면 로그 파일 내용을 검토하십시오.
파일은 C:\Users\kwang\Desktop\WASP\WASP\WASP.InstallLog 위치에 있습니다.
어셈블리 'C:\Users\kwang\Desktop\WASP\WASP\WASP.dll'을(를) 커밋하고 있습니다.
영향을 받는 매개 변수:
   assemblypath = C:\Users\kwang\Desktop\WASP\WASP\WASP.dll
   logfile = C:\Users\kwang\Desktop\WASP\WASP\WASP.InstallLog
   logtoconsole =

Commit 단계가 완료되었습니다.

트랜잭트 설치가 완료되었습니다.

CommandType     Name                                                Definition
-----------     ----                                                ----------
Cmdlet          Get-WindowPosition                                  Get-WindowPosition [-Window] <WindowHandle[]> [-...
Cmdlet          Remove-Window                                       Remove-Window [-Window] <WindowHandle[]> [-Passt...
Cmdlet          Select-ChildWindow                                  Select-ChildWindow [-Window] <WindowHandle[]> [-...
Cmdlet          Select-Control                                      Select-Control [[-Index] <Int32>] -Window <Windo...
Cmdlet          Select-Window                                       Select-Window [[-ProcessName] <String[]>] [-Tool...
Cmdlet          Send-Click                                          Send-Click [[-Left] <Int32>] [[-Top] <Int32>] [[...
Cmdlet          Send-Keys                                           Send-Keys [-Keys] <String> [-Window] <WindowHand...
Cmdlet          Set-WindowActive                                    Set-WindowActive [-Window] <WindowHandle[]> [-Pa...
Cmdlet          Set-WindowPosition                                  Set-WindowPosition [[-Left] <Int32>] [[-Top] <In...
To load the Windows Automation Snapin in the future, you need to run:
Add-PSSnapin WASP

You can also add that line to your Profile script to load it automatically.

Sample Demo

## Open a couple windows(윈도우를 두개 실행)
notepad.exe
explorer.exe

## list the windows( 윈도우 리스트를 출력)
Select-Window | ft –auto

## Activate Notepad(노트패드를 활성화)
Select-Window notepad* | Set-WindowActive

## Close Explorer( 탐색기 종료)
Select-Window explorer | Select -First 1 | Remove-WIndow

## Run a few more copies of notepad(노트패드를 여러개 실행)
notepad; notepad; notepad; notepad;

## Move them around so we can see them all ... (Note the use of foreach with the incrementation)위치 변경
$i = 1;$t = 100; Select-Window notepad | ForEach { Set-WindowPosition -X 20 -Y (($i++)*$t) -Window $_ }

## Put some text into them(텍스트를 입력)

Select-Window notepad | Send-Keys "Test Send-Keys !!!"

#### Close the first notepad window by pressing ALT+F4, and pressing Alt+N
## In this case, you don't have to worry about shifting focus to the popup because it's modal
## THE PROBLEM with sending keys like that is:
## if there is no confirmation dialog because the file is unchanged, the Alt+N still gets sent

Select-Window notepad | Select -First 1 | Send-Keys "%{F4}"

## Close the next notepad window ...
## By asking nicely (Remove-Window) and then hitting "n" for "Don't Save"
## If there are no popups, Select-ChldWindow returns nothing, and that's the end of it

## Close the next notepad window the hard way
## Just to show off that our "Window" objects have a ProcessID and can be piped to kill

Select-Window notepad | Select -First 1 | kill

## A different way to confirm Don't Save (use CLICK instead of keyboard)
## Notice how I dive in through several layers of Select-Control to find the button?
## This can only work experimentally:
## use SPY++, or run the line repeatedly, adding "|Select-Control" until you see the one you want

Select-Window notepad | Select -First 1 | Remove-Window -Passthru | Select-childwindow | select-control| select-control| select-control -title "Do&n't Save" | Send-Click

## But now we have the new -Recurse parameter, so it's easy. Just find the window you want and ...

Select-Window notepad | Select -First 1 | Remove-Window -Passthru | Select-childwindow | select-control -title "Do&n't Save" -recurse | Send-Click

Windows Server 공부방 :: PowerShell 로 IIS 설치 하기(Windows 2008 R2, ServerManager 모듈 사용)

Windows Server 공부방 :: PowerShell 로 IIS 설치 하기(Windows 2008 R2, ServerManager 모듈 사용)

Diretx 버전

Releases :
DirectX version Version number Operating system Date released
DirectX 1.0 4.02.0095 September 30, 1995
DirectX 2.0 Was shipped only with a few 3rd party applications 1996
DirectX 2.0a 4.03.00.1096 Windows 95 OSR2 and NT 4.0 June 5, 1996
DirectX 3.0 4.04.00.0068 September 15, 1996
4.04.00.0069 Later package of DirectX 3.0 included Direct3D 4.04.00.0069 1996
DirectX 3.0a 4.04.00.0070 Windows NT 4.0 SP3 (and above)
last supported version of DirectX for Windows NT 4.0
December 1996
DirectX 3.0b 4.04.00.0070 This was a very minor update to 3.0a that fixed a cosmetic problem with the Japanese version of Windows 95 December 1996
DirectX 4.0 Never launched
DirectX 5.0 4.05.00.0155 (RC55) Available as a beta for Windows NT 5.0 that would install on Windows NT 4.0 July 16, 1997
DirectX 5.2 4.05.01.1600 (RC00) DirectX 5.2 release for Windows 95 May 5, 1998
4.05.01.1998 (RC0) Windows 98 exclusive June 25, 1998
DirectX 6.0 4.06.00.0318 (RC3) Windows CE as implemented on Dreamcast August 7, 1998
DirectX 6.1 4.06.02.0436 (RC0) February 3, 1999
DirectX 6.1a 4.06.03.0518 (RC0) Windows 98 SE exclusive May 5, 1999
DirectX 7.0 4.07.00.0700 (RC1) September 22, 1999
4.07.00.0700 Windows 2000 February 17, 2000
DirectX 7.0a 4.07.00.0716 (RC0) March 8, 2000
4.07.00.0716 (RC1) 2000
DirectX 7.1 4.07.01.3000 (RC1) Windows Me exclusive September 14, 2000
DirectX 8.0 4.08.00.0400 (RC10) November 12, 2000
DirectX 8.0a 4.08.00.0400 (RC14) Last supported version for Windows 95 February 5, 2001
DirectX 8.1 4.08.01.0810 Windows XP, Windows Server 2003 and Xbox exclusive October 25, 2001
4.08.01.0881 (RC7) This version is for the down level operating systems
(Windows 98, Windows Me and Windows 2000)
November 8, 2001
DirectX 8.1a 4.08.01.0901 (RC?) This release includes an update to Direct3D (D3d8.dll) 2002
DirectX 8.1b 4.08.01.0901 (RC7) This update includes a fix to DirectShow on Windows 2000 (Quartz.dll) June 25, 2002
DirectX 8.2 4.08.02.0134 (RC0) Same as the DirectX 8.1b but includes DirectPlay 8.2 2002
DirectX 9.0 4.09.00.0900 (RC4) December 19, 2002
DirectX 9.0a 4.09.00.0901 (RC6) March 26, 2003
DirectX 9.0b 4.09.00.0902 (RC2) August 13, 2003
DirectX 9.0c 4.09.00.0903 Service Pack 2 for Windows XP exclusive
4.09.00.0904 (RC0) August 4, 2004
4.09.00.0904 Windows XP SP2, Windows Server 2003 SP1, Windows Server 2003 R2 and Xbox 360 August 6, 2004
4.09.00.0904 Windows XP SP3 April 21, 2008
DirectX - bimonthly updates 4.09.00.0904 (RC0 for DX 9.0c) The February 9, 2005 release is the first 64-bit capable build.The last build for Windows 98/Me is the redistributable from December 13, 2006. The last build for Windows 2000 is the redistributable from February 5, 2010.. April 2006 is the first official support to Windows Vista and August 2009 is the first official support to Windows 7 and DX11 update Released bimonthly from October 2004 to August 2007, and quarterly thereafter; Latest version: June 2010
DirectX 10 6.00.6000.16386 Windows Vista exclusive November 30, 2006
6.00.6001.18000 Service Pack 1 for Windows Vista, Windows Server 2008
includes Direct3D 10.1
February 4, 2008
6.00.6002.18005 Service Pack 2 for Windows Vista, Windows Server 2008
includes Direct3D 10.1
April 28, 2009
DirectX 11 6.01.7600.16385 Windows 7, Windows Server 2008 R2 October 22, 2009
7.00.6002.18107 Windows Vista SP2 and Windows Server 2008 SP2, through the 2008 October 27, 2009

HTML and CSS Table Border Style Wizard

HTML and CSS Table Border Style Wizard

2010년 9월 3일 금요일

PS1 파일 실행할수 있도록 하기

PS1 파일 실행할수 있도록 하기
Set-ExecutionPolicy Remotesigned

공유폴더에 위차한 서명되지 않은 파워쉘 실행
Set-ExecutionPolicy Unrestricted

2010년 9월 2일 목요일

Using PowerShell to update AsssemblyFileVersions

Asssemblyfile 버전을 변경해주는 Powershell 스크립트

SetVersion.ps1

# SetVersion.ps1
#
# Set the version in all the AssemblyInfo.cs or AssemblyInfo.vb files in any subdirectory.
#
# usage:  
#  from cmd.exe: 
#     powershell.exe SetVersion.ps1  2.8.3.0
# 
#  from powershell.exe prompt: 
#     .\SetVersion.ps1  2.8.3.0
#
# last saved Time-stamp: <Wednesday, April 23, 2008  11:46:40  (by dinoch)>
#
function Usage
{
  echo "Usage: ";
  echo "  from cmd.exe: ";
  echo "     powershell.exe SetVersion.ps1  2.8.3.0";
  echo " ";
  echo "  from powershell.exe prompt: ";
  echo "     .\SetVersion.ps1  2.8.3.0";
  echo " ";
}
function Update-SourceVersion
{
  Param ([string]$Version)
  $NewVersion = 'AssemblyVersion("' + $Version + '")';
  $NewFileVersion = 'AssemblyFileVersion("' + $Version + '")';
  foreach ($o in $input) 
  {
    Write-output $o.FullName
    $TmpFile = $o.FullName + ".tmp"
     get-content $o.FullName | 
        %{$_ -replace 'AssemblyVersion\("[0-9]+(\.([0-9]+|\*)){1,3}"\)', $NewVersion } |
        %{$_ -replace 'AssemblyFileVersion\("[0-9]+(\.([0-9]+|\*)){1,3}"\)', $NewFileVersion }  > $TmpFile
     move-item $TmpFile $o.FullName -force
  }
}
function Update-AllAssemblyInfoFiles ( $version )
{
  foreach ($file in "AssemblyInfo.cs", "AssemblyInfo.vb" ) 
  {
    get-childitem -recurse |? {$_.Name -eq $file} | Update-SourceVersion $version ;
  }
}
# validate arguments 
$r= [System.Text.RegularExpressions.Regex]::Match($args[0], "^[0-9]+(\.[0-9]+){1,3}$");
if ($r.Success)
{
  Update-AllAssemblyInfoFiles $args[0];
}
else
{
  echo " ";
  echo "Bad Input!"
  echo " ";
  Usage ;
}


Building SharePoint Projects with PowerShell and MSBuild - SharePoint Depth Wiki - SharePoint Depth



Powershell script to batch-update AssemblyInfo.cs with new Version - All About Interop - Site Home - MSDN Blogs

콘솔 프로젝트를 생성할 때 만들어지는 파일들

Visual C#으로 콘솔 프로젝트를 생성할 때 만들어지는 파일들이 있습니다.

그것은 AssemblyInfo.cs와 Program.cs 입니다.


AssemblyInfo.cs

이 파일은 프로젝트와 관계되는 어셈블리의 정보가 담겨 있는 CS 파일입니다. 어셈블리는 하나의 기능을 생성하는 타입과 리소스의 집합체입니다. 하나의 프로젝트를 만든다는 것은 하나의 어셈블리를 만드는 것을 의미합니다.

using System.Reflection; 
using System.Runtime.CompilerServices; 
using System.Runtime.InteropServices; 
// 어셈블리의 일반 정보는 다음 특성 집합을 통해 제어됩니다. 
// 어셈블리와 관련된 정보를 수정하려면 
// 이 특성 값을 변경하십시오. 
[assembly: AssemblyTitle("OpenCS.Common.AutoUpdate.WinForms")] 
[assembly: AssemblyDescription("")] 
[assembly: AssemblyConfiguration("")] 
[assembly: AssemblyCompany("")] 
[assembly: AssemblyProduct("OpenCS.Common.AutoUpdate.WinForms")] 
[assembly: AssemblyCopyright("Copyright (C) 2008")] 
[assembly: AssemblyTrademark("")] 
[assembly: AssemblyCulture("")] 
// ComVisible을 false로 설정하면 이 어셈블리의 형식이 COM 구성 요소에 
// 노출되지 않습니다. COM에서 이 어셈블리의 형식에 액세스하려면 
// 해당 형식에 대해 ComVisible 특성을 true로 설정하십시오. 
[assembly: ComVisible(false)] 
// 이 프로젝트가 COM에 노출되는 경우 다음 GUID는 typelib의 ID를 나타냅니다. 
[assembly: Guid("e0bdc914-e6b1-4740-92ab-607ddd62f47e")] 
// 어셈블리의 버전 정보는 다음 네 가지 값으로 구성됩니다. 
// 
// 주 버전 
// 부 버전 
// 빌드 번호 
// 수정 버전 
// 
// 모든 값을 지정하거나 아래와 같이 '*'를 사용하여 빌드 번호 및 수정 버전이 자동으로 
// 지정되도록 할 수 있습니다. 
[assembly: AssemblyVersion("1.0.0.0")] 
[assembly: AssemblyFileVersion("0.3.1.0")]


Program.cs







이 파일은 콘솔 프로젝트 생성 후 개발자가 코드를 작성할 수 있는 최초의 소스 파일입니다. 기본적으로 생성되는 코드는 아래와 같습니다.







using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace HelloWorld // 여기에서 HelloWorld는 프로젝트 이름입니다.
{
class Program
{
static void Main(string[] args)
{
}
}
}






  • using 문과 네임스페이스


처음 4줄에는 using 문들이 기술되어 있네요. Visual C#은 새 콘솔 프로젝트를 생성할 때 자주 사용하는 네임스페이스들을 Program.cs에 명시합니다. 처음 시작하시는 분들에게는 생소한 용어들이 몇 가지 있을 거예요. using도 그렇고, 네임스페이스도, 클래스도 그렇습니다. C#은 객체지향 프로그래밍 언어입니다. 이는 C#으로 만든 프로그램은 여러 가지의 객체들로 구성됨을 의미합니다. 객체를 만들기 위해서는 클래스라는 것을 정의해야 합니다. C#에서는 프로그램을 만들기 위해 적어도 한 개의 클래스가 필요합니다. 우리가 컴퓨터에 파일을 저장할 때 폴더를 만들고 어디에 저장할지를 정하지요. 마찬가지로 클래스들이 많이 만들어지면 이들을 보다 쉽게 구별할 수 있는 방법이 필요합니다. 이 때 사용되는 개념이 바로 네임스페이스입니다. 하나의 클래스는 하나의 네임스페이스에 속하며, 하나의 네임스페이스는 다른 네임스페이스에 속하는 것이 가능합니다. 본래 클래스를 사용하기 위해서는 그것이 속하는 네임스페이스들을 같이 기술해야 합니다. 그러나 using 문을 이용하면, 그러한 번거로움을 덜어줍니다.





  • Program.cs에서 정의되는 네임스페이스


C#은 콘솔 프로젝트를 만들 때 기본적으로 프로젝트와 동일한 이름으로 네임스페이스를 만듭니다. 그리고 그 안에 Program이라는 클래스를 정의하지요. 클래스만 남겨두고 네임스페이스를 지워도 빌드에는 문제가 없습니다. 다만, 프로젝트 이름의 네임스페이스를 만들어두는 것이 나중에 클래스들을 관리하는데 더 도움이 됩니다.








  • Program 클래스와 Main 함수


콘솔 프로젝트 생성시 Visual C#은 기본적으로 Program 클래스를 만듭니다. 이 클래스 안에 프로그램 코드를 작성하면 되겠습니다. 이것은 Main 함수를 가지고 있으며, 프로그램의 시작과 끝은 이 함수에 의해 처리됩니다. 프로그램이 무엇을 할 것인지는 이 함수 안에 코드를 작성하는 것으로 완성됩니다.





  • Program 클래스의 이름을 바꿔도 될까요?

   Program.cs의 Program 클래스의 이름을 바꿔도 빌드가 되는지 궁금했습니다. 시험 결과 빌드 오류는 없었습니다. 즉, 클래스 이름은 마음대로 정할 수 있다는 거지요. 그렇지만 하나의 CS 파일에 하나의 클래스가 들어가며, 두 이름은 일치하는 것이 좋습니다. 일관성 있는 코드를 만들기 위해서는 이러한 규칙을 지키는 것을 권장합니다.





 
도모네 프로그램 세계 :: 네이버 블로그