mirror of
https://github.com/sfall-team/int2ssl.git
synced 2026-07-27 16:52:42 -07:00
Code formating
This commit is contained in:
+41
-32
@@ -1,20 +1,8 @@
|
||||
// FalloutScript.cpp : implementation file
|
||||
//
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "FalloutScript.h"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
// Constants
|
||||
//c_strBogusProcedureName = "..............";
|
||||
//c_strArgumentTemplate = "arg%u";
|
||||
//c_strGlobalVarTemplate = "GVar%u";
|
||||
//c_strLocalVarTemplate = "LVar%u";
|
||||
|
||||
|
||||
// CFalloutScript
|
||||
|
||||
CFalloutScript::CFalloutScript()
|
||||
{
|
||||
}
|
||||
@@ -118,37 +106,45 @@ void CFalloutScript::Serialize(CArchive& ar)
|
||||
|
||||
CString strNumOfArgsWarning("Warning: Omitted \"# of argument to \'start\' procedure\"\n");
|
||||
|
||||
if (!HeaderTail.IsEmpty()) {
|
||||
if (!HeaderTail.IsEmpty())
|
||||
{
|
||||
opcode = HeaderTail.at(HeaderTail.GetUpperBound());
|
||||
|
||||
if (opcode.GetOperator() == COpcode::O_CRITICAL_DONE) {
|
||||
if (opcode.GetOperator() == COpcode::O_CRITICAL_DONE)
|
||||
{
|
||||
HeaderTail.RemoveAt(HeaderTail.GetUpperBound());
|
||||
|
||||
if (!HeaderTail.IsEmpty()) {
|
||||
if (!HeaderTail.IsEmpty())
|
||||
{
|
||||
opcode = HeaderTail.at(HeaderTail.GetUpperBound());
|
||||
|
||||
if (opcode.HasArgument()) {
|
||||
if (opcode.HasArgument())
|
||||
{
|
||||
HeaderTail.RemoveAt(HeaderTail.GetUpperBound());
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
printf("\n");
|
||||
printf("%s", strNumOfArgsWarning.c_str());
|
||||
printf("\n");
|
||||
}
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
printf("\n");
|
||||
printf("%s", strNumOfArgsWarning.c_str());
|
||||
printf("\n");
|
||||
}
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
printf("\n");
|
||||
printf("Warning: Omitted expected opcode 0x8003. Opcode with # of arguments will be not analysed\n");
|
||||
printf("\n");
|
||||
}
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
printf("\n");
|
||||
printf("%s", strNumOfArgsWarning.c_str());
|
||||
printf("\n");
|
||||
@@ -169,12 +165,14 @@ void CFalloutScript::Serialize(CArchive& ar)
|
||||
// Global variables
|
||||
printf(" Extract \"Global variables\" section\n");
|
||||
|
||||
for(INT_PTR i = 0; i < HeaderTail.GetSize(); i++) {
|
||||
for(INT_PTR i = 0; i < HeaderTail.GetSize(); i++)
|
||||
{
|
||||
WORD wGlobalVarOperator = HeaderTail.at(i).GetOperator();
|
||||
|
||||
if ((wGlobalVarOperator != COpcode::O_STRINGOP) &&
|
||||
(wGlobalVarOperator != COpcode::O_FLOATOP) &&
|
||||
(wGlobalVarOperator != COpcode::O_INTOP)) {
|
||||
(wGlobalVarOperator != COpcode::O_INTOP))
|
||||
{
|
||||
printf("Error: Malformed \"Global variables\" section\n");
|
||||
AfxThrowUserException();
|
||||
}
|
||||
@@ -213,27 +211,35 @@ void CFalloutScript::ExtractCodeElements(COpcodeArray& Source, COpcodeArray& Des
|
||||
{
|
||||
INT_PTR i = 0;
|
||||
|
||||
for(; i < Source.GetSize(); i++) {
|
||||
if (Source.at(i).GetOperator() == wDelimeter) {
|
||||
for(; i < Source.GetSize(); i++)
|
||||
{
|
||||
if (Source.at(i).GetOperator() == wDelimeter)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (i < Source.GetSize()) {
|
||||
if (i < nSizeOfCodeItem - 1) {
|
||||
if (i < Source.GetSize())
|
||||
{
|
||||
if (i < nSizeOfCodeItem - 1)
|
||||
{
|
||||
printf(lpszErrorMessage);
|
||||
AfxThrowUserException();
|
||||
}
|
||||
|
||||
while(Source.at(i).GetOperator() == wDelimeter) {
|
||||
for(INT_PTR j = 0; j < nSizeOfCodeItem - 1; j++) {
|
||||
if (!((this->*pCheckFunc)(Source.at(i - nSizeOfCodeItem + 1 + j).GetOperator(), j))) {
|
||||
while(Source.at(i).GetOperator() == wDelimeter)
|
||||
{
|
||||
for(INT_PTR j = 0; j < nSizeOfCodeItem - 1; j++)
|
||||
{
|
||||
if (!((this->*pCheckFunc)(Source.at(i - nSizeOfCodeItem + 1 + j).GetOperator(), j)))
|
||||
{
|
||||
printf(lpszErrorMessage);
|
||||
AfxThrowUserException();
|
||||
}
|
||||
}
|
||||
|
||||
for(INT_PTR j = 0; j < nSizeOfCodeItem - 1; j++) {
|
||||
for(INT_PTR j = 0; j < nSizeOfCodeItem - 1; j++)
|
||||
{
|
||||
Destination.Add(Source.at(i - nSizeOfCodeItem + 1));
|
||||
Source.RemoveAt(i - nSizeOfCodeItem + 1);
|
||||
}
|
||||
@@ -241,7 +247,8 @@ void CFalloutScript::ExtractCodeElements(COpcodeArray& Source, COpcodeArray& Des
|
||||
Source.RemoveAt(i - nSizeOfCodeItem + 1); // Delimeter
|
||||
|
||||
|
||||
if (i > Source.GetUpperBound()) {
|
||||
if (i > Source.GetUpperBound())
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -255,7 +262,8 @@ BOOL CFalloutScript::CheckExportVarCode(WORD wOperator, INT_PTR nIndex)
|
||||
|
||||
BOOL CFalloutScript::CheckSetExportedVarValueCode(WORD wOperator, INT_PTR nIndex)
|
||||
{
|
||||
switch(nIndex) {
|
||||
switch(nIndex)
|
||||
{
|
||||
case 0:
|
||||
return (wOperator == COpcode::O_STRINGOP) ||
|
||||
(wOperator == COpcode::O_FLOATOP) ||
|
||||
@@ -279,3 +287,4 @@ bool CFalloutScript::ArgNeedParens( const CNode& node, const CNode& argument, CF
|
||||
&& ((GetPriority(argument.m_Opcode.GetOperator()) != GetPriority(node.m_Opcode.GetOperator()))
|
||||
|| (GetAssociation(node.m_Opcode.GetOperator()) != assoc)));
|
||||
}
|
||||
|
||||
|
||||
+5
-9
@@ -1,5 +1,3 @@
|
||||
#pragma once
|
||||
|
||||
#ifndef FALLOUT_SCRIPT_H
|
||||
#define FALLOUT_SCRIPT_H
|
||||
|
||||
@@ -8,11 +6,8 @@
|
||||
#include "Namespace.h"
|
||||
#include "Node.h"
|
||||
|
||||
|
||||
// Constants
|
||||
|
||||
// CFalloutScript
|
||||
class CFalloutScript : public CObject {
|
||||
class CFalloutScript
|
||||
{
|
||||
public:
|
||||
CFalloutScript();
|
||||
virtual ~CFalloutScript();
|
||||
@@ -73,8 +68,9 @@ private:
|
||||
Assoc GetAssociation(WORD wOperator);
|
||||
|
||||
private:
|
||||
// CDefObject
|
||||
class CDefObject {
|
||||
|
||||
class CDefObject
|
||||
{
|
||||
public:
|
||||
enum ObjectType {
|
||||
OBJECT_VARIABLE,
|
||||
|
||||
+279
-204
File diff suppressed because it is too large
Load Diff
@@ -1,16 +1,12 @@
|
||||
// FalloutScript.cpp : implementation file
|
||||
//
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "FalloutScript.h"
|
||||
|
||||
|
||||
// CFalloutScript::CDefObject
|
||||
CFalloutScript::CDefObject::CDefObject(ObjectType type, ULONG ulAttributes, ULONG ulObjectData)
|
||||
{
|
||||
m_ulAttributes = ulAttributes;
|
||||
|
||||
switch(m_ObjectType = type) {
|
||||
switch(m_ObjectType = type)
|
||||
{
|
||||
case OBJECT_VARIABLE:
|
||||
m_ulVarValue = ulObjectData;
|
||||
break;
|
||||
|
||||
+15
-10
@@ -1,7 +1,6 @@
|
||||
#include "stdafx.h"
|
||||
#include "FalloutScript.h"
|
||||
|
||||
// CFalloutScript
|
||||
void CFalloutScript::Dump(CArchive& ar)
|
||||
{
|
||||
ar.WriteString("============== Procedures table ==================\n");
|
||||
@@ -67,16 +66,20 @@ void CFalloutScript::Dump(CArchive& ar)
|
||||
|
||||
ar.WriteString("============== Exported variables ==================\n");
|
||||
|
||||
if (m_ExportedVarValue.IsEmpty()) {
|
||||
if (m_ExportedVarValue.IsEmpty())
|
||||
{
|
||||
ar.WriteString("Not found\n");
|
||||
}
|
||||
else {
|
||||
for(INT_PTR i = 0; i < m_ExportedVarValue.GetSize(); i += 2) {
|
||||
else
|
||||
{
|
||||
for(INT_PTR i = 0; i < m_ExportedVarValue.GetSize(); i += 2)
|
||||
{
|
||||
wOperator = m_ExportedVarValue.at(i).GetOperator();
|
||||
ulArgument = m_ExportedVarValue.at(i).GetArgument();
|
||||
ULONG ulNameArgument = m_ExportedVarValue.at(i + 1).GetArgument();
|
||||
|
||||
switch(wOperator) {
|
||||
switch(wOperator)
|
||||
{
|
||||
case COpcode::O_STRINGOP:
|
||||
strOutLine.Format("%s := \"%s\"\n",
|
||||
m_Namespace[ulNameArgument].c_str(),
|
||||
@@ -107,19 +110,21 @@ void CFalloutScript::Dump(CArchive& ar)
|
||||
ar.WriteString("============== Procedures ==================\n");
|
||||
ar.WriteString("\n");
|
||||
|
||||
for(INT_PTR nIndexOfProc = 0; nIndexOfProc < m_ProcTable.GetSize(); nIndexOfProc++) {
|
||||
for(INT_PTR nIndexOfProc = 0; nIndexOfProc < m_ProcTable.GetSize(); nIndexOfProc++)
|
||||
{
|
||||
strOutLine.Format("%d: %s (0x%08x)\n", nIndexOfProc,
|
||||
m_Namespace[m_ProcTable[nIndexOfProc].m_ulNameOffset].c_str(),
|
||||
m_ProcTable[nIndexOfProc].m_ulBodyOffset
|
||||
);
|
||||
m_ProcTable[nIndexOfProc].m_ulBodyOffset);
|
||||
ar.WriteString(strOutLine);
|
||||
ar.WriteString("===============================\n");
|
||||
|
||||
for(INT_PTR i = 0; i < m_ProcBodies.at(nIndexOfProc).GetSize(); i++) {
|
||||
for(INT_PTR i = 0; i < m_ProcBodies.at(nIndexOfProc).GetSize(); i++)
|
||||
{
|
||||
wOperator = m_ProcBodies.at(nIndexOfProc).at(i).m_Opcode.GetOperator();
|
||||
ulArgument = m_ProcBodies.at(nIndexOfProc).at(i).m_Opcode.GetArgument();
|
||||
|
||||
switch(wOperator) {
|
||||
switch(wOperator)
|
||||
{
|
||||
case COpcode::O_STRINGOP:
|
||||
case COpcode::O_INTOP:
|
||||
strOutLine.Format("0x%08X: 0x%04X 0x%08x - %s(0x%08x) // %u (%d)\n",
|
||||
|
||||
+277
-165
File diff suppressed because it is too large
Load Diff
+62
-65
@@ -25,88 +25,87 @@ CNamespace::~CNamespace()
|
||||
|
||||
void CNamespace::Serialize(CArchive& ar)
|
||||
{
|
||||
//if (ar.IsStoring()) {
|
||||
if (false)
|
||||
m_Map.RemoveAll();
|
||||
m_Order.RemoveAll();
|
||||
|
||||
ULONG ulLength;
|
||||
|
||||
if (ReadMSBULong(ar, ulLength) != 4)
|
||||
{
|
||||
//ASSERT(FALSE);
|
||||
printf("Error: Unable read length of namespace\n");
|
||||
AfxThrowUserException();
|
||||
}
|
||||
else {
|
||||
m_Map.RemoveAll();
|
||||
m_Order.RemoveAll();
|
||||
|
||||
ULONG ulLength;
|
||||
if (ulLength == 0xFFFFFFFF) return;
|
||||
|
||||
if (ReadMSBULong(ar, ulLength) != 4)
|
||||
ULONG ulTotalRead = 0;
|
||||
WORD wLengthOfString;
|
||||
LPTSTR lpszNewString;
|
||||
|
||||
while(ulTotalRead < ulLength)
|
||||
{
|
||||
CString strNewString;
|
||||
|
||||
if (ReadMSBWord(ar, wLengthOfString) != 2)
|
||||
{
|
||||
printf("Error: Unable read length of namespace\n");
|
||||
printf("Error: Unable read length of string\n");
|
||||
AfxThrowUserException();
|
||||
};
|
||||
|
||||
if ((wLengthOfString < 2) || (wLengthOfString & 0x0001))
|
||||
{
|
||||
printf("Error: Invalid length of string\n");
|
||||
AfxThrowUserException();
|
||||
}
|
||||
|
||||
if (ulLength != 0xFFFFFFFF)
|
||||
lpszNewString = strNewString.GetBuffer(wLengthOfString);
|
||||
|
||||
if (ar.Read(lpszNewString, wLengthOfString) != wLengthOfString)
|
||||
{
|
||||
ULONG ulTotalRead = 0;
|
||||
WORD wLengthOfString;
|
||||
LPTSTR lpszNewString;
|
||||
strNewString.ReleaseBufferSetLength(0);
|
||||
printf("Error: Unable read string in namespace\n");
|
||||
AfxThrowUserException();
|
||||
}
|
||||
|
||||
while(ulTotalRead < ulLength)
|
||||
{
|
||||
CString strNewString;
|
||||
if ((lpszNewString[wLengthOfString - 1] != '\x00') && (lpszNewString[wLengthOfString - 2] != '\x00'))
|
||||
{
|
||||
strNewString.ReleaseBufferSetLength(0);
|
||||
printf("Error: Invalid end of string in namespace\n");
|
||||
AfxThrowUserException();
|
||||
}
|
||||
|
||||
if (ReadMSBWord(ar, wLengthOfString) != 2) {
|
||||
printf("Error: Unable read length of string\n");
|
||||
AfxThrowUserException();
|
||||
};
|
||||
|
||||
if ((wLengthOfString < 2) || (wLengthOfString & 0x0001)) {
|
||||
printf("Error: Invalid length of string\n");
|
||||
AfxThrowUserException();
|
||||
}
|
||||
|
||||
lpszNewString = strNewString.GetBuffer(wLengthOfString);
|
||||
|
||||
if (ar.Read(lpszNewString, wLengthOfString) != wLengthOfString) {
|
||||
strNewString.ReleaseBufferSetLength(0);
|
||||
printf("Error: Unable read string in namespace\n");
|
||||
AfxThrowUserException();
|
||||
}
|
||||
|
||||
if ((lpszNewString[wLengthOfString - 1] != '\x00') && (lpszNewString[wLengthOfString - 2] != '\x00')) {
|
||||
strNewString.ReleaseBufferSetLength(0);
|
||||
printf("Error: Invalid end of string in namespace\n");
|
||||
AfxThrowUserException();
|
||||
}
|
||||
|
||||
std::string tmpString(lpszNewString);
|
||||
strNewString = tmpString.c_str();//.ReleaseBuffer();
|
||||
std::string tmpString(lpszNewString);
|
||||
strNewString = tmpString.c_str();//.ReleaseBuffer();
|
||||
|
||||
|
||||
// Convert Nongraphic Characters to Escape sequence
|
||||
CString strNonGraph("\\\a\b\f\n\r\t\"");
|
||||
CString strEscape("\\abfnrt\"");
|
||||
// Convert Nongraphic Characters to Escape sequence
|
||||
CString strNonGraph("\\\a\b\f\n\r\t\"");
|
||||
CString strEscape("\\abfnrt\"");
|
||||
|
||||
for(int i = 0; i < strNonGraph.GetLength(); i++)
|
||||
{
|
||||
strNewString.Replace(CString(strNonGraph[i]), CString("\\" + strEscape[i]));
|
||||
}
|
||||
for(int i = 0; i < strNonGraph.GetLength(); i++)
|
||||
{
|
||||
strNewString.Replace(CString(strNonGraph[i]), CString("\\" + strEscape[i]));
|
||||
}
|
||||
|
||||
m_Map.SetAt(ulTotalRead + 6, strNewString);
|
||||
m_Order.Add(ulTotalRead + 6);
|
||||
m_Map.SetAt(ulTotalRead + 6, strNewString);
|
||||
m_Order.Add(ulTotalRead + 6);
|
||||
|
||||
ulTotalRead += (2 + wLengthOfString);
|
||||
}
|
||||
ulTotalRead += (2 + wLengthOfString);
|
||||
}
|
||||
|
||||
ULONG ulTerminator;
|
||||
ULONG ulTerminator;
|
||||
|
||||
if (ReadMSBULong(ar, ulTerminator) != 4)
|
||||
{
|
||||
printf("Error: Unable read terminator of namespace\n");
|
||||
AfxThrowUserException();
|
||||
}
|
||||
if (ReadMSBULong(ar, ulTerminator) != 4)
|
||||
{
|
||||
printf("Error: Unable read terminator of namespace\n");
|
||||
AfxThrowUserException();
|
||||
}
|
||||
|
||||
if (ulTerminator != 0xFFFFFFFF) {
|
||||
printf("Error: Invalid terminator of namespace\n");
|
||||
AfxThrowUserException();
|
||||
}
|
||||
if (ulTerminator != 0xFFFFFFFF)
|
||||
{
|
||||
printf("Error: Invalid terminator of namespace\n");
|
||||
AfxThrowUserException();
|
||||
}
|
||||
|
||||
// //For debugging only
|
||||
// for(INT_PTR i = 0; i < GetSize(); i++) {
|
||||
@@ -114,8 +113,6 @@ void CNamespace::Serialize(CArchive& ar)
|
||||
// }
|
||||
//
|
||||
// printf("\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
INT_PTR CNamespace::GetSize() const
|
||||
|
||||
+3
-5
@@ -1,13 +1,11 @@
|
||||
#pragma once
|
||||
|
||||
#ifndef NAMESPACE_H
|
||||
#define NAMESPACE_H
|
||||
|
||||
#include "Hacks/CArchive.h"
|
||||
#include "Hacks/CMap.h"
|
||||
|
||||
// CNamespace
|
||||
class CNamespace : public CObject {
|
||||
class CNamespace
|
||||
{
|
||||
public:
|
||||
CNamespace();
|
||||
virtual ~CNamespace();
|
||||
@@ -33,4 +31,4 @@ private:
|
||||
CDWordArray m_Order;
|
||||
};
|
||||
|
||||
#endif
|
||||
#endif //NAMESPACE_H
|
||||
|
||||
@@ -1,12 +1,6 @@
|
||||
// Node.cpp : implementation file
|
||||
//
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "Node.h"
|
||||
|
||||
|
||||
// CNode
|
||||
|
||||
CNode::CNode(Type type) :
|
||||
m_ulOffset(0),
|
||||
m_Type(type)
|
||||
@@ -28,28 +22,31 @@ CNode::~CNode()
|
||||
|
||||
CNode& CNode::operator = (const CNode& node)
|
||||
{
|
||||
if (&node != this) {
|
||||
if (&node != this)
|
||||
{
|
||||
m_ulOffset = node.m_ulOffset;
|
||||
m_Opcode = node.m_Opcode;
|
||||
m_Type = node.m_Type;
|
||||
m_Arguments.Copy(node.m_Arguments);
|
||||
}
|
||||
|
||||
return (*this);
|
||||
}
|
||||
|
||||
void CNode::StoreTree(CArchive& ar, int nIndent, int nIndex)
|
||||
{
|
||||
// Indent
|
||||
if (nIndex != 0) {
|
||||
if (nIndex != 0)
|
||||
{
|
||||
ar.WriteString(" ");
|
||||
|
||||
for(int i = 0; i < nIndent; i++) {
|
||||
for(int i = 0; i < nIndent; i++)
|
||||
{
|
||||
ar.WriteString(" ");
|
||||
}
|
||||
}
|
||||
|
||||
switch(m_Type) {
|
||||
switch(m_Type)
|
||||
{
|
||||
case TYPE_BEGIN_OF_BLOCK:
|
||||
ar.WriteString("========= begin of block =========\n");
|
||||
return;
|
||||
@@ -64,7 +61,8 @@ void CNode::StoreTree(CArchive& ar, int nIndent, int nIndex)
|
||||
WORD wOperator = m_Opcode.GetOperator();
|
||||
ULONG ulArgument = m_Opcode.GetArgument();
|
||||
|
||||
switch(wOperator) {
|
||||
switch(wOperator)
|
||||
{
|
||||
case COpcode::O_STRINGOP:
|
||||
case COpcode::O_INTOP:
|
||||
strOutLine.Format("0x%04X 0x%08x ",
|
||||
@@ -85,12 +83,15 @@ void CNode::StoreTree(CArchive& ar, int nIndent, int nIndex)
|
||||
wOperator);
|
||||
ar.WriteString(strOutLine);
|
||||
}
|
||||
if (!m_Arguments.IsEmpty()) {
|
||||
for(int i = 0; i < m_Arguments.GetSize(); i++) {
|
||||
if (!m_Arguments.IsEmpty())
|
||||
{
|
||||
for(int i = 0; i < m_Arguments.GetSize(); i++)
|
||||
{
|
||||
m_Arguments.at(i).StoreTree(ar, nIndent + 1, i);
|
||||
}
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
ar.WriteString("\n");
|
||||
}
|
||||
|
||||
@@ -99,9 +100,13 @@ void CNode::StoreTree(CArchive& ar, int nIndent, int nIndex)
|
||||
ULONG CNode::GetTopOffset()
|
||||
{
|
||||
if (m_Arguments.GetSize() > 0)
|
||||
{
|
||||
return m_Arguments.at(0).GetTopOffset();
|
||||
}
|
||||
else
|
||||
{
|
||||
return m_ulOffset;
|
||||
}
|
||||
}
|
||||
|
||||
bool CNode::IsExpression() const
|
||||
|
||||
@@ -1,22 +1,15 @@
|
||||
#pragma once
|
||||
|
||||
#ifndef NODE_H
|
||||
#define NODE_H
|
||||
|
||||
#include "Namespace.h"
|
||||
#include "Opcode.h"
|
||||
|
||||
|
||||
// Forward declaration of CNode
|
||||
class CNode;
|
||||
|
||||
|
||||
// CNodeArray
|
||||
typedef CArray<CNode, CNode&> CNodeArray;
|
||||
typedef CArray<CNodeArray, CNodeArray&> CArrayOfNodeArray;
|
||||
|
||||
|
||||
// CNode
|
||||
class CNode : public CObject {
|
||||
class CNode
|
||||
{
|
||||
public:
|
||||
enum Type {
|
||||
TYPE_NORMAL,
|
||||
@@ -51,15 +44,8 @@ public:
|
||||
CNodeArray m_Arguments;
|
||||
};
|
||||
|
||||
|
||||
// CNodeArray
|
||||
typedef CArray<CNode, CNode&> CNodeArray;
|
||||
|
||||
// CArrayOfNodeArray
|
||||
typedef CArray<CNodeArray, CNodeArray&> CArrayOfNodeArray;
|
||||
|
||||
// 'Begin' end 'End of block' 'End Else Begin' nodes
|
||||
const CNode c_NodeBeginOfBlock(CNode::TYPE_BEGIN_OF_BLOCK);
|
||||
const CNode c_NodeEndOfBlock(CNode::TYPE_END_OF_BLOCK);
|
||||
|
||||
#endif
|
||||
#endif //NODE_H
|
||||
|
||||
+1
-5
@@ -1,9 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#ifndef OBJECT_ATTRIBUTES_H
|
||||
#define OBJECT_ATTRIBUTES_H
|
||||
|
||||
|
||||
// ProcedureAttributes
|
||||
enum ProcAttributes {
|
||||
P_TIMED = 0x01,
|
||||
@@ -15,7 +12,6 @@ enum ProcAttributes {
|
||||
P_NOTIMPLEMENTED = 0x80000000
|
||||
};
|
||||
|
||||
|
||||
// VariableAtributes
|
||||
enum VariableAtributes {
|
||||
V_GLOBAL = 0x00010000,
|
||||
@@ -23,4 +19,4 @@ enum VariableAtributes {
|
||||
V_EXPORT = 0x00040000
|
||||
};
|
||||
|
||||
#endif
|
||||
#endif //OBJECT_ATTRIBUTES_H
|
||||
|
||||
+48
-39
@@ -1,19 +1,12 @@
|
||||
// Opcode.cpp : implementation file
|
||||
//
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "Opcode.h"
|
||||
#include "Utility.h"
|
||||
|
||||
|
||||
#include <iostream>
|
||||
|
||||
// Globals
|
||||
extern int g_nFalloutVersion;
|
||||
|
||||
|
||||
// COpcode
|
||||
|
||||
COpcode::COpcode() :
|
||||
m_wOperator(O_NOOP),
|
||||
m_ulArgument(0)
|
||||
@@ -41,41 +34,47 @@ COpcode& COpcode::operator = (const COpcode& opcode)
|
||||
|
||||
void COpcode::Serialize(CArchive& ar)
|
||||
{
|
||||
if (ReadMSBWord(ar, m_wOperator) != OPERATOR_SIZE) {
|
||||
if (ReadMSBWord(ar, m_wOperator) != OPERATOR_SIZE)
|
||||
{
|
||||
printf("Error: Unable read opcode\n");
|
||||
AfxThrowUserException();
|
||||
}
|
||||
|
||||
printf("Error: Unable read opcode\n");
|
||||
if ((m_wOperator < O_OPERATOR) ||
|
||||
((m_wOperator >= O_END_OP) &&
|
||||
(m_wOperator != O_STRINGOP) &&
|
||||
(m_wOperator != O_FLOATOP)&&
|
||||
(m_wOperator != O_INTOP)))
|
||||
{
|
||||
ar.Flush();
|
||||
printf("Error: Invalid opcode at 0x%08x\n", ar.GetFile()->GetPosition() - 2);
|
||||
AfxThrowUserException();
|
||||
}
|
||||
|
||||
if ((m_wOperator == O_STRINGOP) || (m_wOperator == O_FLOATOP) || (m_wOperator == O_INTOP))
|
||||
{
|
||||
if (ReadMSBULong(ar, m_ulArgument) != ARGUMENT_SIZE)
|
||||
{
|
||||
printf("Error: Unable read opcode argument\n");
|
||||
AfxThrowUserException();
|
||||
}
|
||||
|
||||
if ((m_wOperator < O_OPERATOR) ||
|
||||
((m_wOperator >= O_END_OP) &&
|
||||
(m_wOperator != O_STRINGOP) &&
|
||||
(m_wOperator != O_FLOATOP)&&
|
||||
(m_wOperator != O_INTOP))) {
|
||||
ar.Flush();
|
||||
printf("Error: Invalid opcode at 0x%08x\n", ar.GetFile()->GetPosition() - 2);
|
||||
AfxThrowUserException();
|
||||
}
|
||||
|
||||
if ((m_wOperator == O_STRINGOP) || (m_wOperator == O_FLOATOP) || (m_wOperator == O_INTOP)) {
|
||||
if (ReadMSBULong(ar, m_ulArgument) != ARGUMENT_SIZE) {
|
||||
printf("Error: Unable read opcode argument\n");
|
||||
AfxThrowUserException();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void COpcode::Expect(CArchive& ar, WORD wOperator, BOOL bArgumentFound, ULONG ulArgument)
|
||||
{
|
||||
Serialize(ar);
|
||||
|
||||
if (m_wOperator != wOperator) {
|
||||
if (m_wOperator != wOperator)
|
||||
{
|
||||
printf("Error: Unexpected opcode (0x%04X expected, but 0x%04X found)\n", wOperator, m_wOperator);
|
||||
AfxThrowUserException();
|
||||
}
|
||||
|
||||
if (bArgumentFound && ((m_wOperator == O_STRINGOP) || (m_wOperator == O_FLOATOP) || (m_wOperator == O_INTOP))) {
|
||||
if (m_ulArgument != ulArgument) {
|
||||
if (bArgumentFound && ((m_wOperator == O_STRINGOP) || (m_wOperator == O_FLOATOP) || (m_wOperator == O_INTOP)))
|
||||
{
|
||||
if (m_ulArgument != ulArgument)
|
||||
{
|
||||
printf("Error: Unexpected argument of opcode. (0x%08X expected, but 0x%08X found)\n", ulArgument, m_ulArgument);
|
||||
AfxThrowUserException();
|
||||
}
|
||||
@@ -87,18 +86,23 @@ void COpcode::Expect(CArchive& ar, int nCount, WORD pwOperators[])
|
||||
Serialize(ar);
|
||||
BOOL bFound = FALSE;
|
||||
|
||||
for(int i = 0; i < nCount; i++) {
|
||||
if (m_wOperator == pwOperators[i]) {
|
||||
for(int i = 0; i < nCount; i++)
|
||||
{
|
||||
if (m_wOperator == pwOperators[i])
|
||||
{
|
||||
bFound = TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!bFound) {
|
||||
if (!bFound)
|
||||
{
|
||||
printf("Error: Unexpected opcode (");
|
||||
|
||||
for(int i = 0; i < nCount; i++) {
|
||||
if (i != 0) {
|
||||
for(int i = 0; i < nCount; i++)
|
||||
{
|
||||
if (i != 0)
|
||||
{
|
||||
printf(" or ");
|
||||
}
|
||||
|
||||
@@ -117,10 +121,12 @@ BOOL COpcode::HasArgument() const
|
||||
|
||||
int COpcode::GetSize() const
|
||||
{
|
||||
if ((m_wOperator == O_STRINGOP) || (m_wOperator == O_FLOATOP) || (m_wOperator == O_INTOP)) {
|
||||
if ((m_wOperator == O_STRINGOP) || (m_wOperator == O_FLOATOP) || (m_wOperator == O_INTOP))
|
||||
{
|
||||
return OPERATOR_SIZE + ARGUMENT_SIZE;
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
return OPERATOR_SIZE;
|
||||
}
|
||||
}
|
||||
@@ -147,13 +153,16 @@ const COpcode::COpcodeAttributes COpcode::GetAttributes() const
|
||||
|
||||
COpcodeAttributes result;
|
||||
|
||||
if (g_nFalloutVersion == 1) {
|
||||
if (f1OpcodeAttributes.Lookup(m_wOperator, result)) {
|
||||
if (g_nFalloutVersion == 1)
|
||||
{
|
||||
if (f1OpcodeAttributes.Lookup(m_wOperator, result))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
if (!f2OpcodeAttributes.Lookup(m_wOperator, result)) {
|
||||
if (!f2OpcodeAttributes.Lookup(m_wOperator, result))
|
||||
{
|
||||
printf("Error: Attempt to obtain attributes of unknown opcode\n");
|
||||
AfxThrowUserException();
|
||||
}
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
#include "Hacks/CArchive.h"
|
||||
#include "Hacks/CMap.h"
|
||||
|
||||
// COpcode
|
||||
class COpcode
|
||||
{
|
||||
public:
|
||||
@@ -21,8 +20,6 @@ public:
|
||||
O_OPERATOR = 0x8000
|
||||
};
|
||||
|
||||
// const O_IF_EXPR = 1000;
|
||||
|
||||
enum O_Core {
|
||||
O_NOOP = O_OPERATOR,
|
||||
O_CONST,
|
||||
@@ -800,13 +797,15 @@ public:
|
||||
};
|
||||
|
||||
// CF2OpcodeAttributesMap
|
||||
class CF2OpcodeAttributesMap : public CMap<WORD, WORD, COpcodeAttributes, const COpcodeAttributes&> {
|
||||
class CF2OpcodeAttributesMap : public CMap<WORD, WORD, COpcodeAttributes, const COpcodeAttributes&>
|
||||
{
|
||||
public:
|
||||
CF2OpcodeAttributesMap();
|
||||
};
|
||||
|
||||
// C12OpcodeAttributesMap
|
||||
class CF1OpcodeAttributesMap : public CMap<WORD, WORD, COpcodeAttributes, const COpcodeAttributes&> {
|
||||
class CF1OpcodeAttributesMap : public CMap<WORD, WORD, COpcodeAttributes, const COpcodeAttributes&>
|
||||
{
|
||||
public:
|
||||
CF1OpcodeAttributesMap();
|
||||
};
|
||||
@@ -838,7 +837,6 @@ private:
|
||||
ULONG m_ulArgument;
|
||||
};
|
||||
|
||||
// COpcodeArray
|
||||
typedef CArray<COpcode, COpcode&> COpcodeArray;
|
||||
|
||||
#endif
|
||||
|
||||
+2
-10
@@ -1,15 +1,6 @@
|
||||
// OpcodeMnemonic.cpp : COpcode class implementation file
|
||||
//
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "Opcode.h"
|
||||
|
||||
#ifdef _DEBUG
|
||||
#define new DEBUG_NEW
|
||||
#endif
|
||||
|
||||
|
||||
// COpcode::COpcodeAttributes
|
||||
COpcode::COpcodeAttributes::COpcodeAttributes(std::string mnemonic,
|
||||
std::string name,
|
||||
ULONG ulNumArgs,
|
||||
@@ -40,7 +31,8 @@ COpcode::COpcodeAttributes::COpcodeAttributes(const COpcodeAttributes& attribute
|
||||
|
||||
COpcode::COpcodeAttributes& COpcode::COpcodeAttributes::operator = (const COpcodeAttributes& attributes)
|
||||
{
|
||||
if (&attributes != this) {
|
||||
if (&attributes != this)
|
||||
{
|
||||
m_strMnemonic = attributes.m_strMnemonic;
|
||||
m_strName = attributes.m_strName;
|
||||
m_ulNumArgs = attributes.m_ulNumArgs;
|
||||
|
||||
+121
-118
@@ -1,6 +1,3 @@
|
||||
// ProcTable.cpp : implementation file
|
||||
//
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "ProcTable.h"
|
||||
#include "Utility.h"
|
||||
@@ -9,8 +6,6 @@
|
||||
#include "Hacks/CString.h"
|
||||
#include <iostream>
|
||||
|
||||
// CProcDescriptor
|
||||
|
||||
CProcDescriptor::CProcDescriptor() :
|
||||
m_ulNameOffset(0),
|
||||
m_ulType(0),
|
||||
@@ -38,7 +33,8 @@ CProcDescriptor::~CProcDescriptor()
|
||||
|
||||
CProcDescriptor& CProcDescriptor::operator = (const CProcDescriptor& Item)
|
||||
{
|
||||
if (&Item != this) {
|
||||
if (&Item != this)
|
||||
{
|
||||
m_ulNameOffset = Item.m_ulNameOffset;
|
||||
m_ulType = Item.m_ulType;
|
||||
m_ulTime = Item.m_ulTime;
|
||||
@@ -52,35 +48,29 @@ CProcDescriptor& CProcDescriptor::operator = (const CProcDescriptor& Item)
|
||||
|
||||
void CProcDescriptor::Serialize(CArchive& ar)
|
||||
{
|
||||
//if (ar.IsStoring()) {
|
||||
if (false)
|
||||
UINT uiTotalRead;
|
||||
|
||||
uiTotalRead = ReadMSBULong(ar, m_ulNameOffset);
|
||||
uiTotalRead += ReadMSBULong(ar, m_ulType);
|
||||
uiTotalRead += ReadMSBULong(ar, m_ulTime);
|
||||
uiTotalRead += ReadMSBULong(ar, m_ulExpressionOffset);
|
||||
uiTotalRead += ReadMSBULong(ar, m_ulBodyOffset);
|
||||
uiTotalRead += ReadMSBULong(ar, m_ulNumArgs);
|
||||
|
||||
// printf("=================\n");
|
||||
// printf("uiTotalRead = %u\n", uiTotalRead);
|
||||
// printf("m_ulNameOffset = 0x%08X\n", m_ulNameOffset);
|
||||
// printf("m_ulType = 0x%08X\n", m_ulType);
|
||||
// printf("m_ulTime = 0x%08X\n", m_ulTime);
|
||||
// printf("m_ulExpressionOffset = 0x%08X\n", m_ulExpressionOffset);
|
||||
// printf("m_ulBodyOffset = 0x%08X\n", m_ulBodyOffset);
|
||||
// printf("m_ulNumArgs = 0x%08X\n", m_ulNumArgs);
|
||||
|
||||
|
||||
if (uiTotalRead != (sizeof(ULONG) * 6))
|
||||
{
|
||||
// ASSERT(FALSE);
|
||||
}
|
||||
else {
|
||||
UINT uiTotalRead;
|
||||
|
||||
uiTotalRead = ReadMSBULong(ar, m_ulNameOffset);
|
||||
uiTotalRead += ReadMSBULong(ar, m_ulType);
|
||||
uiTotalRead += ReadMSBULong(ar, m_ulTime);
|
||||
uiTotalRead += ReadMSBULong(ar, m_ulExpressionOffset);
|
||||
uiTotalRead += ReadMSBULong(ar, m_ulBodyOffset);
|
||||
uiTotalRead += ReadMSBULong(ar, m_ulNumArgs);
|
||||
|
||||
// printf("=================\n");
|
||||
// printf("uiTotalRead = %u\n", uiTotalRead);
|
||||
// printf("m_ulNameOffset = 0x%08X\n", m_ulNameOffset);
|
||||
// printf("m_ulType = 0x%08X\n", m_ulType);
|
||||
// printf("m_ulTime = 0x%08X\n", m_ulTime);
|
||||
// printf("m_ulExpressionOffset = 0x%08X\n", m_ulExpressionOffset);
|
||||
// printf("m_ulBodyOffset = 0x%08X\n", m_ulBodyOffset);
|
||||
// printf("m_ulNumArgs = 0x%08X\n", m_ulNumArgs);
|
||||
|
||||
|
||||
if (uiTotalRead != (sizeof(ULONG) * 6)) {
|
||||
printf("Error: Unable read procedure descriptor\n");
|
||||
AfxThrowUserException();
|
||||
}
|
||||
printf("Error: Unable read procedure descriptor\n");
|
||||
AfxThrowUserException();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -118,7 +108,8 @@ void CProcDescriptor::Dump(CArchive& ar)
|
||||
|
||||
strType += ")";
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
strType = "No special types";
|
||||
}
|
||||
|
||||
@@ -157,20 +148,26 @@ int compareProcBodyOffsets(const void* elem0, const void* elem1)
|
||||
ProcBodyOffset offset0 = *((ProcBodyOffset*)elem0);
|
||||
ProcBodyOffset offset1 = *((ProcBodyOffset*)elem1);
|
||||
|
||||
if (offset0.m_ulBodyOffset < offset1.m_ulBodyOffset) {
|
||||
if (offset0.m_ulBodyOffset < offset1.m_ulBodyOffset)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
else if (offset0.m_ulBodyOffset > offset1.m_ulBodyOffset) {
|
||||
else if (offset0.m_ulBodyOffset > offset1.m_ulBodyOffset)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
else {
|
||||
if (offset0.m_ulProcIndex < offset1.m_ulProcIndex) {
|
||||
else
|
||||
{
|
||||
if (offset0.m_ulProcIndex < offset1.m_ulProcIndex)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
else if (offset0.m_ulProcIndex > offset1.m_ulProcIndex) {
|
||||
else if (offset0.m_ulProcIndex > offset1.m_ulProcIndex)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -178,91 +175,95 @@ int compareProcBodyOffsets(const void* elem0, const void* elem1)
|
||||
|
||||
void CProcTable::Serialize(CArchive& ar)
|
||||
{
|
||||
//if (ar.IsStoring()) {
|
||||
if(false)
|
||||
m_Table.RemoveAll();
|
||||
m_ProcSize.RemoveAll();
|
||||
|
||||
ULONG ulSizeOfTable;
|
||||
ULONG ulRead;
|
||||
|
||||
ar.Flush();
|
||||
ULONG ulSizeOfFile = ULONG(ar.GetFile()->GetLength());
|
||||
|
||||
ulRead = ReadMSBULong(ar, ulSizeOfTable);
|
||||
|
||||
if (ulRead != sizeof(ulSizeOfTable))
|
||||
{
|
||||
// ASSERT(FALSE);
|
||||
printf("Error: Unable read size of procedures table\n");
|
||||
AfxThrowUserException();
|
||||
}
|
||||
else {
|
||||
m_Table.RemoveAll();
|
||||
m_ProcSize.RemoveAll();
|
||||
|
||||
ULONG ulSizeOfTable;
|
||||
ULONG ulRead;
|
||||
m_Table.SetSize(ulSizeOfTable);
|
||||
m_ProcSize.SetSize(ulSizeOfTable);
|
||||
|
||||
ar.Flush();
|
||||
ULONG ulSizeOfFile = ULONG(ar.GetFile()->GetLength());
|
||||
ULONG ulIndexOfProcOffset = 0;
|
||||
ProcBodyOffset* pOffsets = new ProcBodyOffset[ulSizeOfTable + 1];
|
||||
|
||||
ulRead = ReadMSBULong(ar, ulSizeOfTable);
|
||||
if (pOffsets == NULL)
|
||||
{
|
||||
// AfxThrowMemoryException();
|
||||
throw 1;
|
||||
}
|
||||
|
||||
if (ulRead != sizeof(ulSizeOfTable))
|
||||
for(ULONG i = 0; i < ulSizeOfTable; i++)
|
||||
{
|
||||
// printf("======== %u =========\n", i);
|
||||
m_Table.at(i).Serialize(ar);
|
||||
m_ProcSize.at(i) = 0; // Initialize size of procedure
|
||||
|
||||
if (!(m_Table.at(i).m_ulType & P_IMPORT))
|
||||
{
|
||||
printf("Error: Unable read size of procedures table\n");
|
||||
if ((m_Table.at(i).m_ulBodyOffset != 0) && (m_Table.at(i).m_ulBodyOffset != ulSizeOfFile))
|
||||
{
|
||||
pOffsets[ulIndexOfProcOffset].m_ulProcIndex = i;
|
||||
pOffsets[ulIndexOfProcOffset].m_ulBodyOffset = m_Table.at(i).m_ulBodyOffset;
|
||||
ulIndexOfProcOffset++;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_Table.at(i).m_ulType |= P_NOTIMPLEMENTED;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pOffsets[ulIndexOfProcOffset].m_ulProcIndex = ulIndexOfProcOffset + 1;
|
||||
pOffsets[ulIndexOfProcOffset].m_ulBodyOffset = ulSizeOfFile;
|
||||
|
||||
qsort(pOffsets, ulIndexOfProcOffset, sizeof(ProcBodyOffset), compareProcBodyOffsets);
|
||||
|
||||
// Sizes of procedures
|
||||
for(ULONG i = 0; i < ulIndexOfProcOffset; i++)
|
||||
{
|
||||
if (pOffsets[i + 1].m_ulBodyOffset >= pOffsets[i].m_ulBodyOffset)
|
||||
{
|
||||
m_ProcSize.at(pOffsets[i].m_ulProcIndex) = pOffsets[i + 1].m_ulBodyOffset - pOffsets[i].m_ulBodyOffset;
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("Error: Procedures are not sorted in ascending address order\n");
|
||||
AfxThrowUserException();
|
||||
}
|
||||
|
||||
m_Table.SetSize(ulSizeOfTable);
|
||||
m_ProcSize.SetSize(ulSizeOfTable);
|
||||
|
||||
ULONG ulIndexOfProcOffset = 0;
|
||||
ProcBodyOffset* pOffsets = new ProcBodyOffset[ulSizeOfTable + 1];
|
||||
|
||||
if (pOffsets == NULL) {
|
||||
// AfxThrowMemoryException();
|
||||
throw 1;
|
||||
}
|
||||
|
||||
for(ULONG i = 0; i < ulSizeOfTable; i++) {
|
||||
// printf("======== %u =========\n", i);
|
||||
m_Table.at(i).Serialize(ar);
|
||||
m_ProcSize.at(i) = 0; // Initialize size of procedure
|
||||
|
||||
if (!(m_Table.at(i).m_ulType & P_IMPORT)) {
|
||||
if ((m_Table.at(i).m_ulBodyOffset != 0) && (m_Table.at(i).m_ulBodyOffset != ulSizeOfFile)) {
|
||||
pOffsets[ulIndexOfProcOffset].m_ulProcIndex = i;
|
||||
pOffsets[ulIndexOfProcOffset].m_ulBodyOffset = m_Table.at(i).m_ulBodyOffset;
|
||||
ulIndexOfProcOffset++;
|
||||
}
|
||||
else {
|
||||
m_Table.at(i).m_ulType |= P_NOTIMPLEMENTED;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pOffsets[ulIndexOfProcOffset].m_ulProcIndex = ulIndexOfProcOffset + 1;
|
||||
pOffsets[ulIndexOfProcOffset].m_ulBodyOffset = ulSizeOfFile;
|
||||
|
||||
qsort(pOffsets, ulIndexOfProcOffset, sizeof(ProcBodyOffset), compareProcBodyOffsets);
|
||||
|
||||
// Sizes of procedures
|
||||
for(ULONG i = 0; i < ulIndexOfProcOffset; i++) {
|
||||
if (pOffsets[i + 1].m_ulBodyOffset >= pOffsets[i].m_ulBodyOffset) {
|
||||
m_ProcSize.at(pOffsets[i].m_ulProcIndex) = pOffsets[i + 1].m_ulBodyOffset - pOffsets[i].m_ulBodyOffset;
|
||||
}
|
||||
else {
|
||||
printf("Error: Procedures are not sorted in ascending address order\n");
|
||||
AfxThrowUserException();
|
||||
}
|
||||
}
|
||||
|
||||
delete [] pOffsets;
|
||||
|
||||
for(ULONG i = 0; i < ulSizeOfTable; i++) {
|
||||
if (m_Table.at(i).m_ulBodyOffset != 0) {
|
||||
m_ulOffsetOfProcSection = m_Table.at(i).m_ulBodyOffset;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// // For debugging only
|
||||
// printf("Total: %d\n", m_Table.GetSize());
|
||||
//
|
||||
// for(i = 0; i < ulSizeOfTable; i++) {
|
||||
// printf("Offset: 0x%08X, size: 0x%08X\n", m_Table.at(i).m_ulBodyOffset, m_ProcSize.at(i));
|
||||
// }
|
||||
|
||||
// printf("m_ulOffsetOfProcSection: 0x%08X\n", m_ulOffsetOfProcSection);
|
||||
}
|
||||
|
||||
delete [] pOffsets;
|
||||
|
||||
for(ULONG i = 0; i < ulSizeOfTable; i++)
|
||||
{
|
||||
if (m_Table.at(i).m_ulBodyOffset != 0)
|
||||
{
|
||||
m_ulOffsetOfProcSection = m_Table.at(i).m_ulBodyOffset;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// // For debugging only
|
||||
// printf("Total: %d\n", m_Table.GetSize());
|
||||
|
||||
// for(i = 0; i < ulSizeOfTable; i++)
|
||||
// {
|
||||
// printf("Offset: 0x%08X, size: 0x%08X\n", m_Table.at(i).m_ulBodyOffset, m_ProcSize.at(i));
|
||||
// }
|
||||
|
||||
// printf("m_ulOffsetOfProcSection: 0x%08X\n", m_ulOffsetOfProcSection);
|
||||
}
|
||||
|
||||
INT_PTR CProcTable::GetSize()
|
||||
@@ -272,7 +273,8 @@ INT_PTR CProcTable::GetSize()
|
||||
|
||||
ULONG CProcTable::GetSizeOfProc(INT_PTR nIndex)
|
||||
{
|
||||
if ((nIndex < 0) || (nIndex > m_ProcSize.GetUpperBound())) {
|
||||
if ((nIndex < 0) || (nIndex > m_ProcSize.GetUpperBound()))
|
||||
{
|
||||
printf("Warning: Invalid index of procedure (%d). Exception will be thrown\n", nIndex);
|
||||
AfxThrowUserException();
|
||||
}
|
||||
@@ -303,7 +305,8 @@ void CProcTable::Dump(CArchive& ar)
|
||||
|
||||
CProcDescriptor& CProcTable::operator [] (INT_PTR nIndex)
|
||||
{
|
||||
if ((nIndex < 0) || (nIndex > m_ProcSize.GetUpperBound())) {
|
||||
if ((nIndex < 0) || (nIndex > m_ProcSize.GetUpperBound()))
|
||||
{
|
||||
printf("Warning: Invalid index of procedure (%d). Exception will be thrown\n", nIndex);
|
||||
AfxThrowUserException();
|
||||
}
|
||||
|
||||
+4
-4
@@ -6,7 +6,8 @@
|
||||
#include "Hacks/CArchive.h"
|
||||
|
||||
// CProcDescriptor
|
||||
class CProcDescriptor : public CObject {
|
||||
class CProcDescriptor
|
||||
{
|
||||
public:
|
||||
CProcDescriptor();
|
||||
CProcDescriptor(const CProcDescriptor& Item);
|
||||
@@ -29,9 +30,8 @@ public:
|
||||
ULONG m_ulNumArgs; // Number of args to procedure
|
||||
};
|
||||
|
||||
|
||||
// CProcTable
|
||||
class CProcTable : public CObject {
|
||||
class CProcTable
|
||||
{
|
||||
public:
|
||||
CProcTable();
|
||||
virtual ~CProcTable();
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
#pragma once
|
||||
|
||||
#ifndef STARTUP_CODE_H
|
||||
#define STARTUP_CODE_H
|
||||
|
||||
|
||||
@@ -1,9 +1,5 @@
|
||||
#include "stdafx.h"
|
||||
|
||||
CObject::CObject()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void AfxThrowUserException()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user