Thread View: cn.bbs.comp.program
1 messages
1 total messages
Started by ���ܵ�Сʨ
Thu, 07 May 1998 00:00
"����"����̽��
Author: ���ܵ�Сʨ
Date: Thu, 07 May 1998 00:00
Date: Thu, 07 May 1998 00:00
282 lines
17762 bytes
17762 bytes
��ͨ��(RichWin)������֮��(CStar)�Ǵ�ҹ�Ϊ��֪�ĺ���Windo
ws��Ʒ,"����"��������̬��Windows����,һֱ���������ƵĹ�
�˼��������Ĵ�Windows��ģ����û������ض�λ��������,������"
����"������ʵ��,������˲���"����"������̬��Windows�����
ʾ��Դ����
һ��������ʲô?
���߶�����һֱ����Windows�µ������������,������Windows
2.0 �� 3.0 ��3.1 ,ֱ��Windows 95��NT�ijɳ����,Ҳ�����˳���
���ڡ����Ǵ��ڡ�DBWin��CStar��RichWin�ȶ��Windows������Ʒ��
�����ڿ���,Ӱ�����Ҳ��Ϊ�ɹ���,������ͨ���RichWin;����,
����֮��CStar��RichWinʦ��һ��,����ļ�����ȻҲ��ࡣ���
������ö��ص�"���弼������̬��Windows����,һֱ�DZ��߸�
��Ȥ�ĵط���
EXEHDR��Microsoft Visual C++���������к����õ�һ������,
����Լ��NE(New-Exc utable)��ʽ�ļ�,����������RichWin��WSEN
GINE.DLL��CStar��CHINESE.DLL,�ͻᷢ�����ڲ�ͬ������(��CStar
1.20��):
C:\CSTAR>exehdr chinese.dll /v
..................................
6 type offset target
BASE 060a seg 2 offset 0000
PTR 047e imp GDI.GETCHARABCWIDTHS
PTR 059b imp GDI.ENUMFONTFAMILIES
PTR 0451 imp DISPLAY.14 ( EXTTEXTOUT )
PTR 0415 imp KEYBOARD.4 ( TOASCII )
PTR 04ba imp KEYBOARD.5 ( ANSITOOEM )
PTR 04c9 imp KEYBOARD.6 ( OEMTOANSI )
PTR 04d8 imp KEYBOARD.134( ANSITOOEMBUFF )
PTR 05f5 imp USER.430 ( LSTRCMP )
PTR 04e7 imp KEYBOARD.135( OEMTOANSIBUFF )
PTR 0514 imp USER.431 ( ANSIUPPER )
PTR 0523 imp USER.432 ( ANSILOWER )
PTR 05aa imp GDI.56 ( CREATEFONT )
PTR 056e imp USER.433 ( ISCHARALPHA )
PTR 05b9 imp GDI.57 ( CREATEFONTINDIRECT )
PTR 057d imp USER.434 ( ISCHARALPHANUMERIC )
PTR 049c imp USER.179 ( GETSYSTEMMETRICS )
PTR 0550 imp USER.435 ( ISCHARUPPER )
PTR 055f imp USER.436 ( ISCHARLOWER )
PTR 0532 imp USER.437 ( ANSIUPPERBUFF )
PTR 0541 imp USER.438 ( ANSILOWERBUFF )
PTR 05c8 imp GDI.69 ( DELETEOBJECT )
PTR 058c imp GDI.70 ( ENUMFONTS )
PTR 04ab imp KERNEL.ISDBCSLEADBYTE
PTR 05d7 imp GDI.82 ( GETOBJECT )
PTR 048d imp KERNEL.74 ( OPENFILE )
PTR 0460 imp GDI.91 ( GETTEXTEXTENT )
PTR 05e6 imp GDI.92 ( GETTEXTFACE )
PTR 046f imp GDI.350 ( GETCHARWIDTH )
PTR 0442 imp GDI.351 ( EXTTEXTOUT )
PTR 0604 imp USER.471 ( LSTRCMPI )
PTR 04f6 imp USER.472 ( ANSINEXT )
PTR 0505 imp USER.473 ( ANSIPREV )
PTR 0424 imp USER.108 ( GETMESSAGE )
PTR 0433 imp USER.109 ( PEEKMESSAGE )
35 relocations
(������Ϊ�����ϵĶ�ӦWindows API����)
��һ,����ݶ���,�������ض�λ��Ϣ��
�ڶ�,��Щ�ض�λ��Ϣ��ʾ�ĺ���,ȫ����������ʾ����ͼ��̡�
�ַ��йء�Ҳ����˵����Windows,��������Щ����
����dz�����ĵط�,������ʲô��?��ӹ����,�����ڲ�ͬ����
��,�Դ�"����"����֮�Ŷ���,���ǽ�Կ��,Ҳ������ש��
����Windows��ģ����û������ض�λ����
Ϊ������̽��"����"����,������������Windows��ģ����û���
��
Windows�����з�ʵģʽ����ģʽ����ǿģʽ����,��Ȼ�⼸��
ģʽ������ͬ,�������ģ��ĵ��ù�ϵȴ����ȫһ�µ�,��ͼһ��
��Ҫ�����ģ��,�����µĹ�ϵ:
��KERNEL��Windowsϵͳ�ں�,����������ģ�顣
��GDI��Windowsͼ���豸�ӿ�ģ��,��������KERNELģ�顣
��USER��Windows�û��ӿڷ���ģ��,��������KERNEL��GDIģ��
���豸����������ģ�顣
�����ģ��,ʵ���Ͼ���Windows�������̬���ӿ⡣KERNEL����
��ϵͳ������ʽ:Kere l.exe(ʵģʽ)��Krnl286.exe(��ģʽ)��Kr
nl386.exe(386��ǿģʽ);GDIģ����Gdi.ee; USERģ����User.exe��
��Ȼ�ļ�����EXEΪ��չ��,������ʵ�ʶ��Ƕ�̬���ӿ⡣ͼ1 Wind
ows��ģ����û���
ͬʱ,�������е�API���������������ģ���С���EXEHDR����
���ģ�����,�Ϳ��г�һ��Ѵ������Ϥ��Windows API����
��GDIģ��Ϊ��,���н������:
C:\WINDOWS\SYSTEM>exehdr gdi.exe
Exports:
ord seg offset name
............
351 1 923e EXTTEXTOUT exported, shared data
56 3 19e1 CREATEFONT exported, shared data
............
����,�������ܴ�Windows�����ӵ�ϵͳ�����һЩͷ��������
��,������һ����Ҫ������ض�λ��
һ��Windowsִ�г���Ե���API����������̬��ĵ���,��
����װ���ڴ�ǰ,����һЩ���ܶ�λ�Ķ�̬����;����������ڴ�ʱ,
��ЩԶ���ö���Ҫ���¶�λ,���¶�λ�����ݾ����ض�λ�?��Windo
wsִ�г���(������̬��)��ÿ���κ���,ͨ������������һ���ض�λ
�?�ض�λ����ú�������ģ�顢�������к��Լ���λ��ģ���е�
λ�á�
����,��EXEHDR /v ����CHINESE.DLL�õ�:
6 type offset target
..........
PTR 0442 imp GDI.351
..........
�ͱ���,�ڱ��ε�0442Hƫ�ƴ�,������GDI�ĵ�351�ź������
��0442H����0000:FFF, ��ʾ�����ڽ���һ��������GDI.351����;��
��,�����˱����ڻ���һ�����ô˺���,���õ�λ�þ���0442H����ָ
�������,ʵ�����ض�λ��ֻ��������λ�õ��������ͷ����ô,GDI3
51 ��һ��ʲô������?��EXEHDR��GDI.EXE��һ����,�Ϳɵó�,��GDI
�ij���(Export)������,��351����ExtTextOut��
����,������EXEHDR��һ��dz����õĹ��߰�����,�Ѿ���Wi
ndows�ĺ�嫺����г�����һ��,���������Ǽ���������ȥ��
��̬����Windowsԭ��
����֪��,��ͳ�ĺ���Windows�ķ���,��Ҫֱ����Windows����
ʾ�����롢��ӡ��ģ�����,����DDKֱ�ӿ���"�����豸"��ģ�顣
�������������,����,ϵͳ���걸�Ժ��ѱ�֤,������Ҳ�кܶ���
��(���ڵij��ര�ھ������),����ֻ�д��ں�����Windows���Ĵ�
�������İ취��
��Windows��ģ����û���,���ǿ��Կ���,Windowsʵ�������ɰ�
����KERNEL��GDI��UE R�ȼ���ģ���е��ڶຯ��֧�ŵġ���ô,��
�����漰�������ִ���ĺ���,ʹ֮����Ӧ������Ҫ,�����ܴﵽ����
Ŀ������?
���,���ǿ��Եó�����Ľ���:���Լ���ģ�������±�д�漰��
����ʾ������Ķ������,Ȼ��,��Windows�ж���Щ���������,����
���Լ�����Щģ������������Щ���������ɺ���,����Ҫ�����
��Windows���ڲ��ṹ,��CHINESE.DLL����ȷ����ظ���������,����
��ݶε��ض�λ�����г������ú���,����CStar���˵�Windows��
��!Ϊ����֤��һ˼·��������RichWin��һ��ʵ��
��EXEHDR����GDI.EXE,�ó�ExtTextOut������GDI�ĵ�һ�����6
139Hƫ�ƴ�(��ͬ�汾��Windows�����ڴ���κ�ƫ�ƿ��ܲ�һ��)��
Ȼ��,��HelpWalk(Ҳ��Microsoft Visual C+ ���������е�һ��)��
��GDI��Code1��,6139H��ǰ5���ֽ��� B8 FF 05 45 55,��������Rch
Win 4.3 for Internet��,�ٲ鿴ͬ��ĵط�,�Ѹ�Ϊ EA 08 08 8F
3D����ʵ������֪��,��5���ֽھ��� Jmp 3D8F:0808,����Ϊ0x3
D8F��ģ��,��HelpWalk�ܹ۲�����RichWi��W SENGINE.DLL�ĵ�һ��
���( ģ����ΪTEXTMAN)����ƫ��0808H�� B8 B7 3D 45 55 8BC 1E,
����һ��������ʼ�ĵط�,��ʵ���Ͼ���RichWin���ظ�д��ExtText
Out�����˳�RchWin��,����HelpWalk�۲�GDI��Code1�����,һ��
�ָֻ���!����ǰ��ķ���������ȫ�Ǻ�!��ô,��һ���ؼ�����
��ζ�̬��Windows�ĺ������,Ҳ���Ǻ���Windows�ĺ��ġ���"��
��"������
�ġ�"����"����
����"����"����,��Ҫ�ص�ǰ����������֡�����֮��,���ܽ���
Ϊ�ĵ�Windows����,����֮һȴ����һ���ԡ�
��ݶδ�ŵ��DZ���������������,�������������ض�λ��
Ϣ,��ô,�ض�Ҫ�ڱ���˵���н�����ָ�븳��һ��FARPROC���͵ı�
��,����,�ڱ���˵����д��:
FARPROC FarProcFunc=ExtTextOut;
��Ȼ,���Լ��������ݶ���Ҳ�����ض�λ��Ϣ������,�������
���ڴ�ʱ,����FarPrc Func���Ǻ���ExtTextOut�ĵ�ַ�ˡ�
Ҫֱ���Ĵ���ε�����,������һ������,���Ǵ�����Dz��ɸ�
д�ġ���ʱ,��Ҫ�õ�һ��δ������Windows����AllocCStoDSAlias,
ȡ������������ͬ��ַ�Ŀ�д��ݶα����亯������Ϊ:
WORD FAR PASCAL AllocCStoDSAlias(WORD code_sel);
�����Ǵ���εľ��,����ֵ�ǿ�д��ݶα�����
Windows�к����ַ��32λ,���ֽ�����ģ����ڴ���,���ֽ�
�Ǻ�����ģ���ڵ�ƫ�ơ����õ��Ŀ�д��ݶα�������,�ٽ���
��ƫ�ƴ���5���ֽڱ�������,Ȼ�����Ϊת�������(�� EA Jmp
):
*(lpStr+wOffset) =0xEA;
��ͨ��(RichWin)������֮��(CStar)�Ǵ�ҹ�Ϊ��֪�ĺ���Wi
ndows��Ʒ,"����"��������̬��Windows����,һֱ���������Ƶ�
���˼��������Ĵ�Windows��ģ����û������ض�λ��������,������
"����"������ʵ��,������˲���"����"������̬��Windows�����
ʾ��Դ����
//Դ���� relocate.c
#include <WINDOWS.H>
#include <dos.h>
BOOL WINAPI MyExtTextOut(HDC hDC, int x, int y, UINT nIn
t1, const RECTFAR*p Rect,LPCSTR lpStr, UINT nInt2, int FAR*
lpInt);
WORD FAR PASCAL AllocCStoDSAlias(WORD code_sel);
typedef struct tagFUNC
{
FARPROC lpFarProcReplace; //������ַ
FARPROC lpFarProcWindows; //Windows�����ַ
BYTE bOld; //����ԭ�����һ�ֽ�
LONG lOld; //����ԭ����Ӻ�����ֽڳ�ֵ
}FUNC;
FUNC Func={MyExtTextOut,ExtTextOut};
//Windows������
int PASCAL WinMain(HINSTANCE hInstance,HINSTANCE hPrevIn
stance,LPSTR lpCmdi ne,int nCmdShow){
HANDLE hMemCode; //�����
WORD hMemData; //��ͬ��ַ�Ŀ�д��ݶα���
WORD wOffset; //����ƫ��
LPSTR lpStr;
LPLONG lpLong;
char lpNotice[96];
hMemCode=HIWORD((LONG) Func.lpFarProcWindows );
wOffset=LOWORD((LONG) Func.lpFarProcWindows );
wsprintf(lpNotice,"��������ģ���� 0x%4xH,ƫ�� 0x%4xH",
hMemCode,wOffset);
MessageBox(NULL,lpNotice,"��ʾ",MB_OK);
//ȡ����������ͬ��ַ�Ŀ�д��ݶα���
hMemData=AllocCStoDSAlias(hMemCode);
lpStr=GlobalLock(hMemData);
lpLong=(lpStr+wOffset+1 );
//����ԭ����Ҫ�滻��ͷ�����ֽ�
Func.bOld=*(lpStr+wOffset);
Func.lOld=*lpLong;
*(lpStr+wOffset)=0xEA;
*lpLong=Func.lpFarProcReplace;
GlobalUnlock(hMemData);
MessageBox(NULL,"��Ϊ�Լ��ĺ���","��ʾ",MB_OK);
//�����������ݸĻ���
hMemData=AllocCStoDSAlias(hMemCode);
lpStr=GlobalLock(hMemData);
lpLong=(lpStr+wOffset+1 );
*(lpStr+wOffset)=Func.bOld;
*lpLong=Func.lOld;
GlobalUnlock(hMemData);
MessageBox(NULL,"�Ļ�ԭWindows����","��ʾ",MB_OK);
return 1;
}
//�Լ��������
BOOL WINAPI MyExtTextOut(HDC hDC, int x, int y, UINT nIn
t1, const RECT FAR lpRect, LPCSTR lpStr, UINT nInt2, int FAR
* lpInt){
BYTE NameDot[96]={
0x09, 0x00, 0xfd, 0x08, 0x09, 0x08, 0x09, 0x10, 0x09, 0x
20,
0x79, 0x40, 0x41, 0x04, 0x47, 0xfe, 0x41, 0x40, 0x79, 0x
40,
0x09, 0x20, 0x09, 0x20, 0x09, 0x10, 0x09, 0x4e, 0x51, 0x
84,
0x21, 0x00, 0x02, 0x00, 0x01, 0x04, 0xff, 0xfe, 0x00, 0x
00,
0x1f, 0xf0, 0x10, 0x10, 0x10, 0x10, 0x1f, 0xf0, 0x00, 0x
00,
0x7f, 0xfc, 0x40, 0x04, 0x4f, 0xe4, 0x48, 0x24, 0x48, 0x
24,
0x4f, 0xe4, 0x40, 0x0c, 0x10, 0x80, 0x10, 0xfc, 0x10, 0x
88,
0x11, 0x50, 0x56, 0x20, 0x54, 0xd8, 0x57, 0x06, 0x54, 0x
20,
0x55, 0xfc, 0x54, 0x20, 0x55, 0xfc, 0x5c, 0x20, 0x67, 0x
fe,
0x00, 0x20, 0x00, 0x20, 0x00, 0x20
};
HBITMAP hBitmap,hOldBitmap;
HDC hMemDC;
BYTE far *lpDot;
int i;
for ( i=0;i<3;i++ )
{
lpDot=(LPSTR)NameDot+i*32;
hMemDC=CreateCompatibleDC(hDC);
hBitmap=CreateBitmap(16,16,1,1,lpDot);
SetBitmapBits(hBitmap,32L,lpDot);
hOldBitmap=SelectObject(hMemDC,hBitmap);
BitBlt(hDC,x+i*16,y,16,16,hMemDC,0,0,SRCCOPY);
DeleteDC(hMemDC);
DeleteObject(hBitmap);
}
return TRUE;
}
//ģ�鶨���ļ� relocate.def
NAME RELOCATE
EXETYPE WINDOWS
CODE PRELOAD MOVEABLE DISCARDABLE
DATA PRELOAD MOVEABLE MULTIPLE
HEAPSIZE 1024
EXPORTS
�塢������
���Ĵ�ԭ���Ϸ����˳�Ϊ"����"�����Ķ�̬����Windows����,��
���˽���һWindows������ø����Լ�ָ�������ͨ�÷���,����
����������չ������Ӧ����,���������ʾ����ͬ������ʽ���л���
ʾ�ȡ�
--
________ _____ _____ ______________ _____
___ __ \___(_)________ ___(_) __ ___/___ /_ ___(_)
__ /_/ /__ / ___ __ \__ / _____ \ __ __ \__ /
_ ____/ _ / __ /_/ /_ / ____/ / _ / / /_ /
/_/ /_/ _ .___/ /_/ /____/ /_/ /_/ /_/
/_/
[m[1;36m�� ��Դ:���ϴ�С�ٺ���Ϣ����վ bbs.nju.edu.cn��[FROM: hsia.nju.edu.cn][m
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads