U E D R , A S I H C RSS

새싹교실/2012/세싹

1.

  • 다.
  • : 매 15:00~16:00
    12:00~13:00
  • 면 됩다.
  • 과목: everything you want

2.

  • : pkccr1@gmail.com
  • : pkccr@nate.com

3. feedback

  • ZeroPage 되는만 4F(ThreeFs + Future Action Plan) 맞게 feedback 다.
    • Facts, Feelings, Findings, Future Action Plan. , , 느낀 , 깨달 , .
    • 를 들 를 먹 기를 다면 : " 강남 5만를 먹다.() 기대를 는데 다.(느낌) 강남 땅값 값만 보고 라 기대된다는 것 다.(깨달) 다는 미리 보고 가봐겠다.( )"
      • 것보다 더 ? 믿
  • feedback .
    • 반드 ZeroWiki . 를 만드는 것 다.
    • . 과가 더 다.

  • 고로 ZeroWikiMoniWiki Engine 며 Google Chrome나 Mozila Firefox, Safari보다는 Internet Explorer 가는 것 같다.

4.1. 1(2012 3 16)

4.1.1.

O
O
O

4.1.2.

  • wiki를 , 떻게 다.
  • gcc 개발는 법 다.
    1) https://www.virtualbox.org 맞는 VirtualBux
    2) http://ftp.daum.net -> Ubuntu-releases -> 11.10 -> ubuntu-11.10-deskto-amd64.iso 다
    3) Virtualbox -> 로 만들기 -> : Linux : Ubuntu -> 메모리1024MB로 고 나머
    4) 만들 ubuntu -> 미디로 ISO ->
    ( 되는 것 : 글(101/104 )됨!)
  • gcc로 hello world를 다.
    1) gcc 검 &
    2) 는 경로 만들기 (는 .c로 )
    3) 당 문
    4) terminal -> .c 는 경로로 동 (ls cd를 다.)
    5) gcc로 다. (gcc 명.c -o 명 -std=c99) 가로 다.
    6) 다. (./명)
  • w3schools를 다. (www.w3schools.com)
  • 다.
    • , 관리, 나겠 는것 다.

4.1.3.

  • wiki
    1) 만들기 - 로그 로 검 면 됩다. 기본 .
    2) - 고란 기를 남겨면됩다. feedback .
  • gcc 개발경 구
    1) virtual box로 linux hello world 로 보내.

4.1.4.

  • 다:D
    1) w3schools html 보기
    2) linux 명령보기
    3) gcc 보기

4.1.5.

  • 다. 다른 반들과는 다른 , 무 고민다(멘붕 ). 듣는것말고 되면 다. -
  • 다. 가봐 다. 듣는 , 보는 면들 게 많 것 같 기대가 됩다. 보겠다. 드립다. -
  • 다. 곳 Wiki가 매 미로고, 다. 만 들보고 럼 볼 던 것들 보게되 다. 드립다. -
  • 다. 는 문는데 로 강 는 방법 듣고 7z 는 방법다. 데몬 iso 7z다. -
    • ... iso 바로 데.. 대로 ? -
    • 그리고 다. 7z ... 러단 같군. 메뉴 cmd로 라고 다. 는데로 msi 는군. --
    • amd64 려고 cpu문로 가 는군. i386로 깔다. -


4.2. 2(2012 3 20)

4.2.1.

O
O
O

4.2.2.

  • 기 나다.
    1) gcc 다. - gcc 대부 보를 는 것다. 그냥 :D
  • 다.
    1) 리가 보내는 것 다.
    2) 다.
    - app : 리가 다. http, smtp, ftp 다.
    - transport : 데떻게 보낼다. 데떻게 묶 보낼, 리는 떻게 다. TCP/UDP 다.
    - ip : , () 다. 라다.
    - link : 노드 노드 다. , 브릿 다.
    - physical : 물리 다. 블, 무 공기가 매가 되겠.
    3) 리가 모든것 반드 로그램 는것 다.
    - 런 기능들로 나 는, 몰라 그 기능 다.
    - , 로그래밍 리를 모르더라 떤 기능 로그래밍 다.
    4) 그럼 ?
    - (Internet socket, socket' network socket 라고 부르기 다) 결되 다.
    로그램들 고, 로 데를 교다. - wikipedia
    - 는 고 :P 가 byte stream 는 것 는 것다.
    fopen() connect()
    read()/write() read()/write()
    close() close()
    5) http://forum.falinux.com/zbxe/?document_srl=441104.

