如何利用汇编语言
时间:2010-12-20
来源:互联网
首先说下,我还是一个小菜鸟。
前一段,自学了,c和c++,后来编程序老出现错误,然后就有告诉我,说学了汇编就能更好了调试你的程序。
所以我花了一段自学了,汇编。
现在我就迷茫了,我写程序要么写c程序,要么写汇编程序。我怎么才能用我学的汇编给c程序服务,怎么把自己的才能把c语言程序转化为汇编语言程序来调试,现在成了我的问题,有谁来给我指点指点。。。。。。。。。。
前一段,自学了,c和c++,后来编程序老出现错误,然后就有告诉我,说学了汇编就能更好了调试你的程序。
所以我花了一段自学了,汇编。
现在我就迷茫了,我写程序要么写c程序,要么写汇编程序。我怎么才能用我学的汇编给c程序服务,怎么把自己的才能把c语言程序转化为汇编语言程序来调试,现在成了我的问题,有谁来给我指点指点。。。。。。。。。。
作者: tianxiao1101 发布时间: 2010-12-20
1.在VC下使用__asm关键字内联汇编
2.C语言写的程序可以使用Ollydbg反汇编调试
2.C语言写的程序可以使用Ollydbg反汇编调试
作者: chzhn 发布时间: 2010-12-20
编译时的出错,根本无须要学什么汇编吧。如果是在程序运行时,发生了莫名其妙、难以理解的问题的,汇编这时或许可以帮上点儿忙。
作者: zara 发布时间: 2010-12-20
如何在vc下汇编能说的详细点吗?我的悟性很差,基础也很差。。。
引用 1 楼 chzhn 的回复:
1.在VC下使用__asm关键字内联汇编
2.C语言写的程序可以使用Ollydbg反汇编调试
1.在VC下使用__asm关键字内联汇编
2.C语言写的程序可以使用Ollydbg反汇编调试
作者: tianxiao1101 发布时间: 2010-12-20
char* cFileName = "C:\\test\\test.txt";
__asm
{
mov eax, fs:[0x30] ;point to PEB
mov eax, [eax + 0x0C] ;point to _PEB_LDR_DATA
mov eax, [eax + 0x0C] ;point to InLoadOrderModuleList
mov eax, [eax] ;InLoadOrderLinks of this process
mov eax, [eax] ;InLoadOrderLinks of ntdll address
mov eax, [eax + 0x18] ;DllBase of kernel32 address
mov edi,eax ;edi poin to kernel32
//mov ebp,esp;
//sub esp,100;
mov eax,[edi+3ch] ;edx point to pe header
mov edx,[edi+eax+78h] ;edx point to RVA of export table
add edx,edi ;edx point to VA of export table
mov ecx,[edx+18h] ;ecx point to the number of functions of export name table
mov ebx,[edx+20h] ;ebx point to RVA of export name table
add ebx,edi ;ebx point to VA of export name table
search:
dec ecx ;loop counter ecx minusitself
mov esi,[ebx+ecx*4] ;esi get RVA of function name from last
add esi, edi; ;esi get VA of it
mov eax,0x50746547 ;eax get PteG("GetP")
cmp [esi],eax ;compare [esi] with current block
jne search
mov eax,0x41636f72 ;eax get Acor("rocA")
cmp [esi+4],eax ;compare second half
jne search
mov ebx,[edx+24h] ;ebx point to RVA of export index table
add ebx,edi ;ebx point to VA of export index table
mov cx,[ebx+ecx*2] ;
mov ebx,[edx+1ch] ;ebx point to RVA of export address table
add ebx,edi ;ebx point to VA of export address table
mov eax,[ebx+ecx*4] ;eax point to RVA of function
add eax,edi ;eax point to VA of function
mov [ebp+76],eax ;restore somewhere
//call GetProAddress:
push 0;
push DWORD PTR 0x57656C ; leW(" leA")
push DWORD PTR 0x69466574 ;iFet("teFi")
push DWORD PTR 0x61657243 ;aerC("Crea")
push esp
push edi
call [ebp+76]
mov [ebp+80],eax
pop eax
pop eax
pop eax
pop eax
//call CreateFileA:
push 0
push 0
push 2
push 0
push 0
push 40000000h
lea eax,[cFileName]
mov eax,[eax]
push eax
call [ebp+80];
}
__asm
{
mov eax, fs:[0x30] ;point to PEB
mov eax, [eax + 0x0C] ;point to _PEB_LDR_DATA
mov eax, [eax + 0x0C] ;point to InLoadOrderModuleList
mov eax, [eax] ;InLoadOrderLinks of this process
mov eax, [eax] ;InLoadOrderLinks of ntdll address
mov eax, [eax + 0x18] ;DllBase of kernel32 address
mov edi,eax ;edi poin to kernel32
//mov ebp,esp;
//sub esp,100;
mov eax,[edi+3ch] ;edx point to pe header
mov edx,[edi+eax+78h] ;edx point to RVA of export table
add edx,edi ;edx point to VA of export table
mov ecx,[edx+18h] ;ecx point to the number of functions of export name table
mov ebx,[edx+20h] ;ebx point to RVA of export name table
add ebx,edi ;ebx point to VA of export name table
search:
dec ecx ;loop counter ecx minusitself
mov esi,[ebx+ecx*4] ;esi get RVA of function name from last
add esi, edi; ;esi get VA of it
mov eax,0x50746547 ;eax get PteG("GetP")
cmp [esi],eax ;compare [esi] with current block
jne search
mov eax,0x41636f72 ;eax get Acor("rocA")
cmp [esi+4],eax ;compare second half
jne search
mov ebx,[edx+24h] ;ebx point to RVA of export index table
add ebx,edi ;ebx point to VA of export index table
mov cx,[ebx+ecx*2] ;
mov ebx,[edx+1ch] ;ebx point to RVA of export address table
add ebx,edi ;ebx point to VA of export address table
mov eax,[ebx+ecx*4] ;eax point to RVA of function
add eax,edi ;eax point to VA of function
mov [ebp+76],eax ;restore somewhere
//call GetProAddress:
push 0;
push DWORD PTR 0x57656C ; leW(" leA")
push DWORD PTR 0x69466574 ;iFet("teFi")
push DWORD PTR 0x61657243 ;aerC("Crea")
push esp
push edi
call [ebp+76]
mov [ebp+80],eax
pop eax
pop eax
pop eax
pop eax
//call CreateFileA:
push 0
push 0
push 2
push 0
push 0
push 40000000h
lea eax,[cFileName]
mov eax,[eax]
push eax
call [ebp+80];
}
作者: chzhn 发布时间: 2010-12-20
关注下 。。。。
作者: StillMiss 发布时间: 2010-12-20
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28