• Welcome to Valhalla Legends Archive.
 

Question [c++]

Started by iago, February 05, 2003, 06:02 PM

Previous topic - Next topic

iago

Does anybody know how I could get a pointer to the beginning and the end of (my own) program's datasegment?  I tried adding a void FirstFunction() and void LastFunction() but that didn't work :-/
This'll make an interesting test for broken AV:
QuoteX5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*


Yoni

#1
You would have to open your PE header (in memory) and parse it to get that.

iago

#2
So there's no function GetPointerToEnd() ? :-(
This'll make an interesting test for broken AV:
QuoteX5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*


Yoni

#3
AFAIK there is no AllPurposeMagicFunctions.dll

iago

#4
I guess somebody should write it, then...
This'll make an interesting test for broken AV:
QuoteX5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*


Skywing

#5
You turn on .map and .cod generation, and parse those.

Etheran

#6
QuoteBe careful, though, if it was made by a Canadian programmer you might end up with $10000000cdn, which happens to be less than a dollar American!
in that case I would just go with
 deposit_money_in_eths_bank_account('£',100000000);
:)

Arta

#7
What Eth said :P

Banana fanna fo fanna

#8
This isn't an exact answer to your question, but it may help.

You can do stuff like this in C:

void myfunc() {
      DWORD addr;

      __asm {
            mov dword ptr addr, offset [label]
      }
label:
}

iago

#9
hmm.. I like the header idea, but if Storm's actually works it would be a lot easier.  

Thanks!  Can somebody close this topic now?  It's dead :-)
This'll make an interesting test for broken AV:
QuoteX5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*


Adron

#10
I deleted my off-topic post and add this instead:
void printinfo()
{
      unsigned base = (unsigned)GetModuleHandle(0);
      IMAGE_DOS_HEADER *idh = (IMAGE_DOS_HEADER*)base;
      IMAGE_NT_HEADERS *inh = (IMAGE_NT_HEADERS*)((unsigned)idh + idh->e_lfanew);
      IMAGE_SECTION_HEADER *ish = IMAGE_FIRST_SECTION(inh);
      for(int i = 0; i < inh->FileHeader.NumberOfSections; i++) {
            printf("Section %s at %08x ends at %08x, flags %08x\n",
                  ish[i].Name, ish[i].VirtualAddress + base, ish[i].VirtualAddress + base + ish[i].Misc.VirtualSize, ish[i].Characteristics);
      }
}

iago

#11
oooh, very nice, thanks :)
This'll make an interesting test for broken AV:
QuoteX5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*


Banana fanna fo fanna

#12
Can you give some code to convert a virtual addr to a file offset?

Adron

#13
Most of those things are actually in the imagehlp api. If you're doing things that require mapping virtual address to file offset, you're probably modifying executables. Then you should be using the imagehlp api.

Banana fanna fo fanna

#14
I am...it's just that no one taught me how to load memmapped files and I'm lost lol.