 |
Cheat Engine The Official Site of Cheat Engine
|
| View previous topic :: View next topic |
| Author |
Message |
Dark Byte Site Admin
Reputation: 471
Joined: 09 May 2003 Posts: 25823 Location: The netherlands
|
Posted: Sat Apr 19, 2014 3:42 pm Post subject: |
|
|
easiest is after getting the resource data in pData, write it to a MapData.md file in the dll path and just use the code.
but since that's probably not what you wish a second easiest method is to replace the std:fstream with a std:stringstream and load it with the contents of pData (don't ask me how, I don't make use of c++ much, I just see there is a stringstream object you could use with the same parents as fstream)
_________________
Do not ask me about online cheats. I don't know any and wont help finding them.
Like my help? Join me on Patreon so i can keep helping |
|
| Back to top |
|
 |
justa_dude Grandmaster Cheater
Reputation: 23
Joined: 29 Jun 2010 Posts: 893
|
Posted: Sat Apr 19, 2014 4:49 pm Post subject: |
|
|
| Shrooms/user3513035/PREFETCH0 wrote: |
I have the following complete code in c++
| Code: |
void GetMapData ()
{
MapPair NewMap;
string TempString;
BOOL SkipReadLine = FALSE;
//------
char buffer[MAX_PATH];
std::fstream File;
std::string Dir;
GetModuleFileNameA(GlobalhMod, buffer, MAX_PATH);
Dir = buffer;
Dir = Dir.substr(0, Dir.find_last_of("\\")+1);
Dir += "MapData.text";
File.open(Dir.c_str(), std::ios::in);
if(!File.good())
{
MessageBox(GlobalhWnd, "MapData.md is not in your DLL directory.\rGame will be terminate.", "snsRush", MB_OK);
TerminateProcess(GetCurrentProcess(), 0);
}
while (File.good())
{
MapData NewMapData;
PortalData NewPortalData;
if (!SkipReadLine)
getline (File, TempString);
NewMapData.MapID = atoi (TempString.substr (1, TempString.length() - 1).c_str());
if (SkipReadLine)
{
SkipReadLine = FALSE;
getline (File, TempString);
}
getline (File, TempString);
NewMapData.Island = TempString.substr (7, TempString.length() - 7);
if(strcmp(NewMapData.Island.c_str(), "1") != 0 &&strcmp(NewMapData.Island.c_str(), "2") != 0 && strcmp(NewMapData.Island.c_str(), "3") != 0 && strcmp(NewMapData.Island.c_str(), "4") != 0)
{
break;
}
getline (File, TempString);
NewMapData.TopName = TempString.substr (8, TempString.length() - 8);
getline (File, TempString);
NewMapData.MapName = TempString.substr (8, TempString.length() - 8);
File >> TempString;
if (!strcmp (TempString.substr (0, 1).c_str(), "["))
{
SkipReadLine = TRUE;
NewMap = MapPair (NewMapData.MapID, NewMapData);
MsMap.insert (NewMap);
}
else
{
int NumMaps = atoi (TempString.substr (6, TempString.length() - 1).c_str());
for (int i = 1; i <= NumMaps; i++)
{
File >> NewPortalData.PortalName;
File >> NewPortalData.PortalType;
File >> NewPortalData.X;
File >> NewPortalData.Y;
File >> NewPortalData.ToMapID;
NewMapData.Portals.push_back (NewPortalData);
}
getline (File, TempString);
NewMap = MapPair (NewMapData.MapID, NewMapData);
MsMap.insert (NewMap);
}
}
File.close ();
}
|
The problem is that I do not want to have an external MapData.txt, rather I access it through a embedded text resource, which in this case I have no knowledge on doing so.
I have the following snippet which demonstrates to my knowledge on how to access a text resource; however, I do not know hot to modify the code above to implant this, but to still have the same functionality as the original code above.
| Code: |
HRSRC hRes = FindResource(GetModuleHandle(NULL), MAKEINTRESOURCE(IDR_TEXT1), _T("TEXT"));
DWORD dwSize = SizeofResource(GetModuleHandle(NULL), hRes);
HGLOBAL hGlob = LoadResource(GetModuleHandle(NULL), hRes);
const BYTE* pData = reinterpret_cast<const BYTE*>(::LockResource(hGlob));
|
Please take note that I am compiling with a MBCS.
|
Should be as simple as changing the cast from byte to char and using the result as the constructor for an istringstream, which will promote it to a string.
_________________
A nagy kapu mellett, mindig van egy kis kapu.
----------------------
Come on...
Last edited by justa_dude on Sat Apr 19, 2014 7:13 pm; edited 2 times in total |
|
| Back to top |
|
 |
justa_dude Grandmaster Cheater
Reputation: 23
Joined: 29 Jun 2010 Posts: 893
|
Posted: Sat Apr 19, 2014 5:55 pm Post subject: |
|
|
| Shrooms wrote: | | justa_dude wrote: | | Should be as simple as changing the cast from byte to char and using the result as the constructor for an istringstream, which will promote it to a string. |
If I do this, how do I put it into the existing code(do I put istringstream in the File.open, and if so, then it appears to be easy!)? |
I haven't studied your code very closely, and I certainly haven't tried to compile it, but yeah... should be as easy as just "std::istringstream File(pData);" and then the rest should work w/o any changes.
_________________
A nagy kapu mellett, mindig van egy kis kapu.
----------------------
Come on... |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum
|
|