_BLOCK_TYPE_IS_VALID(phead->nBlockUse) on Calling HkGetPlayerInfo in plugin
-
Hi, All, im working on my plugin for flhook now, and get into a big trouble, when i call HkGetPlayerInfo in my plugin, FLServer will crash.
Here is a example:
namespace HkIServerImpl
{EXPORT void __stdcall PlayerLaunch(unsigned int iShip, unsigned int iClientID)
{
returncode = DEFAULT_RETURNCODE;wstring wscCharname = L"a";
HKPLAYERINFO pi;
if(HKHKSUCCESS(HkGetPlayerInfo(wscCharname, pi, false)))
ConPrint(L"Got\n");
else
ConPrint(L"Can’t\n");
}
}i logon with player “a”, console show Got then FLServer crash. that is why? and how can i fix it?
-
strange, this also crash:
namespace HkIServerImpl
{EXPORT void __stdcall PlayerLaunch(unsigned int iShip, unsigned int iClientID)
{
returncode = DEFAULT_RETURNCODE;wstring wscCharname = Players.GetActiveCharacterName(iClientID);
wstring wscUniqueAccID, wscUniqueCharID;HkGetAccountDirName(wscCharname, wscUniqueAccID);
HkGetCharFileName(wscCharname, wscUniqueCharID);ConPrint(L" “);
ConPrint(wscUniqueAccID);
ConPrint(L” “);
ConPrint(wscUniqueCharID);
ConPrint(L”\n");
}
}The wscUniqueAccID successful show up on console, then flserver crash with _BLOCK_TYPE_IS_VALID.
-
see the plugin documentation readme:
IMPORTANT NOTE: If you want to debug your plugins and you are using STL classes
that are being shared with FLHook (i.e. FLHook allocates a string and your
plugin deallocates it) you NEED to make sure you set the compiler to use the
“Multi-threaded DLL (/MD)” runtime library (in VC C++ project settings under
“Code Generation”), otherwise you will get debug assertion crashes! You can also
compile FLHook in debug mode and then also compile your plugin with “Multi-
threaded Debug DLL (/MDd)”. Just make sure, whatever runtime library setting you
use, it must match the one of FLHook.Long story short, you need to compile plugins with /MD if you will be using shared classes like strings (you pass them to FLHook, then it crashes because the std libs are compiled differently)
-
all is default, and strange, when i change Debug (Win32) to Release (Win32) and build project, it will working normally….what happen?
<visualstudioproject<br>ProjectType=“Visual C++”
Version=“7.10”
Name=“My Plugin For FLHook”
ProjectGUID=“{01DE3D3D-0DA2-447E-8C03-B2A2FB03A0F5}”
RootNamespace=“My Plugin For FLHook”
Keyword=“Win32Proj”>
<platforms><platform<br>Name=“Win32”/></platform<br></platforms>
<configurations><configuration<br>Name=“Debug|Win32”
OutputDirectory=“Debug”
IntermediateDirectory=“Debug”
ConfigurationType=“2”
UseOfMFC=“0”
CharacterSet=“2”>
<tool<br>Name=“VCCLCompilerTool”
Optimization=“0”
PreprocessorDefinitions=“WIN32;_DEBUG;_WINDOWS;_USRDLL;FLHOOKWEBFRONTPLUGIN_EXPORTS”
MinimalRebuild=“TRUE”
BasicRuntimeChecks=“3”
RuntimeLibrary=“1”
UsePrecompiledHeader=“0”
WarningLevel=“3”
Detect64BitPortabilityProblems=“TRUE”
DebugInformationFormat=“4”/>
<tool<br>Name=“VCCustomBuildTool”/>
<tool<br>Name=“VCLinkerTool”
AdditionalDependencies=“./libs/FLHook.lib ./libs/server.lib ./libs/common.lib ./libs/remoteclient.lib ./libs/dalib.lib”
OutputFile=“G:\Games\Freelancer\EXE\flhook_plugins\dlls\Plugin.dll”
LinkIncremental=“2”
GenerateDebugInformation=“TRUE”
ProgramDatabaseFile=“$(OutDir)/Plugin.pdb”
SubSystem=“2”
ImportLibrary=“$(OutDir)/Plugin.lib”
TargetMachine=“1”/>
<tool<br>Name=“VCMIDLTool”/>
<tool<br>Name=“VCPostBuildEventTool”/>
<tool<br>Name=“VCPreBuildEventTool”/>
<tool<br>Name=“VCPreLinkEventTool”/>
<tool<br>Name=“VCResourceCompilerTool”/>
<tool<br>Name=“VCWebServiceProxyGeneratorTool”/>
<tool<br>Name=“VCXMLDataGeneratorTool”/>
<tool<br>Name=“VCWebDeploymentTool”/>
<tool<br>Name=“VCManagedWrapperGeneratorTool”/>
<tool<br>Name=“VCAuxiliaryManagedWrapperGeneratorTool”/><configuration<br>Name=“Release|Win32”
OutputDirectory=“Release”
IntermediateDirectory=“Release”
ConfigurationType=“2”
UseOfMFC=“0”
CharacterSet=“2”>
<tool<br>Name=“VCCLCompilerTool”
PreprocessorDefinitions=“WIN32;NDEBUG;_WINDOWS;_USRDLL;PLUGIN_EXPORTS”
RuntimeLibrary=“2”
UsePrecompiledHeader=“0”
WarningLevel=“3”
Detect64BitPortabilityProblems=“TRUE”
DebugInformationFormat=“3”/>
<tool<br>Name=“VCCustomBuildTool”/>
<tool<br>Name=“VCLinkerTool”
AdditionalDependencies=“./libs/FLHook.lib ./libs/server.lib ./libs/common.lib ./libs/remoteclient.lib ./libs/dalib.lib”
OutputFile=“$(OutDir)/Plugin.dll”
LinkIncremental=“1”
GenerateDebugInformation=“TRUE”
SubSystem=“2”
OptimizeReferences=“2”
EnableCOMDATFolding=“2”
ImportLibrary=“$(OutDir)/Plugin.lib”
TargetMachine=“1”/>
<tool<br>Name=“VCMIDLTool”/>
<tool<br>Name=“VCPostBuildEventTool”/>
<tool<br>Name=“VCPreBuildEventTool”/>
<tool<br>Name=“VCPreLinkEventTool”/>
<tool<br>Name=“VCResourceCompilerTool”/>
<tool<br>Name=“VCWebServiceProxyGeneratorTool”/>
<tool<br>Name=“VCXMLDataGeneratorTool”/>
<tool<br>Name=“VCWebDeploymentTool”/>
<tool<br>Name=“VCManagedWrapperGeneratorTool”/>
<tool<br>Name=“VCAuxiliaryManagedWrapperGeneratorTool”/></tool<br></tool<br></tool<br></tool<br></tool<br></tool<br></tool<br></tool<br></tool<br></tool<br></tool<br></tool<br></tool<br></configuration<br></tool<br></tool<br></tool<br></tool<br></tool<br></tool<br></tool<br></tool<br></tool<br></tool<br></tool<br></tool<br></tool<br></configuration<br></configurations></visualstudioproject<br>