4.2.3.

  • c로
    1) 드를 다.
    2) 보내 대문로 바꿔 게 보내는 것다.
    3) 난가 다 므로 다. 보고 날 다 기 나보겠다.
    4) 리 gcc를 다.
    5) 댓글 .

4.2.4.

  • 다:D
    1) w3schools는 보길 바랍다.

4.2.5.

  • 는군 =_=ㅋ 밌겠 ㅋㅋ -
  • 로그래밍 다. 구들 떻게 개념 나 많 고민고 결과는 fail던 것 같다. 나 멘 것 같다..... 그리고 될 것 같.. 대 끝나고 바로 가 꾸벅꾸벅 다. 대를 라. -
  • C로 로그래밍 듯ㅋㅋ -
  • 반 빡 ㅋㅋㅋㅋ 가르들겠다… 난감땐 맨땅 는 것 그것 공돌라고 둘러대는 게 듯… -
  • 가 가능 리된 다. -
    • ... 되... -
      • 2 료를 다.(?) -
  • 로그래밍다. 따라가 두려 는데 다. 딸 때 보던 단 막 나다. 다 될 것 같다. 그리고 가 굉 . -
    • 공감... -
    • 다. VS로 까 뭔가 막 류가 나는데 고는 못겠고 그래 를 깔 . 그런 다. 그리고 다가 긴 문. 로그램 때는 괜데 두 때는 Bind러가 나. 그래 다. 런 문? -
      • 맞닥린 bind 류는, 내가 가 려고(bind려고) 가 보까 다른 bind다는 다. 로그램 bind 고 나 bind를 다. bind 드를 꼭 . -
      • 답글 ! 감다. :) -
        • 결 방법다. 고나 바로 setsockopt(mySocket, SOL_SOCKET, SO_REUSEADDR, &anyIntegerVariableThatContainsNonZero, sizeof(anyIntegerVariableThatContainsNonZero)); 리가 나게 됩다. -


4.3. 3(2012 3 23)

4.3.1.

O
O
O

4.3.2.

  • 다.
    1) 떻게 ?
    - 기때문
    다.
    - 다.
    2) 가 다 는 경떻게 될까?
    - 다. :D
    3) 를 따로두 다. 떻게 방법 ?
    - thread를
    concurrent 로그래밍 다.
    4) 결되 다.
    - off-line 가능
    를 두 push로 메다. C2DM라고 다.
  • Thread 다.
    - thread가 떤 것 떻게 다.
    떻게 로그래밍 보겠다.

4.3.3.


  • - terminal 러개 .
  • 가 다 는 경 다.
  • 만 메는데, 록 구다.
    - while문만 것 같다.

4.3.4.


4.3.5.

4.4. 4(2012 3 27)

4.4.1.

O
O

4.4.2.

  • 다.
    1) 권 만 보내때문 멘붕
    -> 고 close 긴 결과다.
    2) 가 다 는 경
    -> 보는게 는데 다들 당 될 것 . :(
    3)
    -> 무 바빠 를 못는동 가 발
    던 thread로그래밍 thread로 는 것 로그래밍 . 강 멘붕
  • concurrent 로그래밍다.
    1) thread 로그래밍
    - thread thread를 떻게 , 료를 떻게 다.
    - . http://www.joinc.co.kr/modules/moniwiki/wiki.php/Site/Thread/Beginning/WhatThread

4.4.3.

  • socket과 thread를 로그램 .

4.4.4.


4.4.5.

  • 다. 깜빡 고.. 바빠는 것 같. 겠다는 다. 그리고 럼대로 그냥 는대로 기로 다. 물론 가 나 다. -

