📄 loader.c
字号:
RegCloseKey(hKey);
}
///////////////////////////////////////////////////////////////////////////////
// NDL_Deinit - the deinit entry point for this driver
// Input: hDeviceContext - the context returned from NDL_Init
// Output:
// Returns: always returns TRUE.
// Notes:
///////////////////////////////////////////////////////////////////////////////
BOOL NDL_Deinit(DWORD hDeviceContext)
{
PMINIPORT_INSTANCE_INFO pInstance; // memory card instance
DbgPrintZo(SDCARD_ZONE_INIT, (TEXT("SDNDISLDR: +NDL_Deinit\n")));
pInstance = (PMINIPORT_INSTANCE_INFO)hDeviceContext;
// unload the miniport
UnloadMiniport(pInstance);
EnterCriticalSection(&LoaderCriticalSection);
// free our instance number
AllocatedInstance[pInstance->InstanceNumber] = FALSE;
LeaveCriticalSection(&LoaderCriticalSection);
LocalFree(pInstance);
DbgPrintZo(SDCARD_ZONE_INIT, (TEXT("SDNDISLDR: -NDL_Deinit\n")));
return TRUE;
}
///////////////////////////////////////////////////////////////////////////////
// NDL_Init - the init entry point
// Input: dwContext - the context for this init
// Output:
// Return: returns a non-zero context
// Notes:
///////////////////////////////////////////////////////////////////////////////
DWORD NDL_Init(DWORD dwContext)
{
PMINIPORT_INSTANCE_INFO pInstance; // this instance of the device
ULONG ii;
DWORD dwThreadID;
DbgPrintZo(SDCARD_ZONE_INIT, (TEXT("SDNDISLDR: +NDL_Init\n")));
pInstance = (PMINIPORT_INSTANCE_INFO)LocalAlloc(LPTR, sizeof(MINIPORT_INSTANCE_INFO));
if (pInstance == NULL) {
DbgPrintZo(SDCARD_ZONE_ERROR, (TEXT("SDNDISLDR: Failed to allocate device info \n")));
DbgPrintZo(SDCARD_ZONE_INIT, (TEXT("SDNDISLDR: -NDL_Init\n")));
return 0;
}
// on CE, the dwContext is a pointer to a string to the "Active" registry path
// we pass this to the NDIS driver
wcscpy(pInstance->ActiveKeyPath, (PWCHAR)dwContext);
if (SDGetRegPathFromInitContext((PWCHAR)dwContext,
pInstance->RegPath,
sizeof(pInstance->RegPath)) != ERROR_SUCCESS) {
DbgPrintZo(SDCARD_ZONE_ERROR, (TEXT("SDNDISLDR: Failed to get reg path \n")));
LocalFree(pInstance);
return 0;
}
EnterCriticalSection(&LoaderCriticalSection);
// walk through the array and find an open instance number
for (ii = 0; ii < MAX_NUMBER_OF_ADAPTERS; ii++) {
if (AllocatedInstance[ii] == FALSE) {
// mark that it has been allocated
AllocatedInstance[ii] = TRUE;
// save off the index
pInstance->InstanceNumber = ii;
break;
}
}
LeaveCriticalSection(&LoaderCriticalSection);
if (ii >= MAX_NUMBER_OF_ADAPTERS) {
DbgPrintZo(SDCARD_ZONE_ERROR, (TEXT("SDNDISLDR: Max instances exceeded \n")));
LocalFree(pInstance);
return 0;
}
// per BSquare's suggestion, use a seperate thread to prevent the interrupt replies from blocking
CreateThread(NULL, 0, (unsigned long (__cdecl *)(void *))LoadMiniport, pInstance, 0, &dwThreadID);
DbgPrintZo(SDCARD_ZONE_INIT, (TEXT("SDNDISLDR: -NDL_Init\n")));
return (DWORD)pInstance;
}
///////////////////////////////////////////////////////////////////////////////
// NDL_IOControl - the I/O control entry point
// Input: Handle - the context returned from NDL_Open
// IoctlCode - the ioctl code
// pInBuf - the input buffer from the user
// InBufSize - the length of the input buffer
// pOutBuf - the output buffer from the user
// InBufSize - the length of the output buffer
// pBytesReturned - the size of the transfer
// Output:
// Return: TRUE if Ioctl was handled
// Notes: Not used
///////////////////////////////////////////////////////////////////////////////
BOOL NDL_IOControl(DWORD Handle,
DWORD IoctlCode,
PBYTE pInBuf,
DWORD InBufSize,
PBYTE pOutBuf,
DWORD OutBufSize,
PDWORD pBytesReturned)
{
// not used
return FALSE;
}
///////////////////////////////////////////////////////////////////////////////
// NDL_Open - the open entry point
// Input: hDeviceContext - the device context from NDL_Init
// AccessCode - the desired access
// ShareMode - the desired share mode
// Output:
// Return: returns an open context
// Notes: Not used
///////////////////////////////////////////////////////////////////////////////
DWORD NDL_Open(DWORD hDeviceContext,
DWORD AccessCode,
DWORD ShareMode)
{
// just return the instance
return hDeviceContext;
}
///////////////////////////////////////////////////////////////////////////////
// NDL_Close - the close entry point
// Input: hOpenContext - the context returned from NDL_Open
// Output:
// Return: always returns TRUE
// Notes: Not used
///////////////////////////////////////////////////////////////////////////////
BOOL NDL_Close(DWORD hOpenContext)
{
return TRUE;
}
///////////////////////////////////////////////////////////////////////////////
// NDL_PowerDown - the power down entry point for the bus driver
// Input: hDeviceContext - the device context from NDL_Init
// Output:
// Return:
// Notes: performs no actions
///////////////////////////////////////////////////////////////////////////////
void NDL_PowerDown(DWORD hDeviceContext)
{
return;
}
///////////////////////////////////////////////////////////////////////////////
// NDL_PowerUp - the power up entry point for the CE file system wrapper
// Input: hDeviceContext - the device context from NDL_Init
// Output:
// Return:
// Notes: performs no actions
///////////////////////////////////////////////////////////////////////////////
void NDL_PowerUp(DWORD hDeviceContext)
{
return;
}
///////////////////////////////////////////////////////////////////////////////
// NDL_Read - the read entry point
// Input: hOpenContext - the context from NDL_Open
// pBuffer - the user's buffer
// Count - the size of the transfer
// Output:
// Return: zero (not implemented)
// Notes: Not used
///////////////////////////////////////////////////////////////////////////////
DWORD NDL_Read(DWORD hOpenContext,
LPVOID pBuffer,
DWORD Count)
{
return 0;
}
///////////////////////////////////////////////////////////////////////////////
// NDL_Seek - the seek entry point
// Input: hOpenContext - the context from NDL_Open
// Amount - the amount to seek
// Type - the type of seek
// Output:
// Return: zero (not implemented)
// Notes: Not used
///////////////////////////////////////////////////////////////////////////////
DWORD NDL_Seek(DWORD hOpenContext,
long Amount,
DWORD Type)
{
return 0;
}
///////////////////////////////////////////////////////////////////////////////
// NDL_Write - the write entry point
// Input: hOpenContext - the context from NDL_Open
// pBuffer - the user's buffer
// Count - the size of the transfer
// Output:
// Return: zero (not implemented)
// Notes: Not used
///////////////////////////////////////////////////////////////////////////////
DWORD NDL_Write(DWORD hOpenContext,
LPCVOID pBuffer,
DWORD Count)
{
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -