Beispiel #1
0
/***********************************************************************
 *           WaitEvent  (KERNEL.30)
 */
BOOL16 WINAPI WaitEvent16( HTASK16 hTask )
{
    TDB *pTask;

    if (!hTask) hTask = GetCurrentTask();
    pTask = TASK_GetPtr( hTask );

    if (pTask->flags & TDBF_WIN32)
    {
        FIXME("called for Win32 thread (%04x)!\n", GetCurrentThreadId());
        return TRUE;
    }

    if (pTask->nEvents > 0)
    {
        pTask->nEvents--;
        return FALSE;
    }

    if (pTask->teb == NtCurrentTeb())
    {
        DWORD lockCount;

        NtResetEvent( pTask->hEvent, NULL );
        ReleaseThunkLock( &lockCount );
        SYSLEVEL_CheckNotLevel( 1 );
        WaitForSingleObject( pTask->hEvent, INFINITE );
        RestoreThunkLock( lockCount );
        if (pTask->nEvents > 0) pTask->nEvents--;
    }
    else FIXME("for other task %04x cur=%04x\n",pTask->hSelf,GetCurrentTask());

    return TRUE;
}
Beispiel #2
0
/* get the search path for the current module; helper for OpenFile16 */
static char *get_search_path(void)
{
    UINT len;
    char *ret, *p, module[OFS_MAXPATHNAME];

    module[0] = 0;
    if (GetCurrentTask() && GetModuleFileName16( GetCurrentTask(), module, sizeof(module) ))
    {
        if (!(p = strrchr( module, '\\' ))) p = module;
        *p = 0;
    }

    len = (2 +                                              /* search order: first current dir */
           GetSystemDirectory16( NULL, 0 ) + 1 +            /* then system dir */
           GetWindowsDirectoryA( NULL, 0 ) + 1 +            /* then windows dir */
           strlen( module ) + 1 +                           /* then module path */
           GetEnvironmentVariableA( "PATH", NULL, 0 ) + 1); /* then look in PATH */
    if (!(ret = HeapAlloc( GetProcessHeap(), 0, len ))) return NULL;
    strcpy( ret, ".;" );
    p = ret + 2;
    GetSystemDirectory16( p, ret + len - p );
    p += strlen( p );
    *p++ = ';';
    GetWindowsDirectoryA( p, ret + len - p );
    p += strlen( p );
    *p++ = ';';
    if (module[0])
    {
        strcpy( p, module );
        p += strlen( p );
        *p++ = ';';
    }
    GetEnvironmentVariableA( "PATH", p, ret + len - p );
    return ret;
}
Beispiel #3
0
/*
 * NotifyHandler - call back routine for notifications
 */
BOOL __export FAR PASCAL NotifyHandler( WORD id, DWORD data )
{
    notify      *ptr;

    if( id == NFY_TASKIN || id == NFY_TASKOUT ) {
        if( GetCurrentTask() == ourTask ) {
            if( id == NFY_TASKIN ) {
                UnPauseSampler();
            } else {
                PauseSampler();
            }
        }
        return( FALSE );
    }
    PauseSampler();

    ptr = getNotifyData( data );

    switch( id ) {
    case NFY_STARTDLL:
        _fmemcpy( &ptr->startdll, (LPVOID) data, sizeof( NFYSTARTDLL ) );
        MyModuleFindHandle( &ptr->me, ptr->startdll.hModule );
        HandleLibLoad( SAMP_CODE_LOAD, ptr->startdll.hModule );
        break;
    case NFY_STARTTASK:
        if( ourTask == NULL ) { // handle spawned tasks
            ourTask = GetCurrentTask();
            MyTaskFindHandle( &ptr->te, ptr->task );
            MyModuleFindHandle( &ptr->me, ptr->te.hModule );
            HandleLibLoad( SAMP_MAIN_LOAD, ptr->te.hModule );
            StartSampler();
        } else {
            MyTaskFindHandle( &ptr->te, ptr->task );
            MyModuleFindHandle( &ptr->me, ptr->te.hModule );
            HandleLibLoad( SAMP_CODE_LOAD, ptr->te.hModule );
        }
        break;
    case NFY_EXITTASK:
        if( GetCurrentTask() == ourTask ) { // handle spawned tasks
            QuitSampler( &TotalTime );
            SharedMemory->TaskEnded = TRUE;
        }
        break;
    }
    UnPauseSampler();
    return( FALSE );

} /* NotifyHandler */
Beispiel #4
0
static void MZ_Launch( LPCSTR cmdtail, int length )
{
  TDB *pTask = GlobalLock16( GetCurrentTask() );
  BYTE *psp_start = PTR_REAL_TO_LIN( DOSVM_psp, 0 );
  DWORD rv;
  SYSLEVEL *lock;

  MZ_FillPSP(psp_start, cmdtail, length);
  pTask->flags |= TDBF_WINOLDAP;

  /* DTA is set to PSP:0080h when a program is started. */
  pTask->dta = MAKESEGPTR( DOSVM_psp, 0x80 );

  GetpWin16Lock( &lock );
  _LeaveSysLevel( lock );

  ResumeThread(dosvm_thread);
  rv = DOSVM_Loop(dosvm_thread);

  CloseHandle(dosvm_thread);
  dosvm_thread = 0; dosvm_tid = 0;
  CloseHandle(loop_thread);
  loop_thread = 0; loop_tid = 0;

  VGA_Clean();
  ExitProcess(rv);
}
void TAppDictionary::Add(PTApplication pApplication)
{
    HANDLE hTask = GetCurrentTask();
    TAppDictionaryEntry *pFreeEntry = NULL;  // no free entry yet

    // First see if table already.  If so, replace entry

    for (TAppDictionaryEntry * pEntry = Table; pEntry < &Table[NumEntries];
         pEntry++)
    {
        if (pEntry->hTask == hTask) // already in table?
        {
            pEntry->pApplication = pApplication;
            return;
        }
        else                    // see if entry is free
        {
            if (!pFreeEntry && pEntry->hTask == 0)  // remember this entry
                pFreeEntry = pEntry;
        }
    }

    // Not in table.  See if we encountered a free entry in table.  If
    // so, use it.  Otherwise grow table.

    if ((pEntry = (pFreeEntry ? pFreeEntry : GrowTable())) != 0)
    {
        pEntry->hTask = hTask;
        pEntry->pApplication = pApplication;
        return;
    }
}
Beispiel #6
0
/***********************************************************************
 *		NotifyRegister (TOOLHELP.73)
 */
BOOL16 WINAPI NotifyRegister16( HTASK16 htask, FARPROC16 lpfnCallback,
                              WORD wFlags )
{
    int	i;

    FIXME("(%x,%x,%x), semi-stub.\n",
                      htask, (DWORD)lpfnCallback, wFlags );
    if (!htask) htask = GetCurrentTask();
    for (i=0;i<nrofnotifys;i++)
        if (notifys[i].htask==htask)
            break;
    if (i==nrofnotifys) {
        if (notifys==NULL)
            notifys=HeapAlloc( GetProcessHeap(), 0,
                                               sizeof(struct notify) );
        else
            notifys=HeapReAlloc( GetProcessHeap(), 0, notifys,
                                        sizeof(struct notify)*(nrofnotifys+1));
        if (!notifys) return FALSE;
        nrofnotifys++;
    }
    notifys[i].htask=htask;
    notifys[i].lpfnCallback=lpfnCallback;
    notifys[i].wFlags=wFlags;
    return TRUE;
}
void CRUTopologicalDGIterator::Next()
{
	RUASSERT(FALSE == allTasksLinkMap_.IsEmpty());

	CRUTask *pTask = GetCurrentTask();
	if (NULL == pTask)
	{
		return; // all the tasks have been already traversed
	}

	// The tasks that need to be traversed after me
	CRUTaskList &refTaskList = 
		(DIRECT == dir_) ? 
			pTask->GetTasksThatDependOnMe() :
			pTask->GetTasksThatIDependOn();

	// For all of these tasks, decrecase the reference count
	// Update the "ready" list, if any of the tasks have become ready.
	UpdateIterator(refTaskList);

	// Select a new current task
	if (TRUE == readyTasksList_.IsEmpty())
	{
		SetCurrentTask(NULL); // The last task has just been traversed
	}
	else
	{
		// Retrieve a new task from the "ready" list
		SetCurrentTask(readyTasksList_.RemoveHead());
	}
}
Beispiel #8
0
/***********************************************************************
 *           TerminateApp   (TOOLHELP.77)
 *
 * See "Undocumented Windows".
 */
void WINAPI TerminateApp16(HTASK16 hTask, WORD wFlags)
{
    if (hTask && hTask != GetCurrentTask())
    {
        FIXME("cannot terminate task %x\n", hTask);
        return;
    }

    if (wFlags & NO_UAE_BOX)
    {
        UINT16 old_mode;
        old_mode = SetErrorMode16(0);
        SetErrorMode16(old_mode|SEM_NOGPFAULTERRORBOX);
    }
    FatalAppExit16( 0, NULL );

    /* hmm, we're still alive ?? */

    /* check undocumented flag */
    if (!(wFlags & 0x8000))
        TASK_CallTaskSignalProc( USIG16_TERMINATION, hTask );

    /* UndocWin says to call int 0x21/0x4c exit=0xff here,
       but let's just call ExitThread */
    ExitThread(0xff);
}
Beispiel #9
0
void qPBReaderPlatform::ReaderApplicationStarted(const QString & isBookFile)
{
   TRSCOPE(pb, "qPBReaderPlatform::ReaderApplicationStarted");
#ifdef Q_OS_POCKETBOOK

   TRACE << "Declaring " << ENC(isBookFile) << endl;

   // set application icon
   // taskmgr looks for app_%s_icon.bmp file in theme, %s being the
   // task name. Since I have not found another way to provide an icon at
   // runtime, setting task name to "reader" does the job.

   int task = ::GetCurrentTask();
   taskinfo * pTask = ::GetTaskInfo(GetCurrentTask());

   if (pTask)
   {
      int rc = ::SetTaskParameters(task, "reader", 0, 0, pTask->flags);
      TRACE << "SetTaskParameters " << VAR(rc) << endl;
   }

   // switch to reading mode, seems to change panel appearance

   SetReadingMode(true);

   // and register book as read by this program

   ::BookReady(isBookFile.toUtf8().data());
#else

   Q_UNUSED(isBookFile);
#endif
}
Beispiel #10
0
void WINAPI
PostQuitMessage(int nExitCode)
{
    APISTR((LF_APICALL,"PostQuitMessage(int %x)\n", nExitCode));
    (void) AddAppMsgQueue(GetCurrentTask(),0,0,WM_QUIT,nExitCode,0);
    APISTR((LF_APIRET,"PostQuitMessage: returns void\n"));
}
Beispiel #11
0
void
IT_GLOBALALLOC (ENV *envp,LONGPROC f)	/* GlobalAlloc */
{
	UINT uSel,flags;
	DWORD dwSize;
	DWORD dwMemSize;
	HGLOBAL hGlobal;

	dwSize = GETDWORD(SP+4);
	flags = GETWORD(SP+8);
	dwMemSize=dwSize;
	dwSize = max(32,(dwSize + 31) & 0xffffffe0);

	uSel = TWIN_AllocSelector(dwSize,flags);

	if (uSel) {
	    hGlobal = GetSelectorHandle(uSel);
	    CreateDataInstance((HINSTANCE)hGlobal,(HMODULE)0,
			GetCurrentTask());

	    if (flags & GMEM_MOVEABLE) {
		GlobalUnlock(hGlobal);
		uSel &= 0xfffe;
	    }
	}
	envp->reg.sp += UINT_86 + DWORD_86 + RET_86;
	envp->reg.ax = LOWORD(uSel);
	envp->reg.dx = 0;
}
Beispiel #12
0
void GUIHookF1( void )
{
    if( F1Hooked == 0 ) {
        F1ProcInst = _wpi_makeprocinstance( (WPI_PROC)F1Proc, GUIMainHInst );
#ifndef __OS2_PM__
        // we use a hook to trap F1 in dialogs that were not
        // created using this instance yet on our behalf. IE COMMDLG stuff

        // we cant use a system wide hook because they only can be
        // used in DLL's
        #if defined(__NT__)
            F1HookHandle = SetWindowsHookEx( WH_MSGFILTER,
                                             (HOOKPROC)F1ProcInst,
                                             GUIMainHInst,
                                             (DWORD)GetCurrentThreadId() );
        #else
            F1HookHandle = SetWindowsHookEx( WH_MSGFILTER, 
                                             (HOOKPROC)F1ProcInst,
                                             GUIMainHInst,
                                             GetCurrentTask() );
        #endif
#else
        // in OS/2, it has to be an app. specific input filter (OS/2 has
        // bad problems, occassionally, with system input hooks)
        WinSetHook( GUIMainHInst.hab, HMQ_CURRENT, HK_INPUT, (PFN) F1ProcInst,
                    GUIMainHInst.mod_handle );
#endif
    }
    F1Hooked++;
}
Beispiel #13
0
/***********************************************************************
 *           SetCurrentDirectory   (KERNEL.412)
 */
BOOL16 WINAPI SetCurrentDirectory16( LPCSTR dir )
{
    char fulldir[MAX_PATH];

    if (!GetFullPathNameA( dir, MAX_PATH, fulldir, NULL )) return FALSE;

    if (!SetCurrentDirectoryA( dir )) return FALSE;

    if (fulldir[0] && fulldir[1] == ':')
    {
        TDB *pTask = GlobalLock16( GetCurrentTask() );
        char env_var[4] = "=A:";

        env_var[1] = fulldir[0];
        SetEnvironmentVariableA( env_var, fulldir );

        /* update the directory in the TDB */
        if (pTask)
        {
            pTask->curdrive = 0x80 | (fulldir[0] - 'A');
            GetShortPathNameA( fulldir + 2, pTask->curdir, sizeof(pTask->curdir) );
        }
    }
    return TRUE;
}
Beispiel #14
0
static DWORD MZ_Launch( LPCSTR cmdtail, int length )
{
  TDB *pTask = GlobalLock16( GetCurrentTask() );
  BYTE *psp_start = PTR_REAL_TO_LIN( DOSVM_psp, 0 );
  DWORD rv;
  SYSLEVEL *lock;
  MSG msg;

  MZ_FillPSP(psp_start, cmdtail, length);
  pTask->flags |= TDBF_WINOLDAP;

  /* DTA is set to PSP:0080h when a program is started. */
  pTask->dta = MAKESEGPTR( DOSVM_psp, 0x80 );

  GetpWin16Lock( &lock );
  _LeaveSysLevel( lock );

  /* force the message queue to be created */
  PeekMessageW(&msg, NULL, WM_USER, WM_USER, PM_NOREMOVE);

  ResumeThread(dosvm_thread);
  rv = DOSVM_Loop(dosvm_thread);

  CloseHandle(dosvm_thread);
  dosvm_thread = 0; dosvm_tid = 0;
  CloseHandle(loop_thread);
  loop_thread = 0; loop_tid = 0;
  if (rv) return rv;

  VGA_Clean();
  ExitProcess(0);
}
Beispiel #15
0
/***********************************************************************
 *           LookupETask (COMPOBJ.94)
 */
HRESULT WINAPI LookupETask16(HTASK16 *hTask,LPVOID p) {
	FIXME("(%p,%p),stub!\n",hTask,p);
	if ((*hTask = GetCurrentTask()) == hETask) {
		memcpy(p, Table_ETask, sizeof(Table_ETask));
	}
	return 0;
}
void CRYPTO_THREADID_current(CRYPTO_THREADID *id)
	{
	if (threadid_callback)
		{
		threadid_callback(id);
		return;
		}
#ifndef OPENSSL_NO_DEPRECATED
	/* If the deprecated callback was set, fall back to that */
	if (id_callback)
		{
		CRYPTO_THREADID_set_numeric(id, id_callback());
		return;
		}
#endif
	/* Else pick a backup */
#ifdef OPENSSL_SYS_WIN16
	CRYPTO_THREADID_set_numeric(id, (unsigned long)GetCurrentTask());
#elif defined(OPENSSL_SYS_WIN32)
	CRYPTO_THREADID_set_numeric(id, (unsigned long)GetCurrentThreadId());
#elif defined(OPENSSL_SYS_BEOS)
	CRYPTO_THREADID_set_numeric(id, (unsigned long)find_thread(NULL));
#else
	/* For everything else, default to using the address of 'errno' */
	CRYPTO_THREADID_set_pointer(id, (void*)&errno);
#endif
	}
