我正在尝试使用Visual Studio 2015制作C ++ DLL。没有任何内容作为错误加下划线,但是当我尝试构建错误时,会报告错误。然后我被问到是否要运行最后一个工作版本,虽然从来没有以前的工作版本,所以也失败了。这些错误都与不属于std::
成员的事物有关。我想我已经包含了我需要的一切。为什么这不起作用?
这是主要的dll代码:
#include <string>
#include <vector>
#include <iostream>
#include <sstream>
#include <fstream>
#include "stdafx.h"
#include "scan.h"
#define SerializerFunc 0xA1B010
#define WorkspaceVTable 0x1165EBC
#define InstanceSetParent 0x5249C0
std::string RBXMX_FileName;
std::ofstream RBXMX_Out;
struct instance_shared_ptr {
void* instance;
void* unk;
};
//typedef int(__thiscall* _ffc)(void* instance, std::string childname, char recursive);
typedef void(__cdecl* _serialize)(std::ostream&, std::vector<instance_shared_ptr>, ULONG);
typedef char(__thiscall* _SetParentInstance)(void* self, int wot, int whatever);
_SetParentInstance SetParentInstance;
//_ffc findfirstchild;
_serialize serialize;
DWORD WorkspaceVT;
DWORD Workspace;
DWORD Terrain;
BOOL Dump_Instance_Vector(std::ostream& export_stream, std::vector<instance_shared_ptr>* instance_vector)
{
serialize(export_stream, *instance_vector, NULL);
return TRUE;
}
std::string* GetName(int Instance) {
return (std::string*)(*(int*)(Instance + 0x28));
}
int GetChildByName(int Instance, std::string Name) {
// iterate over the children vector
DWORD StartOfChildren = *(DWORD*)(Instance + 0x2C);
DWORD EndOfChildren = *(DWORD*)(StartOfChildren + 4);
for (int i = *(int*)StartOfChildren; i != EndOfChildren; i += 8)
if (strcmp(GetName(*(int*)i)->c_str(), Name.c_str()) == 0)
return *(int*)i;
return 0;
}
/*
void RemoveTerrainFromWorkspace(int Workspace)
{
DWORD StartOfChildren = *(DWORD*)(Workspace + 0x2C);
DWORD EndOfChildren = *(DWORD*)(StartOfChildren + 4);
for (int i = *(int*)StartOfChildren; i != EndOfChildren; i += 8)
if (strcmp(GetName(*(int*)i)->c_str(), "Terrain") == 0)
*(int*)i = NULL;
}
*/
int __stdcall MessageBoxHook(HWND WindowParent, LPCSTR Body, LPCSTR Caption, UINT Type)
{
MessageBoxW(WindowParent, L"The place has successfully been dumped! Roblox will now close.", L"Magus Night", MB_ICONINFORMATION);
PostMessage(GetConsoleWindow(), WM_CLOSE, NULL, NULL);
std::exit(NULL);
return 0;
}
// crash rate: ~40%
// please excuse the terrible code (this was made in 5 minutes)
VOID Init()
{
std::stringstream RBXMX_Log;
DWORD OldPerm, OldPermMsg, Base;
// open console
VirtualProtect(&FreeConsole, 1, PAGE_EXECUTE_READWRITE, &OldPerm);
VirtualProtect(&MessageBoxA, 5, PAGE_EXECUTE_READWRITE, &OldPerm);
*(BYTE*)(&FreeConsole) = 0xC3;
AllocConsole();
freopen("CONOUT$", "w", stdout);
freopen("CONIN$", "r", stdin);
SetConsoleTitleA("Place Stealer - by Louka @ V3rmillion");
// header/filestream stuff
std::cout << "Place Stealer - by Louka @ V3rmillion\nIf the game crashes during the dumping process, just try again.\n\nPlease enter filename: ";
getline(std::cin, RBXMX_FileName);
RBXMX_Out = std::ofstream(RBXMX_FileName, std::ios_base::out | std::ios_base::binary);
if (RBXMX_Out.fail())
{
std::cout << "\nSomething went wrong while opening the file. Close Roblox and try again.";
return;
}
// get functions from their offset
std::cout << "[1/3] Getting funcs... ";
Base = (DWORD)GetModuleHandleA("RobloxPlayerBeta.exe");
serialize = (_serialize)(SerializerFunc - 0x400000 + Base);
//SerializerJumpTo = (SerializerBckt - 0x400000 + Base);
SetParentInstance = (_SetParentInstance)(InstanceSetParent - 0x400000 + Base);
std::cout << "OK!\n[2/3] Obtaining workspace children vector... ";
// obtain the workspace service by scanning its vftable
WorkspaceVT = (WorkspaceVTable - 0x400000 + Base);
Workspace = Memory::Scan(PAGE_READWRITE, (char*)&WorkspaceVT, "xxxx");
if (strcmp(GetName(Workspace)->c_str(), "Workspace"))
{
std::cout << "Wrong Workspace instance! Quit Roblox and try again.";
return;
}
// save the thing
std::cout << "OK!\n[3/3] Dumping place to file... ";
Terrain = GetChildByName(Workspace, "Terrain");
//*(DWORD*)(Terrain + 0x22) = 0;
//*(DWORD*)(Terrain + 0x34) = NULL;
//RemoveTerrainFromWorkspace(Workspace);
try
{
SetParentInstance((void*)Terrain, NULL, TRUE);
Dump_Instance_Vector(RBXMX_Out, (std::vector<instance_shared_ptr>*)(Workspace + 0x2C));
}
catch (std::exception e)
{
std::cout << "An error occured while dumping: " << e.what() << "\n";
return;
}
//Serialize_Instances(RBXMX_Out, *(std::vector<instance_shared_ptr>*)(Workspace + 0x2C), NULL);
*(BYTE*)(&MessageBoxA) = 0xE9;
*(DWORD*)((DWORD)&MessageBoxA + 1) = ((DWORD)&MessageBoxHook - (DWORD)&MessageBoxA) - 5;
std::cout << "OK!\nDump successful!";
RBXMX_Out.close();
}
这是scan.h文件:
namespace Memory {
bool Compare(const BYTE *pData, const BYTE *bMask, const char *szMask)
{
for (; *szMask; ++szMask, ++pData, ++bMask)
if (*szMask == 'x' && *pData != *bMask) return 0;
return (*szMask) == NULL;
}
DWORD FindPattern(DWORD dwAddress, DWORD dwLen, BYTE *bMask, char *szMask)
{
for (int i = 0; i < (int)dwLen; i++)
if (Compare((BYTE*)(dwAddress + (int)i), bMask, szMask)) return (int)(dwAddress + i);
return 0;
}
int Scan(DWORD mode, char* content, char* mask)
{
DWORD PageSize;
SYSTEM_INFO si;
GetSystemInfo(&si);
PageSize = si.dwPageSize;
MEMORY_BASIC_INFORMATION mi;
for (DWORD lpAddr = 0; lpAddr < 0x7FFFFFFF; lpAddr += PageSize)
{
DWORD vq = VirtualQuery((void*)lpAddr, &mi, PageSize);
if (vq == ERROR_INVALID_PARAMETER || vq == 0) break;
if (mi.Type == MEM_MAPPED) continue;
if (mi.Protect == mode)
{
int addr = FindPattern(lpAddr, PageSize, (PBYTE)content, mask);
if (addr != 0)
{
return addr;
}
}
}
}
}
错误:
Severity Code Description Project File Line Suppression State
Error C2039 'string': is not a member of 'std' Place Stealer c:\users\owner\documents\visual studio 2015\projects\place stealer\place stealer\place stealer.cpp 13
Error C4430 missing type specifier - int assumed. Note: C++ does not support default-int Place Stealer c:\users\owner\documents\visual studio 2015\projects\place stealer\place stealer\place stealer.cpp 13
Error C2146 syntax error: missing ';' before identifier 'RBXMX_FileName' Place Stealer c:\users\owner\documents\visual studio 2015\projects\place stealer\place stealer\place stealer.cpp 13
Error C2039 'ofstream': is not a member of 'std' Place Stealer c:\users\owner\documents\visual studio 2015\projects\place stealer\place stealer\place stealer.cpp 14
Error C4430 missing type specifier - int assumed. Note: C++ does not support default-int Place Stealer c:\users\owner\documents\visual studio 2015\projects\place stealer\place stealer\place stealer.cpp 14
Error C2146 syntax error: missing ';' before identifier 'RBXMX_Out' Place Stealer c:\users\owner\documents\visual studio 2015\projects\place stealer\place stealer\place stealer.cpp 14
Error C2039 'ostream': is not a member of 'std' Place Stealer c:\users\owner\documents\visual studio 2015\projects\place stealer\place stealer\place stealer.cpp 22
Error C2065 'ostream': undeclared identifier Place Stealer c:\users\owner\documents\visual studio 2015\projects\place stealer\place stealer\place stealer.cpp 22
Error C2059 syntax error: ',' Place Stealer c:\users\owner\documents\visual studio 2015\projects\place stealer\place stealer\place stealer.cpp 22
Error C2039 'vector': is not a member of 'std' Place Stealer c:\users\owner\documents\visual studio 2015\projects\place stealer\place stealer\place stealer.cpp 22
Error C4430 missing type specifier - int assumed. Note: C++ does not support default-int Place Stealer c:\users\owner\documents\visual studio 2015\projects\place stealer\place stealer\place stealer.cpp 26
Error C2146 syntax error: missing ';' before identifier 'serialize' Place Stealer c:\users\owner\documents\visual studio 2015\projects\place stealer\place stealer\place stealer.cpp 26
Error C2039 'ostream': is not a member of 'std' Place Stealer c:\users\owner\documents\visual studio 2015\projects\place stealer\place stealer\place stealer.cpp 31
Error C2065 'ostream': undeclared identifier Place Stealer c:\users\owner\documents\visual studio 2015\projects\place stealer\place stealer\place stealer.cpp 31
Error C2065 'export_stream': undeclared identifier Place Stealer c:\users\owner\documents\visual studio 2015\projects\place stealer\place stealer\place stealer.cpp 31
Error C2039 'vector': is not a member of 'std' Place Stealer c:\users\owner\documents\visual studio 2015\projects\place stealer\place stealer\place stealer.cpp 31
Error C2065 'vector': undeclared identifier Place Stealer c:\users\owner\documents\visual studio 2015\projects\place stealer\place stealer\place stealer.cpp 31
Error C2275 'instance_shared_ptr': illegal use of this type as an expression Place Stealer c:\users\owner\documents\visual studio 2015\projects\place stealer\place stealer\place stealer.cpp 31
Error C2065 'instance_vector': undeclared identifier Place Stealer c:\users\owner\documents\visual studio 2015\projects\place stealer\place stealer\place stealer.cpp 31
Error C2448 'Dump_Instance_Vector': function-style initializer appears to be a function definition Place Stealer c:\users\owner\documents\visual studio 2015\projects\place stealer\place stealer\place stealer.cpp 32
Error C2039 'string': is not a member of 'std' Place Stealer c:\users\owner\documents\visual studio 2015\projects\place stealer\place stealer\place stealer.cpp 37
Error C2143 syntax error: missing ';' before '*' Place Stealer c:\users\owner\documents\visual studio 2015\projects\place stealer\place stealer\place stealer.cpp 37
Error C4430 missing type specifier - int assumed. Note: C++ does not support default-int Place Stealer c:\users\owner\documents\visual studio 2015\projects\place stealer\place stealer\place stealer.cpp 37
Error C2086 'int string': redefinition Place Stealer c:\users\owner\documents\visual studio 2015\projects\place stealer\place stealer\place stealer.cpp 37
Error C2059 syntax error: '{' Place Stealer c:\users\owner\documents\visual studio 2015\projects\place stealer\place stealer\place stealer.cpp 37
Error C2143 syntax error: missing ';' before '{' Place Stealer c:\users\owner\documents\visual studio 2015\projects\place stealer\place stealer\place stealer.cpp 37
Error C2447 '{': missing function header (old-style formal list?) Place Stealer c:\users\owner\documents\visual studio 2015\projects\place stealer\place stealer\place stealer.cpp 37
Error C2039 'string': is not a member of 'std' Place Stealer c:\users\owner\documents\visual studio 2015\projects\place stealer\place stealer\place stealer.cpp 41
Error C2061 syntax error: identifier 'string' Place Stealer c:\users\owner\documents\visual studio 2015\projects\place stealer\place stealer\place stealer.cpp 41
Error C2227 left of '->c_str' must point to class/struct/union/generic type Place Stealer c:\users\owner\documents\visual studio 2015\projects\place stealer\place stealer\place stealer.cpp 46
Error C2065 'Name': undeclared identifier Place Stealer c:\users\owner\documents\visual studio 2015\projects\place stealer\place stealer\place stealer.cpp 46
Error C2228 left of '.c_str' must have class/struct/union Place Stealer c:\users\owner\documents\visual studio 2015\projects\place stealer\place stealer\place stealer.cpp 46
Error C2660 'strcmp': function does not take 1 arguments Place Stealer c:\users\owner\documents\visual studio 2015\projects\place stealer\place stealer\place stealer.cpp 46
Error C2039 'exit': is not a member of 'std' Place Stealer c:\users\owner\documents\visual studio 2015\projects\place stealer\place stealer\place stealer.cpp 66
Error C3861 'exit': identifier not found Place Stealer c:\users\owner\documents\visual studio 2015\projects\place stealer\place stealer\place stealer.cpp 66
Error C2039 'stringstream': is not a member of 'std' Place Stealer c:\users\owner\documents\visual studio 2015\projects\place stealer\place stealer\place stealer.cpp 74
Error C2065 'stringstream': undeclared identifier Place Stealer c:\users\owner\documents\visual studio 2015\projects\place stealer\place stealer\place stealer.cpp 74
Error C2146 syntax error: missing ';' before identifier 'RBXMX_Log' Place Stealer c:\users\owner\documents\visual studio 2015\projects\place stealer\place stealer\place stealer.cpp 74
Error C2065 'RBXMX_Log': undeclared identifier Place Stealer c:\users\owner\documents\visual studio 2015\projects\place stealer\place stealer\place stealer.cpp 74
Error C2065 'stdout': undeclared identifier Place Stealer c:\users\owner\documents\visual studio 2015\projects\place stealer\place stealer\place stealer.cpp 82
Error C3861 'freopen': identifier not found Place Stealer c:\users\owner\documents\visual studio 2015\projects\place stealer\place stealer\place stealer.cpp 82
Error C2065 'stdin': undeclared identifier Place Stealer c:\users\owner\documents\visual studio 2015\projects\place stealer\place stealer\place stealer.cpp 83
Error C3861 'freopen': identifier not found Place Stealer c:\users\owner\documents\visual studio 2015\projects\place stealer\place stealer\place stealer.cpp 83
Error C2039 'cout': is not a member of 'std' Place Stealer c:\users\owner\documents\visual studio 2015\projects\place stealer\place stealer\place stealer.cpp 87
Error C2065 'cout': undeclared identifier Place Stealer c:\users\owner\documents\visual studio 2015\projects\place stealer\place stealer\place stealer.cpp 87
Error C2039 'cin': is not a member of 'std' Place Stealer c:\users\owner\documents\visual studio 2015\projects\place stealer\place stealer\place stealer.cpp 88
Error C2065 'cin': undeclared identifier Place Stealer c:\users\owner\documents\visual studio 2015\projects\place stealer\place stealer\place stealer.cpp 88
Error C2065 'RBXMX_FileName': undeclared identifier Place Stealer c:\users\owner\documents\visual studio 2015\projects\place stealer\place stealer\place stealer.cpp 88
Error C3861 'getline': identifier not found Place Stealer c:\users\owner\documents\visual studio 2015\projects\place stealer\place stealer\place stealer.cpp 88
Error C2065 'RBXMX_Out': undeclared identifier Place Stealer c:\users\owner\documents\visual studio 2015\projects\place stealer\place stealer\place stealer.cpp 89
Error C2039 'ofstream': is not a member of 'std' Place Stealer c:\users\owner\documents\visual studio 2015\projects\place stealer\place stealer\place stealer.cpp 89
Error C2065 'RBXMX_FileName': undeclared identifier Place Stealer c:\users\owner\documents\visual studio 2015\projects\place stealer\place stealer\place stealer.cpp 89
Error C3083 'ios_base': the symbol to the left of a '::' must be a type Place Stealer c:\users\owner\documents\visual studio 2015\projects\place stealer\place stealer\place stealer.cpp 89
Error C2039 'out': is not a member of 'std' Place Stealer c:\users\owner\documents\visual studio 2015\projects\place stealer\place stealer\place stealer.cpp 89
Error C2065 'out': undeclared identifier Place Stealer c:\users\owner\documents\visual studio 2015\projects\place stealer\place stealer\place stealer.cpp 89
Error C2039 'binary': is not a member of 'std' Place Stealer c:\users\owner\documents\visual studio 2015\projects\place stealer\place stealer\place stealer.cpp 89
Error C2065 'binary': undeclared identifier Place Stealer c:\users\owner\documents\visual studio 2015\projects\place stealer\place stealer\place stealer.cpp 89
Error C2065 'RBXMX_Out': undeclared identifier Place Stealer c:\users\owner\documents\visual studio 2015\projects\place stealer\place stealer\place stealer.cpp 90
Error C2228 left of '.fail' must have class/struct/union Place Stealer c:\users\owner\documents\visual studio 2015\projects\place stealer\place stealer\place stealer.cpp 90
Error C2039 'cout': is not a member of 'std' Place Stealer c:\users\owner\documents\visual studio 2015\projects\place stealer\place stealer\place stealer.cpp 92
Error C2065 'cout': undeclared identifier Place Stealer c:\users\owner\documents\visual studio 2015\projects\place stealer\place stealer\place stealer.cpp 92
Error C2039 'cout': is not a member of 'std' Place Stealer c:\users\owner\documents\visual studio 2015\projects\place stealer\place stealer\place stealer.cpp 97
Error C2065 'cout': undeclared identifier Place Stealer c:\users\owner\documents\visual studio 2015\projects\place stealer\place stealer\place stealer.cpp 97
Error C2065 'serialize': undeclared identifier Place Stealer c:\users\owner\documents\visual studio 2015\projects\place stealer\place stealer\place stealer.cpp 99
Error C2064 term does not evaluate to a function taking 1 arguments Place Stealer c:\users\owner\documents\visual studio 2015\projects\place stealer\place stealer\place stealer.cpp 99
Error C2039 'cout': is not a member of 'std' Place Stealer c:\users\owner\documents\visual studio 2015\projects\place stealer\place stealer\place stealer.cpp 102
Error C2065 'cout': undeclared identifier Place Stealer c:\users\owner\documents\visual studio 2015\projects\place stealer\place stealer\place stealer.cpp 102
Error C2227 left of '->c_str' must point to class/struct/union/generic type Place Stealer c:\users\owner\documents\visual studio 2015\projects\place stealer\place stealer\place stealer.cpp 107
Error C2039 'cout': is not a member of 'std' Place Stealer c:\users\owner\documents\visual studio 2015\projects\place stealer\place stealer\place stealer.cpp 109
Error C2065 'cout': undeclared identifier Place Stealer c:\users\owner\documents\visual studio 2015\projects\place stealer\place stealer\place stealer.cpp 109
Error C2039 'cout': is not a member of 'std' Place Stealer c:\users\owner\documents\visual studio 2015\projects\place stealer\place stealer\place stealer.cpp 114
Error C2065 'cout': undeclared identifier Place Stealer c:\users\owner\documents\visual studio 2015\projects\place stealer\place stealer\place stealer.cpp 114
Error C2660 'GetChildByName': function does not take 2 arguments Place Stealer c:\users\owner\documents\visual studio 2015\projects\place stealer\place stealer\place stealer.cpp 115
Error C2065 'RBXMX_Out': undeclared identifier Place Stealer c:\users\owner\documents\visual studio 2015\projects\place stealer\place stealer\place stealer.cpp 122
Error C2039 'vector': is not a member of 'std' Place Stealer c:\users\owner\documents\visual studio 2015\projects\place stealer\place stealer\place stealer.cpp 122
Error C2065 'vector': undeclared identifier Place Stealer c:\users\owner\documents\visual studio 2015\projects\place stealer\place stealer\place stealer.cpp 122
Error C2275 'instance_shared_ptr': illegal use of this type as an expression Place Stealer c:\users\owner\documents\visual studio 2015\projects\place stealer\place stealer\place stealer.cpp 122
Error C2059 syntax error: ')' Place Stealer c:\users\owner\documents\visual studio 2015\projects\place stealer\place stealer\place stealer.cpp 122
Error C2039 'exception': is not a member of 'std' Place Stealer c:\users\owner\documents\visual studio 2015\projects\place stealer\place stealer\place stealer.cpp 124
Error C2061 syntax error: identifier 'exception' Place Stealer c:\users\owner\documents\visual studio 2015\projects\place stealer\place stealer\place stealer.cpp 124
Error C2310 catch handlers must specify one type Place Stealer c:\users\owner\documents\visual studio 2015\projects\place stealer\place stealer\place stealer.cpp 124
Error C2039 'cout': is not a member of 'std' Place Stealer c:\users\owner\documents\visual studio 2015\projects\place stealer\place stealer\place stealer.cpp 126
Error C2065 'cout': undeclared identifier Place Stealer c:\users\owner\documents\visual studio 2015\projects\place stealer\place stealer\place stealer.cpp 126
Error C2065 'e': undeclared identifier Place Stealer c:\users\owner\documents\visual studio 2015\projects\place stealer\place stealer\place stealer.cpp 126
Error C2228 left of '.what' must have class/struct/union Place Stealer c:\users\owner\documents\visual studio 2015\projects\place stealer\place stealer\place stealer.cpp 126
Error C2039 'cout': is not a member of 'std' Place Stealer c:\users\owner\documents\visual studio 2015\projects\place stealer\place stealer\place stealer.cpp 132
Error C2065 'cout': undeclared identifier Place Stealer c:\users\owner\documents\visual studio 2015\projects\place stealer\place stealer\place stealer.cpp 132
Error C2065 'RBXMX_Out': undeclared identifier Place Stealer c:\users\owner\documents\visual studio 2015\projects\place stealer\place stealer\place stealer.cpp 133
Error C2228 left of '.close' must have class/struct/union Place Stealer c:\users\owner\documents\visual studio 2015\projects\place stealer\place stealer\place stealer.cpp 133
感谢任何帮助,再次感谢!
答案 0 :(得分:3)
使用预编译头时,编译器认为该文件始终以#include "stdafx.h"
开头,并跳过之前的所有内容。
所以只需重新排序您的包含,以便#include "stdafx.h"
是第一个。