mirror of
https://github.com/rapid7/metasploit-payloads
synced 2025-01-08 14:36:22 +01:00
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-b9f4589650da
This commit is contained in:
parent
95f43bf9c2
commit
b9743b90a6
@ -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 void * HMODULE;
|
||||||
typedef short SHORT;
|
typedef short SHORT;
|
||||||
typedef unsigned short USHORT;
|
typedef unsigned short USHORT;
|
||||||
|
typedef uint64_t QWORD;
|
||||||
|
|
||||||
#ifndef TRUE
|
#ifndef TRUE
|
||||||
#define TRUE (1)
|
#define TRUE (1)
|
||||||
@ -227,6 +228,7 @@ typedef unsigned short USHORT;
|
|||||||
|
|
||||||
int local_error;
|
int local_error;
|
||||||
|
|
||||||
|
#define WSAGetLastError() GetLastError()
|
||||||
#define GetLastError() (local_error != -1 ? local_error : errno)
|
#define GetLastError() (local_error != -1 ? local_error : errno)
|
||||||
#define SetLastError(x) (local_error = (x))
|
#define SetLastError(x) (local_error = (x))
|
||||||
#define __declspec(x)
|
#define __declspec(x)
|
||||||
|
@ -307,6 +307,13 @@ void *__paused_thread(void *req)
|
|||||||
thread = tc->thread;
|
thread = tc->thread;
|
||||||
free(tc);
|
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);
|
return funk(thread);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -352,6 +359,8 @@ THREAD * thread_create( THREADFUNK funk, LPVOID param1, LPVOID param2 )
|
|||||||
// PKS, this is fucky.
|
// PKS, this is fucky.
|
||||||
// we need to use conditionals to implement this.
|
// we need to use conditionals to implement this.
|
||||||
|
|
||||||
|
thread->thread_started = FALSE;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
pthread_t pid;
|
pthread_t pid;
|
||||||
|
|
||||||
@ -407,6 +416,8 @@ BOOL thread_run( THREAD * thread )
|
|||||||
tc->engine_running = TRUE;
|
tc->engine_running = TRUE;
|
||||||
pthread_mutex_unlock(&tc->suspend_mutex);
|
pthread_mutex_unlock(&tc->suspend_mutex);
|
||||||
pthread_cond_signal(&tc->suspend_cond);
|
pthread_cond_signal(&tc->suspend_cond);
|
||||||
|
|
||||||
|
thread->thread_started = TRUE;
|
||||||
#endif
|
#endif
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
@ -417,10 +428,26 @@ BOOL thread_run( THREAD * thread )
|
|||||||
*/
|
*/
|
||||||
BOOL thread_sigterm( THREAD * thread )
|
BOOL thread_sigterm( THREAD * thread )
|
||||||
{
|
{
|
||||||
|
BOOL ret;
|
||||||
|
|
||||||
if( thread == NULL )
|
if( thread == NULL )
|
||||||
return FALSE;
|
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
|
#ifndef _WIN32
|
||||||
void *suspend_thread_data;
|
void *suspend_thread_data;
|
||||||
pthread_t pid;
|
pthread_t pid;
|
||||||
|
int thread_started;
|
||||||
#endif
|
#endif
|
||||||
} THREAD, * LPTHREAD;
|
} THREAD, * LPTHREAD;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user