|
1鱼币
- #include <stdio.h>
- #include <stdlib.h>
- #include <Windows.h>
- #include <tchar.h>
- #include <string.h>
- void run()
- {
- printf("HelloWorld!\n");
- }
- int main()
- {
- HANDLE hd=GetCurrentProcess();
- char* pRemoteThread =(char*) VirtualAllocEx(hd, 0,1024, MEM_COMMIT | MEM_RESERVE, PAGE_EXECUTE_READWRITE);
- memset(pRemoteThread,0,1024);
- if (!WriteProcessMemory(hd,pRemoteThread,&run,1024,0)) {
- MessageBox(NULL, "写入主失败 !","Notice", MB_ICONINFORMATION | MB_OK);
- return 0;
- }
-
- DWORD addr;
- sscanf(pRemoteThread, "%x", &addr);
- printf("%#x \n",pRemoteThread);
-
- _asm
- {
- lea eax, RetAddr
- push eax
- call addr
- // jmp run 这样可以 不过打算不用这种方法
- //如何 通过 pRemoteThread 的指针 执行这段代码
- RetAddr:
-
- }
- printf("Main\n");
- while (true);
- return 0;
- }
- /*
- char* pRemoteThread =(char*) VirtualAllocEx(hd, 0,1024, MEM_COMMIT | MEM_RESERVE, PAGE_EXECUTE_READWRITE);
- //如何 用汇编 的jmp 执行 pRemoteThread 里面的内容
- _asm{
- };
- */
复制代码 // jmp run 这样可以 不过打算不用这种方法
//如何 通过 pRemoteThread 的指针 执行这段代码
|
|