Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

¼¸ÖÖC/C++µÄº¯Êýѹջ·½Ê½

Ò»£¬²»Í¬¹Ø¼ü×Ö£¬ÏµÍ³Ñ¹Õ»·½Ê½
1£¬Èç¹ûº¯ÊýfuncÊÇ__cdecl(VCϵÄĬÈϵ÷Ó÷½Ê½)£¬µ÷ÓÃʱÇé¿öÈçÏÂ
int main()
{
//²ÎÊý´ÓÓÒµ½×óѹջ
push 4
push 3
push 2
push 1
call func
add esp 0x10 //µ÷ÓÃÕ߻ָ´¶ÑÕ»Ö¸Õëesp£¬4¸ö²ÎÊýµÄ´óСÊÇ0x10(4x4)
}
Cµ÷ÓÃÔ¼¶¨£¨¼´ÓÃ__cdecl¹Ø¼ü×Ö˵Ã÷£©°´´ÓÓÒÖÁ×óµÄ˳Ðòѹ²ÎÊýÈëÕ»£¬Óɵ÷ÓÃÕ߰ѲÎÊýµ¯³öÕ»¡£¶ÔÓÚ´«ËͲÎÊýµÄÄÚ´æÕ»ÊÇÓɵ÷ÓÃÕßÀ´Î¬»¤µÄ£¨ÕýÒòΪÈç´Ë£¬ÊµÏֿɱä²ÎÊýµÄº¯ÊýÖ»ÄÜʹÓøõ÷ÓÃÔ¼¶¨£©¡£ÁíÍ⣬ÔÚº¯ÊýÃûÐÞÊÎÔ¼¶¨·½ÃæÒ²ÓÐËù²»Í¬¡£
_cdeclÊÇCºÍC£«£«³ÌÐòµÄȱʡµ÷Ó÷½Ê½¡£Ã¿Ò»¸öµ÷ÓÃËüµÄº¯Êý¶¼°üº¬Çå¿Õ¶ÑÕ»µÄ´úÂ룬ËùÒÔ²úÉúµÄ¿ÉÖ´ÐÐÎļþ´óС»á±Èµ÷ÓÃ_stdcallº¯ÊýµÄ´ó¡£º¯Êý²ÉÓôÓÓÒµ½×óµÄѹջ·½Ê½¡£VC½«º¯Êý±àÒëºó»áÔÚº¯ÊýÃûÇ°Ãæ¼ÓÉÏÏ»®Ïßǰ׺¡£ÊÇMFCȱʡµ÷ÓÃÔ¼¶¨
2.Èç¹ûº¯ÊýfuncÊÇ__stdcall£¬µ÷ÓÃʱÇé¿öÈçÏÂ
int main()
{
//²ÎÊý´ÓÓÒµ½×óѹջ
push 4
push 3
push 2
push 1
call func
//»Ö¸´¶ÑÕ»Ö¸ÕëÓɱ»µ÷ÓÃÕßfunc¸ºÔ𣬷½·¨ÊÇ"ret 0x10"
}
_stdcallÊÇPascal³ÌÐòµÄȱʡµ÷Ó÷½Ê½£¬Í¨³£ÓÃÓÚWin32 ApiÖУ¬º¯Êý²ÉÓôÓÓÒµ½×óµÄѹջ·½Ê½£¬×Ô¼ºÔÚÍ˳öʱÇå¿Õ¶ÑÕ»¡£VC½«º¯Êý±àÒëºó»áÔÚº¯ÊýÃûÇ°
Ãæ¼ÓÉÏÏ»®Ïßǰ׺£¬ÔÚº¯ÊýÃûºó¼ÓÉÏ"@"ºÍ²ÎÊýµÄ×Ö½ÚÊý¡£
3.Èç¹ûº¯ÊýfuncÊÇ__pascal£¬µ÷ÓÃÇé¿öÈçÏÂ
int main()
{
//²ÎÊý´Ó×óµ½ÓÒѹջ
push 1
push 2
push 3
push 4
call func
//»Ö¸´¶ÑÕ»Ö¸ÕëÓɱ»µ÷ÓÃÕßfunc¸ºÔ𣬷½·¨ÊÇ"ret 0x10"
}
3.Èç¹ûº¯ÊýfuncÊÇ__fastcall£¬µ÷ÓÃÇé¿öÈçÏÂ
int main()
{
//²ÎÊýÏÈÓÃecx, edx, eax´«µÝ£¬È»ºóÔÙѹջ
//²»½øÕ»
//(²»ÖªÎªÊ²Ã´£¬°ïÖúÖÐдµÄÊÇ´Ó×óµ½ÓÒ´«µÝµÄ£¬
//ÊDz»ÊÇ´íÁË£¬»¹ÊÇBCB6ºÍBCB5µÄ²»Ò»Ñù)
push 4
mov ecx 3
mov edx 2
mov eax 1
call func
//»Ö¸´¶ÑÕ»Ö¸ÕëÓɱ»µ÷ÓÃÕßfunc¸ºÔ𣬷½·¨ÊÇ"ret 0x04",
//ÒòΪֻ½øÕ»Ò»¸ö²ÎÊý£¬ÆäÓàÓüĴæÆ÷´«µÝ£¬ËùÒÔÓÃret 0x04»Ö¸´
}
__fastcallµ÷ÓÃÔ¼¶¨ÊÇ“ÈË”ÈçÆäÃû£¬ËüµÄÖ÷ÒªÌصã¾ÍÊǿ죬ÒòΪËüÊÇͨ¹ý¼Ä´æÆ÷À´´«ËͲÎÊýµÄ£¨Êµ¼ÊÉÏ£¬ËüÓÃECXºÍEDX´«ËÍÇ°Á½¸öË«×Ö£¨DWORD£©»ò¸üСµÄ²ÎÊý£¬Ê£ÏµIJÎÊýÈÔ¾É×ÔÓÒÏò×óѹջ´«ËÍ£¬±»µ÷Óõĺ¯ÊýÔÚ·µ»ØÇ°ÇåÀí´«ËͲÎÊýµÄÄÚ´æÕ»£©£¬ÔÚº¯ÊýÃûÐÞÊÎÔ¼¶¨·½Ã棬ËüºÍÇ°Á½Õß¾ù²»Í¬¡£
__fastcall·½Ê½µÄº¯Êý²ÉÓüĴæÆ÷´«µÝ²ÎÊý£¬VC½«º¯Êý±àÒëºó»áÔÚº¯ÊýÃûÇ°Ãæ¼ÓÉÏ"@"ǰ׺£¬ÔÚº¯ÊýÃûºó¼ÓÉÏ"@"ºÍ²ÎÊýµÄ×Ö½ÚÊ


