// FcsrasapiP.cpp : DLL AvP[Vp̃Gg |Cg`܂B
//


/////////////////////////////////////////////////////////////////////////////
//
//	Fcsrasapi.cpp : Soft RAS DLLĂяo
//                          
//
//	Copyright (C) NEC Corporation 2005
//
//
/////////////////////////////////////////////////////////////////////////////


#include "stdafx.h"

int WINAPI DllMain(HINSTANCE hInst, DWORD fdwReason, PVOID pvReserved)
{
    return TRUE;
}

/////////////////////////////////////////////////////////////////////////////
//	GetArraySize:
//
//	Description:
//		z̃TCY擾
//
//	Arguments:
//		NONE
//
//	Return Value:
//		  :ž
//		 s :-1
//
DWORD GetArraySize(
		LPSAFEARRAY   *ppSa

) 
{
	INT		dimension;	
	DWORD	nBuffSize;
	LONG	lBound;
	LONG	uBound;

	// ۑGA̎`FbN
	dimension = SafeArrayGetDim(*ppSa);
	if (dimension == 1) {
		// ۑGÃTCY`FbN
		SafeArrayGetLBound(*ppSa, 1, &lBound);
		SafeArrayGetUBound(*ppSa, 1, &uBound);
		nBuffSize = uBound - lBound + 1;
	} else {
		nBuffSize = -1;
	}
	return nBuffSize;
}
/////////////////////////////////////////////////////////////////////////////
//	fcsoftrasOpen:
//
//	Description:
//		FC\tgRAS I[v
//
//	Arguments:
//		NONE
//
//	Return Value:
//		 FCSRASAPI_SUCCESS	: Success
//		 FCSRASAPI_DRVERR	: Faild
//
FCSOFTRASP_API
DWORD __stdcall
fcsoftrasOpenP (
	VOID
	)
{
	return fcsoftrasOpen();
}


/////////////////////////////////////////////////////////////////////////////
//	fcsoftrasClose:
//
//	Description:
//		FC\tgRAS N[Y
//
//	Arguments:
//		NONE
//
//	Return Value:
//		 FCSRASAPI_SUCCESS	: Success
//		 FCSRASAPI_DRVERR	: Faild
//
FCSOFTRASP_API
DWORD __stdcall
fcsoftrasCloseP (
	VOID
	)
{
	return fcsoftrasClose();
}

/////////////////////////////////////////////////////////////////////////////
//	fcsoftrasGetVersion:
//
//	Description:
//		FC\tgRAS o[W擾
//
//	Arguments:
//		LPBYTE	lpBuff		: o[Wi[obt@擪|C^
//		DWORD	nBuffSize	: i[obt@TCY (68byteȏ)
//						-----------------
//					+0	| Module Number | fio[
//					:	|               |    (ASCII 40)
//					:	-----------------
//					+40	| Firmware Rev  | t@[EFArW
//					:	|               |    (ASCII 8)
//					:	-----------------
//					+48	| Serial Number | VAio[
//					:	|               |    (ASCII 20)
//					+67	-----------------
//
//	Return Value:
//		 FCSRASAPI_SUCCESS	: Success
//		 FCSRASAPI_DRVERR	: Faild
//
FCSOFTRASP_API
DWORD __stdcall
fcsoftrasGetVersionP (
	LPSAFEARRAY   *ppVersion
	)
{
	DWORD ret;	
	LPBYTE pBuff;
	DWORD nBuffSize;
    PCHAR   buf;
    	
	nBuffSize = GetArraySize(ppVersion);

	if (nBuffSize > 0) {	
		// ۑGÃTCỸGAm
		pBuff = (LPBYTE)malloc(nBuffSize);

		// ۂ̌Ăяo
		ret = fcsoftrasGetVersion(pBuff,nBuffSize);

		// ĂяoʂۑGAփRs[
		SafeArrayAccessData(*ppVersion,(void**)&buf);
		memcpy(buf,pBuff,nBuffSize);	
		SafeArrayUnaccessData(*ppVersion);

	} else {
		ret = FCSRASAPI_DRVERR;
	}

	return ret;


}
/////////////////////////////////////////////////////////////////////////////
//	fcsoftrasGetTemp:
//
//	Description:
//		FC\tgRAS x擾
//
//	Arguments:
//		LPBYTE	lpBuff		: xi[obt@擪|C^
//		DWORD	nBuffSize	: i[obt@TCY (4byteȏ)
//						-----------------
//					+0	| Error Bit     | xG[(Bit) [Bit0:CPUx,Bit1:щx]
//						-----------------
//					+1	| Warning Bit   | x[jO(Bit) [Bit0:CPUx,Bit1:щx]
//						-----------------
//					+2	| Temp Data 1   | CPUxf[^ (signed char)
//						-----------------
//					+3	| Temp Data 2   | щxf[^ (signed char)
//						-----------------
//
//	Return Value:
//		 FCSRASAPI_SUCCESS	: Success
//		 FCSRASAPI_DRVERR	: Faild
//
FCSOFTRASP_API
DWORD __stdcall
fcsoftrasGetTempP (
	LPSAFEARRAY   *ppTemp
	)
{
	DWORD ret;	
	LPBYTE pBuff;
	DWORD nBuffSize;
    PCHAR   buf;
	
	nBuffSize = GetArraySize(ppTemp);

	if (nBuffSize > 0 ) {
		// ۑGÃTCỸGAm
		pBuff = (LPBYTE)malloc(nBuffSize);
		// ۂ̏Ăяo
		ret = fcsoftrasGetTemp(pBuff,nBuffSize);

		// ĂяoʂۑGAփRs[
		SafeArrayAccessData(*ppTemp,(void**)&buf);
		memcpy(buf,pBuff,nBuffSize);	
		SafeArrayUnaccessData(*ppTemp);
	
		free ((void *)pBuff);

	} else {
		ret = FCSRASAPI_DRVERR;
	}
	return ret;

}
/////////////////////////////////////////////////////////////////////////////
//	fcsoftrasGetFan:
//
//	Description:
//		FC\tgRAS t@]f[^擾
//
//	Arguments:
//		LPBYTE	lpBuff		: t@]f[^i[obt@擪|C^
//		DWORD	nBuffSize	: i[obt@TCY (9byteȏ)
//						-----------------
//					+0	|  Error Bit    | t@G[(Bit) [ Bit0:CPU, Bit1:\, 
//						-----------------                     Bit2:A, Bit3:d ]
//					+1	|               | 
//						-  Fan Data 1   - CPUt@]
//						|               | 
//						-----------------
//					+3	|               | 
//						-  Fan Data 2   - \t@]
//						|               | 
//						-----------------
//					+5	|               |
//						-  Fan Data 3   - At@]
//						|               |
//						-----------------
//					+7	|               |
//						-  Fan Data 4   - dt@]
//						|               |
//						-----------------
//
//	Return Value:
//		 FCSRASAPI_SUCCESS	: Success
//		 FCSRASAPI_DRVERR	: Faild
//
FCSOFTRASP_API
DWORD __stdcall
fcsoftrasGetFanP (
	LPSAFEARRAY   *ppFan
	)
{

	DWORD ret;	
	LPBYTE pBuff;
	DWORD nBuffSize;
    PCHAR   buf;
	
	nBuffSize = GetArraySize(ppFan);

	if (nBuffSize > 0 ) {
		// ۑGÃTCỸGAm
		pBuff = (LPBYTE)malloc(nBuffSize);
		// ۂ̏Ăяo
		ret = fcsoftrasGetFan(pBuff,nBuffSize);

		// ĂяoʂۑGAփRs[
		SafeArrayAccessData(*ppFan,(void**)&buf);
		memcpy(buf,pBuff,nBuffSize);	
		SafeArrayUnaccessData(*ppFan);
	
		free ((void *)pBuff);

	} else {
		ret = FCSRASAPI_DRVERR;
	}
	return ret;
}

/////////////////////////////////////////////////////////////////////////////
//	fcsoftrasGetVoltage:
//
//	Description:
//		FC\tgRAS df[^擾
//
//	Arguments:
//		LPBYTE	lpBuff		: df[^i[obt@擪|C^
//		DWORD	nBuffSize	: i[obt@TCY (15byteȏ)
//						-----------------
//					+0	|  Error Bit    | dG[(Bit) [ Bit0:+2.5V, Bit1:CPU-VRM, Bit2:+3.3V 
//						-----------------                   Bit3:+5V, Bit4:+12V, Bit5:+3.3V, Bit6:+1.5V ]
//					+1	|               | 
//						-  Volt Data 1  - +2.5V d
//						|               | 
//						-----------------
//					+3	|               | 
//						-  Volt Data 2  - CPU VRM d
//						|               | 
//						-----------------
//					+5	|               |
//						-  Volt Data 3  - +3.3V d
//						|               |
//						-----------------
//					+7	|               |
//						-  Volt Data 4  - +5V d
//						|               |
//						-----------------
//					+9	|               |
//						-  Volt Data 5  - +12V d
//						|               |
//						-----------------
//					+11 |               |
//						-  Volt Data 6  - +3.3V d
//						|               |
//						-----------------
//					+13	|               |
//						-  Volt Data 7  - +1.5V d
//						|               |
//						-----------------
//
//	Return Value:
//		 FCSRASAPI_SUCCESS	: Success
//		 FCSRASAPI_DRVERR	: Faild
//
FCSOFTRASP_API
DWORD	__stdcall
fcsoftrasGetVoltageP (
	LPSAFEARRAY   *ppVoltage
	)
{

	DWORD ret;	
	LPBYTE pBuff;
	DWORD nBuffSize;
    PCHAR   buf;
	
	nBuffSize = GetArraySize(ppVoltage);

	if (nBuffSize > 0 ) {
		// ۑGÃTCỸGAm
		pBuff = (LPBYTE)malloc(nBuffSize);
		// ۂ̏Ăяo
		ret = fcsoftrasGetVoltage(pBuff,nBuffSize);

		// ĂяoʂۑGAփRs[
		SafeArrayAccessData(*ppVoltage,(void**)&buf);
		memcpy(buf,pBuff,nBuffSize);	
		SafeArrayUnaccessData(*ppVoltage);
		free ((void *)pBuff);
	} else {
		ret = FCSRASAPI_DRVERR;
	}
		
	return ret;
}