4.5. 5(2012 3 30)

4.5.1.

O
O
O

4.5.2.


4.5.4.


4.5.5.

  • /리 료. 가는 다... -
  • 는다 . 나는 는다 료. - 멘붕며...

4.6. 6(2012 4 3)

4.6.1.

O
O
O

4.6.2.

  • NTFS 다.

  •   // 더 : ntfs.h
    #pragma once
    #define _WIN32_WINNT 0x0500
    
    #include <windows.h>
    #include <winioctl.h>
    #include <stdio.h>
    
    typedef BOOLEAN TF;
    typedef	UCHAR U8;
    typedef USHORT U16;
    typedef ULONG U32;
    typedef ULONGLONG U64;
    
    typedef struct {
    	U32 Type;
    	U16 UsaOffset;
    	U16 UsaCount;
    	U64 Usn;
    } NTFS_RECORD_HEADER, *PNTFS_RECORD_HEADER;
    
    typedef struct {
    	NTFS_RECORD_HEADER Ntfs;
    	U16 SequenceNumber;
    	U16 LinkCount;
    	U16 AttributeOffset;
    	U16 Flags;		// inUse 0x0001 Directory 0x0002
    	U32 BytesInUse;
    	U32 BytesAllocated;
    	U64 BaseFileRecord;
    	U16 NextAttributeNumber;
    } FILE_RECORD_HEADR, *PFILE_RECORD_HEADER;
    
    // Standard Attribute
    
    typedef enum {
    	AttributeStandardInformation = 0x10,
    	AttributeAttributeList = 0x20,
    	AttributeFileName = 0x30,
    	AttributeObjectId = 0x40,
    	AttributeSecurityDesciptor = 0x50,
    	AttributeVolumeName = 0x60,
    	AttributeVolumeInformation = 0x70,
    	AttributeData = 0x80,
    	AttributeIndexRoot = 0x90,
    	AttributeIndexAllocation = 0xA0,
    	AttributeBitmap = 0xB0,
    	AttributeReparsePoint = 0xC0,
    	AttributeEAInformation = 0xD0,
    	AttributeEA = 0xE0,
    	AttributePropertySet = 0xF0,
    	AttributeLoggedUtilityStream = 0x100
    } ATTRIBUTE_TYPE, *PATTRIBUTE_TYPE;
    
    typedef struct {
    	ATTRIBUTE_TYPE AttributeType;
    	U32 Length;
    	TF Nonresident;
    	U8 NameLength;
    	U16 NameOffset;
    	U16 Flags;
    	U16 AttributeNumber;
    } ATTRIBUTE, *PATTRIBUTE;
    
    typedef struct {
    	ATTRIBUTE Attribute;
    	U32 ValueLength;
    	U16 ValueOffset;
    	U16 Flags;
    } RESIDENT_ATTRIBUTE,*PRESIDENT_ATTRIBUTE;
    
    
    
    #pragma pack(push, 1)
    typedef struct {
    	U8 Jump[3];
    	U8 Format[8];
    	U16 BytesPerSector;	//당 바 
    	U8 SectorsPerCluster;	//
    	U16 BootSectors;
    	U8 Mbz1;
    	U16 Mbz2;
    	U16 Reserved1;
    	U8 MediaType;
    	U16 Mbz3;
    	U16 SectorsPerTrack;
    	U16 NumberOfHeads;
    	U32 PartitionOffset;
    	U32 Reserved2[2];
    	U64 TotalSectors;	//디  .
    	U64 MftStartLcn;	//MFT가 되는 .
    	U64 Mft2StartLcn;	// MFT Mirror 부 되는 
    	U32 ClustersPerFileRecord;	//  드당 
    	U32 ClustersPerIndexBlock;	//	 블럭당 
    	U64 VolumeSerialNumber;
    	U8 Code[0x1AE];
    	U16 BootSignature;
    } BOOT_BLOCK, *PBOOT_BLOCK;
    #pragma pack(pop)
    
    - main.cpp