Ïà¹ØÎĵµ£º

mysql connect by c++

#include <stdio.h>
#include <windows.h>
#include <mysql.h>
#define host "localhost"
#define username "root"
#define password "123"
#define database "oa"
MYSQL *conn;
int main()
{
MYSQL_RES *res_set;
MYSQL_ROW row;
unsigned int i,ret;
FILE *fp;
MYSQL_FIELD *field; ......

CÅÌת»»ÎªNTFS¸ñʽ.cmd

@ ECHO OFF
@ ECHO.
@ ECHO.                               ˵   Ã÷
@ ECHO ----------------------------------------------------------------- ......

C/C++ÊÇ×îÖ÷ÒªµÄ±à³ÌÓïÑÔ,ÕâÀïÁгöÁË50ÃûÓÅÐãÍøÕ¾

C/C++ÊÇ×îÖ÷ÒªµÄ±à³ÌÓïÑÔ¡£ÕâÀïÁгöÁË50ÃûÓÅÐãÍøÕ¾ºÍÍøÒ³Çåµ¥£¬ÕâЩÍøÕ¾Ìṩc/c++Ô´´úÂë ¡£Õâ·ÝÇåµ¥ÌṩÁËÔ´´úÂëµÄÁ´½ÓÒÔ¼°ËüÃǵÄС˵Ã÷¡£ÎÒÒѾ¡Á¦°üÀ¨×î¼ÑµÄC/C++Ô´´úÂëµÄÍøÕ¾¡£Õâ²»ÊÇÒ»¸öÍêÕûµÄÇåµ¥£¬ÄúÓн¨Òé¿ÉÒÔÁªÏµÎÒ£¬ÎÒ½«»¶Ó­ÄúµÄ½¨ Ò飬ÒÔ½øÒ»²½¼ÓÇ¿Õâ·½ÃæµÄÇåµ¥¡£
1¡¢http://snippets.dzone.com/tag/c/ --ÊýÒÔǧ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