home *** CD-ROM | disk | FTP | other *** search
- #line -a-
-
- /*┌──────────────────────────────────────────────────────────────────────┐*/
- /*│ ìạáτÑ¡¿Ñ : ÄΓ«ípáªÑ¡¿Ñ páºí¿Ñ¡¿∩ ªÑßΓ¬«ú« ñ¿ß¬á │*/
- /*├──────────────────────────────────────────────────────────────────────┤*/
- /*│ é맮ó : FIXPARTC [¡«¼Ñp ñ¿ß¬á] (»« π¼«½τá¡¿ε 0) │*/
- /*└──────────────────────────────────────────────────────────────────────┘*/
-
- #include <dos.h>
- #include <string.h>
- #include <stdlib.h>
-
- #define TRUE ( 1 == 1 )
- #define FALSE ( 1 == 0 )
-
- #define HI(x) ( *((BYTE *) (&x) + 1) ) /* 髺ópáΘáÑΓ ßΓápΦ¿⌐ íá⌐Γ */
- #define LO(x) ( *((BYTE *) &x) ) /* 髺ópáΘáÑΓ ¼½áñΦ¿⌐ íá⌐Γ */
-
- typedef unsigned char BYTE;
- typedef unsigned int WORD;
-
-
- typedef struct { /* îÑßΓ«»«½«ªÑ¡¿Ñ ßÑ¬Γ«pá */
- BYTE Head; /* ⫽«ó¬á τΓÑ¡¿∩/ºá»¿ß¿ */
- WORD SecCyl; /* 쫼Ñp ßÑ¬Γ«pá ¿ µ¿½¿¡ñpá */
- } SECPOS;
-
- typedef struct { /* éσ«ñ ó Γáí½¿µπ páºñѽ«ó */
- BYTE Status; /* æ«ßΓ«∩¡¿Ñ páºñѽá */
- SECPOS StartSec; /* ìáτá½∞¡δ⌐ ßÑ¬Γ«p */
- BYTE PartTyp; /* Æ¿» páºñѽá */
- SECPOS EndSec; /* è«¡Ñτ¡δ⌐ ßÑ¬Γ«p */
- unsigned long SecOfs; /* æ¼ÑΘÑ¡¿Ñ ßÑ¬Γ«pá ºáúpπº¬¿*/
- unsigned long SecNum; /* 諽¿τÑßΓó« ßÑ¬Γ«p«ó */
- } PARTENTRY;
-
- typedef struct { /* æÑ¬Γ«p páºí¿Ñ¡¿∩ */
- BYTE BootCode[ 0x1BE ];
- PARTENTRY PartTable[ 4 ];
- WORD IdCode;
- } PARTSEC; /* OxAA55 */
-
- typedef PARTSEC far *PARSPTR; /* ô¬áºáΓѽ∞ > ßÑ¬Γ«pá páºñѽá ó »á¼∩Γ¿ */
-
- /*┌──────────────────────────────────────────────────────────────────────┐*/
- /*│ ReadPartSec : ù¿ΓáÑΓ ßÑ¬Γ«p páºí¿Ñ¡¿∩ ß ñ¿ß¬á ¿ »«¼ÑΘáÑΓ ó íπΣÑp │*/
- /*├──────────────────────────────────────────────────────────────────────┤*/
- /*│ éσ«ñ¡δÑ »ápá¼ÑΓpδ : HrdDrive - BIOS-¬«ñ ñ¿ß¬á(Äσ80 ¿½¿ Äσ81 ) │*/
- /*│ : Head - 쫼Ñp ú«½«ó¬¿ τΓÑ¡¿∩/ºá»¿ß¿ │*/
- /*│ : SecCyl - 쫼Ñp ßѬΓ. ¿ µ¿½¿¡ñpá ó Σ«p¼áΓÑ BIOS │*/
- /*│ : Buf - üπΣÑp, ó ¬«Γ«pδ⌐ »«¼ÑΘáÑΓß∩ ßÑ¬Γ«p │*/
- /*│ éδσ«ñ¡δÑ »ápá¼ÑΓpδ : TRUE - Ñß½¿ ßÑ¬Γ«p τ¿ΓáÑΓß∩ íѺ «Φ¿í¬¿ │*/
- /*│ : FALSE - ¿¡áτÑ │*/
- /*└──────────────────────────────────────────────────────────────────────┘*/
-
- BYTE ReadPartSec( BYTE HrdDrive, BYTE Head, WORD SecCyl, PARSPTR Buf )
- {
- union REGS Regs; /* ÉÑú¿ßΓpδ »p«µÑßß«pá ñ½∩ ó맮óá */
- struct SREGS SRegs; /* »pÑpδóá¡¿∩ */
-
- Regs.x.ax = 0x0201; /* 쫼Ñp Σπ¡¬µ¿¿ "τΓÑ¡¿Ñ", 1 ßÑ¬Γ«p */
- Regs.h.dl = HrdDrive; /* çáúpπº¬á »ápá¼ÑΓp«ó ó pÑú¿ßΓpδ */
- Regs.h.dh = Head;
- Regs.x.cx = SecCyl;
- Regs.x.bx = FP_OFF( Buf );
- SRegs.es = FP_SEG( Buf );
-
- int86x ( 0x13, &Regs, &Regs, &SRegs); /* é맮ó »pÑpδóá¡¿∩ */
- /* ªÑßΓ¬«ú« ñ¿ß¬á */
- return !Regs.x.cflag;
- }
-
- /*┌──────────────────────────────────────────────────────────────────────┐*/
- /*│ GetSecCyl : Ä»pÑñѽ∩ÑΓ ¡«¼Ñp ßÑ¬Γ«pá ¿ µ¿½¿¡ñpá ó Σ«p¼áΓÑ BIOS │*/
- /*├──────────────────────────────────────────────────────────────────────┤*/
- /*│ éσ«ñ¡δÑ »ápá¼ÑΓpδ : SecCyl - 쫼Ñp ßÑ¬Γ«pá ¿ µ¿½¿¡ñpá ó Σ«p¼áΓÑ BIOS│*/
- /*│ : Sector - ê¼∩ »ÑpѼѡ¡«⌐ "ßÑ¬Γ«p" │*/
- /*│ : Cylinder - ê¼∩ »ÑpѼѡ¡«⌐ "µ¿½¿¡ñp" │*/
- /*│ éδσ«ñ¡δÑ »ápá¼ÑΓpδ: ¡ÑΓ │*/
- /*└──────────────────────────────────────────────────────────────────────┘*/
-
- void GetSecCyl( WORD SecCyl, int *Sector, int *Cylinder )
- {
- *Sector = SecCyl & 63; /* êºó½ÑτÑ¡¿Ñ í¿Γ«ó 6 ¿ 7 */
- *Cylinder = HI( SecCyl ) + ( ( (WORD) LO( SecCyl ) & 192 ) << 2 );
-
- }
- /*┌──────────────────────────────────────────────────────────────────────┐*/
- /*│ ShowPartition : ÄΓ«ípáªáÑΓ páºí¿Ñ¡¿Ñ ªÑßΓ¬«ú« ñ¿ß¬á ¡á φ¬pá¡Ñ │*/
- /*├──────────────────────────────────────────────────────────────────────┤*/
- /*│ éσ«ñ¡«⌐ »ápá¼ÑΓp : DR - 쫼Ñp ñ¿ß¬á │*/
- /*│ éδσ«ñ¡δÑ »ápá¼ÑΓpδ: ¡ÑΓ │*/
- /*└──────────────────────────────────────────────────────────────────────┘*/
-
- void ShowPartition( BYTE LW )
- {
-
- #define AP ParSec.PartTable[ Entry ]
-
- BYTE Head, /* ⫽«ó¬á ñ½∩ ΓѬπΘÑú« páºñѽá */
- Entry, /* æτÑΓτ¿¬ µ¿¬½á */
- SecCyl; /* æÑ¬Γ«p ¿ µ¿½¿¡ñp */
- PARTSEC ParSec; /* ÆÑ¬πΘ¿⌐ ßÑ¬Γ«p páºí¿Ñ¡¿∩ */
- int Sector, /* Å«½πτÑ¡¿Ñ ßÑ¬Γ«pá ¿ µ¿½¿¡ñpá */
- Cylinder; /* 쫼Ñp */
- union REGS Regs; /* ÉÑú¿ßΓpδ »p«µÑßß«pá */
- /* ñ½∩ ó맮óá »pÑpδóá¡¿∩ */
- printf( "\n" );
- LW |= 0x80; /* Å«ñú«Γ«ó¬á ¡«¼Ñpá ñ¿ß¬á ñ½∩ BIOS */
- if ( ReadPartSec( LW, 0, 1, &ParSec ) ) /* ùΓÑ¡¿Ñ ΓѬπΘÑú« ΓѬßΓá */
- { /* æÑ¬Γ«p πß»ÑΦ¡« »p«τ¿Γá¡ */
- Regs.h.ah = 8; /* ùΓÑ¡¿Ñ ñá¡¡δσ ñ¿ß¬á */
- Regs.h.dl = LW;
- int86( 0x13, &Regs, &Regs );/* é맮ó »pÑpδóá¡¿∩ ªÑßΓ¬«ú« ñ¿ß¬á*/
- GetSecCyl( Regs.x.cx, &Sector, &Cylinder );
- printf("┌──────────────────────────────────────────────────────"
- "────────────────────────┐");
- printf("│ ä¿ß¬ %2d: %2d ú«½«ó«¬ ß %4d "
- " µ¿½¿¡ñpἿ %3d ßÑ¬Γ«pἿ │",
- LW-0x80, Regs.h.dh+1, Cylinder, Sector );
- printf("│ Æáí½¿µá páºñѽ«ó ó ßÑ¬Γ«pÑ páºí¿Ñ¡¿∩ "
- " │");
- printf("├──┬────┬───────────────────────┬─────────────┬───"
- "──────────┬───────────┬──────┤");
- printf("│ │ │ │ ìáτὫ │ 諡ѵ"
- " │ÉáßßΓ«∩¡¿Ñ │諽-ó«│");
-
- printf("│#.│çáúp│Æ¿» │ ⫽ û¿½ æÑ¬ │"
- " ⫽ û¿½ æÑ¬ │«Γ ßѬ.ºáú.│ßѬΓ. │");
-
- printf("├──┼────┼───────────────────────┼─────────────┼─────"
- "────────┼───────────┼──────┤");
-
- for(Entry = 0; Entry < 4; ++Entry)
- {
- printf( "│ %d│", Entry );
- if (AP.Status == 0x80 )
- printf("äá ");
- else
- printf("ìÑΓ ");
- printf("│");
- switch( AP.PartTyp ) /* ÄΓ«ípáªÑ¡¿Ñ Γ¿»á páºñѽá */
- {
- case 0x00 : printf("ìÑ ºá¡∩Γ« ");
- break;
- case 0x01 : printf("DOS, 12-í¿Γ«óá∩ FAT ");
- break;
- case 0x02 : printf("XENIX ");
- break;
- case 0x03 : printf("XENIX ");
- break;
- case 0x04 : printf("DOS, 16-í¿Γ«óá∩ FAT ");
- break;
- case 0x05 : printf("DOS, ä«»«½¡¿Γ. páºñѽ ");
- break;
- case 0xDB : printf("Åápώѽ∞¡á∩ DOS ");
- break;
- default : printf("ìÑ¿ºóÑßΓ¡á∩ (%3d) ",
- ParSec.PartTable[Entry].PartTyp);
- }
-
- GetSecCyl ( AP.StartSec.SecCyl, &Sector, &Cylinder );
- printf ( "│%2d %5d %3d ",AP.StartSec.Head,Cylinder, Sector );
- GetSecCyl ( AP.EndSec.SecCyl, &Sector, &Cylinder );
- printf ( "│%2d %5d %3d ",AP.EndSec.Head,Cylinder, Sector );
- printf ( "│ %6lu │%6lu│",AP.SecOfs, AP.SecNum );
- }
- printf("└──┴────┴───────────────────────┴─────────────┴───"
- "──────────┴───────────┴──────┘");
- }
- else
- printf(" ÄΦ¿í¬á ó« ópѼ∩ ñ«ßΓπ»á ¬ ßÑ¬Γ«pπ ºáúpπº¬¿!\n");
- }
-
- /**************************************************************************/
- /* âÄïÄéìǃ ÅÉÄâÉÇîîÇ */
- /**************************************************************************/
- int main( int argc, char *argv[] )
- {
- int HrdDrive;
-
- HrdDrive = 0; /* Å« π¼«½τá¡¿ε */
- if ( argc == 2 ) /* àß½¿ ñ¿ß¬ ºáñá¡ »ápá¼ÑΓp«¼ */
- { /* äá */
- HrdDrive = atoi ( argv[ 1 ]);
- if ( HrdDrive == 0 && *argv[ 1 ] != '0' )
- {
- printf( "\n ìÑóÑp¡« π¬áºá¡ ñ¿ß¬!" );
- return( 1 ); /* 諡ѵ »p«úpá¼¼δ */
- }
- }
- ShowPartition( HrdDrive ); /* ÄΓ«ípáªÑ¡¿Ñ ßÑ¬Γ«pá páºí¿Ñ¡¿∩ */
- return( 0 );
- }
-
-