不能直接写stdout
由 user1 于 2023-02-01 20:05:14 发表,最后修改于 2023-02-02 06:23:35
#include <stdio.h>
int a;
#define P 0x408000
int main() {
printf("%p\n", &a);
*((char*)0x4081a0) = '?';
for (int i=0; i<100; ++i) printf("%p %p", (char**)P+i, *((char**)P+i)), printf(" %p\n", *((char**)P+i));
//*((char**)0x408048) = (char*)0x4081b9;
}
明明stdout就在那,改不了
#include <stdio.h>
int a;
#define P 0x408180
int main() {
printf("%p\n", &a);
//*((char*)0x4081a0) = '?';
for (int i=0; i<100; ++i) printf("%p %p", (char**)P+i, *((char**)P+i)), printf(" %p\n", *((char**)P+i));
//*((char**)0x408048) = (char*)0x4081b9;
}
EDIT: 好了
#include <sys/syscall.h>
#include <stdio.h>
#define uint64_t unsigned long long
struct DuckInfo_t {
uint64_t abi_version;
const char *stdin_ptr; // stdin pointer (read-only contents)
uint64_t stdin_size; // stdin size
char *stdout_ptr; // stdout pointer
uint64_t stdout_limit; // [IN] stdout maximum size
uint64_t stdout_size; // [OUT] stdout actual size
char *stderr_ptr; // stderr pointer
uint64_t stderr_limit; // [IN] stderr maximum size
uint64_t stderr_size; // [OUT] stderr actual size
const char *IB_ptr; // IB (Input Buffer) pointer
uint64_t IB_limit; // IB limit
char *OB_ptr; // OB (Output Buffer) pointer
uint64_t OB_limit; // OB limit
uint64_t tsc_frequency; // TSC (Time Stamp Counter) frequency
} __attribute__((packed));
int main() {
struct DuckInfo_t *duckinfo = (struct DuckInfo_t *) getauxval(0x6b637564);
printf ("%p", duckinfo);
fprintf (stderr, "吃鸭肉");
duckinfo->stderr_ptr = duckinfo->stdout_ptr;
duckinfo->stderr_size = 4;
}
Judge Duck Online | 评测鸭在线
Server Time: 2024-12-04 01:57:46 | Loaded in 14 ms | Server Status
个人娱乐项目,仅供学习交流使用 | 捐赠