分享
 
 
 

我的 壳程序 框架

王朝vc·作者佚名  2006-01-08
窄屏简体版  字體: |||超大  

;frame.asm

; #########################################################################

.386

.model flat , stdcall

option casemap :none ; case sensitive

; #########################################################################

; @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

; proto directive can specifier a function type

; but must implement this function use divrective 'proc'

; and 'proc' directive will insert some instructions in your code

; and these instructions are not seen in list file !!

; these code is like below ,

; lines start with ;;;; is assembler auto inserted instructions

; fun proc x:dword

;;;; push ebp

;;;; mov ebp , esp

;

; ......

; your function body ...

; ....

;

;;;; pop ebp

; fun endp

; in api call , this is not alowed , must a direct no condition jump

; to transfer control to api function , code should like below:

;

; fun:

; jmp DWORD PTR [xxxx] ; [xxxx] store the address of the api function

;

; because these codes will be used in any different address

; can not use absolute address to addressing data

; in my code , I use IRA (instruction relative address) to every

; gloable variant and API function's address

; this behavior is defined as a macro 'ldira' (LoaD IRA)

; you can see the macro below , thus , in my api fun ,

; this call like this:

;

; fun:

; ldira eax , xxxx

; jmp DWORD PTR [eax]

;

; after expand macro ldira , the code is :

;

; fun:

; call LL

; LL:

; pop eax

; add eax , xxxx - LL

; jmp DWORD PTR [eax]

;

; @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

include \masm32\include\windows.inc

include \masm32\include\user32.inc

include \masm32\include\kernel32.inc

include \masm32\include\gdi32.inc

; a void directive

myaddr equ

; ------------------------------------------------------------------

; macro for put IRA of _ira to _dst

; ------------------------------------------------------------------

ldira macro _dst , _ira

local LL

call LL

LL:

pop _dst

add _dst , myaddr _ira - myaddr LL

endm

; ------------------------------------------------------------------

; macro for making STDCALL procedure and API calls.

; ------------------------------------------------------------------

Scall MACRO fun_name:REQ,p1,p2,p3,p4,p5,p6,p7,p8,p9,p10,p11,p12, p13,p14,p15,p16,p17,p18,p19,p20,p21,p22

;; ---------------------------------------

;; loop through arguments backwards, push

;; NON blank ones and call the function.

;; ---------------------------------------

FOR arg,<p22,p21,p20,p19,p18,p17,p16,p15,p14,p13, p12,p11,p10,p9,p8,p7,p6,p5,p4,p3,p2,p1>

IFNB <arg> ;; If not blank

push arg ;; push parameter

ENDIF

ENDM

call fun_name ;; call the procedure

ENDM

Section_Start equ 0 ;1000h ;( 1000h - myaddr start )

MyShieldHeader struc

ShieldEntry DD myaddr start - myaddr _TEXT

ShieldImportAddress DD myaddr Start_Import_Table - start + Section_Start

ShieldImportSize DD myaddr End_Import_Table - myaddr Start_Import_Table

ClientEntry DD myaddr NoClientProgram@@

ClientImportAddress DD ?

ClientImportSize DD ?

ClientCodeBase DD ? ; need not store , but I reserve it

ClientDataBase DD ?

Authentication DB 32 dup(?) ; 256 bit Authentication Number

MyShieldHeader ends

_TEXT segment public 'code'

org 0

start:

jmp EntryPoint

org start + 10h

WangBaTitle label byte

db "Íõ°Ëµ°£¡£¡ÏëÆƽ⣿£¿"

db 0

WangBaMsg label byte

db "Íõ°Ëµ°£¡£¡ÏëÆƽ⣿£¿" , 0DH , 0AH

db "ÔÙÐÞÁ¶¼¸Äê°É£¡£¡" , 0DH , 0AH

db 08h,"ºÇºÇ£¡£¡" , 0DH , 0AH

db 08h,"ÒѾ­´ÓÊýѧÉÏÖ¤Ã÷ÁËÕâ¸öÈí¼þ" , 0DH , 0AH

db 08h,"ÔÚÓîÖæÃðÍö֮ǰÊDz»¿ÉÆƽâµÄ£¡£¡" , 0DH , 0AH

db 0

org start + 100h

shieldHeader MyShieldHeader < > ; here stores MyshieldHeader

org start + 200h

EntryPoint:

; ####################################################################################

;;;; start of user code

ifdef _MORE_DEBUG

jmp L1

szDlgTitle db 'Hello World',0

szMsg db 'Hello World',0

szDlgTitleIRA DB 'Addressing by instruction relative address',0

szMsgIRA DB 'Addressing by instruction relative address',0dh,0ah,0

L1:

ldira eax , szDlgTitleIRA

ldira ecx , szMsgIRA

push MB_OK ;;;invoke iraMessageBoxA , 0 , eax , ecx , MB_OK

push ecx

push eax

push 0

call near ptr iraMessageBoxA@16

ldira eax , WangBaMsg

ldira ecx , WangBaTitle

Scall iraMessageBoxA@16,NULL,eax,ecx,MB_OKCANCEL

endif

; ###################################################################################

; ||||

; |||| <----- Á÷³Ì˳ÐòÍùÏ£¬ÎÞÌøת

; \ /

; ¡Å

; ###################################################################################

; call shield function in C++ source , because shield main and user function it calls

; are in C++ source , it can be very complexcomplex

; extrn _ShieldMain@0:near

call _ShieldMain@0 ; ShildMain has no parameters

; ###################################################################################

; ||||

; |||| <----- Á÷³Ì˳ÐòÍùÏ£¬ÎÞÌøת

; \ /

; ¡Å

; ###################################################################################

; Load Client Import Functions

Scall _LoadClientImport@0

; ###################################################################################

; ||||

; |||| <----- Á÷³Ì˳ÐòÍùÏ£¬ÎÞÌøת

; \ /

; ¡Å

; ###################################################################################

; jump to the client entry point

ldira ecx , shieldHeader.ClientEntry

Scall iraGetModuleHandleA@4 , NULL ; self module handle put to eax

add DWORD PTR [ecx] , eax ; now [ecx] hold the current client entry point

jmp DWORD PTR [ECX]

; ###################################################################################

; ###################################################################################

;;; user code compiled form C++ is int this file

;;; ¿ªÊ¼Ê±Îªµ÷ÊÔÓã¬ÏÖÔÚÕâ¸ö include ÒÑÎÞÓã¬

;;; ½«ÔÚ¡°!¿Ç!Ö÷³ÌÐò¡±Öаüº¬±¾Îļþ¡ª¡ª frame.asm ,

;;; ¿ÉÓÃÓÚ¶à¸ö¡°!¿Ç!Ö÷³ÌÐò¡±£¬Éú³É¶à¸ö¿Ç

; include shield.asm

;;; End of user code

; ###################################################################################

; ###################################################################################

; only used when no client , if client is present ,

; execute can not reach here

NoClientProgram@@:

ldira eax , szMsgNoClient

ldira ecx , szTitleNoClient

Scall iraMessageBoxA@16 , NULL , eax , ecx , MB_OK

push 0

call near ptr iraExitProcess@4

szTitleNoClient db 'Have no Client Program!'

db 0

szMsgNoClient db 'Have no Client Program!',0dh,0ah

db 'Shield Terminate!!'

db 0

; ###################################################################################

; ###################################################################################

; This is a function , it convert an address to an IRV , only used in C++ Source

; This function is efficient and perfect ! It Optimized the stack structure

; have only one parameter , this parameter is the address to be converted

A2IRA@4:

call A2IRA@4LL

A2IRA@4LL:

pop eax

sub eax , A2IRA@4LL

add eax , DWORD PTR [esp+4] ; the parameter

ret 4

; this function return the shield header ,

; can only use in shield MODULE , can not use in other MODULE , such as "merge" MODULE

GetShieldHeader@0:

ldira eax , shieldHeader

ret 0

; #############################################################################

_TEXT ENDS

; #############################################################################

; Import Table Related contents are in this file

include ShieldImport.asm

; this file only contain one function named "LoadClientImport" and have no paramters

; because this function is hard coding with assembly , so i code it with C and

; compile it to assembly

include LoadClientImport.asm

; #############################################################################

END start

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
2023年上半年GDP全球前十五强
 百态   2023-10-24
美众议院议长启动对拜登的弹劾调查
 百态   2023-09-13
上海、济南、武汉等多地出现不明坠落物
 探索   2023-09-06
印度或要将国名改为“巴拉特”
 百态   2023-09-06
男子为女友送行,买票不登机被捕
 百态   2023-08-20
手机地震预警功能怎么开?
 干货   2023-08-06
女子4年卖2套房花700多万做美容:不但没变美脸,面部还出现变形
 百态   2023-08-04
住户一楼被水淹 还冲来8头猪
 百态   2023-07-31
女子体内爬出大量瓜子状活虫
 百态   2023-07-25
地球连续35年收到神秘规律性信号,网友:不要回答!
 探索   2023-07-21
全球镓价格本周大涨27%
 探索   2023-07-09
钱都流向了那些不缺钱的人,苦都留给了能吃苦的人
 探索   2023-07-02
倩女手游刀客魅者强控制(强混乱强眩晕强睡眠)和对应控制抗性的关系
 百态   2020-08-20
美国5月9日最新疫情:美国确诊人数突破131万
 百态   2020-05-09
荷兰政府宣布将集体辞职
 干货   2020-04-30
倩女幽魂手游师徒任务情义春秋猜成语答案逍遥观:鹏程万里
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案神机营:射石饮羽
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案昆仑山:拔刀相助
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案天工阁:鬼斧神工
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案丝路古道:单枪匹马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:与虎谋皮
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:李代桃僵
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:指鹿为马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:小鸟依人
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:千金买邻
 干货   2019-11-12
 
推荐阅读
 
 
 
>>返回首頁<<
 
靜靜地坐在廢墟上,四周的荒凉一望無際,忽然覺得,淒涼也很美
© 2005- 王朝網路 版權所有