Author Topic: (SOLVED)Dll Help  (Read 1933 times)

0 Members and 1 Guest are viewing this topic.

Offline bubzuru

  • Knight
  • **
  • Posts: 395
  • Cookies: 21
  • everything is contained in the data
    • View Profile
    • New School Tools
(SOLVED)Dll Help
« on: September 22, 2012, 06:59:39 pm »
im trying to write a dll that kills the process that loads it. (seems stupid but i have my reasons)

Code: (c) [Select]
#include <windows.h>
#include <stdio.h>

BOOL APIENTRY DllMain (HINSTANCE hInst     /* Library instance handle. */ ,
                       DWORD reason        /* Reason this function is being called. */ ,
                       LPVOID reserved     /* Not used. */ )
{
    switch (reason)
    {
      case DLL_PROCESS_ATTACH:     
        OutputDebugString("Hello From The Dll");
        ExitProcess(-69);   
        break;
      case DLL_PROCESS_DETACH:
        ExitProcess(-69);
        break;
      case DLL_THREAD_ATTACH:
        ExitProcess(-69);
        break;
      case DLL_THREAD_DETACH:
        ExitProcess(-69);
        break;
    }
    /* Returns TRUE on success, FALSE on failure */
    return TRUE;
}

the person that sent me the code also sent a compiled dll (that works) but
when i compile the code then load the dll it doesnt work

here is the program im using to load the dll
Code: (c) [Select]
#include <cstdlib>
#include <iostream>
#include <windows.h>

using namespace std;

int main(int argc, char *argv[])
{
    char* DllName = "TestDll.dll"; /* Name of the dll to be loaded */
   
    /* Load the dll */
    printf("trying to load %s \n", DllName);
    HMODULE EmployeDll = LoadLibrary(DllName); 
   
    /* Give some output */
    if(EmployeDll != 0)
    {
       printf("%s is loaded into memory \n\n", DllName);
      //FreeLibrary(EmployeDll); /* Unload the dll from memory */
    }
    else
      printf("error loading %s into memory \n\n", DllName);
     
    /* And then say goodbye */
    system("PAUSE");
    return EXIT_SUCCESS;
}

any ideas why the code is not working ?
« Last Edit: September 23, 2012, 01:43:07 am by bubzuru »
Damm it feels good to be gangsta
http://bubzuru.comule.com

Offline bubzuru

  • Knight
  • **
  • Posts: 395
  • Cookies: 21
  • everything is contained in the data
    • View Profile
    • New School Tools
Re: Dll Help
« Reply #1 on: September 23, 2012, 12:44:07 am »
has anyone tryd compiling\testing this

its really strange that it wont work for me but works for him. what is wrong ?
Damm it feels good to be gangsta
http://bubzuru.comule.com

Offline bubzuru

  • Knight
  • **
  • Posts: 395
  • Cookies: 21
  • everything is contained in the data
    • View Profile
    • New School Tools
Re: (SOLVED)Dll Help
« Reply #2 on: September 23, 2012, 01:45:33 am »
ok DevC++ sucks ass. problem was DllMain isnt actualy the real entry point in a DevC++ app so it never fires (strange compiler) i switched to a c project and it works now

you guys will like what im doing will post a vid soon
Damm it feels good to be gangsta
http://bubzuru.comule.com

Offline Daemon

  • VIP
  • Baron
  • *
  • Posts: 845
  • Cookies: 153
  • A wise man fears a gentle mans anger
    • View Profile
Re: (SOLVED)Dll Help
« Reply #3 on: September 23, 2012, 02:51:14 am »
triple posts bubzuru...you know better than that :P

but anyways, i was going to make this my next priority but since you've swapped to a C project I'll tone it down a bit. plus im waiting for a question to get answered.... anyways, grats on getting it working
This lifestyle is strictly DIY or GTFO - lucid

Because sexploits are for h0edays - noncetonic


Xires burns the souls of HF skids as a power supply

Offline bubzuru

  • Knight
  • **
  • Posts: 395
  • Cookies: 21
  • everything is contained in the data
    • View Profile
    • New School Tools
Re: (SOLVED)Dll Help
« Reply #4 on: September 23, 2012, 02:50:08 pm »
triple posts bubzuru...you know better than that :P

but anyways, i was going to make this my next priority but since you've swapped to a C project I'll tone it down a bit. plus im waiting for a question to get answered.... anyways, grats on getting it working


i love to double post :) xx

the 3rd post was just to give an answer.  and the answer is, the compiler is shit.
so anyone having the same problem , switch compiler or make it a C project if you dont need any C++ functionality (i dont for this project)

now we all know that calling Shell32 functions or killing the host process in DllMain is obviously non-kosha. but hey if you need to in a c++ dll. dont use DevC++

hope this will help some people with the same problem because i searchd google and didnt find an answer (i had to look at the asm in a debugger) maybe we should give the thread a better title
« Last Edit: September 23, 2012, 02:54:35 pm by bubzuru »
Damm it feels good to be gangsta
http://bubzuru.comule.com