Question

Unable to add a class member (LNK2001)

Asked by: MikeDotNet555

Hi, just learning c++ now and this is probably something really easy to figure out but I just can't seem to find a reason.

I have a class with a few methods, all works fine and I can call a method from my main(), everything is fine up to that point.

The problem I have is when I try to add a new method, I get the following error:
Error      3      error LNK2001: unresolved external symbol "public: void __thiscall WardenHandler::test(void)" (?test@WardenHandler@@QAEXXZ)      Main.obj      WardenCPP

I really can't find out what is causing this, since I am almost sure I declared it the same way as all other methods:
-I have the method definition in my .h file (under public:)
-I have the method body in my .cpp file

I can't see any difference between this definition and the others, so there must be something really east I am overlooking.

Thanks in advance.

This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.

Subscribe now for full access to Experts Exchange and get

Instant Access to this Solution

  • Plus...
  • 30 Day FREE access, no risk, no obligation
  • Collaborate with the world's top tech experts
  • Unlimited access to our exclusive solution database
  • Never be left without tech help again

Subscribe Now

Asked On
2009-11-02 at 09:08:38ID24864310
Topics

C++ Programming Language

,

C Programming Language

Participating Experts
1
Points
500
Comments
6

Trusted by hundreds of thousands everyday for fast, accurate and reliable tech support.

  • "The time we save is the biggest benefit of Experts Exchange to Warner Bros. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange." Mike Kapnisakis, Warner Bros.
  • "Our team likes having a resource that is more secure than just using Google and most experts using this service really know their stuff. It's nice to look here first versus using Google." Dayna Sellner, Lockheed Martin
  • "Anytime that I've been stumped with a problem, 9 out of 10 times Experts Exchange has either the accepted solution or an open discussion of the potential solution to the problem." Kenny Red, eBay Inc.

See what Experts Exchange can do for you.

Got a question?

We've got the answer.

Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.

Screenshot of Experts Exchange Knowledgebase

Need individual assistance?

Our experts are ready to help.

If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.

Screenshot of Experts Exchange Knowledgebase

Want to learn from the best?

Read articles from industry experts.

Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.

Screenshot of an Article

Working on a long term project?

Store your work and research.

Save solutions to your questions, answers you’ve discovered through searching plus helpful articles in your personal knowledgebase for easy future access.

Screenshot of Experts Exchange Knowledgebase

Access the answers to your technology questions today.

Subscribe Now

30-day free trial. Register in 60 seconds.

What Makes Experts Exchange Unique?

Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Trusted by the world's most respected brands.

image of each brand's logo

Faithfully serving IT professionals since 1996.

Experts Exchange Logo

Try it out and discover for yourself.

Subscribe Now

30-day free trial. Register in 60 seconds.

