-
-
Notifications
You must be signed in to change notification settings - Fork 251
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cloak: Add with_lock_held() and is_locked()
- Loading branch information
Showing
3 changed files
with
30 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
/* | ||
* Copyright (C) 2017-2023 Ole André Vadla Ravnås <[email protected]> | ||
* Copyright (C) 2024 Francesco Tamagni <[email protected]> | ||
* | ||
* Licence: wxWindows Library Licence, Version 3.1 | ||
*/ | ||
|
@@ -735,3 +736,22 @@ gum_fd_compare (gconstpointer element_a, | |
return -1; | ||
return 1; | ||
} | ||
|
||
void | ||
gum_cloak_with_lock_held (GumCloakLockedFunc func, | ||
gpointer user_data) | ||
{ | ||
gum_spinlock_acquire (&cloak_lock); | ||
func (user_data); | ||
gum_spinlock_release (&cloak_lock); | ||
} | ||
|
||
gboolean | ||
gum_cloak_is_locked (void) | ||
{ | ||
if (!gum_spinlock_try_acquire (&cloak_lock)) | ||
return TRUE; | ||
|
||
gum_spinlock_release (&cloak_lock); | ||
return FALSE; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
/* | ||
* Copyright (C) 2017-2023 Ole André Vadla Ravnås <[email protected]> | ||
* Copyright (C) 2024 Francesco Tamagni <[email protected]> | ||
* | ||
* Licence: wxWindows Library Licence, Version 3.1 | ||
*/ | ||
|
@@ -19,6 +20,7 @@ typedef gboolean (* GumCloakFoundThreadFunc) (GumThreadId id, | |
typedef gboolean (* GumCloakFoundRangeFunc) (const GumMemoryRange * range, | ||
gpointer user_data); | ||
typedef gboolean (* GumCloakFoundFDFunc) (gint fd, gpointer user_data); | ||
typedef void (* GumCloakLockedFunc) (gpointer user_data); | ||
|
||
GUM_API void gum_cloak_add_thread (GumThreadId id); | ||
GUM_API void gum_cloak_remove_thread (GumThreadId id); | ||
|
@@ -39,6 +41,10 @@ GUM_API gboolean gum_cloak_has_file_descriptor (gint fd); | |
GUM_API void gum_cloak_enumerate_file_descriptors (GumCloakFoundFDFunc func, | ||
gpointer user_data); | ||
|
||
GUM_API void gum_cloak_with_lock_held (GumCloakLockedFunc func, | ||
gpointer user_data); | ||
GUM_API gboolean gum_cloak_is_locked (void); | ||
|
||
G_END_DECLS | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters