Filthy newline drama?
[craw.git] / craw / utility.hpp
blob907d5089d19ce9d31a2df1937895f7b0bdaadb5d
1 #pragma once
3 #include <string>
4 #include <ail/types.hpp>
5 #include <ail/string.hpp>
6 #include <windows.h>
7 #include <Tlhelp32.h>
9 extern unsigned page_size;
10 extern DWORD main_thread_id;
12 void error(std::string const & message);
13 void last_error(std::string const & message);
14 void initialise_console();
15 void write_text(std::string const & text);
16 void write_line(std::string const & text);
17 bool procedure_lookup(std::string const & module, std::string const & procedure, void * & output);
18 unsigned get_page(unsigned address);
19 void exit_process();
20 void attach_point();
22 typedef std::vector<DWORD> thread_id_vector;
24 class thread_controller
26 public:
27 bool suspend();
28 bool resume();
30 private:
31 thread_id_vector thread_ids;
32 DWORD current_thread_id;
33 DWORD process_id;
35 bool get_thread_ids();
36 void process_thread_entry(THREADENTRY32 & thread_entry);
39 std::string dword_to_string(ulong input);
40 wchar_t * string_to_wchar(std::string const & input);
41 std::string wchar_to_string(wchar_t * input);
43 template <class type>
44 void print_object(type & object)
46 write_line("Printing object of size " + ail::number_to_string(sizeof(type)) + " at address " + ail::hex_string_32(reinterpret_cast<ulong>(&object)));
47 std::string data(reinterpret_cast<char *>(&object), sizeof(type));
48 write_line(ail::hex_string(data));