关于 windows:C – WinAPI 的 ProcessCreation 问题 | 珊瑚贝

C – ProcessCreation Problems with WinAPI

本问题已经有最佳答案,请猛点这里访问。


我正在尝试将文件打开到文件缓冲区,然后用它创建一个新进程。我试图 ASM 转到文件的开头,但遗憾的是由于 windows 它实际上不会做任何事情,因为所有信息都在 windows 可执行文件的顶部。所以我尝试创建一个新进程,但我对 windows API 并不擅长。谁能告诉我我做错了什么?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#include <stdio.h>
#include <windows.h>
#include <WinBase.h>

char *file0_buffer;
int file0_size;

STARTUPINFO si;
PROCESS_INFORMATION pi;

int main(int argc, char **argv){

   ZeroMemory( &si, sizeof(si) );
   si.cb = sizeof(si);
   ZeroMemory( &pi, sizeof(pi) );

   FILE *file0 = fopen(“./input.exe”,“rb”);
   if(file0 == NULL){printf(“fopen file0 error”); getchar(); return 0;}

   fseek(file0, 0, SEEK_END);
   file0_size = ftell(file0);
   rewind(file0);

   file0_buffer = (char*)malloc(file0_size);
   fread(file0_buffer, sizeof(char), file0_size, file0);
   fclose(file0);

   CreateProcess(NULL, NULL, NULL, NULL, TRUE, CREATE_DEFAULT_ERROR_MODE, &file0_buffer, NULL, &si, &pi);

   getchar(); return 0;
}

  • 您可以尝试 GetLastError 找出系统报告的错误类型。我还没有看到将第一个和第二个参数都设置为 NULL 的 CreateProcess 的使用。
  • 什么是错的就是一切。不支持您尝试的操作。


CreateProcess的第7个参数用于指定新进程中的环境变量。

看这个:从内存缓冲区创建进程

  • 这应该只是一个”接近重复”的建议,而不是答案。


来源:https://www.codenong.com/24150113/

微信公众号
手机浏览(小程序)

Warning: get_headers(): SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57

Warning: get_headers(): Failed to enable crypto in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57

Warning: get_headers(https://static.shanhubei.com/qrcode/qrcode_viewid_10053.jpg): failed to open stream: operation failed in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57
0
分享到:
没有账号? 忘记密码?