aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--compile_commands.json6
-rw-r--r--makefile12
-rw-r--r--ramdump.c (renamed from main.c)34
3 files changed, 38 insertions, 14 deletions
diff --git a/compile_commands.json b/compile_commands.json
index e0edd02..a1cf60f 100644
--- a/compile_commands.json
+++ b/compile_commands.json
@@ -1,7 +1,7 @@
[
{
- "command": "cc -c -o main.o main.c",
- "directory": "/home/bloodstalker/devi/abbatoir/hole68",
- "file": "/home/bloodstalker/devi/abbatoir/hole68/main.c"
+ "command": "cc -c -o ramdump.o ramdump.c",
+ "directory": "/home/bloodstalker/extra/MemDump",
+ "file": "/home/bloodstalker/extra/MemDump/ramdump.c"
}
] \ No newline at end of file
diff --git a/makefile b/makefile
index 9d04274..814a88c 100644
--- a/makefile
+++ b/makefile
@@ -1,4 +1,4 @@
-TARGET=main
+TARGET=ramdump
CC=clang
CC?=clang
CC_FLAGS=
@@ -7,13 +7,9 @@ CC_FLAGS+=$(CC_EXTRA)
.DEFAULT:all clean
-.PHONY:all clean $(TARGET) help dirs
+.PHONY:all clean help dirs
-all: dirs $(TARGET)
-
-dirs:
- if [[ ! -d obj ]]; then mkdir obj;fi
- if [[ ! -d libs ]]; then mkdir libs;fi
+all: $(TARGET)
.c.o:
$(CC) $(CC_FLAGS) -c $< -o $@
@@ -22,7 +18,7 @@ android:
export NDK_PROJECT_PATH=`pwd`
ndk-build
-$(TARGET): main.o
+$(TARGET): $(TARGET).o
$(CC) $^ $(LD_FLAGS) -o $@
clean:
diff --git a/main.c b/ramdump.c
index 8bdd992..6e6dc08 100644
--- a/main.c
+++ b/ramdump.c
@@ -1,12 +1,36 @@
+
+/*first line is intentionally left blank*/
+/***********************************************************************************************************/
+#include <arpa/inet.h>
+#include <inttypes.h>
+#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
-#include <limits.h>
+#include <unistd.h>
+#if defined(_WIN32) || defined(_WIN64) || defined(__CYGWIN__)
+#include <process.h>
+#include <tlhelp32.h>
+#include <windows.h>
+#endif
+#if defined(__linux__) || defined(__ANDROID__)
#include <sys/ptrace.h>
#include <sys/socket.h>
#include <sys/wait.h>
-#include <arpa/inet.h>
-#include <unistd.h>
+#endif
+/***********************************************************************************************************/
+#if defined(_WIN32) || defined(_WIN64) || defined(__CYGWIN__)
+DWORD access = PRCOESS_VM_READ | PROCESS_QUERY_INFORMATION | PRCOESS_VM_WRITE | PRCOESS_VM_OPERATION;
+HANDLE proc = OpenProcess(access, FALSE, pid);
+void dump_memory_region() {
+ void* addr;
+ size_t written;
+ ReadProcessMemory(proc, addr, &value, sizeof(value), &written);
+}
+void write_memory_region(proc, addr, &value, sizeof(value), &written) {}
+#endif
+
+#if defined(__linux__) || defined(__ANDROID__)
void dump_memory_region(FILE* pMemFile, unsigned long start_address, long length, int serverSocket) {
unsigned long address;
int pageLength = 4096;
@@ -22,6 +46,7 @@ void dump_memory_region(FILE* pMemFile, unsigned long start_address, long length
}
}
}
+#endif
int main(int argc, char **argv) {
if (argc == 2 || argc == 4) {
@@ -86,3 +111,6 @@ int main(int argc, char **argv) {
exit(0);
}
}
+/***********************************************************************************************************/
+/*last line is intentionally left blank*/
+