Beispiel #17
0
void slowPoll( void )
	{
	RANDOM_STATE randomState;
	BYTE buffer[ RANDOM_BUFSIZE ];
	MODULEENTRY moduleEntry;
	GLOBALENTRY globalEntry;
	TASKENTRY taskEntry;
	int count;

	initRandomData( randomState, buffer, RANDOM_BUFSIZE );

	/* Walk the global heap getting information on each entry in it.  This
	   retrieves the objects linear address, size, handle, lock count, owner,
	   object type, and segment type */
	count = 0;
	globalEntry.dwSize = sizeof( GLOBALENTRY );
	if( GlobalFirst( &globalEntry, GLOBAL_ALL ) )
		do
			{
			addRandomData( randomState, &globalEntry, sizeof( GLOBALENTRY ) );
			count++;
			}
		while( count < 70 && GlobalNext( &globalEntry, GLOBAL_ALL ) );

	/* Walk the module list getting information on each entry in it.  This
	   retrieves the module name, handle, reference count, executable path,
	   and next module */
	count = 0;
	moduleEntry.dwSize = sizeof( MODULEENTRY );
	if( ModuleFirst( &moduleEntry ) )
		do
			{
			addRandomData( randomState, &moduleEntry, sizeof( MODULEENTRY ) );
			count++;
			}
		while( count < 20 && ModuleNext( &moduleEntry ) );

	/* Walk the task list getting information on each entry in it.  This
	   retrieves the task handle, parent task handle, instance handle, stack
	   segment and offset, stack size, number of pending events, task queue,
	   and the name of module executing the task.  We also call TaskGetCSIP()
	   for the code segment and offset of each task if it's safe to do so
	   (note that this call can cause odd things to happen in debuggers and
	   runtime code checkers because of the way TaskGetCSIP() is implemented) */
	count = 0;
	taskEntry.dwSize = sizeof( TASKENTRY );
	if( TaskFirst( &taskEntry ) )
		do
			{
			addRandomData( randomState, &taskEntry, sizeof( TASKENTRY ) );
			if( taskEntry.hTask != GetCurrentTask() )
				addRandomValue( randomState,
								TaskGetCSIP( taskEntry.hTask ) );
			count++;
			}
		while( count < 100 && TaskNext( &taskEntry ) );

	/* Flush any remaining data through */
	endRandomData( randomState, 100 );
	}
Beispiel #18
0
HMODULE
GetModuleFromInstance(HINSTANCE hInstance)
{
    MEMORYINFO *lpMemory;
    HANDLE hResult;

    if (hInstance == 0)
    {
        HTASK t;

        t = GetCurrentTask();
        return GetModuleFromInstance((GETTASKINFO(t))->hInst); 
    }

    if (!(lpMemory = GETHANDLEINFO(hInstance))) {
        MODULEINFO *lpModule = GETMODULEINFO(hInstance);
        BOOL bGotModule =  lpModule ? TRUE : FALSE;
	RELEASEMODULEINFO(lpModule);
	if (!bGotModule)
	    return (HMODULE)0;
	else {
	    RELEASEHANDLEINFO(lpMemory);
	    return (HMODULE)hInstance;
	}
    }
    hResult = lpMemory->hModule;
    RELEASEHANDLEINFO(lpMemory);
    return hResult;
}
Beispiel #19
0
ULONG32 CAsyncNetThread::GetSession()
{
#if defined( _WIN32 )
	return (GetCurrentThreadId());
#else
	return ((ULONG32)(LPSTR)GetCurrentTask());
#endif
}
Beispiel #20
0
/***********************************************************************
 *		SetWindowsHook (USER.121)
 */
FARPROC16 WINAPI SetWindowsHook16( INT16 id, HOOKPROC16 proc )
{
    HINSTANCE16 hInst = FarGetOwner16( HIWORD(proc) );

    /* WH_MSGFILTER is the only task-specific hook for SetWindowsHook() */
    HTASK16 hTask = (id == WH_MSGFILTER) ? GetCurrentTask() : 0;

    return (FARPROC16)SetWindowsHookEx16( id, proc, hInst, hTask );
}
Beispiel #21
0
/***********************************************************************
 *           GetAppCompatFlags   (KERNEL.354)
 */
DWORD WINAPI GetAppCompatFlags16( HTASK16 hTask )
{
    TDB *pTask;

    if (!hTask) hTask = GetCurrentTask();
    if (!(pTask=TASK_GetPtr( hTask ))) return 0;
    if (GlobalSize16(hTask) < sizeof(TDB)) return 0;
    return pTask->compat_flags;
}
static int ssl_sock_init(void)
	{
#ifdef WATT32
	extern int _watt_do_exit;
	_watt_do_exit = 0;
	if (sock_init())
		return (0);
#elif defined(OPENSSL_SYS_WINDOWS)
	if (!wsa_init_done)
		{
		int err;
	  
#ifdef SIGINT
		signal(SIGINT,(void (*)(int))ssl_sock_cleanup);
#endif
		wsa_init_done=1;
		memset(&wsa_state,0,sizeof(wsa_state));
		if (WSAStartup(0x0101,&wsa_state)!=0)
			{
			err=WSAGetLastError();
			BIO_printf(bio_err,"unable to start WINSOCK, error code=%d\n",err);
			return(0);
			}

#ifdef OPENSSL_SYS_WIN16
		EnumTaskWindows(GetCurrentTask(),enumproc,0L);
		lpTopWndProc=(FARPROC)GetWindowLong(topWnd,GWL_WNDPROC);
		lpTopHookProc=MakeProcInstance((FARPROC)topHookProc,_hInstance);

		SetWindowLong(topWnd,GWL_WNDPROC,(LONG)lpTopHookProc);
#endif /* OPENSSL_SYS_WIN16 */
		}
#elif defined(OPENSSL_SYS_NETWARE) && !defined(NETWARE_BSDSOCK)
   WORD wVerReq;
   WSADATA wsaData;
   int err;

   if (!wsa_init_done)
      {
   
# ifdef SIGINT
      signal(SIGINT,(void (*)(int))sock_cleanup);
# endif

      wsa_init_done=1;
      wVerReq = MAKEWORD( 2, 0 );
      err = WSAStartup(wVerReq,&wsaData);
      if (err != 0)
         {
         BIO_printf(bio_err,"unable to start WINSOCK2, error code=%d\n",err);
         return(0);
         }
      }
#endif /* OPENSSL_SYS_WINDOWS */
	return(1);
	}
Beispiel #23
0
HWND
CreateRootWindow()
{
    static HWND hRoot;

    HWND32 lpRootWindow;
    HCLASS32 hClassRoot32;
    WNDCLASSEX RootClass;
    int nScreenWidth,nScreenHeight;

    if(hRoot)
	return hRoot;

    /* Check if class has been registered */
    if (!(hClassRoot32 = FindClass((LPSTR)"ROOTWClass",(HANDLE)0))) {
	return (HWND)0;
    }

    /* Get class information */
    InternalGetClassInfoEx(hClassRoot32,&RootClass);

    /* Create handle for the new window */
    if (!(lpRootWindow = CREATEHWIN(hRoot))) {
	RELEASECLASSINFO(hClassRoot32);
	return 0;
    }

    /* Set root window proc */
    lpRootWindow->lpfnWndProc = RootClass.lpfnWndProc;

    /* set style & flags*/
    lpRootWindow->dwStyle = WS_POPUP|WS_VISIBLE;
    lpRootWindow->dwWinFlags = 0L;

    /* set class pointer */
    lpRootWindow->hWindowClass32 = hClassRoot32;

    /* for now root window doesn't have any extra bytes */

    /* Set root window size */
    nScreenWidth = GetSystemMetrics(SM_CXSCREEN);
    nScreenHeight = GetSystemMetrics(SM_CYSCREEN);

    SetRect(&lpRootWindow->rWnd,0,0,nScreenWidth,nScreenHeight);
    lpRootWindow->wWidth = nScreenWidth;
    lpRootWindow->wHeight = nScreenHeight;

    /* Every window must have a task.  It determines the queue to use */
    lpRootWindow->hTask = GetCurrentTask();

    RELEASEWININFO(lpRootWindow);
    RELEASECLASSINFO(hClassRoot32);
    return hRoot;
}
Beispiel #24
0
void    WINAPI 
ReplyMessage(LRESULT lParam)
{
    if (lpSendMessageStack && 
	lpSendMessageStack->hReceivingTask == GetCurrentTask())
    {
	lpSendMessageStack->lResult = lParam;
	lpSendMessageStack->bSendCompleted = TRUE;
	DirectedYield(lpSendMessageStack->hSendingTask);
    }
}
Beispiel #25
0
/***********************************************************************
 *           SetTaskSignalProc   (KERNEL.38)
 */
