Missing file, QWORD compile fix, and thread error handling improvements.
asm/ucontext.h will be used to implement a crash handler in msflinker, which should allow for easier debugging and development of msflinker and extension code. thread.c/h, fixes a bug if you thread_create(), but stop the thread before running it. Compilation fix for WSAGetLastError git-svn-id: file:///home/svn/framework3/trunk@10415 4d416f70-5f16-0410-b530-b9f4589650daunstable
parent
8d45915f8c
commit
3c99897115
23
external/source/meterpreter/source/bionic/libc/kernel/arch-x86/asm/ucontext.h
vendored
Normal file
23
external/source/meterpreter/source/bionic/libc/kernel/arch-x86/asm/ucontext.h
vendored
Normal file
|
@ -0,0 +1,23 @@
|
|||
/****************************************************************************
|
||||
****************************************************************************
|
||||
***
|
||||
*** This header was automatically generated from a Linux kernel header
|
||||
*** of the same name, to make information necessary for userspace to
|
||||
*** call into the kernel available to libc. It contains only constants,
|
||||
*** structures, and macros generated from the original header, and thus,
|
||||
*** contains no copyrightable information.
|
||||
***
|
||||
****************************************************************************
|
||||
****************************************************************************/
|
||||
#ifndef __ASM_X86_UCONTEXT_H
|
||||
#define __ASM_X86_UCONTEXT_H
|
||||
|
||||
struct ucontext {
|
||||
unsigned long uc_flags;
|
||||
struct ucontext *uc_link;
|
||||
stack_t uc_stack;
|
||||
struct sigcontext uc_mcontext;
|
||||
sigset_t uc_sigmask;
|
||||
};
|
||||
|
||||
#endif
|
|
@ -189,6 +189,7 @@ typedef VOID * PVOID;
|
|||
typedef void * HMODULE;
|
||||
typedef short SHORT;
|
||||
typedef unsigned short USHORT;
|
||||
typedef uint64_t QWORD;
|
||||
|
||||
#ifndef TRUE
|
||||
#define TRUE (1)
|
||||
|
@ -227,6 +228,7 @@ typedef unsigned short USHORT;
|
|||
|
||||
int local_error;
|
||||
|
||||
#define WSAGetLastError() GetLastError()
|
||||
#define GetLastError() (local_error != -1 ? local_error : errno)
|
||||
#define SetLastError(x) (local_error = (x))
|
||||
#define __declspec(x)
|
||||
|
|
|
@ -307,6 +307,13 @@ void *__paused_thread(void *req)
|
|||
thread = tc->thread;
|
||||
free(tc);
|
||||
|
||||
if(event_poll(thread->sigterm, 0) == TRUE) {
|
||||
/*
|
||||
* In some cases, we might want to stop a thread before it does anything :/
|
||||
*/
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return funk(thread);
|
||||
}
|
||||
#endif
|
||||
|
@ -352,6 +359,8 @@ THREAD * thread_create( THREADFUNK funk, LPVOID param1, LPVOID param2 )
|
|||
// PKS, this is fucky.
|
||||
// we need to use conditionals to implement this.
|
||||
|
||||
thread->thread_started = FALSE;
|
||||
|
||||
do {
|
||||
pthread_t pid;
|
||||
|
||||
|
@ -407,6 +416,8 @@ BOOL thread_run( THREAD * thread )
|
|||
tc->engine_running = TRUE;
|
||||
pthread_mutex_unlock(&tc->suspend_mutex);
|
||||
pthread_cond_signal(&tc->suspend_cond);
|
||||
|
||||
thread->thread_started = TRUE;
|
||||
#endif
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -417,10 +428,26 @@ BOOL thread_run( THREAD * thread )
|
|||
*/
|
||||
BOOL thread_sigterm( THREAD * thread )
|
||||
{
|
||||
BOOL ret;
|
||||
|
||||
if( thread == NULL )
|
||||
return FALSE;
|
||||
|
||||
return event_signal( thread->sigterm );
|
||||
ret = event_signal( thread->sigterm );
|
||||
|
||||
#ifndef _WIN32
|
||||
/*
|
||||
* If we sig term a thread before it's started execution, we will leak memory / not be
|
||||
* able to join on the thread, etc.
|
||||
*
|
||||
* Therefore, we need to start the thread executing before calling thread_join
|
||||
*/
|
||||
if(thread->thread_started != TRUE) {
|
||||
thread_run(thread);
|
||||
}
|
||||
#endif
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -63,6 +63,7 @@ typedef struct _THREAD
|
|||
#ifndef _WIN32
|
||||
void *suspend_thread_data;
|
||||
pthread_t pid;
|
||||
int thread_started;
|
||||
#endif
|
||||
} THREAD, * LPTHREAD;
|
||||
|
||||
|
|
Loading…
Reference in New Issue