/////////////////////////////////////////////////////////////////////////////
//	fcsoftrasGetHDDInf:
//
//	Description:
//		FC\tgRAS HDD擾
//
//	Arguments:
//		LPBYTE	lpBuff		: HDDi[obt@擪|C^
//		DWORD	nBuffSize	: i[obt@TCY (4byteȏ)
//						-----------------
//					+0	| ײإϽ    | IDE ײإϽ HDDBit
//						-----------------
//					+1	| ײإڰ  | IDE ײإڰ HDDBit
//						-----------------
//					+2	| إϽ    | IDE إϽ HDDBit
//						-----------------
//					+3	| إڰ  | IDE إڰ HDDBit
//						-----------------
//
//	Return Value:
//		 FCSRASAPI_SUCCESS	: Success
//		 FCSRASAPI_DRVERR	: Faild
//
FCSOFTRASP_API
DWORD __stdcall
fcsoftrasGetHDDInfP (
	LPSAFEARRAY   *ppHddInf
	)
{
	DWORD ret;	
	LPBYTE pBuff;
	DWORD nBuffSize;
    PCHAR   buf;
	
	nBuffSize = GetArraySize(ppHddInf);

	if (nBuffSize > 0 ) {
		// ۑGÃTCỸGAm
		pBuff = (LPBYTE)malloc(nBuffSize);
		// ۂ̏Ăяo
		ret =  fcsoftrasGetHDDInf (pBuff,nBuffSize);

		// ĂяoʂۑGAփRs[
		SafeArrayAccessData(*ppHddInf,(void**)&buf);
		memcpy(buf,pBuff,nBuffSize);	
		SafeArrayUnaccessData(*ppHddInf);
	
		free ((void *)pBuff);

	} else {
		ret = FCSRASAPI_DRVERR;
	}
	return ret;

}
/////////////////////////////////////////////////////////////////////////////
//	fcsoftrasGetMirrorStatus:
//
//	Description:
//		FC\tgRAS ~[J[hԎ擾
//
//	Arguments:
//		BYTE	byDriveNum	: 擾hCuw
//		LPBYTE	lpBuff		: HDDi[obt@擪|C^
//		DWORD	nBuffSize	: i[obt@TCY (3byteȏ)
//						-----------------
//					+0	| Mirror State  | ~[J[hԃR[h
//						-----------------
//					+1	| Drive1 State  | HDD Drive1 Bit
//						-----------------
//					+2	| Drive2 State  | HDD Drive2 Bit
//						-----------------
//
//	Return Value:
//		 FCSRASAPI_SUCCESS	: Success
//		 FCSRASAPI_DRVERR	: Faild
//
FCSOFTRASP_API
DWORD __stdcall
fcsoftrasGetMirrorStatusP (
	BYTE	byDriveNum,
	LPSAFEARRAY   *ppState
	)
{
	DWORD ret;	
	LPBYTE pBuff;
	DWORD nBuffSize;
    PCHAR   buf;
	
	nBuffSize = GetArraySize(ppState);

	if (nBuffSize > 0 ) {
		// ۑGÃTCỸGAm
		pBuff = (LPBYTE)malloc(nBuffSize);
		// ۂ̏Ăяo
		ret = fcsoftrasGetMirrorStatus(byDriveNum,pBuff,nBuffSize);

		// ĂяoʂۑGAփRs[
		SafeArrayAccessData(*ppState,(void**)&buf);
		memcpy(buf,pBuff,nBuffSize);	
		SafeArrayUnaccessData(*ppState);
	
		free ((void *)pBuff);

	} else {
		ret = FCSRASAPI_DRVERR;
	}
	return ret;

}

