Commit 64ef34c5 by 李定达

1.导出RESGetValue和GetValue

parent 966d9fa2
Debug/
Release/
*.ipch
*.sdf
#include <stdio.h>
#include <Windows.h>
#include <Winbase.h>
#include <string>
#pragma comment(lib, "Kernel32.lib")
EXTERN_C IMAGE_DOS_HEADER __ImageBase;
#define FMPDLL "fmclient.dll"
//#define FMCRYPT "fmcrypt.dll"
#define LIBCURL "libcurl.dll"
#define LIBEAY32 "libeay32.dll"
#define LIBIDN "libidn-11.dll"
#define SSLEAY32 "ssleay32.dll"
#define ZLIB1 "zlib1.dll"
#define SQLITE "sqlite3.dll"
#define FMPDLLR "fmclientR.dll"
//#define FMCRYPTR "fmcryptR.dll"
#define LIBCURLR "libcurlR.dll"
#define LIBEAY32R "libeay32R.dll"
#define LIBIDNR "libidn-11R.dll"
#define SSLEAY32R "ssleay32R.dll"
#define ZLIB1R "zlib1R.dll"
#define SQLITER "sqlite3R.dll"
void DoCopyFile(const char *dir);
EXTERN_C typedef int (_stdcall *PFN_GETVALUE)(char *, char *);
EXTERN_C typedef int (_stdcall *PFN_RESGETVALUE)(char *, char *);
int init_sign = 0;
HMODULE GetInstance()
{
char current_dir[MAX_PATH] = { 0 };
if (0 < GetCurrentDirectoryA(MAX_PATH, current_dir)) {
char mod[MAX_PATH] = { 0 };
GetModuleFileNameA((HMODULE)&__ImageBase, mod, MAX_PATH);
char *ch = strrchr(mod,'\\');
if (ch++) {
*ch = '\0';
}
printf("Current directory: %s\nModule path: %s\n", current_dir, mod);
printf("Changing current to: %s\n", mod);
SetCurrentDirectory(mod);
char instance[MAX_PATH] = { 0 };
sprintf(instance, "%s%s", mod, FMPDLL);
if(init_sign == 0)
DoCopyFile(mod);
init_sign = 1;
HMODULE hMod = LoadLibraryA(instance);
printf("Changing current to: %s\n", current_dir);
SetCurrentDirectory(current_dir);
return hMod;
}
return NULL;
}
void DoCopyFile(const char *dir)
{
char inskt[MAX_PATH] = { 0 };
//char fmcrypt[MAX_PATH] = { 0 };
char libcurl[MAX_PATH] = { 0 };
char libeay32[MAX_PATH] = { 0 };
char libidn[MAX_PATH] = { 0 };
char ssleay32[MAX_PATH] = { 0 };
char zlib1[MAX_PATH] = { 0 };
char insktr[MAX_PATH] = { 0 };
char fmcryptr[MAX_PATH] = { 0 };
char libcurlr[MAX_PATH] = { 0 };
char libeay32r[MAX_PATH] = { 0 };
char libidnr[MAX_PATH] = { 0 };
char ssleay32r[MAX_PATH] = { 0 };
char zlib1r[MAX_PATH] = { 0 };
char sqlite[MAX_PATH] = { 0 };
char sqliter[MAX_PATH] = { 0 };
sprintf(inskt, "%s%s", dir, FMPDLL);
//sprintf(fmcrypt, "%s%s", dir, FMCRYPT);
sprintf(libcurl, "%s%s", dir, LIBCURL);
sprintf(libeay32, "%s%s", dir, LIBEAY32);
sprintf(libidn, "%s%s", dir, LIBIDN);
sprintf(ssleay32, "%s%s", dir, SSLEAY32);
sprintf(zlib1, "%s%s", dir, ZLIB1);
sprintf(insktr, "%s%s", dir, FMPDLLR);
sprintf(sqlite, "%s%s", dir, SQLITE);
//sprintf(fmcryptr, "%s%s", dir, FMCRYPTR);
sprintf(libcurlr, "%s%s", dir, LIBCURLR);
sprintf(libeay32r, "%s%s", dir, LIBEAY32R);
sprintf(libidnr, "%s%s", dir, LIBIDNR);
sprintf(ssleay32r, "%s%s", dir, SSLEAY32R);
sprintf(zlib1r, "%s%s", dir, ZLIB1R);
sprintf(sqliter, "%s%s", dir, SQLITER);
CopyFile(insktr, inskt, false);
//CopyFile(fmcryptr, fmcrypt, false);
CopyFile(libcurlr, libcurl, false);
CopyFile(libeay32r, libeay32, false);
CopyFile(libidnr, libidn, false);
CopyFile(ssleay32r, ssleay32, false);
CopyFile(zlib1r, zlib1, false);
CopyFile(sqliter, sqlite, false);
}
extern "C"{
__declspec(dllexport) int _stdcall GetValue(char *indata, char *outdata)
{
HMODULE hMod = GetInstance();
if (hMod) {
PFN_GETVALUE pfn_GetValue = (PFN_GETVALUE)GetProcAddress(hMod, "_GetValue@8");
if (pfn_GetValue) {
return pfn_GetValue(indata, outdata);
}
FreeLibrary(hMod);
}
return -1;
}
__declspec(dllexport) int _stdcall RESGetValue(char *indata, char *outdata)
{
HMODULE hMod = GetInstance();
if (hMod) {
PFN_RESGETVALUE pfn_GetValue = (PFN_GETVALUE)GetProcAddress(hMod, "_RESGetValue@8");
if (pfn_GetValue) {
return pfn_GetValue(indata, outdata);
}
FreeLibrary(hMod);
}
return -1;
}
};
\ No newline at end of file

Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FreemudWrapper", "FreemudWrapper.vcxproj", "{3AE5812C-93BD-444F-9766-DD042450BFF9}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Release|Win32 = Release|Win32
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{3AE5812C-93BD-444F-9766-DD042450BFF9}.Debug|Win32.ActiveCfg = Debug|Win32
{3AE5812C-93BD-444F-9766-DD042450BFF9}.Debug|Win32.Build.0 = Debug|Win32
{3AE5812C-93BD-444F-9766-DD042450BFF9}.Release|Win32.ActiveCfg = Release|Win32
{3AE5812C-93BD-444F-9766-DD042450BFF9}.Release|Win32.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{3AE5812C-93BD-444F-9766-DD042450BFF9}</ProjectGuid>
<RootNamespace>FreemudWrapper</RootNamespace>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>MultiByte</CharacterSet>
<UseOfMfc>Static</UseOfMfc>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>MultiByte</CharacterSet>
<UseOfMfc>Static</UseOfMfc>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup />
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="FreemudWrapper.cpp" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="源文件">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="头文件">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
</Filter>
<Filter Include="资源文件">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="FreemudWrapper.cpp">
<Filter>源文件</Filter>
</ClCompile>
</ItemGroup>
</Project>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LocalDebuggerCommand>C:\Users\ldd\Desktop\博朗\新建文件夹\sbkdlltest.exe</LocalDebuggerCommand>
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LocalDebuggerCommand>C:\Users\ldd\Desktop\博朗\新建文件夹\sbkdlltest.exe</LocalDebuggerCommand>
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
</PropertyGroup>
</Project>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment