Ejemplo n.º 1
0
/**
  Ax88772 driver unload routine.

  @param [in] ImageHandle       Handle for the image.

  @retval EFI_SUCCESS           Image may be unloaded

**/
EFI_STATUS
EFIAPI
DriverUnload (
  IN EFI_HANDLE ImageHandle
  )
{
  UINTN BufferSize;
  UINTN Index;
  UINTN Max;
  EFI_HANDLE * pHandle;
  EFI_STATUS Status;

  //
  //  Determine which devices are using this driver
  //
  BufferSize = 0;
  pHandle = NULL;
  Status = gBS->LocateHandle (
                  ByProtocol,
                  &gEfiCallerIdGuid,
                  NULL,
                  &BufferSize,
                  NULL );
  if ( EFI_BUFFER_TOO_SMALL == Status ) {
    for ( ; ; ) {
      //
      //  One or more block IO devices are present
      //
      Status = gBS->AllocatePool (
                      EfiRuntimeServicesData,
                      BufferSize,
                      (VOID **) &pHandle
                      );
      if ( EFI_ERROR ( Status )) {
        DEBUG (( DEBUG_ERROR | DEBUG_POOL | DEBUG_INIT | DEBUG_INFO,
                  "Insufficient memory, failed handle buffer allocation\r\n" ));
        break;
      }

      //
      //  Locate the block IO devices
      //
      Status = gBS->LocateHandle (
                      ByProtocol,
                      &gEfiCallerIdGuid,
                      NULL,
                      &BufferSize,
                      pHandle );
      if ( EFI_ERROR ( Status )) {
        //
        //  Error getting handles
        //
        DEBUG (( DEBUG_ERROR | DEBUG_INIT | DEBUG_INFO,
                "Failure getting Telnet handles\r\n" ));
        break;
      }

      //
      //  Remove any use of the driver
      //
      Max = BufferSize / sizeof ( pHandle[ 0 ]);
      for ( Index = 0; Max > Index; Index++ ) {
        Status = DriverStop ( &gDriverBinding,
                              pHandle[ Index ],
                              0,
                              NULL );
        if ( EFI_ERROR ( Status )) {
          DEBUG (( DEBUG_WARN | DEBUG_INIT | DEBUG_INFO,
                    "WARNING - Failed to shutdown the driver on handle %08x\r\n", pHandle[ Index ]));
          break;
        }
      }
      break;
    }
  }
  else {
    if ( EFI_NOT_FOUND == Status ) {
      //
      //  No devices were found
      //
      Status = EFI_SUCCESS;
    }
  }

  //
  //  Free the handle array
  //
  if ( NULL != pHandle ) {
    gBS->FreePool ( pHandle );
  }

  //
  //  Remove the protocols installed by the EntryPoint routine.
  //
  if ( !EFI_ERROR ( Status )) {
    gBS->UninstallMultipleProtocolInterfaces (
            ImageHandle,
            &gEfiDriverBindingProtocolGuid,
            &gDriverBinding,
            &gEfiComponentNameProtocolGuid,
            &gComponentName,
            &gEfiComponentName2ProtocolGuid,
            &gComponentName2,
            NULL
            );
    DEBUG (( DEBUG_POOL | DEBUG_INIT | DEBUG_INFO,
            "Removed:   gEfiComponentName2ProtocolGuid from 0x%08x\r\n",
            ImageHandle ));
    DEBUG (( DEBUG_POOL | DEBUG_INIT | DEBUG_INFO,
              "Removed:   gEfiComponentNameProtocolGuid from 0x%08x\r\n",
              ImageHandle ));
    DEBUG (( DEBUG_POOL | DEBUG_INIT | DEBUG_INFO,
              "Removed:   gEfiDriverBindingProtocolGuid from 0x%08x\r\n",
              ImageHandle ));
  }

  //
  //  Return the unload status
  //
  return Status;
}
Ejemplo n.º 2
0
BOOL CALLBACK DdkHookAppDlgProc(HWND hDlg,UINT uMsg,WPARAM wParam,LPARAM lParam) {
	int n=0;
	LVCOLUMN COL;
	BOOL RetBOOL;
	switch(uMsg) {
		case WM_INITDIALOG:
			hDdkHookAppDlg=hDlg;
			hListPS=GetDlgItem(hDlg,IDC_LIST_PS);
			hEditPS=GetDlgItem(hDlg,IDC_EDIT_PS);
			hEditState=GetDlgItem(hDlg,IDC_EDIT_STATE);
			COL.mask=LVCF_FMT|LVCF_WIDTH|LVCF_TEXT|LVCF_SUBITEM;
			COL.fmt=LVCFMT_LEFT; //왼쪽 정렬
			COL.cx=150;
			COL.pszText="ProcName"; //항목의 이름
			COL.iSubItem=0; //항목의 번호
			SendMessage(hListPS, LVM_INSERTCOLUMN,COL.iSubItem,(LPARAM)&COL);
			COL.cx=50;
			COL.pszText="ProcID"; //항목의 이름
			COL.iSubItem=1; //항목의 번호
			SendMessage(hListPS, LVM_INSERTCOLUMN,COL.iSubItem,(LPARAM)&COL);
			PSList();
			return TRUE;
		case WM_NOTIFY:
			switch(LOWORD(wParam)) {
				case IDC_LIST_PS:
					if(((LPNMHDR)lParam)->code==NM_DBLCLK) {
						char Text1[32]={0},Text2[32]={0},Temp[128]={0};
						ULONG ret;
						int iSlected=ListView_GetNextItem(hListPS,-1,LVNI_FOCUSED);
						if(iSlected==-1) {
							MessageBox(hDlg,"No Items in ListView","Error",MB_OK|MB_ICONINFORMATION);
							break;
						}
						ListView_GetItemText(hListPS,iSlected,0,Text1,32);
						strcpy_s(Temp,Text1);
						ListView_GetItemText(hListPS,iSlected,1,Text1,32);
						sprintf_s(Text2,"(%s): %s",Text1,"프로세스강제종료막음");
						strcat_s(Temp,Text2);
						SetWindowText(hEditPS,Temp);
						//-----------------------------
						handle=CreateFile(FullDeviceName,GENERIC_READ|GENERIC_WRITE,0,0,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,0);
						if(handle==(HANDLE)-1) {
							SetWindowText(hEditPS,"");
							MessageBox(hDlg,"CreateFile Error","Error",MB_OK);
							break;
						}
						WriteFile(handle,Text1,(DWORD)strlen(Text1),&ret,NULL);
						CloseHandle(handle);
					}
					break;
			}
			return TRUE;
		case WM_COMMAND:
			switch(LOWORD(wParam)) {
				case IDC_BT_REVIEW:
					ListView_DeleteAllItems(hListPS);
					PSList();
					break;
				case IDC_BT_DRINST:
					RetBOOL=DriverInstall(DriverName,DriverExe);
					if(!RetBOOL) SetWindowText(hEditState,"Cannot install");
					else {
						bInstall=TRUE;
						RetBOOL=DriverStart(DriverName);
						if(!RetBOOL) SetWindowText(hEditState,"Cannot start");
						else {
							bStart=TRUE;
							SetWindowText(hEditState,"Started");
						}
					}
					break;
				case IDC_BT_DRREM:
					if(bInstall) {
						RetBOOL=DriverStop(DriverName);
						if(!RetBOOL) SetWindowText(hEditState,"Cannot stop");
						else {
							bStart=FALSE;
							RetBOOL=DriverRemove(DriverName,DriverExe);
							if(!RetBOOL) SetWindowText(hEditState,"Cannot remove");
							else {
								bInstall=FALSE;
								SetWindowText(hEditState,"Removed");
							}
						}
					}
					else SetWindowText(hEditState,"Cannot remove");
					break;
			}
			return TRUE;
		case WM_CLOSE:
			if(bStart) DriverStop(DriverName);
			if(bInstall) DriverRemove(DriverName,DriverExe);
			EndDialog(hDlg,0);
			return TRUE;
	}
	return FALSE;
}