Skip to content

Commit

Permalink
Significant re-engineering of try/catch to generate more reliable min…
Browse files Browse the repository at this point in the history
…idumps.
  • Loading branch information
friendlyfire committed May 5, 2016
1 parent 8ccae87 commit 6d096f3
Show file tree
Hide file tree
Showing 35 changed files with 146 additions and 130 deletions.
Binary file modified bin-vc14/FLHook.dll
Binary file not shown.
Binary file modified bin-vc14/FLHook.pdb
Binary file not shown.
Binary file modified bin-vc14/flhook_plugins/ahookext.dll
Binary file not shown.
Binary file modified bin-vc14/flhook_plugins/ahookext.pdb
Binary file not shown.
Binary file modified bin-vc14/flhook_plugins/base.dll
Binary file not shown.
Binary file modified bin-vc14/flhook_plugins/base.pdb
Binary file not shown.
Binary file modified bin-vc14/flhook_plugins/cloak.dll
Binary file not shown.
Binary file modified bin-vc14/flhook_plugins/cloak.pdb
Binary file not shown.
Binary file modified bin-vc14/flhook_plugins/condata.dll
Binary file not shown.
Binary file modified bin-vc14/flhook_plugins/condata.pdb
Binary file not shown.
Binary file modified bin-vc14/flhook_plugins/conn.dll
Binary file not shown.
Binary file modified bin-vc14/flhook_plugins/conn.pdb
Binary file not shown.
Binary file modified bin-vc14/flhook_plugins/event.dll
Binary file not shown.
Binary file modified bin-vc14/flhook_plugins/event.pdb
Binary file not shown.
Binary file modified bin-vc14/flhook_plugins/minecontrol.dll
Binary file not shown.
Binary file modified bin-vc14/flhook_plugins/minecontrol.pdb
Binary file not shown.
Binary file modified bin-vc14/flhook_plugins/mobiledock.dll
Binary file not shown.
Binary file modified bin-vc14/flhook_plugins/mobiledock.pdb
Binary file not shown.
Binary file modified bin-vc14/flhook_plugins/playercntl.dll
Binary file not shown.
Binary file modified bin-vc14/flhook_plugins/playercntl.pdb
Binary file not shown.
Binary file modified bin-vc14/flhook_plugins/tempban.dll
Binary file not shown.
Binary file modified bin-vc14/flhook_plugins/tempban.pdb
Binary file not shown.
Binary file modified plugins/flhookplugin_sdk/libs/FLHook-vc14.lib
Binary file not shown.
2 changes: 1 addition & 1 deletion plugins/playercntl_plugin/src/PluginUtilities.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ void HkLoadStringDLLs();
void HkUnloadStringDLLs();
wstring HkGetWStringFromIDS(uint iIDS);

void AddExceptionInfoLog(LPEXCEPTION_POINTERS pep);
void AddExceptionInfoLog(struct SEHException* pep);
#define LOG_EXCEPTION { AddLog("ERROR Exception in %s", __FUNCTION__); AddExceptionInfoLog(0); }

CAccount* HkGetAccountByClientID(uint iClientID);
Expand Down
5 changes: 3 additions & 2 deletions project-vc14/FLHook.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ copy /Y $(OutDir)$(TargetName).lib ..\plugins\flhookplugin_sdk\libs\$(TargetNa
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
</ClCompile>
<Link>
<AdditionalDependencies>Ws2_32.lib;psapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>Ws2_32.lib;psapi.lib;dbghelp.lib;%(AdditionalDependencies)</AdditionalDependencies>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Windows</SubSystem>
<OptimizeReferences>true</OptimizeReferences>
Expand All @@ -127,7 +127,8 @@ copy /Y $(OutDir)$(TargetName).lib ..\plugins\flhookplugin_sdk\libs\$(TargetNa
<TargetMachine>MachineX86</TargetMachine>
</Link>
<PostBuildEvent>
<Command />
<Command>copy /Y $(OutDir)$(TargetName).dll C:\FWDev\Freeworlds-public\exe\
copy /Y $(OutDir)$(TargetName).pdb C:\FWDev\Freeworlds-public\exe\</Command>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemGroup>
Expand Down
10 changes: 4 additions & 6 deletions source/FLHook.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,8 @@ BYTE oldSetUnhandledExceptionFilter[5];
LONG WINAPI FLHookTopLevelFilter(struct _EXCEPTION_POINTERS *pExceptionInfo)
{
AddLog("!!TOP LEVEL EXCEPTION!!");
WriteMiniDump(pExceptionInfo);
SEHException ex(0, pExceptionInfo);
WriteMiniDump(&ex);
return EXCEPTION_EXECUTE_HANDLER; // EXCEPTION_CONTINUE_SEARCH;
}

Expand Down Expand Up @@ -643,7 +644,7 @@ struct timeval tv = {0, 0};

void ProcessPendingCommands()
{
try {
TRY_HOOK {
// check for new console commands
EnterCriticalSection(&cs);
while(lstConsoleCmds.size())
Expand Down Expand Up @@ -852,8 +853,5 @@ void ProcessPendingCommands()
}

lstDelete.clear();
} catch(...) {
LOG_EXCEPTION
throw "exception";
}
} CATCH_HOOK({})
}
4 changes: 2 additions & 2 deletions source/HkCbChat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ void __stdcall HkCb_SendChat(uint iClientID, uint iTo, uint iSize, void *pRDL)
CALL_PLUGINS_V(PLUGIN_HkCb_SendChat,__stdcall,(uint,uint,uint,void*),(iClientID,iTo,iSize,pRDL));


try {
TRY_HOOK {
if(HkIServerImpl::g_bInSubmitChat && (iTo != 0x10004)) {
wchar_t wszBuf[1024] = L"";
// extract text from rdlReader
Expand Down Expand Up @@ -120,5 +120,5 @@ void __stdcall HkCb_SendChat(uint iClientID, uint iTo, uint iSize, void *pRDL)
popad
}
}
} catch(...) { LOG_EXCEPTION }
} CATCH_HOOK({})
}
13 changes: 6 additions & 7 deletions source/HkCbDamage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ int __stdcall HkCB_MissileTorpHit(char *ECX, char *p1, DamageList *dmg)

CALL_PLUGINS(PLUGIN_HkCB_MissileTorpHit,int,__stdcall,(char*,char*,DamageList*),(ECX,p1,dmg));

try {
TRY_HOOK {
// get client id
char *szP;
memcpy(&szP, ECX + 0x10, 4);
Expand Down Expand Up @@ -48,7 +48,7 @@ int __stdcall HkCB_MissileTorpHit(char *ECX, char *p1, DamageList *dmg)
dmg->set_cause((enum DamageCause)0xC0); // change to sth else, so client won't recognize it as a disruptor
}
}
} catch(...) { LOG_EXCEPTION }
} CATCH_HOOK({})
return 0;
}

Expand Down Expand Up @@ -119,7 +119,7 @@ void __stdcall HkCb_AddDmgEntry(DamageList *dmgList, unsigned short p1, float p2
else
dmgList->add_damage_entry(p1, p2, p3);

try {
TRY_HOOK {
LastDmgList = *dmgList; // save

// float fHealth,fMaxHealth;32 256
Expand All @@ -141,7 +141,7 @@ void __stdcall HkCb_AddDmgEntry(DamageList *dmgList, unsigned short p1, float p2
}


} catch(...) { LOG_EXCEPTION }
} CATCH_HOOK({})

CALL_PLUGINS_V(PLUGIN_HkCb_AddDmgEntry_AFTER,__stdcall,(DamageList *,unsigned short,float, DamageEntry::SubObjFate),(dmgList,p1,p2,p3));

Expand Down Expand Up @@ -175,7 +175,7 @@ void __stdcall HkCb_GeneralDmg(char *szECX)

CALL_PLUGINS_V(PLUGIN_HkCb_GeneralDmg,__stdcall,(char*),(szECX));

try {
TRY_HOOK {
char *szP;
memcpy(&szP, szECX + 0x10, 4);
uint iClientID;
Expand All @@ -185,8 +185,7 @@ void __stdcall HkCb_GeneralDmg(char *szECX)

iDmgTo = iClientID;
iDmgToSpaceID = iSpaceID;
}
catch (...) { LOG_EXCEPTION }
} CATCH_HOOK({})
}

__declspec(naked) void _HkCb_GeneralDmg()
Expand Down
4 changes: 2 additions & 2 deletions source/HkCbDeath.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ void __stdcall ShipDestroyed(DamageList *_dmg, DWORD *ecx, uint iKill)

CALL_PLUGINS_V(PLUGIN_ShipDestroyed,__stdcall,(DamageList *_dmg, DWORD *ecx, uint iKill),(_dmg,ecx,iKill));

try {
TRY_HOOK {
if(iKill==1)
{
CShip *cship = (CShip*)ecx[4];
Expand Down Expand Up @@ -252,7 +252,7 @@ void __stdcall ShipDestroyed(DamageList *_dmg, DWORD *ecx, uint iKill)
ClientInfo[iClientID].iShipOld = ClientInfo[iClientID].iShip;
ClientInfo[iClientID].iShip = 0;
}
} catch(...) { LOG_EXCEPTION }
} CATCH_HOOK({})
}

FARPROC fpOldShipDestroyed;
Expand Down
4 changes: 2 additions & 2 deletions source/HkCbDisconnect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@

int __stdcall DisconnectPacketSent(uint iClientID)
{
try {
TRY_HOOK {
uint iShip = 0;
pub::Player::GetShip(iClientID, iShip);
if(set_iDisconnectDelay && iShip)
{ // in space
ClientInfo[iClientID].tmF1TimeDisconnect = timeInMS() + set_iDisconnectDelay;
return 0; // don't pass on
}
} catch(...) { LOG_EXCEPTION }
} CATCH_HOOK({})
return 1; // pass on
}

Expand Down
4 changes: 2 additions & 2 deletions source/HkCbIEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,9 @@ int __cdecl Dock_Call(unsigned int const &uShipID,unsigned int const &uSpaceID,i

CALL_PLUGINS(PLUGIN_HkCb_Dock_Call,int,,(unsigned int const &,unsigned int const &,int,DOCK_HOST_RESPONSE),(uShipID,uSpaceID,p3,p4));

try {
TRY_HOOK {
return pub::SpaceObj::Dock(uShipID,uSpaceID,p3,p4);
} catch(...) { LOG_EXCEPTION }
} CATCH_HOOK({})

CALL_PLUGINS(PLUGIN_HkCb_Dock_Call_AFTER, int, , (unsigned int const &, unsigned int const &, int, DOCK_HOST_RESPONSE), (uShipID, uSpaceID, p3, p4));

Expand Down
Loading

0 comments on commit 6d096f3

Please sign in to comment.