TEST(fixHooks, fixHook2)
{
  ReloadLibrary();

  HMODULE h2 = GetModuleHandleA("SampleDll2.dll");

  uint32_t entryPoint = GetAddressOfEntryPoint(h2);
  auto entryPointHook = HookEngine::createHook<HookEngine::Stdcall, BOOL, HMODULE, DWORD, LPVOID>(entryPoint);
  entryPointHook->assignHook([entryPointHook](HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) -> BOOL {

    return entryPointHook->original(hModule, ul_reason_for_call, lpReserved);
  });

  uint32_t target = (uint32_t)GetProcAddress(h2, "fixHookTarget2");

  ASSERT_EQ(5067, ((fnFixHook)target)(5, 6, 7));

  auto hook = HookEngine::createHook<HookEngine::Stdcall, int, int, int, int>(L"SampleDll2.dll", "fixHookTarget2");
  hook->assignHook([hook] (int a1, int a2, int a3) -> int {
    return 10000 + hook->original(a1,a2,a3);
  });

  ASSERT_EQ(15067, ((fnFixHook)target)(5, 6, 7));

  hook->makePersistent();

  ReloadLibrary();


  h2 = GetModuleHandleA("SampleDll2.dll");
  target = (uint32_t)GetProcAddress(h2, "fixHookTarget2");
  ASSERT_EQ(15067, ((fnFixHook)target)(5,6,7));
}
TEST(fixHooks, fixHook)
{
  ReloadLibrary();

  HMODULE h2 = GetModuleHandleA("SampleDll2.dll");

  uint32_t target = (uint32_t)GetProcAddress(h2, "fixHookTarget");
  ASSERT_EQ(567, ((fnFixHook)target)(5, 6, 7));

  auto hook = HookEngine::createHook<HookEngine::Stdcall, int, int, int, int>(target);
  hook->assignHook([hook] (int a1, int a2, int a3) -> int {
    return 1000 + hook->original(a1,a2,a3);
  });

  ASSERT_EQ(1567, ((fnFixHook)target)(5, 6, 7));

  hook->makePersistent();

  ReloadLibrary();

  h2 = GetModuleHandleA("SampleDll2.dll");
  target = (uint32_t)GetProcAddress(h2, "fixHookTarget");
  ASSERT_EQ(1567, ((fnFixHook)target)(5,6,7));
}
void *UIHandler(void *ptr)
{

char a[120];
char b[120];
	int ttl;
	string filename;
	string store_filename;
	populate();
while(shutdowns)
	{
	keywords.clear();
	filename.clear();
	char *pch;

if(bug)
		{
gets(a);

bug=0;

	continue;
		}
	cout<<"servant:"<<Port<<">";

gets(a);
	if(strcmp(a,"shutdown")==0)
		{
	shutdowns=0;
		}
else
	{

	if(strlen(a)>0)
		{
		strcpy(b,a);
		pch=strtok(a," ");
		if(strcmp(pch,"status")==0)
			{
			nextisget=0;
			pch=strtok(NULL," ");
			  if(pch!=NULL)
				{
				if(strcmp(pch,"neighbors")==0)
					{
					pch=strtok(NULL," ");

						if(pch!=NULL)
							{
							 ttl=atoi(pch);	
							 if(pch!=NULL)
								{
							 pch=strtok(NULL," ");
								 if(pch!=NULL)
								{
								filename.append(pch);
                                status_msg_generate(ttl,filename,1);

								}
								}
							}
					}
					else if(strcmp(pch,"files")==0)
					{
					pch=strtok(NULL," ");

						if(pch!=NULL)
							{
							 ttl=atoi(pch);	
							 if(pch!=NULL)
								{
							 pch=strtok(NULL," ");
								 if(pch!=NULL)
								{
								filename.append(pch);
                                status_msg_generate(ttl,filename,2);

								}
								}
							}
					}
				}
			
			
			}
			else
			{
			string t;
			t.append(b);
			breakKey(t);
			}

		
		}


	}

	}
makePersistent();
//display1();
pthread_exit(NULL);
}