We need hook "GL_LoadTexture" engine function.

GL_LOADTEXTURE_SIG from hw.dll(3266) engine, can not use for other engine version.

 #include <metahook.h>
#include "qgl.h"
#include "surface.h" extern DWORD g_dwEngineBase, g_dwEngineSize; #define GL_LOADTEXTURE_SIG "\xA1\xC8\x20\xEC\x01\x8B\x4C\x24\x20\x8B\x54\x24\x1C\x50\x8B\x44" int (*g_pfnGL_LoadTexture)(char *identifier, int textureType, int width, int height, BYTE *data, int mipmap, int iType, BYTE *pPal) = ; int GL_LoadTexture(char *identifier, int textureType, int width, int height, BYTE *data, int mipmap, int iType, BYTE *pPal)
{
if (width > || height > )
{
static BYTE buffer[ * * ]; for (DWORD i = ; i < width * height; ++i)
{
buffer[(i * ) + ] = pPal[(data[i] * ) + ];
buffer[(i * ) + ] = pPal[(data[i] * ) + ];
buffer[(i * ) + ] = pPal[(data[i] * ) + ];
} int id = g_pSurface->CreateNewTextureID(); qglBindTexture(GL_TEXTURE_2D, id);
qglTexImage2D(GL_TEXTURE_2D, , GL_RGB, width, height, , GL_RGB, GL_UNSIGNED_BYTE, buffer);
qglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
qglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); return id;
} return g_pfnGL_LoadTexture(identifier, textureType, width, height, data, mipmap, iType, pPal);
} void Hook_InstallHook(void)
{
g_pfnGL_LoadTexture = (int (*)(char *, int, int, int, BYTE *, int, int, BYTE *))g_pMetaHookAPI->SearchPattern((void *)g_dwEngineBase, g_dwEngineSize, GL_LOADTEXTURE_SIG, sizeof(GL_LOADTEXTURE_SIG) - ); if (g_pfnGL_LoadTexture)
{
g_pMetaHookAPI->InlineHook(g_pfnGL_LoadTexture, GL_LoadTexture, (void *&)g_pfnGL_LoadTexture);
}
}

[MetaHook] Load large texture from model的更多相关文章

  1. [MetaHook] Load TGA texture to OpenGL

    This function load a *.tga texture file and convert to OpenGL pixel format, uncompress only. #pragma ...

  2. [MetaHook] Load DTX texture to OpenGL

    This function load a LithTech *.dtx texture file and convert to OpenGL pixel format, compressed supp ...

  3. Projective Texture的原理与实现

    http://blog.csdn.net/xukunn1226/article/details/775644 Projective Texture是比较常见的一种技术,实现起来代码也就区区的不过百行, ...

  4. Introducing DataFrames in Apache Spark for Large Scale Data Science(中英双语)

    文章标题 Introducing DataFrames in Apache Spark for Large Scale Data Science 一个用于大规模数据科学的API——DataFrame ...

  5. Projective Texture的原理与实现 【转】

              Projective Texture是比较常见的一种技术,实现起来代码也就区区的不过百行,了解其原理及技术细节是我们的重点,知其然,知其所以然.        粗略的说就是想象场景 ...

  6. "NHibernate.Exceptions.GenericADOException: could not load an entity" 解决方案

     今天,测试一个项目的时候,抛出了这个莫名其妙的异常,然后就开始了一天的调试之旅... 花了很长时间,没有从代码找出任何问题... 那么到底哪里出问题呢? 根据下面那段长长的错误日志: -- ::, ...

  7. ExtJS笔记 Ext.data.Model

    A Model represents some object that your application manages. For example, one might define a Model ...

  8. UnityException: Texture is not readable

    原地址:http://blog.csdn.net/emoonight/article/details/18002913 fore you can save or load a Texture, you ...

  9. yii2 model源码解读

    模型yii\base\Model 模型主要实现了验证规则和验证器确保输入的数据是安全和正确的. 模型的流程: 1.从请求中读取数据.使用load或者loadMultiple或者手动赋值.load会根据 ...

随机推荐

  1. Swift随记

    进一步理解swift拆包和解包(如有问题,大神请指教):!作用是拆包,?作用是压包(也许没有压包这个词,实际上就是转为optional类型),不管是!还是?其实都是类型转换的过程.swift语言在类型 ...

  2. DP大作战—组合背包

    题目描述 组合背包:有的物品只可以取一次(01背包),有的物品可以取无限次(完全背包),有的物品可以取的次数有一个上限(多重背包). DD大牛的伪代码 for i = 1 to N if 第i件物品属 ...

  3. Windows Form小技巧

    如果需要将两个控件在窗体上使用Dock来进行布局时,会出现Dock.Fill不会占据Dock.Bottom之外空间的情况,这时可以设置Dock.Fill的控件BringToFront, 这样使得控件最 ...

  4. Mysql中的视图

    什么是视图 通俗的讲,视图就是一条SELECT语句执行后返回的结果集.所以我们在创建视图的时候,主要的工作就落在创建这条SQL查询语句上. 视图的特性 视图是对若干张基本表的引用,一张虚表,查询语句执 ...

  5. python yield

    http://www.jb51.net/article/15717.htm  这里还不错 只是粗略的知道yield可以用来为一个函数返回值塞数据,比如下面的例子: def addlist(alist) ...

  6. JavaScript Patterns 2.12 Writing API Docs

    Free and open source tools for doc generation: the JSDoc Toolkit (http://code.google.com/p/jsdoc-too ...

  7. tair源码分析——leveldb存储引擎使用

    分析完leveldb以后,接下来的时间准备队tair的源码进行阅读和分析.我们刚刚分析完了leveldb而在tair中leveldb是其几大存储引擎之一,所以我们这里首先从tair对leveldb的使 ...

  8. 问题解决——XP线程池找不到QueueUserWorkItem

    2013年7月11号 主管让同事写一个并发100的小工具进行什么压力测试,据说是创建100个线程. 我表示这真真的是在坑人! 线程创建消耗资源,以自己的笔记本来跑这个东西,时间片都消耗在了线程切换上了 ...

  9. Apache Kafka - Quick Start on Windows

    在这篇文章中,我将要介绍如何搭建和使用Apache Kafka在windows环境.在开始之前,简要介绍一下Kafka,然后再进行实践. Apache Kafka Kafka是分布式的发布-订阅消息的 ...

  10. IP工具类-自己动手做个ip解析器

    IP工具类-自己动手做个ip解析器 一.资料准备 导入依赖包: