Why ghidra skip some some address - ghidra

I have an so. Load in ghidra and set the base address to 0. I found that some address has skipped like this:
And the so is:
https://www.dropbox.com/s/wmea0pcirzopoll/libxxx.so?dl=0

Related

How to use printk to print a physical address (aka phys_addr_t)?

I want to print real physical address that is stored in a variable of type phys_addr_t. Now I'm doing something like this:
phys_addr_t paddr;
...
paddr = virt_to_phys(some_virt_addr);
pr_info("%pa", &paddr);
...
As for documentation:
Physical addresses types ``phys_addr_t``
========================================
::
%pa[p] 0x01234567 or 0x0123456789abcdef
For printing a ``phys_addr_t`` type (and its derivatives, such as
``resource_size_t``) which can vary based on build options, regardless of
the width of the CPU data path. Passed by reference.
but I'm a bit confused about Passed by reference, because it is already something like reference. So my actual questions are:
How to correctly print phys_addr_t using printk?
What does Passed by reference mean here?
What does the [p] postfix of %pa[p] mean?
If my example is not correct or inefficient, please show me how it should be.
You are doing it correctly:
phys_addr_t paddr = 0x1234;
printk(KERN_INFO "%pa\n", &paddr);
// Result: 0x0000000000001234
"Pass by reference" means to pass a pointer to the physical address you want to print (&paddr) instead of directly passing its value (paddr).
The [p] suffix in the documentation means that the last p is optional. You can use %pa or %pap. The final p is not necessary and also doesn't change the output format (as you can see from the source here).

Linker error: "bad address <value> for zero page symbol <name>"!

I'm trying to make COSMIC compiler allocate a struct at a specific address in the memory (0x5420). I added the following lines in my C code (where CAN_TypeDef is a typedef struct):
#pragma section [mycan]
CAN_TypeDef CAN;
#pragma section []
In the IDE (STVD), I created a new section named Can inside which I created a new section named .mycan.
When I build the code in STVD, a linker error appears saying:
#error clnk Debug\can.lkf:1 bad address (0x5420) for zero page symbol _CAN
In the above picture, it is clear that Can and Zero Page are two different segments. What can be the cause of this error and how can I solve it?
I don't know the STM8, but I think I found it. In the STVD documentation I read:
Global variables
When the category is set to General , you can use
the Global Variables list box to specify the default location of
global variables:
In Zero Page: This is the default option.
In Data: Specifies to place global variables in the first 64Kbytes of
memory.
So the compiler assumes all global data sitting in the zero page and the addresses are just eight bit wide. Only the linker sees that the section .mycan is not in the zero page and you get an error. I would try #near CAN_TypeDef CAN; or simply extern CAN_TypeDef CAN #5420; without creating your own section.

How to specify custom section start addresses for PE sections?

On Linux, when linking I can specify any virtual address for a section:
ld -Ttext 0x10000000 -Tdata 0x20000000 foo.o -o foo
But I don't see such option for Windows' link.exe.
Is it possible to specify PE section start addresses somehow?
MinGW ld can put the sections at arbitrary addresses. Dumpbin and disassemblers can handle it without problem.
But it seems Windows does not accept anything but the default address: if you try to set it to a different value Windows will say "not a valid Win32 application".
The base address must be 0x400000 or 0x1000000.
And the .text section must be at 0x401000 or 0x1001000.
Also it seems no gaps allowed between the sections. If I try to place the .data section to 0x403000 instead of 0x402000, then Windows is unable to load it...
(I maybe wrong, or mingw ld is buggy...)
When using GCC, this page explains how to define variables at absolute addresses (including mentioning the section in which they should reside) : https://mcuoneclipse.com/2012/11/01/defining-variables-at-absolute-addresses-with-gcc/
The idea I use here is to put the variable with a special section
name, and then place it in the linker file at an absolute address.
unsigned char __attribute__((section (".myBufSection"))) buf[128]
__attribute__ ((aligned (512)));
With this, my variable will be put into a section named
‘.myBufSection’, and it will be aligned on a 512 address boundary.
The next step is to place that section at an address in the linker file.
SECTIONS
{
/* placing my named section at given address: */
.myBufBlock 0x20000000 :
{
KEEP(*(.myBufSection)) /* keep my variable even if not referenced */
} > m_data
/* other placements follow here... */
}
PS: Another method is mentioned in How can I declare a variable at an absolute address with GCC?
PS 2: Another related (alas unanswered) question is this : How to place a variable at a given absolute address in memory (with Visual C++)

