具体过程:

一 使用visualstudio2022新建一个c语言项目

二 c语言内连x86汇编的具体代码示例

x86_inline_c.cpp

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
//x86_inline_c.cpp
#include <stdio.h>
#include <stdlib.h>
#include <Windows.h>

int main()
{
//x86 _asm{}
//x64 写纯汇编混合编程/换编译器
int number = 0;
const char* szFormat = "%d\n";
const char* szPause = "pause";
//printf("%d\n",nUmber);
//_cdecl
_asm
{
mov number, 100
push number
mov eax, szFormat
push eax
call printf
add esp, 8
mov eax, szPause
push eax
call system
add esp, 4
}
return 0;
}

补充零散知识点:

64位寄存器传参rcx,rdx,r8,r9,后面用堆栈[rsp+20h],data,[rsp+28h],data

进程遍历用到的win32函数:

1
2
3
CreateToolhelp32napshot
Process32First
Process32Next