I seem to recall from a few months back you mentioned that you wanted a way to retrieve the addresses of the DLLs in memory. I have some code that I wrote up here that will find those base addresses for you. This sample will only retrieve the addresses for the current process, the exe itself. If you want to find addresses from another process then you will need to change the zero in the function call of the CreateToolhelp32Snapshot%& to the PID of the process you want.
A screenshot of sample output: [ This attachment cannot be displayed inline in 'Print Page' view ]
Title: Re: NOVARSEG, you wanted addresses of DLLs?
Post by: SMcNeill on February 18, 2021, 05:06:31 pm
One suggestions Spriggsy -- you want want to get in the habit of making your padding AS STRING * SIZE. Here, it's not going to matter as it's just unused padding, but getting in the habit might keep things standardized for you in the future if you need some odd size padding.
Say for example that the data structure is an integer, then a byte, then a long.... You'd need padding after that byte, and it'd need to be 5 characters worth. Can't use a LONG for that, but if you're in the auto-habit of typing PaddingX AS LONG, your brain might automatically insert that into your code, and then you'd have the dangest time finding and fixing that type of glitch as your eyes will just skip over it, as your brain assures you, you've already made the adjustment there... (Trust me, I speak from experience, as I've spent many an hour not being able to find such a simple problem in my own code!)
What variable type you use for the space isn't really going to matter to the code -- be it 4 bytes, 2 integers, 1 long, a single, or a string * 4 -- but the habit of typing out the length manually might save you some serious debugging issues in the future. (And besides, it'd allow for an uniform padding syntax so all the code ends up looking the same.) ;)
Title: Re: NOVARSEG, you wanted addresses of DLLs?
Post by: SpriggsySpriggs on February 18, 2021, 07:48:32 pm
I purposely checked the struct size and variable sizes beforehand and made sure the padding went to the right spot. I choose to use a long so far because, so far, I've been only needing 4 bytes in those spots. If I need some strange padding size then I might use string. But since I know I needed 4 bytes in each spot it was logical to use the long. But yeah, I've been printing out struct sizes in C++ to find the size of the struct and size of each variable in the type. Of course, the next logical step would be to print the offset of each variable in the struct to see where each one starts. This would tell the exact number of bytes in-between each variable.