+ -
当前位置:首页 → 问答吧 → 如何利用汇编语言

如何利用汇编语言

时间:2010-12-20

来源:互联网

首先说下,我还是一个小菜鸟。
前一段,自学了,c和c++,后来编程序老出现错误,然后就有告诉我,说学了汇编就能更好了调试你的程序。
所以我花了一段自学了,汇编。
现在我就迷茫了,我写程序要么写c程序,要么写汇编程序。我怎么才能用我学的汇编给c程序服务,怎么把自己的才能把c语言程序转化为汇编语言程序来调试,现在成了我的问题,有谁来给我指点指点。。。。。。。。。。

作者: tianxiao1101   发布时间: 2010-12-20

1.在VC下使用__asm关键字内联汇编
2.C语言写的程序可以使用Ollydbg反汇编调试

作者: chzhn   发布时间: 2010-12-20

编译时的出错,根本无须要学什么汇编吧。如果是在程序运行时,发生了莫名其妙、难以理解的问题的,汇编这时或许可以帮上点儿忙。

作者: zara   发布时间: 2010-12-20

如何在vc下汇编能说的详细点吗?我的悟性很差,基础也很差。。。
引用 1 楼 chzhn 的回复:
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];
}

作者: chzhn   发布时间: 2010-12-20

关注下 。。。。

作者: StillMiss   发布时间: 2010-12-20

热门下载

更多