#include "ntfs.h"

U32 BytesPerFileRecord;
BOOT_BLOCK boot_block;
HANDLE hVolume;
U32 cnt;
CHAR drive[] = "\\\\.\\C:";
PFILE_RECORD_HEADER MFT;


void ReadSector(U64 sector, U32 count, void* buffer);
void LoadMFT();

void main()
{

	hVolume = CreateFile(drive, GENERIC_READ,FILE_SHARE_READ | FILE_SHARE_WRITE, 0,OPEN_EXISTING, 0, 0);
	ReadFile(hVolume, &boot_block, sizeof(boot_block), &cnt, 0);
	
	printf("======My FILE SYSTEM INFO==========\n");
	printf("File System : %s \n",boot_block.Format);
	printf("Total Sectors : %u \n",boot_block.TotalSectors);
	printf("Sector per Bytes : %u \n",boot_block.BytesPerSector);
	printf("Cluster per Sectors : %u\n",boot_block.SectorsPerCluster);
	printf("Clusters Per FileRecord : %u\n",boot_block.ClustersPerFileRecord);
	printf("Clusters Per IndexBlock : %u\n",boot_block.ClustersPerIndexBlock);

}

void LoadMFT()
{
	BytesPerFileRecord = boot_block.ClustersPerFileRecord < 0x80? boot_block.ClustersPerFileRecord* boot_block.SectorsPerCluster* boot_block.BytesPerSector : 1 << (0x100 - boot_block.ClustersPerFileRecord);
	MFT = PFILE_RECORD_HEADER(new U8[BytesPerFileRecord]);
	ReadSector(boot_block.MftStartLcn * boot_block.SectorsPerCluster,	BytesPerFileRecord / boot_block.BytesPerSector, MFT);
	printf("buffer : %s\n", MFT+0x27);
}

void ReadSector(U64 sector, U32 count, void* buffer)
{
	ULARGE_INTEGER offset;
	OVERLAPPED overlap = {0};
	U32 n;
	
	offset.QuadPart = sector * boot_block.BytesPerSector;
	overlap.Offset = offset.LowPart; 
	overlap.OffsetHigh = offset.HighPart;
	ReadFile(hVolume, buffer, count * boot_block.BytesPerSector, &n, &overlap);
	
}

4.6.4.

  • 드를 보기 다. - cpp ,

4.6.5.

  • 로 멘붕 다. -
  • 로 멘붕다. 뒤는 게 맡긴다 . -

4.7. 7(2012 4 6)

4.7.1.

O
O
X

4.7.2.

  • NTFS 는 방법

4.7.3.

  • 드 또는 기 기를 MFT

4.7.5.

  • URP 가게 되다. 내가 라고 때는 는구나 :D -
    • 그리고 배때 F빵.ㅠㅜ -
  • NTFS다. 다. 그래 는 것 .
    기 과가 늘 로그램 다. 것 같다. -

4.8. 8(2012 4 10)

4.8.1.

O
O
O

4.8.2.


4.8.4.

  • NTFS 공부다.

4.8.5.


4.9. 9(2012 4 13)

4.9.1.

O
O
O

4.9.2.

#include "ntfs.h"

U32 BytesPerFileRecord;
BOOT_BLOCK boot_block;
HANDLE hVolume;
U32 cnt;
CHAR drive[] = "\\\\.\\C:";
//WCHAR drive[] = TEXT("\\\\.\\C:");
PFILE_RECORD_HEADER MFT;


void ReadSector(U64 sector, U32 count, void* buffer);
void LoadMFT();

void main()
{

	hVolume = CreateFile(drive, GENERIC_READ,FILE_SHARE_READ | FILE_SHARE_WRITE, 0,OPEN_EXISTING, 0, 0);
	ReadFile(hVolume, &boot_block, sizeof(boot_block), &cnt, 0);
//	FILE *fp=fopen(drive,"rb");
//	fread((void*)&boot_block,sizeof(boot_block),1,fp);

	printf("======My FILE SYSTEM INFO==========\n");
	printf("File System : %s \n",boot_block.Format);
	printf("Total Sectors : %u \n",boot_block.TotalSectors);
	printf("Sector per Bytes : %u \n",boot_block.BytesPerSector);
	printf("Cluster per Sectors : %u\n",boot_block.SectorsPerCluster);
	printf("Clusters Per FileRecord : %u\n",boot_block.ClustersPerFileRecord);
	printf("Clusters Per IndexBlock : %u\n",boot_block.ClustersPerIndexBlock);
	printf("\n\n");
	LoadMFT();
}

void LoadMFT()
{
	int i;
	BytesPerFileRecord = boot_block.ClustersPerFileRecord < 0x80? boot_block.ClustersPerFileRecord* boot_block.SectorsPerCluster* boot_block.BytesPerSector : 1 << (0x100 - boot_block.ClustersPerFileRecord);
	MFT = PFILE_RECORD_HEADER(new U8[BytesPerFileRecord]);

	ReadSector(boot_block.MftStartLcn * boot_block.SectorsPerCluster,	BytesPerFileRecord / boot_block.BytesPerSector, MFT);

	printf("$MFT's Signaturer : %s\n", MFT);//+0x27);
	printf("Offset to fixup array : 0x%02x%02x\n", *((unsigned char*)MFT+5),*((unsigned char*)MFT+4));
	printf("Number of this MFT Entry : 0x%02x%02x%02x%02x\n"
		, *((unsigned char*)MFT+47),*((unsigned char*)MFT+46),*((unsigned char*)MFT+45),*((unsigned char*)MFT+44));

	
	printf("Offset to first attribute : 0x%02x%02x \n"
		, *((unsigned char*)MFT+21),*((unsigned char*)MFT+20));



	i=((int)(*((unsigned char*)MFT+21))<<8)+*((unsigned char*)MFT+20);//Offset 동
	printf("First Attribute : 0x%02x%02x%02x%02x\n",*((unsigned char*)MFT+i+3),*((unsigned char*)MFT+i+2),*((unsigned char*)MFT+i+1),*((unsigned char*)MFT+i));
	i+=4;// 4바 동
	printf("First Attribute Size : 0x%02x%02x%02x%02x\n",*((unsigned char*)MFT+i+3),*((unsigned char*)MFT+i+2),*((unsigned char*)MFT+i+1),*((unsigned char*)MFT+i));
	printf("\n");

	

	i=	i+
		((int)(*((unsigned char*)MFT+i+3))<<24)+
		((int)(*((unsigned char*)MFT+i+2))<<16)+
		((int)(*((unsigned char*)MFT+i+1))<<8)+
		*((unsigned char*)MFT+i)
		-4;//  4바다.

	printf("Second Attribute : 0x%02x%02x%02x%02x\n",*((unsigned char*)MFT+i+3),*((unsigned char*)MFT+i+2),*((unsigned char*)MFT+i+1),*((unsigned char*)MFT+i));
	i+=4;// 4바 동
	printf("Second Attribute Size : 0x%02x%02x%02x%02x\n",*((unsigned char*)MFT+i+3),*((unsigned char*)MFT+i+2),*((unsigned char*)MFT+i+1),*((unsigned char*)MFT+i));
	printf("\n");


	i=	i+
		((int)(*((unsigned char*)MFT+i+3))<<24)+
		((int)(*((unsigned char*)MFT+i+2))<<16)+
		((int)(*((unsigned char*)MFT+i+1))<<8)+
		*((unsigned char*)MFT+i)
		-4;//  4바다.

	printf("Third Attribute : 0x%02x%02x%02x%02x\n",*((unsigned char*)MFT+i+3),*((unsigned char*)MFT+i+2),*((unsigned char*)MFT+i+1),*((unsigned char*)MFT+i));
	i+=4;// 4바 동
	printf("Third Attribute Size : 0x%02x%02x%02x%02x\n",*((unsigned char*)MFT+i+3),*((unsigned char*)MFT+i+2),*((unsigned char*)MFT+i+1),*((unsigned char*)MFT+i));
	printf("\n");
	
/*
	ReadSector(boot_block.Mft2StartLcn * boot_block.SectorsPerCluster,	BytesPerFileRecord / boot_block.BytesPerSector, MFT);

	printf("$MFT Mirr's Signaturer : %s\n", MFT);//+0x27);
	printf("Offset to fixup array : 0x%02x%02x\n", *((unsigned char*)MFT+5),*((unsigned char*)MFT+4));
	printf("Number of this MFT Entry : 0x%02x%02x%02x%02x\n"
		, *((unsigned char*)MFT+47),*((unsigned char*)MFT+46),*((unsigned char*)MFT+45),*((unsigned char*)MFT+44));
	printf("\n");
//*/

	printf("MftStartLcn : %d\n",boot_block.MftStartLcn);
	printf("Mft2StartLcn : %d\n",boot_block.Mft2StartLcn);
}


void ReadSector(U64 sector, U32 count, void* buffer)
{
	ULARGE_INTEGER offset;
	OVERLAPPED overlap = {0};
	U32 n;
	
	offset.QuadPart = sector * boot_block.BytesPerSector;
	overlap.Offset = offset.LowPart; 
	overlap.OffsetHigh = offset.HighPart;
	ReadFile(hVolume, buffer, count * boot_block.BytesPerSector, &n, &overlap);
}

4.9.4.

  • 력방
  • 공부

4.9.5.

  • 고, 리로 변.
    브러리를 다.
    htons, htonl
  • HxD라는 다. 4기가 바 대 8 다고 다. 그리고 가 .
    http://mh-nexus.de/en/hxd/ -
  • Code jam ... -
  • 다. 4bit unsigned 3byte,7byte unsigned .ㅠㅜ -


4.10. 10(2012 4 17)

4.10.1.

O
O
O

4.10.2.

#include "ntfs.h"

U32 BytesPerFileRecord;
BOOT_BLOCK boot_block;
HANDLE hVolume;
U32 cnt;
CHAR drive[] = "\\\\.\\C:";
//WCHAR drive[] = TEXT("\\\\.\\C:");
PFILE_RECORD_HEADER MFT;


void ReadSector(U64 sector, U32 count, void* buffer);
void LoadMFT();
unsigned int LoadAttribute(int i);

unsigned __int64 htonll(unsigned __int64);
unsigned int htonl(unsigned int);
//unsigned short htons(unsigned short);

void main()
{

	hVolume = CreateFile(drive, GENERIC_READ,FILE_SHARE_READ | FILE_SHARE_WRITE, 0,OPEN_EXISTING, 0, 0);
	ReadFile(hVolume, &boot_block, sizeof(boot_block), &cnt, 0);
//	FILE *fp=fopen(drive,"rb");
//	fread((void*)&boot_block,sizeof(boot_block),1,fp);

	printf("======My FILE SYSTEM INFO==========\n");
	printf("File System : %s \n",boot_block.Format);
	printf("Total Sectors : %u \n",boot_block.TotalSectors);
	printf("Sector per Bytes : %u \n",boot_block.BytesPerSector);
	printf("Cluster per Sectors : %u\n",boot_block.SectorsPerCluster);
	printf("Clusters Per FileRecord : %u\n",boot_block.ClustersPerFileRecord);
	printf("Clusters Per IndexBlock : %u\n",boot_block.ClustersPerIndexBlock);
	printf("\n\n");
	LoadMFT();
	system("pause");
}

void LoadMFT()
{
	int point;
	unsigned __int64 num;
	BytesPerFileRecord = boot_block.ClustersPerFileRecord < 0x80? boot_block.ClustersPerFileRecord* boot_block.SectorsPerCluster* boot_block.BytesPerSector : 1 << (0x100 - boot_block.ClustersPerFileRecord);
	MFT = PFILE_RECORD_HEADER(new U8[BytesPerFileRecord]);

	printf("MftStartLcn : %016x\n",boot_block.MftStartLcn);
	printf("Mft2StartLcn : %016x\n",boot_block.Mft2StartLcn);
	printf("\n");

	//0 대면 다른 MFT entry를 볼  .
	ReadSector((boot_block.MftStartLcn+0) * boot_block.SectorsPerCluster,	BytesPerFileRecord / boot_block.BytesPerSector, MFT);
	

	printf("MFT's Signaturer : %s\n", MFT);//+0x27);
	printf("Offset to fixup array : 0x%02x%02x\n", *((unsigned char*)MFT+5),*((unsigned char*)MFT+4));
	printf("Number of this MFT Entry : 0x%02x%02x%02x%02x\n"
		, *((unsigned char*)MFT+47),*((unsigned char*)MFT+46),*((unsigned char*)MFT+45),*((unsigned char*)MFT+44));

	printf("Offset to first attribute : 0x%02x%02x \n"
		, *((unsigned char*)MFT+21),*((unsigned char*)MFT+20));
	printf("\n");


	point=((int)(*((unsigned char*)MFT+21))<<8)+*((unsigned char*)MFT+20);//Offset 동
	
	printf("Attribute List Start\n\n");
	while(htonl(*((unsigned int*)((unsigned char*)MFT+point)))!=0xFFFFFFFF)
		point+=LoadAttribute(point);
	printf("Attribute List End\n");

	printf("\n");

}

unsigned int LoadAttribute(int point)
{
	int i=0,j=0,k=0;
	int HeaderSize;

	/*
		*((unsigned char*)MFT+i+9) = Attribute Name Size
		Resident=24 / Non-resident=64
	*/

	if(*((unsigned char*)MFT+point+8))
		HeaderSize=64+*((unsigned char*)MFT+point+9);
	else
		HeaderSize=24+*((unsigned char*)MFT+point+9);


	switch(htonl(*((unsigned int*)((unsigned char*)MFT+point))))
	{
	case 0x10://$STANDARD_INFORMATION
		printf("Attribute type : Standard Information\n");
		break;

	case 0x20://$ATTRIBUTE_LIST
		printf("Attribute type : Attribute List\n");
		break;

	case 0x30://$FILE_NAME
		printf("Attribute type : File Name\n");
		printf("File Name Size : %d\n",*((unsigned char*)MFT+point+HeaderSize+64));	
		printf("File NameSpace : ");
		switch(*((unsigned char*)MFT+point+HeaderSize+65))
		{
		case 0:
			printf("POSIX\n");
			break;
		case 1:
			printf("Win32\n");
			break;
		case 2:
			printf("DOS\n");
			break;
		case 3:
			printf("Win32 & DOS\n");
			break;
		}
		printf("File Name : ");
		for(j=0;j<2**((unsigned char*)MFT+point+HeaderSize+64);j++)
			printf("%c",*((unsigned char*)MFT+point+HeaderSize+66+j));
		printf("\n");
		break;

	case 0x40://$
		printf("Attribute type : \n");
		break;

	case 0x50://$SECURITY_DESCRIPTOR
		printf("Attribute type : Security Descriptor\n");
		break;

	case 0x60://$
		printf("Attribute type : \n");
		break;

	case 0x70://$
		printf("Attribute type : \n");
		break;

	case 0x80://$DATA
		printf("Attribute type : Data\n");

		//__int64는 메모리 little endian됨.  만...
		printf("Run List  Start VCN : %I64d\n",*((unsigned __int64*)((unsigned char*)MFT+point+16)));
		printf("Run List   End  VCN : %I64d\n",*((unsigned __int64*)((unsigned char*)MFT+point+24)));
		printf("Run List Start Offset : 0x%02x%02x\n",*((unsigned char*)MFT+point+33),*((unsigned char*)MFT+point+32));

//		printf("Cluster Size : %I64d\n",*((unsigned __int64*)((unsigned char*)MFT+point+40)));
//		printf("Attribute Size : %I64d\n",*((unsigned __int64*)((unsigned char*)MFT+point+48)));
//		printf("real Size : %I64d\n",*((unsigned __int64*)((unsigned char*)MFT+point+56)));

		i=(int)*((unsigned char*)MFT+point+33)+*((unsigned char*)MFT+point+32);

		for(j=0;j<(*((unsigned char*)MFT+point+i)&0x0F);j++)//*((unsigned __int64*)((unsigned char*)MFT+point+24));j++)
		{
			printf("Cluster %d lenth : 0x",j);
			for(k=0;k<(*((unsigned char*)MFT+point+i)&0x0F);k++)
				printf("%02x",*((unsigned char*)MFT+point+i+(*((unsigned char*)MFT+point+i)&0x0F)-k));
			printf("\n");

			printf("Cluster %d offset : 0x",j);
			for(;k<(*((unsigned char*)MFT+point+i)&0x0F)+((*((unsigned char*)MFT+point+i)&0xF0)>>4);k++)
				printf("%02x",*((unsigned char*)MFT+point+i
					+(*((unsigned char*)MFT+point+i)&0x0F)+((*((unsigned char*)MFT+point+i)&0xF0)>>4)
					-k+(*((unsigned char*)MFT+point+i)&0x0F)));
			printf("\n");
			i+=(*((unsigned char*)MFT+point+i)&0x0F)+((*((unsigned char*)MFT+point+i)&0xF0)>>4)+1;
		}
		break;
	case 0xB0:
		printf("Attribute type : Bitmap\n");
		break;
	}

	printf("\n");

	return htonl(*((unsigned int*)((unsigned char*)MFT+point+4)));
}

void ReadSector(U64 sector, U32 count, void* buffer)
{
	ULARGE_INTEGER offset;
	OVERLAPPED overlap = {0};
	U32 n;
	
	offset.QuadPart = sector * boot_block.BytesPerSector;
	overlap.Offset = offset.LowPart; 
	overlap.OffsetHigh = offset.HighPart;
	ReadFile(hVolume, buffer, count * boot_block.BytesPerSector, &n, &overlap);
}



unsigned __int64 htonll(unsigned __int64 LittleEndian)
{
	unsigned __int64 BigEndian;
	int i;
	LittleEndian>>=16;
	BigEndian=0;
	BigEndian+=(unsigned __int64)(*((unsigned char*)&LittleEndian+7))<<54;
	BigEndian+=(unsigned __int64)(*((unsigned char*)&LittleEndian+6))<<48;
	BigEndian+=(unsigned __int64)(*((unsigned char*)&LittleEndian+5))<<40;
	BigEndian+=(unsigned __int64)(*((unsigned char*)&LittleEndian+4))<<32;
	BigEndian+=(unsigned __int64)(*((unsigned char*)&LittleEndian+3))<<24;
	BigEndian+=(unsigned __int64)(*((unsigned char*)&LittleEndian+2))<<16;
	BigEndian+=(unsigned __int64)(*((unsigned char*)&LittleEndian+1))<<8;
	BigEndian+=(unsigned __int64)(*((unsigned char*)&LittleEndian+0));
	return BigEndian;
}


unsigned int htonl(unsigned int LittleEndian)
{
	unsigned int BigEndian;
	BigEndian=
		((unsigned int)(*((unsigned char*)&LittleEndian+3))<<24)+
		((unsigned int)(*((unsigned char*)&LittleEndian+2))<<16)+
		((unsigned int)(*((unsigned char*)&LittleEndian+1))<<8)+
		*((unsigned char*)&LittleEndian)
		;
	return BigEndian;
}



/*
unsigned short htons(unsigned short LittleEndian)
{
	unsigned short BigEndian;
	BigEndian=
		((unsigned short)(*((unsigned char*)&LittleEndian+1))<<8)+
		*((unsigned char*)&LittleEndian)
		;
	return BigEndian;
}
/*/



4.10.4.


4.10.5.


Valid XHTML 1.0! Valid CSS! powered by MoniWiki
last modified 2021-02-07 05:29:46
Processing time 0.1587 sec