主题
获取模块基地址 - GetModuleBaseAddr
函数简介
获取模块基地址。
接口名称
GetModuleBaseAddrDLL调用
long GetModuleBaseAddr(long instance, long hwnd, string module_name);参数说明
| 参数名 | 类型 | 说明 |
|---|---|---|
| instance | 长整数型 | OLAPlug对象的指针,由 CreateCOLAPlugInterFace 接口生成。 |
| hwnd | 长整数型 | 窗口句柄。 |
| module_name | 字符串 | 模块名。 |
示例
SDK 调用
cpp
#include "OLAPlugServer.h"
OLAPlugServer ola;
long handle = ola.GetModuleBaseAddr(hwnd, "value");csharp
using OLAPlug;
var ola = new OLAPlugServer();
long handle = ola.GetModuleBaseAddr(hwnd, "value");python
from OLAPlugServer import OLAPlugServer
ola = OLAPlugServer()
handle = ola.GetModuleBaseAddr(hwnd, "value")java
import com.olaplug.OLAPlugServer;
OLAPlugServer ola = new OLAPlugServer();
long handle = ola.GetModuleBaseAddr(hwnd, "value");cpp
var ola = com("OlaPlug.OlaSoft")
var handle = ola.GetModuleBaseAddr(hwnd, "value")vbscript
Set ola = CreateObject("OlaPlug.OlaSoft")
handle = ola.GetModuleBaseAddr(hwnd, "value")text
.局部变量 ola, OLAPlug
ola.创建 ()
handle = ola.GetModuleBaseAddr(hwnd, "value")aardio
import OLAPlugServer;
var ola = OLAPlugServer();
var handle = ola.GetModuleBaseAddr(hwnd, "value");text
变量 ola <类型 = OLAPlugServer>
ola = 新建 OLAPlugServer
长整数 handle = ola.GetModuleBaseAddr(hwnd, "value")cpp
#include "OLAPlugServer.h"
OLAPlugServer ola;
long handle = ola.GetModuleBaseAddr(hwnd, "value");原生 DLL 调用
cpp
long instance = CreateCOLAPlugInterFace();
long ptr = GetModuleBaseAddr(instance, hwnd, "value");
if (ptr != 0) {
char buffer[512] = {0};
GetStringFromPtr(ptr, buffer, sizeof(buffer));
FreeStringPtr(ptr);
}csharp
using System.Runtime.InteropServices;
using System.Text;
[DllImport("OLAPlug_x64.dll", CallingConvention = CallingConvention.StdCall)]
static extern long CreateCOLAPlugInterFace();
[DllImport("OLAPlug_x64.dll", CallingConvention = CallingConvention.StdCall)]
static extern int GetStringFromPtr(long ptr, StringBuilder lpString, int size);
[DllImport("OLAPlug_x64.dll", CallingConvention = CallingConvention.StdCall)]
static extern int FreeStringPtr(long ptr);
[DllImport("OLAPlug_x64.dll", CallingConvention = CallingConvention.StdCall)]
static extern int GetStringSize(long ptr);
[DllImport("OLAPlug_x64.dll", CallingConvention = CallingConvention.StdCall)]
static extern long GetModuleBaseAddr(long ola, long hwnd, string module_name);
long instance = CreateCOLAPlugInterFace();
long ptr = GetModuleBaseAddr(instance, hwnd, "value");
if (ptr != 0) {
StringBuilder sb = new StringBuilder(GetStringSize(ptr) + 1);
GetStringFromPtr(ptr, sb, sb.Capacity);
FreeStringPtr(ptr);
string result = sb.ToString();
}python
from ctypes import CDLL, c_int, c_int64, create_string_buffer
ola = CDLL("OLAPlug_x64.dll")
ola.CreateCOLAPlugInterFace.restype = c_int64
instance = ola.CreateCOLAPlugInterFace()
ptr = ola.GetModuleBaseAddr(instance, hwnd, "value")
if ptr:
buf = create_string_buffer(512)
ola.GetStringFromPtr(ptr, buf, 512)
ola.FreeStringPtr(ptr)
result = buf.value.decode("utf-8")返回值
| 返回值 | 说明 |
|---|---|
非 0 | 成功,返回 模块基地址。 |
0 | 失败。 |