FARPROC16 WINAPI SetTaskSignalProc( HTASK16 hTask, FARPROC16 proc )
{
    TDB *pTask;
    FARPROC16 oldProc;

    if (!hTask) hTask = GetCurrentTask();
    if (!(pTask = TASK_GetPtr( hTask ))) return NULL;
    oldProc = pTask->userhandler;
    pTask->userhandler = proc;
    return oldProc;
}
Beispiel #26
0
BOOL TWIN_IsSafeToMessageBox()
{
    if (lpSendMessageStack && 
	lpSendMessageStack->hReceivingTask == GetCurrentTask() &&
	!lpSendMessageStack->bSendReceived)
    {
	return FALSE;
    }
    else
	return TRUE;
}
Beispiel #27
0
/* ------------------------------------------------------------------ */
void Skt4uRcd (SOCKET sNewSkt, int nState)
{
int Ark;
  if ( (Ark=FindFirstFreeIdx()) != INVALID_INDEX) 
   {
      HistoSocket[Ark].skt    = sNewSkt;
      HistoSocket[Ark].nState = nState;
      HistoSocket[Ark].nRcv = HistoSocket[Ark].nSnd = 0;
      HistoSocket[Ark].hTask  = GetCurrentTask ();
   } 
} /* RcdSocket */
Beispiel #28
0
int PASCAL WinMain(HINSTANCE hInst,
  HINSTANCE /*hPrevInst*/, LPSTR /*pszCmdLine*/,
  int /*nCmdShow*/)
{
    if (IsWin95())
    {
        if (GetModuleUsage(hInst) <= 1)
            SetModuleExpWinVer(hInst, 0x0400);
        SetTaskExpWinVer(GetCurrentTask(), 0x0400);
    }

    // do something else...

    if (IsWin95())
    {
        if (GetModuleUsage(hInst) <= 1)
            SetModuleExpWinVer(hInst, 0x030a);
        SetTaskExpWinVer(GetCurrentTask(), 0x030a);
    }
    return (0);
}
Beispiel #29
0
BOOL TOOLHELPAPI NotifyUnRegister(
    HANDLE hTask)
{
    NOTIFYSTRUCT *pNotify;
    NOTIFYSTRUCT *pBefore;

    /* Make sure we have notifications installed and that TOOLHELP is OK */
    if (!wLibInstalled || !wNotifyInstalled)
        return FALSE;

    /* NULL hTask means current task */
    if (!hTask)
        hTask = GetCurrentTask();

    /* First try to find the task */
    pBefore = NULL;
    for (pNotify = npNotifyHead ; pNotify ; pNotify = pNotify->pNext)
        if (pNotify->hTask == hTask)
            break;
        else
            pBefore = pNotify;
    if (!pNotify)
        return FALSE;

    /* Unhook the death signal proc only if there is no interrupt handler */
    if (!InterruptIsHooked(hTask))
        SignalUnRegister(hTask);

    /* Check to see if the notification handler is about to use this entry.
     *  If it is, we point it to the next one, if any.
     */
    if (npNotifyNext == pNotify)
        npNotifyNext = pNotify->pNext;

    /* Remove it from the list */
    if (!pBefore)
        npNotifyHead = pNotify->pNext;
    else
        pBefore->pNext = pNotify->pNext;

    /* Free the structure */
    LocalFree((HANDLE)pNotify);

    /* If there are no more handlers, unhook the callback */
    if (!npNotifyHead)
    {
        NotifyUnInit();
        wNotifyInstalled = FALSE;
    }

    return TRUE;
}
Beispiel #30
-1
/***********************************************************************
 *		SetWindowsHookEx (USER.291)
 */
HHOOK WINAPI SetWindowsHookEx16( INT16 id, HOOKPROC16 proc, HINSTANCE16 hInst, HTASK16 hTask )
{
    struct user_thread_info *thread_info = get_user_thread_info();
    struct hook16_queue_info *info;
    HHOOK hook;
    int index = id - WH_MINHOOK;

    if (id < WH_MINHOOK || id > WH_MAXHOOK16) return 0;
    if (!hook_procs[index])
    {
        FIXME( "hook type %d broken in Win16\n", id );
        return 0;
    }
    if (!hTask) FIXME( "System-global hooks (%d) broken in Win16\n", id );
    else if (hTask != GetCurrentTask())
    {
        FIXME( "setting hook (%d) on other task not supported\n", id );
        return 0;
    }

    if (!(info = thread_info->hook16_info))
    {
        if (!(info = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*info) ))) return 0;
        thread_info->hook16_info = info;
    }
    if (info->hook[index])
    {
        FIXME( "Multiple hooks (%d) for the same task not supported yet\n", id );
        return 0;
    }
    if (!(hook = SetWindowsHookExA( id, hook_procs[index], 0, GetCurrentThreadId() ))) return 0;
    info->hook[index] = hook;
    info->proc[index] = proc;
    return hook;
}