validating ip address in datastage

I have a source file that contains two fields: IP_ADDRESS and USER_NAME. I want to check whether the IP address is correct or not before loading it to the datawarehouse using DATASTAGE. How do I do this?
I was browsing Stack Overflow and think I might have a solution to your question. If you create a job to grab all of the IP_ADDRESS's from the file and send them to a BASIC transformer (search for BASIC transformer in DataStage. It is NOT the one that is normally on the palette). From there, set the Stage Variables as 'SetUserStatus() and write out the column name to a peek stage (You don't need the output at all. The SetUserStatus is the important part). This will now allow you to pass up the Command Output (list of IP Addresses) to a Sequence. From the Sequence, start with the job you just created (BASIC transformer job) and link that to a User Variables Activity. In the User Variables Activity stage, Set the name to something like 'IP Address' and Expression as IP_ADDRESS.$UserStatus. You can then use a Loop to take that output that is now a List and send each individual IP Address to an Execute Stage with a Ping command to see if it returns a valid IP Address. If it does return a valid IP then have your job that writes the USER_NAME and IP_ADDRESS to do a 'Select' statement where the IP_ADDRESS = the valid IP_ADDRESS. For the ones that aren't valid, you can send them down a different path and have them write out to '.txt' file somewhere so you know which ones weren't valid. I'm sure you will need a few more steps in there but that should be the gist of it.
Hope my quick stab at your issue helps.
Yes, you can use a transformer or a transformer and a filter to do that, depending on the version of Datastage you're using. If you're using PX, just encode the validation logic in a transformer stage, and then, on the output link set up a filter that doesn't allow the rows to pass forward if they didn't pass the validation logic.

Is it possible for me to check and see if a value is entered in for ipv4?

I have a requirement to ensure that a value is entered in a server for ipv4 ip address, subnet mask, default gateway, a value for DNS and a value for WINS.
I don't necessarily need to check against those values to ensure they are correct since the correct values are pulled from a seperate internal website. I don't have any way to interface with it. So I just want to make sure it is completely entered and ipv6 is not being used.
I can't seem to find anything to help me on this. I looked through the registry to see if I could find anything there to grab.
No luck =/
Any suggestions?
Your question is unclear. It almost sounds like you want to read a value from an input field, but then you say something about the registry. You need to ask more clearly where you are looking for said information.
With that in mind, assuming you mean you want to figure out if the system has acquired an IP address, etc., then consider the following.
1) You can use the Run method and execute ipconfig /all and parse its results.
2) You can use netsh.exe and parse results. For example:
C:\> netsh interface ipv6 show address
IPv6 is not installed.
There is a lot of information that is able to be gained through this method.
3) You can look in the Registry.
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\NetworkCards usually contains a list of numeric sub-keys. For example, on my system, there is HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\NetworkCards\9. This key contains values:
Description REG_SZ "Broadcom NetXtreme 57xx Gigabit Controller"
ServiceName REG_SZ "{A1167D26-ADE0-4CDB-B0C6-1F8C5CF9DF5B}"
Of course, that ServiceName GUID will differ. It is unique to each system, but for the following, I will use it in examples. You have to replace it by what your system has.
This points to HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\{A1167D26-ADE0-4CDB-B0C6-1F8C5CF9DF5B}\Parameters\Tcpip where the following values are stored:
"EnableDHCP"=dword:00000001
"IPAddress"=hex(7):30,00,2e,00,30,00,2e,00,30,00,2e,00,30,00,00,00,00,00
"SubnetMask"=hex(7):30,00,2e,00,30,00,2e,00,30,00,2e,00,30,00,00,00,00,00
"DefaultGateway"=hex(7):00,00
"DhcpIPAddress"="10.152.30.49"
"DhcpSubnetMask"="255.255.255.0"
"DhcpServer"="10.152.28.23"
"Lease"=dword:0003f480
"LeaseObtainedTime"=dword:503f5dd6
"T1"=dword:50415816
"T2"=dword:5042d3c6
"LeaseTerminatesTime"=dword:50435256
"DhcpDefaultGateway"=hex(7):31,00,30,00,2e,00,31,00,35,00,32,00,2e,00,33,00,30,\
00,2e,00,31,00,00,00,00,00
"DhcpSubnetMaskOpt"=hex(7):32,00,35,00,35,00,2e,00,32,00,35,00,35,00,2e,00,32,\
00,35,00,35,00,2e,00,30,00,00,00,00,00
It also points to HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces\{A1167D26-ADE0-4CDB-B0C6-1F8C5CF9DF5B} where the following values are stored:
"UseZeroBroadcast"=dword:00000000
"EnableDeadGWDetect"=dword:00000001
"EnableDHCP"=dword:00000001
"IPAddress"=hex(7):30,00,2e,00,30,00,2e,00,30,00,2e,00,30,00,00,00,00,00
"SubnetMask"=hex(7):30,00,2e,00,30,00,2e,00,30,00,2e,00,30,00,00,00,00,00
"DefaultGateway"=hex(7):00,00
"DefaultGatewayMetric"=hex(7):00,00
"NameServer"=""
"Domain"=""
"RegistrationEnabled"=dword:00000001
"RegisterAdapterName"=dword:00000000
"TCPAllowedPorts"=hex(7):30,00,00,00,00,00
"UDPAllowedPorts"=hex(7):30,00,00,00,00,00
"RawIPAllowedProtocols"=hex(7):30,00,00,00,00,00
"NTEContextList"=hex(7):30,00,78,00,30,00,30,00,30,00,30,00,30,00,30,00,30,00,\
32,00,00,00,00,00
"DhcpClassIdBin"=hex:
"DhcpServer"="10.152.28.23"
"Lease"=dword:0003f480
"LeaseObtainedTime"=dword:503f5dd6
"T1"=dword:50415816
"T2"=dword:5042d3c6
"LeaseTerminatesTime"=dword:50435256
"IPAutoconfigurationAddress"="0.0.0.0"
"IPAutoconfigurationMask"="255.255.0.0"
"IPAutoconfigurationSeed"=dword:00000000
"AddressType"=dword:00000000
"IsServerNapAware"=dword:00000000
"DhcpIPAddress"="10.152.30.49"
"DhcpSubnetMask"="255.255.255.0"
"DhcpRetryTime"=dword:0001fa40
"DhcpRetryStatus"=dword:00000000
"DhcpNameServer"="10.125.28.23 10.125.28.21 192.168.115.2"
"DhcpDefaultGateway"=hex(7):31,00,30,00,2e,00,31,00,35,00,32,00,2e,00,33,00,30,\
00,2e,00,31,00,00,00,00,00
"DhcpDomain"="my.domain.Local"
"DhcpSubnetMaskOpt"=hex(7):32,00,35,00,35,00,2e,00,32,00,35,00,35,00,2e,00,32,\
00,35,00,35,00,2e,00,30,00,00,00,00,00
This should get you started. Presumably, you can search the registry for {A1167D26-ADE0-4CDB-B0C6-1F8C5CF9DF5B} for other interesting information relating to your network adapter. For example:
HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Services\Dhcp\Parameters\...
HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Services\LanmanServer\Linkage\...
HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Services\lanmanworkstation\Linkage\...
... and so on ...
Each of those locations is rich with cross-references and data about the network sub-system.
4) See also Get active network interface on Windows. In particular, look at the answer that starts out:
You don't need make a new API. Use the WMI class from VBScript.
http://msdn.microsoft.com/en-us/library/windows/desktop/aa394216(v=vs.85).aspx
5) A link of helpful WMIC commands is here: WMIC-Snippets > NIC properties

Resources