I was bored, so I fixed some random forgotten test applications

svn path=/trunk/; revision=7233
This commit is contained in:
KJK::Hyperion
2003-12-25 18:30:09 +00:00
parent 08ba5babf3
commit a39dcfd091
7 changed files with 145 additions and 20 deletions
@@ -12,7 +12,7 @@ int PASCAL WinMain (HINSTANCE inst, HINSTANCE prev, LPSTR cmdline, int show)
HMODULE kernel32;
kernel32 = LoadLibrary("KERNEL32");
if (kernel32<32) {
if (kernel32 == NULL) {
fprintf(stderr,"FATAL: could not load KERNEL32!\n");
return 0;
}
@@ -1,4 +1,5 @@
#include <stdio.h>
#include <string.h>
#include <windows.h>
/* Win32 counterpart for CalcChildScroll16 is not implemented */
/* even in MS Visual C++ */
@@ -74,7 +75,7 @@ LRESULT CALLBACK WndProc2 (HWND wnd, UINT msg, WPARAM w, LPARAM l)
case WM_PAINT:
dc = BeginPaint (wnd, &ps);
sprintf(buf,"ps.rcPaint = {left = %d, top = %d, right = %d, bottom = %d}",
sprintf(buf,"ps.rcPaint = {left = %lu, top = %lu, right = %lu, bottom = %lu}",
ps.rcPaint.left,ps.rcPaint.top,ps.rcPaint.right,ps.rcPaint.bottom);
rectInfo.left = rectInfo.top = 0;
GetTextExtentPoint32 (dc, buf, strlen(buf), ((LPSIZE)&rectInfo) + 1 );
@@ -114,8 +115,8 @@ int PASCAL WinMain (HINSTANCE inst, HINSTANCE prev, LPSTR cmdline, int show)
class.cbClsExtra = 0;
class.cbWndExtra = 0;
class.hInstance = inst;
class.hIcon = LoadIcon (0, IDI_APPLICATION);
class.hCursor = LoadCursor (0, IDC_ARROW);
class.hIcon = LoadIcon (0, MAKEINTRESOURCE(IDI_APPLICATION));
class.hCursor = LoadCursor (0, MAKEINTRESOURCE(IDC_ARROW));
class.hbrBackground = GetStockObject (WHITE_BRUSH);
class.lpszMenuName = NULL;
class.lpszClassName = className;
+6 -10
View File
@@ -202,7 +202,7 @@ char*WndName(HWND hWnd,int state)
return buffer;
}
}
sprintf(buffer,"%04x",hWnd);
sprintf(buffer,"%p",hWnd);
return buffer;
}
@@ -451,7 +451,6 @@ LRESULT FAR CALLBACK _export MainWindowProc(HWND hWnd, UINT msg, WPARAM wParam,
LRESULT FAR CALLBACK _export SubWindowProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
LRESULT lResult=0;
RECT rect;
int OldState=State;
State=STATE_RECURS; Rec++;
@@ -486,19 +485,19 @@ LRESULT FAR CALLBACK _export SubClassWindowProc(HWND hWnd, UINT msg, WPARAM wPar
if (!Clicked) {
LogMessage(OldState,hWnd,msg,wParam,lParam,NULL);
if (But!=-1) {
lResult=CallWindowProc((FARPROC)wndButton[But],hWnd,msg,wParam,lParam);
lResult=CallWindowProc(wndButton[But],hWnd,msg,wParam,lParam);
if (msg==WM_LBUTTONUP) {
LogChildOrder(GetParent(hWnd));
}
}
else if (hWnd==hDialog) {
lResult=CallWindowProc((FARPROC)wndDialog,hWnd,msg,wParam,lParam);
lResult=CallWindowProc(wndDialog,hWnd,msg,wParam,lParam);
}
else if (hWnd==hSubDlg) {
lResult=CallWindowProc((FARPROC)wndSubDlg,hWnd,msg,wParam,lParam);
lResult=CallWindowProc(wndSubDlg,hWnd,msg,wParam,lParam);
}
else if (hWnd==hGroup) {
lResult=CallWindowProc((FARPROC)wndGroup,hWnd,msg,wParam,lParam);
lResult=CallWindowProc(wndGroup,hWnd,msg,wParam,lParam);
if (msg==WM_SETFOCUS) {
/* create subdialog */
if (hSubDlg) {
@@ -534,7 +533,6 @@ BOOL FAR CALLBACK _export TestDialogProc(HWND hWndDlg, UINT msg, WPARAM wParam,
BOOL bResult=0;
RECT rect;
int OldState=State;
int But=-1;
State=STATE_RECURS; Rec++;
if (!Clicked) LogMessage(OldState,hWndDlg,msg,wParam,lParam,"dlgp");
@@ -586,9 +584,7 @@ BOOL FAR CALLBACK _export TestDialogProc(HWND hWndDlg, UINT msg, WPARAM wParam,
BOOL FAR CALLBACK _export SubDialogProc(HWND hWndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
BOOL bResult=0;
RECT rect;
int OldState=State;
int But=-1;
State=STATE_RECURS; Rec++;
if (!Clicked) LogMessage(OldState,hWndDlg,msg,wParam,lParam,NULL);
@@ -622,7 +618,7 @@ BOOL AppInit(void)
wclass.cbWndExtra = 0;
wclass.hInstance = hInst;
wclass.hIcon = LoadIcon(hInst,MAKEINTRESOURCE(1));
wclass.hCursor = LoadCursor(0,IDC_ARROW);
wclass.hCursor = LoadCursor(0, MAKEINTRESOURCE(IDC_ARROW));
wclass.hbrBackground = GetStockObject(WHITE_BRUSH);
wclass.lpszMenuName = NULL;
wclass.lpszClassName = wclassname;
+3 -2
View File
@@ -1,4 +1,5 @@
#include <windows.h>
#include <string.h>
char szAppName[] = "Hello";
@@ -18,8 +19,8 @@ int PASCAL WinMain (HINSTANCE hInstance, HINSTANCE hPrevInst, LPSTR lpszCmdLine,
wndclass.cbClsExtra = 0;
wndclass.cbWndExtra = 0;
wndclass.hInstance = hInstance;
wndclass.hIcon = LoadIcon(NULL, IDI_APPLICATION);
wndclass.hCursor = LoadCursor(NULL, IDC_ARROW);
wndclass.hIcon = LoadIcon(NULL, MAKEINTRESOURCE(IDI_APPLICATION));
wndclass.hCursor = LoadCursor(NULL, MAKEINTRESOURCE(IDC_ARROW));
wndclass.hbrBackground = GetStockObject(WHITE_BRUSH);
wndclass.lpszMenuName = NULL;
wndclass.lpszClassName = szAppName;
+3 -3
View File
@@ -22,8 +22,8 @@ int PASCAL WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
wndclass.cbClsExtra = 0 ;
wndclass.cbWndExtra = 0 ;
wndclass.hInstance = hInstance ;
wndclass.hIcon = LoadIcon (NULL, IDI_APPLICATION) ;
wndclass.hCursor = LoadCursor (NULL, IDC_ARROW) ;
wndclass.hIcon = LoadIcon (NULL, MAKEINTRESOURCE(IDI_APPLICATION)) ;
wndclass.hCursor = LoadCursor (NULL, MAKEINTRESOURCE(IDC_ARROW)) ;
wndclass.hbrBackground = GetStockObject (WHITE_BRUSH) ;
wndclass.lpszMenuName = NULL ;
wndclass.lpszClassName = szAppName ;
@@ -73,7 +73,7 @@ LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
wndclass.cbWndExtra = 0 ;
wndclass.hInstance = ghInstance ;
wndclass.hIcon = NULL ;
wndclass.hCursor = LoadCursor (NULL, IDC_CROSS) ;
wndclass.hCursor = LoadCursor (NULL, MAKEINTRESOURCE(IDC_CROSS)) ;
wndclass.hbrBackground = GetStockObject (LTGRAY_BRUSH) ;
wndclass.lpszMenuName = NULL ;
wndclass.lpszClassName = clsName;
+1 -1
View File
@@ -231,7 +231,7 @@ int PASCAL WinMain (HINSTANCE inst, HINSTANCE prev, LPSTR cmdline, int show)
class.cbWndExtra = 0;
class.hInstance = inst;
class.hIcon = 0; /* Draw my own icon */
class.hCursor = LoadCursor (0, IDC_ARROW);
class.hCursor = LoadCursor (0, MAKEINTRESOURCE(IDC_ARROW));
class.hbrBackground = (HBRUSH)(COLOR_BACKGROUND + 1);
class.lpszMenuName = 0;
class.lpszClassName = AppName;
+127
View File
@@ -0,0 +1,127 @@
#define RTL_FOREACH_LIST(PLIST_HEAD__, TYPE__, FIELD__) \
{ \
PLIST_ENTRY _RTL_FOREACH_LIST_END = (PLIST_HEAD__); \
PLIST_ENTRY _RTL_FOREACH_LIST_CUR = _RTL_FOREACH_LIST_END->Flink; \
TYPE__ * _RTL_ITEM = \
CONTAINING_RECORD(_RTL_FOREACH_LIST_CUR, TYPE__, FIELD__); \
\
for \
( \
; \
_RTL_FOREACH_LIST_CUR != _RTL_FOREACH_LIST_END; \
_RTL_ITEM = CONTAINING_RECORD(_RTL_FOREACH_LIST_CUR, TYPE__, FIELD__) \
)
#define RTL_FOREACH_END }
NTSTATUS STDCALL LdrpRosTlsAction
(
IN ULONG Reason
)
{
typedef struct _LDRP_TLS_ENTRY
{
LIST_ENTRY TlsList;
PIMAGE_TLS_DIRECTORY TlsDir;
PLDR_MODULE LdrModule;
}
LDRP_TLS_ENTRY, * PLDRP_TLS_ENTRY;
static LIST_ENTRY s_leTlsList;
static SIZE_T s_nTlsImagesCount;
switch(Reason)
{
case DLL_PROCESS_ATTACH:
{
PPEB_LDR_DATA pLdr = NtCurrentPeb()->Ldr;
InitializeListHead(&s_leTlsList);
s_nTlsImagesCount = 0;
RTL_FOREACH_LIST
(
&pLdr->InLoadOrderModuleList,
LDR_MODULE,
InLoadOrderModuleList
)
{
SIZE_T nSize;
PIMAGE_TLS_DIRECTORY pitdTlsDir = RtlImageDirectoryEntryToData
(
_RTL_ITEM->BaseAddress,
TRUE,
IMAGE_DIRECTORY_ENTRY_TLS,
&nSize
);
if(pitdTlsDir == NULL || nSize < sizeof(IMAGE_TLS_DIRECTORY)) continue;
PLDRP_TLS_ENTRY plteCur =
RtlAllocateHeap(pPeb->ProcessHeap, 0, sizeof(LDRP_TLS_ENTRY));
if(plteCur == NULL) return STATUS_NO_MEMORY;
InsertTailList(&s_leTlsList, &plteCur->TlsList);
_RTL_ITEM->TlsIndex = s_nTlsImagesCount;
++ s_nTlsImagesCount; /* TODO: check for out-of-bounds index */
plteCur->LdrModule = _RTL_ITEM;
plteCur->TlsDir = pitdTlsDir;
*pitdTlsDir->AddressOfIndex = _RTL_ITEM->TlsIndex;
}
RTL_FOREACH_END;
RtlSetBits(pPeb->TlsBitmap, 0, s_nTlsImagesCount);
/* fall through */
}
case DLL_THREAD_ATTACH:
{
RTL_FOREACH_LIST(&s_leTlsList, LDRP_TLS_ENTRY, TlsList)
{
PBYTE pcTlsData;
PIMAGE_TLS_DIRECTORY pitdTlsDir = _RTL_ITEM->TlsDir;
SIZE_T nInitDataSize =
pitdTlsDir->EndAddressOfRawData - pitdTlsDir->StartAddressOfRawData;
PIMAGE_TLS_CALLBACK * pitcCallbacks =
(PIMAGE_TLS_CALLBACK *)_RTL_ITEM->TlsDir->AddressOfCallbacks;
pcTlsData = RtlAllocateHeap
(
pPeb->ProcessHeap,
0,
nInitDataSize + pitdTlsDir->SizeOfZeroFill
);
if(pcTlsData == NULL) return STATUS_NO_MEMORY;
pTeb->TlsSlots[_RTL_ITEM->LdrModule->TlsIndex] = pcTlsData;
RtlMoveMemory(pcTlsData, pitdTlsDir->StartAddressOfRawData, nInitDataSize);
RtlZeroMemory(pcTlsData + nInitDataSize, pitdTlsDir->SizeOfZeroFill);
if(pitcCallbacks)
for(; *pitcCallbacks; ++ pitcCallbacks)
(*pitcCallbacks)(_RTL_ITEM->LdrModule->BaseAddress, Reason, NULL);
}
RTL_FOREACH_END;
return STATUS_SUCCESS;
}
case DLL_THREAD_DETACH:
{
}
case DLL_PROCESS_DETACH:
{
}
default: return STATUS_SUCCESS;
}
}