Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@airportyh
airportyh / test_log.txt
Created September 18, 2023 15:29
pydebug test errors
I+00000.340: Injector[PID=525152] output: Target 'None' cannot support this command.
I+00000.340: Injector[PID=525152] output: The target architecture is set to "auto" (currently "i386").
I+00000.340: Injector[PID=525152] output: No symbol table is loaded. Use the "file" command.
I+00000.340: Injector[PID=525152] output: No symbol table is loaded. Use the "file" command.
I+00000.347: Injector[PID=525152] output: E+00000.116: Code injection into PID=525152 failed:
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <errno.h>
#include <string.h>
#include <stdarg.h>
int error_code = 0;
#define ERROR_MESSAGE_MAX_SIZE 100
char error_message[ERROR_MESSAGE_MAX_SIZE];
#include <stdio.h>
#include <string.h>
// Code below is from http://www.azillionmonkeys.com/qed/hash.html
#include <stdint.h>
#undef get16bits
#if (defined(__GNUC__) && defined(__i386__)) || defined(__WATCOMC__) \
|| defined(_MSC_VER) || defined (__BORLANDC__) || defined (__TURBOC__)
#define get16bits(d) (*((const uint16_t *) (d)))
#endif
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include "uthash.h"
typedef struct _Person {
unsigned long id;
char *name;
char *email;
UT_hash_handle hh;
#include <string.h> /* strcpy */
#include <stdlib.h> /* malloc */
#include <stdio.h> /* printf */
#include "uthash.h"
struct my_struct {
char name[10]; /* key (string is WITHIN the structure) */
int id;
UT_hash_handle hh; /* makes this structure hashable */
};
// https://troydhanson.github.io/uthash/utstring.html
#include "utstring.h"
int main() {
UT_string *str;
utstring_new(str);
char *names[3] = { "Emma", "Marty", "Linus" };
#include <wchar.h>
#include <stdlib.h>
#include <stdio.h>
int main() {
wchar_t *filename = L"/blah/blah/wimpykid.py";
wchar_t *found = wcsrchr(filename, L'.');
int idx = found - filename;
int new_string_size = idx + 8;
wchar_t *log_filename = malloc(sizeof(wchar_t) * new_string_size);
@airportyh
airportyh / weird.c
Created March 2, 2021 23:42
Weird corner case in C where inner scope redeclares a var in the outer scope while at the same time trying to reference the outer one.
#include <stdio.h>
int main() {
int n = 8;
if (n < 10) {
int n = n * 2;
printf("%d\n", n);
}
printf("%d\n", n);
}
@airportyh
airportyh / diff.patch
Created December 15, 2020 19:20
I modified the Python interpreter (ceval.c) to look the state of the stack before each bytecode instruction.
diff --git a/Python/ceval.c b/Python/ceval.c
index 9de925780e..99ca5d6265 100644
--- a/Python/ceval.c
+++ b/Python/ceval.c
@@ -144,6 +144,50 @@ is_tstate_valid(PyThreadState *tstate)
}
#endif
+void printObject(PyObject *obj) {
+ PyObject *type = PyObject_Type(obj);
def f():
n = 0
while n < 10:
n = n + 1
print("Hello")