Made GetProcessHeap(), GetCurrentProcessId(), GetCurrentThread() and
GetCurrentProcess() inline.
This commit is contained in:
parent
e8d2aa5e65
commit
114830e8a9
|
@ -15,9 +15,6 @@ struct _NE_MODULE;
|
|||
struct _THREAD_ENTRY;
|
||||
struct _UTINFO;
|
||||
|
||||
/* Current Process pseudo-handle - Returned by GetCurrentProcess*/
|
||||
#define CURRENT_PROCESS_PSEUDOHANDLE ((HANDLE)0x7fffffff)
|
||||
|
||||
/* Win32 process environment database */
|
||||
typedef struct
|
||||
{
|
||||
|
|
|
@ -44,7 +44,7 @@ typedef struct _TEB
|
|||
struct _TEB *self; /* 12- 18 Pointer to this structure */
|
||||
WORD tibflags; /* 1!n 1c Flags (NT: EnvironmentPointer) */
|
||||
WORD mutex_count; /* 1-n 1e Win16 mutex count */
|
||||
DWORD debug_context; /* 1!n 20 Debug context (NT: PVOID UniqueProcess) */
|
||||
void *pid; /* !2- 20 Process id (win95: debug context) */
|
||||
void *tid; /* -2- 24 Thread id */
|
||||
HQUEUE16 queue; /* 1!- 28 Message queue (NT: DWORD ActiveRpcHandle)*/
|
||||
WORD pad1; /* --n 2a */
|
||||
|
@ -113,16 +113,13 @@ typedef struct _TEB
|
|||
#define TEBF_WIN32 0x0001
|
||||
#define TEBF_TRAP 0x0002
|
||||
|
||||
/* The pseudo handle value returned by GetCurrentThread */
|
||||
#define CURRENT_THREAD_PSEUDOHANDLE 0xfffffffe
|
||||
|
||||
/* The per-thread signal stack size */
|
||||
#define SIGNAL_STACK_SIZE 16384
|
||||
|
||||
|
||||
/* scheduler/thread.c */
|
||||
extern TEB *THREAD_CreateInitialThread( struct _PDB *pdb, int server_fd );
|
||||
extern TEB *THREAD_Create( struct _PDB *pdb, void *tid, int fd, DWORD flags,
|
||||
extern TEB *THREAD_Create( struct _PDB *pdb, void *pid, void *tid, int fd, DWORD flags,
|
||||
DWORD stack_size, BOOL alloc_stack16 );
|
||||
extern BOOL THREAD_IsWin16( TEB *thdb );
|
||||
extern TEB *THREAD_IdToTEB( DWORD id );
|
||||
|
|
|
@ -237,6 +237,8 @@ typedef struct
|
|||
#define INVALID_HANDLE_VALUE16 ((HANDLE16) -1)
|
||||
#define INVALID_HANDLE_VALUE ((HANDLE) -1)
|
||||
|
||||
#define TLS_OUT_OF_INDEXES ((DWORD)0xFFFFFFFF)
|
||||
|
||||
/* comm */
|
||||
|
||||
#define CBR_110 0xFF10
|
||||
|
@ -1269,13 +1271,12 @@ UINT WINAPI GetConsoleOutputCP(void);
|
|||
DWORD WINAPI GetConsoleTitleA(LPSTR,DWORD);
|
||||
DWORD WINAPI GetConsoleTitleW(LPWSTR,DWORD);
|
||||
#define GetConsoleTitle WINELIB_NAME_AW(GetConsoleTitle)
|
||||
BOOL WINAPI GetCommMask(HANDLE, LPDWORD);
|
||||
BOOL WINAPI GetCommModemStatus(HANDLE, LPDWORD);
|
||||
HANDLE WINAPI GetCurrentProcess(void);
|
||||
DWORD WINAPI GetCurrentProcessId(void);
|
||||
HANDLE WINAPI GetCurrentThread(void);
|
||||
INT WINAPI GetDateFormatA(LCID,DWORD,LPSYSTEMTIME,LPCSTR,LPSTR,INT);
|
||||
INT WINAPI GetDateFormatW(LCID,DWORD,LPSYSTEMTIME,LPCWSTR,LPWSTR,INT);
|
||||
BOOL WINAPI GetCommMask(HANDLE, LPDWORD);
|
||||
BOOL WINAPI GetCommModemStatus(HANDLE, LPDWORD);
|
||||
HANDLE WINAPI GetCurrentProcess(void);
|
||||
HANDLE WINAPI GetCurrentThread(void);
|
||||
INT WINAPI GetDateFormatA(LCID,DWORD,LPSYSTEMTIME,LPCSTR,LPSTR,INT);
|
||||
INT WINAPI GetDateFormatW(LCID,DWORD,LPSYSTEMTIME,LPCWSTR,LPWSTR,INT);
|
||||
#define GetDateFormat WINELIB_NAME_AW(GetDateFormat)
|
||||
LPSTR WINAPI GetEnvironmentStringsA(void);
|
||||
LPWSTR WINAPI GetEnvironmentStringsW(void);
|
||||
|
@ -1310,7 +1311,6 @@ BOOL WINAPI GetNumberOfEventLogRecords(HANDLE,PDWORD);
|
|||
UINT WINAPI GetOEMCP(void);
|
||||
BOOL WINAPI GetOldestEventLogRecord(HANDLE,PDWORD);
|
||||
DWORD WINAPI GetPriorityClass(HANDLE);
|
||||
HANDLE WINAPI GetProcessHeap(void);
|
||||
DWORD WINAPI GetProcessVersion(DWORD);
|
||||
BOOL WINAPI GetSecurityDescriptorControl(PSECURITY_DESCRIPTOR,PSECURITY_DESCRIPTOR_CONTROL,LPDWORD);
|
||||
BOOL WINAPI GetSecurityDescriptorDacl(PSECURITY_DESCRIPTOR,LPBOOL,PACL *,LPBOOL);
|
||||
|
@ -1816,6 +1816,14 @@ extern inline DWORD WINAPI GetLastError(void)
|
|||
return ret;
|
||||
}
|
||||
|
||||
extern inline DWORD WINAPI GetCurrentProcessId(void);
|
||||
extern inline DWORD WINAPI GetCurrentProcessId(void)
|
||||
{
|
||||
DWORD ret;
|
||||
__asm__ __volatile__( ".byte 0x64\n\tmovl 0x20,%0" : "=r" (ret) );
|
||||
return ret;
|
||||
}
|
||||
|
||||
extern inline DWORD WINAPI GetCurrentThreadId(void);
|
||||
extern inline DWORD WINAPI GetCurrentThreadId(void)
|
||||
{
|
||||
|
@ -1830,9 +1838,19 @@ extern inline void WINAPI SetLastError( DWORD err )
|
|||
__asm__ __volatile__( ".byte 0x64\n\tmovl %0,0x60" : : "r" (err) : "memory" );
|
||||
}
|
||||
|
||||
extern inline HANDLE WINAPI GetProcessHeap(void);
|
||||
extern inline HANDLE WINAPI GetProcessHeap(void)
|
||||
{
|
||||
DWORD *pdb;
|
||||
__asm__ __volatile__( ".byte 0x64\n\tmovl 0x30,%0" : "=r" (pdb) );
|
||||
return pdb[0x18 / sizeof(DWORD)]; /* get dword at offset 0x18 in pdb */
|
||||
}
|
||||
|
||||
#else /* __i386__ && __GNUC__ */
|
||||
DWORD WINAPI GetCurrentProcessId(void);
|
||||
DWORD WINAPI GetCurrentThreadId(void);
|
||||
DWORD WINAPI GetLastError(void);
|
||||
HANDLE WINAPI GetProcessHeap(void);
|
||||
PVOID WINAPI InterlockedCompareExchange(PVOID*,PVOID,PVOID);
|
||||
LONG WINAPI InterlockedDecrement(PLONG);
|
||||
LONG WINAPI InterlockedExchange(PLONG,LONG);
|
||||
|
@ -1841,6 +1859,10 @@ LONG WINAPI InterlockedIncrement(PLONG);
|
|||
VOID WINAPI SetLastError(DWORD);
|
||||
#endif /* __i386__ && __GNUC__ */
|
||||
|
||||
#ifdef __WINE__
|
||||
#define GetCurrentProcess() ((HANDLE)0xffffffff)
|
||||
#define GetCurrentThread() ((HANDLE)0xfffffffe)
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -499,6 +499,7 @@ int CLIENT_InitThread(void)
|
|||
if (teb->buffer == (void*)-1) server_perror( "mmap" );
|
||||
first_req = teb->buffer;
|
||||
teb->process->server_pid = first_req->pid;
|
||||
teb->pid = first_req->pid;
|
||||
teb->tid = first_req->tid;
|
||||
if (first_req->version != SERVER_PROTOCOL_VERSION)
|
||||
server_protocol_error( "version mismatch %d/%d.\n"
|
||||
|
|
|
@ -277,6 +277,7 @@ static PDB *PROCESS_CreatePDB( PDB *parent, BOOL inherit )
|
|||
|
||||
if (!pdb) return NULL;
|
||||
pdb->exit_code = STILL_ACTIVE;
|
||||
pdb->heap = GetProcessHeap();
|
||||
pdb->threads = 1;
|
||||
pdb->running_threads = 1;
|
||||
pdb->ring0_threads = 1;
|
||||
|
@ -364,8 +365,6 @@ void PROCESS_Start(void)
|
|||
PDB *pdb = PROCESS_Current();
|
||||
NE_MODULE *pModule = NE_GetPtr( pdb->module );
|
||||
LPCSTR filename = ((OFSTRUCT *)((char*)(pModule) + (pModule)->fileinfo))->szPathName;
|
||||
IMAGE_OPTIONAL_HEADER *header = !pModule->module32? NULL :
|
||||
&PE_HEADER(pModule->module32)->OptionalHeader;
|
||||
|
||||
/* Get process type */
|
||||
enum { PROC_DOS, PROC_WIN16, PROC_WIN32 } type;
|
||||
|
@ -379,15 +378,6 @@ void PROCESS_Start(void)
|
|||
/* Initialize the critical section */
|
||||
InitializeCriticalSection( &pdb->crit_section );
|
||||
|
||||
/* Create the heap */
|
||||
if (!(pdb->heap = GetProcessHeap()))
|
||||
{
|
||||
if (!(pdb->heap = HeapCreate( HEAP_GROWABLE,
|
||||
header? header->SizeOfHeapReserve : 0x10000,
|
||||
header? header->SizeOfHeapCommit : 0 )))
|
||||
goto error;
|
||||
}
|
||||
|
||||
/* Create the environment db */
|
||||
if (!PROCESS_CreateEnvDB()) goto error;
|
||||
|
||||
|
@ -567,9 +557,8 @@ PDB *PROCESS_Create( NE_MODULE *pModule, HFILE hFile, LPCSTR cmd_line, LPCSTR en
|
|||
|
||||
/* Create the main thread */
|
||||
|
||||
if (!(teb = THREAD_Create( pdb, req->tid, fd, flags & CREATE_SUSPENDED,
|
||||
if (!(teb = THREAD_Create( pdb, req->pid, req->tid, fd, flags & CREATE_SUSPENDED,
|
||||
size, alloc_stack16 ))) goto error;
|
||||
teb->tid = (void *)info->dwThreadId;
|
||||
teb->startup = PROCESS_Start;
|
||||
fd = -1; /* don't close it */
|
||||
|
||||
|
@ -783,15 +772,6 @@ void WINAPI SetProcessDword( DWORD dwProcessID, INT offset, DWORD value )
|
|||
}
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
* GetCurrentProcess (KERNEL32.198)
|
||||
*/
|
||||
HANDLE WINAPI GetCurrentProcess(void)
|
||||
{
|
||||
return CURRENT_PROCESS_PSEUDOHANDLE;
|
||||
}
|
||||
|
||||
|
||||
/*********************************************************************
|
||||
* OpenProcess (KERNEL32.543)
|
||||
*/
|
||||
|
@ -819,15 +799,6 @@ DWORD WINAPI MapProcessHandle( HANDLE handle )
|
|||
return ret;
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
* GetCurrentProcessId (KERNEL32.199)
|
||||
*/
|
||||
DWORD WINAPI GetCurrentProcessId(void)
|
||||
{
|
||||
return (DWORD)PROCESS_Current()->server_pid;
|
||||
}
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
* GetThreadLocale (KERNEL32.295)
|
||||
*/
|
||||
|
@ -1211,3 +1182,12 @@ UINT WINAPI SetErrorMode( UINT mode )
|
|||
PROCESS_Current()->error_mode = mode;
|
||||
return old;
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
* GetCurrentProcess (KERNEL32.198)
|
||||
*/
|
||||
#undef GetCurrentProcess
|
||||
HANDLE WINAPI GetCurrentProcess(void)
|
||||
{
|
||||
return 0xffffffff;
|
||||
}
|
||||
|
|
|
@ -195,7 +195,7 @@ TEB *THREAD_CreateInitialThread( PDB *pdb, int server_fd )
|
|||
* allocate in this area and don't support a granularity of 4kb
|
||||
* yet we leave it to VirtualAlloc to choose an address.
|
||||
*/
|
||||
TEB *THREAD_Create( PDB *pdb, void *tid, int fd, DWORD flags,
|
||||
TEB *THREAD_Create( PDB *pdb, void *pid, void *tid, int fd, DWORD flags,
|
||||
DWORD stack_size, BOOL alloc_stack16 )
|
||||
{
|
||||
TEB *teb = VirtualAlloc(0, 0x1000, MEM_COMMIT, PAGE_EXECUTE_READWRITE);
|
||||
|
@ -208,6 +208,7 @@ TEB *THREAD_Create( PDB *pdb, void *tid, int fd, DWORD flags,
|
|||
teb->process = pdb;
|
||||
teb->exit_code = STILL_ACTIVE;
|
||||
teb->socket = fd;
|
||||
teb->pid = pid;
|
||||
teb->tid = tid;
|
||||
fcntl( fd, F_SETFD, 1 ); /* set close on exec flag */
|
||||
|
||||
|
@ -270,7 +271,8 @@ HANDLE WINAPI CreateThread( SECURITY_ATTRIBUTES *sa, DWORD stack,
|
|||
if (server_call_fd( REQ_NEW_THREAD, -1, &socket )) return 0;
|
||||
handle = req->handle;
|
||||
|
||||
if (!(teb = THREAD_Create( PROCESS_Current(), req->tid, socket, flags, stack, TRUE )))
|
||||
if (!(teb = THREAD_Create( PROCESS_Current(), (void *)GetCurrentProcessId(),
|
||||
req->tid, socket, flags, stack, TRUE )))
|
||||
{
|
||||
close( socket );
|
||||
return 0;
|
||||
|
@ -342,18 +344,6 @@ void WINAPI ExitThread( DWORD code ) /* [in] Exit code for this thread */
|
|||
}
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
* GetCurrentThread [KERNEL32.200] Gets pseudohandle for current thread
|
||||
*
|
||||
* RETURNS
|
||||
* Pseudohandle for the current thread
|
||||
*/
|
||||
HANDLE WINAPI GetCurrentThread(void)
|
||||
{
|
||||
return CURRENT_THREAD_PSEUDOHANDLE;
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
* SetLastErrorEx [USER32.485] Sets the last-error code.
|
||||
*
|
||||
|
@ -824,6 +814,19 @@ BOOL WINAPI SetThreadLocale(
|
|||
}
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
* GetCurrentThread [KERNEL32.200] Gets pseudohandle for current thread
|
||||
*
|
||||
* RETURNS
|
||||
* Pseudohandle for the current thread
|
||||
*/
|
||||
#undef GetCurrentThread
|
||||
HANDLE WINAPI GetCurrentThread(void)
|
||||
{
|
||||
return 0xfffffffe;
|
||||
}
|
||||
|
||||
|
||||
#ifdef __i386__
|
||||
|
||||
/* void WINAPI SetLastError( DWORD error ); */
|
||||
|
@ -836,6 +839,9 @@ __ASM_GLOBAL_FUNC( SetLastError,
|
|||
/* DWORD WINAPI GetLastError(void); */
|
||||
__ASM_GLOBAL_FUNC( GetLastError, ".byte 0x64\n\tmovl 0x60,%eax\n\tret" );
|
||||
|
||||
/* DWORD WINAPI GetCurrentProcessId(void) */
|
||||
__ASM_GLOBAL_FUNC( GetCurrentProcessId, ".byte 0x64\n\tmovl 0x20,%eax\n\tret" );
|
||||
|
||||
/* DWORD WINAPI GetCurrentThreadId(void) */
|
||||
__ASM_GLOBAL_FUNC( GetCurrentThreadId, ".byte 0x64\n\tmovl 0x24,%eax\n\tret" );
|
||||
|
||||
|
@ -857,6 +863,14 @@ DWORD WINAPI GetLastError(void)
|
|||
return NtCurrentTeb()->last_error;
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
* GetCurrentProcessId [KERNEL32.199] Returns process identifier.
|
||||
*/
|
||||
DWORD WINAPI GetCurrentProcessId(void)
|
||||
{
|
||||
return (DWORD)NtCurrentTeb()->pid;
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
* GetCurrentThreadId [KERNEL32.201] Returns thread identifier.
|
||||
*/
|
||||
|
|
|
@ -1403,7 +1403,7 @@ DWORD WINAPI GetWindowThreadProcessId( HWND hwnd, LPDWORD process )
|
|||
|
||||
if (!queue) return 0;
|
||||
|
||||
if ( process ) *process = (DWORD)queue->teb->process->server_pid;
|
||||
if ( process ) *process = (DWORD)queue->teb->pid;
|
||||
retvalue = (DWORD)queue->teb->tid;
|
||||
|
||||
QUEUE_Unlock( queue );
|
||||
|
|
Loading…
Reference in New Issue