|
|
|
|
|
[求助]看雪坛子的大虾来 小虾就别来了
push ebp mov ebp, esp push ebx push esi push edi __asm{ mov eax, offset test push eax } pop edi pop esi pop ebx pop ebp 楼上你的c编译器没有生成保护ebx esi edi的代码么 即使没有 那ebp总该有的吧 你仅仅是一个push offset test,接下来会立即pop ebp 这时候ret就会用原始ebp中的值做返回地址了。。 |
|
[求助]看雪坛子的大虾来 小虾就别来了
刚才经调试 问题已解决 谢谢memspirit的提醒 不过我不是想平衡main函数的堆栈 只要能返回mainCRTStartup 那就让mainCRTStartup去平衡调用main函数的堆栈 我add esp,12 漏掉一个相应的push 应该是add esp,16 这样栈顶就是返回mainCRTStartup的地址了 问题已解决 完整代码和注释在下面 大家编译后调试一下 注意栈的变化 一看便知 #include "stdio.h" void __cdecl test(){ __asm{ add esp,16 //恢复main函数入口处C编译器自动生成的 ebp ebx esi edi 寄存器所占堆栈 } printf("hallo"); //因为从来没有调过test 而是从main函数ret到test函数的入口处的 所以这时候栈顶是返回到mainCRTStartup } int __cdecl main(int __argc,char** __argv, char** __environ){ //函数入口处C编译器将自动生成代码用来保护 ebp ebx esi edi四个寄存器 // push ebp // mov ebp,esp // push ebx // push esi // push edi __asm{ mov eax,offset test push eax //ret指令将使用这个地址跳转 push ebp //实际上这里有个错误 这个ebp已经被修改过了 push ebx push esi push edi } return 0; //xor eax, eax //函数末尾处C编译器也将自动生成代码用来恢复 edi esi ebx ebp四个寄存器 // pop edi // pop esi // pop ebx // pop ebp } |
|
[求助]看雪坛子的大虾来 小虾就别来了
@2 噢。。 我看错了 mov eax,offset test是个warning 不是error 另外 我的add esp,12 是使堆栈平衡 因为ret指令使eip直接跳到了test函数入口处 __cdecl需要主调函数平衡堆栈 但是直接跳到了test函数入口处了 所以没能平衡堆栈 所以我家了 add esp,12 自己手动平衡了堆栈 程序崩溃另有原因 要怎么才能正常返回的mainCRTstartup函数执行exit 这个要等看雪的大虾出来解释了。。 |
|
|
|
[求助]啦啦啦 内存越界啦。。。 期待看雪的大虾出现帮小妹看看。。
就是循环把main第二个参数__argv字符串指针数组依次入栈 然后printf呀 printf里面有三个格式符 却只传了一个__argc 这样就可以打出来我刚才循环入栈的__argv字符串了呀 |
|
[求助]啦啦啦 内存越界啦。。。 期待看雪的大虾出现帮小妹看看。。
我自己想到问题原因啦 printf后面 c编译器生成的堆栈平衡不对 调用printf之后 __asm { add esp,8 } 就ok了 可是现在还有一个问题 就是我输入 test.exe abc 读到的不是 test.exe abc 你们可以试试 - -# |
操作理由
RANk
{{ user_info.golds == '' ? 0 : user_info.golds }}
雪币
{{ experience }}
课程经验
{{ score }}
学习收益
{{study_duration_fmt}}
学习时长
基本信息
荣誉称号:
{{ honorary_title }}
能力排名:
No.{{ rank_num }}
等 级:
LV{{ rank_lv-100 }}
活跃值:
在线值:
浏览人数:{{ visits }}
最近活跃:{{ last_active_time }}
注册时间:{{ user_info.create_date_jsonfmt }}
勋章
兑换勋章
证书
证书查询 >
能力值