View Single Post
Old 04-10-2019, 03:11
chants chants is offline
Join Date: Jul 2016
Posts: 559
Rept. Given: 6
Rept. Rcvd 35 Times in 21 Posts
Thanks Given: 472
Thanks Rcvd at 835 Times in 392 Posts
chants Reputation: 35
It is strange because I see no references to those structures at the end in the code. The comments in the code seem to be inferred somehow from those data structures. Perhaps the compiler optimized out the try-catch already and just left in some extra metadata.

RTTI is Run-time Type Information, its basically a reflection metadata system for C++ especially for class hierarchy identification to allow for virtual destructors and the like. It does not necessarily mean it was referenced in the code as I think its merely a compiler option. Please refer to MSDN or even here:
So the real keys here are about compiler optimizations and whether they already optimized out unnecessary SEH, and whether the compiler is included extra and unneeded SEH data. Regardless, to resurrect the original source accurately, you would want to bring back those useless optimized out code and so this is definetely a bonus to have the information.

I don't understand the question further as the first dump shows where a try { block starts and also gives a comment as to its end so it should be easy for you to add those to your clone function. You can basically merge the contiguous try blocks as the close brace is misleading. There is just one try and one catch.

.text:10038B34 ;   try {
.text:10038C4F ;   } // starts at 10038B34
.text:10038C55 ;   try {
.text:10038C78 ;   } // starts at 10038C55
.text:10038C7E ;   try {
.text:10038D28 ;   } // starts at 10038C7E
.text:10038D2E ;   try {
.text:10038D38 ;   catch(ErrorClass) // owned by 10038B34
.text:10038D38 ;   catch(ErrorClass) // owned by 10038C55
.text:10038D6B ;   } // starts at 10038D2E
Basically because of the structure you already put in the clone you cannot match this easily. However again knowing what is safe and non-safe of the calls is crucial and the compiler theoretically uses heuristics to deduce and optimize based on this.

Possibly you just wrap the entire code block you show up to W3dExportClass::PrintTotalVertexCount(); in:
try {
 (original clone)
} catch (ErrorClass* ec) {
//.text:10038D38                 mov     esi, [ebp+i] really [ebp+0x10] so some error class with a zero terminated ascii string at 0x10 bytes in which we call szMessage 
  MessageBox(NULL, ec->szMessage, "Error", MB_SETFOREGROUND); //0x10000=MB_SETFOREGROUND
//.text:10038D5F                 mov     eax, offset loc_10038D65
The problem is you need to invert your control flow and return early or use goto's very similar to the way Microsoft does in a lot of their source code for large functions...
if ( !r.Open(2) ) {
  MessageBoxA(NULL, "Unable to open file.", "Error", MB_SETFOREGROUND);
  return 1; //or goto return_loc
//...return_loc: return 1;
if ( !(W3DExportClass::DoExportDialog(this, suppressPrompts)
    && (this->ExportStruct.ExportSkeleton || this->ExportStruct.ExportAnimation || this->ExportStruct.ExportGeometry)) ) return 1; //or goto return_loc

Last edited by chants; 04-10-2019 at 03:34.
Reply With Quote
The Following User Says Thank You to chants For This Useful Post:
Indigo (07-19-2019)