summaryrefslogtreecommitdiffstats
path: root/Bachelor/Mikroprozessorsysteme2/ARM202U/SOURCE/WIN32/ARMUL/ARMULDLL.C
blob: 64305afaf760c2863c2040ece6e35591e541b5b6 (plain)
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
/***************************************************************************\
* armuldll.c                                                                *
* Copyright (C) 1995 Advanced RISC Machines Limited.  All rights reserved.  *
\***************************************************************************/

/*
 * RCS $Revision: 1.1.2.1 $
 * Checkin $Date: 1996/02/07 15:50:38 $
 * Revising $Author: jporter $
 */

#include <windows.h>
#include <stdio.h>
#include "armuldll.h"

UINT AbortRead;

BOOL WINAPI DllMain (HANDLE hDLL, DWORD dwReason, LPVOID lpReserved)
{
  switch (dwReason)
  {
    case DLL_PROCESS_ATTACH:
    {
                AbortRead = RegisterWindowMessage("ABORT_READ");
#ifdef _DEBUG
      char buf[BUFSIZE+1];
      //
      // DLL is attaching to the address space of the current process.
      //

      ghMod = hDLL;
      GetModuleFileName (NULL, (LPTSTR) buf, BUFSIZE);
      MessageBox ( GetFocus(),
                  (LPCTSTR) buf,
                  (LPCTSTR) "ARMulator DLL: Process attaching",
                  MB_OK | MB_SYSTEMMODAL);
#endif
      break;
    }

    case DLL_THREAD_ATTACH:
        {
#ifdef _DEBUG

      //
      // A new thread is being created in the current process.
      //

      MessageBox ( GetFocus(),
                  (LPCTSTR) "ARMulator DLL: Thread attaching",
                  (LPCTSTR) "",
                  MB_OK | MB_SYSTEMMODAL);
#endif
      break;
        }
    case DLL_THREAD_DETACH:
        {
#ifdef _DEBUG

      //
      // A thread is exiting cleanly.
      //

      MessageBox ( GetFocus(),
                  (LPCTSTR) "ARMulator DLL: Thread detaching",
                  (LPCTSTR) "",
                  MB_OK | MB_SYSTEMMODAL);
#endif
      break;
        }
    case DLL_PROCESS_DETACH:
        {
#ifdef _DEBUG

      //
      // The calling process is detaching the DLL from its address space.
      //
      MessageBox ( GetFocus(),
                  (LPCTSTR) "ARMulator DLL: Process detaching",
                  (LPCTSTR) "",
                  MB_OK | MB_SYSTEMMODAL );
#endif
      break;
        }
  }

return TRUE;
}


/******************************************************************************\
*
*  FUNCTION: Utils
*
*  RETURNS:  ARMulator DLL Utility functions (not exported)
*
\******************************************************************************/

void YieldControl(int nLoops)
{
        MSG Message;
        int loop = 0;

        if (PeekMessage(&Message, NULL, AbortRead,AbortRead, PM_NOREMOVE)) return;
        if (PeekMessage(&Message, NULL, WM_CLOSE,WM_CLOSE, PM_NOREMOVE)) return;
        while (loop < nLoops)
        {
                while (PeekMessage(&Message, NULL, 0,0, PM_REMOVE))
                {
                        TranslateMessage(&Message);
                        DispatchMessage(&Message);
                }
                loop++;
        }
}

void armsd_hourglass(void)
{
        YieldControl(1); // This could be Selected By Options
}