Related Solutions

  1. error LNK2001: unresolved external symbol _
    I am getting the following errors while trying to build an application using TAPI. tapi32.lib is already included in "object/library modules" of Project/Settongs/Link tab MYTAPI_.OBJ : error LNK2001: unresolved external symbol _lineOpenA@36 MYTAPI_.OBJ : error LNK...
  2. error LNK2001: unresolved external symbol
    hi! all i'm creating an input plugin for winamp . i'm getting linking error 2001 & i don't know where & what is going wrong. decod.obj : error LNK2001: unresolved external symbol __fltused decod.obj : error LNK2001: unresolved external symbol __ftol decod...
  3. LNK2001: unresolved external symbol (MS Visual C+…
    Hello, I'm a beginner in C++. Need to know what the following is and how I get rid of it. I'm not advanced in configuring the software - I'll need a "plain English" explanation please (e.g. , menu, settings, click here or there). cube.obj : error LNK2001: un...
  4. Static class member in DLL => LNK2001 in App
    I have a class with a static member RUNLEVEL. This is just an enumeration.: //header class __declspec(dllexport) Logger : public BaseObject { private: static Logger* me; static eRunLevel RUNLEVEL; ..... //source #include "Logger.h" Logger* Logge...
  5. error Lnk2001: unresolved external symbol "void __…
    Hello, I was trying to build a project in VC++ environment. The project includes a .CPP file and rest all .C source files. In the .CPP source file I was trying to call a C function. While building , I was facing the Linker Error: error Lnk2001: unresolved external sy...
  6. Error LNK2001
    I created a class node and try to create an instance of it but it keeps giving me errors; //node.h #ifndef NODE_H #define NODE_H template<class nodetype> class node { public: nodetype getdata(); node(nodetype=0); private:nodetype data; node<no...

Free Tech Articles

  1. WARNING: 5 Reasons why you should NEVER fix a computer for free.
    It is in our nature to love the puzzle. We are obsessed. The lot of us. We love puzzles. We love the challenge. We thrive on finding the answer. We hate disarray. It bothers us deep in our soul. W...
  2. SCCM OSD Basic troubleshooting
    SCCM 2007 OSD is a fantastic way to deploy operating systems, however, like most things SCCM issues can sometimes be difficult to resolve due to the sheer volume of logs to sift through and the dispe...
  3. Migrate Small Business Server 2003 to Exchange 2010 and Windows 2008 R2
    This guide is intended to provide step by step instructions on how to migrate from Small Business Server 2003 to Windows 2008 R2 with Exchange 2010. For this migration to work you will need the fo...
  4. Create a Win7 Gadget
    This article shows you how to create a simple "Gadget" -- a sort of mini-application supported by Windows 7 and Vista. Gadgets can be dropped anywhere on the desktop to provide instant information, ...
  5. Outlook continually prompting for username and password
    There have been a lot of questions recently regarding Outlook prompting for a username and password whilst using Exchange 2007. There are a few reasons why this would happen and I will try to cover t...
  6. Backup Exchange 2010 Information Store using Windows Backup
    There seems to be quite a lot of confusion around the ability to backup Exchange 2010 using the built in Windows Backup feature. This stems from the omission of this feature prior to Exchange 2007 s...

Cloud Class Webinars

  1. Avoiding Bugs in Microsoft Access
    Alison Balter takes and in-depth look at avoiding bugs in Access. In this webinar you will learn about using the immediate window to debug your applications, invoking the debugger, using breakpoints to troubleshoot, stepping through code, setting the next statement to execute, ...
  2. Top 10 Best New Features in Visio 2010
    Scott Helmers gives live demonstrations of the top 10 new features in Visio 2010. This webinar will teach you how to create compelling diagrams by adding shapes to the page with a single click, linking the shapes in a diagram to data in Excel (or SQL Server, or SharePoint), ...
  3. IT Consultant Business Secrets Revealed
    Michael Munger, Experts Exchange tech pro and IT consultant, pulls back the curtain on his very successful businesses and answers question on every IT consultant and business owner should know about. He shares secrets on what he did to solve the 5 most common problems in IT, ...
  4. Disaster Recovery and Business Continuity
    Quest CTO, Mike Billon, gives an overview of the steps involved in building a dunamic disaster recovery plan. Through case studies and an examination of software/hardware tooles for monitoring and testing, you'll gain a better understandin of where you are, where you want ...
  5. Organize Your Visio Diagrams with Containers and Lists
    Scott Helmers uses cross functional flowcharts, wireframe diagrams, data graphic legends and seating charts to teach you: how to ustilize all three new structured diagram components in Visio 2010, the best practices for organizeing shapes in previous version of Visio, how to organize ...
  6. How to Us Objects, Properties, Events and Methods in Microsoft Access
    Alison Dalter gives an in-depbth look at objects, properties, events and methods in Microsoft Access. In this webinar you will learn about using the object browser, referring to objects, working with properties and methods, working with object variables, understanding the ...

Join the Community

Give a Little. Get a Lot.

Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.

Join the Community

Answers

 

by: jkrPosted on 2009-11-02 at 09:23:20ID: 25721377

Please post your code (both .h and .cpp).

 

by: MikeDotNet555Posted on 2009-11-02 at 09:24:50ID: 25721389

ok there it is

.h
#pragma once 
class WardenHandler
{
public:
	WardenHandler(void);
	~WardenHandler(void); 
	typedef struct _WardenFuncList WardenFuncList;
	//from preparation.h
	unsigned char* PrepareModule(const unsigned char* pModule);
	unsigned int getInteger(const unsigned char* pArray, unsigned int dwLocation);
	void insertInteger(const unsigned char* pArray, unsigned int dwLocation, unsigned int dwValue);
	//from intialize.h
	
	
	unsigned char* GenerateRC4KeysEx(_WardenFuncList** ppWFuncList, void* seed, int len);
	WardenFuncList** InitializeWarden(const unsigned char* pModule);
	void test();
private:
}; 
.cpp
#include "WardenHandler.h"
#include <stdio.h>
#include <stdlib.h>
#include <windows.h> 
 
typedef unsigned int uint32_t;
typedef unsigned short uint16_t;
typedef unsigned char uint8_t;
#define module_get_prep_size(a) getInteger(a, 0)
#define memalloc malloc 
#define module_get_int32(a, b) \
	(*(uint32_t*)(a + (uint32_t)b)) 
#define module_get_aint32(a, b) \
	(*(uint32_t*)(&a[b])) 
#define module_get_int16(a, b) \
	(*(uint16_t*)&a[(uint32_t)b]) 
#define module_swap_int16(a) \
	(((a & 0xFF00) >> 8) | ((a & 0xFF) << 8)) 
#define module_set_int32(a, b, c)\
  (*(uint32_t*)(a + b) = c) 
typedef struct{
  uint32_t maped_size; /*00*/
  uint32_t unknown1;   /*04*/
  uint32_t ref_table;  /*08*/
  uint32_t ref_count;  /*0C*/
  uint32_t init_addr;  /*10*/
  uint32_t unknown3;   /*14*/
  uint32_t unknown4;   /*18*/
  uint32_t lib_table;  /*1C*/
  uint32_t lib_count;  /*20*/
  uint32_t unknown5;   /*24*/
}module_header, *pmodule_header; 
typedef struct{
  uint32_t name_address;
  uint32_t function_table;
}library_referance, *plibrary_referance; 
typedef struct _FuncList
{
	void *fpSendPacket; //0x00
	void *fpCheckModule; //0x04
	void *fpLoadModule; //0x08
	void *fpAllocateMemory;//0xC
	void *fpReleaseMemory;//0x10
	void *fpSetRC4Data;//0x14
	void *fpGetRC4Data;//0x18
} FuncList; 
// 
typedef void (__thiscall *fnGenerateRC4Keys)(_WardenFuncList** ppFncList, void* lpData, DWORD dwSize);
typedef void (__thiscall *fnUnloadModule)(_WardenFuncList** ppFncList);
typedef void (__thiscall *fnPacketHandler)(_WardenFuncList** ppFncList, BYTE* pPacket, DWORD dwSize, DWORD* dwBuffer);
typedef void (__thiscall *fnTick)(_WardenFuncList** ppFncList, DWORD _2); // _2 is sum dwOldTick - GetTickCount(); shit .. 
typedef struct _WardenFuncList
{
	fnGenerateRC4Keys fpGenerateRC4Keys;//0x00
	fnUnloadModule * fpUnload;//0x04 - Before it frees everything it will call FuncList:fpSetRC4Data and store the RC4 key
	fnPacketHandler * fpPacketHandler;//0x8
	fnTick * fpTick;//0xC
} WardenFuncList;
typedef WardenFuncList** (__fastcall *fnInitializeModule)(DWORD* lpPtr2Table); 
WardenHandler::WardenHandler(void)
{
} 
WardenHandler::~WardenHandler(void)
{
} 
unsigned char *
WardenHandler::PrepareModule(const unsigned char* source)
{
	uint32_t src_location;
	uint32_t dest_location;
	uint16_t length = 0;
	uint8_t bskip = 0;
	uint16_t *refs;
	uint32_t x = 0;
	uint32_t y = 0;
	library_referance *libs;
	uint8_t *lib;
	HMODULE handle;
	uint32_t function;
	uint32_t func;
	//uint8_t *msgbuff;
	uint32_t dest;
	uint32_t max_size;
	module_header *header = (pmodule_header)source;
	LPCSTR procName; 
	max_size = module_get_prep_size(source);
	dest = (uint32_t)memalloc(max_size);
	memset((uint8_t*)dest, 0, max_size);
	
	memcpy((uint8_t*)dest, source, sizeof(module_header)); 
	src_location = sizeof(module_header) + (header->unknown5 * 12);
	dest_location = module_get_aint32(source, 40); 
	while(dest_location < header->maped_size){
		length = module_get_int16(source, src_location);
		src_location += 2;
		if(!bskip){
			memcpy((uint8_t*)(dest + dest_location), source + src_location, length);
			src_location += length;
		}
		bskip = !bskip;
		dest_location += length;
	}  
	refs = (uint16_t*)(dest + header->ref_table);
	dest_location = 0; 
	for(x = 0; x < header->ref_count; x++){
		dest_location += module_swap_int16(refs[x]);
		module_set_int32(dest, dest_location, (module_get_int32(dest, dest_location) % max_size) + dest);
	} 
	libs = (plibrary_referance)(dest + header->lib_table);
	for(x = 0; x < header->lib_count; x++){
		lib = (uint8_t*)(dest + libs[x].name_address);
		//handle = LoadLibrary((const char*)lib);
		LPCSTR libName = (LPCSTR)lib;
		handle = LoadLibrary(libName);
		
		printf("Loaded library %s at address %x\n", lib, handle);
		function = libs[x].function_table;
		while(module_get_int32(dest, function) != 0){
			func = module_get_int32(dest, function);
			if((func & 0x7FFFFFFF) > max_size){
				//sprintf_s(msgbuff, 500, "Attempted to read API from offset pass end of module: 0x%08Xn", func); write_to_file(msgbuff);
				printf("Attempted to read API from offset pass end of module, BIG ERROR");
				break;
			}
			if(func & 0x80000000){
				procName = (LPCSTR)(func & 0x7FFFFFFF);
				y = (uint32_t)GetProcAddress(handle, procName);
				printf("\t%s mapped at %x\n",procName, y);
				
			}else{
				procName = (const char*)(dest + func);
				y = (uint32_t)GetProcAddress(handle, procName);
				printf("\t%s mapped at %x\n",procName, y);
			}
			module_set_int32(dest, function, y);
			function += 4;
		}
	} 
	return (BYTE*)dest; 

	return 0;
} 

unsigned int 
WardenHandler::getInteger(const unsigned char* pArray, unsigned int dwLocation)
{
	return *(int*)&pArray[dwLocation];
} 

void
WardenHandler::insertInteger(const unsigned char* pArray, unsigned int dwLocation, unsigned int dwValue)
{
	*(unsigned int*)&pArray[dwLocation] = dwValue;
} 
void __stdcall cSendPacket(BYTE* pPacket, DWORD dwSize)
{
	printf("cSendPacket called.");
} 
BOOL __stdcall cCheckModule(BYTE* pModName, DWORD _2)
{
	printf("cCheckModule called.");
	return 0;
} 
WardenFuncList** __stdcall cLoadModule(BYTE* pRC4Key, BYTE* pModule, DWORD dwModSize)
{
	printf("cLoadModule called.\n");
	return 0;
} 
LPVOID __stdcall cAllocateMemory(DWORD dwSize)
{
	void * res = malloc(dwSize);
	printf("cAllocateMemory of size %u\n", dwSize);
	return res;
} 
VOID __stdcall cReleaseMemory(LPVOID lpMemory)
{
	printf("cReleaseMemory called.");
	free(lpMemory);
} 
VOID __stdcall cSetRC4Data(LPVOID lpKeys, DWORD dwSize)
{
	printf("cSetRC4Data called.");
} 
DWORD __stdcall cGetRC4Data(LPVOID lpBuffer, LPDWORD dwSize)
{
	printf("cGetRC4Data buffer=%x, size=%x\n",lpBuffer, *dwSize);
	return 0;
} 

WardenFuncList** 
WardenHandler::InitializeWarden(const unsigned char *pModule)
{
	FuncList dwTable;
	DWORD A, B, C;
	fnInitializeModule fpInitializeModule;
	fnGenerateRC4Keys fpGenerateRC4Keys;
	FuncList *tableptr = NULL;
	WardenFuncList** ppWFuncList; 

	printf("pModule: %u\n", pModule); 
	C = getInteger(pModule, 0x18);
	B = 1 - C; 
	if(B > getInteger(pModule, 0x14))
		return FALSE; 
	A = getInteger(pModule, 0x10); // offsetWardenSetup
	A = getInteger(pModule, A + (B * 4)) + (DWORD)pModule; 
	fpInitializeModule = (fnInitializeModule)A;
	printf("Initialize Function is mapped at %x (%x)\n", A, A - (DWORD)pModule); 
	memset(&dwTable, 0, sizeof(FuncList));
	dwTable.fpSendPacket = cSendPacket;
	dwTable.fpCheckModule = cCheckModule;
	dwTable.fpLoadModule = cLoadModule;
	dwTable.fpAllocateMemory = cAllocateMemory;
	dwTable.fpReleaseMemory = cReleaseMemory;
	dwTable.fpSetRC4Data = cSetRC4Data;
	dwTable.fpGetRC4Data = cGetRC4Data;
	tableptr = &dwTable; 
	ppWFuncList = fpInitializeModule((DWORD*)&tableptr); 
	return ppWFuncList;
}
unsigned char* GenerateRC4KeysEx(_WardenFuncList** ppWFuncList, void* seed, int len)
{
	/*fnGenerateRC4Keys fpGenerateRC4Keys; 
	void* ptr = (void*)*ppWFuncList;
	WardenFuncList* pWardenFuncList = (WardenFuncList*)ptr; 
    fpGenerateRC4Keys = pWardenFuncList->fpGenerateRC4Keys;
	
	uint32_t dwGameHash = 0xaef0e532;
	uint32_t *pGameGash = &dwGameHash;
	
	fpGenerateRC4Keys(ppWFuncList, pGameGash, 4);*/ 
	return 0;
} 
void test()
{ 
}
                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
133:
134:
135:
136:
137:
138:
139:
140:
141:
142:
143:
144:
145:
146:
147:
148:
149:
150:
151:
152:
153:
154:
155:
156:
157:
158:
159:
160:
161:
162:
163:
164:
165:
166:
167:
168:
169:
170:
171:
172:
173:
174:
175:
176:
177:
178:
179:
180:
181:
182:
183:
184:
185:
186:
187:
188:
189:
190:
191:
192:
193:
194:
195:
196:
197:
198:
199:
200:
201:
202:
203:
204:
205:
206:
207:
208:
209:
210:
211:
212:
213:
214:
215:
216:
217:
218:
219:
220:
221:
222:
223:
224:
225:
226:
227:
228:
229:
230:
231:
232:
233:
234:
235:
236:
237:
238:
239:
240:
241:
242:
243:
244:
245:
246:
247:
248:
249:
250:
251:
252:
253:
254:
255:
256:
257:
258:
259:
260:
261:
262:
263:
264:
265:
266:
267:
268:
269:
270:
271:
272:
273:
274:
275:
276:
277:
278:
279:
280:
281:
282:
283:
284:
285:
286:
287:
288:
289:
290:
291:
292:
293:
294:
295:
296:
297:
298:
299:
300:
301:
302:
303:
304:
305:
306:
307:

Select allOpen in new window

 

by: MikeDotNet555Posted on 2009-11-02 at 09:25:42ID: 25721396

note: it's a conversion from C code but I needed __thiscall and I wasn't able to find out how to do it in C (I am not even sure it is possible).

 

by: jkrPosted on 2009-11-02 at 09:31:26ID: 25721451

Um, that's

void test()
{
}

were it should be

void WardenHandler::test()
{
}

You forgot the class specifier, it should compile and link fine that way.

 

by: MikeDotNet555Posted on 2009-11-02 at 09:33:45ID: 31648949

hehe yes you are completly right. Coming from c# that c++ syntax is a little confusing.

Thanks you very much.

 

by: jkrPosted on 2009-11-02 at 09:39:57ID: 25721548

You're most welcome ;o)

20120131-EE-VQP-002

3 Ways to Join

30-Day Free Trial

The Experts

98% positive feedback on 31,087 answers since March 2000. angeliii is a Microsoft Most Valuable Professional for his work with MS SQL Server & Develoment.

He has also proven his knowledge of Visual Basic Programming, PHP Scripting and Oracle Databases.

The Experts

97% positive feedback on 10,752 answers since July 2000. lrmoore has more than 18 years experience in the networking industry.

The six-time Mircosoft MVPs specialties include firewalls, virtual private networking, and network management.

Testimonials

"...and excellent source for support... Kind of like having your very own IT dept." Electriciansnet

Testimonials

"I was apprehensive at signing up at first. However... it has already made my life as an IT administrator much easier." JaCrews

Testimonials

"WOW! You guys have great, active, and knowledgeable people on here." moore50

Business Clients

Business Clients

In the Press

"If you’ve got a question... Experts Exchange can supply an answer.”

In the Press

"...an invaluable aid for both IT professionals and those who require tech support."

In the Press

"where IT professionals provide quick answers on just about any topic"

Business Account Plans

Loading Advertisement...