本帖最后由 shane007 于 2023-9-4 18:48 编辑
# s) d5 a( J& h/ d. z, p8 w4 n! D3 L" \, }" \+ ?1 E5 J
这是个opengl引擎的游戏,对opengl的初始化是在scream.exe里边完成的。
/ c! Q Q6 V6 M) n- k4 j对于opengl的游戏我们主要关注glGenLists和glCallList这2个函数2 Y' V$ @4 ~% M: j2 B8 g6 _( w
7 m4 F4 Y9 J( p0 B! G" m% u, c5 a% b
o7 G! c Z& [
glGenLists的调用有4处,前3处参数为1,应该不是。3 { i3 B. {/ s' ?. d+ K
一下是第四处代码,这里应该就是生成字体的地方。! h K5 L9 T3 g( {) T: ` }
从代码里可以看出,字体材质长宽各是16各字符,共256个字符,此处要修改。
" O3 N+ O* B$ m1 P- int sub_40BEB0(): W$ }4 w( W3 t- \4 K7 B
- {# B0 F9 q% {, {
- signed int v0; // ebx
. `) z4 U O) B2 m Q( B& }% ?5 u - int v1; // ecx
/ j3 n. R1 L) d0 T" v S+ m! ^ - float v2; // ST18_4
7 @( y( \" D6 p3 w3 p5 p. { - float v3; // ST1C_47 y; ?- G+ ?. J1 H+ l
- float v4; // ST20_4
9 d7 P, H9 z; M$ B5 Z9 ?: w - float v5; // ST24_4# n# N V7 q) T R% [
- int result; // eax, I$ v! e- N Y, ?
1 T& }0 Y8 u+ B2 l- v0 = 0;7 n& D/ G W* Z9 M0 v
- dword_4DF5130 = glGenLists(272);
0 X: g. l' d; @% j6 b8 X - do
# y. Y) Z$ t) Z" Z* M - {1 ]8 K# r8 z2 _. A1 P% v" b3 ?
- v2 = (double)(v0 % -16) * flt_483450;! l: [8 g5 N$ p" F0 ?8 F
- v3 = (double)(v0 / 16) * flt_483450;
m2 c9 Z! C/ y z7 c/ ?2 } - glNewList(v1, v0 % 16, v0 + dword_4DF5130, 4864);
, ` Z( Y5 }9 B3 a0 Z F) z - glBegin(7);
/ u- ~. n& ? K" W3 a - glTexCoord2f(LODWORD(v2), LODWORD(v3));$ \3 n8 s, ?4 \
- glVertex2i(0, 0);
8 `+ l7 |* W/ p' D - v4 = v2 + flt_483450;: `4 z- k4 v" e
- glTexCoord2f(LODWORD(v4), LODWORD(v3));
! b: v& l" {( M+ m# y! L - glVertex2i(16, 0);" O- Y' R( Z3 h4 _, J: |& {# T9 W* ?
- v5 = v3 + flt_483454;
! o0 B \( S1 L# [/ b$ G# y - glTexCoord2f(LODWORD(v4), LODWORD(v5));; I! {8 t+ |* \+ E$ `4 v, `
- glVertex2i(16, 16);' W, `# u f! a; z' b! R
- glTexCoord2f(LODWORD(v2), LODWORD(v5));* o& M T, Q# N/ ^
- glVertex2i(0, 16);5 ~! {' \2 P7 l9 j0 t6 b0 K9 N* j- [2 b
- glEnd();
3 h; n- X' n. o ?: K2 i* E - ++v0;
/ i% Z% Q8 ]% \" W0 r - glTranslated(0, 1076101120, 0, 0, 0, 0);
. o. A( {5 O) R, \ - result = glEndList();
2 e6 \( |! Q& ~5 R% X" { e# e - }5 Y3 {# S1 k' c
- while ( v0 < 272 );
' k' q5 D+ N* T - return result;
0 x5 G7 ^; P+ F: e* ~ ]% z. B - }
复制代码 3 s' M# m. Q; h: i; h& f# p
- C* r4 x! F5 a5 `' ^! a
对glCallList的调用只有以下一处,
- m8 ]1 y* n) N) c这是显示单个字符还是字符串的方法,待以后再确认。: _6 i b$ n2 x& T+ m8 t2 R
glCallLists(strlen(&v7), 5121, &v7);' `: [* i' x) E/ C/ T1 ]& g" Q
5121为0x1401 ,即 GL_UNSIGNED_BYTE ,是单字节。
% m: c, b! | @, ]
" \+ I* N! V! k7 B" Z7 J! p z- #define GL_BYTE 0x1400
( O" u: z$ l( G( s - #define GL_UNSIGNED_BYTE 0x1401
( J7 k2 v2 e; G4 A D - #define GL_SHORT 0x1402
" V" K5 `* \/ ^+ U6 @1 n - #define GL_UNSIGNED_SHORT 0x1403. E% t7 q: I, `6 [
- #define GL_INT 0x1404/ f U' a" T# f. a# t
- #define GL_UNSIGNED_INT 0x1405
6 R1 |6 w3 R/ w/ \" B7 B3 ` - #define GL_FLOAT 0x14060 C! W% z. J1 z5 D
- #define GL_2_BYTES 0x1407
" X p1 b" c2 j3 E - #define GL_3_BYTES 0x14080 {$ S: t/ U. @9 e2 N, W" D
- #define GL_4_BYTES 0x14092 l) |1 k$ G9 w- n. z
- #define GL_DOUBLE 0x140A
复制代码 * N/ O l" R8 t2 I! q+ K/ F9 H
M: Z: Q8 M% ^
) q$ z. V9 T, q( y2 K7 _1 Y0 b- int __cdecl sub_40BFD0(signed int a1, int a2, int a3, int a4, char a5). C5 M2 g% Y0 t) L, E( s
- {3 [) k9 y0 Z Z [
- int v5; // ecx
; s. O5 @ w- V: c. i1 N$ \ H$ g - int result; // eax1 g* J1 [4 t, V
- char v7; // [esp+18h] [ebp-118h]0 A; b- f' j& S8 C
- char *v8; // [esp+118h] [ebp-18h], }! G! U- W* g, p
- int v9; // [esp+11Ch] [ebp-14h]' V! ]! ?3 O, E/ i8 b: Z. q) k
- int v10; // [esp+128h] [ebp-8h]
6 N8 M9 N* B3 S! J; u/ V
0 N7 q D$ K/ `9 A3 a6 q- v10 = v5;
7 \6 e" b# A k7 ?9 R2 K$ m - if ( a4 )0 l% ~1 G0 F* A6 ]9 T M2 X8 \
- {
+ {8 s2 M7 m7 F - v8 = &a5;
; m7 ~8 f: q: U0 n \' y - sub_41BA00(v5, a4);/ M# y6 p' R+ `
- v8 = 0;
+ ? W6 b; t1 w# y z - glBlendFunc(770, 771);
, L. x7 {8 E- A; m; n - glBindTexture(3553, dword_4DF3BC4[8 * a3]);
* Y7 r. p. v) M - glPushMatrix();$ ?9 u. B" H% v. j. Q9 t5 U
- glLoadIdentity();
: `* X' s, J$ o0 n9 F9 t - v9 = a1;% O, i% ~/ \8 q
- glTranslated(
$ x6 [. P6 R% s* K( P2 a - COERCE_UNSIGNED_INT64((double)a1),* I! s" D& T' Z
- COERCE_UNSIGNED_INT64((double)a1) >> 32,5 W) w& U* X& O( j
- COERCE_UNSIGNED_INT64((double)(dword_4DF8B68 - a2)),* k% Z3 }" w6 G; ]' d5 k& m1 n$ E
- COERCE_UNSIGNED_INT64((double)(dword_4DF8B68 - a2)) >> 32,
% X# E# y' t7 Q8 V. k+ T0 C - 0,
/ Z. f' u6 F: a* q4 O. L - 0);: L: E: g B5 A2 m' r/ Q
- glPushAttrib(0x20000);1 k0 o4 Y s7 L% f
- glListBase(dword_4DF5130 + 16);; o+ A+ n. t7 O2 I8 w
- glCallLists(strlen(&v7), 5121, &v7); ^! \. v( `1 `
- glPopAttrib();, \1 N4 T/ A; a+ n! ]% F* z' H
- result = glPopMatrix();, f+ p' E. r7 t! D' T( `- S( G
- }$ t2 \% E" ^, C. I3 s& U$ v
- return result;4 f0 e* B6 H8 l
- }7 P: ]9 A5 O' c7 d& V
复制代码 : t4 t# k% b9 E0 w- o# p: c
# L! a; _* O R1 W
7 Z9 _. ]% m3 s* P+ i |