Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // &x and &y are the only preserved values.
- // They are pointers to the original.
- int isthisokay(int x, int y, int z) {
- int* p_x = &x + 22;
- int* p_y = &y + 22;
- int* p_z = &z + 22;
- // Function pointer: 4
- // Return pointer: 4
- // Param1 : 4
- // param2 : 4
- // param3 : 4
- // == 20
- printf("isthisokay: X(%d, %d) Y(%d, %d) Z(%d, %d)\n", *p_x, p_x, *p_y, p_y, *p_z, p_z);
- return x + 1;
- }
- /**
- * Puts a variable amount of parameters into an array for use by a function.
- * @var int size - The amount of parameters to be read from the variable amount.
- * @return A list of the parameters with array size of "size"
- */
- int* put(int size, ...) {
- int* values = new int[size];
- int i = 0;
- va_list valist;
- va_start(valist, size);
- for (; size > 0; size--, i++) {
- values[i] = va_arg(valist, int);
- }
- va_end(valist);
- return values;
- }
- int main() {
- IPCFunc* func = new IPCFunc(isthisokay, 3);
- int x = 1;
- int y = 2;
- int z = 3;
- printf("beforecall: X(%d, %d) Y(%d, %d) Z(%d, %d)\n", x, &x, y, &y, z, &z);
- int* arguments = put(func->cPars, &x, &y, &z);
- int t = testFunc.Invoke(arguments);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement