Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

C 

C++ convert function to unsigned char array

How to convert function to unsigned char array (*void pointer)
I'm sorry if I do not understand correctly what is *void pointer
For example i have functions like this

Example 1
Code
void test(){
 std::cout << "Hello" << std::endl;
}

Example 2
Code
void test2(int a){
 std::cout << "Hello" << std::endl;
 std::cout << std::to_string(a) << std::endl;
}

Example 3
Code
int test3(int a){
 return a;
}

In short i need univesal method to convert any method(function) to raw data.
I need to save this functions as array or vector of unsigned char.

Someone can help me?
Thank you so much.
Code
unsigned char* function = (unsigned char*)test;
//remove page protection
unsigned char functioncopy[SIZE_OF_FUNCTION] = {0};
memcpy(functioncopy,function,SIZE_OF_FUNCTION);
//restore page protection


Possibly Related Threads...
Thread / Author Replies Views Last Post
[C] by maryousJul 24, 2022 03:35 PM 0 160 Jul 24, 2022 03:35 PM
Last Post: maryous
[C#] by Julius013Mar 2, 2022 05:12 PM 4 311 Mar 2, 2022 05:12 PM
Last Post: Julius013
[C] by FhackMar 2, 2022 03:52 AM 4 306 Mar 2, 2022 03:52 AM
Last Post: Fhack