posted by 방랑군 2012. 1. 24. 23:33

List<T>는 ArrayList의 Generic 버전이다.
Dictionary<K, V>는 HashTable의 Generic 버전이다. 등등.

 

특정 Application에서 Collection을 운용하는 경우, 관리되는 데이터 타입은 결정되어있을 것이다.
이러한 경우 ArrayList나 HashTable을 사용하는 것보다 Generic 버전의 Collection을 사용하는 것이 옳다.

 

Generic Collection 개체는 불필요한 Boxing/Unboxing 연산을 수행하지 않기 때문에 더 빠르고, 컴파일 타임에 데이터 타입이 지정되기 때문에 잘못된 데이터의 삽입으로 발생할 수 있는 오류를 사전에 잡을 수 있는 장점이 있다.

 

Generic은 C++의 Template와 닮아있다.
따라서 C++에서처럼 Generic 형태의 클래스, 메서드 또한 선언할 수 있다.

 

1. Generic 클래스
ex)
class 클래스명<T> where T:new()
{
 T _instance;

 public T GetInstance()
 {

  if (_instance == null)

  {

    _instance = new T();

  }
  _instance = value;
 }
}

 

2. Generic 메서드
ex)
static void Swap<T>(ref T i, ref T j)
{
 T temp;
 temp = i;
 i = j;
 j = temp;
}

 

C++과 비교하여 추가된 점은 제약 조건을 줄 수 있다는 점이다.

 

선언된 형식 뒤에 기재할 수 있다.
where T:struct => 값 타입만 허용
where T:class => 참조 타입만 허용
where T:new() => Default 생성자가 있을 때만 허용
where T:base => base로부터 파생된 클래스만 허용

 

static void Swap<T>(ref T i, ref T j) where T:struct // 값 타입만 허용하는 Swap 메서드.

 

두가지 이상의 제약조건을 설정하는 경우.
class 클래스명<T, U> where T:제약형식1, 제약형식2 where U:제약형식

[출처] [C#] Generic|작성자 에스이오케이

posted by 방랑군 2012. 1. 22. 22:36

출처 :  http://jok3.tistory.com/27 


역분석을 하다보면 api함수로 찾아줄때가 많은데 자주쓰이는 함수들을 정리해 봤습니다.
첨부파일은 원하는 함수를쓰면 그함수의 쓰임세가 설명되있는 도움말파일이라고 보시면 됩니다.





-파일 생성 & 열때.
16-bit : CreateFile
32-bit : CreateFileA
wide : CreateFileW


-파일 입출력(Read&Write)
ReadFile : 읽기
WriteFile : 쓰기

-파일 접근(Access)
SetFilePointer : 포인터 조정

-시스템 디렉토리 얻어오는 함수
16-bit : GetSystemDirectory
32-bit : GetSystemDirectoryA
wide : GetSystemDirectoryW


-.ini 구성설정에 관련된 함수들
16-bit : GetPrivateProfileString
GetPrivateProfileInt
WritePrivateProfileString
WritePrivateProfileInt
32-bit : GetPrivateProfileStringA
GetPrivateProfileIntA
WritePrivateProfileStringA
WritePrivateProfileIntA
wide : GetPrivateProfileStringW
GetPrivateProfileIntW
WritePrivateProfileStringW
WritePrivateProfileIntW

-레지스트리의 키를 생성 혹은 삭제할때
16-bit : RegCreateKey
RegDeleteKey
32-bit : RegCreateKeyA
RegDeleteKeyA
wide : RegCreateKeyW
RegDeleteKeyW

-현재 열려진 레지스트리 키를 읽을때
16-bit : RegQueryValue
32-bit : RegQueryValueA
wide : RegQueryValueW

-레지스트리 키를 열때
16-bit : RegCloseKey
RegOpenKey
32-bit : RegCloseKeyA
RegOpenKeyA
wide : RegCloseKeyW
RegOpenKeyW

-객체에서 문자열을 읽을때
16-bit : GetWindowText
GetDlgItemText
32-bit : GetWindowTextA
GetDlgItemTextA

wide : GetWindowTextW
GetDlgItemTextW

-정수여부 상관
GetDlgItemInt

-객체의 텍스트를 지정
16-bit : SetWindowText
SetDlgItemText
32-bit : SetWindowTextA
SetDlgItemTextA
wide : SetWindowTextW
SetDlgItemTextW


-메시지 박스
16bit : MessageBox
MessageBeep
32bit : MessageBoxA
MessageBoxExA
wide : MessageBoxW
MessageBoxExW

-메시지 관련
16bit : SendMessage
WSPRINTF
32bit :SendMessageA
wide : SendMessageW

-날짜와 시간을 구할때
GetSystemTime
GetLocalTime
SystemTimeToFileTime


-창을 생성 & 제거할때
16bit : CreateWindow
CreateWindowEx
DialogBoxParam
DestroyWindow
EndDialog
showwindow
bitblt
32bit : CreateWindowA
CreateWindowExA
DialogBoxParamA
wide : CreateWindowW
CreateWindowExW
DialogBoxParamW


-CD롬을 요구하는 함수 들
16bit : GetDriveType (만약 eax=5 라면 CD롬 체크 이다.)
GetLogicalDrives
GetLogicalDriveStrings
32bit : GetDriveTypeA
GetLogicalDrivesA
GetLogicalDriveStringsA
wide : GetDriveTypeW

-리턴 코드:
값 설명
0 Drive Cannot Be determined
1 Root Dir Does not exist
2 DriveRemoveable
3 A Fixed Disk (HardDrive)
4 Remote Drive(Network)
5 Cd-Rom Drive <==============
6 RamDisk

GetLogicalDrivesW
GetLogicalDriveStringsW

-Win NumberSerial:
GETWINDOWWORD
GETWINDOWLONG

+ORC가 제안한 훌륭한 함수
BOZOSLIVEHERE
HMEMCPY
GLOBALGETATOMNAME