/////////////////////////////////////////////////////////////////////////////
//	fcsoftrasGetSMART:
//
//	Description:
//		FC\tgRAS HDD-S.M.A.R.T f[^擾
//
//	Arguments:
//		BYTE	byDriveNum	: 擾hCuw
//		LPBYTE	lpBuff		: SMARTf[^i[obt@擪|C^
//		DWORD	nBuffSize	: i[obt@TCY (512byteȏ)
//						-----------------
//					+0	|               |
//					:	| SMART Data    | SMARTf[^ (512byte)
//					+511|               |
//						-----------------
//
//	Return Value:
//		 FCSRASAPI_SUCCESS	: Success
//		 FCSRASAPI_DRVERR	: Faild
//
FCSOFTRASP_API
DWORD __stdcall
fcsoftrasGetSMARTP (
	BYTE	byDriveNum,
	LPSAFEARRAY  *ppSMART
	)
{
	DWORD ret;	
	LPBYTE pBuff;
	DWORD nBuffSize;
    PCHAR   buf;
	
	nBuffSize = GetArraySize(ppSMART);

	if (nBuffSize > 0 ) {
		// ۑGÃTCỸGAm
		pBuff = (LPBYTE)malloc(nBuffSize);
		// ۂ̏Ăяo
		ret = fcsoftrasGetSMART(byDriveNum,pBuff,nBuffSize);

		// ĂяoʂۑGAփRs[
		SafeArrayAccessData(*ppSMART,(void**)&buf);
		memcpy(buf,pBuff,nBuffSize);	
		SafeArrayUnaccessData(*ppSMART);
	
		free ((void *)pBuff);

	} else {
		ret = FCSRASAPI_DRVERR;
	}
	return ret;

}
/////////////////////////////////////////////////////////////////////////////
//	fcsoftrasGetPciErr:
//
//	Description:
//		FC\tgRAS PCIG[擾
//
//	Arguments:
//		LPBYTE	lpBuff		: PCIG[i[obt@擪|C^
//		DWORD	nBuffSize	: i[obt@TCY (1byteȏ)
//						-----------------
//					+0	| PCI Error Bit | PCIG[(Bit) [Bit0:èװ]
//						-----------------
//
//	Return Value:
//		 FCSRASAPI_SUCCESS	: Success
//		 FCSRASAPI_DRVERR	: Faild
//
FCSOFTRASP_API
DWORD __stdcall
fcsoftrasGetPciErrorP (
	LPSAFEARRAY  *ppPciError	
	)
{
	DWORD ret;	
	LPBYTE pBuff;
	DWORD nBuffSize;
    PCHAR   buf;
	
	nBuffSize = GetArraySize(ppPciError);

	if (nBuffSize > 0 ) {
		// ۑGÃTCỸGAm
		pBuff = (LPBYTE)malloc(nBuffSize);
		// ۂ̏Ăяo
		ret = fcsoftrasGetPciError (pBuff,nBuffSize);

		// ĂяoʂۑGAփRs[
		SafeArrayAccessData(*ppPciError,(void**)&buf);
		memcpy(buf,pBuff,nBuffSize);	
		SafeArrayUnaccessData(*ppPciError);
	
		free ((void *)pBuff);

	} else {
		ret = FCSRASAPI_DRVERR;
	}
	return ret;

}
/////////////////////////////////////////////////////////////////////////////
//	fcsoftrasGetRevRcn:
//
//	Description:
//		FC\tgRAS ~[HDDoCoR񐔎擾
//
//	Arguments:
//		BYTE	byDriveNum	: 擾hCuw
//		LPBYTE	lpbyGetCunt	: 擾񐔐擪|C^(BYTE)
//
//	Return Value:
//		 FCSRASAPI_SUCCESS	: Success
//		 FCSRASAPI_DRVERR	: Faild
//
FCSOFTRASP_API
DWORD __stdcall
fcsoftrasGetRevRcnP (
	BYTE	byDriveNum,
	LPBYTE	lpbyGetCunt
	)
{
	return fcsoftrasGetRevRcn(byDriveNum,lpbyGetCunt);
}
/////////////////////////////////////////////////////////////////////////////
//	fcsoftrasClearPowerButton:
//
//	Description:
//		FC\tgRAS dSW̏ԃNA
//
//	Arguments:
//       
//	Return Value:
//		 FCSRASAPI_SUCCESS	: Success
//		 FCSRASAPI_DRVERR	: Faild
//
FCSOFTRASP_API
DWORD __stdcall
fcsoftrasClearPowerButtonP (
	void
)
{
	return fcsoftrasClearPowerButton ();
}
/////////////////////////////////////////////////////////////////////////////
//	fcsoftrasSetRevRcn:
//
//	Description:
//		FC\tgRAS ~[HDDoCoR񐔐ݒ
//
//	Arguments:
//		BYTE	byDriveNum	: ݒhCuw
//		BYTE	bySetCunt	: ݒ
//
//	Return Value:
//		 FCSRASAPI_SUCCESS	: Success
//		 FCSRASAPI_DRVERR	: Faild
//
FCSOFTRASP_API
DWORD __stdcall
fcsoftrasSetRevRcnP (
	BYTE	byDriveNum,
	BYTE	bySetCunt
	)
{
	return fcsoftrasSetRevRcn(byDriveNum,bySetCunt);
}
/////////////////////////////////////////////////////////////////////////////
//	fcsoftrasGetRTCTime:
//
//	Description:
//		FC\tgRAS RTC 擾
//
//	Arguments:
//		LPBYTE	lpBuff		: RTCi[obt@擪|C^
//		DWORD	nBuffSize	: i[obt@TCY (7byteȏ)
//						-----------------
//					+0	| Year          | (2)
//						-----------------
//					+1	| Manth         | 
//						-----------------
//					+2	| Day           | 
//						-----------------
//					+3	| Day of week   | j
//						-----------------
//					+4	| Hour          | 
//						-----------------
//					+5	| Minute        | 
//						-----------------
//					+6	| Second        | b
//						-----------------
//
//	Return Value:
//		 FCSRASAPI_SUCCESS	: Success
//		 FCSRASAPI_DRVERR	: Faild
//
FCSOFTRASP_API
DWORD __stdcall
fcsoftrasGetRTCTimeP (
		LPSAFEARRAY  *ppTime
)
{
	DWORD ret;	
	LPBYTE pBuff;
	DWORD nBuffSize;
    PCHAR   buf;
	
	nBuffSize = GetArraySize(ppTime);

	if (nBuffSize > 0 ) {
		// ۑGÃTCỸGAm
		pBuff = (LPBYTE)malloc(nBuffSize);
		// ۂ̏Ăяo
		ret = fcsoftrasGetRTCTime (pBuff,nBuffSize);

		// ĂяoʂۑGAփRs[
		SafeArrayAccessData(*ppTime,(void**)&buf);
		memcpy(buf,pBuff,nBuffSize);	
		SafeArrayUnaccessData(*ppTime);
	
		free ((void *)pBuff);

	} else {
		ret = FCSRASAPI_DRVERR;
	}
	return ret;

}
/////////////////////////////////////////////////////////////////////////////
//	fcsoftrasSetRTCTime:
//
//	Description:
//		FC\tgRAS RTC ݒ
//
//	Arguments:
//		LPBYTE	lpBuff		: RTCi[obt@擪|C^
//		DWORD	nBuffSize	: i[obt@TCY (7byteȏ)
//						-----------------
//					+0	| Year          | (2)
//						-----------------
//					+1	| Manth         | 
//						-----------------
//					+2	| Day           | 
//						-----------------
//					+3	| Day of week   | j
//						-----------------
//					+4	| Hour          | 
//						-----------------
//					+5	| Minute        | 
//						-----------------
//					+6	| Second        | b
//						-----------------
//
//	Return Value:
//		 FCSRASAPI_SUCCESS	: Success
//		 FCSRASAPI_DRVERR	: Faild
//
FCSOFTRASP_API
DWORD __stdcall
fcsoftrasSetRTCTimeP (
	LPSAFEARRAY  *ppTime
	)
{
	DWORD ret;	
	LPBYTE pBuff;
	DWORD nBuffSize;
    PCHAR   buf;
	
	nBuffSize = GetArraySize(ppTime);

	if (nBuffSize > 0 ) {
		// ۑGÃTCỸGAm
		pBuff = (LPBYTE)malloc(nBuffSize);
		// ۂ̏Ăяo
		ret = fcsoftrasSetRTCTime(pBuff,nBuffSize);

		// ĂяoʂۑGAփRs[
		SafeArrayAccessData(*ppTime,(void**)&buf);
		memcpy(buf,pBuff,nBuffSize);	
		SafeArrayUnaccessData(*ppTime);
	
		free ((void *)pBuff);

	} else {
		ret = FCSRASAPI_DRVERR;
	}
	return ret;
}

