ReactOS.org
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2024
December
November
October
September
August
July
June
May
April
March
February
January
2023
December
November
October
September
August
July
June
May
April
March
February
January
2022
December
November
October
September
August
July
June
May
April
March
February
January
2021
December
November
October
September
August
July
June
May
April
March
February
January
2020
December
November
October
September
August
July
June
May
April
March
February
January
2019
December
November
October
September
August
July
June
May
April
March
February
January
2018
December
November
October
September
August
July
June
May
April
March
February
January
2017
December
November
October
September
August
July
June
May
April
March
February
January
2016
December
November
October
September
August
July
June
May
April
March
February
January
2015
December
November
October
September
August
July
June
May
April
March
February
January
2014
December
November
October
September
August
July
June
May
April
March
February
January
2013
December
November
October
September
August
July
June
May
April
March
February
January
2012
December
November
October
September
August
July
June
May
April
March
February
January
2011
December
November
October
September
August
July
June
May
April
March
February
January
2010
December
November
October
September
August
July
June
May
April
March
February
January
2009
December
November
October
September
August
July
June
May
April
March
February
January
2008
December
November
October
September
August
July
June
May
April
March
February
January
2007
December
November
October
September
August
July
June
May
April
March
February
January
2006
December
November
October
September
August
July
June
May
April
March
February
January
2005
December
November
October
September
August
July
June
May
April
March
February
January
2004
December
November
October
September
August
July
June
May
April
March
February
List overview
Download
Ros-diffs
November 2006
----- 2024 -----
December 2024
November 2024
October 2024
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
----- 2013 -----
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
----- 2012 -----
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
----- 2011 -----
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
----- 2010 -----
December 2010
November 2010
October 2010
September 2010
August 2010
July 2010
June 2010
May 2010
April 2010
March 2010
February 2010
January 2010
----- 2009 -----
December 2009
November 2009
October 2009
September 2009
August 2009
July 2009
June 2009
May 2009
April 2009
March 2009
February 2009
January 2009
----- 2008 -----
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
April 2008
March 2008
February 2008
January 2008
----- 2007 -----
December 2007
November 2007
October 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007
February 2007
January 2007
----- 2006 -----
December 2006
November 2006
October 2006
September 2006
August 2006
July 2006
June 2006
May 2006
April 2006
March 2006
February 2006
January 2006
----- 2005 -----
December 2005
November 2005
October 2005
September 2005
August 2005
July 2005
June 2005
May 2005
April 2005
March 2005
February 2005
January 2005
----- 2004 -----
December 2004
November 2004
October 2004
September 2004
August 2004
July 2004
June 2004
May 2004
April 2004
March 2004
February 2004
ros-diffs@reactos.org
16 participants
324 discussions
Start a n
N
ew thread
[fireball] 24787: Add PsInitialSystemProcess declaration into winddk.h (fixes win32k compilation)
by fireball@svn.reactos.org
Author: fireball Date: Sun Nov 19 23:24:46 2006 New Revision: 24787 URL:
http://svn.reactos.org/svn/reactos?rev=24787&view=rev
Log: Add PsInitialSystemProcess declaration into winddk.h (fixes win32k compilation) Modified: trunk/reactos/include/ddk/winddk.h Modified: trunk/reactos/include/ddk/winddk.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/ddk/winddk.h?rev=2…
============================================================================== --- trunk/reactos/include/ddk/winddk.h (original) +++ trunk/reactos/include/ddk/winddk.h Sun Nov 19 23:24:46 2006 @@ -9878,6 +9878,7 @@ PsTerminateSystemThread( IN NTSTATUS ExitStatus); +extern NTSYSAPI PEPROCESS PsInitialSystemProcess; /** Security reference monitor routines **/
18 years, 1 month
1
0
0
0
[greatlrd] 24786: remove the start of reactos vbe directdraw support until it is ready. allot problem with current code. so I discde to remove it from reactos, untill it is stable.
by greatlrd@svn.reactos.org
Author: greatlrd Date: Sun Nov 19 23:24:15 2006 New Revision: 24786 URL:
http://svn.reactos.org/svn/reactos?rev=24786&view=rev
Log: remove the start of reactos vbe directdraw support until it is ready. allot problem with current code. so I discde to remove it from reactos, untill it is stable. Modified: trunk/reactos/drivers/video/displays/framebuf/enable.c trunk/reactos/drivers/video/displays/framebuf/framebuf.h trunk/reactos/drivers/video/displays/framebuf/framebuf.rbuild Modified: trunk/reactos/drivers/video/displays/framebuf/enable.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/video/displays/fra…
============================================================================== --- trunk/reactos/drivers/video/displays/framebuf/enable.c (original) +++ trunk/reactos/drivers/video/displays/framebuf/enable.c Sun Nov 19 23:24:15 2006 @@ -31,11 +31,7 @@ {INDEX_DrvGetModes, (PFN)DrvGetModes}, {INDEX_DrvSetPalette, (PFN)DrvSetPalette}, {INDEX_DrvSetPointerShape, (PFN)DrvSetPointerShape}, - {INDEX_DrvMovePointer, (PFN)DrvMovePointer}, - {INDEX_DrvGetDirectDrawInfo, (PFN) DrvGetDirectDrawInfo }, - {INDEX_DrvEnableDirectDraw, (PFN) DrvEnableDirectDraw }, - {INDEX_DrvDisableDirectDraw, (PFN) DrvDisableDirectDraw } - + {INDEX_DrvMovePointer, (PFN)DrvMovePointer} }; Modified: trunk/reactos/drivers/video/displays/framebuf/framebuf.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/video/displays/fra…
============================================================================== --- trunk/reactos/drivers/video/displays/framebuf/framebuf.h (original) +++ trunk/reactos/drivers/video/displays/framebuf/framebuf.h Sun Nov 19 23:24:15 2006 @@ -69,42 +69,13 @@ DWORD dwHeap; VIDEOMEMORY* pvmList; BOOL bDDInitialized; - DDPIXELFORMAT ddpfDisplay; - DDHALINFO dxHalInfo; + DDPIXELFORMAT ddpfDisplay; } PDEV, *PPDEV; #define TAG(A, B, C, D) (ULONG)(((A)<<0) + ((B)<<8) + ((C)<<16) + ((D)<<24)) #define DEVICE_NAME L"framebuf" #define ALLOC_TAG TAG('F','B','U','F') - -DWORD CALLBACK -DdCanCreateSurface( LPDDHAL_CANCREATESURFACEDATA pccsd ); - -DWORD CALLBACK -DdCreateSurface(PDD_CREATESURFACEDATA pcsd); - -VOID STDCALL -DrvDisableDirectDraw( - IN DHPDEV dhpdev); - - -BOOL STDCALL -DrvEnableDirectDraw( - IN DHPDEV dhpdev, - OUT DD_CALLBACKS *pCallBacks, - OUT DD_SURFACECALLBACKS *pSurfaceCallBacks, - OUT DD_PALETTECALLBACKS *pPaletteCallBacks); - - -BOOL STDCALL -DrvGetDirectDrawInfo( - IN DHPDEV dhpdev, - OUT DD_HALINFO *pHalInfo, - OUT DWORD *pdwNumHeaps, - OUT VIDEOMEMORY *pvmList, - OUT DWORD *pdwNumFourCCCodes, - OUT DWORD *pdwFourCC); DHPDEV STDCALL Modified: trunk/reactos/drivers/video/displays/framebuf/framebuf.rbuild URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/video/displays/fra…
============================================================================== --- trunk/reactos/drivers/video/displays/framebuf/framebuf.rbuild (original) +++ trunk/reactos/drivers/video/displays/framebuf/framebuf.rbuild Sun Nov 19 23:24:15 2006 @@ -9,7 +9,5 @@ <file>pointer.c</file> <file>screen.c</file> <file>surface.c</file> - <file>ddenable.c</file> - <file>dd.c</file> <file>framebuf.rc</file> </module>
18 years, 1 month
1
0
0
0
[fireball] 24785: Add a typecast to remove a warning
by fireball@svn.reactos.org
Author: fireball Date: Sun Nov 19 23:06:44 2006 New Revision: 24785 URL:
http://svn.reactos.org/svn/reactos?rev=24785&view=rev
Log: Add a typecast to remove a warning Modified: trunk/reactos/lib/rtl/debug.c Modified: trunk/reactos/lib/rtl/debug.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/rtl/debug.c?rev=24785&…
============================================================================== --- trunk/reactos/lib/rtl/debug.c (original) +++ trunk/reactos/lib/rtl/debug.c Sun Nov 19 23:06:44 2006 @@ -283,7 +283,7 @@ /* Setup the output string */ Output.Length = strlen (OutputString); - Output.Buffer = OutputString; + Output.Buffer = (PCHAR)OutputString; /* Call the system service */ return DebugPrompt(&Output, &Input);
18 years, 1 month
1
0
0
0
[gedmurphy] 24784: - merge the latest code from my minibranch: - use a static image to refer to when choosing your image brightness so returning to normal (100) displays the original colours - allow individual colours (RGB) to be adjusted as well as adjusting them all simultaneously - apply the chosen brightness from the dialog to the main image - implement greyscale, so an image can be displayed in black and white - implement inverting of colours so an image can be displayed as a negative.
by gedmurphy@svn.reactos.org
Author: gedmurphy Date: Sun Nov 19 22:49:45 2006 New Revision: 24784 URL:
http://svn.reactos.org/svn/reactos?rev=24784&view=rev
Log: - merge the latest code from my minibranch: - use a static image to refer to when choosing your image brightness so returning to normal (100) displays the original colours - allow individual colours (RGB) to be adjusted as well as adjusting them all simultaneously - apply the chosen brightness from the dialog to the main image - implement greyscale, so an image can be displayed in black and white - implement inverting of colours so an image can be displayed as a negative. Added: trunk/reactos/base/applications/imagesoft/brightness.c Removed: trunk/reactos/base/applications/imagesoft/imageprop.c Modified: trunk/reactos/base/applications/imagesoft/adjust.c trunk/reactos/base/applications/imagesoft/imageprop.h trunk/reactos/base/applications/imagesoft/imagesoft.rbuild trunk/reactos/base/applications/imagesoft/imgedwnd.c trunk/reactos/base/applications/imagesoft/lang/En.rc trunk/reactos/base/applications/imagesoft/mainwnd.c trunk/reactos/base/applications/imagesoft/resource.h Modified: trunk/reactos/base/applications/imagesoft/adjust.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/imagesof…
============================================================================== --- trunk/reactos/base/applications/imagesoft/adjust.c (original) +++ trunk/reactos/base/applications/imagesoft/adjust.c Sun Nov 19 22:49:45 2006 @@ -1,9 +1,10 @@ -#include "precomp.h" +#include <precomp.h> -VOID -AdjustBrightness(PIMAGEADJUST pImgAdj, - HDC hdcMem) +BOOL +DisplayBlackAndWhite(HWND hwnd, + HDC hdcMem, + HBITMAP hBitmap) { BITMAPINFO bi; BITMAP bitmap; @@ -11,34 +12,38 @@ DWORD Count = 0; INT i, j; PBYTE pBits; + RECT rc; + + GetObject(hBitmap, + sizeof(BITMAP), + &bitmap); /* Bitmap header */ bi.bmiHeader.biSize = sizeof(bi.bmiHeader); - bi.bmiHeader.biWidth = pImgAdj->ImageRect.right; - bi.bmiHeader.biHeight = pImgAdj->ImageRect.bottom; + bi.bmiHeader.biWidth = bitmap.bmWidth; + bi.bmiHeader.biHeight = bitmap.bmHeight; bi.bmiHeader.biPlanes = 1; bi.bmiHeader.biBitCount = 32; bi.bmiHeader.biCompression = BI_RGB; - bi.bmiHeader.biSizeImage = pImgAdj->ImageRect.right * 4 * pImgAdj->ImageRect.bottom; + bi.bmiHeader.biSizeImage = bitmap.bmWidth * bitmap.bmHeight * 4; bi.bmiHeader.biClrUsed = 0; bi.bmiHeader.biClrImportant = 0; /* Buffer */ pBits = (PBYTE)HeapAlloc(ProcessHeap, 0, - pImgAdj->ImageRect.right * 4 * pImgAdj->ImageRect.bottom); + bitmap.bmWidth * bitmap.bmHeight * 4); + if (!pBits) + return FALSE; + /* get the bits from the original bitmap */ bRes = GetDIBits(hdcMem, - pImgAdj->hBitmap, + hBitmap, 0, - pImgAdj->ImageRect.bottom, + bitmap.bmHeight, pBits, &bi, DIB_RGB_COLORS); - - GetObject(pImgAdj->hBitmap, - sizeof(BITMAP), - &bitmap); for (i = 0; i < bitmap.bmHeight; i++) { @@ -56,35 +61,22 @@ g = GetGValue(Val); r = GetBValue(Val); - /* Red */ - r += pImgAdj->RedVal; - if (r > 255) r = 255; - else if (r < 0) r = 0; + // get the average color value + Val = (r+g+b)/3; - /* Green */ - g += pImgAdj->GreenVal; - if (g > 255) g = 255; - else if (g < 0) g = 0; - - /* Blue */ - b += pImgAdj->BlueVal; - if (b > 255) b = 255; - else if (b < 0) b = 0; - - /* Store in reverse order */ - Val = RGB(b, g, r); - CopyMemory(&pBits[Count], - &Val, + // assign to RGB color + Val = RGB(Val, Val, Val); + CopyMemory(&pBits[Count], + &Val, 4); - /* RGB color take 4 bytes.The high-order byte must be zero */ - Count += 4; + Count+=4; } } /* Set the new pixel bits */ SetDIBits(hdcMem, - pImgAdj->hBitmap, + hBitmap, 0, bRes, pBits, @@ -95,7 +87,105 @@ 0, pBits); - InvalidateRect(pImgAdj->hPicPrev, - &pImgAdj->ImageRect, + GetClientRect(hwnd, + &rc); + + InvalidateRect(hwnd, + &rc, FALSE); + + return TRUE; } + + +BOOL +DisplayInvertedColors(HWND hwnd, + HDC hdcMem, + HBITMAP hBitmap) +{ + BITMAPINFO bi; + BITMAP bitmap; + BOOL bRes; + DWORD Count = 0; + INT i, j; + PBYTE pBits; + RECT rc; + + GetObject(hBitmap, + sizeof(BITMAP), + &bitmap); + + /* Bitmap header */ + bi.bmiHeader.biSize = sizeof(bi.bmiHeader); + bi.bmiHeader.biWidth = bitmap.bmWidth; + bi.bmiHeader.biHeight = bitmap.bmHeight; + bi.bmiHeader.biPlanes = 1; + bi.bmiHeader.biBitCount = 32; + bi.bmiHeader.biCompression = BI_RGB; + bi.bmiHeader.biSizeImage = bitmap.bmWidth * bitmap.bmHeight * 4; + bi.bmiHeader.biClrUsed = 0; + bi.bmiHeader.biClrImportant = 0; + + /* Buffer */ + pBits = (PBYTE)HeapAlloc(ProcessHeap, + 0, + bitmap.bmWidth * bitmap.bmHeight * 4); + if (!pBits) + return FALSE; + + /* get the bits from the original bitmap */ + bRes = GetDIBits(hdcMem, + hBitmap, + 0, + bitmap.bmHeight, + pBits, + &bi, + DIB_RGB_COLORS); + + for (i = 0; i < bitmap.bmHeight; i++) + { + for (j = 0; j < bitmap.bmWidth; j++) + { + DWORD Val = 0; + INT b, g, r; + + CopyMemory(&Val, + &pBits[Count], + 4); + + b = 255 - GetRValue(Val); + g = 255 - GetGValue(Val); + r = 255 - GetBValue(Val); + + Val = RGB(b, g, r); + + CopyMemory(&pBits[Count], + &Val, + 4); + + Count+=4; + } + } + + /* Set the new pixel bits */ + SetDIBits(hdcMem, + hBitmap, + 0, + bRes, + pBits, + &bi, + DIB_RGB_COLORS); + + HeapFree(ProcessHeap, + 0, + pBits); + + GetClientRect(hwnd, + &rc); + + InvalidateRect(hwnd, + &rc, + FALSE); + + return TRUE; +} Added: trunk/reactos/base/applications/imagesoft/brightness.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/imagesof…
============================================================================== --- trunk/reactos/base/applications/imagesoft/brightness.c (added) +++ trunk/reactos/base/applications/imagesoft/brightness.c Sun Nov 19 22:49:45 2006 @@ -1,0 +1,379 @@ +#include "precomp.h" + +#define BASECOLOUR 100 + + +VOID +AdjustBrightness(HBITMAP hOrigBitmap, + HBITMAP hNewBitmap, + HWND hwnd, + HDC hdcMem, + INT RedVal, + INT GreenVal, + INT BlueVal) +{ + BITMAPINFO bi; + BITMAP bitmap; + BOOL bRes; + DWORD Count = 0; + INT i, j; + PBYTE pBits; + RECT rc; + + GetObject(hNewBitmap, + sizeof(BITMAP), + &bitmap); + + /* Bitmap header */ + bi.bmiHeader.biSize = sizeof(bi.bmiHeader); + bi.bmiHeader.biWidth = bitmap.bmWidth; + bi.bmiHeader.biHeight = bitmap.bmHeight; + bi.bmiHeader.biPlanes = 1; + bi.bmiHeader.biBitCount = 32; + bi.bmiHeader.biCompression = BI_RGB; + bi.bmiHeader.biSizeImage = bitmap.bmWidth * bitmap.bmHeight * 4; + bi.bmiHeader.biClrUsed = 0; + bi.bmiHeader.biClrImportant = 0; + + /* Buffer */ + pBits = (PBYTE)HeapAlloc(ProcessHeap, + 0, + bitmap.bmWidth * bitmap.bmHeight * 4); + if (!pBits) + return; + + /* get the bits from the original bitmap */ + bRes = GetDIBits(hdcMem, + hOrigBitmap, + 0, + bitmap.bmHeight, + pBits, + &bi, + DIB_RGB_COLORS); + + for (i = 0; i < bitmap.bmHeight; i++) + { + for (j = 0; j < bitmap.bmWidth; j++) + { + DWORD Val = 0; + INT b, g, r; + + CopyMemory(&Val, + &pBits[Count], + 4); + + /* Get pixels in reverse order */ + b = GetRValue(Val); + g = GetGValue(Val); + r = GetBValue(Val); + + /* Red */ + r += RedVal; + if (r > 255) r = 255; + else if (r < 0) r = 0; + + /* Green */ + g += GreenVal; + if (g > 255) g = 255; + else if (g < 0) g = 0; + + /* Blue */ + b += BlueVal; + if (b > 255) b = 255; + else if (b < 0) b = 0; + + /* Store in reverse order */ + Val = RGB(b, g, r); + CopyMemory(&pBits[Count], + &Val, + 4); + + /* RGB color take 4 bytes.The high-order byte must be zero */ + Count += 4; + } + } + + /* Set the new pixel bits */ + SetDIBits(hdcMem, + hNewBitmap, + 0, + bRes, + pBits, + &bi, + DIB_RGB_COLORS); + + HeapFree(ProcessHeap, + 0, + pBits); + + GetClientRect(hwnd, + &rc); + + InvalidateRect(hwnd, + &rc, + FALSE); +} + + +static PIMAGEADJUST +OnInitDialog(PIMAGEADJUST pImgAdj, + HWND hDlg, + LPARAM lParam) +{ + pImgAdj = HeapAlloc(ProcessHeap, + 0, + sizeof(IMAGEADJUST)); + if (!pImgAdj) + return NULL; + + + pImgAdj->Info = (PMAIN_WND_INFO)lParam; + if (!pImgAdj->Info->ImageEditors) + goto fail; + + + pImgAdj->hPicPrev = GetDlgItem(hDlg, IDC_PICPREVIEW); + GetClientRect(pImgAdj->hPicPrev, + &pImgAdj->ImageRect); + + /* Make a static copy of the main image */ + pImgAdj->hBitmap = CopyImage(pImgAdj->Info->ImageEditors->hBitmap, + IMAGE_BITMAP, + pImgAdj->ImageRect.right, + pImgAdj->ImageRect.bottom, + LR_CREATEDIBSECTION); + if (!pImgAdj->hBitmap) + goto fail; + + /* Make a copy which will be updated */ + pImgAdj->hPreviewBitmap = CopyImage(pImgAdj->Info->ImageEditors->hBitmap, + IMAGE_BITMAP, + pImgAdj->ImageRect.right, + pImgAdj->ImageRect.bottom, + LR_CREATEDIBSECTION); + if (!pImgAdj->hPreviewBitmap) + goto fail; + + + pImgAdj->RedVal = pImgAdj->BlueVal = pImgAdj->GreenVal = 0; + + /* setup dialog */ + SendDlgItemMessage(hDlg, + IDC_BRI_FULL, + BM_SETCHECK, + BST_CHECKED, + 0); + SendDlgItemMessage(hDlg, + IDC_BRI_TRACKBAR, + TBM_SETRANGE, + TRUE, + (LPARAM)MAKELONG(0, 200)); + SendDlgItemMessage(hDlg, + IDC_BRI_TRACKBAR, + TBM_SETPOS, + TRUE, + (LPARAM)BASECOLOUR); + SetDlgItemText(hDlg, + IDC_BRI_EDIT, + _T("100")); + + return pImgAdj; + +fail: + HeapFree(ProcessHeap, + 0, + pImgAdj); + return NULL; +} + + +static VOID +OnDrawItem(PIMAGEADJUST pImgAdj, + LPARAM lParam) +{ + LPDRAWITEMSTRUCT lpDrawItem; + HDC hdcMem; + + lpDrawItem = (LPDRAWITEMSTRUCT)lParam; + + hdcMem = CreateCompatibleDC(lpDrawItem->hDC); + + if(lpDrawItem->CtlID == IDC_PICPREVIEW) + { + SelectObject(hdcMem, + pImgAdj->hPreviewBitmap); + + BitBlt(lpDrawItem->hDC, + pImgAdj->ImageRect.left, + pImgAdj->ImageRect.top, + pImgAdj->ImageRect.right, + pImgAdj->ImageRect.bottom, + hdcMem, + 0, + 0, + SRCCOPY); + + DeleteDC(hdcMem); + } +} + + +static VOID +OnTrackBar(PIMAGEADJUST pImgAdj, + HWND hDlg) +{ + HDC hdcMem; + DWORD TrackPos; + + TrackPos = (DWORD)SendDlgItemMessage(hDlg, + IDC_BRI_TRACKBAR, + TBM_GETPOS, + 0, + 0); + + SetDlgItemInt(hDlg, + IDC_BRI_EDIT, + TrackPos, + FALSE); + + if (IsDlgButtonChecked(hDlg, IDC_BRI_FULL) == BST_CHECKED) + { + pImgAdj->RedVal = pImgAdj->GreenVal = pImgAdj->BlueVal = TrackPos - BASECOLOUR; + } + else if (IsDlgButtonChecked(hDlg, IDC_BRI_RED) == BST_CHECKED) + { + pImgAdj->RedVal = TrackPos - BASECOLOUR; + } + else if (IsDlgButtonChecked(hDlg, IDC_BRI_GREEN) == BST_CHECKED) + { + pImgAdj->GreenVal = TrackPos - BASECOLOUR; + } + else if (IsDlgButtonChecked(hDlg, IDC_BRI_BLUE) == BST_CHECKED) + { + pImgAdj->BlueVal = TrackPos - BASECOLOUR; + } + + hdcMem = GetDC(pImgAdj->hPicPrev); + + AdjustBrightness(pImgAdj->hBitmap, + pImgAdj->hPreviewBitmap, + pImgAdj->hPicPrev, + hdcMem, + pImgAdj->RedVal, + pImgAdj->GreenVal, + pImgAdj->BlueVal); + + ReleaseDC(pImgAdj->hPicPrev, hdcMem); +} + + +static BOOL +OnCommand(PIMAGEADJUST pImgAdj, + HWND hDlg, + UINT uID) +{ + switch (uID) + { + case IDOK: + { + HDC hdcMem; + + hdcMem = GetDC(pImgAdj->Info->ImageEditors->hSelf); + + AdjustBrightness(pImgAdj->Info->ImageEditors->hBitmap, + pImgAdj->Info->ImageEditors->hBitmap, + pImgAdj->Info->ImageEditors->hSelf, + hdcMem, + pImgAdj->RedVal, + pImgAdj->GreenVal, + pImgAdj->BlueVal); + + ReleaseDC(pImgAdj->Info->ImageEditors->hSelf, + hdcMem); + + EndDialog(hDlg, + uID); + + return TRUE; + } + + case IDCANCEL: + { + EndDialog(hDlg, + uID); + return TRUE; + } + } + + return FALSE; +} + + +INT_PTR CALLBACK +BrightnessProc(HWND hDlg, + UINT message, + WPARAM wParam, + LPARAM lParam) +{ + static PIMAGEADJUST pImgAdj = NULL; + + switch (message) + { + case WM_INITDIALOG: + { + pImgAdj = OnInitDialog(pImgAdj, + hDlg, + lParam); + if (!pImgAdj) + { + EndDialog(hDlg, -1); + return FALSE; + } + + return TRUE; + } + + case WM_DRAWITEM: + { + OnDrawItem(pImgAdj, + lParam); + return TRUE; + } + + case WM_HSCROLL: + { + if (LOWORD(wParam) == TB_THUMBTRACK || + LOWORD(wParam) == TB_ENDTRACK) + { + OnTrackBar(pImgAdj, + hDlg); + } + + return TRUE; + } + + case WM_COMMAND: + { + return OnCommand(pImgAdj, + hDlg, + LOWORD(wParam)); + } + + case WM_DESTROY: + { + if (pImgAdj) + { + if (pImgAdj->hBitmap) + DeleteObject(pImgAdj->hBitmap); + if (pImgAdj->hPreviewBitmap) + DeleteObject(pImgAdj->hPreviewBitmap); + + HeapFree(ProcessHeap, + 0, + pImgAdj); + } + } + } + + return FALSE; +} Removed: trunk/reactos/base/applications/imagesoft/imageprop.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/imagesof…
============================================================================== --- trunk/reactos/base/applications/imagesoft/imageprop.c (original) +++ trunk/reactos/base/applications/imagesoft/imageprop.c (removed) @@ -1,145 +1,0 @@ -#include <precomp.h> - -INT_PTR CALLBACK -BrightnessProc(HWND hDlg, - UINT message, - WPARAM wParam, - LPARAM lParam) -{ - static PIMAGEADJUST pImgAdj = NULL; - - switch (message) - { - case WM_INITDIALOG: - { - pImgAdj = HeapAlloc(ProcessHeap, - 0, - sizeof(IMAGEADJUST)); - if (!pImgAdj) - return -1; - - /* setup values */ - pImgAdj->Info = (PMAIN_WND_INFO)lParam; - pImgAdj->hPicPrev = GetDlgItem(hDlg, IDC_PICPREVIEW); - GetClientRect(pImgAdj->hPicPrev, - &pImgAdj->ImageRect); - - pImgAdj->hBitmap = CopyImage(pImgAdj->Info->ImageEditors->hBitmap, - IMAGE_BITMAP, - pImgAdj->ImageRect.right, - pImgAdj->ImageRect.bottom, - LR_CREATEDIBSECTION); - - pImgAdj->OldTrackPos = 100; - pImgAdj->RedVal = pImgAdj->BlueVal = pImgAdj->GreenVal = 0; - - /* setup dialog */ - SendDlgItemMessage(hDlg, - IDC_BRI_FULL, - BM_SETCHECK, - BST_CHECKED, - 0); - SendDlgItemMessage(hDlg, - IDC_BRI_TRACKBAR, - TBM_SETRANGE, - TRUE, - (LPARAM)MAKELONG(0, 200)); - SendDlgItemMessage(hDlg, - IDC_BRI_TRACKBAR, - TBM_SETPOS, - TRUE, - (LPARAM)100); - SetDlgItemText(hDlg, - IDC_BRI_EDIT, - _T("100")); - - return TRUE; - } - - case WM_DRAWITEM: - { - LPDRAWITEMSTRUCT lpDrawItem; - HDC hdcMem; - - lpDrawItem = (LPDRAWITEMSTRUCT)lParam; - - hdcMem = CreateCompatibleDC(lpDrawItem->hDC); - - if(lpDrawItem->CtlID == IDC_PICPREVIEW) - { - SelectObject(hdcMem, - pImgAdj->hBitmap); - - BitBlt(lpDrawItem->hDC, - pImgAdj->ImageRect.left, - pImgAdj->ImageRect.top, - pImgAdj->ImageRect.right, - pImgAdj->ImageRect.bottom, - hdcMem, - 0, - 0, - SRCCOPY); - - DeleteDC(hdcMem); - } - return TRUE; - } - - case WM_HSCROLL: - { - if (LOWORD(wParam) == TB_THUMBTRACK || - LOWORD(wParam) == TB_ENDTRACK) - { - HDC hdcMem; - DWORD TrackPos = (DWORD)SendDlgItemMessage(hDlg, - IDC_BRI_TRACKBAR, - TBM_GETPOS, - 0, - 0); - - /* quick hack, change all the colours regardless */ - pImgAdj->RedVal = pImgAdj->BlueVal = pImgAdj->GreenVal = TrackPos - pImgAdj->OldTrackPos; - pImgAdj->OldTrackPos = TrackPos; - - SetDlgItemInt(hDlg, - IDC_BRI_EDIT, - TrackPos, - FALSE); - - hdcMem = GetDC(pImgAdj->hPicPrev); - - AdjustBrightness(pImgAdj, - hdcMem); - - ReleaseDC(pImgAdj->hPicPrev, hdcMem); - - } - - return TRUE; - } - - case WM_COMMAND: - { - if (LOWORD(wParam) == IDOK || - LOWORD(wParam) == IDCANCEL) - { - EndDialog(hDlg, - LOWORD(wParam)); - return TRUE; - } - } - break; - - case WM_DESTROY: - { - DeleteObject(pImgAdj->hBitmap); - - HeapFree(ProcessHeap, - 0, - pImgAdj); - } - - } - - return FALSE; -} Modified: trunk/reactos/base/applications/imagesoft/imageprop.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/imagesof…
============================================================================== --- trunk/reactos/base/applications/imagesoft/imageprop.h (original) +++ trunk/reactos/base/applications/imagesoft/imageprop.h Sun Nov 19 22:49:45 2006 @@ -4,8 +4,8 @@ PMAIN_WND_INFO Info; HWND hPicPrev; HBITMAP hBitmap; + HBITMAP hPreviewBitmap; RECT ImageRect; - DWORD OldTrackPos; INT RedVal; INT GreenVal; INT BlueVal; @@ -16,10 +16,19 @@ UINT message, WPARAM wParam, LPARAM lParam); + INT_PTR CALLBACK BrightnessProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam); -VOID AdjustBrightness(PIMAGEADJUST pImgAdj, - HDC hdcMem); +VOID AdjustBrightness(HBITMAP hOrigBitmap, + HBITMAP hNewBitmap, + HWND hwnd, + HDC hdcMem, + INT RedVal, + INT GreenVal, + INT BlueVal); + +BOOL DisplayBlackAndWhite(HWND hwnd, HDC hdcMem, HBITMAP hBitmap); +BOOL DisplayInvertedColors(HWND hwnd, HDC hdcMem, HBITMAP hBitmap); Modified: trunk/reactos/base/applications/imagesoft/imagesoft.rbuild URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/imagesof…
============================================================================== --- trunk/reactos/base/applications/imagesoft/imagesoft.rbuild (original) +++ trunk/reactos/base/applications/imagesoft/imagesoft.rbuild Sun Nov 19 22:49:45 2006 @@ -18,10 +18,10 @@ <compilationunit name="unit.c"> <file>about.c</file> <file>adjust.c</file> + <file>brightness.c</file> <file>custcombo.c</file> <file>floatwindow.c</file> <file>font.c</file> - <file>imageprop.c</file> <file>imagesoft.c</file> <file>imgedwnd.c</file> <file>mainwnd.c</file> Modified: trunk/reactos/base/applications/imagesoft/imgedwnd.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/imagesof…
============================================================================== --- trunk/reactos/base/applications/imagesoft/imgedwnd.c (original) +++ trunk/reactos/base/applications/imagesoft/imgedwnd.c Sun Nov 19 22:49:45 2006 @@ -1,4 +1,4 @@ -#include <precomp.h> +#include "precomp.h" static const TCHAR szImageEditWndClass[] = TEXT("ImageSoftEditWndClass"); @@ -33,13 +33,15 @@ } -static VOID +static BOOL LoadBlankCanvas(PEDIT_WND_INFO Info) { /* FIXME: convert this to a DIB Section */ /* set bitmap dimensions */ Info->Width = Info->OpenInfo->New.Width; Info->Height = Info->OpenInfo->New.Height; + + return TRUE; } static BOOL @@ -125,6 +127,8 @@ static BOOL InitEditWnd(PEDIT_WND_INFO Info) { + //BOOL bRet = FALSE; + Info->Zoom = 100; if (Info->OpenInfo != NULL) Modified: trunk/reactos/base/applications/imagesoft/lang/En.rc URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/imagesof…
============================================================================== --- trunk/reactos/base/applications/imagesoft/lang/En.rc (original) +++ trunk/reactos/base/applications/imagesoft/lang/En.rc Sun Nov 19 22:49:45 2006 @@ -50,6 +50,11 @@ MENUITEM "Brightness...", ID_BRIGHTNESS MENUITEM "Contrast...", -1, GRAYED MENUITEM "Hue/Saturation...", -1, GRAYED + POPUP "Colour" + BEGIN + MENUITEM "Black and White" ID_BLACKANDWHITE + MENUITEM "Invert Colours" ID_INVERTCOLORS + END MENUITEM SEPARATOR MENUITEM "Blur", -1, GRAYED MENUITEM "Sharpen", -1, GRAYED Modified: trunk/reactos/base/applications/imagesoft/mainwnd.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/imagesof…
============================================================================== --- trunk/reactos/base/applications/imagesoft/mainwnd.c (original) +++ trunk/reactos/base/applications/imagesoft/mainwnd.c Sun Nov 19 22:49:45 2006 @@ -906,6 +906,28 @@ (LPARAM)Info); break; + case ID_BLACKANDWHITE: + { + if (Info->ImageEditors) + { + DisplayBlackAndWhite(Info->ImageEditors->hSelf, + Info->ImageEditors->hDCMem, + Info->ImageEditors->hBitmap); + } + } + break; + + case ID_INVERTCOLORS: + { + if (Info->ImageEditors) + { + DisplayInvertedColors(Info->ImageEditors->hSelf, + Info->ImageEditors->hDCMem, + Info->ImageEditors->hBitmap); + } + } + break; + case ID_EXIT: SendMessage(Info->hSelf, WM_CLOSE, Modified: trunk/reactos/base/applications/imagesoft/resource.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/imagesof…
============================================================================== --- trunk/reactos/base/applications/imagesoft/resource.h (original) +++ trunk/reactos/base/applications/imagesoft/resource.h Sun Nov 19 22:49:45 2006 @@ -80,6 +80,8 @@ /* Adjust */ #define ID_BRIGHTNESS 2100 +#define ID_BLACKANDWHITE 2101 +#define ID_INVERTCOLORS 2102 #define ID_ABOUT 2400
18 years, 1 month
1
0
0
0
[janderwald] 24783: - fix prototype
by janderwald@svn.reactos.org
Author: janderwald Date: Sun Nov 19 22:43:54 2006 New Revision: 24783 URL:
http://svn.reactos.org/svn/reactos?rev=24783&view=rev
Log: - fix prototype Modified: trunk/reactos/lib/rtl/debug.c Modified: trunk/reactos/lib/rtl/debug.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/rtl/debug.c?rev=24783&…
============================================================================== --- trunk/reactos/lib/rtl/debug.c (original) +++ trunk/reactos/lib/rtl/debug.c Sun Nov 19 22:43:54 2006 @@ -270,7 +270,7 @@ */ ULONG NTAPI -DbgPrompt(PCH OutputString, +DbgPrompt(PCCH OutputString, PCH InputString, ULONG InputSize) {
18 years, 1 month
1
0
0
0
[greatlrd] 24782: the new desgin of ddraw are in place some files need be rename. 1. this version does not working and contain allot of bugs 2. HAL are not setup right yet 3. HEL are not setup right yet 4. crashing VS when u try debug it from vs if it compile with gcc. 5. implement HEL in user mode. 6. remove some code that was working for it is not longer compatible with new desgin
by greatlrd@svn.reactos.org
Author: greatlrd Date: Sun Nov 19 22:13:35 2006 New Revision: 24782 URL:
http://svn.reactos.org/svn/reactos?rev=24782&view=rev
Log: the new desgin of ddraw are in place some files need be rename. 1. this version does not working and contain allot of bugs 2. HAL are not setup right yet 3. HEL are not setup right yet 4. crashing VS when u try debug it from vs if it compile with gcc. 5. implement HEL in user mode. 6. remove some code that was working for it is not longer compatible with new desgin Added: trunk/reactos/dll/directx/ddraw/callbacks_hel.c - copied, changed from r24775, trunk/reactos/dll/directx/ddraw/soft/surface_callbacks_hel.c trunk/reactos/dll/directx/ddraw/iface_clipper.c trunk/reactos/dll/directx/ddraw/iface_color.c trunk/reactos/dll/directx/ddraw/iface_gamma.c trunk/reactos/dll/directx/ddraw/iface_kernel.c trunk/reactos/dll/directx/ddraw/iface_palette.c trunk/reactos/dll/directx/ddraw/iface_videoport.c Removed: trunk/reactos/dll/directx/ddraw/clipper.c trunk/reactos/dll/directx/ddraw/color.c trunk/reactos/dll/directx/ddraw/gamma.c trunk/reactos/dll/directx/ddraw/hal/ trunk/reactos/dll/directx/ddraw/kernel.c trunk/reactos/dll/directx/ddraw/palette.c trunk/reactos/dll/directx/ddraw/regsvr.c trunk/reactos/dll/directx/ddraw/soft/ trunk/reactos/dll/directx/ddraw/videoport.c trunk/reactos/dll/directx/ddraw/winedraw.h Modified: trunk/reactos/dll/directx/ddraw/cleanup.c trunk/reactos/dll/directx/ddraw/ddraw.rbuild trunk/reactos/dll/directx/ddraw/main.c trunk/reactos/dll/directx/ddraw/main/ddraw_main.c trunk/reactos/dll/directx/ddraw/main/surface_main.c trunk/reactos/dll/directx/ddraw/rosdraw.h trunk/reactos/dll/directx/ddraw/startup.c trunk/reactos/dll/directx/ddraw/thunks/ddraw_thunk.c trunk/reactos/dll/directx/ddraw/thunks/surface_thunk.c [This mail would be too long, it was shortened to contain the URLs only.] Copied: trunk/reactos/dll/directx/ddraw/callbacks_hel.c (from r24775, trunk/reactos/dll/directx/ddraw/soft/surface_callbacks_hel.c) URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/directx/ddraw/callback…
Modified: trunk/reactos/dll/directx/ddraw/cleanup.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/directx/ddraw/cleanup.…
Removed: trunk/reactos/dll/directx/ddraw/clipper.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/directx/ddraw/clipper.…
Removed: trunk/reactos/dll/directx/ddraw/color.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/directx/ddraw/color.c?…
Modified: trunk/reactos/dll/directx/ddraw/ddraw.rbuild URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/directx/ddraw/ddraw.rb…
Removed: trunk/reactos/dll/directx/ddraw/gamma.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/directx/ddraw/gamma.c?…
Added: trunk/reactos/dll/directx/ddraw/iface_clipper.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/directx/ddraw/iface_cl…
Added: trunk/reactos/dll/directx/ddraw/iface_color.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/directx/ddraw/iface_co…
Added: trunk/reactos/dll/directx/ddraw/iface_gamma.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/directx/ddraw/iface_ga…
Added: trunk/reactos/dll/directx/ddraw/iface_kernel.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/directx/ddraw/iface_ke…
Added: trunk/reactos/dll/directx/ddraw/iface_palette.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/directx/ddraw/iface_pa…
Added: trunk/reactos/dll/directx/ddraw/iface_videoport.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/directx/ddraw/iface_vi…
Removed: trunk/reactos/dll/directx/ddraw/kernel.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/directx/ddraw/kernel.c…
Modified: trunk/reactos/dll/directx/ddraw/main.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/directx/ddraw/main.c?r…
Modified: trunk/reactos/dll/directx/ddraw/main/ddraw_main.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/directx/ddraw/main/ddr…
Modified: trunk/reactos/dll/directx/ddraw/main/surface_main.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/directx/ddraw/main/sur…
Removed: trunk/reactos/dll/directx/ddraw/palette.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/directx/ddraw/palette.…
Removed: trunk/reactos/dll/directx/ddraw/regsvr.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/directx/ddraw/regsvr.c…
Modified: trunk/reactos/dll/directx/ddraw/rosdraw.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/directx/ddraw/rosdraw.…
Modified: trunk/reactos/dll/directx/ddraw/startup.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/directx/ddraw/startup.…
Modified: trunk/reactos/dll/directx/ddraw/thunks/ddraw_thunk.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/directx/ddraw/thunks/d…
Modified: trunk/reactos/dll/directx/ddraw/thunks/surface_thunk.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/directx/ddraw/thunks/s…
Removed: trunk/reactos/dll/directx/ddraw/videoport.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/directx/ddraw/videopor…
Removed: trunk/reactos/dll/directx/ddraw/winedraw.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/directx/ddraw/winedraw…
18 years, 1 month
1
0
0
0
[janderwald] 24781: fix typo
by janderwald@svn.reactos.org
Author: janderwald Date: Sun Nov 19 22:08:42 2006 New Revision: 24781 URL:
http://svn.reactos.org/svn/reactos?rev=24781&view=rev
Log: fix typo Modified: trunk/reactos/boot/bootdata/packages/reactos.dff Modified: trunk/reactos/boot/bootdata/packages/reactos.dff URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/bootdata/packages/rea…
============================================================================== --- trunk/reactos/boot/bootdata/packages/reactos.dff (original) +++ trunk/reactos/boot/bootdata/packages/reactos.dff Sun Nov 19 22:08:42 2006 @@ -235,7 +235,7 @@ ; Drivers -drivers\base\bootvid\kdcom.dll 2 +drivers\base\kdcom\kdcom.dll 2 drivers\base\beep\beep.sys 2 drivers\base\bootvid\bootvid.sys 2 drivers\base\null\null.sys 2
18 years, 1 month
1
0
0
0
[ion] 24780: - Change kdcom.sys to kdcom.dll. - Remove all kdcom exports and files from HAL and link with kdcom.dll instead. - Add support in freeldr for loading kdcom.dll (and theoretically any other import, such as the Code Integrity DLL for kernel-mode signing, but for now I've only tested this one). - Refactor some of the HAL loading code to make it generic for any image. - Load HAL manually when loading kernel, before processing imports, to make sure that HAL is index 1 in the loader module
by ion@svn.reactos.org
Author: ion Date: Sun Nov 19 22:00:03 2006 New Revision: 24780 URL:
http://svn.reactos.org/svn/reactos?rev=24780&view=rev
Log: - Change kdcom.sys to kdcom.dll. - Remove all kdcom exports and files from HAL and link with kdcom.dll instead. - Add support in freeldr for loading kdcom.dll (and theoretically any other import, such as the Code Integrity DLL for kernel-mode signing, but for now I've only tested this one). - Refactor some of the HAL loading code to make it generic for any image. - Load HAL manually when loading kernel, before processing imports, to make sure that HAL is index 1 in the loader modules and loads before KDCOM. - Fix some build problems. Removed: trunk/reactos/hal/halx86/generic/kdbg.c Modified: trunk/reactos/boot/bootdata/packages/reactos.dff trunk/reactos/boot/bootdata/txtsetup.sif trunk/reactos/boot/freeldr/freeldr/arch/i386/loader.c trunk/reactos/boot/freeldr/freeldr/reactos/reactos.c trunk/reactos/boot/freeldr/freeldr/reactos/setupldr.c trunk/reactos/drivers/base/kdcom/kdcom.def trunk/reactos/drivers/base/kdcom/kdcom.rbuild trunk/reactos/hal/hal/hal.def trunk/reactos/hal/halx86/generic/generic.rbuild trunk/reactos/ntoskrnl/ntoskrnl.rbuild Modified: trunk/reactos/boot/bootdata/packages/reactos.dff URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/bootdata/packages/rea…
============================================================================== --- trunk/reactos/boot/bootdata/packages/reactos.dff (original) +++ trunk/reactos/boot/bootdata/packages/reactos.dff Sun Nov 19 22:00:03 2006 @@ -235,7 +235,7 @@ ; Drivers -drivers\base\bootvid\kdcom.sys 2 +drivers\base\bootvid\kdcom.dll 2 drivers\base\beep\beep.sys 2 drivers\base\bootvid\bootvid.sys 2 drivers\base\null\null.sys 2 Modified: trunk/reactos/boot/bootdata/txtsetup.sif URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/bootdata/txtsetup.sif…
============================================================================== --- trunk/reactos/boot/bootdata/txtsetup.sif (original) +++ trunk/reactos/boot/bootdata/txtsetup.sif Sun Nov 19 22:00:03 2006 @@ -22,7 +22,7 @@ cdfs.sys = 3 cdrom.sys = 3 class2.sys = 3 -kdcom.sys = 3 +kdcom.dll = 3 disk.sys = 3 floppy.sys = 3 ;keyboard.sys = 3 Modified: trunk/reactos/boot/freeldr/freeldr/arch/i386/loader.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/arch/…
============================================================================== --- trunk/reactos/boot/freeldr/freeldr/arch/i386/loader.c (original) +++ trunk/reactos/boot/freeldr/freeldr/arch/i386/loader.c Sun Nov 19 22:00:03 2006 @@ -132,14 +132,10 @@ extern PAGE_DIRECTORY_X64 apic_pagetable_pae; extern PAGE_DIRECTORY_X64 kpcr_pagetable_pae; -extern CHAR szHalName[1024]; - -PIMAGE_BASE_RELOCATION -NTAPI -LdrProcessRelocationBlockLongLong(IN ULONG_PTR Address, - IN ULONG Count, - IN PUSHORT TypeOffset, - IN LONGLONG Delta); +BOOLEAN +NTAPI +FrLdrLoadImage(IN PCHAR szFileName, + IN INT nPos); /* FUNCTIONS *****************************************************************/ @@ -733,9 +729,9 @@ NTSTATUS NTAPI -LdrPEGetOrLoadModule(PCHAR ModuleName, - PCHAR ImportedName, - PLOADER_MODULE* ImportedModule) +LdrPEGetOrLoadModule(IN PCHAR ModuleName, + IN PCHAR ImportedName, + IN PLOADER_MODULE* ImportedModule) { NTSTATUS Status = STATUS_SUCCESS; @@ -747,10 +743,11 @@ * Later, FrLdrLoadDriver should be made to share the same * code, and we'll just call it instead. */ - if (!_stricmp(ImportedName, "hal.dll")) + if (!_stricmp(ImportedName, "hal.dll") || + !_stricmp(ImportedName, "kdcom.dll")) { /* Load the HAL */ - FrLdrLoadHal(szHalName, 10); + FrLdrLoadImage(ImportedName, 10); /* Return the new module */ *ImportedModule = LdrGetModuleObject(ImportedName); @@ -809,8 +806,8 @@ VOID NTAPI -FrLdrMapImage(IN PIMAGE_NT_HEADERS NtHeader, - IN PVOID Base) +FrLdrReMapImage(IN PIMAGE_NT_HEADERS NtHeader, + IN PVOID Base) { PIMAGE_SECTION_HEADER Section; ULONG SectionCount, SectionSize; @@ -900,7 +897,7 @@ FsReadFile(KernelImage, ImageSize, NULL, LoadBase); /* Map it */ - FrLdrMapImage(NtHeader, LoadBase); + FrLdrReMapImage(NtHeader, LoadBase); /* Calculate Difference between Real Base and Compiled Base*/ LdrRelocateImageWithBias(LoadBase, @@ -920,7 +917,10 @@ /* Increase the next Load Base */ NextModuleBase = ROUND_UP(LoadBase + ImageSize, PAGE_SIZE); - /* Perform import fixups */ + /* Load the HAL now (name will be changed internally if needed) */ + FrLdrLoadImage("hal.dll", 10); + + /* Perform import fixups */ LdrPEFixupImports(LoadBase, "ntoskrnl.exe"); /* Return Success */ @@ -929,11 +929,13 @@ BOOLEAN NTAPI -FrLdrMapHal(FILE *HalImage) +FrLdrMapImage(IN FILE *HalImage, + IN PCHAR Name) { PIMAGE_NT_HEADERS NtHeader; PVOID ImageBase, LoadBase; ULONG ImageSize; + ULONG ImageId = LoaderBlock.ModsCount; /* Set the virtual (image) and physical (load) addresses */ LoadBase = (PVOID)NextModuleBase; @@ -955,7 +957,7 @@ FsReadFile(HalImage, ImageSize, NULL, LoadBase); /* Map it into virtual memory */ - FrLdrMapImage(NtHeader, LoadBase); + FrLdrReMapImage(NtHeader, LoadBase); /* Calculate Difference between Real Base and Compiled Base*/ LdrRelocateImageWithBias(LoadBase, @@ -966,17 +968,18 @@ STATUS_UNSUCCESSFUL); /* Fill out Module Data Structure */ - reactos_modules[1].ModStart = (ULONG_PTR)ImageBase; - reactos_modules[1].ModEnd = (ULONG_PTR)ImageBase + ImageSize; - strcpy(reactos_module_strings[1], "hal.dll"); - reactos_modules[1].String = (ULONG_PTR)reactos_module_strings[1]; + reactos_modules[ImageId].ModStart = (ULONG_PTR)ImageBase; + reactos_modules[ImageId].ModEnd = (ULONG_PTR)ImageBase + ImageSize; + strcpy(reactos_module_strings[ImageId], Name); + reactos_modules[ImageId].String = (ULONG_PTR)reactos_module_strings[ImageId]; LoaderBlock.ModsCount++; - - /* Perform import fixups */ - LdrPEFixupImports(LoadBase, "hal.dll"); /* Increase the next Load Base */ NextModuleBase = ROUND_UP(NextModuleBase + ImageSize, PAGE_SIZE); + + /* Perform import fixups */ + //DbgPrint("Fixing up: %s loaded at: %p\n", Name, ImageBase); + LdrPEFixupImports(LoadBase, Name); /* Return Success */ return TRUE; Modified: trunk/reactos/boot/freeldr/freeldr/reactos/reactos.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/react…
============================================================================== --- trunk/reactos/boot/freeldr/freeldr/reactos/reactos.c (original) +++ trunk/reactos/boot/freeldr/freeldr/reactos/reactos.c Sun Nov 19 22:00:03 2006 @@ -33,7 +33,8 @@ ARC_DISK_SIGNATURE reactos_arc_disk_info[32]; // ARC Disk Information char reactos_arc_strings[32][256]; unsigned long reactos_disk_count = 0; - CHAR szHalName[1024]; +CHAR szHalName[255]; +CHAR szBootPath[255]; static CHAR szLoadingMsg[] = "Loading ReactOS..."; static BOOLEAN @@ -86,41 +87,56 @@ BOOLEAN NTAPI -FrLdrMapHal(FILE *KernelImage); +FrLdrMapImage( + IN FILE *Image, + IN PCHAR ShortName +); BOOLEAN NTAPI -FrLdrLoadHal(PCHAR szFileName, - INT nPos) +FrLdrLoadImage(IN PCHAR szFileName, + IN INT nPos) { PFILE FilePointer; PCHAR szShortName; - CHAR szBuffer[256]; - - /* Extract Kernel filename without path */ + CHAR szBuffer[256], szFullPath[256]; + + /* Check if this the HAL being loaded */ + if (!_stricmp(szFileName, "hal.dll")) + { + /* Use the boot.ini name instead */ + szFileName = szHalName; + } + + /* Extract filename without path */ szShortName = strrchr(szFileName, '\\'); - if (szShortName == NULL) { - + if (!szShortName) + { /* No path, leave it alone */ szShortName = szFileName; - } else { - + /* Which means we need to build a path now */ + strcpy(szBuffer, szFileName); + strcpy(szFullPath, szBootPath); + strcat(szFullPath, "SYSTEM32\\DRIVERS\\"); + strcat(szFullPath, szBuffer); + szFileName = szFullPath; + } + else + { /* Skip the path */ szShortName = szShortName + 1; } - /* Open the Kernel */ + /* Open the image */ FilePointer = FsOpenFile(szFileName); - - /* Make sure it worked */ - if (FilePointer == NULL) { - + if (!FilePointer) + { /* Return failure on the short name */ strcpy(szBuffer, szShortName); strcat(szBuffer, " not found."); UiMessageBox(szBuffer); - return(FALSE); + return FALSE; } /* Update the status bar with the current file */ @@ -129,11 +145,11 @@ UiDrawStatusText(szBuffer); /* Do the actual loading */ - FrLdrMapHal(FilePointer); + FrLdrMapImage(FilePointer, szShortName); /* Update Processbar and return success */ UiDrawProgressBarCenter(nPos, 100, szLoadingMsg); - return(TRUE); + return TRUE; } static VOID @@ -618,13 +634,12 @@ LoadAndBootReactOS(PCSTR OperatingSystemName) { PFILE FilePointer; - CHAR name[1024]; - CHAR value[1024]; - CHAR SystemPath[1024]; - CHAR szKernelName[1024]; - CHAR szFileName[1024]; - CHAR szBootPath[256]; - UINT i; + CHAR name[255]; + CHAR value[255]; + CHAR SystemPath[255]; + CHAR szKernelName[255]; + CHAR szFileName[255]; + UINT i; CHAR MsgBuffer[256]; ULONG SectionId; @@ -657,10 +672,10 @@ LoaderBlock.PageDirectoryStart = (ULONG)&PageDirectoryStart; LoaderBlock.PageDirectoryEnd = (ULONG)&PageDirectoryEnd; LoaderBlock.BootDevice = 0xffffffff; - LoaderBlock.CommandLine = (unsigned long)reactos_kernel_cmdline; + LoaderBlock.CommandLine = reactos_kernel_cmdline; LoaderBlock.ModsCount = 0; - LoaderBlock.ModsAddr = (unsigned long)reactos_modules; - LoaderBlock.DrivesAddr = (unsigned long)reactos_arc_disk_info; + LoaderBlock.ModsAddr = reactos_modules; + LoaderBlock.DrivesAddr = reactos_arc_disk_info; LoaderBlock.MmapLength = (unsigned long)MachGetMemoryMap((PBIOS_MEMORY_MAP)(PVOID)&reactos_memory_map, 32) * sizeof(memory_map_t); if (LoaderBlock.MmapLength) { Modified: trunk/reactos/boot/freeldr/freeldr/reactos/setupldr.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/react…
============================================================================== --- trunk/reactos/boot/freeldr/freeldr/reactos/setupldr.c (original) +++ trunk/reactos/boot/freeldr/freeldr/reactos/setupldr.c Sun Nov 19 22:00:03 2006 @@ -314,9 +314,9 @@ LoaderBlock.PageDirectoryStart = (ULONG)&PageDirectoryStart; LoaderBlock.PageDirectoryEnd = (ULONG)&PageDirectoryEnd; LoaderBlock.BootDevice = 0xffffffff; - LoaderBlock.CommandLine = (unsigned long)reactos_kernel_cmdline; + LoaderBlock.CommandLine = reactos_kernel_cmdline; LoaderBlock.ModsCount = 0; - LoaderBlock.ModsAddr = (unsigned long)reactos_modules; + LoaderBlock.ModsAddr = reactos_modules; LoaderBlock.MmapLength = (unsigned long)MachGetMemoryMap((PBIOS_MEMORY_MAP)(PVOID)&reactos_memory_map, 32) * sizeof(memory_map_t); if (LoaderBlock.MmapLength) { Modified: trunk/reactos/drivers/base/kdcom/kdcom.def URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/base/kdcom/kdcom.d…
============================================================================== --- trunk/reactos/drivers/base/kdcom/kdcom.def (original) +++ trunk/reactos/drivers/base/kdcom/kdcom.def Sun Nov 19 22:00:03 2006 @@ -1,4 +1,4 @@ -LIBRARY kdcom.sys +LIBRARY kdcom.dll EXPORTS KdComPortInUse=_KdComPortInUse Modified: trunk/reactos/drivers/base/kdcom/kdcom.rbuild URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/base/kdcom/kdcom.r…
============================================================================== --- trunk/reactos/drivers/base/kdcom/kdcom.rbuild (original) +++ trunk/reactos/drivers/base/kdcom/kdcom.rbuild Sun Nov 19 22:00:03 2006 @@ -1,6 +1,6 @@ -<module name="kdcom" type="kernelmodedll" entrypoint="DriverEntry@8" installbase="system32/drivers" installname="kdcom.sys"> +<module name="kdcom" type="kernelmodedll" entrypoint="DriverEntry@8" installbase="system32/drivers" installname="kdcom.dll"> <importlibrary definition="kdcom.def"></importlibrary> - <bootstrap base="reactos" nameoncd="kdcom.sys" /> + <bootstrap base="reactos" nameoncd="kdcom.dll" /> <include base="kdcom">.</include> <define name="__USE_W32API" /> <library>ntoskrnl</library> Modified: trunk/reactos/hal/hal/hal.def URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/hal/hal/hal.def?rev=24780&…
============================================================================== --- trunk/reactos/hal/hal/hal.def (original) +++ trunk/reactos/hal/hal/hal.def Sun Nov 19 22:00:03 2006 @@ -72,21 +72,6 @@ IoReadPartitionTable@16=HalpReadPartitionTable@16 IoSetPartitionInformation@16=HalpSetPartitionInformation@16 IoWritePartitionTable@20=HalpWritePartitionTable@20 -KdComPortInUse=_KdComPortInUse -; FIXME: DEPRECATED -KdPortGetByte@4 -KdPortGetByteEx@8 -KdPortInitialize@12 -KdPortInitializeEx@12 -KdPortPollByte@4 -KdPortPollByteEx@8 -KdPortPutByte@4 -KdPortPutByteEx@8 -KdPortRestore@0 -KdPortSave@0 -KdPortDisableInterrupts@0 -KdPortEnableInterrupts@0 -; FIXME: END DEPRECATED BLOCK KeAcquireSpinLock@8 KeFlushWriteBuffer@0 KeGetCurrentIrql@0 Modified: trunk/reactos/hal/halx86/generic/generic.rbuild URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/hal/halx86/generic/generic…
============================================================================== --- trunk/reactos/hal/halx86/generic/generic.rbuild (original) +++ trunk/reactos/hal/halx86/generic/generic.rbuild Sun Nov 19 22:00:03 2006 @@ -11,7 +11,6 @@ <file>drive.c</file> <file>halinit.c</file> <file>isa.c</file> - <file>kdbg.c</file> <file>mca.c</file> <file>misc.c</file> <file>pci.c</file> Removed: trunk/reactos/hal/halx86/generic/kdbg.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/hal/halx86/generic/kdbg.c?…
============================================================================== --- trunk/reactos/hal/halx86/generic/kdbg.c (original) +++ trunk/reactos/hal/halx86/generic/kdbg.c (removed) @@ -1,547 +1,0 @@ -/* $Id$ - * - * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS kernel - * FILE: ntoskrnl/hal/x86/kdbg.c - * PURPOSE: Serial i/o functions for the kernel debugger. - * PROGRAMMER: Emanuele Aliberti - * Eric Kohl - * UPDATE HISTORY: - * Created 05/09/99 - */ - -/* INCLUDES *****************************************************************/ - -#include <hal.h> -#define NDEBUG -#include <debug.h> - - -#define DEFAULT_BAUD_RATE 19200 - - -/* MACROS *******************************************************************/ - -#define SER_RBR(x) ((x)+0) -#define SER_THR(x) ((x)+0) -#define SER_DLL(x) ((x)+0) -#define SER_IER(x) ((x)+1) -#define SR_IER_ERDA 0x01 -#define SR_IER_ETHRE 0x02 -#define SR_IER_ERLSI 0x04 -#define SR_IER_EMS 0x08 -#define SR_IER_ALL 0x0F -#define SER_DLM(x) ((x)+1) -#define SER_IIR(x) ((x)+2) -#define SER_FCR(x) ((x)+2) -#define SR_FCR_ENABLE_FIFO 0x01 -#define SR_FCR_CLEAR_RCVR 0x02 -#define SR_FCR_CLEAR_XMIT 0x04 -#define SER_LCR(x) ((x)+3) -#define SR_LCR_CS5 0x00 -#define SR_LCR_CS6 0x01 -#define SR_LCR_CS7 0x02 -#define SR_LCR_CS8 0x03 -#define SR_LCR_ST1 0x00 -#define SR_LCR_ST2 0x04 -#define SR_LCR_PNO 0x00 -#define SR_LCR_POD 0x08 -#define SR_LCR_PEV 0x18 -#define SR_LCR_PMK 0x28 -#define SR_LCR_PSP 0x38 -#define SR_LCR_BRK 0x40 -#define SR_LCR_DLAB 0x80 -#define SER_MCR(x) ((x)+4) -#define SR_MCR_DTR 0x01 -#define SR_MCR_RTS 0x02 -#define SR_MCR_OUT1 0x04 -#define SR_MCR_OUT2 0x08 -#define SR_MCR_LOOP 0x10 -#define SER_LSR(x) ((x)+5) -#define SR_LSR_DR 0x01 -#define SR_LSR_TBE 0x20 -#define SER_MSR(x) ((x)+6) -#define SR_MSR_CTS 0x10 -#define SR_MSR_DSR 0x20 -#define SER_SCR(x) ((x)+7) - - -/* GLOBAL VARIABLES *********************************************************/ - -ULONG KdComPortInUse = 0; - - -/* STATIC VARIABLES *********************************************************/ - -static ULONG ComPort = 0; -static ULONG BaudRate = 0; -static PUCHAR PortBase = (PUCHAR)0; - -/* The com port must only be initialized once! */ -static BOOLEAN PortInitialized = FALSE; - - -/* STATIC FUNCTIONS *********************************************************/ - -static BOOLEAN -KdpDoesComPortExist (PUCHAR BaseAddress) -{ - BOOLEAN found; - UCHAR mcr; - UCHAR msr; - - found = FALSE; - - /* save Modem Control Register (MCR) */ - mcr = READ_PORT_UCHAR (SER_MCR(BaseAddress)); - - /* enable loop mode (set Bit 4 of the MCR) */ - WRITE_PORT_UCHAR (SER_MCR(BaseAddress), 0x10); - - /* clear all modem output bits */ - WRITE_PORT_UCHAR (SER_MCR(BaseAddress), 0x10); - - /* read the Modem Status Register */ - msr = READ_PORT_UCHAR (SER_MSR(BaseAddress)); - - /* - * the upper nibble of the MSR (modem output bits) must be - * equal to the lower nibble of the MCR (modem input bits) - */ - if ((msr & 0xF0) == 0x00) - { - /* set all modem output bits */ - WRITE_PORT_UCHAR (SER_MCR(BaseAddress), 0x1F); - - /* read the Modem Status Register */ - msr = READ_PORT_UCHAR (SER_MSR(BaseAddress)); - - /* - * the upper nibble of the MSR (modem output bits) must be - * equal to the lower nibble of the MCR (modem input bits) - */ - if ((msr & 0xF0) == 0xF0) - { - /* - * setup a resonable state for the port: - * enable fifo and clear recieve/transmit buffers - */ - WRITE_PORT_UCHAR (SER_FCR(BaseAddress), - (SR_FCR_ENABLE_FIFO | SR_FCR_CLEAR_RCVR | SR_FCR_CLEAR_XMIT)); - WRITE_PORT_UCHAR (SER_FCR(BaseAddress), 0); - READ_PORT_UCHAR (SER_RBR(BaseAddress)); - WRITE_PORT_UCHAR (SER_IER(BaseAddress), 0); - found = TRUE; - } - } - - /* restore MCR */ - WRITE_PORT_UCHAR (SER_MCR(BaseAddress), mcr); - - return (found); -} - - -/* FUNCTIONS ****************************************************************/ - -/* HAL.KdPortInitialize */ -BOOLEAN -STDCALL -KdPortInitialize ( - PKD_PORT_INFORMATION PortInformation, - ULONG Unknown1, - ULONG Unknown2 - ) -{ - ULONG BaseArray[5] = {0, 0x3F8, 0x2F8, 0x3E8, 0x2E8}; - char buffer[80]; - ULONG divisor; - UCHAR lcr; - - if (PortInitialized == FALSE) - { - if (PortInformation->BaudRate != 0) - { - BaudRate = PortInformation->BaudRate; - } - else - { - BaudRate = DEFAULT_BAUD_RATE; - } - - if (PortInformation->ComPort == 0) - { - if (KdpDoesComPortExist ((PUCHAR)BaseArray[2])) - { - PortBase = (PUCHAR)BaseArray[2]; - ComPort = 2; - PortInformation->BaseAddress = (ULONG)PortBase; - PortInformation->ComPort = ComPort; -#ifndef NDEBUG - sprintf (buffer, - "\nSerial port COM%ld found at 0x%lx\n", - ComPort, - (ULONG)PortBase); - HalDisplayString (buffer); -#endif /* NDEBUG */ - } - else if (KdpDoesComPortExist ((PUCHAR)BaseArray[1])) - { - PortBase = (PUCHAR)BaseArray[1]; - ComPort = 1; - PortInformation->BaseAddress = (ULONG)PortBase; - PortInformation->ComPort = ComPort; -#ifndef NDEBUG - sprintf (buffer, - "\nSerial port COM%ld found at 0x%lx\n", - ComPort, - (ULONG)PortBase); - HalDisplayString (buffer); -#endif /* NDEBUG */ - } - else - { - sprintf (buffer, - "\nKernel Debugger: No COM port found!!!\n\n"); - HalDisplayString (buffer); - return FALSE; - } - } - else - { - if (KdpDoesComPortExist ((PUCHAR)BaseArray[PortInformation->ComPort])) - { - PortBase = (PUCHAR)BaseArray[PortInformation->ComPort]; - ComPort = PortInformation->ComPort; - PortInformation->BaseAddress = (ULONG)PortBase; -#ifndef NDEBUG - sprintf (buffer, - "\nSerial port COM%ld found at 0x%lx\n", - ComPort, - (ULONG)PortBase); - HalDisplayString (buffer); -#endif /* NDEBUG */ - } - else - { - sprintf (buffer, - "\nKernel Debugger: No serial port found!!!\n\n"); - HalDisplayString (buffer); - return FALSE; - } - } - - PortInitialized = TRUE; - } - - /* - * set baud rate and data format (8N1) - */ - - /* turn on DTR and RTS */ - WRITE_PORT_UCHAR (SER_MCR(PortBase), SR_MCR_DTR | SR_MCR_RTS); - - /* set DLAB */ - lcr = READ_PORT_UCHAR (SER_LCR(PortBase)) | SR_LCR_DLAB; - WRITE_PORT_UCHAR (SER_LCR(PortBase), lcr); - - /* set baud rate */ - divisor = 115200 / BaudRate; - WRITE_PORT_UCHAR (SER_DLL(PortBase), (UCHAR)(divisor & 0xff)); - WRITE_PORT_UCHAR (SER_DLM(PortBase), (UCHAR)((divisor >> 8) & 0xff)); - - /* reset DLAB and set 8N1 format */ - WRITE_PORT_UCHAR (SER_LCR(PortBase), - SR_LCR_CS8 | SR_LCR_ST1 | SR_LCR_PNO); - - /* read junk out of the RBR */ - lcr = READ_PORT_UCHAR (SER_RBR(PortBase)); - - /* - * set global info - */ - KdComPortInUse = (ULONG)PortBase; - - /* - * print message to blue screen - */ - sprintf (buffer, - "\nKernel Debugger: COM%ld (Port 0x%lx) BaudRate %ld\n\n", - ComPort, - (ULONG)PortBase, - BaudRate); - - HalDisplayString (buffer); - - return TRUE; -} - - -/* HAL.KdPortInitializeEx */ -BOOLEAN -STDCALL -KdPortInitializeEx ( - PKD_PORT_INFORMATION PortInformation, - ULONG Unknown1, - ULONG Unknown2 - ) -{ - ULONG BaseArray[5] = {0, 0x3F8, 0x2F8, 0x3E8, 0x2E8}; - PUCHAR ComPortBase; - char buffer[80]; - ULONG divisor; - UCHAR lcr; - - if (PortInformation->BaudRate == 0) - { - PortInformation->BaudRate = DEFAULT_BAUD_RATE; - } - - if (PortInformation->ComPort == 0) - { - return FALSE; - } - else - { - if (KdpDoesComPortExist ((PUCHAR)BaseArray[PortInformation->ComPort])) - { - ComPortBase = (PUCHAR)BaseArray[PortInformation->ComPort]; - PortInformation->BaseAddress = (ULONG)ComPortBase; -#ifndef NDEBUG - sprintf (buffer, - "\nSerial port COM%ld found at 0x%lx\n", - PortInformation->ComPort, - (ULONG)ComPortBase]; - HalDisplayString (buffer); -#endif /* NDEBUG */ - } - else - { - sprintf (buffer, - "\nKernel Debugger: Serial port not found!!!\n\n"); - HalDisplayString (buffer); - return FALSE; - } - } - - /* - * set baud rate and data format (8N1) - */ - - /* turn on DTR and RTS */ - WRITE_PORT_UCHAR (SER_MCR(ComPortBase), SR_MCR_DTR | SR_MCR_RTS); - - /* set DLAB */ - lcr = READ_PORT_UCHAR (SER_LCR(ComPortBase)) | SR_LCR_DLAB; - WRITE_PORT_UCHAR (SER_LCR(ComPortBase), lcr); - - /* set baud rate */ - divisor = 115200 / PortInformation->BaudRate; - WRITE_PORT_UCHAR (SER_DLL(ComPortBase), (UCHAR)(divisor & 0xff)); - WRITE_PORT_UCHAR (SER_DLM(ComPortBase), (UCHAR)((divisor >> 8) & 0xff)); - - /* reset DLAB and set 8N1 format */ - WRITE_PORT_UCHAR (SER_LCR(ComPortBase), - SR_LCR_CS8 | SR_LCR_ST1 | SR_LCR_PNO); - - /* read junk out of the RBR */ - lcr = READ_PORT_UCHAR (SER_RBR(ComPortBase)); - -#ifndef NDEBUG - - /* - * print message to blue screen - */ - sprintf (buffer, - "\nKernel Debugger: COM%ld (Port 0x%lx) BaudRate %ld\n\n", - PortInformation->ComPort, - (ULONG)ComPortBase, - PortInformation->BaudRate); - - HalDisplayString (buffer); - -#endif /* NDEBUG */ - - return TRUE; -} - - -/* HAL.KdPortGetByte */ -BOOLEAN -STDCALL -KdPortGetByte ( - PUCHAR ByteRecieved - ) -{ - if (PortInitialized == FALSE) - return FALSE; - - if ((READ_PORT_UCHAR (SER_LSR(PortBase)) & SR_LSR_DR)) - { - *ByteRecieved = READ_PORT_UCHAR (SER_RBR(PortBase)); - return TRUE; - } - - return FALSE; -} - - -/* HAL.KdPortGetByteEx */ -BOOLEAN -STDCALL -KdPortGetByteEx ( - PKD_PORT_INFORMATION PortInformation, - PUCHAR ByteRecieved - ) -{ - PUCHAR ComPortBase = (PUCHAR)PortInformation->BaseAddress; - - if ((READ_PORT_UCHAR (SER_LSR(ComPortBase)) & SR_LSR_DR)) - { - *ByteRecieved = READ_PORT_UCHAR (SER_RBR(ComPortBase)); - return TRUE; - } - - return FALSE; -} - - -/* HAL.KdPortPollByte */ -BOOLEAN -STDCALL -KdPortPollByte ( - PUCHAR ByteRecieved - ) -{ - if (PortInitialized == FALSE) - return FALSE; - - while ((READ_PORT_UCHAR (SER_LSR(PortBase)) & SR_LSR_DR) == 0) - ; - - *ByteRecieved = READ_PORT_UCHAR (SER_RBR(PortBase)); - - return TRUE; -} - - -/* HAL.KdPortPollByteEx */ -BOOLEAN -STDCALL -KdPortPollByteEx ( - PKD_PORT_INFORMATION PortInformation, - PUCHAR ByteRecieved - ) -{ - PUCHAR ComPortBase = (PUCHAR)PortInformation->BaseAddress; - - while ((READ_PORT_UCHAR (SER_LSR(ComPortBase)) & SR_LSR_DR) == 0) - ; - - *ByteRecieved = READ_PORT_UCHAR (SER_RBR(ComPortBase)); - - return TRUE; -} - - - - -/* HAL.KdPortPutByte */ -VOID -STDCALL -KdPortPutByte ( - UCHAR ByteToSend - ) -{ - if (PortInitialized == FALSE) - return; - - while ((READ_PORT_UCHAR (SER_LSR(PortBase)) & SR_LSR_TBE) == 0) - ; - - WRITE_PORT_UCHAR (SER_THR(PortBase), ByteToSend); -} - -/* HAL.KdPortPutByteEx */ -VOID -STDCALL -KdPortPutByteEx ( - PKD_PORT_INFORMATION PortInformation, - UCHAR ByteToSend - ) -{ - PUCHAR ComPortBase = (PUCHAR)PortInformation->BaseAddress; - - while ((READ_PORT_UCHAR (SER_LSR(ComPortBase)) & SR_LSR_TBE) == 0) - ; - - WRITE_PORT_UCHAR (SER_THR(ComPortBase), ByteToSend); -} - - -/* HAL.KdPortRestore */ -VOID -STDCALL -KdPortRestore ( - VOID - ) -{ -} - - -/* HAL.KdPortSave */ -VOID -STDCALL -KdPortSave ( - VOID - ) -{ -} - - -/* HAL.KdPortDisableInterrupts */ -BOOLEAN -STDCALL -KdPortDisableInterrupts() -{ - UCHAR ch; - - if (PortInitialized == FALSE) - return FALSE; - - ch = READ_PORT_UCHAR (SER_MCR (PortBase)); - ch &= (~(SR_MCR_OUT1 | SR_MCR_OUT2)); - WRITE_PORT_UCHAR (SER_MCR (PortBase), ch); - - ch = READ_PORT_UCHAR (SER_IER (PortBase)); - ch &= (~SR_IER_ALL); - WRITE_PORT_UCHAR (SER_IER (PortBase), ch); - - return TRUE; -} - - -/* HAL.KdPortEnableInterrupts */ -BOOLEAN -STDCALL -KdPortEnableInterrupts() -{ - UCHAR ch; - - if (PortInitialized == FALSE) - return FALSE; - - ch = READ_PORT_UCHAR (SER_IER (PortBase)); - ch &= (~SR_IER_ALL); - ch |= SR_IER_ERDA; - WRITE_PORT_UCHAR (SER_IER (PortBase), ch); - - ch = READ_PORT_UCHAR (SER_MCR (PortBase)); - ch &= (~SR_MCR_LOOP); - ch |= (SR_MCR_OUT1 | SR_MCR_OUT2); - WRITE_PORT_UCHAR (SER_MCR (PortBase), ch); - - return TRUE; -} - -/* EOF */ Modified: trunk/reactos/ntoskrnl/ntoskrnl.rbuild URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ntoskrnl.rbuild?r…
============================================================================== --- trunk/reactos/ntoskrnl/ntoskrnl.rbuild (original) +++ trunk/reactos/ntoskrnl/ntoskrnl.rbuild Sun Nov 19 22:00:03 2006 @@ -22,7 +22,7 @@ <library>rtl</library> <library>rossym</library> <library>string</library> - <!-- <library>kdcom</library> --> + <library>kdcom</library> <library>wdmguid</library> <directory name="include"> <pch>ntoskrnl.h</pch>
18 years, 1 month
1
0
0
0
[ion] 24779: - Fix last-minute compiler bug.
by ion@svn.reactos.org
Author: ion Date: Sun Nov 19 21:12:27 2006 New Revision: 24779 URL:
http://svn.reactos.org/svn/reactos?rev=24779&view=rev
Log: - Fix last-minute compiler bug. Modified: trunk/reactos/boot/freeldr/freeldr/arch/i386/loader.c Modified: trunk/reactos/boot/freeldr/freeldr/arch/i386/loader.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/arch/…
============================================================================== --- trunk/reactos/boot/freeldr/freeldr/arch/i386/loader.c (original) +++ trunk/reactos/boot/freeldr/freeldr/arch/i386/loader.c Sun Nov 19 21:12:27 2006 @@ -813,7 +813,7 @@ IN PVOID Base) { PIMAGE_SECTION_HEADER Section; - ULONG SectionCount, SectionSize, i; + ULONG SectionCount, SectionSize; PVOID SourceSection, TargetSection; INT i;
18 years, 1 month
1
0
0
0
[ion] 24778: - Major changes to HAL/kernel loading and freeldr hacks: - Add PE routines for traversing the import table and fixing up the imports. - Add routine for getting the LOADER_MODULE for a freeldr module by name. - Add the ability to load a not-yet-loaded-driver that's in an import entry (ie: dependencies). Only used for HAL now. - Map HAL in the same was as the kernel, instead of relocating it as a hack from within the kernel. - Refactor some routines to better share code. Don't read fr
by ion@svn.reactos.org
Author: ion Date: Sun Nov 19 20:53:31 2006 New Revision: 24778 URL:
http://svn.reactos.org/svn/reactos?rev=24778&view=rev
Log: - Major changes to HAL/kernel loading and freeldr hacks: - Add PE routines for traversing the import table and fixing up the imports. - Add routine for getting the LOADER_MODULE for a freeldr module by name. - Add the ability to load a not-yet-loaded-driver that's in an import entry (ie: dependencies). Only used for HAL now. - Map HAL in the same was as the kernel, instead of relocating it as a hack from within the kernel. - Refactor some routines to better share code. Don't read freed memory anymore. - Use LdrRelocateImageWithBias instead of quintuplicating relocation code. - Parse kernel and HAL imports while PE-loading from within freeldr. - Remove dozens of freeldr.c hacks from the kernel. Remove slow code which was making two copies of the parameter block and wasting over 30KB in static strings that were immediately copied to other strings... - Don't use HalModuleObject and NtoskrnlModuleObject anymore. Remove LdrSafePEProcessModule and other similar boot-time hacks. Reimplement MmGetSystemRoutineAddress. - NDK/DDK fixes. - Add KDCOM to bootcd/installation. Modified: trunk/reactos/boot/bootdata/packages/reactos.dff trunk/reactos/boot/bootdata/txtsetup.sif trunk/reactos/boot/freeldr/freeldr/arch/i386/loader.c trunk/reactos/boot/freeldr/freeldr/reactos/reactos.c trunk/reactos/include/ddk/winddk.h trunk/reactos/include/ndk/pstypes.h trunk/reactos/include/ndk/rtlfuncs.h trunk/reactos/include/reactos/rosldr.h trunk/reactos/ntoskrnl/ex/init.c trunk/reactos/ntoskrnl/include/internal/ke.h trunk/reactos/ntoskrnl/include/internal/ldr.h trunk/reactos/ntoskrnl/include/ntoskrnl.h trunk/reactos/ntoskrnl/io/iomgr/driver.c trunk/reactos/ntoskrnl/kd/wrappers/gdbstub.c trunk/reactos/ntoskrnl/ke/freeldr.c trunk/reactos/ntoskrnl/ke/i386/kiinit.c trunk/reactos/ntoskrnl/ldr/loader.c trunk/reactos/ntoskrnl/mm/mm.c trunk/reactos/ntoskrnl/ntoskrnl.rbuild Modified: trunk/reactos/boot/bootdata/packages/reactos.dff URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/bootdata/packages/rea…
============================================================================== --- trunk/reactos/boot/bootdata/packages/reactos.dff (original) +++ trunk/reactos/boot/bootdata/packages/reactos.dff Sun Nov 19 20:53:31 2006 @@ -235,6 +235,7 @@ ; Drivers +drivers\base\bootvid\kdcom.sys 2 drivers\base\beep\beep.sys 2 drivers\base\bootvid\bootvid.sys 2 drivers\base\null\null.sys 2 Modified: trunk/reactos/boot/bootdata/txtsetup.sif URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/bootdata/txtsetup.sif…
============================================================================== --- trunk/reactos/boot/bootdata/txtsetup.sif (original) +++ trunk/reactos/boot/bootdata/txtsetup.sif Sun Nov 19 20:53:31 2006 @@ -22,6 +22,7 @@ cdfs.sys = 3 cdrom.sys = 3 class2.sys = 3 +kdcom.sys = 3 disk.sys = 3 floppy.sys = 3 ;keyboard.sys = 3 Modified: trunk/reactos/boot/freeldr/freeldr/arch/i386/loader.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/arch/…
============================================================================== --- trunk/reactos/boot/freeldr/freeldr/arch/i386/loader.c (original) +++ trunk/reactos/boot/freeldr/freeldr/arch/i386/loader.c Sun Nov 19 20:53:31 2006 @@ -17,11 +17,12 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ - +#define _NTSYSTEM_ #include <freeldr.h> #define NDEBUG #include <debug.h> +#undef DbgPrint /* Base Addres of Kernel in Physical Memory */ #define KERNEL_BASE_PHYS 0x200000 @@ -131,6 +132,15 @@ extern PAGE_DIRECTORY_X64 apic_pagetable_pae; extern PAGE_DIRECTORY_X64 kpcr_pagetable_pae; +extern CHAR szHalName[1024]; + +PIMAGE_BASE_RELOCATION +NTAPI +LdrProcessRelocationBlockLongLong(IN ULONG_PTR Address, + IN ULONG Count, + IN PUSHORT TypeOffset, + IN LONGLONG Delta); + /* FUNCTIONS *****************************************************************/ /*++ @@ -526,6 +536,319 @@ return; } +PVOID +NTAPI +LdrPEGetExportByName(PVOID BaseAddress, + PUCHAR SymbolName, + USHORT Hint) +{ + PIMAGE_EXPORT_DIRECTORY ExportDir; + PULONG * ExFunctions; + PULONG * ExNames; + USHORT * ExOrdinals; + PVOID ExName; + ULONG Ordinal; + PVOID Function; + LONG minn, maxn, mid, res; + ULONG ExportDirSize; + + /* HAL and NTOS use a virtual address, switch it to physical mode */ + if ((ULONG_PTR)BaseAddress & 0x80000000) + { + BaseAddress = (PVOID)((ULONG_PTR)BaseAddress - KSEG0_BASE + 0x200000); + } + + ExportDir = (PIMAGE_EXPORT_DIRECTORY) + RtlImageDirectoryEntryToData(BaseAddress, + TRUE, + IMAGE_DIRECTORY_ENTRY_EXPORT, + &ExportDirSize); + if (!ExportDir) + { + DbgPrint("LdrPEGetExportByName(): no export directory!\n"); + return NULL; + } + + /* The symbol names may be missing entirely */ + if (!ExportDir->AddressOfNames) + { + DbgPrint("LdrPEGetExportByName(): symbol names missing entirely\n"); + return NULL; + } + + /* + * Get header pointers + */ + ExNames = (PULONG *)RVA(BaseAddress, ExportDir->AddressOfNames); + ExOrdinals = (USHORT *)RVA(BaseAddress, ExportDir->AddressOfNameOrdinals); + ExFunctions = (PULONG *)RVA(BaseAddress, ExportDir->AddressOfFunctions); + + /* + * Check the hint first + */ + if (Hint < ExportDir->NumberOfNames) + { + ExName = RVA(BaseAddress, ExNames[Hint]); + if (strcmp(ExName, (PCHAR)SymbolName) == 0) + { + Ordinal = ExOrdinals[Hint]; + Function = RVA(BaseAddress, ExFunctions[Ordinal]); + if ((ULONG_PTR)Function >= (ULONG_PTR)ExportDir && + (ULONG_PTR)Function < (ULONG_PTR)ExportDir + ExportDirSize) + { + Function = NULL; + if (Function == NULL) + { + DbgPrint("LdrPEGetExportByName(): failed to find %s\n",SymbolName); + } + return Function; + } + + if (Function != NULL) return Function; + } + } + + /* + * Binary search + */ + minn = 0; + maxn = ExportDir->NumberOfNames - 1; + while (minn <= maxn) + { + mid = (minn + maxn) / 2; + + ExName = RVA(BaseAddress, ExNames[mid]); + res = strcmp(ExName, (PCHAR)SymbolName); + if (res == 0) + { + Ordinal = ExOrdinals[mid]; + Function = RVA(BaseAddress, ExFunctions[Ordinal]); + if ((ULONG_PTR)Function >= (ULONG_PTR)ExportDir && + (ULONG_PTR)Function < (ULONG_PTR)ExportDir + ExportDirSize) + { + Function = NULL; + if (Function == NULL) + { + DbgPrint("LdrPEGetExportByName(): failed to find %s\n",SymbolName); + } + return Function; + } + if (Function != NULL) + { + return Function; + } + } + else if (res > 0) + { + maxn = mid - 1; + } + else + { + minn = mid + 1; + } + } + + ExName = RVA(BaseAddress, ExNames[mid]); + DbgPrint("LdrPEGetExportByName(): failed to find %s\n",SymbolName); + return (PVOID)NULL; +} + +NTSTATUS +NTAPI +LdrPEProcessImportDirectoryEntry(PVOID DriverBase, + PLOADER_MODULE LoaderModule, + PIMAGE_IMPORT_DESCRIPTOR ImportModuleDirectory) +{ + PVOID* ImportAddressList; + PULONG FunctionNameList; + + if (ImportModuleDirectory == NULL || ImportModuleDirectory->Name == 0) + { + return STATUS_UNSUCCESSFUL; + } + + /* Get the import address list. */ + ImportAddressList = (PVOID*)RVA(DriverBase, ImportModuleDirectory->FirstThunk); + + /* Get the list of functions to import. */ + if (ImportModuleDirectory->OriginalFirstThunk != 0) + { + FunctionNameList = (PULONG)RVA(DriverBase, ImportModuleDirectory->OriginalFirstThunk); + } + else + { + FunctionNameList = (PULONG)RVA(DriverBase, ImportModuleDirectory->FirstThunk); + } + + /* Walk through function list and fixup addresses. */ + while (*FunctionNameList != 0L) + { + if ((*FunctionNameList) & 0x80000000) + { + DbgPrint("Failed to import ordinal from %s\n", LoaderModule->String); + return STATUS_UNSUCCESSFUL; + } + else + { + IMAGE_IMPORT_BY_NAME *pe_name; + pe_name = RVA(DriverBase, *FunctionNameList); + *ImportAddressList = LdrPEGetExportByName((PVOID)LoaderModule->ModStart, pe_name->Name, pe_name->Hint); + + /* Fixup the address to be virtual */ + *ImportAddressList = (PVOID)((ULONG_PTR)*ImportAddressList + (KSEG0_BASE - 0x200000)); + + //DbgPrint("Looked for: %s and found: %p\n", pe_name->Name, *ImportAddressList); + if ((*ImportAddressList) == NULL) + { + DbgPrint("Failed to import %s from %s\n", pe_name->Name, LoaderModule->String); + return STATUS_UNSUCCESSFUL; + } + } + ImportAddressList++; + FunctionNameList++; + } + return STATUS_SUCCESS; +} + +PLOADER_MODULE +NTAPI +LdrGetModuleObject(PCHAR ModuleName) +{ + ULONG i; + + for (i = 0; i < LoaderBlock.ModsCount; i++) + { + if (!_stricmp((PCHAR)reactos_modules[i].String, ModuleName)) + { + return &reactos_modules[i]; + } + } + + return NULL; +} + +BOOLEAN +NTAPI +FrLdrLoadHal(PCHAR szFileName, INT nPos); + +NTSTATUS +NTAPI +LdrPEGetOrLoadModule(PCHAR ModuleName, + PCHAR ImportedName, + PLOADER_MODULE* ImportedModule) +{ + NTSTATUS Status = STATUS_SUCCESS; + + *ImportedModule = LdrGetModuleObject(ImportedName); + if (*ImportedModule == NULL) + { + /* + * For now, we only support import-loading the HAL. + * Later, FrLdrLoadDriver should be made to share the same + * code, and we'll just call it instead. + */ + if (!_stricmp(ImportedName, "hal.dll")) + { + /* Load the HAL */ + FrLdrLoadHal(szHalName, 10); + + /* Return the new module */ + *ImportedModule = LdrGetModuleObject(ImportedName); + if (*ImportedModule == NULL) + { + DbgPrint("Error loading import: %s\n", ImportedName); + return STATUS_UNSUCCESSFUL; + } + } + else + { + DbgPrint("Don't yet support loading new modules from imports\n"); + Status = STATUS_NOT_IMPLEMENTED; + } + } + + return Status; +} + +NTSTATUS +NTAPI +LdrPEFixupImports(IN PVOID DllBase, + IN PCHAR DllName) +{ + PIMAGE_IMPORT_DESCRIPTOR ImportModuleDirectory; + PCHAR ImportedName; + NTSTATUS Status; + PLOADER_MODULE ImportedModule; + ULONG Size; + + /* Process each import module */ + ImportModuleDirectory = (PIMAGE_IMPORT_DESCRIPTOR) + RtlImageDirectoryEntryToData(DllBase, + TRUE, + IMAGE_DIRECTORY_ENTRY_IMPORT, + &Size); + while (ImportModuleDirectory->Name) + { + /* Check to make sure that import lib is kernel */ + ImportedName = (PCHAR) DllBase + ImportModuleDirectory->Name; + //DbgPrint("Processing imports for file: %s into file: %s\n", DllName, ImportedName); + + Status = LdrPEGetOrLoadModule(DllName, ImportedName, &ImportedModule); + if (!NT_SUCCESS(Status)) return Status; + + //DbgPrint("Import Base: %p\n", ImportedModule->ModStart); + Status = LdrPEProcessImportDirectoryEntry(DllBase, ImportedModule, ImportModuleDirectory); + if (!NT_SUCCESS(Status)) return Status; + + //DbgPrint("Imports for file: %s into file: %s complete\n", DllName, ImportedName); + ImportModuleDirectory++; + } + + return STATUS_SUCCESS; +} + +VOID +NTAPI +FrLdrMapImage(IN PIMAGE_NT_HEADERS NtHeader, + IN PVOID Base) +{ + PIMAGE_SECTION_HEADER Section; + ULONG SectionCount, SectionSize, i; + PVOID SourceSection, TargetSection; + INT i; + + /* Load the first section */ + Section = IMAGE_FIRST_SECTION(NtHeader); + SectionCount = NtHeader->FileHeader.NumberOfSections - 1; + + /* Now go to the last section */ + Section += SectionCount; + + /* Walk each section backwards */ + for (i = SectionCount; i >= 0; i--, Section--) + { + /* Get the disk location and the memory location, and the size */ + SourceSection = RVA(Base, Section->PointerToRawData); + TargetSection = RVA(Base, Section->VirtualAddress); + SectionSize = Section->SizeOfRawData; + + /* If the section is already mapped correctly, go to the next */ + if (SourceSection == TargetSection) continue; + + /* Load it into memory */ + RtlMoveMemory(TargetSection, SourceSection, SectionSize); + + /* Check for uninitialized data */ + if (Section->SizeOfRawData < Section->Misc.VirtualSize) + { + /* Zero it out */ + RtlZeroMemory(RVA(Base, Section->VirtualAddress + + Section->SizeOfRawData), + Section->Misc.VirtualSize - Section->SizeOfRawData); + } + } +} + /*++ * FrLdrMapKernel * INTERNAL @@ -547,43 +870,18 @@ NTAPI FrLdrMapKernel(FILE *KernelImage) { - PIMAGE_DOS_HEADER ImageHeader; PIMAGE_NT_HEADERS NtHeader; - PIMAGE_SECTION_HEADER Section; - ULONG SectionCount; ULONG ImageSize; - ULONG_PTR SourceSection; - ULONG_PTR TargetSection; - ULONG SectionSize; - INT i; - PIMAGE_DATA_DIRECTORY RelocationDDir; - PIMAGE_BASE_RELOCATION RelocationDir, RelocationEnd; - ULONG Count; - ULONG_PTR Address, MaxAddress; - PUSHORT TypeOffset; - ULONG_PTR Delta; - PUSHORT ShortPtr; - PULONG LongPtr; - - /* Allocate 1024 bytes for PE Header */ - ImageHeader = (PIMAGE_DOS_HEADER)MmAllocateMemory(1024); - - /* Make sure it was succesful */ - if (ImageHeader == NULL) { - - return FALSE; - } + PVOID LoadBase; + + /* Set the virtual (image) and physical (load) addresses */ + LoadBase = (PVOID)KERNEL_BASE_PHYS; /* Load the first 1024 bytes of the kernel image so we can read the PE header */ - if (!FsReadFile(KernelImage, 1024, NULL, ImageHeader)) { - - /* Fail if we couldn't read */ - MmFreeMemory(ImageHeader); - return FALSE; - } + if (!FsReadFile(KernelImage, 1024, NULL, LoadBase)) return FALSE; /* Now read the MZ header to get the offset to the PE Header */ - NtHeader = (PIMAGE_NT_HEADERS)((PCHAR)ImageHeader + ImageHeader->e_lfanew); + NtHeader = RtlImageNtHeader(LoadBase); /* Get Kernel Base */ KernelBase = NtHeader->OptionalHeader.ImageBase; @@ -595,103 +893,22 @@ /* Save the Image Size */ ImageSize = NtHeader->OptionalHeader.SizeOfImage; - /* Free the Header */ - MmFreeMemory(ImageHeader); - /* Set the file pointer to zero */ FsSetFilePointer(KernelImage, 0); /* Load the file image */ - FsReadFile(KernelImage, ImageSize, NULL, (PVOID)KERNEL_BASE_PHYS); - - /* Reload the NT Header */ - NtHeader = (PIMAGE_NT_HEADERS)((PCHAR)KERNEL_BASE_PHYS + ImageHeader->e_lfanew); - - /* Load the first section */ - Section = IMAGE_FIRST_SECTION(NtHeader); - SectionCount = NtHeader->FileHeader.NumberOfSections - 1; - - /* Now go to the last section */ - Section += SectionCount; - - /* Walk each section backwards */ - for (i=(INT)SectionCount; i >= 0; i--, Section--) { - - /* Get the disk location and the memory location, and the size */ - SourceSection = RaToPa(Section->PointerToRawData); - TargetSection = RaToPa(Section->VirtualAddress); - SectionSize = Section->SizeOfRawData; - - /* If the section is already mapped correctly, go to the next */ - if (SourceSection == TargetSection) continue; - - /* Load it into memory */ - memmove((PVOID)TargetSection, (PVOID)SourceSection, SectionSize); - - /* Check for unitilizated data */ - if (Section->SizeOfRawData < Section->Misc.VirtualSize) { - - /* Zero it out */ - memset((PVOID)RaToPa(Section->VirtualAddress + Section->SizeOfRawData), - 0, - Section->Misc.VirtualSize - Section->SizeOfRawData); - } - } - - /* Get the Relocation Data Directory */ - RelocationDDir = &NtHeader->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_BASERELOC]; - - /* Get the Relocation Section Start and End*/ - RelocationDir = (PIMAGE_BASE_RELOCATION)(KERNEL_BASE_PHYS + RelocationDDir->VirtualAddress); - RelocationEnd = (PIMAGE_BASE_RELOCATION)((ULONG_PTR)RelocationDir + RelocationDDir->Size); + FsReadFile(KernelImage, ImageSize, NULL, LoadBase); + + /* Map it */ + FrLdrMapImage(NtHeader, LoadBase); /* Calculate Difference between Real Base and Compiled Base*/ - Delta = KernelBase - NtHeader->OptionalHeader.ImageBase; - - /* Determine how far we shoudl relocate */ - MaxAddress = KERNEL_BASE_PHYS + ImageSize; - - /* Relocate until we've processed all the blocks */ - while (RelocationDir < RelocationEnd && RelocationDir->SizeOfBlock > 0) { - - /* See how many Relocation Blocks we have */ - Count = (RelocationDir->SizeOfBlock - sizeof(IMAGE_BASE_RELOCATION)) / sizeof(USHORT); - - /* Calculate the Address of this Directory */ - Address = KERNEL_BASE_PHYS + RelocationDir->VirtualAddress; - - /* Calculate the Offset of the Type */ - TypeOffset = (PUSHORT)(RelocationDir + 1); - - for (i = 0; i < (INT)Count; i++) { - - ShortPtr = (PUSHORT)(Address + (*TypeOffset & 0xFFF)); - - switch (*TypeOffset >> 12) { - - case IMAGE_REL_BASED_ABSOLUTE: - break; - - case IMAGE_REL_BASED_HIGH: - *ShortPtr += HIWORD(Delta); - break; - - case IMAGE_REL_BASED_LOW: - *ShortPtr += LOWORD(Delta); - break; - - case IMAGE_REL_BASED_HIGHLOW: - LongPtr = (PULONG)ShortPtr; - *LongPtr += Delta; - break; - } - - TypeOffset++; - } - - /* Move to the next Relocation Table */ - RelocationDir = (PIMAGE_BASE_RELOCATION)((ULONG_PTR)RelocationDir + RelocationDir->SizeOfBlock); - } + LdrRelocateImageWithBias(LoadBase, + KernelBase - (ULONG_PTR)LoadBase, + "FreeLdr", + STATUS_SUCCESS, + STATUS_UNSUCCESSFUL, + STATUS_UNSUCCESSFUL); /* Fill out Module Data Structure */ reactos_modules[0].ModStart = KernelBase; @@ -701,7 +918,65 @@ LoaderBlock.ModsCount++; /* Increase the next Load Base */ - NextModuleBase = ROUND_UP(KERNEL_BASE_PHYS + ImageSize, PAGE_SIZE); + NextModuleBase = ROUND_UP(LoadBase + ImageSize, PAGE_SIZE); + + /* Perform import fixups */ + LdrPEFixupImports(LoadBase, "ntoskrnl.exe"); + + /* Return Success */ + return TRUE; +} + +BOOLEAN +NTAPI +FrLdrMapHal(FILE *HalImage) +{ + PIMAGE_NT_HEADERS NtHeader; + PVOID ImageBase, LoadBase; + ULONG ImageSize; + + /* Set the virtual (image) and physical (load) addresses */ + LoadBase = (PVOID)NextModuleBase; + ImageBase = RVA(LoadBase , -KERNEL_BASE_PHYS + KSEG0_BASE); + + /* Load the first 1024 bytes of the HAL image so we can read the PE header */ + if (!FsReadFile(HalImage, 1024, NULL, LoadBase)) return FALSE; + + /* Now read the MZ header to get the offset to the PE Header */ + NtHeader = RtlImageNtHeader(LoadBase); + + /* Save the Image Size */ + ImageSize = NtHeader->OptionalHeader.SizeOfImage; + + /* Set the file pointer to zero */ + FsSetFilePointer(HalImage, 0); + + /* Load the file image */ + FsReadFile(HalImage, ImageSize, NULL, LoadBase); + + /* Map it into virtual memory */ + FrLdrMapImage(NtHeader, LoadBase); + + /* Calculate Difference between Real Base and Compiled Base*/ + LdrRelocateImageWithBias(LoadBase, + (ULONG_PTR)ImageBase - (ULONG_PTR)LoadBase, + "FreeLdr", + STATUS_SUCCESS, + STATUS_UNSUCCESSFUL, + STATUS_UNSUCCESSFUL); + + /* Fill out Module Data Structure */ + reactos_modules[1].ModStart = (ULONG_PTR)ImageBase; + reactos_modules[1].ModEnd = (ULONG_PTR)ImageBase + ImageSize; + strcpy(reactos_module_strings[1], "hal.dll"); + reactos_modules[1].String = (ULONG_PTR)reactos_module_strings[1]; + LoaderBlock.ModsCount++; + + /* Perform import fixups */ + LdrPEFixupImports(LoadBase, "hal.dll"); + + /* Increase the next Load Base */ + NextModuleBase = ROUND_UP(NextModuleBase + ImageSize, PAGE_SIZE); /* Return Success */ return TRUE; @@ -750,6 +1025,8 @@ /* Move to next memory block and increase Module Count */ NextModuleBase = ROUND_UP(ModuleData->ModEnd, PAGE_SIZE); LoaderBlock.ModsCount++; +// DbgPrint("NextBase, ImageSize, ModStart, ModEnd %p %p %p %p\n", + // NextModuleBase, LocalModuleSize, ModuleData->ModStart, ModuleData->ModEnd); /* Return Module Size if required */ if (ModuleSize != NULL) { Modified: trunk/reactos/boot/freeldr/freeldr/reactos/reactos.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/react…
============================================================================== --- trunk/reactos/boot/freeldr/freeldr/reactos/reactos.c (original) +++ trunk/reactos/boot/freeldr/freeldr/reactos/reactos.c Sun Nov 19 20:53:31 2006 @@ -33,7 +33,7 @@ ARC_DISK_SIGNATURE reactos_arc_disk_info[32]; // ARC Disk Information char reactos_arc_strings[32][256]; unsigned long reactos_disk_count = 0; - + CHAR szHalName[1024]; static CHAR szLoadingMsg[] = "Loading ReactOS..."; static BOOLEAN @@ -78,6 +78,58 @@ /* Do the actual loading */ FrLdrMapKernel(FilePointer); + + /* Update Processbar and return success */ + UiDrawProgressBarCenter(nPos, 100, szLoadingMsg); + return(TRUE); +} + +BOOLEAN +NTAPI +FrLdrMapHal(FILE *KernelImage); + +BOOLEAN +NTAPI +FrLdrLoadHal(PCHAR szFileName, + INT nPos) +{ + PFILE FilePointer; + PCHAR szShortName; + CHAR szBuffer[256]; + + /* Extract Kernel filename without path */ + szShortName = strrchr(szFileName, '\\'); + if (szShortName == NULL) { + + /* No path, leave it alone */ + szShortName = szFileName; + + } else { + + /* Skip the path */ + szShortName = szShortName + 1; + } + + /* Open the Kernel */ + FilePointer = FsOpenFile(szFileName); + + /* Make sure it worked */ + if (FilePointer == NULL) { + + /* Return failure on the short name */ + strcpy(szBuffer, szShortName); + strcat(szBuffer, " not found."); + UiMessageBox(szBuffer); + return(FALSE); + } + + /* Update the status bar with the current file */ + strcpy(szBuffer, "Reading "); + strcat(szBuffer, szShortName); + UiDrawStatusText(szBuffer); + + /* Do the actual loading */ + FrLdrMapHal(FilePointer); /* Update Processbar and return success */ UiDrawProgressBarCenter(nPos, 100, szLoadingMsg); @@ -126,6 +178,7 @@ PROSSYM_INFO RosSymInfo; ULONG Size; ULONG_PTR Base; + //return TRUE; RosSymInit(&FreeldrCallbacks); @@ -569,7 +622,6 @@ CHAR value[1024]; CHAR SystemPath[1024]; CHAR szKernelName[1024]; - CHAR szHalName[1024]; CHAR szFileName[1024]; CHAR szBootPath[256]; UINT i; @@ -744,8 +796,6 @@ strcat(szKernelName, value); } - if (!FrLdrLoadKernel(szKernelName, 5)) return; - /* * Find the HAL image name * and try to load the kernel off the disk @@ -774,19 +824,9 @@ strcat(szHalName, value); } - if (!FrLdrLoadDriver(szHalName, 10)) - return; - -#if 0 - /* Load bootvid */ - strcpy(value, "INBV.DLL"); - strcpy(szHalName, szBootPath); - strcat(szHalName, "SYSTEM32\\"); - strcat(szHalName, value); - - if (!FrLdrLoadDriver(szHalName, 10)) - return; -#endif + /* Load the kernel */ + if (!FrLdrLoadKernel(szKernelName, 5)) return; + /* * Load the System hive from disk */ Modified: trunk/reactos/include/ddk/winddk.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/ddk/winddk.h?rev=2…
============================================================================== --- trunk/reactos/include/ddk/winddk.h (original) +++ trunk/reactos/include/ddk/winddk.h Sun Nov 19 20:53:31 2006 @@ -395,6 +395,7 @@ extern POBJECT_TYPE NTSYSAPI PsThreadType; extern POBJECT_TYPE NTSYSAPI LpcPortObjectType; extern POBJECT_TYPE NTSYSAPI SeTokenObjectType; +extern POBJECT_TYPE NTSYSAPI PsProcessType; #if (NTDDI_VERSION >= NTDDI_LONGHORN) extern volatile CCHAR NTSYSAPI KeNumberProcessors; Modified: trunk/reactos/include/ndk/pstypes.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/ndk/pstypes.h?rev=…
============================================================================== --- trunk/reactos/include/ndk/pstypes.h (original) +++ trunk/reactos/include/ndk/pstypes.h Sun Nov 19 20:53:31 2006 @@ -41,8 +41,8 @@ // #ifndef NTOS_MODE_USER -extern NTSYSAPI struct _EPROCESS* PsInitialSystemProcess; -extern NTSYSAPI POBJECT_TYPE PsProcessType; +//extern NTSYSAPI struct _EPROCESS* PsInitialSystemProcess; +//extern NTSYSAPI POBJECT_TYPE PsProcessType; #endif Modified: trunk/reactos/include/ndk/rtlfuncs.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/ndk/rtlfuncs.h?rev…
============================================================================== --- trunk/reactos/include/ndk/rtlfuncs.h (original) +++ trunk/reactos/include/ndk/rtlfuncs.h Sun Nov 19 20:53:31 2006 @@ -2495,7 +2495,7 @@ ULONG NTAPI DbgPrompt( - IN PCH PromptString, + IN PCCH PromptString, OUT PCH OutputString, IN ULONG OutputSize ); Modified: trunk/reactos/include/reactos/rosldr.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/reactos/rosldr.h?r…
============================================================================== --- trunk/reactos/include/reactos/rosldr.h (original) +++ trunk/reactos/include/reactos/rosldr.h Sun Nov 19 20:53:31 2006 @@ -29,14 +29,14 @@ ULONG MemLower; ULONG MemHigher; ULONG BootDevice; - ULONG CommandLine; + PCHAR CommandLine; ULONG ModsCount; - ULONG ModsAddr; + PLOADER_MODULE ModsAddr; UCHAR Syms[12]; ULONG MmapLength; ULONG MmapAddr; ULONG DrivesCount; - ULONG DrivesAddr; + PARC_DISK_SIGNATURE DrivesAddr; ULONG ConfigTable; ULONG BootLoaderName; ULONG PageDirectoryStart; Modified: trunk/reactos/ntoskrnl/ex/init.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ex/init.c?rev=247…
============================================================================== --- trunk/reactos/ntoskrnl/ex/init.c (original) +++ trunk/reactos/ntoskrnl/ex/init.c Sun Nov 19 20:53:31 2006 @@ -932,6 +932,8 @@ /* Unmap Low memory, and initialize the MPW and Balancer Thread */ MmInit3(); + extern ULONG Guard; + ASSERT(Guard == 0xCACA1234); /* Initialize VDM support */ KeI386VdmInitialize(); Modified: trunk/reactos/ntoskrnl/include/internal/ke.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/include/internal/…
============================================================================== --- trunk/reactos/ntoskrnl/include/internal/ke.h (original) +++ trunk/reactos/ntoskrnl/include/internal/ke.h Sun Nov 19 20:53:31 2006 @@ -54,9 +54,6 @@ struct _KPCR; struct _KPRCB; struct _KEXCEPTION_FRAME; - -extern ADDRESS_RANGE KeMemoryMap[64]; -extern ULONG KeMemoryMapRangeCount; extern ULONG_PTR MmFreeLdrFirstKrnlPhysAddr; extern ULONG_PTR MmFreeLdrLastKrnlPhysAddr; Modified: trunk/reactos/ntoskrnl/include/internal/ldr.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/include/internal/…
============================================================================== --- trunk/reactos/ntoskrnl/include/internal/ldr.h (original) +++ trunk/reactos/ntoskrnl/include/internal/ldr.h Sun Nov 19 20:53:31 2006 @@ -18,12 +18,6 @@ VOID NTAPI LdrLoadAutoConfigDrivers(VOID); - -VOID -NTAPI -LdrInitModuleManagement( - IN PVOID KernelBase -); NTSTATUS NTAPI @@ -70,15 +64,6 @@ PWCH Name ); -PVOID -NTAPI -LdrSafePEProcessModule( - PVOID ModuleLoadBase, - PVOID DriverBase, - PVOID ImportModuleBase, - PULONG DriverSize -); - NTSTATUS NTAPI LdrLoadModule( Modified: trunk/reactos/ntoskrnl/include/ntoskrnl.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/include/ntoskrnl.…
============================================================================== --- trunk/reactos/ntoskrnl/include/ntoskrnl.h (original) +++ trunk/reactos/ntoskrnl/include/ntoskrnl.h Sun Nov 19 20:53:31 2006 @@ -13,6 +13,8 @@ /* DDK/IFS/NDK Headers */ #include <ntifs.h> +#undef _KPROCESS +#undef _EPROCESS #include <wdmguid.h> #include <arc/arc.h> #include <ntndk.h> Modified: trunk/reactos/ntoskrnl/io/iomgr/driver.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/io/iomgr/driver.c…
============================================================================== --- trunk/reactos/ntoskrnl/io/iomgr/driver.c (original) +++ trunk/reactos/ntoskrnl/io/iomgr/driver.c Sun Nov 19 20:53:31 2006 @@ -1011,7 +1011,7 @@ } /* Loop modules again */ - NextEntry = ListHead->Flink->Flink; + NextEntry = ListHead->Flink->Flink->Flink; while (ListHead != NextEntry) { /* Get the entry */ @@ -1020,6 +1020,10 @@ InLoadOrderLinks); /* Free memory */ + DPRINT("Freeing memory at: %p of size: %lx for module: %wZ\n", + LdrEntry->DllBase, + LdrEntry->SizeOfImage, + &LdrEntry->FullDllName); MiFreeBootDriverMemory(LdrEntry->DllBase, LdrEntry->SizeOfImage); /* Go to the next driver */ Modified: trunk/reactos/ntoskrnl/kd/wrappers/gdbstub.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/kd/wrappers/gdbst…
============================================================================== --- trunk/reactos/ntoskrnl/kd/wrappers/gdbstub.c (original) +++ trunk/reactos/ntoskrnl/kd/wrappers/gdbstub.c Sun Nov 19 20:53:31 2006 @@ -1759,7 +1759,6 @@ GspEnumThread = NULL; HalDisplayString("Waiting for GDB to attach\n"); - DbgPrint("Module 'hal.dll' loaded at 0x%.08x.\n", LdrHalBase); DbgBreakPointWithStatus(DBG_STATUS_CONTROL_C); } else if (BootPhase == 2) Modified: trunk/reactos/ntoskrnl/ke/freeldr.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ke/freeldr.c?rev=…
============================================================================== --- trunk/reactos/ntoskrnl/ke/freeldr.c (original) +++ trunk/reactos/ntoskrnl/ke/freeldr.c Sun Nov 19 20:53:31 2006 @@ -14,44 +14,34 @@ /* GLOBALS *******************************************************************/ -/* FreeLDR Module Data */ -LOADER_MODULE KeLoaderModules[64]; -ULONG KeLoaderModuleCount; -static CHAR KeLoaderModuleStrings[64][256]; -static ARC_DISK_SIGNATURE KeArcDiskInfo[32]; - /* FreeLDR Memory Data */ -ADDRESS_RANGE KeMemoryMap[64]; -ULONG KeMemoryMapRangeCount; ULONG_PTR MmFreeLdrFirstKrnlPhysAddr, MmFreeLdrLastKrnlPhysAddr; ULONG_PTR MmFreeLdrLastKernelAddress; ULONG MmFreeLdrMemHigher; ULONG MmFreeLdrPageDirectoryEnd; /* FreeLDR Loader Data */ -ROS_LOADER_PARAMETER_BLOCK KeRosLoaderBlock; -static CHAR KeLoaderCommandLine[256]; +PROS_LOADER_PARAMETER_BLOCK KeRosLoaderBlock; BOOLEAN AcpiTableDetected; -/* FreeLDR PE Hack Data */ -extern LDR_DATA_TABLE_ENTRY HalModuleObject; - -/* NT Loader Data */ -LOADER_PARAMETER_BLOCK BldrLoaderBlock; -LOADER_PARAMETER_EXTENSION BldrExtensionBlock; -CHAR BldrCommandLine[256]; -CHAR BldrArcBootPath[64]; -CHAR BldrArcHalPath[64]; -CHAR BldrNtHalPath[64]; -CHAR BldrNtBootPath[64]; -LDR_DATA_TABLE_ENTRY BldrModules[64]; -MEMORY_ALLOCATION_DESCRIPTOR BldrMemoryDescriptors[64]; -WCHAR BldrModuleStrings[64][260]; -NLS_DATA_BLOCK BldrNlsDataBlock; -SETUP_LOADER_BLOCK BldrSetupBlock; -ARC_DISK_INFORMATION BldrArcDiskInfo; -CHAR BldrArcNames[32][256]; -ARC_DISK_SIGNATURE BldrDiskInfo[32]; +/* NT Loader Data. Eats up about 50KB! */ +LOADER_PARAMETER_BLOCK BldrLoaderBlock; // 0x0000 +LOADER_PARAMETER_EXTENSION BldrExtensionBlock; // 0x0060 +CHAR BldrCommandLine[256]; // 0x00DC +CHAR BldrArcBootPath[64]; // 0x01DC +CHAR BldrArcHalPath[64]; // 0x021C +CHAR BldrNtHalPath[64]; // 0x025C +CHAR BldrNtBootPath[64]; // 0x029C +LDR_DATA_TABLE_ENTRY BldrModules[64]; // 0x02DC +MEMORY_ALLOCATION_DESCRIPTOR BldrMemoryDescriptors[64]; // 0x14DC +WCHAR BldrModuleStrings[64][260]; // 0x19DC +NLS_DATA_BLOCK BldrNlsDataBlock; // 0x9BDC +SETUP_LOADER_BLOCK BldrSetupBlock; // 0x9BE8 +ARC_DISK_INFORMATION BldrArcDiskInfo; // 0x9F34 +CHAR BldrArcNames[32][256]; // 0x9F3C +ARC_DISK_SIGNATURE BldrDiskInfo[32]; // 0xBF3C + // 0xC23C +ULONG Guard = 0xCACA1234; /* FUNCTIONS *****************************************************************/ @@ -70,12 +60,12 @@ PCHAR BootPath, HalPath; CHAR CommandLine[256]; PARC_DISK_SIGNATURE RosDiskInfo, ArcDiskInfo; + PIMAGE_NT_HEADERS NtHeader; /* First get some kernel-loader globals */ AcpiTableDetected = (RosLoaderBlock->Flags & MB_FLAGS_ACPI_TABLE) ? TRUE : FALSE; MmFreeLdrMemHigher = RosLoaderBlock->MemHigher; MmFreeLdrPageDirectoryEnd = RosLoaderBlock->PageDirectoryEnd; - KeLoaderModuleCount = RosLoaderBlock->ModsCount; /* Set the NT Loader block and initialize it */ *NtLoaderBlock = LoaderBlock = &BldrLoaderBlock; @@ -97,10 +87,10 @@ InitializeListHead(&LoaderBlock->ArcDiskInformation->DiskSignatureListHead); /* Loop boot driver list */ - for (i = 0; i < KeLoaderModuleCount; i++) + for (i = 0; i < RosLoaderBlock->ModsCount; i++) { /* Get the ROS loader entry */ - RosEntry = &KeLoaderModules[i]; + RosEntry = &RosLoaderBlock->ModsAddr[i]; DriverName = (PCHAR)RosEntry->String; ModStart = (PVOID)RosEntry->ModStart; ModSize = RosEntry->ModEnd - (ULONG_PTR)ModStart; @@ -184,6 +174,38 @@ continue; } + /* Check if this is the kernel */ + if (!(_stricmp(DriverName, "ntoskrnl.exe"))) + { + /* Create an MD for it */ + MdEntry = &BldrMemoryDescriptors[i]; + MdEntry->MemoryType = LoaderSystemCode; + MdEntry->BasePage = (ULONG_PTR)ModStart >> PAGE_SHIFT; + MdEntry->PageCount = ModSize >> PAGE_SHIFT; + InsertTailList(&LoaderBlock->MemoryDescriptorListHead, + &MdEntry->ListEntry); + } + else if (!(_stricmp(DriverName, "hal.dll"))) + { + /* Create an MD for the HAL */ + MdEntry = &BldrMemoryDescriptors[i]; + MdEntry->MemoryType = LoaderHalCode; + MdEntry->BasePage = (ULONG_PTR)ModStart >> PAGE_SHIFT; + MdEntry->PageCount = ModSize >> PAGE_SHIFT; + InsertTailList(&LoaderBlock->MemoryDescriptorListHead, + &MdEntry->ListEntry); + } + else + { + /* Create an MD for any driver */ + MdEntry = &BldrMemoryDescriptors[i]; + MdEntry->MemoryType = LoaderBootDriver; + MdEntry->BasePage = (ULONG_PTR)ModStart >> PAGE_SHIFT; + MdEntry->PageCount = ModSize >> PAGE_SHIFT; + InsertTailList(&LoaderBlock->MemoryDescriptorListHead, + &MdEntry->ListEntry); + } + /* Setup the loader entry */ LdrEntry = &BldrModules[i]; RtlZeroMemory(LdrEntry, sizeof(LDR_DATA_TABLE_ENTRY)); @@ -201,6 +223,12 @@ /* Copy data from Freeldr Module Entry */ LdrEntry->DllBase = ModStart; LdrEntry->SizeOfImage = ModSize; + + /* Copy additional data */ + NtHeader = RtlImageNtHeader(ModStart); + LdrEntry->EntryPoint = RVA(ModStart, + NtHeader-> + OptionalHeader.AddressOfEntryPoint); /* Initialize other data */ LdrEntry->LoadCount = 1; @@ -211,46 +239,11 @@ /* Insert it into the loader block */ InsertTailList(&LoaderBlock->LoadOrderListHead, &LdrEntry->InLoadOrderLinks); - - /* Check if this is the kernel */ - if (!(_stricmp(DriverName, "ntoskrnl.exe"))) - { - /* Create an MD for it */ - MdEntry = &BldrMemoryDescriptors[i]; - MdEntry->MemoryType = LoaderSystemCode; - MdEntry->BasePage = (ULONG_PTR)ModStart >> PAGE_SHIFT; - MdEntry->PageCount = ModSize >> PAGE_SHIFT; - InsertTailList(&LoaderBlock->MemoryDescriptorListHead, - &MdEntry->ListEntry); - } - else if (!(_stricmp(DriverName, "hal.dll"))) - { - /* The HAL actually gets loaded somewhere else */ - ModStart = HalModuleObject.DllBase; - - /* Create an MD for the HAL */ - MdEntry = &BldrMemoryDescriptors[i]; - MdEntry->MemoryType = LoaderHalCode; - MdEntry->BasePage = (ULONG_PTR)ModStart >> PAGE_SHIFT; - MdEntry->PageCount = ModSize >> PAGE_SHIFT; - InsertTailList(&LoaderBlock->MemoryDescriptorListHead, - &MdEntry->ListEntry); - } - else - { - /* Create an MD for any driver */ - MdEntry = &BldrMemoryDescriptors[i]; - MdEntry->MemoryType = LoaderBootDriver; - MdEntry->BasePage = (ULONG_PTR)ModStart >> PAGE_SHIFT; - MdEntry->PageCount = ModSize >> PAGE_SHIFT; - InsertTailList(&LoaderBlock->MemoryDescriptorListHead, - &MdEntry->ListEntry); - } } /* Setup command line */ LoaderBlock->LoadOptions = BldrCommandLine; - strcpy(BldrCommandLine, KeLoaderCommandLine); + strcpy(BldrCommandLine, RosLoaderBlock->CommandLine); /* Setup the extension block */ LoaderBlock->Extension = &BldrExtensionBlock; @@ -299,7 +292,7 @@ for (i = 0; i < RosLoaderBlock->DrivesCount; i++) { /* Get the ROS loader entry */ - RosDiskInfo = &KeArcDiskInfo[i]; + RosDiskInfo = &RosLoaderBlock->DrivesAddr[i]; /* Get the ARC structure */ ArcDiskInfo = &BldrDiskInfo[i]; @@ -324,12 +317,7 @@ IN PROS_LOADER_PARAMETER_BLOCK LoaderBlock) { ULONG i; - ULONG size; - ULONG HalBase; - ULONG DriverBase; - ULONG DriverSize; PLOADER_PARAMETER_BLOCK NtLoaderBlock; - CHAR* s; PKTSS Tss; PKGDTENTRY TssEntry; @@ -347,126 +335,34 @@ TssEntry->HighWord.Bytes.BaseMid = (UCHAR)((ULONG_PTR)Tss >> 16); TssEntry->HighWord.Bytes.BaseHi = (UCHAR)((ULONG_PTR)Tss >> 24); - /* Copy the Loader Block Data locally since Low-Memory will be wiped */ - memcpy(&KeRosLoaderBlock, LoaderBlock, sizeof(ROS_LOADER_PARAMETER_BLOCK)); - memcpy(&KeLoaderModules[0], - (PVOID)KeRosLoaderBlock.ModsAddr, - sizeof(LOADER_MODULE) * KeRosLoaderBlock.ModsCount); - KeRosLoaderBlock.ModsAddr = (ULONG)&KeLoaderModules; - memcpy(&KeArcDiskInfo[0], - (PVOID)KeRosLoaderBlock.DrivesAddr, - sizeof(ARC_DISK_SIGNATURE) * KeRosLoaderBlock.DrivesCount); - KeRosLoaderBlock.DrivesAddr = (ULONG)&KeArcDiskInfo; - - /* Check for BIOS memory map */ - KeMemoryMapRangeCount = 0; - if (KeRosLoaderBlock.Flags & MB_FLAGS_MMAP_INFO) + /* Save pointer to ROS Block */ + KeRosLoaderBlock = LoaderBlock; + + /* Save the Base Address */ + MmSystemRangeStart = (PVOID)KeRosLoaderBlock->KernelBase; + + /* Convert every driver address to virtual memory */ + for (i = 2; i < KeRosLoaderBlock->ModsCount; i++) { - /* We have a memory map from the nice BIOS */ - size = *((PULONG)(KeRosLoaderBlock.MmapAddr - sizeof(ULONG))); - i = 0; - - /* Map it until we run out of size */ - while (i < KeRosLoaderBlock.MmapLength) - { - /* Copy into the Kernel Memory Map */ - memcpy (&KeMemoryMap[KeMemoryMapRangeCount], - (PVOID)(KeRosLoaderBlock.MmapAddr + i), - sizeof(ADDRESS_RANGE)); - - /* Increase Memory Map Count */ - KeMemoryMapRangeCount++; - - /* Increase Size */ - i += size; - } - - /* Save data */ - KeRosLoaderBlock.MmapLength = KeMemoryMapRangeCount * - sizeof(ADDRESS_RANGE); - KeRosLoaderBlock.MmapAddr = (ULONG)KeMemoryMap; + /* Subtract the base Address in Physical Memory */ + KeRosLoaderBlock->ModsAddr[i].ModStart -= 0x200000; + + /* Add the Kernel Base Address in Virtual Memory */ + KeRosLoaderBlock->ModsAddr[i].ModStart += KSEG0_BASE; + + /* Subtract the base Address in Physical Memory */ + KeRosLoaderBlock->ModsAddr[i].ModEnd -= 0x200000; + + /* Add the Kernel Base Address in Virtual Memory */ + KeRosLoaderBlock->ModsAddr[i].ModEnd += KSEG0_BASE; } - else - { - /* Nothing from BIOS */ - KeRosLoaderBlock.MmapLength = 0; - KeRosLoaderBlock.MmapAddr = (ULONG)KeMemoryMap; - } - - /* Save the Base Address */ - MmSystemRangeStart = (PVOID)KeRosLoaderBlock.KernelBase; - - /* Set the Command Line */ - strcpy(KeLoaderCommandLine, (PCHAR)LoaderBlock->CommandLine); - KeRosLoaderBlock.CommandLine = (ULONG)KeLoaderCommandLine; - - /* Create a block for each module */ - for (i = 1; i < KeRosLoaderBlock.ModsCount; i++) - { - /* Check if we have to copy the path or not */ - if ((s = strrchr((PCHAR)KeLoaderModules[i].String, '/')) != 0) - { - strcpy(KeLoaderModuleStrings[i], s + 1); - } - else - { - strcpy(KeLoaderModuleStrings[i], (PCHAR)KeLoaderModules[i].String); - } - - /* Substract the base Address in Physical Memory */ - KeLoaderModules[i].ModStart -= 0x200000; - - /* Add the Kernel Base Address in Virtual Memory */ - KeLoaderModules[i].ModStart += KSEG0_BASE; - - /* Substract the base Address in Physical Memory */ - KeLoaderModules[i].ModEnd -= 0x200000; - - /* Add the Kernel Base Address in Virtual Memory */ - KeLoaderModules[i].ModEnd += KSEG0_BASE; - - /* Select the proper String */ - KeLoaderModules[i].String = (ULONG)KeLoaderModuleStrings[i]; - } - - /* Choose last module address as the final kernel address */ - MmFreeLdrLastKernelAddress = - PAGE_ROUND_UP(KeLoaderModules[KeRosLoaderBlock.ModsCount - 1].ModEnd); - - /* Select the HAL Base */ - HalBase = KeLoaderModules[1].ModStart; - - /* Choose Driver Base */ - DriverBase = MmFreeLdrLastKernelAddress; - LdrHalBase = (ULONG_PTR)DriverBase; - - /* Initialize Module Management */ - LdrInitModuleManagement((PVOID)KeLoaderModules[0].ModStart); - - /* Load HAL.DLL with the PE Loader */ - LdrSafePEProcessModule((PVOID)HalBase, - (PVOID)DriverBase, - (PVOID)KeLoaderModules[0].ModStart, - &DriverSize); - - // - // - // HACK HACK HACK WHEN WILL YOU PEOPLE FIX FREELDR?!?!?! - // FREELDR SENDS US AN ***INVALID*** HAL PE HEADER!!! - // WE READ IT IN LdrInitModuleManagement ABOVE!!! - // WE SET .SizeOfImage TO A *GARBAGE* VALUE!!! - // - // This dirty hack fixes it, and should make symbol lookup work too. - // - HalModuleObject.SizeOfImage = RtlImageNtHeader((PVOID)HalModuleObject. - DllBase)-> - OptionalHeader.SizeOfImage; - - /* Increase the last kernel address with the size of HAL */ - MmFreeLdrLastKernelAddress += PAGE_ROUND_UP(DriverSize); - - /* Now select the final beginning and ending Kernel Addresses */ - MmFreeLdrFirstKrnlPhysAddr = KeLoaderModules[0].ModStart - + + /* Save memory manager data */ + MmFreeLdrLastKernelAddress = PAGE_ROUND_UP(KeRosLoaderBlock-> + ModsAddr[KeRosLoaderBlock-> + ModsCount - 1]. + ModEnd); + MmFreeLdrFirstKrnlPhysAddr = KeRosLoaderBlock->ModsAddr[0].ModStart - KSEG0_BASE + 0x200000; MmFreeLdrLastKrnlPhysAddr = MmFreeLdrLastKernelAddress - KSEG0_BASE + 0x200000; @@ -475,17 +371,11 @@ KeInitExceptions(); // ONCE HACK BELOW IS GONE, MOVE TO KISYSTEMSTARTUP! KeInitInterrupts(); // ROS HACK DEPRECATED SOON BY NEW HAL - /* Load the Kernel with the PE Loader */ - LdrSafePEProcessModule((PVOID)KeLoaderModules[0].ModStart, - (PVOID)KeLoaderModules[0].ModStart, - (PVOID)DriverBase, - &DriverSize); - - /* Sets up the VDM Data */ + /* Set up the VDM Data */ NtEarlyInitVdm(); /* Convert the loader block */ - KiRosFrldrLpbToNtLpb(&KeRosLoaderBlock, &NtLoaderBlock); + KiRosFrldrLpbToNtLpb(KeRosLoaderBlock, &NtLoaderBlock); /* Do general System Startup */ KiSystemStartup(NtLoaderBlock); Modified: trunk/reactos/ntoskrnl/ke/i386/kiinit.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ke/i386/kiinit.c?…
============================================================================== --- trunk/reactos/ntoskrnl/ke/i386/kiinit.c (original) +++ trunk/reactos/ntoskrnl/ke/i386/kiinit.c Sun Nov 19 20:53:31 2006 @@ -430,8 +430,8 @@ MmInit1(MmFreeLdrFirstKrnlPhysAddr, MmFreeLdrLastKrnlPhysAddr, MmFreeLdrLastKernelAddress, - (PADDRESS_RANGE)&KeMemoryMap, - KeMemoryMapRangeCount, + NULL, + 0, 4096); /* Sets up the Text Sections of the Kernel and HAL for debugging */ Modified: trunk/reactos/ntoskrnl/ldr/loader.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ldr/loader.c?rev=…
============================================================================== --- trunk/reactos/ntoskrnl/ldr/loader.c (original) +++ trunk/reactos/ntoskrnl/ldr/loader.c Sun Nov 19 20:53:31 2006 @@ -47,8 +47,6 @@ LDR_DATA_TABLE_ENTRY NtoskrnlModuleObject; LDR_DATA_TABLE_ENTRY HalModuleObject; -ULONG_PTR LdrHalBase; - /* FORWARD DECLARATIONS ******************************************************/ NTSTATUS @@ -85,7 +83,7 @@ LdrPEFixupForward ( PCHAR ForwardName ); static NTSTATUS -LdrPEFixupImports ( PLDR_DATA_TABLE_ENTRY Module ); +LdrPEFixupImports ( IN PVOID DllBase, IN PWCHAR DllName); /* FUNCTIONS *****************************************************************/ @@ -98,49 +96,48 @@ VOID INIT_FUNCTION NTAPI -LdrInit1 ( VOID ) -{ - /* Hook for KDB on initialization of the loader. */ - KDB_LOADERINIT_HOOK(&NtoskrnlModuleObject, &HalModuleObject); -} - -VOID -INIT_FUNCTION -NTAPI -LdrInitModuleManagement ( PVOID KernelBase ) -{ - PIMAGE_NT_HEADERS NtHeader; +LdrInit1(VOID) +{ + PLDR_DATA_TABLE_ENTRY HalModuleObject, NtoskrnlModuleObject, LdrEntry; /* Initialize the module list and spinlock */ InitializeListHead(&ModuleListHead); KeInitializeSpinLock(&ModuleListLock); + /* Get the NTOSKRNL Entry from the loader */ + LdrEntry = CONTAINING_RECORD(KeLoaderBlock->LoadOrderListHead.Flink, LDR_DATA_TABLE_ENTRY, InLoadOrderLinks); + /* Initialize ModuleObject for NTOSKRNL */ - RtlZeroMemory(&NtoskrnlModuleObject, sizeof(LDR_DATA_TABLE_ENTRY)); - NtoskrnlModuleObject.DllBase = (PVOID) KernelBase; - RtlInitUnicodeString(&NtoskrnlModuleObject.FullDllName, KERNEL_MODULE_NAME); - LdrpBuildModuleBaseName(&NtoskrnlModuleObject.BaseDllName, &NtoskrnlModuleObject.FullDllName); - - NtHeader = RtlImageNtHeader((PVOID)KernelBase); - NtoskrnlModuleObject.EntryPoint = (PVOID) ((ULONG_PTR) NtoskrnlModuleObject.DllBase + NtHeader->OptionalHeader.AddressOfEntryPoint); - DPRINT("ModuleObject:%08x entrypoint at %x\n", &NtoskrnlModuleObject, NtoskrnlModuleObject.EntryPoint); - NtoskrnlModuleObject.SizeOfImage = NtHeader->OptionalHeader.SizeOfImage; - - InsertTailList(&ModuleListHead, &NtoskrnlModuleObject.InLoadOrderLinks); + NtoskrnlModuleObject = ExAllocatePoolWithTag(PagedPool, + sizeof(LDR_DATA_TABLE_ENTRY), + TAG('M', 'm', 'L', 'd')); + NtoskrnlModuleObject->DllBase = LdrEntry->DllBase; + RtlInitUnicodeString(&NtoskrnlModuleObject->FullDllName, KERNEL_MODULE_NAME); + LdrpBuildModuleBaseName(&NtoskrnlModuleObject->BaseDllName, &NtoskrnlModuleObject->FullDllName); + NtoskrnlModuleObject->EntryPoint = LdrEntry->EntryPoint; + NtoskrnlModuleObject->SizeOfImage = LdrEntry->SizeOfImage; + + /* Insert it into the list */ + InsertTailList(&ModuleListHead, &NtoskrnlModuleObject->InLoadOrderLinks); + + /* Get the HAL Entry from the loader */ + LdrEntry = CONTAINING_RECORD(KeLoaderBlock->LoadOrderListHead.Flink->Flink, LDR_DATA_TABLE_ENTRY, InLoadOrderLinks); /* Initialize ModuleObject for HAL */ - RtlZeroMemory(&HalModuleObject, sizeof(LDR_DATA_TABLE_ENTRY)); - HalModuleObject.DllBase = (PVOID) LdrHalBase; - - RtlInitUnicodeString(&HalModuleObject.FullDllName, HAL_MODULE_NAME); - LdrpBuildModuleBaseName(&HalModuleObject.BaseDllName, &HalModuleObject.FullDllName); - - NtHeader = RtlImageNtHeader((PVOID)LdrHalBase); - HalModuleObject.EntryPoint = (PVOID) ((ULONG_PTR) HalModuleObject.DllBase + NtHeader->OptionalHeader.AddressOfEntryPoint); - DPRINT("ModuleObject:%08x entrypoint at %x\n", &HalModuleObject, HalModuleObject.EntryPoint); - HalModuleObject.SizeOfImage = NtHeader->OptionalHeader.SizeOfImage; - - InsertTailList(&ModuleListHead, &HalModuleObject.InLoadOrderLinks); + HalModuleObject = ExAllocatePoolWithTag(PagedPool, + sizeof(LDR_DATA_TABLE_ENTRY), + TAG('M', 'm', 'L', 'd')); + HalModuleObject->DllBase = LdrEntry->DllBase; + RtlInitUnicodeString(&HalModuleObject->FullDllName, HAL_MODULE_NAME); + LdrpBuildModuleBaseName(&HalModuleObject->BaseDllName, &HalModuleObject->FullDllName); + HalModuleObject->EntryPoint = LdrEntry->EntryPoint; + HalModuleObject->SizeOfImage = LdrEntry->SizeOfImage; + + /* Insert it into the list */ + InsertTailList(&ModuleListHead, &HalModuleObject->InLoadOrderLinks); + + /* Hook for KDB on initialization of the loader. */ + KDB_LOADERINIT_HOOK(NtoskrnlModuleObject, HalModuleObject); } NTSTATUS @@ -816,7 +813,8 @@ DPRINT("EntryPoint at %x\n", CreatedModuleObject->EntryPoint); /* Perform import fixups */ - Status = LdrPEFixupImports(CreatedModuleObject); + Status = LdrPEFixupImports(CreatedModuleObject->DllBase, + CreatedModuleObject->FullDllName.Buffer); if (!NT_SUCCESS(Status)) { // MmFreeSection(DriverBase); @@ -839,16 +837,6 @@ PageAddress = (PVOID)PAGE_ROUND_DOWN(BaseAddress); Protect = LdrLookupPageProtection(PageAddress, DriverBase, &PENtHeaders->FileHeader, PESectionHeaders); -#if 1 - /* - * FIXME: - * This driver modifies a string in the first page of the text section while initialising. - */ - if (0 == _wcsicmp(L"fireport.sys", FileName->Buffer)) - { - Protect = PAGE_EXECUTE_READWRITE; - } -#endif if (PageAddress < RVA(DriverBase, DriverSize)) { MmSetPageProtect(NULL, PageAddress, Protect); @@ -906,164 +894,6 @@ return STATUS_SUCCESS; } - -PVOID -INIT_FUNCTION -NTAPI -LdrSafePEProcessModule ( - PVOID ModuleLoadBase, - PVOID DriverBase, - PVOID ImportModuleBase, - PULONG DriverSize) -{ - unsigned int Idx; - ULONG CurrentSize; - PIMAGE_DOS_HEADER PEDosHeader; - PIMAGE_NT_HEADERS PENtHeaders; - PIMAGE_SECTION_HEADER PESectionHeaders; - NTSTATUS Status; - - ps("Processing PE Module at module base:%08lx\n", ModuleLoadBase); - - /* Get header pointers */ - PEDosHeader = (PIMAGE_DOS_HEADER) ModuleLoadBase; - PENtHeaders = RtlImageNtHeader(ModuleLoadBase); - PESectionHeaders = IMAGE_FIRST_SECTION(PENtHeaders); - CHECKPOINT; - - /* Check file magic numbers */ - if (PEDosHeader->e_magic != IMAGE_DOS_SIGNATURE) - { - return NULL; - } - if (PEDosHeader->e_lfanew == 0) - { - return NULL; - } - if (PENtHeaders->Signature != IMAGE_NT_SIGNATURE) - { - return NULL; - } - if (PENtHeaders->FileHeader.Machine != IMAGE_FILE_MACHINE_I386) - { - return NULL; - } - - ps("OptionalHdrMagic:%04x LinkVersion:%d.%d\n", - PENtHeaders->OptionalHeader.Magic, - PENtHeaders->OptionalHeader.MajorLinkerVersion, - PENtHeaders->OptionalHeader.MinorLinkerVersion); - ps("Entry Point:%08lx\n", PENtHeaders->OptionalHeader.AddressOfEntryPoint); - - /* Determine the size of the module */ - *DriverSize = PENtHeaders->OptionalHeader.SizeOfImage; - ps("DriverSize %x\n",*DriverSize); - - /* Copy headers over */ - if (DriverBase != ModuleLoadBase) - { - memcpy(DriverBase, ModuleLoadBase, PENtHeaders->OptionalHeader.SizeOfHeaders); - } - - ps("Hdr: 0x%X\n", PENtHeaders); - ps("Hdr->SizeOfHeaders: 0x%X\n", PENtHeaders->OptionalHeader.SizeOfHeaders); - ps("FileHdr->NumberOfSections: 0x%X\n", PENtHeaders->FileHeader.NumberOfSections); - - /* Ntoskrnl.exe need no relocation fixups since it is linked to run at the same - address as it is mapped */ - if (DriverBase != ModuleLoadBase) - { - CurrentSize = 0; - - /* Copy image sections into virtual section */ - for (Idx = 0; Idx < PENtHeaders->FileHeader.NumberOfSections; Idx++) - { - PIMAGE_SECTION_HEADER Section = &PESectionHeaders[Idx]; - // Copy current section into current offset of virtual section - if (Section->SizeOfRawData) - { - // ps("PESectionHeaders[Idx].VirtualAddress (%X) + DriverBase %x\n", - // PESectionHeaders[Idx].VirtualAddress, PESectionHeaders[Idx].VirtualAddress + DriverBase); - memcpy(Section->VirtualAddress + (char*)DriverBase, - Section->PointerToRawData + (char*)ModuleLoadBase, - Section->Misc.VirtualSize > Section->SizeOfRawData ? Section->SizeOfRawData : Section->Misc.VirtualSize); - } - if (Section->SizeOfRawData < Section->Misc.VirtualSize) - { - memset(Section->VirtualAddress + Section->SizeOfRawData + (char*)DriverBase, - 0, - Section->Misc.VirtualSize - Section->SizeOfRawData); - } - CurrentSize += ROUND_UP(Section->Misc.VirtualSize, - PENtHeaders->OptionalHeader.SectionAlignment); - } - - /* Perform relocation fixups */ - Status = LdrRelocateImageWithBias(DriverBase, 0, "", STATUS_SUCCESS, - STATUS_CONFLICTING_ADDRESSES, STATUS_INVALID_IMAGE_FORMAT); - - if (!NT_SUCCESS(Status)) - { - return NULL; - } - } - - /* Perform import fixups */ - Status = LdrPEFixupImports(DriverBase == ModuleLoadBase ? &NtoskrnlModuleObject : &HalModuleObject); - if (!NT_SUCCESS(Status)) - { - return NULL; - } - - /* Set the page protection for the virtual sections */ - MmSetPageProtect(NULL, DriverBase, PAGE_READONLY); - for (Idx = 0; Idx < PENtHeaders->FileHeader.NumberOfSections; Idx++) - { - ULONG Characteristics = PESectionHeaders[Idx].Characteristics; - ULONG Length; - PVOID BaseAddress; - PVOID PageAddress; - ULONG Protect; - Length = PESectionHeaders[Idx].Misc.VirtualSize; - BaseAddress = PESectionHeaders[Idx].VirtualAddress + (char*)DriverBase; - PageAddress = (PVOID)PAGE_ROUND_DOWN(BaseAddress); - - if (Characteristics & IMAGE_SCN_MEM_EXECUTE) - { - if (Characteristics & IMAGE_SCN_MEM_WRITE) - { - Protect = PAGE_EXECUTE_READWRITE; - } - else - { - Protect = PAGE_EXECUTE_READ; - } - } - else if (Characteristics & IMAGE_SCN_MEM_WRITE) - { - Protect = PAGE_READWRITE; - } - else - { - Protect = PAGE_READONLY; - } - while ((ULONG_PTR)PageAddress < (ULONG_PTR)BaseAddress + Length) - { - MmSetPageProtect(NULL, PageAddress, Protect); - PageAddress = (PVOID)((ULONG_PTR)PageAddress + PAGE_SIZE); - } - if (DriverBase == ModuleLoadBase && - Characteristics & IMAGE_SCN_CNT_UNINITIALIZED_DATA) - { - /* For ntoskrnl, we must stop after the bss section */ - break; - } - - } - - return DriverBase; -} - static PVOID LdrPEFixupForward ( PCHAR ForwardName ) { @@ -1106,7 +936,7 @@ static NTSTATUS LdrPEGetOrLoadModule ( - PLDR_DATA_TABLE_ENTRY Module, + PWCHAR ModuleName, PCHAR ImportedName, PLDR_DATA_TABLE_ENTRY* ImportedModule) { @@ -1115,20 +945,6 @@ WCHAR NameBuffer[PATH_MAX]; NTSTATUS Status = STATUS_SUCCESS; - if (0 == _stricmp(ImportedName, "ntoskrnl") || - 0 == _stricmp(ImportedName, "ntoskrnl.exe")) - { - *ImportedModule = &NtoskrnlModuleObject; - return STATUS_SUCCESS; - } - - if (0 == _stricmp(ImportedName, "hal") || - 0 == _stricmp(ImportedName, "hal.dll")) - { - *ImportedModule = &HalModuleObject; - return STATUS_SUCCESS; - } - RtlCreateUnicodeStringFromAsciiz (&DriverName, ImportedName); DPRINT("Import module: %wZ\n", &DriverName); @@ -1138,11 +954,11 @@ PWCHAR PathEnd; ULONG PathLength; - PathEnd = wcsrchr(Module->FullDllName.Buffer, L'\\'); + PathEnd = wcsrchr(ModuleName, L'\\'); if (NULL != PathEnd) { - PathLength = (PathEnd - Module->FullDllName.Buffer + 1) * sizeof(WCHAR); - RtlCopyMemory(NameBuffer, Module->FullDllName.Buffer, PathLength); + PathLength = (PathEnd - ModuleName + 1) * sizeof(WCHAR); + RtlCopyMemory(NameBuffer, ModuleName, PathLength); RtlCopyMemory(NameBuffer + (PathLength / sizeof(WCHAR)), DriverName.Buffer, DriverName.Length); NameString.Buffer = NameBuffer; NameString.MaximumLength = NameString.Length = (USHORT)PathLength + DriverName.Length; @@ -1389,7 +1205,8 @@ } static NTSTATUS -LdrPEFixupImports ( PLDR_DATA_TABLE_ENTRY Module ) +LdrPEFixupImports (IN PVOID DllBase, + IN PWCHAR DllName) { PIMAGE_IMPORT_DESCRIPTOR ImportModuleDirectory; PCHAR ImportedName; @@ -1399,31 +1216,26 @@ /* Process each import module */ ImportModuleDirectory = (PIMAGE_IMPORT_DESCRIPTOR) - RtlImageDirectoryEntryToData(Module->DllBase, + RtlImageDirectoryEntryToData(DllBase, TRUE, IMAGE_DIRECTORY_ENTRY_IMPORT, &Size); DPRINT("Processeing import directory at %p\n", ImportModuleDirectory); while (ImportModuleDirectory->Name) { - if (Module->SizeOfImage <= ImportModuleDirectory->Name) - { - DPRINT1("Invalid import directory in %wZ\n", &Module->FullDllName); - return STATUS_SECTION_NOT_IMAGE; - } - /* Check to make sure that import lib is kernel */ - ImportedName = (PCHAR) Module->DllBase + ImportModuleDirectory->Name; - - Status = LdrPEGetOrLoadModule(Module, ImportedName, &ImportedModule); + ImportedName = (PCHAR) DllBase + ImportModuleDirectory->Name; + + Status = LdrPEGetOrLoadModule(DllName, ImportedName, &ImportedModule); if (!NT_SUCCESS(Status)) { return Status; } - Status = LdrPEProcessImportDirectoryEntry(Module->DllBase, ImportedModule, ImportModuleDirectory); + Status = LdrPEProcessImportDirectoryEntry(DllBase, ImportedModule, ImportModuleDirectory); if (!NT_SUCCESS(Status)) { + while (TRUE); return Status; } Modified: trunk/reactos/ntoskrnl/mm/mm.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/mm/mm.c?rev=24778…
============================================================================== --- trunk/reactos/ntoskrnl/mm/mm.c (original) +++ trunk/reactos/ntoskrnl/mm/mm.c Sun Nov 19 20:53:31 2006 @@ -14,9 +14,6 @@ #include <internal/debug.h> /* GLOBALS *****************************************************************/ - -extern LDR_DATA_TABLE_ENTRY NtoskrnlModuleObject; -extern LDR_DATA_TABLE_ENTRY HalModuleObject; ULONG MmUserProbeAddress = 0; PVOID MmHighestUserAddress = NULL; @@ -370,38 +367,64 @@ * @implemented */ PVOID -STDCALL -MmGetSystemRoutineAddress ( - IN PUNICODE_STRING SystemRoutineName - ) -{ - PVOID ProcAddress; - ANSI_STRING AnsiRoutineName; - NTSTATUS Status; - - if(!NT_SUCCESS(RtlUnicodeStringToAnsiString(&AnsiRoutineName, - SystemRoutineName, - TRUE))) - { - return NULL; - } - - Status = LdrGetProcedureAddress(NtoskrnlModuleObject.DllBase, - &AnsiRoutineName, - 0, - &ProcAddress); - - if(!NT_SUCCESS(Status)) - { - Status = LdrGetProcedureAddress(HalModuleObject.DllBase, - &AnsiRoutineName, - 0, - &ProcAddress); - } - - RtlFreeAnsiString(&AnsiRoutineName); - - return (NT_SUCCESS(Status) ? ProcAddress : NULL); +NTAPI +MmGetSystemRoutineAddress(IN PUNICODE_STRING SystemRoutineName) +{ + PVOID ProcAddress; + ANSI_STRING AnsiRoutineName; + NTSTATUS Status; + PLIST_ENTRY NextEntry; + extern LIST_ENTRY ModuleListHead; + PLDR_DATA_TABLE_ENTRY LdrEntry; + BOOLEAN Found = FALSE; + UNICODE_STRING KernelName = RTL_CONSTANT_STRING(L"ntoskrnl.exe"); + UNICODE_STRING HalName = RTL_CONSTANT_STRING(L"hal.dll"); + + /* Convert routine to ansi name */ + Status = RtlUnicodeStringToAnsiString(&AnsiRoutineName, + SystemRoutineName, + TRUE); + if (!NT_SUCCESS(Status)) return NULL; + + /* Loop the loaded module list */ + NextEntry = ModuleListHead.Flink; + while (NextEntry != &ModuleListHead) + { + /* Get the entry */ + LdrEntry = CONTAINING_RECORD(NextEntry, + LDR_DATA_TABLE_ENTRY, + InLoadOrderLinks); + + /* Check if it's the kernel or HAL */ + if (RtlEqualUnicodeString(&KernelName, &LdrEntry->BaseDllName, TRUE)) + { + /* Found it */ + Found = TRUE; + } + else if (RtlEqualUnicodeString(&HalName, &LdrEntry->BaseDllName, TRUE)) + { + /* Found it */ + Found = TRUE; + } + + /* Check if we found a valid binary */ + if (Found) + { + /* Find the procedure name */ + Status = LdrGetProcedureAddress(LdrEntry->DllBase, + &AnsiRoutineName, + 0, + &ProcAddress); + break; + } + + /* Keep looping */ + NextEntry = NextEntry->Flink; + } + + /* Free the string and return */ + RtlFreeAnsiString(&AnsiRoutineName); + return (NT_SUCCESS(Status) ? ProcAddress : NULL); } NTSTATUS Modified: trunk/reactos/ntoskrnl/ntoskrnl.rbuild URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ntoskrnl.rbuild?r…
============================================================================== --- trunk/reactos/ntoskrnl/ntoskrnl.rbuild (original) +++ trunk/reactos/ntoskrnl/ntoskrnl.rbuild Sun Nov 19 20:53:31 2006 @@ -22,6 +22,7 @@ <library>rtl</library> <library>rossym</library> <library>string</library> + <!-- <library>kdcom</library> --> <library>wdmguid</library> <directory name="include"> <pch>ntoskrnl.h</pch>
18 years, 1 month
1
0
0
0
← Newer
1
...
20
21
22
23
24
25
26
...
33
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
Results per page:
10
25
50
100
200