   .X File Saving Problems
  I wanted a way of saving gamesettings and other values in a hierarchical text file, my first choice was XML but there didn't seem to be any built in parsers without using the .NET framework which would mess up the way my directx project is set up. So I opted to use .x files to retain the data.I have two classes at the moment, one that handles most of the .x file opening/saving and another to store the values:#pragma once// Includes then libraries required for reading .x files#include <dxfile.h>#include <initguid.h>#include <rmxftmpl.h>#include <rmxfguid.h>#pragma comment (lib, "d3dxof.lib")#pragma comment (lib, "dxguid.lib")class XFileManager {private:LPD3DXFILE XFileHandler; // oversees handling of .x fileLPD3DXFILEENUMOBJECT XEnumObject; // represents file dataLPDIRECTXFILESAVEOBJECT XSave;void _Init(){XFileHandler = NULL;if(FAILED(D3DXFileCreate(&XFileHandler)))return; // error}public:std::string Filename;XFileManager(){this->_Init();}XFileManager(std::string File){this->_Init();Load(File);}void Load(std::string File){this->Filename = File;XFileHandler->CreateEnumObject(File.c_str(), DXFILELOAD_FROMFILE, &XEnumObject);}void BeginSave(){//XFileHandler->CreateSaveObject(this->Filename.c_str(), D3DXF_FILESAVE_TOWFILE, //DXFILEFORMAT_TEXT, &XSave);// register templates}void BeginSave(std::string file){//XFileHandler->CreateSaveObject(file.c_str(), D3DXF_FILESAVE_TOWFILE, //DXFILEFORMAT_TEXT, &XSave);}void EndSave(){}void Cleanup(){XFileHandler->Release();XEnumObject->Release();}void GetEnumerator(LPD3DXFILEENUMOBJECT* obj) { obj = &XEnumObject; }void SetEnumerator(LPD3DXFILEENUMOBJECT obj) { XEnumObject = obj; }void GetSaveObject(LPDIRECTXFILESAVEOBJECT* obj) { obj = &XSave; }void SetSaveObject(LPDIRECTXFILESAVEOBJECT obj) { XSave = obj; }};class GameSettings {private:XFileManager x;GUID GUID_GAME_SETTINGS;public:struct {char* GameName;char* GameDeveloper;DWORD GameVersion;DWORD ScreenWidth;DWORD ScreenHeight;DWORD FullScreen;} Values;GameSettings(){}void Load(){x = XFileManager("./GameSettings.x");LPD3DXFILEENUMOBJECT enumerator = NULL;x.GetEnumerator(&enumerator);SIZE_T size = 0;enumerator->GetChildren(&size);for(SIZE_T cnt = 0; cnt < size; cnt++){LPD3DXFILEDATA data = NULL;enumerator->GetChild(cnt, &data);SIZE_T nSize = 0;data->GetName(NULL, &nSize);char* name= new char[nSize];data->GetName(name, &nSize);if(name == "GameSettings"){data->GetType(&GUID_GAME_SETTINGS);SIZE_T str_size = 0;data->Lock(&str_size, (const void**)&data);data->Unlock();}data->Release();}// Set Values}void Save(){/*x->BeginSave("GameSettings2.x");LPDIRECTXFILESAVEOBJECT s;LPD3DXFILEDATA data = NULL;x->GetSaveObject(&s);XFileManagers->CreateDataObject(GUID_GAME_SETTINGS, "GameSettings", NULL, sizeof(Values), &Values, &data);x->SetSaveObject(&s);x->EndSave();*/}void Cleanup(void){}};At the moment I can't even get past the x being initialised in the constructor, I get some stack error at runtime that I don't understand:Another problem I'm worried about is that I'm not registering the templates, so when I save I think it may not save them along with it. But I'm not sure of this as I haven't even been able to run it yet.And lastly, the saving process is boggling my mind, I have a book that tells me to use one pointer and the documentation telling me to use another and getting no results using either.I'm hoping to at least be able to read some data, could someone help me out?Thank you!   
  This a bump, sorry if bumps are not allowed.   ;  Been trying this for hours and hours now and it still doesn't work.I can get as far as locking the data which puts the data into a pointer (GAME_SETTINGS struct in this case) but the debugger tells me that all the values are "Bad Ptr" for the strings and a ridiculous number for the DWORDs.The code is as follows:class XFileManager {private:LPD3DXFILE XFileHandler; // oversees handling of .x filevoid _Init(){XFileHandler = NULL;if(FAILED(D3DXFileCreate(&XFileHandler))){int error = 1;}}public:LPD3DXFILEENUMOBJECT XEnumObject; // represents file dataLPD3DXFILESAVEOBJECT XSave;char * Filename;XFileManager(){this->_Init();}XFileManager(char * File){this->_Init();Load(File);}void Load(char * File){XEnumObject = NULL; D3DXFileCreate(&XFileHandler);XFileHandler->CreateEnumObject(File, DXFILELOAD_FROMFILE, &XEnumObject);SIZE_T size;XEnumObject->GetChildren(&size);int x = size;}void BeginSave(){XFileHandler->CreateSaveObject(this->Filename, D3DXF_FILESAVE_TOWFILE,DXFILEFORMAT_TEXT, &XSave);}void BeginSave(char * File){XFileHandler->CreateSaveObject(File, D3DXF_FILESAVE_TOWFILE,DXFILEFORMAT_TEXT, &XSave);}void EndSave(){}void Cleanup(){XFileHandler->Release();XEnumObject->Release();}};struct GAME_SETTINGS{char* GameName;char* GameDeveloper;DWORD GameVersion;DWORD ScreenWidth;DWORD ScreenHeight;DWORD FullScreen;};class GameSettings {private:XFileManager* x;GUID GUID_GAME_SETTINGS;public:GAME_SETTINGS Values;GameSettings(){}void Load(){x = NULL;x = new XFileManager("./GameSettings.x");//x->GetEnumerator(&enumerator);SIZE_T size = 0;//HRESULT er = enumerator->GetChildren(&size);x->XEnumObject->GetChildren(&size);for(SIZE_T cnt = 0; cnt < size; cnt++){LPD3DXFILEDATA data = NULL;x->XEnumObject->GetChild(cnt, &data);SIZE_T nSize = 0;data->GetName(NULL, &nSize);char* name= new char[nSize];data->GetName(name, &nSize);Alert("checking name");if(strcmp(name,"GameSettings")==0){Alert("Name was right");data->GetType(&GUID_GAME_SETTINGS);SIZE_T str_size = 0;Alert("Locking");//char * n;GAME_SETTINGS* tmp = NULL; HRESULT hr = data->Lock(&str_size, (const void**)&tmp);Values.FullScreen = (DWORD)tmp->FullScreen;Values.GameName = (char *)tmp->GameName;data->Unlock();//Alert(n);}data->Release();}// Set ValuesAlert("end load");}void Save(){Values.GameVersion = 0.2;x->BeginSave("GameSettings2.x");LPD3DXFILESAVEDATA data = NULL;x->XSave->AddDataObject(GUID_GAME_SETTINGS, "GameSettings", NULL, sizeof(Values), &Values, &data);if(FAILED(x->XSave->Save()))Alert("proper failed bruv");x->EndSave();}void Cleanup(void){}};And the .x file:xof 0302txt 0032// Declarationtemplate GAME_SETTINGS{<3DF64362-FEC1-4749-B04D-131E0075DE59>STRING GameName;STRING GameDeveloper;DWORD GameVersion;DWORD ScreenWidth;DWORD ScreenHeight;DWORD FullScreen;}GAME_SETTINGS GameSettings{"Le Physics Sandbox";// Game Name"Alexander Brook Perry";// Developer0.1;// Version800;// Screen Width600;// Screen Height1;// FullScreen (0 = false, 1 = true)};  In your first screenshot, your this pointer is null, which is the result of calling a member function on a null pointer; it won't crash until you access a member variable or virtual function of the class.   ;  That error has been fixed, the only one I have now is actually getting data out of the file.At this rate I'd prefer to use XML but is there a built in parser or will I have to get one?   ;  I'm going to use TinyXML now, I'll probably post up my Settings class when I finish it.   