/////////////////////////////////////////////////////////////////////////////
//	fcsoftrasReleaseMirrorDrive:
//
//	Description:
//		FC\tgRAS ~[hCu؂藣
//
//	Arguments:
//		BYTE	byDriveNum	: ؂藣hCuw
//
//	Return Value:
//		 FCSRASAPI_SUCCESS	: Success
//		 FCSRASAPI_DRVERR	: Faild
//
FCSOFTRASP_API
DWORD __stdcall
fcsoftrasReleaseMirrorDriveP (
	BYTE	byDriveNum
	)
{
	return fcsoftrasReleaseMirrorDrive(byDriveNum);
}

/////////////////////////////////////////////////////////////////////////////
//	fcsoftrasSetMirrorSMARTMode:
//
//	Description:
//		FC\tgRAS ~[SMART[hݒ
//
//	Arguments:
//		BYTE	byDriveNum	: ݒ~[hCuw
//		BYTE	byModeCode	: ݒSMART[h
//
//	Return Value:
//		 FCSRASAPI_SUCCESS	: Success
//		 FCSRASAPI_DRVERR	: Faild
//
FCSOFTRASP_API
DWORD __stdcall
fcsoftrasSetMirrorSMARTModeP (
	BYTE	byDriveNum,
	BYTE	byModeCode
	)
{
	return fcsoftrasSetMirrorSMARTMode (byDriveNum,byModeCode);
}
/////////////////////////////////////////////////////////////////////////////
//	fcsoftrasGetMirrorSMARTMode:
//
//	Description:
//		FC\tgRAS ~[SMART[h擾
//
//	Arguments:
//		BYTE	byDriveNum	: 擾~[hCuw
//		LPBYTE	pModeCode	: 擾SMART[hi[GA
//
//	Return Value:
//		 FCSRASAPI_SUCCESS	: Success
//		 FCSRASAPI_DRVERR	: Faild
//
FCSOFTRASP_API
DWORD __stdcall
fcsoftrasGetMirrorSMARTModeP(
	BYTE	byDriveNum,
	LPBYTE	lpModeCode
	)
{
	return fcsoftrasGetMirrorSMARTMode(byDriveNum,lpModeCode);
}
/////////////////////////////////////////////////////////////////////////////
//	fcsoftrasGetHDDErrorLog:
//
//	Description:
//		FC\tgRAS HDD-ErrorLogf[^擾
//
//	Arguments:
//		BYTE	byDriveNum	: 擾hCuw
//		LPBYTE	lpBuff		: ErrorLogf[^i[obt@擪|C^
//		DWORD	nBuffSize	: i[obt@TCY (512x64byteȏ)
//						-----------------
//					+0	|               |
//					:	| ErrorLog Data | ErrorLogf[^ (512x64byte)
//				  +32767|               |
//						-----------------
//
//	Return Value:
//		 FCSRASAPI_SUCCESS	: Success
//		 FCSRASAPI_DRVERR	: Faild
//
FCSOFTRASP_API
DWORD __stdcall
fcsoftrasGetHDDErrorLogP (
	BYTE	byDriveNum,
	LPSAFEARRAY  *ppErrorLog
	)
{
	DWORD ret;	
	LPBYTE pBuff;
	DWORD nBuffSize;
    PCHAR   buf;
	
	nBuffSize = GetArraySize(ppErrorLog);

	if (nBuffSize > 0 ) {
		// ۑGÃTCỸGAm
		pBuff = (LPBYTE)malloc(nBuffSize);
		// ۂ̏Ăяo
		ret = fcsoftrasGetHDDErrorLog (byDriveNum,pBuff,nBuffSize);

		// ĂяoʂۑGAփRs[
		SafeArrayAccessData(*ppErrorLog,(void**)&buf);
		memcpy(buf,pBuff,nBuffSize);	
		SafeArrayUnaccessData(*ppErrorLog);
	
		free ((void *)pBuff);

	} else {
		ret = FCSRASAPI_DRVERR;
	}
	return ret;

}
/////////////////////////////////////////////////////////////////////////////
//	fcsoftrasGetPowerButton:
//
//	Description:
//		FC\tgRAS dSW̏Ԏ擾
//
//	Arguments:
//		LPBYTE	lpBuff		: dԕۑGA
//		DWORD	nBuffSize	: i[obt@TCY (1byteȏ)
//						-----------------
//					+0	|  Error Bit    | t@G[(Bit) [ Bit0 ON :DC Switchꂽ
//						-----------------                     Bit0 OFF:DC SwitchĂȂ]
//
//	Return Value:
//		 FCSRASAPI_SUCCESS	: Success
//		 FCSRASAPI_DRVERR	: Faild
//
FCSOFTRASP_API
DWORD __stdcall
fcsoftrasGetPowerButtonP (
	LPSAFEARRAY  *ppPoerButton
)
{
	DWORD ret;	
	LPBYTE pBuff;
	DWORD nBuffSize;
    PCHAR   buf;
	
	nBuffSize = GetArraySize(ppPoerButton);

	if (nBuffSize > 0 ) {
		// ۑGÃTCỸGAm
		pBuff = (LPBYTE)malloc(nBuffSize);
		// ۂ̏Ăяo
		ret =  fcsoftrasGetPowerButton (pBuff,nBuffSize);

		// ĂяoʂۑGAփRs[
		SafeArrayAccessData(*ppPoerButton,(void**)&buf);
		memcpy(buf,pBuff,nBuffSize);	
		SafeArrayUnaccessData(*ppPoerButton);	
		free ((void *)pBuff);

	} else {
		ret = FCSRASAPI_DRVERR;
	}
	return ret;

	
}
/////////////////////////////////////////////////////////////////////////////
//	fcsoftrasGetHDDIdentify:
//
//	Description:
//		FC\tgRAS HDD ʏ f[^擾
//
//	Arguments:
//		BYTE	byDriveNum	: 擾hCuw
//		LPBYTE	lpBuff		: HDDʏobt@擪|C^
//		DWORD	nBuffSize	: i[obt@TCY (512byteȏ)
//						-----------------
//					+0	|               |
//					:	| ʏ      | ʏf[^ (512byte)
//					+511|               |
//						-----------------
//
//	Return Value:
//		 FCSRASAPI_SUCCESS	: Success
//		 FCSRASAPI_DRVERR	: Faild
//
FCSOFTRASP_API
DWORD __stdcall
fcsoftrasGetHDDIdentifyP (
	BYTE	byDriveNum,
	LPSAFEARRAY  *ppIdentify,
	LPBYTE  lpAtaCmd
	)
{
	DWORD ret;	
	LPBYTE pBuff;
	DWORD nBuffSize;
    PCHAR   buf;
	
	nBuffSize = GetArraySize(ppIdentify);

	if (nBuffSize > 0 ) {
		// ۑGÃTCỸGAm
		pBuff = (LPBYTE)malloc(nBuffSize);
		// ۂ̏Ăяo		
		ret =  fcsoftrasGetHDDIdentify (byDriveNum,pBuff,nBuffSize, lpAtaCmd);

		// ĂяoʂۑGAփRs[
		SafeArrayAccessData(*ppIdentify,(void**)&buf);
		memcpy(buf,pBuff,nBuffSize);	
		SafeArrayUnaccessData(*ppIdentify);
	
		free ((void *)pBuff);

	} else {
		ret = FCSRASAPI_DRVERR;
	}
	return ret;


}

/////////////////////////////////////////////////////////////////////////////
//	fcsoftrasGetMirrorReconProgress:
//
//	Description:
//		FC\tgRAS ~[č\zi󋵎擾
//
//	Arguments:
//		BYTE	byDriveNum	: 擾~[hCuw
//		LPBYTE	pModeCode	: č\zi
//
//	Return Value:
//		 FCSRASAPI_SUCCESS	: Success
//		 FCSRASAPI_DRVERR	: Faild
//
FCSOFTRASP_API
DWORD __stdcall
fcsoftrasGetMirrorReconProgressP (
	BYTE	byDriveNum,
	LPBYTE	lpModeCode
	)
{
	return fcsoftrasGetMirrorReconProgress (byDriveNum,lpModeCode);
}