Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

System.NullReferenceException Help

Status
Not open for further replies.

mikecx

Technical User
Jul 9, 2002
215
US
The following code produces the error in the subject line. Am I missing something simple?


Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim Result As Boolean
Result = InitializeWinIo()
If (Result = False) Then
MsgBox("Whoops ! There is a problem with InitializeWinIo.", vbOKOnly + vbCritical, "VBDumpPhys32")
End If
End Sub

Private Sub submit_button_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles submit_button.Click
Dim PhysVal As Long
Dim Result As Boolean
Result = GetPhysLong(Val("&H" + get_reg.Text()), PhysVal)
ret_val.Clear()
ret_val.AppendText(PhysVal)
ShutdownWinIo()
End Sub
 
First thing I would do is to step though your code at runtime and verify that NOTHING is NULL or being set to NULL.

The error basicly says that something is null, and it shouldn't be.

The PogoWolf
 
Result = GetPhysLong(Val("&H" + get_reg.Text()), PhysVal) is the line that is throwing the error. I'll try stepping through the code and making sure of that but I know get_reg.Text() is not null so i'll check out the other variables. Any other information I can provide that will help with this I will.
 
bool _stdcall GetPhysLong(PBYTE pbPhysAddr, PDWORD pdwPhysVal)
{
PDWORD pdwLinAddr;
HANDLE PhysicalMemoryHandle;

if (!IsWinIoInitialized)
return false;

pdwLinAddr = (PDWORD)MapPhysToLin(pbPhysAddr, 4, &PhysicalMemoryHandle);

if (pdwLinAddr == NULL)
return false;

*pdwPhysVal = *pdwLinAddr;

UnmapPhysicalMemory(PhysicalMemoryHandle, (PBYTE)pdwLinAddr);

return true;
}
 
Also, since it calls mapphystolin i'll add that, sorry it's a bit long.

PBYTE _stdcall MapPhysToLin(PBYTE pbPhysAddr, DWORD dwPhysSize, HANDLE *pPhysicalMemoryHandle)
{
PBYTE pbLinAddr;
tagPhys32Struct Phys32Struct;
DWORD dwBytesReturned;

if (!IsWinIoInitialized)
return false;

if (IsNT)
{
Phys32Struct.dwPhysMemSizeInBytes = dwPhysSize;
Phys32Struct.pvPhysAddress = pbPhysAddr;

if (!DeviceIoControl(hDriver, IOCTL_WINIO_MAPPHYSTOLIN, &Phys32Struct,
sizeof(tagPhys32Struct), &Phys32Struct, sizeof(tagPhys32Struct),
&dwBytesReturned, NULL))
return NULL;
else
{
pbLinAddr = (PBYTE)((DWORD)Phys32Struct.pvPhysMemLin + (DWORD)pbPhysAddr - (DWORD)Phys32Struct.pvPhysAddress);
*pPhysicalMemoryHandle = Phys32Struct.PhysicalMemoryHandle;
}
}
else
{
_asm
{
Mov BX, WORD PTR [pbPhysAddr + 2]
Mov CX, WORD PTR [pbPhysAddr]
Mov SI, WORD PTR [dwPhysSize + 2]
Mov DI, WORD PTR [dwPhysSize]
}

// Call DPMI function MapPhysicalToLinear

DPMICall(0x800, (DWORD)pbPhysAddr);

_asm
{
Jnc Success
Xor BX, BX
Xor CX, CX

Success:

Mov WORD PTR [pbLinAddr + 2], BX
Mov WORD PTR [pbLinAddr], CX
}
}

return pbLinAddr;
}
 
That's going to be difficult as one is just an included dll file. Any idea how to step through something like that?
 
I'm assuming you have the source code. if so, create a new project in your solution and add that source code to it. Then remove the reference to the dll and add a reference, there should be a "Project Reference" tab. Add the new project you created as a reference. Now, when that line is called it will step though the code in your solution, not the dll

-Rick

----------------------
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top